-
Notifications
You must be signed in to change notification settings - Fork 3
/
supp-edit.php
executable file
·1317 lines (1194 loc) · 41.8 KB
/
supp-edit.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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?
#This program is copyright by Andre Coetzee email: ac@main.me
#and is licensed under the GPL v3
#
#
#
#
#Please add yourself to: http://www.accounting-123.com
#Developers, Software Vendors, Support, Accountants, Users
#
#
#The full software license can be found here:
#http://www.accounting-123.com/a.php?a=153/GPLv3
#
#
#
#
#
#
#
#
#
#
#
# Get settings
require ("settings.php");
# Decide what to do
if (isset($_POST["key"])) {
switch ($_POST["key"]) {
case "confirm":
$OUTPUT = confirm($_POST);
break;
case "write":
$OUTPUT = write($_POST);
break;
case "doc_save":
$OUTPUT = doc_save();
break;
default:
if (isset($_GET['supid'])){
$OUTPUT = edit ($_GET['supid']);
} else {
$OUTPUT = "<li> - Invalid use of module</li>";
}
}
} else {
if (isset($_GET['supid'])){
$OUTPUT = edit ($_GET['supid']);
} else {
$OUTPUT = "<li> - Invalid use of module.</li>";
}
}
# display output
require ("template.php");
function edit($supid, $err="")
{
# validate input
require_lib("validate");
$v = new validate ();
$v->isOk ($supid, "num", 1, 50, "Invalid supplier id.");
# display errors, if any
if ($v->isError ()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>-".$e["msg"]."</li>";
}
return $confirm;
}
# Select
db_connect();
$sql = "SELECT * FROM suppliers WHERE supid = '$supid' AND div = '".USER_DIV."'";
$suppRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
if(pg_numrows($suppRslt) < 1){
return "<li> Invalid supplier ID.</li>";
}else{
$supp = pg_fetch_array($suppRslt);
# get vars
extract ($supp);
}
# Departments
db_conn("exten");
$depts = "<select name='deptid'>";
$sql = "SELECT * FROM departments WHERE div = '".USER_DIV."' ORDER BY deptname ASC";
$deptRslt = db_exec($sql);
if(pg_numrows($deptRslt) < 1){
return "<li>There are no Price lists in Cubit.</li>";
}else{
while($dept = pg_fetch_array($deptRslt)){
if($dept['deptid'] == $deptid){
$sel = "selected";
}else{
$sel = "";
}
$depts .= "<option value='$dept[deptid]' $sel>$dept[deptname]</option>";
}
}
$depts .= "</select>";
# Get Pricelists
$pricelists = "<select name='listid' style='width: 120'>";
$sql = "SELECT * FROM spricelist WHERE div = '".USER_DIV."' ORDER BY listname ASC";
$listRslt = db_exec($sql);
if(pg_numrows($listRslt) < 1){
return "<li>There are no Price lists in Cubit.</li>";
}else{
while($list = pg_fetch_array($listRslt)){
if($list['listid'] == $listid){
$sel = "selected";
}else{
$sel = "";
}
$pricelists .= "<option value='$list[listid]' $sel>$list[listname]</option>";
}
}
$pricelists .= "</select>";
db_connect();
# Locations drop down
$locs = array("loc"=>"Local", "int"=>"International");
$locsel = extlib_cpsel("loc", $locs, $location);
# Currency drop down
$currsel = ext_unddbsel("fcid", "currency", "fcid", "descrip", "There are is no currency found in Cubit, please add currency first.", $fcid);
if(isset($bee_status) AND ($bee_status == "no")){
$sel1 = "";
$sel2 = "checked=yes";
}else {
$sel1 = "checked=yes";
$sel2 = "";
}
$get_grp = "SELECT * FROM supp_grpowners WHERE supid = '$supid' LIMIT 1";
$run_grp = db_exec($get_grp) or errDie("Unable to get supplier group information.");
if(pg_numrows($run_grp) < 1){
$supp_grp = "0";
}else {
$sarr = pg_fetch_array($run_grp);
$supp_grp = $sarr['grpid'];
}
//Get supplier groups
$get_grps = "SELECT * FROM supp_groups ORDER BY groupname";
$run_grps = db_exec($get_grps) or errDie("Unable to get supplier group information.");
if(pg_numrows($run_grps) < 1){
return "Unable to get supplier group information. Please add a supplier group.";
}else {
$supp_grpdrop = "<select name='supp_grp'>";
while ($garr = pg_fetch_array($run_grps)){
if($garr['id'] == $supp_grp){
$supp_grpdrop .= "<option value='$garr[id]' selected>$garr[groupname]</option>";
}else {
$supp_grpdrop .= "<option value='$garr[id]'>$garr[groupname]</option>";
}
}
$supp_grpdrop .= "</select>";
}
// Retrieve teams
$sql = "SELECT * FROM crm.teams ORDER BY name ASC";
$team_rslt = db_exec($sql) or errDie("Unable to retrieve teams.");
$team_sel = "<select name='team_id'>";
$team_sel.= "<option value='0'>[None]</option>";
while ($team_data = pg_fetch_array($team_rslt)) {
if ($team_id == $team_data["id"]) {
$sel = "selected";
} else {
$sel = "";
}
$team_sel .= "<option value='$team_data[id]' $sel>$team_data[name]</option>";
}
$team_sel .= "</select>";
$setdayssel1 = "";
$setdayssel2 = "";
$setdayssel3 = "";
$setdayssel4 = "";
$setdayssel5 = "";
if(isset($setdays) AND $setdays == "0")
$setdayssel1 = "selected";
if(isset($setdays) AND $setdays == "1")
$setdayssel2 = "selected";
if(isset($setdays) AND $setdays == "7")
$setdayssel3 = "selected";
if(isset($setdays) AND $setdays == "15")
$setdayssel4 = "selected";
if(isset($setdays) AND $setdays == "25")
$setdayssel5 = "selected";
$setdays_drop = "
<select name='setdays'>
<option $setdayssel1 value='0'>Last Day Of The Month</option>
<option $setdayssel2 value='1'>1st Day Of The Month</option>
<option $setdayssel3 value='7'>7th Of The Month</option>
<option $setdayssel4 value='15'>15th Of The Month</option>
<option $setdayssel5 value='25'>25th Of The Month</option>
<option $setdayssel6 value='60'>End Of Next Month</option>
</select>";
if ($supid != 0){
db_connect ();
#get 1 lower cusnum
$get_prev = "SELECT supid FROM suppliers WHERE supid < '$supid' ORDER BY supid DESC LIMIT 1";
$run_prev = db_exec($get_prev) or errDie ("Unable to get previous supplier information.");
if (pg_numrows($run_prev) > 0){
$back_supid = pg_fetch_result ($run_prev,0,0);
$show_back_button = "<input type='button' onClick=\"document.location='supp-edit.php?supid=$back_supid';\" value='View Previous Supplier'>";
}
$get_next = "SELECT supid FROM suppliers WHERE supid > '$supid' ORDER BY supid ASC LIMIT 1";
$run_next = db_exec($get_next) or errDie ("Unable to get next supplier information.");
if (pg_numrows($run_next) > 0){
$next_supid = pg_fetch_result ($run_next,0,0);
$show_next_button = "<input type='button' onClick=\"document.location='supp-edit.php?supid=$next_supid';\" value='View Next Supplier'>";
}
$showbuttons = "$show_back_button $show_next_button <br><br>";
}
//<input type='button' onClick=\"popupSized('contact-entry-new.php?type=supplier&sup=$supid','Add Additional Contact','880','580')\" value='Add Additional Contact'>
//http://127.0.0.1/cubit3.33/conper-add.php?type=supp&id=2
$enter = "
$showbuttons
<form action='".SELF."' method='POST'>
$err
<input type='hidden' name='key' value='confirm'>
<input type='hidden' name='supid' value='$supid'>
<table cellpadding=0 cellspacing=0>
<tr valign='top'>
<td>
<table ".TMPL_tblDflts.">
<tr>
<th colspan='2'>Supplier Details</th>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Department</td>
<td>$depts</td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Supplier No</td>
<td><input type='text' size='10' name='supno' value='$supno'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Supplier/Name</td>
<td><input type='text' size='20' name='supname' value='$supname'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Registration/ID</td>
<td><input type='text' size='20' name='registration' value='$registration'></td>
</tr>
<tr class='".bg_class()."'>
<td>Branch</td>
<td><input type='text' size='20' name='branch' value='$branch'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Type</td>
<td>$locsel</td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Currency</td>
<td>$currsel</td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ." VAT Number</td>
<td><input type='text' size='21' name='vatnum' value='$vatnum'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ." Address</td>
<td><textarea name='supaddr' rows='5' cols='18'>$supaddr</textarea></td>
</tr>
<tr class='".bg_class()."'>
<td>Postal Address</td>
<td><textarea name='suppostaddr' rows='5' cols='18'>$suppostaddr</textarea></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Contact Name</td>
<td>
<input type='text' size='20' name='contname' value='$contname'>
<input type='button' onClick=\"popupSized('conper-add.php?type=supp&id=$supid','Add Additional Contact','880','580')\" value='Add Additional Contact'>
</td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Tel No.</td>
<td><input type='text' size='20' name='tel' value='$tel'></td>
</tr>
<tr class='".bg_class()."'>
<td>Fax No.</td>
<td><input type='text' size='20' name='fax' value='$fax'></td>
</tr>
<tr class='".bg_class()."'>
<td>Cell No.</td>
<td><input type='text' size='20' name='cell' value='$cell'></td>
</tr>
<tr class='".bg_class()."'>
<td>E-mail</td>
<td><input type='text' size='20' name='email' value='$email'></td>
</tr>
<tr class='".bg_class()."'>
<td>Web Address</td>
<td>http://<input type='text' size='30' name='url' value='$url'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Price List</td>
<td>$pricelists</td>
</tr>
<tr class='".bg_class()."'>
<td>Supplier Group</td>
<td>$supp_grpdrop</td>
</tr>
<tr class='".bg_class()."'>
<td>Status BEE</td>
<td>Yes <input type='radio' name='bee_status' value='yes' $sel1> No <input type='radio' name='bee_status' value='no' $sel2></td>
</tr>
<tr class='".bg_class()."'>
<td>Team Permissions</td>
<td>$team_sel</td>
</tr>
</table>
</td>
<td>
<table ".TMPL_tblDflts.">
<tr class='".bg_class()."'>
<th colspan='2'> Bank Details</th>
</tr>
<tr class='".bg_class()."'>
<td>Bank </td>
<td><input type='text' size='20' name='bankname' value='$bankname'></td>
</tr>
<tr class='".bg_class()."'>
<td>Branch</td>
<td><input type='text' size='20' name='branname' value='$branname'></td>
</tr>
<tr class='".bg_class()."'>
<td>Branch Code</td>
<td><input type='text' size='20' name='brancode' value='$brancode'></td>
</tr>
<tr class='".bg_class()."'>
<td>Account Name</td>
<td><input type='text' size='20' name='bankaccname' value='$bankaccname'></td>
</tr>
<tr class='".bg_class()."'>
<td>Account Type</td>
<td><input type='text' size='20' name='bankacctype' value='$bankacctype'></td>
</tr>
<tr class='".bg_class()."'>
<td>Account Number</td>
<td><input type='text' size='20' name='bankaccno' value='$bankaccno'></td>
</tr>
<tr class='".bg_class()."'>
<td>Reference</td>
<td><input type='text' size='20' name='reference' value='$reference'></td>
</tr>
<tr class='".bg_class()."'>
<td>Settlement Discount %</td>
<td><input type='text' name='setdisc' value='$setdisc'></td>
</tr>
<tr class='".bg_class()."'>
<td>Statement Day</td>
<td>$setdays_drop</td>
</tr>
<tr class='".bg_class()."'>
<td>Comments</td>
<td><textarea name='comments' rows='5' cols='18'>$comments</textarea></td>
</tr>
<tr>
<td colspan='2' align='right'><input type='submit' value='Confirm »'></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td colspan='2' align='right'>
<table border='0' cellpadding='2' cellspacing='1'>
<tr>
<th>Quick Links</th>
</tr>
<tr class='".bg_class()."'>
<td><a href='supp-view.php'>View Suppliers</a></td>
</tr>
<tr class='".bg_class()."'>
<td><a href='main.php'>Main Menu</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>";
return $enter;
}
# error func
function edit_err ($_POST, $err="")
{
# get vars
extract ($_POST);
# Departments
db_conn("exten");
$depts = "<select name='deptid'>";
$sql = "SELECT * FROM departments WHERE div = '".USER_DIV."' ORDER BY deptname ASC";
$deptRslt = db_exec($sql);
if(pg_numrows($deptRslt) < 1){
return "<li>There are no Price lists in Cubit.</li>";
}else{
while($dept = pg_fetch_array($deptRslt)){
if($dept['deptid'] == $deptid){
$sel = "selected";
}else{
$sel = "";
}
$depts .= "<option value='$dept[deptid]' $sel>$dept[deptname]</option>";
}
}
$depts .= "</select>";
# Get Pricelists
$pricelists = "<select name='listid' style='width: 120'>";
$sql = "SELECT * FROM spricelist WHERE div = '".USER_DIV."' ORDER BY listname ASC";
$listRslt = db_exec($sql);
if(pg_numrows($listRslt) < 1){
return "<li>There are no Price lists in Cubit.</li>";
}else{
while($list = pg_fetch_array($listRslt)){
if($list['listid'] == $listid){
$sel = "selected";
}else{
$sel = "";
}
$pricelists .= "<option value='$list[listid]' $sel>$list[listname]</option>";
}
}
$pricelists .= "</select>";
db_connect();
if(!isset($location)) {
$location = "";
}
# Locations drop down
$locs = array("loc"=>"Local", "int"=>"International");
$locsel = extlib_cpsel("loc", $locs, $location);
# Currency drop down
$currsel = ext_unddbsel("fcid", "currency", "fcid", "descrip", "There are is no currency found in Cubit, please add currency first.", $fcid);
if(isset($bee_status) AND ($bee_status == "no")){
$sel1 = "";
$sel2 = "checked=yes";
}else {
$sel1 = "checked=yes";
$sel2 = "";
}
//Get supplier groups
$get_grps = "SELECT * FROM supp_groups ORDER BY groupname";
$run_grps = db_exec($get_grps) or errDie("Unable to get supplier group information.");
if(pg_numrows($run_grps) < 1){
return "Unable to get supplier group information. Please add a supplier group.";
}else {
$supp_grpdrop = "<select name='supp_grp'>";
while ($garr = pg_fetch_array($run_grps)){
if($garr['id'] == $supp_grp){
$supp_grpdrop .= "<option value='$garr[id]' selected>$garr[groupname]</option>";
}else {
$supp_grpdrop .= "<option value='$garr[id]'>$garr[groupname]</option>";
}
}
$supp_grpdrop .= "</select>";
}
// Retrieve teams
$sql = "SELECT * FROM crm.teams WHERE id = '$team_id' LIMIT 1";
$team_rslt = db_exec($sql) or errDie("Unable to retrieve teams.");
$team_data = pg_fetch_array($team_rslt);
$team_sel = "$team_data[name]";
if(!isset($team_sel))
$team_sel = "";
$setdayssel1 = "";
$setdayssel2 = "";
$setdayssel3 = "";
$setdayssel4 = "";
$setdayssel5 = "";
if(isset($setdays) AND $setdays == "0")
$setdayssel1 = "selected";
if(isset($setdays) AND $setdays == "1")
$setdayssel2 = "selected";
if(isset($setdays) AND $setdays == "7")
$setdayssel3 = "selected";
if(isset($setdays) AND $setdays == "15")
$setdayssel4 = "selected";
if(isset($setdays) AND $setdays == "25")
$setdayssel5 = "selected";
$setdays_drop = "
<select name='setdays'>
<option $setdayssel1 value='0'>Last Day Of The Month</option>
<option $setdayssel2 value='1'>1st Day Of The Month</option>
<option $setdayssel3 value='7'>7th Of The Month</option>
<option $setdayssel4 value='15'>15th Of The Month</option>
<option $setdayssel5 value='25'>25th Of The Month</option>
</select>";
$enter = "
<h3>Edit Supplier</h3>
<form action='".SELF."' method='POST'>
<input type='hidden' name='key' value='confirm'>
<input type='hidden' name='supid' value='$supid'>
<input type='hidden' name='team_id' value='$team_id' />
<table cellpadding='0' cellspacing='0'>
<tr>
<td colspan='2'>$err</td>
</tr>
<tr valign='top'>
<td>
<table ".TMPL_tblDflts.">
<tr>
<th colspan='2'>Supplier Details</th>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Department</td>
<td>$depts</td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Supplier No</td>
<td><input type='text' size='10' name='supno' value='$supno'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Supplier/Name</td>
<td><input type='text' size='20' name='supname' value='$supname'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Registration/ID</td>
<td><input type='text' size='20' name='registration' value='$registration'></td>
</tr>
<tr class='".bg_class()."'>
<td>Branch</td>
<td><input type='text' size='20' name='branch' value='$branch'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Type</td>
<td>$locsel</td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Currency</td>
<td>$currsel</td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."VAT Number</td>
<td><input type='text' size='21' name='vatnum' value='$vatnum'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Address</td>
<td><textarea name='supaddr' rows='5' cols='18'>$supaddr</textarea></td>
</tr>
<tr class='".bg_class()."'>
<td>Postal Address</td>
<td><textarea name='suppostaddr' rows='5' cols='18'>$suppostaddr</textarea></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Contact Name</td>
<td><input type='text' size='20' name='contname' value='$contname'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Tel No.</td>
<td><input type='text' size='20' name='tel' value='$tel'></td>
</tr>
<tr class='".bg_class()."'>
<td>Fax No.</td>
<td><input type='text' size='20' name='fax' value='$fax'></td>
</tr>
<tr class='".bg_class()."'>
<td>Cell No.</td>
<td><input type='text' size='20' name='cell' value='$cell'></td>
</tr>
<tr class='".bg_class()."'>
<td>E-mail</td>
<td><input type='text' size='20' name='email' value='$email'></td>
</tr>
<tr class='".bg_class()."'>
<td>Web Address</td>
<td>http://<input type='text' size='30' name='url' value='$url'></td>
</tr>
<tr class='".bg_class()."'>
<td>".REQ."Price List</td>
<td>$pricelists</td>
</tr>
<tr class='".bg_class()."'>
<td>Supplier Group</td>
<td>$supp_grpdrop</td>
</tr>
<tr class='".bg_class()."'>
<td>Status BEE</td>
<td>Yes <input type='radio' name='bee_status' value='yes' $sel1> No <input type='radio' name='bee_status' value='no' $sel2></td>
</tr>
<tr class='".bg_class()."'>
<td>Team Permissions</td>
<td>$team_sel</td>
</tr>
</table>
</td>
<td>
<table ".TMPL_tblDflts.">
<tr class='".bg_class()."'>
<th colspan='2'> Bank Details</th>
</tr>
<tr class='".bg_class()."'>
<td>Bank </td>
<td><input type='text' size='20' name='bankname' value='$bankname'></td>
</tr>
<tr class='".bg_class()."'>
<td>Branch</td>
<td><input type='text' size='20' name='branname' value='$branname'></td>
</tr>
<tr class='".bg_class()."'>
<td>Branch Code</td>
<td><input type='text' size='20' name='brancode' value='$brancode'></td>
</tr>
<tr class='".bg_class()."'>
<td>Account Name</td>
<td><input type='text' size='20' name='bankaccname' value='$bankaccname'></td>
</tr>
<tr class='".bg_class()."'>
<td>Account Type</td>
<td><input type='text' size='20' name='bankacctype' value='$bankacctype'></td>
</tr>
<tr class='".bg_class()."'>
<td>Account Number</td>
<td><input type='text' size='20' name='bankaccno' value='$bankaccno'></td>
</tr>
<tr class='".bg_class()."'>
<td>Reference</td>
<td><input type='text' size='20' name='reference' value='$reference'></td>
</tr>
<tr class='".bg_class()."'>
<td>Settlement Discount %</td>
<td><input type='text' name='setdisc' value='$setdisc'></td>
</tr>
<tr class='".bg_class()."'>
<td>Statement Day</td>
<td>$setdays_drop</td>
</tr>
<tr class='".bg_class()."'>
<td>Comments</td>
<td><textarea name='comments' rows='5' cols='18'>$comments</textarea></td>
</tr>
".TBL_BR."
<tr>
<td colspan='2' align='right'><input type='submit' value='Confirm »'></td>
</tr>
".TBL_BR."
<tr>
<td colspan='2' align='right'>
<table border='0' cellpadding='2' cellspacing='1'>
<tr>
<th>Quick Links</th>
</tr>
<tr class='".bg_class()."'>
<td><a href='supp-view.php'>View Suppliers</a></td>
</tr>
<tr class='".bg_class()."'>
<td><a href='main.php'>Main Menu</a></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>";
return $enter;
}
# confirm new data
function confirm ($_POST)
{
# get vars
extract ($_POST);
# validate input
require_lib("validate");
$v = new validate ();
$v->isOk ($deptid, "num", 1, 255, "Invalid Department.");
$v->isOk ($supid, "num", 1, 50, "Invalid supplier id.");
$v->isOk ($supno, "string", 1, 255, "Invalid suppleir number.");
$v->isOk ($supname, "string", 1, 255, "Invalid supplier name.");
$v->isOk ($loc, "string", 1, 3, "Invalid Type.");
$v->isOk ($fcid, "num", 1, 30, "Invalid Currency.");
$v->isOk ($vatnum, "string", 1, 255, "Invalid supplier vat number.");
$v->isOk ($registration, "string", 1, 255, "Invalid registration/id number.");
$v->isOk ($supaddr, "string", 1, 255, "Invalid supplier address.");
$v->isOk ($suppostaddr, "string", 0, 255, "Invalid supplier postal address.");
$v->isOk ($contname, "string", 1, 255, "Invalid contact name.");
$v->isOk ($tel, "string", 1, 20, "Invalid tel no.");
$v->isOk ($fax, "string", 0, 20, "Invalid fax no.");
$v->isOk ($cell, "string", 0, 20, "Invalid cell no.");
$v->isOk ($email, "email", 0, 255, "Invalid e-mail address.");
$v->isOk ($listid, "num", 1, 20, "Invalid price list.");
$v->isOk ($url, "url", 0, 255, "Invalid web address.");
$v->isOk ($bankname, "string", 0, 255, "Invalid bank name.");
$v->isOk ($branname, "string", 0, 255, "Invalid branch name.");
$v->isOk ($brancode, "string", 0, 255, "Invalid branch code.");
$v->isOk ($bankaccname, "string", 0, 255, "Invalid bank account name.");
$v->isOk ($bankacctype, "string", 0, 255, "Invalid bank account type.");
$v->isOk ($bankaccno, "num", 0, 255, "Invalid bank account number.");
$v->isOk ($comments, "string", 0, 255, "Invalid characters in comment.");
$v->isOk ($branch, "string", 0, 255, "Invalid supplier branch.");
$v->isOk ($reference, "string", 0, 255, "Invalid reference.");
$v->isOk ($bee_status, "string", 0, 255, "Invalid BEE Status");
$v->isOk ($supp_grp, "num", 1, 9, "Invalid supplier group selected.");
$v->isOk ($team_id, "num", 1, 9, "Invalid team selection.");
$v->isOk ($setdisc, "float", 1, 40, "Invalid Settlement Discount Amount.");
$v->isOk ($setdays, "num", 1, 40, "Invalid Settlement Discount Days");
# display errors, if any
if ($v->isError ()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>".$e["msg"]."</li>";
}
return edit_err($_POST, $confirm);
exit;
$confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='« Correct submission'>";
return $confirm;
}
db_conn('cubit');
$Sl = "SELECT * FROM suppliers WHERE supno='$supno' AND supid!='$supid'";
$Ri = db_exec($Sl) or errDie("Unable to get data.");
if(pg_num_rows($Ri)>0) {
return edit_err($_POST, "<li class='err'>There is already a supplier with that number.</lI>");
}
# get department
db_conn("exten");
$sql = "SELECT * FROM departments WHERE deptid = '$deptid' AND div = '".USER_DIV."'";
$deptRslt = db_exec($sql);
if(pg_numrows($deptRslt) < 1){
$deptname = "<li class='err'>Department not Found.</li>";
}else{
$dept = pg_fetch_array($deptRslt);
$deptname = $dept['deptname'];
}
# Get Price List
$sql = "SELECT * FROM spricelist WHERE listid = '$listid' AND div = '".USER_DIV."'";
$listRslt = db_exec($sql);
if(pg_numrows($listRslt) < 1){
$plist = "<li class='err'>Class not Found.</li>";
}else{
$list = pg_fetch_array($listRslt);
$plist = $list['listname'];
}
# Locations drop down
$locs = array("loc"=>"Local", "int"=>"International");
$curr = getSymbol($fcid);
$get_suppgrp = "SELECT groupname FROM supp_groups WHERE id = '$supp_grp' LIMIT 1";
$run_suppgrp = db_exec($get_suppgrp) or errDie("Unable to get supplier group information");
if(pg_numrows($run_suppgrp) < 1){
$showsupp_grp = "Unknown Supplier Group";
}else{
$garr = pg_fetch_array ($run_suppgrp);
$showsupp_grp = $garr['groupname'];
}
$hidden = "
<input type='hidden' name='deptid' value='$deptid'>
<input type='hidden' name='supid' value='$supid'>
<input type='hidden' name='supno' value='$supno'>
<input type='hidden' name='supname' value='$supname'>
<input type='hidden' name='loc' value='$loc'>
<input type='hidden' name='location' value='$loc'>
<input type='hidden' name='fcid' value='$fcid'>
<input type='hidden' name='vatnum' value='$vatnum'>
<input type='hidden' name='registration' value='$registration'>
<input type='hidden' name='supaddr' value='$supaddr'>
<input type='hidden' name='suppostaddr' value='$suppostaddr'>
<input type='hidden' name='contname' value='$contname'>
<input type='hidden' name='tel' value='$tel'>
<input type='hidden' name='fax' value='$fax'>
<input type='hidden' name='cell' value='$cell'>
<input type='hidden' name='email' value='$email'>
<input type='hidden' name='url' value='$url'>
<input type='hidden' name='listid' value='$listid'>
<input type='hidden' name='bankname' value='$bankname'>
<input type='hidden' name='branname' value='$branname'>
<input type='hidden' name='brancode' value='$brancode'>
<input type='hidden' name='bankaccname' value='$bankaccname'>
<input type='hidden' name='bankacctype' value='$bankacctype'>
<input type='hidden' name='bankaccno' value='$bankaccno'>
<input type='hidden' name='comments' value='$comments'>
<input type='hidden' name='branch' value='$branch'>
<input type='hidden' name='reference' value='$reference'>
<input type='hidden' name='bee_status' value='$bee_status'>
<input type='hidden' name='supp_grp' value='$supp_grp'>
<input type='hidden' name='team_id' value='$team_id' />
<input type='hidden' name='setdisc' value='$setdisc' />
<input type='hidden' name='setdays' value='$setdays' />";
// Retrieve teams
$sql = "SELECT * FROM crm.teams WHERE id = '$team_id' LIMIT 1";
$team_rslt = db_exec($sql) or errDie("Unable to retrieve teams.");
$team_data = pg_fetch_array($team_rslt);
$team_sel = "$team_data[name]";
if(!isset($team_sel))
$team_sel = "";
$confirm = "
<h3>Confirm Supplier</h3>
<form action='".SELF."' method='POST'>
$hidden
<input type='hidden' name='key' value='write'>
<table ".TMPL_tblDflts.">
<table cellpadding='0' cellspacing='0'>
<tr valign='top'>
<td>
<table ".TMPL_tblDflts.">
<tr>
<th colspan='2'>Supplier Details</th>
</tr>
<tr class='".bg_class()."'>
<td>Department</td>
<td>$deptname</td>
</tr>
<tr class='".bg_class()."'>
<td>Supplier No</td>
<td>$supno</td>
</tr>
<tr class='".bg_class()."'>
<td>Supplier/Name </td>
<td>$supname</td>
</tr>
<tr class='".bg_class()."'>
<td>Registration/ID </td>
<td>$registration</td>
</tr>
<tr class='".bg_class()."'>
<td>Branch</td>
<td>$branch</td>
</tr>
<tr class='".bg_class()."'>
<td>Type</td>
<td>$locs[$loc]</td>
</tr>
<tr class='".bg_class()."'>
<td>Currency</td>
<td>$curr[symbol] - $curr[name]</td>
</tr>
<tr class='".bg_class()."'>
<td>VAT Number</td>
<td>$vatnum</td>
</tr>
<tr class='".bg_class()."'>
<td>Address</td>
<td><pre>$supaddr</pre></td>
</tr>
<tr class='".bg_class()."'>
<td>Postal Address</td>
<td><pre>$suppostaddr</pre></td>
</tr>
<tr class='".bg_class()."'>
<td>Contact Name</td>
<td>$contname</td>
</tr>
<tr class='".bg_class()."'>
<td>Tel No.</td>
<td>$tel</td>
</tr>
<tr class='".bg_class()."'>
<td>Fax No.</td>
<td>$fax</td>
</tr>
<tr class='".bg_class()."'>
<td>Cell No.</td>
<td>$cell</td>
</tr>
<tr class='".bg_class()."'>
<td>E-mail</td>
<td>$email</td>
</tr>
<tr class='".bg_class()."'>
<td>Web Address</td>
<td>http://$url</td>
</tr>
<tr class='".bg_class()."'>
<td>Price List</td>
<td>$plist</td>
</tr>
<tr class='".bg_class()."'>
<td>Supplier Group</td>
<td>$showsupp_grp</td>
</tr>
<tr class='".bg_class()."'>
<td>Status BEE</td>
<td>$bee_status</td>
</tr>
<tr class='".bg_class()."'>
<td>Team Permissions</td>
<td>$team_sel</td>
</tr>
<tr class='".bg_class()."'>
<td>Comments</td>
<td>".nl2br($comments)."</td>
</tr>
<tr>
<td><input type='submit' name='back' value='« Correction'></td>
</tr>
</table>
</td>
<td>
<table ".TMPL_tblDflts.">
<tr class='".bg_class()."'>
<th colspan='2'> Bank Details</th>
</tr>
<tr class='".bg_class()."'>
<td>Bank </td>
<td>$bankname</td>
</tr>
<tr class='".bg_class()."'>
<td>Branch</td>
<td>$branname</td>
</tr>
<tr class='".bg_class()."'>
<td>Branch Code</td>
<td>$brancode</td>
</tr>
<tr class='".bg_class()."'>
<td>Account Name</td>
<td>$bankaccname</td>
</tr>
<tr class='".bg_class()."'>
<td>Account Type</td>
<td>$bankacctype</td>
</tr>
<tr class='".bg_class()."'>
<td>Account Number</td>
<td>$bankaccno</td>
</tr>
<tr class='".bg_class()."'>
<td>Reference</td>
<td>$reference</td>
</tr>
<tr class='".bg_class()."'>
<td>Settlement Discount %</td>
<td>$setdisc %</td>
</tr>
<tr class='".bg_class()."'>
<td>Statement Day</td>
<td>$setdays</td>
</tr>
".TBL_BR."
<tr>