source: app/templates/fakturi_edit_form.html

Last change on this file was 3d7fc00, checked in by Aleksandar <zaredite@…>, 15 months ago

Initial Commit

  • Property mode set to 100644
File size: 5.7 KB
RevLine 
[3d7fc00]1{% extends 'index.html' %}
2{% block content %}
3
4<div class="container" style="margin-top: 20px;">
5 <a class="btn btn-primary" href="{% url 'fakturi' %}">Назад</a>
6 <form method="POST" id="form">
7 {% csrf_token %}
8 <div class="row mt-2">
9 <div class="col-2 form-floating">
10 <input class="stavkaid" type="hidden" name="stavka" value="{{ stavka.stavkaid }}">
11 <input type="text" class="form-control" id="broj" name="broj" placeholder="Broj" value="{{ stavka.broj }}">
12 <label for="broj">Број</label>
13 </div>
14 <div class="col-8 form-floating">
15 <input class="klientid" type="hidden" name="klient" value="{{ stavka.klientid.klientid }}">
16 <input type="text" class="form-control" id="klient" placeholder="Klient" value="{{ stavka.klientid }}">
17 <label for="klient">Клиент</label>
18 </div>
19 <div class="col-2 form-floating">
20 <input type="date" class="form-control" id="datum" name="datum" placeholder="Datum" value="{{ stavka.datum|date:'Y-m-d' }}">
21 <label for="datum">Датум</label>
22 </div>
23 </div>
24
25 <table class="table table-striped table-hover">
26 <thead>
27 <tr>
28 <th scope="col">#</th>
29 <th scope="col">Артикл</th>
30 <th scope="col">Количина</th>
31 <th scope="col">ДДВ (%)</th>
32 <th scope="col">Цена Без ДДВ</th>
33 <th scope="col">Цена со ДДВ</th>
34 </tr>
35 </thead>
36 <tbody class="table-group-divider">
37 {% for artikl in artikli %}
38 <tr>
39 <input class="lagerlist" type="hidden" name="lagerlist_id" value="{{ artikl.lagerlist_id }}">
40 <input class="id" type="hidden" name="id" value="{{ artikl.artikal.artikal_id }}">
41 <td scope="col">
42 <input type="text" value="{{ artikl.artikal.sifra }}" class="form-control sifra">
43 </td>
44 <td scope="col" class="col-md-6">
45 <input type="text" value="{{ artikl.artikal.artikal_ime }}" class="form-control artikl">
46 </td>
47 <td scope="col">
48 <input type="text" value="{{ artikl.kolicina }}" name="kol" class="form-control kol">
49 </td>
50 <td scope="col">
51 <input type="text" value="{{ artikl.artikal.ddvid }}" class="form-control ddv">
52 </td>
53 <td scope="col">
54 <input type="text" value="{{ artikl.artikal.cena }}" name="cenabezddv" class="form-control cenabezddv">
55 </td>
56 <td scope="col">
57 <input type="text" value="{{ artikl.artikal.cenasoddv }}" name="cenasoddv" class="form-control cenasoddv">
58 </td>
59 <td scope="col" class="del-row" style="cursor: pointer; vertical-align: middle;">
60 X
61 </td>
62 </tr>
63 {% endfor %}
64 </tbody>
65 </table>
66 <div class="d-flex">
67 <a class="btn btn-primary" id="new">Нов Артикл</a>
68 <button type="submit" class="btn btn-primary d-flex ms-auto">Зачувај</button>
69 </div>
70 </form>
71</div>
72
73<script>
74 $(function() {
75 var artikli_items = [
76 {% for item in items %}
77 { value: "{{ item }}", id:"{{ item.artikal_id }}", sifra: "{{ item.sifra }}", ddv: "{{ item.ddvid }}", cenabezddv: "{{ item.cena }}", cenasoddv: "{{ item.cenasoddv }}"},
78 {% endfor %}
79 ];
80
81 $(".artikl").autocomplete({
82 source: artikli_items,
83 select: function(event, ui) {
84 $(this).parent().parent().find(".id").attr("value", ui.item.id);
85 $(this).parent().parent().find(".sifra").val(ui.item.sifra);
86 $(this).parent().parent().find(".ddv").val(ui.item.ddv);
87 $(this).parent().parent().find(".cenabezddv").val(ui.item.cenabezddv);
88 $(this).parent().parent().find(".cenasoddv").val(ui.item.cenasoddv);
89 }
90 });
91
92 var klienti_items = [
93 {% for klient in klienti %}
94 { value: "{{ klient }}", id: "{{ klient.klientid }}"},
95 {% endfor %}
96 ];
97
98 $("#klient").autocomplete({
99 source: klienti_items,
100 select: function(event, ui) {
101 $(this).parent().parent().find(".klientid").attr("value", ui.item.id);
102 }
103 });
104
105 $('#new').click(function(){
106 var row = $(".table tr:last").clone();
107 $(".table").append(row);
108 row.find("input").val("");
109 row.find(".artikl").autocomplete({
110 source: artikli_items,
111 select: function(event, ui) {
112 $(this).parent().parent().find(".id").attr("value", ui.item.id);
113 $(this).parent().parent().find(".sifra").val(ui.item.sifra);
114 $(this).parent().parent().find(".ddv").val(ui.item.ddv);
115 $(this).parent().parent().find(".cenabezddv").val(ui.item.cenabezddv);
116 $(this).parent().parent().find(".cenasoddv").val(ui.item.cenasoddv);
117 }
118 });
119 });
120
121 $('.del-row').click(function(){
122 $(this).closest('tr').remove();
123 });
124 });
125</script>
126
127{% endblock %}
Note: See TracBrowser for help on using the repository browser.