source: app/templates/fakturi_new_form.html@ 3d7fc00

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

Initial Commit

  • Property mode set to 100644
File size: 4.9 KB
Line 
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 type="text" class="form-control" id="broj" name="broj" placeholder="Broj">
11 <label for="broj">Број</label>
12 </div>
13 <div class="col-8 form-floating">
14 <input class="klientid" type="hidden" name="klient" value="{{ stavka.klientid.klientid }}">
15 <input type="text" class="form-control" id="klient" placeholder="Klient">
16 <label for="klient">Клиент</label>
17 </div>
18 <div class="col-2 form-floating">
19 <input type="date" class="form-control" id="datum" name="datum" placeholder="Datum" value="{{ stavka.datum|date:'Y-m-d' }}">
20 <label for="datum">Датум</label>
21 </div>
22 </div>
23
24 <table class="table table-striped table-hover">
25 <thead>
26 <tr>
27 <th scope="col">#</th>
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 </tr>
34 </thead>
35 <tbody class="table-group-divider">
36 <tr class="artikl_row">
37 <input class="id" type="hidden" name="id">
38 <td scope="col">
39 <input type="text" class="form-control sifra">
40 </td>
41 <td scope="col" class="col-md-6">
42 <input type="text" class="form-control artikl">
43 </td>
44 <td scope="col">
45 <input type="text" name="kol" class="form-control kol">
46 </td>
47 <td scope="col">
48 <input type="text" class="form-control ddv">
49 </td>
50 <td scope="col">
51 <input type="text" name="cenabezddv" class="form-control cenabezddv">
52 </td>
53 <td scope="col">
54 <input type="text" name="cenasoddv" class="form-control cenasoddv">
55 </td>
56 </tr>
57 </tbody>
58 </table>
59 <div class="d-flex">
60 <a class="btn btn-primary" id="new">Нов Артикл</a>
61 <button type="submit" class="btn btn-primary d-flex ms-auto">Зачувај</button>
62 </div>
63 </form>
64</div>
65
66<script>
67 $(function() {
68 var artikli_items = [
69 {% for item in items %}
70 { value: "{{ item }}", id:"{{ item.artikal_id }}", sifra: "{{ item.sifra }}", ddv: "{{ item.ddvid }}", cenabezddv: "{{ item.cena }}", cenasoddv: "{{ item.cenasoddv }}"},
71 {% endfor %}
72 ];
73
74 $(".artikl").autocomplete({
75 source: artikli_items,
76 select: function(event, ui) {
77 $(this).parent().parent().find(".id").attr("value", ui.item.id);
78 $(this).parent().parent().find(".sifra").val(ui.item.sifra);
79 $(this).parent().parent().find(".ddv").val(ui.item.ddv);
80 $(this).parent().parent().find(".cenabezddv").val(ui.item.cenabezddv);
81 $(this).parent().parent().find(".cenasoddv").val(ui.item.cenasoddv);
82 }
83 });
84
85 var klienti_items = [
86 {% for klient in klienti %}
87 { value: "{{ klient }}", id: "{{ klient.klientid }}"},
88 {% endfor %}
89 ];
90
91 $("#klient").autocomplete({
92 source: klienti_items,
93 select: function(event, ui) {
94 $(this).parent().parent().find(".klientid").attr("value", ui.item.id);
95 }
96 });
97
98 $('#new').click(function(){
99 var row = $(".table tr:last").clone();
100 $(".table").append(row);
101 row.find("input").val("");
102 row.find(".artikl").autocomplete({
103 source: artikli_items,
104 select: function(event, ui) {
105 $(this).parent().parent().find(".id").attr("value", ui.item.id);
106 $(this).parent().parent().find(".sifra").val(ui.item.sifra);
107 $(this).parent().parent().find(".ddv").val(ui.item.ddv);
108 $(this).parent().parent().find(".cenabezddv").val(ui.item.cenabezddv);
109 $(this).parent().parent().find(".cenasoddv").val(ui.item.cenasoddv);
110 }
111 });
112 });
113 });
114</script>
115
116{% endblock %}
Note: See TracBrowser for help on using the repository browser.