-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.php
991 lines (799 loc) · 31.6 KB
/
validate.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
<?php
include "php/inc/header.inc.php";
require_once(__ROOT__.'php/lib/account_writers.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=$language;?>" lang="<?=$language;?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $Text['global_title'] . " - " . $Text['head_ti_validate'] ;?></title>
<link rel="stylesheet" type="text/css" media="screen" href="css/aixada_main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="js/aixadacart/aixadacart.css?v=<?=aixada_js_version();?>" />
<link rel="stylesheet" type="text/css" media="screen" href="js/fgmenu/fg.menu.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-themes/<?=$default_theme;?>/jqueryui.css"/>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jqueryui/jqueryui.js"></script>
<?php echo aixada_js_src(); ?>
<script type="text/javascript" src="js/aixadacart/jquery.aixadacart.js?v=<?=aixada_js_version();?>" ></script>
<script type="text/javascript" src="js/aixadacart/i18n/cart.locale-<?=$language;?>.js?v=<?=aixada_js_version();?>" ></script>
<script type="text/javascript" src="js/jqueryui/i18n/jquery.ui.datepicker-<?=$language;?>.js" ></script>
<?php
$cfg = configuration_vars::get_instance();
$cfg_js_validate_self =
(isset($cfg->validate_self) && $cfg->validate_self) ?
'true' : 'false'; // default false
$cfg_js_validate_deposit =
(isset($cfg->validate_deposit) && !$cfg->validate_deposit) ?
'false' : 'true'; // default true
$cfg_js_validate_btn_create_carts =
( isset($cfg->validate_btn_create_carts) &&
$cfg->validate_btn_create_carts ) ?
'true' : 'false'; // default false
?>
<script type="text/javascript">
$(function(){
$.ajaxSetup({ cache: false });
//loading animation
$('.loadSpinner').attr('src', "img/ajax-loader-<?=$default_theme;?>.gif").hide();
//made deposit
var gMadeDeposit = true;
//get the operator user id to prevent own validation
var gTornUfId = <?=get_session_uf_id();?>;
var cfg_js_validate_self = <?php echo $cfg_js_validate_self; ?>;
var cfg_js_validate_deposit = <?php echo $cfg_js_validate_deposit; ?>;
var cfg_js_validate_btn_create_carts = <?php echo $cfg_js_validate_btn_create_carts; ?>;
var cfg_js_show_carts_filter = '<?php
echo get_config('validate_show_carts','day')!=='week'?
'today' :
'steps&steps=1&range=week' ?>';
//stores todays date
var gToday = null;
//indicates if cart is not yet validated.
var gActiveCart = 0;
$.getAixadaDates('getToday', function (date){
gToday = date[0];
//var today = $.datepicker.parseDate('yy-mm-dd', date[0]);
});
/**
* UF LISTING FUNCTIONALITY
*/
$('#uf_cart_select').xml2html('init',{
offSet : 1,
url : 'php/ctrl/Validate.php',
params : 'oper=getUFsCartCount',
rowComplete : function(rowIndex, row){
//show number of non_validated carts for uf
var non_validated_carts = $(row).attr('cc');
non_validated_carts = (non_validated_carts > 0)? ' (#'+non_validated_carts+')':'';
$(row).append(non_validated_carts);
//dim out own uf
if ($(row).val() == gTornUfId && !cfg_js_validate_self){ //cannot validate yourself
$(row).addClass('dim60');
}
},
loadOnInit:true
}).change(function(){
var last_uf = $('#deposit .insert_uf_id').text();
var uf_id = $("option:selected", this).val();
if (cfg_js_validate_deposit && !checkMadeDeposit(last_uf, uf_id)) {
return false;
}
$("#createCart").hide();
if (uf_id <=0) {
resetFields();
resetDeposit();
return false;
} else if (uf_id == gTornUfId && !cfg_js_validate_self){ //cannot validate your own cart
$.showMsg({
msg:"<?php echo $Text['msg_err_validate_self'];?>",
type: 'error'});
resetFields();
resetDeposit();
return false;
}
//activate the deposit pane
$('.insert_uf_id').html('<strong>'+uf_id+'</strong>');
$('.showCartDate').removeClass('ui-state-highlight dim40').text('');
$('.cartTitle').show();
$('.noCartTitle, .validatedCartTitle').hide();
$('#deposit_submit').button('enable');
$('#deposit_amount, #deposit_note, #search').attr('disabled',false);
//how many carts are there?
$('#tbl_Shop tbody').xml2html('reload',{
url : 'php/ctrl/Validate.php',
params : 'oper=getNonValidatedCarts&uf_id='+uf_id
});
}); //end of listing
if (cfg_js_validate_btn_create_carts) {
$("#crtDateForShop").datepicker({
dateFormat: 'DD d M, yy',
showAnim: '',
beforeShowDay: function(date){
return [true, ""];
},
onSelect: function (dateText, instance){
//refreshSelects($.getSelectedDate('#crtDateForShop'));
}
}).show();
$('.toggleShopDate').click(function(){
$("#crtDateForShop").toggle();
});
var _today = new Date();
$("#crtDateForShop").datepicker('setDate', _today);
$("#btn_createCart").button().click(function() {
var _uf_id = $("#uf_cart_select option:selected").val(),
_date_for_shop = $.getSelectedDate('#crtDateForShop');
$.ajax({
type: "POST",
url: "php/ctrl/Validate.php?oper=createEmptyCart&uf_id="+_uf_id+
"&date="+_date_for_shop,
success: function(msg) {
$('#tbl_cart_listing tbody').xml2html('reload');
$('#uf_cart_select').xml2html('reload',{
url: 'php/ctrl/Validate.php',
params: 'oper=getUFsCartCount',
complete: function(rowCount){
$('#uf_cart_select').val(_uf_id
).attr('selected', true
).trigger('change');
}
});
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$.updateTips("#depositMsg", "error",
XMLHttpRequest.responseText);
},
complete: function(msg) {
$("#createCart").hide();
}
});
});
}
//load purchase listing: how may carts does this uf have?
$('#tbl_Shop tbody').xml2html('init',{
url : 'php/ctrl/Shop.php',
loadOnInit : false,
rowComplete : function(rowIndex, row){
var validated = $(row).children().eq(2).text();
if (validated == "0000-00-00 00:00:00"){
$(row).children().eq(2).html('<span class="ui-state-error ui-corner-all"><?php echo $Text['not_validated'];?></span>');
}
},
complete: function(rowCount){
//more than one cart to validate
if (rowCount > 1){
$('#dialog_select_cart').dialog('open');
} else if (rowCount == 0){
$.showMsg({
msg:"<?php echo $Text['nothing_to_val'] ;?>",
type: 'warning'});
$('#cartLayer').aixadacart('resetCart');
if (cfg_js_validate_btn_create_carts) {
$("#createCart").show();
}
//resetFields();
//one, should be today!
} else {
var cart_id = $('#tbl_Shop tbody tr').attr('shopId');
var date_for_shop = $('#tbl_Shop tbody tr').attr('dateForShop');
var css = (date_for_shop != gToday)? 'ui-state-highlight':'dim40';
var df = '('+$.getCustomDate(date_for_shop, 'D, d M, yy')+')';
$('.showCartDate').removeClass('ui-state-highlight dim40').addClass(css).text(df);
if (cart_id > 0 ){
$('#cartLayer').aixadacart('resetCart');
loadCart(cart_id, date_for_shop);
} else {
$('.cartTitle, .validatedCartTitle').hide();
$('.noCartTitle').show();
}
}
}
});
/**
* MULTIPLE CARTS TO VALIDATE / SELECT
*/
$('#dialog_select_cart').dialog({
autoOpen:false,
width:500,
buttons: {
"<?=$Text['btn_cancel'];?>" : function(){
$( this ).dialog( "close" );
}
}
});
//tbl_Shop checks for multiple non-validated carts; tbl_cart_listing is right hand list of carts
$('#tbl_Shop tbody tr, #tbl_cart_listing tbody tr')
.live('mouseover', function(){
$(this).removeClass('highlight').addClass('ui-state-hover');
})
.live('mouseout',function(){
$(this).removeClass('ui-state-hover');
})
.live('click',function(e){
var last_uf = $('#deposit .insert_uf_id').text();
var uf_id = $(this).attr('ufId');
if (cfg_js_validate_deposit && !checkMadeDeposit(last_uf, uf_id)) {
return false;
}
$('.showCartDate').removeClass('ui-state-highlight dim40');
var validated = $(this).attr('validated');
var cart_id = $(this).attr('shopId');
var date_for_shop = $(this).attr('dateForShop');
if (uf_id == gTornUfId && !cfg_js_validate_self){ //cannot validate your own cart
$.showMsg({
msg:"<?php echo $Text['msg_err_validate_self'];?>",
type: 'error'});
resetFields();
resetDeposit();
return false;
}
//means we come from cart observe
if (uf_id > 0){
$('#uf_cart_select').val(uf_id).attr('selected','selected');
$('.insert_uf_id').html('<strong>'+uf_id+'</strong>');
$('#deposit_submit').button('enable');
$('#deposit_amount, #deposit_note, #search').attr('disabled',false);
}
//if cart is not validated, load it
if (validated == "0000-00-00 00:00:00") {
$('.cartTitle').show();
$('.noCartTitle, .validatedCartTitle').hide();
var css = (date_for_shop != gToday)? 'ui-state-highlight':'dim40';
var df = '('+$.getCustomDate(date_for_shop, 'D, d M, yy')+')';
$('.showCartDate').addClass(css).text(df);
$('#cartLayer').aixadacart('resetCart');
loadCart(cart_id, date_for_shop);
//if already validated, the offer choice to see purchase details
} else {
resetFields();
$.showMsg({
msg:"<?php echo $Text['msg_already_validated']; ?>",
width:500,
buttons: {
"<?=$Text['btn_ok'];?>":function(){
window.location.href = "report_shop_ufs.php?detailForCart="+cart_id+"&lastPage=validate";
$( this ).dialog( "close" );
},
"<?=$Text['btn_cancel'];?>" : function(){
$( this ).dialog( "close" );
}
},
type: 'warning'});
}
$('#dialog_select_cart').dialog('close');
});
//init tabs
$("#tabs").tabs();
//init cart
$('#cartLayer').aixadacart("init",{
saveCartURL : 'php/ctrl/Validate.php',
cartType : 'simple',
btnType : 'validate',
saveOnDelete: false,
submitSuccess : function (msg){
//alert(msg.cart_id + " " + msg.ts_last_saved);
$('#tbl_cart_listing tbody').xml2html('reload');
$('#list_account tbody').xml2html('reload');
//update nr of unvalidated carts in select
var txt = $('#uf_cart_select option:selected').text();
var nr = new Number(txt.substring(txt.lastIndexOf('#')+1, txt.length-1));
var rplstr = (nr == 1)? '':'(#'+(nr-1)+')';
var newTxt = txt.replace('(#'+nr+')', rplstr);
$('#uf_cart_select option:selected').text(newTxt);
//reloadValidationUfs();
//empty the cart
$(this).aixadacart("resetCart");
gMadeDeposit = false;
gActiveCart = false;
},
submitError : function (err_msg){
$.showMsg({
msg:err_msg,
type: 'error'});
}
});
//init xml2html product search
$('#product_list_search tbody').xml2html('init',{
url : 'php/ctrl/ShopAndOrder.php'
});
/**
* MAKE A DEPOSIT
*/
$('#deposit_submit')
.button()
.click(function(){
var description = $('#deposit_note').val();
var uf_account_id = 1000 + new Number($("#uf_cart_select option:selected").val());
var quantity = $.checkNumber($('#deposit_amount'), '', 2);
if (!quantity) {
$.showMsg({
msg:"<?php echo $Text['msg_enter_deposit_amount'];?>",
type: 'warning'});
return false;
} else if (uf_account_id <= 1000 || uf_account_id == '' || typeof(uf_account_id) != 'number' ){
$.showMsg({
msg:"<?php echo $Text['msg_please_set_ufid_deposit'];?>",
type: 'error'});
return false;
}
$('#deposit_submit').button('disable');
$.ajax({
type: "POST",
url: "php/ctrl/Account.php?oper=depositCashForUf&account_id="+uf_account_id+"&quantity="+quantity+"&description="+description,
beforeSend : function (){
$('#deposit .loadSpinner').show();
},
success: function(msg){
$.updateTips("#depositMsg", "success", "<?=$Text['msg_deposit_success'];?>" );
resetDeposit();
$('#dailyStats tbody').xml2html('reload');
$('#list_account tbody').xml2html('reload');
gMadeDeposit = true;
},
error : function(XMLHttpRequest, textStatus, errorThrown){
$.updateTips("#depositMsg","error", XMLHttpRequest.responseText);
},
complete : function(msg){
$('#deposit_submit').button('enable');
$('#deposit .loadSpinner').hide();
}
}); //end ajax
});
/**
* MONITOR Money, daily stats, negative ufs, stock
*/
$('#list_account tbody').xml2html('init',{
url : 'php/ctrl/Account.php',
params : 'oper=latestMovements',
loadOnInit: true,
rowComplete : function (rowIndex, row){
$.formatQuantity(row, "<?=$Text['currency_sign'];?>");
},
complete : function (rowCount){
$('#list_account tbody tr:even').addClass('rowHighlight');
}
});
//carts to validate today
$('#tbl_cart_listing tbody').xml2html('init',{
url : 'php/ctrl/Shop.php',
params : 'oper=getShopListing&filter='+cfg_js_show_carts_filter,
autoReload: 100200,
loadOnInit:true,
beforeLoad : function(){
$('#dailyStats .loadSpinner').show();
},
rowComplete : function(rowIndex, row){
var validated = $(row).children().eq(3).text();
if (validated == '0000-00-00 00:00:00'){
$(row).children().eq(3).html('<p class="textAlignCenter">-</p>');
} else {
$(row).children().eq(3).addClass('okGreen').html('<span class="ui-icon ui-icon-check tdIconCenter" title="<?php echo $Text['validated_at']; ?>: '+validated+'"></span>');
}
},
complete : function(){
$('tr:even', this).addClass('rowHighlight');
$('#dailyStats .loadSpinner').hide();
}
});
//negative stock
$('#min_stock tbody').xml2html('init',{
url : 'php/ctrl/Shop.php',
params : 'oper=getProductsBelowMinStock',
loadOnInit: false,
autoReload: 100010,
beforeLoad : function(){
$('#min_stock .loadSpinner').show();
},
complete : function(){
$('#min_stock .loadSpinner').hide();
},
rowComplete : function(rowIndex, row){
//reformat numbers to two decimal places
var currentStock = new Number($(row).children().last().text());
var minStock = new Number($(row).children().eq(3).text());
$(row).children().last().text(currentStock.toFixed(2));
$(row).children().eq(3).text(minStock.toFixed(2));
}
});
$('.left-icons')
.bind("mouseenter", function(){
if ($(this).hasClass('ui-icon-triangle-1-s')){
$(this).removeClass('ui-icon-triangle-1-s').addClass('ui-icon-circle-triangle-s');
} else {
$(this).removeClass('ui-icon-triangle-1-e').addClass('ui-icon-circle-triangle-e');
}
})
.bind("mouseleave", function(){
if ($(this).hasClass('ui-icon-circle-triangle-s')){
$(this).removeClass('ui-icon-circle-triangle-s').addClass('ui-icon-triangle-1-s');
} else {
$(this).removeClass('ui-icon-circle-triangle-e').addClass('ui-icon-triangle-1-e');
}
})
.bind("click", function(){
$(this).parent().next().toggle();
if ($(this).hasClass('ui-icon-circle-triangle-s')){
$(this).removeClass('ui-icon-circle-triangle-s').addClass('ui-icon-circle-triangle-e');
} else {
$(this).removeClass('ui-icon-circle-triangle-e').addClass('ui-icon-circle-triangle-s');
}
});
/**
* init ufs for account deposit select
*/
$('#uf_account_select').hide();
$('#toggle_uf_account_select').click(function(){
$('#uf_account_select').toggle();
});
/**
* product search functionality
*/
$("#search").keyup(function(e){
//search with min of X characters
var minLength = 3;
//retrieve search input
var searchStr = $("#search").val();
if (searchStr.length >= minLength){
$('#product_list_search tbody').xml2html('reload',{
params: 'oper=getToShopProducts&date=0&like='+searchStr,
rowComplete : function(rowIndex, row){ //updates quantities for items already in cart
var id = $(row).attr("id");
var qu = $("#cart_quantity_"+id).val();
$("#quantity_"+id).val(qu);
}
});
} else {
//delete all product entries in the table if we are below minLength; but
$('#product_list_search tbody').xml2html("removeAll");
}
//prevent default event propagation. once the list is build, just stop here.
e.preventDefault();
}); //end autocomplete
/**
* attach event listeners for the product input fields; change of quantity will put the
* item into the cart.
*/
$('.product_list tbody').find("input").live("change", function (e){
//check if a cart/UF is selected, only then can one add items
if ($('#uf_cart_select option:selected').val() > 0 && gActiveCart){
//retrieve the current table row where quantity has been changed
var row = $(this).parents("tr");
//don't add nonsense values
var qu = $(this).val();
if (isNaN(parseFloat(qu.replace(",",".")))) {
$(this).val(0);
return false;
}
//if quantity has changed, add it to the cart.
$('#cartLayer').aixadacart("addItem",{
id : $(row).attr("id"),
isPreorder : false,
name : $("td.item_name", row).text(),
provider_name : $("td.item_provider_name", row).text(),
price : parseFloat($("td.item_price", row).text()),
quantity : $(this).val(),
unit : $("td.item_unit", row).text(),
rev_tax_percent : parseFloat( $("td.item_rev_tax_percent", row).text()),
iva_percent : $("td.item_iva_percent", row).text()
}); //end addItem to cart
//switch back to item listing
$("#tabs").tabs('select',0);
//if no cart is selected
} else {
$.showMsg({
msg: "<?php echo $Text['msg_select_cart_first'];?>",
type: 'error'
});
}
});//end event listener for product list
/**
* resets all input fields
*/
function resetFields(){
$('#cartLayer').aixadacart('resetCart');
$('.cartTitle').show();
$('.noCartTitle, .validatedCartTitle').hide();
$('.insert_uf_id').html('<strong>??</strong>');
$('.showCartDate').removeClass('ui-state-highlight dim40').text('');
$('#uf_cart_select').val(-10);
$('#deposit_submit').button('disable');
$('#deposit_amount, #deposit_note').attr('disabled',true);
}
//reset the deposit pane
function resetDeposit(){
$('#deposit_amount').val('');
$('#deposit_note').val('');
$('.deposit_status').hide();
}
//realod the uf listing, update the (#) carts to be validated
function reloadValidationUfs(){
$('#uf_cart_select').xml2html('reload',{
url : 'php/ctrl/Validate.php',
params : 'oper=getUFsCartCount'
});
}
/**
* if new cart is selected for validation, shows warning message if for previous
* cart no deposit has been made
*/
function checkMadeDeposit(depositUF, nextUF){
//check if last uf made deposit and show warning if not
if (!gMadeDeposit){
$.showMsg({
msg:"<?php echo $Text['msg_err_no_deposit'];?>",
width:600,
height:400,
buttons: {
"<?=$Text['btn_deposit_now'];?>":function(){
$('#uf_cart_select').val(depositUF).attr('selected',true);
$( this ).dialog( "close" );
},
"<?=$Text['btn_load_cart'];?>": function(){
gMadeDeposit = true; //simulate we made a deposit!
$('#uf_cart_select').val(nextUF).attr('selected',true);
$('#uf_cart_select').trigger('change');
$( this ).dialog( "close" );
}
},
type: 'warning'});
return false;
} else {
return true;
}
}
/**
* load items for given cart.
* date_for_shop is not needed for loading, however for submitting(!)
*/
function loadCart(cart_id, date_for_shop){
var uf_id = $("#uf_cart_select option:selected").val();
var account = 1000+parseInt(uf_id);
//set the uf_id and date for the saveCartURL when submitting
//TODO this should be replaced with the cart_id...! however this means
//to change the lib/validation_cart_manager, abstract_cart_manager!!
$('#cartLayer').aixadacart('options',{
date : date_for_shop,
saveCartURL : 'php/ctrl/Validate.php?oper=commit&uf_id='+uf_id
});
$('#cartAnim').show();
//the url to load the items for given uf/date
$('#cartLayer').aixadacart('loadCart',{
loadCartURL : 'php/ctrl/Validate.php?oper=getShopCart&cart_id='+cart_id,
loadCartHeadURL: 'php/ctrl/Validate.php?oper=getShopCartHead&cart_id='+cart_id,
loadSuccess : function (){
$('#cartAnim').hide();
gActiveCart = true;
}
}); //end loadCart
}
/*function getSelectedDate(){
return $('#selDate4Validation option:selected').val();
}*/
//prevent accidental submit on return when editing input
$('#cartLayer input')
.live('keydown', function(e){
if (e.keyCode == 13){
//var ti = $(this).attr("tabindex");
//$(this).attr("tabindex",ti+1);
e.stopPropagation();
return false;
}
})
resetFields();
resetDeposit();
}); //close document ready
</script>
</head>
<?php flush(); ?>
<body>
<div id="wrap">
<div id="headwrap">
<?php include "php/inc/menu.inc.php" ?>
</div>
<!-- end of headwrap -->
<div id="stagewrap" class="ui-widget">
<div id="titlewrap">
<div id="titleLeftCol">
<p class="floatLeft"><img src="img/validar.png" style="margin-top:4px; height:60px;"/></p>
<div class="aix-layout-title-with-icon">
<h1 class="cartTitle"><?php echo $Text['ti_validate']; ?><span class="insert_uf_id cart">??</span> <span class="ui-corner-all aix-style-padding3x3 showCartDate"></span> </h1>
<h1 class="noCartTitle ui-state-highlight ui-corner-all"><?php echo $Text['nothing_to_val']; ?><span class="insert_uf_id cart">??</span> </h1>
<h1 class="validatedCartTitle ui-state-highlight ui-corner-all"><?php echo $Text['ti_validate']; ?><span class="insert_uf_id cart">??</span></h1>
</div>
</div>
<div id="titleRightCol">
<div class="textAlignRight">
<select id="uf_cart_select">
<option value="-10" selected="selected"><?php echo $Text['sel_uf']; ?></option>
<option value="{uf_id}" cc="{non_validated_carts}"> {uf_id} {uf_name}</option>
</select>
<div id="createCart" class="hidden">
<?=i18n('cart_date')?>: <input type="text"
class="datePickerInput ui-widget-content ui-corner-all"
id="crtDateForShop"
title="<?=i18n('click_to_change')?>">
<button id="btn_createCart"
title="<?=i18n('create_cart');?>"><?=i18n('create_cart');?></button>
</div>
</div>
</div>
</div>
<div class="aix-layout-splitW60 floatLeft">
<div id="tabs">
<span style="float:right; margin-top:6px; margin-right:10px;" ><img id="cartAnim" class="loadSpinner" src="img/ajax-loader.gif"/></span>
<ul>
<li><a href="#tabs-1"><?php echo $Text['validate']; ?></a></li>
<li><a href="#tabs-2"><?php echo $Text['search_add']; ?></a></li>
</ul>
<div id="tabs-1">
<div id="cartLayer"></div>
</div>
<div id="tabs-2">
<div class="ui-widget">
<label for="search"><?php echo $Text['search'];?></label>
<input id="search" class="ui-widget-content ui-corner-all" value="" />
</div>
<p> </p>
<div>
<table id="product_list_search" class="product_list" >
<thead>
<tr>
<th><?php echo $Text['id'];?></th>
<th><?php echo $Text['name_item'];?></th>
<th><?php echo $Text['provider_name'];?></th>
<th><?php echo $Text['quantity'];?></th>
<th><?php echo $Text['unit'];?></th>
<th><?php echo $Text['revtax_abbrev'];?></th>
<th><?php echo $Text['price'];?></th>
</tr>
</thead>
<tbody>
<tr id="{id}">
<td class="item_it">{id}</td>
<td class="item_name">{name}</td>
<td class="item_provider_name">{provider_name}</td>
<td class="item_quantity"><input name="{id}" class="ui-corner-all quantity_{id}" value="0.00" size="4" id="quantity_{id}"/></td>
<td class="item_unit">{unit}</td>
<td class="item_iva_percent hidden">{iva_percent}</td>
<td class="item_rev_tax_percent">{rev_tax_percent}</td>
<td class="item_price">{unit_price}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div><!-- end tabs -->
</div><!-- end left col -->
<div class="aix-layout-splitW40 floatRight">
<div id="deposit" class="ui-widget">
<div class="aix-style-observer-widget ui-widget-content ui-corner-all" >
<h3 class="ui-widget-header ui-corner-all"><?php echo $Text['make_deposit'];?> <span class="insert_uf_id account">??</span><span class="loadAnim floatRight"><img class="loadSpinner" src="img/ajax-loader.gif"/></span></h3>
<p id="depositMsg"></p>
<div id="deposit_content">
<table class="tblForms">
<tr><td><?php echo $Text['amount'];?>: </td><td><input type="text" name="quantity" id="deposit_amount" class="inputTxtMiddle ui-widget-content ui-corner-all" value=""/></td></tr>
<tr><td><?php echo $Text['comment'];?>: </td><td><input type="text" name="description" id="deposit_note" class="inputTxtMiddle ui-widget-content ui-corner-all" value=""/></td></tr>
<tr>
<td></td>
<td><button id="deposit_submit"><?=$Text['btn_make_deposit']; ?></button></td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="monitorFlows" class="ui-widget">
<div class="ui-widget-content ui-corner-all aix-style-observer-widget">
<h3 class="ui-widget-header ui-corner-all"><span class="left-icons ui-icon ui-icon-triangle-1-s"></span><?php echo $Text['latest_movements'];?> <span class="loadAnim floatRight"><img class="loadSpinner" src="img/ajax-loader.gif"/></span></h3>
<table id="list_account" class="tblListingDefault">
<thead>
<tr>
<th><?php echo $Text['account'];?></th>
<th><?php echo $Text['uf_short'];?></th>
<th><?php echo $Text['transfer_type'];?></th>
<th class="textAlignRight"><?php echo $Text['amount'];?></th>
<th class="textAlignRight"><?php echo $Text['balance'];?></th>
</tr>
</thead>
<tbody>
<tr>
<td>{account_id}</td>
<td>{uf_id}</td>
<td>{method}</td>
<td><p class="textAlignRight"><span class="formatQty">{quantity}</span></p></td>
<td><p class="textAlignRight"><span class="formatQty">{balance}</span></p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="monitorCarts" class="ui-widget">
<div class="ui-widget-content ui-corner-all aix-style-observer-widget">
<h3 class="ui-widget-header ui-corner-all"><span class="left-icons ui-icon ui-icon-triangle-1-s"></span><?php
echo get_config('validate_show_carts','day')!=='week'?
$Text['todays_carts']:
$Text['week_carts'];
?><span class="loadAnim floatRight"><img class="loadSpinner" src="img/ajax-loader.gif"/></span></h3>
<table id="tbl_cart_listing" class="tblListingDefault">
<thead>
<tr >
<th><?=$Text['cart_id'];?></th>
<th><?=$Text['uf_short'];?></th>
<th class="textAlignCenter"><?=$Text['date_of_purchase'];?></th>
<th class="textAlignCenter"><?=$Text['validated'];?></th>
<th><p class="textAlignRight"><?=$Text['total'];?> </p></th>
</tr>
</thead>
<tbody>
<tr id="shop_{id}" shopId="{id}" dateForShop="{date_for_shop}" ufId="{uf_id}" validated="{ts_validated}" class="clickable">
<td>{id}</td>
<td>{uf_id}</td>
<td>{date_for_shop}</td>
<td>{ts_validated}</td>
<td><p class="textAlignRight">{purchase_total} <?php echo $Text['currency_sign'];?></p></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php write_negative_ufs(); ?>
<?php write_dailyStats(); ?>
<div id="monitorStock" class="ui-widget hidden">
<div class="rightCol-Observer ui-widget-content ui-corner-all aix-style-observer-widget">
<h3 class="ui-widget-header ui-corner-all"><span class="left-icons ui-icon ui-icon-triangle-1-s"></span><?php echo $Text['negativeStock'];?><span class="loadAnim floatRight hidden"><img class="loadSpinner" src="img/ajax-loader.gif"/></span></h3>
<table id="min_stock" class="tblListingDefault">
<thead>
<tr>
<th><?php echo $Text['id'];?></th>
<th><?php echo $Text['product_name'];?></th>
<th><?php echo $Text['provider_name'];?></th>
<th><?php echo $Text['minStock'];?></th>
<th><?php echo $Text['curStock'];?></th>
</tr>
</thead>
<tbody>
<tr>
<td>{id}</td>
<td>{stock_item}</td>
<td>{stock_provider}</td>
<td>{stock_min}</td>
<td class="negativeBalance">{stock_actual}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- end of stage wrap -->
</div>
<!-- end of wrap -->
<!-- / END -->
<div id="dialog_select_cart" title="Non-validated carts for household">
<p> </p>
<p class="ui-state-highlight ui-corner-all aix-style-padding8x8"><?php echo $Text['msg_several_carts']; ?> </p>
<p> </p>
<table id="tbl_Shop" class="tblListingDefault">
<thead>
<tr >
<th><?php echo $Text['cart_id'];?></th>
<th class="textAlignCenter"><?=$Text['date_of_purchase'];?></th>
<th class="textAlignCenter"><?=$Text['validated'];?></th>
<th class="textAlignRight"><?=$Text['total'];?></th>
</tr>
</thead>
<tbody>
<tr id="shop_{id}" shopId="{id}" dateForShop="{date_for_shop}" validated="{ts_validated}" class="clickable">
<td>{id}</td>
<td class="textAlignCenter">{date_for_shop}</td>
<td class="textAlignCenter">{ts_validated}</td>
<td class="textAlignRight">{purchase_total}<?php echo $Text['currency_sign'];?></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>