main.njk
5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
{% extends "template.sbadmin2.njk" %}
{% block content %}
<table class="table">
<thead>
<tr>
<th>Produk</th>
<th class="text-right">Sisa Kuota</th>
<th> </th>
</tr>
</thead>
<tbody>
{% for item in limitedList %}
<tr>
<td><strong>{{ item.product }}</strong></td>
<td class="text-right">{{ item.value }}</td>
<td>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#editQuotaModal" data-product="{{ item.product }}">
Edit
</button>
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#addQuotaModal" data-product="{{ item.product }}">
Tambah
</button>
<a href="{{ baseUrl }}/delete/{{ item.supplier | urlencode }}/{{ item.product | urlencode }}"
class="btn btn-danger btn-sm"
onclick="return confirm('Apakah anda yakin ingin menghapus kuota “{{ item.product }}“ pada supplier “{{ item.supplier }}“?');"
>
Hapus
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="card border-left-primary">
<div class="card-header align-items-center">
<h5 class="m0 font-weight-bold text-primary">Penambahan Produk Terlimit</h5>
</div>
<div class="card-body">
<form method="POST" action="{{ baseUrl }}/add-product">
<div class="form-group">
<label for="inputProduct">Kode Produk di Supplier</label>
<input name="product" type="text" class="form-control" id="inputProduct" aria-describedby="inputProductHelp">
<small id="inputProductHelp" class="form-text text-muted">Masukkan kode produk di supplier.</small>
</div>
<div class="form-group">
<label for="inputLimit">Batas limit</label>
<input name="newLimit" type="text" class="form-control" id="inputLimit" aria-describedby="inputLimitHelp">
<small id="inputLimitHelp" class="form-text text-muted">Masukkan batas limit.</small>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
<form method="POST" action="{{ baseUrl }}/edit-product">
<div class="modal fade" id="editQuotaModal" tabindex="-1" role="dialog" aria-labelledby="editQuotaModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editQuotaModalLabel">Edit Kuota</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="hidden" name="product" id="inputProduct" value="-999">
<div class="form-group">
<label for="inputLimit">Batas limit</label>
<input name="newLimit" type="number" class="form-control" id="inputLimit" aria-describedby="inputLimitHelp" required>
<small id="inputLimitHelp" class="form-text text-muted">Masukkan batas limit baru.</small>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" value="Simpan">
</div>
</div>
</div>
</div>
</form>
<form method="POST" action="{{ baseUrl }}/add-quota">
<div class="modal fade" id="addQuotaModal" tabindex="-1" role="dialog" aria-labelledby="addQuotaModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editQuotaModalLabel">Tambah Kuota</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="hidden" name="product" id="inputProduct">
<div class="form-group">
<label for="raiseValue">Kuota yang ingin ditambahkan</label>
<input name="raiseValue" type="number" class="form-control" id="raiseValue" aria-describedby="raiseValueHelp" required>
<small id="raiseValue" class="form-text text-muted">Masukkan tambahan kuota.</small>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" value="Simpan">
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block postScriptOnBody %}
<script>
$('#editQuotaModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var product = button.data('product');
var modal = $(this)
modal.find('.modal-title').text(`Edit Kuota ${product}`);
modal.find('.modal-body #inputProduct').val(product);
});
$('#addQuotaModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var product = button.data('product');
var modal = $(this)
modal.find('.modal-title').text(`Tambah Kuota ${product}`);
modal.find('.modal-body #inputProduct').val(product);
});
</script>
{% endblock %}