forked from yoyoren/mordercms
/
pro_print.php
258 lines (211 loc) · 8.88 KB
/
pro_print.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
<?php
/**
* 生产打印
* @author: bisc
*/
@require(dirname(__FILE__) . '/includes/init.php');
$_REQUEST['act'] = empty($_REQUEST['act']) ? 'list' : trim($_REQUEST['act']);
if ($_REQUEST['act'] == 'list') {
$smarty->assign('tdm', date('Y-m-d'));
$smarty->assign('ur_here', '生产打印');
$smarty->assign('full_page', 1);
$smarty->assign('city_arr', $_SESSION['city_arr']);
$turn=getTurn();
//print_r($turn);exit;
$smarty->assign('turn', $turn);
$smarty->assign('cakes', $goods_array);
//蛋糕种类
$sql="select goods_id,goods_sn,goods_name from ecs_goods";
$goods_array=$db_read->getAll($sql);
//print_r($goods_array);
$smarty->assign('cakes', $goods_array);
$_REQUEST['printp'] = 2;
$list = order_list();
$smarty->assign('record_count', $list['record_count']);
$smarty->assign('page_count', $list['page_count']);
$smarty->assign('cake_count', $list['cake_count']);
$smarty->assign('filter', $list['filter']);
$smarty->assign('orders', $list['list']);
$smarty->display('pro_print_list.htm');
}
/*------------------------------------------------------ */
//-- 排序、分页、查询
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'query')
{
$list = order_list();
$smarty->assign('record_count', $list['record_count']);
$smarty->assign('page_count', $list['page_count']);
$smarty->assign('cake_count', $list['cake_count']);
$smarty->assign('filter', $list['filter']);
$smarty->assign('orders', $list['list']);
$smarty->assign('td', date('Y-m-d'));
make_json_result($smarty->fetch('pro_print_list.htm'), '', array('filter' => $list['filter'], 'page_count' => $list['page_count']));
}
elseif ($_REQUEST['act'] == 'print')
{
if (empty($_REQUEST['order_id'])) die('wrong orders!');
if (empty($_REQUEST['sdate'])) die('wrong best_time!');
$order_count = $goods_count = 0;
$html = "";
$bdate = trim($_REQUEST['sdate']);
$order_sn_list = explode(',', $_REQUEST['order_id']);
$num=0;
$cakesum_sn='0';
foreach ($order_sn_list as $order_id)
{
if($order_id != 'all')
{
$admin_id = $_SESSION['admin_id'];
$group = $_SESSION['city_group'];
$psn = get_print_sn($order_id,$bdate,$admin_id,$group,1);
//$psn = get_print_sn1($order_id,$bdate,$admin_id,$group,1);
$res = pro_print1($order_id);
//print_r($res);
$result=print_goods($order_id);
//$candle=$result['candle'];
//$candle=$res[0]['candle'];
$cakesum=$result['cakenum'];
$cakesum_array=array();
for($i=1;$i<=$cakesum;$i++){
if($i<10){
$cakesum_array[]='0'.$i;
}else{
$cakesum_array[]=$i;
}
//$cakesum_sn=$cakesum_array[$i];
//$smarty->assign('cake_sn', $cakesum_sn);
}
//echo $cakesum;
// print_r($cakesum_array);
$sql = "select a.turn,b.route_name,a.add_time from order_dispatch as a,ship_route as b where a.route_id=b.route_id and a.order_id=".$order_id;
$pack = $db_read->getRow($sql);
$pack['add_time']=date('Y-m-d H:i',$pack['add_time']);
foreach ($res as $key=>$val)
{
$smarty->assign('order', $val);
$smarty->assign('pack', $pack);
$smarty->assign('print_sn', $psn);
// $smarty->assign('candle', $candle);
$smarty->assign('cakesum', $cakesum);
$smarty->assign('cake_sn', $cakesum_array[$key]);
$html .= $smarty->fetch('produce_print_bj_d.html');
$num++;
}
}
}
$string='<!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">
<head runat="server">
<title>打印结果</title><body>';
$html =$string.'<div class="noprint"><h3 style="margin:0 20px">本次打印蛋糕数量:'.$num.'</h3><hr/></div></body></html>'.$html;
echo $html;exit;
}
elseif($_REQUEST['act'] == 'alert'){
$date = date('Y-m-d');
$city_code=array_keys($_SESSION['city_arr']);
$str=implode(',',$city_code);
$where = " where o.country in (".$str.") ";
$sql = "SELECT COUNT(*) FROM order_genid as a
left join ecs_order_info AS o on a.order_id=o.order_id
left join ecs_order_goods as g on o.order_id=g.order_id
left join order_dispatch as d on o.order_id=d.order_id
left join print_log_x as c on o.order_id = c.order_id
".$where." and o.order_status = 1 and d.status >0
and (c.stime = '' or c.stime is null) and o.best_time > '".$date."' and o.best_time < '".$date." 23:01:01' and g.goods_price >40";
$re = $db_read->getOne($sql);
echo $re;
}
/*
* 取得订单列表
*/
function order_list()
{
$os[0]='未确认';
$os[1]='已确认';
$os[2]='已取消';
$os[3]='无效';
$os[4]='退货';
$filter['turn'] = intval($_REQUEST['turn']);
$filter['stan'] = intval($_REQUEST['city']);
$filter['cake'] = trim($_REQUEST['cake']);
$filter['bdate'] = empty($_REQUEST['bdate']) ? date('Y-m-d') :trim($_REQUEST['bdate']);
$filter['status'] = empty($_REQUEST['order_status']) ? 1 : intval($_REQUEST['order_status']);
//$filter['prinp'] = '2';
$filter['prinp'] = trim($_REQUEST['printp']);
$filter['ordsn'] = trim($_REQUEST['order_sn']);
$filter['psn'] = trim($_REQUEST['print_sn']);
$filter['page'] = empty($_REQUEST['page']) || (intval($_REQUEST['page']) <= 0) ? 1 : intval($_REQUEST['page']);
$page = empty($_REQUEST['page']) || (intval($_REQUEST['page']) <= 0) ? 1 : intval($_REQUEST['page']);
$size = 30;
//$size = 2;
$city_code=array_keys($_SESSION['city_arr']);
$str=implode(',',$city_code);
$where = " where o.order_status = 1 and o.country in (".$str.") ";
if($filter['turn'])
{
$where .= " and d.turn = ".$filter['turn'];
}
if($filter['stan'])
{
$where .= " and o.country = ".$filter['stan'];
}
if($filter['status'])
{
$where .= " and d.status >0 ";
}
if($filter['cake'])
{
$where .= " and g.goods_id = '".$filter['cake']."' ";
}
if($filter['prinp'] == 1)
{
$where .= " and c.stime >0 ";
}
if($filter['prinp'] == 2)
{
$where .= " and (c.stime = '' or c.stime is null) ";
}
if($filter['bdate'])
{
$where .= " and o.best_time > '".$filter['bdate']."' and o.best_time < '".$filter['bdate']." 23:01:01' ";
}
if($filter['ordsn'])
{
$where = " where o.order_sn = '".$filter['ordsn']."' ";
}
if($filter['psn'])
{
$where = " where o.best_time > '".$filter['bdate']."' and o.best_time < '".$filter['bdate']." 23:01:01' and c.city_group=".$_SESSION['city_group']." and c.print_sn = '".$filter['psn']."' ";
}
/*原系统的订单打印记录数*/
/* $sql = "SELECT COUNT(*) FROM order_genid as a left join ecs_order_info AS o on a.order_id=o.order_id left join ecs_order_goods as g on o.order_id=g.order_id ".
"left join order_dispatch as d on o.order_id=d.order_id left join print_log as c on o.order_id = c.order_id ". $where. " and g.goods_price >40 ";*/
/*修改后的订单打印记录数*/
$sql = "SELECT COUNT(*) FROM order_genid as a left join ecs_order_info AS o on a.order_id=o.order_id left join ecs_order_goods as g on o.order_id=g.order_id left join order_dispatch as d on o.order_id=d.order_id left join print_log_x as c on o.order_id = c.order_id ". $where. " and g.goods_price >40";
$record_count = $GLOBALS['db_read']->getOne($sql);
$page_count = $record_count > 0 ? ceil($record_count / $size) : 1;
$sql = "select o.order_id,o.order_sn,o.order_status,o.best_time,o.address,o.add_time,".
"c.stime,c.print_sn,c.st,group_concat(g.goods_name) as goods,sum(g.goods_number) as num ".
"from order_genid as a left join ecs_order_info as o on a.order_id=o.order_id ".
"left join ecs_order_goods as g on o.order_id=g.order_id ".
"left join order_dispatch as d on o.order_id=d.order_id ".
"left join print_log_x as c on o.order_id = c.order_id ".$where.
"and g.goods_price>40 group by o.order_id order by o.best_time ".
"LIMIT " . ($filter['page'] - 1) * $size . ",$size";
$rs = $GLOBALS['db_read']->getAll($sql);
$n = 0;
foreach ($rs as $key => $val)
{
$sql = "select status from order_dispatch where order_id=".$val['order_id'];
$rs[$key]['status'] = $GLOBALS['db_read']->getOne($sql);
$rs[$key]['add_time'] = date('Y-m-d H:i',$val['add_time']);
$rs[$key]['best_time'] = substr($val['best_time'],0,16);
$rs[$key]['order_status'] = $os[$val['order_status']];
$rs[$key]['i'] = $key + 1;
$n += $val['num'];
}
$arr = array('list' => $rs, 'filter' => $filter, 'page_count' => $page_count, 'record_count' => $record_count,'cake_count' => $n);
return $arr;
}
?>