-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_item.php
638 lines (486 loc) · 37.1 KB
/
new_item.php
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
<?php
$gl_accounts = $api->get_all_gl_accounts('array');
$all_categories = getAllItemCategories();
$item_tax_types = $api->get_item_tax_types('array');
$costingMethods = $GLOBALS['costing_methods'];
$stockTypes = $GLOBALS['stock_types'];
$fresh_item = false;
$edit_stock_id = REQUEST_INPUT('edit_stock_id');
$general_info = [];
$price_info = [];
$sub_info = [];
$category_id = null;
$sub_category_list1 = [];
$sub_category_list2 = [];
if (!empty($edit_stock_id)) {
$item_info = $api->get_item_info($edit_stock_id, 'array');
$general_info = $item_info['g'];
$category_id = $general_info['category_id'];
$price_info = $item_info['p'];
$sub_info = $item_info['sub'];
$sub_category_list1 = $api->get_subcategory($category_id, false, 'array');
$sub_category_list2 = $api->get_subcategory($category_id, $sub_info['parent_sub_cat_id'], 'array');
$fresh_item = !check_usage($edit_stock_id, false);
}
function getAllItemCategories() {
$sql = (
"SELECT
sc.*,
dim.name department
FROM 0_stock_category sc
INNER JOIN 0_dimensions dim ON json_contains(sc.belongs_to_dep, json_quote(concat('', dim.id)))
WHERE sc.inactive = 0"
);
$result = db_query($sql);
$categories = [];
while ($r = db_fetch($result)) {
$categories[$r['department']][] = $r;
}
return $categories;
}
?>
<div class="kt-container kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor kt-grid--stretch">
<div class="kt-body kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor kt-grid--stretch" id="kt_body">
<div class="kt-content kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">
<div class="kt-container kt-grid__item kt-grid__item--fluid">
<div class="row">
<div class="kt-portlet">
<div class="kt-portlet__head">
<div class="kt-portlet__head-label">
<h3 class="kt-portlet__head-title">
<?= trans('ADD NEW SERVICE/ITEM') ?>
</h3>
</div>
</div>
<!--begin::Form-->
<form class="kt-form kt-form--label-right" id="item_form">
<input type="hidden" name="edit_stock_id" id="edit_stock_id"
value="<?= REQUEST_INPUT('edit_stock_id') ?>">
<h6 class="kt-portlet__head-title" style="padding: 11px 1px 0px 24px;">
<?= trans('GENERAL DETAILS') ?>:
</h6>
<hr>
<!-- Hidden Values-->
<input type="hidden" name="units" value="<?= getArrayValue($general_info, 'units') ?>">
<input type="hidden" name="dimension_id" value="<?= getArrayValue($general_info, 'dimension_id') ?>">
<input type="hidden" name="dimension2_id" value="<?= getArrayValue($general_info, 'dimension2_id') ?>">
<input type="hidden" name="inventory_account" value="<?= getArrayValue($general_info, 'inventory_account') ?>">
<input type="hidden" name="adjustment_account" value="<?= getArrayValue($general_info, 'adjustment_account') ?>">
<input type="hidden" name="wip_account" value="<?= getArrayValue($general_info, 'wip_account') ?>">
<form class="kt-form">
<div class="kt-portlet__body" style="padding: 20px !important;">
<div class="kt-portlet__body">
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('ITEM CODE') ?>:
<span>
<a href="#" onclick="generateItemCode();" style=" background: #009487;
color: #fff;
padding: 4px;
font-size: 12px;"><?= trans('Generate') ?></a>
</span>
</label>
<div class="col-lg-6">
<input type="text" id="NewStockID" name="NewStockID"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'stock_id') ?>">
</div>
<label class="col-lg-2 col-form-label"><?= trans('SERVICE CHARGE') ?>:
</label>
<div class="col-lg-2">
<input type="number" id="price" name="price" class="form-control"
placeholder=""
value="<?= getArrayValue($price_info, 'price') ?>">
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('ITEM NAME') ?>:</label>
<div class="col-lg-6">
<input type="text" id="description" name="description"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'description') ?>">
</div>
<label class="col-lg-2 col-form-label"><?= trans('GOVT BANK ACCOUNT') ?>
:</label>
<div class="col-lg-2">
<select class="form-control kt-select2 ap-select2 ap_gl_account_select"
name="govt_bank_account" id="govt_bank_account">
<?= prepareSelectOptions(
$gl_accounts,
'account_code',
'account_name',
getArrayValue($general_info, 'govt_bank_account'),
'-- select --'
) ?>
</select>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('ARABIC NAME') ?>
:</label>
<div class="col-lg-6">
<div class="input-group">
<input type="text" id="long_description" name="long_description"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'long_description') ?>">
</div>
</div>
<label class="col-lg-2 col-form-label"><?= trans('GOVT CHARGE') ?>:
</label>
<div class="col-lg-2">
<input type="number" id="govt_fee" name="govt_fee" class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'govt_fee') ?>">
<span class="error_note form-text text-muted kt-hidden">Please enter govt charge</span>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('CATEGORY') ?>:</label>
<div class="col-lg-6">
<select class="form-control kt-select2 ap-select2 ap_item_category"
name="category_id" id="category_id"
onchange="setDefaultAccounts(this, <?= intval($fresh_item) ?>)">
<option value="">-- select category --</option>
<?php foreach($all_categories as $dep => $cats): ?>
<optgroup label="<?= $dep ?>">
<?php foreach($cats as $c): ?>
<option <?= $c['category_id'] == $category_id ? 'selected' : ''?>
value="<?= $c['category_id'] ?>">
<?= $c['description'] ?>
</option>
<?php endforeach ?>
</optgroup>
<?php endforeach ?>
</select>
</div>
<label class="col-lg-2 col-form-label"><?= trans('BANK SERVICE CHARGE') ?>
:
</label>
<div class="col-lg-2">
<input type="number" id="bank_service_charge" name="bank_service_charge"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'bank_service_charge') ?>">
<span class="error_note form-text text-muted kt-hidden">Please enter bank service charge</span>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('SUB CATEGORY') ?>
1:</label>
<div class="col-lg-6">
<div class="kt-input-icon kt-input-icon--right">
<select id="sub_cat_1"
class="form-control kt-select2 ap-select2 sub_cat_1"
name="sub_cat_1">
<option value="">-- select --</option>
<!-- <?= prepareSelectOptions($sub_category_list1, 'id', 'value', getArrayValue($sub_info, 'parent_sub_cat_id')) ?> -->
</select>
</div>
</div>
<label class="col-lg-2 col-form-label"><?= trans('OTHER CHARGE') ?>:
</label>
<div class="col-lg-2">
<input type="number" id="pf_amount" name="pf_amount"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'pf_amount') ?>">
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('SUB CATEGORY') ?>
2:</label>
<div class="col-lg-6">
<div class="kt-input-icon kt-input-icon--right">
<select id="sub_cat_2"
class="form-control kt-select2 ap-select2 sub_cat_2"
name="sub_cat_2">
<?= prepareSelectOptions($sub_category_list2, 'id', 'value', getArrayValue($sub_info, 'id')) ?>
</select>
</div>
</div>
<label class="col-lg-2 col-form-label"><?= trans('LOCAL COMMISSION') ?>:
</label>
<div class="col-lg-2">
<input type="number" id="commission_loc_user" name="commission_loc_user"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'commission_loc_user') ?>">
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Recievable Benefits Acc.') ?>:</label>
<div class="col-lg-6">
<div class="kt-input-icon kt-input-icon--right">
<select id="returnable_to"
class="form-control kt-select2 ap-select2 returnable_to"
name="returnable_to">
<option value="">-- select --</option>
<?php foreach ($gl_accounts as $account): ?>
<option <?= ($general_info['returnable_to'] ?? null) == $account['account_code'] ? 'selected' : '' ?>
value="<?= $account['account_code'] ?>"><?= $account['account_name'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<label class="col-lg-2 col-form-label"><?= trans('Recievable Benefits Amt.') ?>:</label>
<div class="col-lg-2">
<input type="number"
id="returnable_amt"
name="returnable_amt"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'returnable_amt') ?>">
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Split Govt. Fee Acc.') ?>:</label>
<div class="col-lg-6">
<div class="kt-input-icon kt-input-icon--right">
<select id="split_govt_fee_acc"
class="form-control kt-select2 ap-select2 split_govt_fee_acc"
name="split_govt_fee_acc">
<option value="">-- select --</option>
<?php foreach (get_bank_accounts()->fetch_all(MYSQLI_ASSOC) as $account): ?>
<option <?= ($general_info['split_govt_fee_acc'] ?? null) == $account['id'] ? 'selected' : '' ?>
value="<?= $account['id'] ?>"><?= $account['bank_account_name'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<label class="col-lg-2 col-form-label"><?= trans('Split Govt. Fee Amt.') ?>:</label>
<div class="col-lg-2">
<input type="number"
id="split_govt_fee_amt"
name="split_govt_fee_amt"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'split_govt_fee_amt') ?>">
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Receivable Commission Account') ?>:</label>
<div class="col-lg-6">
<div class="kt-input-icon kt-input-icon--right">
<select class="form-control kt-select2 ap-select2 ap_gl_account_select"
name="receivable_commission_account" id="receivable_commission_account">
<?= prepareSelectOptions($gl_accounts, 'account_code', 'account_name',
getArrayValue($general_info, 'receivable_commission_account')) ?>
</select>
</div>
</div>
<label class="col-lg-2 col-form-label"><?= trans('Receivable Commission Amt') ?>:</label>
<div class="col-lg-2">
<input type="number"
id="receivable_commission_amount"
name="receivable_commission_amount"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'receivable_commission_amount') ?>">
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Extra Service Chg') ?>:</label>
<div class="col-lg-6">
<input type="number"
id="extra_srv_chg"
name="extra_srv_chg"
class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'extra_srv_chg') ?>">
</div>
<label class="col-lg-2 col-form-label"><?= trans('Nationality') ?>:</label>
<div class="col-lg-2">
<select
required
name="nationality"
id="nationality"
class="form-control">
<option value="">-- Select Nationality --</option>
<?php foreach (getCountriesKeyedByCode() as $code => $country): ?>
<option value="<?= $code ?>" <?= getArrayValue($general_info, 'nationality') == $code ? 'selected' : '' ?> ><?= $country['name'] ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</div>
<h6 class="kt-portlet__head-title" style="padding: 11px 1px 0px 20px;">
<?= trans('ADVANCED DETAILS') ?>:
</h6>
<input type="hidden" name="sales_type_id" value="1">
<input type="hidden" name="curr_abrev" value="AED">
<div class="kt-portlet__body" style="padding: 20px !important;">
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('ITEM TAX TYPE') ?>:</label>
<div class="col-lg-6">
<select id="tax_type_id"
class="form-control kt-select2 ap-select2 ap_item_tax_type"
name="tax_type_id">
<?= prepareSelectOptions(
$item_tax_types,
'id',
'name',
getArrayValue($general_info, 'tax_type_id'),
'-- select --'
) ?>
</select>
</div>
<label class="col-lg-2 col-form-label"><?= trans('NON-LOCAL COMMISSION:') ?>
</label>
<div class="col-lg-2">
<input type="number" id="commission_non_loc_user"
name="commission_non_loc_user" class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'commission_non_loc_user') ?>">
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('EDITABLE DESCRIPTION') ?>
:</label>
<div class="col-lg-6">
<select id="editable" class="form-control kt-selectpicker" name="editable">
<option value="0" <?= getArrayValue($general_info, 'editable') == 0 ? 'selected' : '' ?>><?= trans('NO') ?></option>
<option value="1" <?= getArrayValue($general_info, 'editable') == 1 ? 'selected' : '' ?>><?= trans('YES') ?></option>
</select>
</div>
<label class="col-lg-2 col-form-label"><?= trans('USE OWN GOVT.BANK') ?>
:</label>
<div class="col-lg-2">
<select id="use_own_govt_bank_account" class="form-control kt-selectpicker"
name="use_own_govt_bank_account">
<option value="0" <?= getArrayValue($general_info, 'use_own_govt_bank_account') == 0 ? 'selected' : '' ?>><?= trans('NO') ?></option>
<option value="1" <?= getArrayValue($general_info, 'use_own_govt_bank_account') == 1 ? 'selected' : '' ?>><?= trans('YES') ?></option>
</select>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('SALES ACCOUNT') ?>
:</label>
<div class="col-lg-6">
<select class="form-control kt-select2 ap-select2 ap_gl_account_select"
name="sales_account" id="sales_account">
<?= prepareSelectOptions($gl_accounts, 'account_code', 'account_name',
getArrayValue($general_info, 'sales_account')) ?>
</select>
</div>
<label class="col-lg-2 col-form-label"><?= trans('COGS ACCOUNT') ?>:</label>
<div class="col-lg-2">
<select class="form-control kt-select2 ap-select2 ap_gl_account_select"
name="cogs_account" id="cogs_account">
<?= prepareSelectOptions($gl_accounts, 'account_code', 'account_name',
getArrayValue($general_info, 'cogs_account')) ?>
</select>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('ITEM STATUS') ?>:</label>
<div class="col-lg-6">
<select id="inactive" class="form-control kt-selectpicker" name="inactive">
<option value="0" <?= getArrayValue($general_info, 'inactive') == 0 ? 'selected' : '' ?>><?= trans('ACTIVE') ?></option>
<option value="1" <?= getArrayValue($general_info, 'inactive') == 1 ? 'selected' : '' ?>><?= trans('INACTIVE') ?></option>
</select>
</div>
<label class="col-lg-2 col-form-label"><?= trans('VAT FOR BANK CHARGE') ?>
:
</label>
<div class="col-lg-2">
<input type="number" id="bank_service_charge_vat"
name="bank_service_charge_vat" class="form-control"
placeholder=""
value="<?= getArrayValue($general_info, 'bank_service_charge_vat') ?>">
<span class="error_note form-text text-muted kt-hidden">Please enter bank charge VAT</span>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Costing Method') ?>:</label>
<div class="<?= class_names('col-lg-6', ['inactive-control' => $fresh_item]) ?>">
<div>
<select
<?= class_names(['disabled' => $fresh_item ]) ?>
id="costing_method"
class="form-control kt-selectpicker"
name="costing_method">
<?php foreach ($costingMethods as $key => $value) { ?>
<option value="<?= $key ?>" <?= getArrayValue($general_info, 'costing_method') == $key ? 'selected' : '' ?> ><?= $value ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Item Type') ?>:</label>
<div class="<?= class_names('col-lg-6', ['inactive-control' => $fresh_item]) ?>">
<div>
<select
<?= class_names(['disabled' => $fresh_item ]) ?>
id="mb_flag"
class="form-control kt-selectpicker"
name="mb_flag" >
<?php foreach ($stockTypes as $key => $value) { ?>
<option value="<?= $key ?>" <?= getArrayValue($general_info, 'mb_flag') == $key ? 'selected' : '' ?> ><?= $value ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Exclude from sales') ?>:</label>
<div class="col-lg-6">
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
name="no_sale"
id="no_sale"
value="1"
<?php echo getArrayValue($general_info, 'no_sale') ? 'checked' : ''; ?>
>
</div>
<span class="error_message text-danger"></span>
</div>
</div>
<div class="form-group row form-group-marginless kt-margin-t-20">
<label class="col-lg-2 col-form-label"><?= trans('Exclude from purchases') ?>:</label>
<div class="col-lg-6">
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
name="no_purchase"
id="no_purchase"
value="1"
<?php echo getArrayValue($general_info, 'no_purchase') ? 'checked' : ''; ?>
>
</div>
<span class="error_message text-danger"></span>
</div>
</div>
</div>
<div class="kt-portlet__foot">
<div class="kt-form__actions">
<div class="row">
<div class="col-lg-4"></div>
<div class="col-lg-8">
<button type="button" onclick="CreateNewItem();"
class="btn btn-primary">
<?= trans('Submit') ?>
</button>
<button
type="button"
onclick="goBack()"
class="btn btn-secondary"><?= trans('Cancel') ?></button>
</div>
</div>
</div>
</div>
</form>
<!--end::Form-->
</div>
</div>
</div>
<!-- end:: Content -->
</div>
</div>
</div>