forked from jmueller17/Aixada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_shop_providers.php
363 lines (269 loc) · 10.3 KB
/
report_shop_providers.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
<?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'] . " - " . $Text['nav_report_shop_pv'] ;?></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"/>
<?php if (isset($_SESSION['dev']) && $_SESSION['dev'] == true ) { ?>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jqueryui/jqueryui.js"></script>
<script type="text/javascript" src="js/fgmenu/fg.menu.js"></script>
<script type="text/javascript" src="js/aixadautilities/jquery.aixadaMenu.js"></script>
<script type="text/javascript" src="js/aixadautilities/jquery.aixadaXML2HTML.js" ></script>
<script type="text/javascript" src="js/aixadautilities/jquery.aixadaUtilities.js" ></script>
<script type="text/javascript" src="js/tablesorter/jquery.tablesorter.js" ></script>
<?php } else { ?>
<script type="text/javascript" src="js/js_for_report_shop_providers.min.js"></script>
<?php }?>
<script type="text/javascript" src="js/jqueryui/i18n/jquery.ui.datepicker-<?=$language;?>.js" ></script>
<script type="text/javascript">
$(function(){
var gUniqueProviders = [];
var gProviderId = 0;
//loading animation
$('.loadSpinner').attr('src', "img/ajax-loader-<?=$default_theme;?>.gif").hide();
$("#datepicker_from").datepicker({
dateFormat : 'DD, d MM, yy',
onSelect : function (dateText, instance){
$('#setFromDate').text(dateText);
}
});
$("#datepicker_to").datepicker({
dateFormat : 'DD, d MM, yy',
onSelect : function (dateText, instance){
$('#setToDate').text(dateText);
}
});
/********************************************************
* PURCHASE LISTING
********************************************************/
//the table sorter plugin
//$("#tbl_Providers").tablesorter();
$("#tbl_Providers").bind('sortEnd', function(){
$('tr',this).removeClass('rowHighlight')
$('tr:even',this).addClass('rowHighlight');
});
//load purchase listing
$('#tbl_Providers tbody').xml2html('init',{
url : 'php/ctrl/Shop.php',
params : 'oper=getTotalSalesByProviders&filter=prevMonth&provider_id=0',
loadOnInit : true,
beforeLoad : function(){
$('.loadSpinner').show();
},
rowComplete : function(rowIndex, row){
var pvid = $(row).children().eq(0).text();
var date = $(row).children().eq(2).text();
var total = new Number($(row).children().eq(3).text());
$(row).children().eq(2).text($.getCustomDate(date, 'd MM, yy'));
$(row).children().eq(3).text(total.toFixed(2));
gUniqueProviders.push(pvid);
},
complete : function(rowCount){
//$('tr:even', this).addClass('rowHighlight');
//$("#tbl_Providers").trigger("update");
$('.loadSpinner').hide();
var unique=gUniqueProviders.filter(function(itm,i,a){
return i==gUniqueProviders.indexOf(itm);
});
for (var i=0; i<unique.length; i++){
var sum_provider = 0;
$('.total_'+unique[i]).each(function(){
sum_provider += new Number($(this).text());
});
var nrows = $('.pvid_'+unique[i]).length;
$('.pvid_'+unique[i]).first().append('<td rowspan="'+nrows+'" id="sumCell_'+unique[i]+'" ><p class="textAlignRight boldStuff">'+sum_provider.toFixed(2)+'</p></td>');
}
if (rowCount == 0){
$.showMsg({
msg:"<?=$Text['msg_err_order_filter'];?>",
type: 'warning'});
}
}
});
$('#tbl_Providers tbody tr')
.live('mouseover', function(){
$(this).removeClass('highlight').addClass('ui-state-hover');
var pvid = $(this).attr('providerId');
$('#sumCell_'+pvid).addClass('ui-state-hover');
})
.live('mouseout',function(){
$(this).removeClass('ui-state-hover');
var pvid = $(this).attr('providerId');
$('#sumCell_'+pvid).removeClass('ui-state-hover');
})
.live('click',function(e){
});
$("#tblViewOptions")
.button({
icons: {
secondary: "ui-icon-triangle-1-s"
}
})
.menu({
content: $('#tblOptionsItems').html(),
showSpeed: 50,
width:280,
flyOut: true,
itemSelected: function(item){ //TODO instead of using this callback function make your own menu; if jquerui is updated, this will not work
//show hide deactivated products
var filter = $(item).attr('id');
if (filter == 'provider'){
$("#providerSelect").val(-1).attr('selected', true);
//open dialog
$('#dialog_providerSelect').dialog("open");
} else if (filter == 'exact'){
//open datepicker dialog
$('#dialog_exactDate').dialog("open");
} else {
$('#tbl_Providers tbody').xml2html('reload',{
params : 'oper=getTotalSalesByProviders&filter='+filter+'&provider_id='+gProviderId,
});
}
}//end item selected
});//end menu
$('#dialog_exactDate').dialog({
autoOpen:false,
width:680,
height:500,
buttons: {
"<?=$Text['btn_ok'];?>" : function(){
$('#tbl_Providers tbody').xml2html('reload',{
params : 'oper=getTotalSalesByProviders&filter=exact&provider_id='+gProviderId+'&from_date='+$.getSelectedDate('#datepicker_from')+'&to_date='+$.getSelectedDate('#datepicker_to'),
});
$( this ).dialog( "close" );
},
"<?=$Text['btn_close'];?>" : function(){
$( this ).dialog( "close" );
}
}
});
$('#dialog_providerSelect').dialog({
autoOpen:false,
width:400,
height:200,
buttons: {
"<?=$Text['btn_close'];?>" : function(){
$( this ).dialog( "close" );
}
}
});
$("#providerSelect").xml2html("init", {
url : 'php/ctrl/ShopAndOrder.php',
params : 'oper=getShopProviders',
loadOnInit: true,
offSet : 2
}).change(function(){
gProviderId = $("option:selected", this).val();
if (gProviderId == 0){
var filter = 'prevMonth';
} else {
var filter = 'all';
}
$('#dialog_providerSelect').dialog("close");
$('#tbl_Providers tbody').xml2html('reload',{
params : 'oper=getTotalSalesByProviders&filter='+filter+'&provider_id='+gProviderId,
});
}); //end select change
/********************************************************
* DETAIL PURCHASE VIEW
********************************************************/
function switchTo(section){
switch (section){
case 'detail':
$('.overviewElements').hide();
$('.detailElements').fadeIn(1000);
break;
case 'overview':
$('.detailElements').hide();
$('.overviewElements').fadeIn(1000);
break;
}
}
}); //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_report_shop_pv']; ?></h1>
</div>
<div id="titleRightCol">
<button id="tblViewOptions" class="overviewElements btn_right"><?=$Text['btn_filter']; ?></button>
<div id="tblOptionsItems" class="hidden">
<ul>
<li><a href="javascript:void(null)" id="today"><?=$Text['filter_todays'];?></a></li>
<li><a href="javascript:void(null)" id="prevMonth"><?=$Text['filter_month'] ; ?></a></li>
<li><a href="javascript:void(null)" id="all"><?=$Text['filter_all_sales']; ?></a></li>
<li><a href="javascript:void(null)" id="exact"><?=$Text['filter_exact'];?></a></li>
<li><a href="javascript:void(null)" id="provider"><?=$Text['by_provider'] ; ?></a></li>
</ul>
</div>
</div>
</div>
<div id="purchase_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_Providers" class="tblListingDefault">
<thead>
<tr>
<th class="textAlignCenter"><?php echo $Text['provider']; ?></th>
<th class="textAlignCenter"><?php echo $Text['purchase_date']; ?> </th>
<th><p class="textAlignRight"><?php echo $Text['total_4date']; ?></p> </th>
<th><p class="textAlignRight"><?php echo $Text['total_4provider']; ?></p></th>
</tr>
</thead>
<tbody>
<tr class="pvid_{provider_id}" providerId="{provider_id}">
<td class="hidden">{provider_id}</td>
<td>{provider_name}</td>
<td>{date_for_shop}</td>
<td class="total_{provider_id} floatRight">{total}</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
</div>
<!-- end of stage wrap -->
</div>
<!-- end of wrap -->
<!-- / END -->
<div id="dialog_exactDate" title="<?php echo $Text['sel_sales_dates_ti']; ?>">
<p> </p>
<p><?php echo $Text['sel_sales_dates']; ?></p>
<br/>
<table>
<tr>
<td><?php echo $Text['date_from']; ?>:</td>
<td><input type="text" id="datepicker_from" class="ui-corner-all"/></td>
<td> </td>
<td><?php echo $Text['date_to']; ?>:</p></td>
<td><input type="text" id="datepicker_to"/></td>
</tr>
</table>
</div>
<div id="dialog_providerSelect" title="<?php echo $Text['by_provider'];?>">
<p> </p>
<select id="providerSelect" class="longSelect">
<option value="-1" selected="selected"><?php echo $Text['sel_provider']; ?></option>
<option value="0"><?php echo $Text['filter_all']; ?></option>
<option value="{id}"> {name}</option>
</select>
</div>
</body>
</html>