main.njk
8.38 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
{% extends "template.sbadmin2.njk" %}
{% block content %}
<table class="table">
<thead>
<tr>
<th style="white-space: nowrap; width: 1%;">Produk</th>
<th class="text-right">Sisa</th>
<th style="white-space: nowrap; width: 1%;"> </th>
</tr>
</thead>
<tbody>
{% for item in limitedList %}
<tr>
<td style="white-space: nowrap; width: 1%;">
<strong>{{ item.product }}</strong>
</td>
<td class="text-right">
{% set maxValue = maxValues[item.product] %}
{% if maxValue %}
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: {{ 100 * item.value / (maxValue or item.value) }}%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="{{ maxValue }}"></div>
</div>
<br>
{% endif %}
<a href="#" title="klik untuk edit nilai maksimal pada grafik indikator" data-toggle="modal" data-target="#editMaxValueModal" data-product="{{ item.product }}" data-maxvalue="{{ maxValue or item.value }}">
{{ item.value }}
{% if maxValue %} dari {{ maxValue }} {% endif %}
</a>
</td>
<td style="white-space: nowrap; width: 1%;">
<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>
<form method="POST" action="{{ baseUrl }}/edit-max-value-for-indicator">
<div class="modal fade" id="editMaxValueModal" tabindex="-1" role="dialog" aria-labelledby="editMaxValueModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editMaxValueModalLabel">Edit nilai maksimal pada indikator</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">Nilai maksimal</label>
<input name="maxValue" type="number" class="form-control" id="maxValue" aria-describedby="maxValueHelp" required>
<small id="maxValueHelp" class="form-text text-muted">Masukkan nilai maksimal (untuk tampilan grafik).</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);
});
$('#editMaxValueModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var product = button.data('product');
var maxvalue = button.data('maxvalue');
var modal = $(this)
modal.find('.modal-title').text(`Edit nilai maksimal ${product}`);
modal.find('.modal-body #inputProduct').val(product);
modal.find('.modal-body #maxValue').val(maxvalue);
});
</script>
{% endblock %}