-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport_shop_ufs.php
482 lines (374 loc) · 14.4 KB
/
report_shop_ufs.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
<?php include "php/inc/header.inc.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_sales'] ;?></title>
<link rel="stylesheet" type="text/css" media="screen" href="css/aixada_main.css" />
<link rel="stylesheet" type="text/css" media="print" href="css/print.css" />
<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/aixadautilities/jquery.aixadaExport.js" ></script>
<script type="text/javascript" src="js/tablesorter/jquery.tablesorter.js" ></script>
<script type="text/javascript" src="js/jqueryui/i18n/jquery.ui.datepicker-<?=$language;?>.js" ></script>
<script type="text/javascript">
$(function(){
$.ajaxSetup({ cache: false });
//loading animation
$('.loadSpinner').attr('src', "img/ajax-loader-<?=$default_theme;?>.gif").hide();
//saves the selected purchase row
var gSelShopRow = null;
//coming from other page
var gDetail = (typeof $.getUrlVar('detailForCart') == "string")? $.getUrlVar('detailForCart'):false;
//order overview filter option
var gBackTo = (typeof $.getUrlVar('lastPage') == "string")? $.getUrlVar('lastPage'):false;
/********************************************************
* PURCHASE LISTING
********************************************************/
var shopDateSteps = 1;
var srange = 'year';
//the table sorter plugin
$("#tbl_Shop").tablesorter();
$("#tbl_Shop").bind('sortEnd', function(){
$('tr',this).removeClass('rowHighlight')
$('tr:even',this).addClass('rowHighlight');
});
//load purchase listing
$('#tbl_Shop tbody').xml2html('init',{
url : 'php/ctrl/Shop.php',
params : 'oper=getShopListing&filter=prev3Month',
loadOnInit : true,
beforeLoad : function(){
$('.loadSpinner').show();
},
rowComplete : function(rowIndex, row){
var validated = $(row).children().eq(4).text();
if (validated == '0000-00-00 00:00:00'){
$(row).children().eq(4).html("<p class='textAlignCenter'>-</p>");
} else {
$(row).children().eq(4).html('<span class="ui-icon ui-icon-check tdIconCenter" title="<?php echo $Text['validated_at'];?>: '+validated+'"></span>');
}
if (gDetail > 0 && $(row).attr('shopId') == gDetail){
gSelShopRow = $(row);
}
},
complete : function(){
$('tr:even', this).addClass('rowHighlight');
$("#tbl_Shop").trigger("update");
if (gSelShopRow != null) {
gSelShopRow.trigger('click');
}
$('.loadSpinner').hide();
}
});
$('#tbl_Shop tbody tr')
.live('mouseover', function(){
$(this).removeClass('highlight').addClass('ui-state-hover');
})
.live('mouseout',function(){
$(this).removeClass('ui-state-hover');
})
.live('click',function(e){
if (gSelShopRow != null) gSelShopRow.removeClass('ui-state-highlight');
$(this).addClass('ui-state-highlight');
gSelShopRow = $(this);
$('#tbl_purchaseDetail tbody').xml2html('reload',{
params : 'oper=getShopCart&shop_id='+$(this).attr('shopId')
});
$('.setUfId').text($(this).attr('ufId'));
$('.setCartId').text($(this).attr('shopId'));
var cd = $.getCustomDate($(this).attr('dateForShop'));
$('.setShopDate').text(cd);
var dateValidated = $(this).attr('validated');
$('.setValidateStatus').removeClass('noRed okGreen');
if (dateValidated == "0000-00-00 00:00:00"){
$('.setValidateStatus').addClass('noRed').text('<?php echo $Text['not_yet_val']; ?>');
} else {
var opUf = $(this).attr('operatorUf');
var opName = $(this).attr('operatorName');
var dv = $.getCustomDate(dateValidated.substring(0,10),'DD M m, yy');
$('.setValidateStatus')
.addClass('okGreen')
.html('<span title="<?php echo $Text['val_by'];?> '+opUf+' '+opName+'">'+dv+'</span>');
}
switchTo('detail');
});
/********************************************************
* DETAIL PURCHASE VIEW
********************************************************/
//load purchase detail (products and quantities)
$('#tbl_purchaseDetail tbody').xml2html('init',{
url : 'php/ctrl/Shop.php',
params : 'oper=getShopCart',
loadOnInit : false,
beforeLoad : function(){
$('.loadSpinner').show();
},
rowComplete : function (rowIndex, row){
var price = new Number($('.up',row).text());
$('.up',row).text(price.toFixed(2));
var qu = new Number($('.qu',row).text());
var totalPrice = price * qu;
totalPrice = totalPrice.toFixed(2);
$('.itemPrice',row).text(totalPrice);
},
complete : function(rowCount){
var totals = $.sumItems('.itemPrice');
$('#total').text(totals['total']);
$('#total_iva').text(totals['totalIva']);
$('#total_revTax').text(totals['totalRevTax']);
$('tr:even', this).addClass('rowHighlight');
$("#tbl_Shop").trigger("update");
$('.loadSpinner').hide();
}
});
//print incidents accoring to current incidents template in new window or download as pdf
$("#btn_print")
.button({
icons: {
primary: "ui-icon-print"
}
})
.click(function(e){
var shopId = gSelShopRow.attr('shopId');
var date = gSelShopRow.attr('dateForShop');
var op_name = gSelShopRow.attr('operatorName');
var op_uf = gSelShopRow.attr('operatorUf');
var printWin = window.open('tpl/<?=$tpl_print_bill;?>?shopId='+shopId+'&date='+date+'&operatorName='+op_name+'&operatorUf='+op_uf);
printWin.focus();
printWin.print();
return false;
});//end print menu
//uf select
$('#uf_select').xml2html('init',{
offSet : 1,
url : 'php/ctrl/UserAndUf.php',
params : 'oper=getUfListing',
loadOnInit:true
//event listener to load items for this uf to validate
}).change(function(){
//get the id of the uf
var uf_id = $("option:selected", this).val();
if (uf_id < 1){
$('#tbl_Shop tbody').xml2html('reload',{
params : 'oper=getShopListing&filter=prev3Month'
})
} else {
$('#tbl_Shop tbody').xml2html('reload',{
params : 'oper=getShopListing&uf_id='+uf_id+'&filter=all'
})
}
});
//EXPORT STUFF
$('#dialog_export_options').dialog({
autoOpen:false,
width:520,
height:500,
buttons: {
"<?=$Text['btn_ok'];?>" : function(){
exportCart();
},
"<?=$Text['btn_close'];?>" : function(){
$( this ).dialog( "close" );
}
}
});
$('#btn_export')
.button({
icons: {
primary: "ui-icon-transferthick-e-w"
}
})
.click(function(e){
$('#dialog_export_options')
.dialog("open");
})
.hide();
function checkExportForm(){
var frmData = $('#frm_export_options').serialize();
if (!$.checkFormLength($('input[name=exportName]'),1,150)){
$.showMsg({
msg:"File name cannot be empty!",
type: 'error'});
return false;
}
return frmData;
}
//export cart
function exportCart(){
var frmData = checkExportForm();
if (frmData){
var urlStr = "php/ctrl/ImportExport.php?oper=exportCart&shopId="+gSelShopRow.attr('shopId')+"&" + frmData;
//load the stuff through the export channel
$('#exportChannel').attr('src',urlStr);
}
}
/**********************************
*
* SWITCHING STUFF
*
**********************************/
function switchTo(section){
switch (section){
case 'detail':
$('.overviewElements').hide();
$('.detailElements').fadeIn(1000);
break;
case 'overview':
$('.detailElements').hide();
$('.overviewElements').fadeIn(1000);
break;
}
}
/**
* returns to order overview
*/
var label = 'Overview';
if (gBackTo != ''){
label = 'Back to validate';
}
$("#btn_overview").button({
icons: {
primary: "ui-icon-circle-arrow-w"
},
label: label
})
.click(function(e){
if (gBackTo != ''){
window.location.href = 'validate.php';
} else {
switchTo('overview');
}
});
switchTo('overview');
}); //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">
<div id="titlewrap" class="ui-widget">
<div id="titleLeftCol">
<button id="btn_overview" class="floatLeft detailElements"><?php echo $Text['overview'];?></button>
<h1 class="overviewElements"><?php echo $Text['ti_all_sales']; ?></h1>
<h1 class="detailElements"><?php echo $Text['purchase_details']; ?><span class="setCartId"></span></h1>
<p class="floatRight detailElements"><?php echo $Text['validated'];?>: <span class="ui-corner-all padding5x5 setValidateStatus"></span></p>
</div>
<div id="titleRightCol">
<button id="btn_print" class="detailElements btn_right"><?=$Text['printout'];?></button>
<button id="btn_export" class="detailElements floatRight"><?php echo $Text['btn_export']; ?></button>
<p class="textAlignRight overviewElements">
<select id="uf_select">
<option value="-10" selected="selected"><?php echo $Text['filter_uf']; ?></option>
<option value="{id}">{id} {name}</option>
</select>
</p>
</div>
</div>
<div id="shop_list" class="ui-widget overviewElements">
<div class="ui-widget-content ui-corner-all">
<h3 class="ui-widget-header ui-corner-all"> <span style="float:right; margin-top:-4px;"><img class="loadSpinner" src="img/ajax-loader.gif"/></span></h3>
<table id="tbl_Shop" class="tblListingDefault">
<thead>
<tr>
<th></th>
<th class="textAlignCenter clickable">Cart id <span class="ui-icon ui-icon-triangle-2-n-s floatLeft"></span></th>
<th class="clickable"><?php echo $Text['uf_long']; ?><span class="ui-icon ui-icon-triangle-2-n-s floatLeft"></span></th>
<th class="clickable"><p class="textAlignCenter"><?php echo $Text['purchase_date'];?> <span class="ui-icon ui-icon-triangle-2-n-s floatLeft"></span></p></th>
<th><p class="textAlignCenter"><?php echo $Text['validated'];?></p></th>
<th><p class="textAlignRight"><?php echo $Text['total'];?></p></th>
</tr>
</thead>
<tbody>
<tr class="clickable" id="shop_{id}" shopId="{id}" ufId={uf_id} dateForShop="{date_for_shop}" validated="{ts_validated}" operatorName="{operator_name}" operatorUf="{operator_uf}">
<td></td>
<td><p>{id}</p></td>
<td><p>{uf_id} {uf_name}</p></td>
<td><p class="textAlignCenter">{date_for_shop}</p></td>
<td>{ts_validated}</td>
<td><p class="textAlignRight">{purchase_total}<?=$Text['currency_sign'];?></p></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<td colspan="6">
<!-- p class="textAlignCenter">
<button id="btn_prevPurchase">Previous</button> Dates
<button id="btn_nextPurchase">Next</button></p-->
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div id="shop_detail" class="ui-widget detailElements">
<div class="ui-widget-content ui-corner-all">
<h3 class="ui-widget-header"><?php echo $Text['purchase_uf']; ?><span class="setUfId"></span>, <span class="setShopDate"></span><span style="float:right; margin-top:-4px;"><img class="loadSpinner" src="img/ajax-loader.gif"/></span></h3>
<table id="tbl_purchaseDetail" class="tblListingGrid" currentShopId="" currenShopDate="">
<thead>
<tr>
<th><?php echo $Text['name_item'];?></th>
<th><?php echo $Text['provider_name'];?></th>
<th><p class="textAlignRight"><?php echo $Text['quantity_short']; ?></p></th>
<th><?php echo $Text['unit'];?></th>
<th><p class="textAlignRight"><?php echo $Text['revtax_abbrev']; ?></p></th>
<th><p class="textAlignRight"><?php echo $Text['iva']; ?></p></th>
<th><p class="textAlignRight"><?php echo $Text['unit_price'];?></p></th>
<th class="width-180"><p class="textAlignRight"><?php echo $Text['price'];?></p></th>
</tr>
</thead>
<tbody>
<tr class="detail_shop_{cart_id}">
<td>{name}</td>
<td>{provider_name}</td>
<td><p class="textAlignRight qu">{quantity}</p></td>
<td>{unit}</td>
<td><p class="textAlignRight">{rev_tax_percent}%</p></td>
<td><p class="textAlignRight">{iva_percent}%</p></td>
<td><p class="textAlignRight up">{unit_price}</p></td>
<td><p class="textAlignRight itemPrice" iva="{iva_percent}" revTax="{rev_tax_percent}"></p></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7" class="boldStuff"><?php echo $Text['total'];?></td>
<td id="total" class="boldStuff dblBorderBottom dblBorderTop"></td>
</tr>
<tr>
<td colspan="7"><?php echo $Text['incl_iva']; ?></td>
<td id="total_iva" class="dblBorderTop"></td>
</tr>
<tr>
<td colspan="7"><?php echo $Text['incl_revtax']; ?></td>
<td id="total_revTax"></td>
</tr>
<tr>
<td colspan="8"><p> </p></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<!-- end of stage wrap -->
</div>
<!-- end of wrap -->
<!-- / END -->
<iframe name="dataFrame" style="display:none"></iframe>
<iframe id="exportChannel" src="" style="display:none; visibility:hidden;"></iframe>
<div id="dialog_export_options" title="<?php echo $Text['export_options']; ?>">
<?php include("tpl/export_dialog.php");?>
</div>
</body>
</html>