| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794 | 
							- <?php
 
- /*
 
-  * Scanner Class
 
-  * by lijg 20181107
 
-  */
 
- require_once 'trdLibrary/PHPExcel/PHPExcel.php';
 
- require_once 'library/mdb.php';
 
- require_once 'library/common.php';
 
- class WigsOutCtrl{
 
-     public function __construct(){
 
-         $this->db = new MdbLib();
 
-         $this->common = new CommonLib();
 
-         $this->skey = '2019';
 
-     }
 
-     //show
 
-     public function getOrders(){
 
-         if(!isset($_GET['now']) || !isset($_GET['shop'])  || !isset($_GET['status']) || !isset($_GET['startDate']) || !isset($_GET['endDate']) || !isset($_GET['type'])){
 
-             return false;
 
-         }else{
 
-             $now = $this->common->my_filter_input($_GET['now']);
 
-             $shop = $this->common->my_filter_input($_GET['shop']);
 
-             $status = $this->common->my_filter_input($_GET['status']);
 
-             $type = $this->common->my_filter_input($_GET['type']);
 
-             $startDate = $_GET['startDate'] . ' 00:00:00';
 
-             $endDate = $_GET['endDate'].' 23:59:59';
 
-             $key = $this->common->my_filter_input($_GET['key']);
 
-             $pnsn = isset($_GET['pnsn'])?$this->common->my_filter_input($_GET['pnsn']):15;
 
-         }
 
-         
 
-         $shop_type = '';
 
-         switch($shop){
 
-             case 1:
 
-                 $shop_type = 'AAASSS';
 
-                 break;
 
-             case 2:
 
-                 $shop_type = 'Alipearl';
 
-                 break;
 
-             case 3:
 
-                 $shop_type = 'QQ';
 
-                 break;
 
-             case 4:
 
-                 $shop_type = 'SuperNova';
 
-                 break;
 
-             case 5:
 
-                 $shop_type = 'West-Kiss';
 
-                 break;
 
-             case 6:
 
-                 $shop_type = 'Yolissa';
 
-                 break;
 
-             default:
 
-                 $shop_type = '';
 
-         }
 
-         
 
-         $offset = ($now-1)*$pnsn;
 
-         $sql = 'SELECT `oid`,`order_barcode`,`order_status`,`goods_no`,`goods_info`,`out_time`,`gir`,`in_time`,`print_time`,`memo`,`transport`,`print_times`,`print_date` ';
 
-         $sql .= 'FROM `app_wigsout` '; 
 
-         $sql .= "WHERE `print_time` BETWEEN '{$startDate}' AND '{$endDate}'";
 
-         
 
-         if($shop != 0){
 
-             $sql .= " AND `order_barcode` LIKE '{$shop_type}%' ";
 
-         }
 
-         if($status != 0){
 
-             $sql .= " AND `order_status`='{$status}' ";
 
-         }
 
-         if($type != 0){
 
-             $sql .= " AND `type`='{$type}' ";
 
-         }
 
-         
 
-         $sql .= "ORDER BY `order_status` ASC,`in_time` DESC,`print_time` DESC LIMIT {$offset},$pnsn;";
 
-         $query = $this->db->querySql($sql);
 
-         
 
-         $line = "";
 
-         while($item = $this->db->queryRs($query)) {
 
-             if($item['order_status'] == '2'){
 
-                 $order_status = "已入库";
 
-                 $in_time = $item['in_time'];
 
-                 $out_time = '暂无';
 
-                 $class = 'ok1';
 
-             }elseif($item['order_status'] == '5'){
 
-                 $order_status = "未入库";
 
-                 $in_time = '暂无';
 
-                 $out_time = '暂无';
 
-                 $class = 'no';
 
-             }elseif($item['order_status'] == '3'){
 
-                 $order_status = "已出库";
 
-                 $in_time = $item['in_time'];
 
-                 $out_time = $item['out_time'];
 
-                 $class = 'ok2';
 
-             }elseif($item['order_status'] == '4'){
 
-                 $order_status = "已取消";
 
-                 $in_time = '暂无';
 
-                 $out_time = '暂无';
 
-                 $class = 'canceled';
 
-             }
 
-             if($item['gir'] == 1){
 
-                 $repeat = 'repeat';
 
-             }else{
 
-                 $repeat = '';
 
-             }
 
-             if($item['print_times'] == 0){
 
-                 $print_status = "未打印";
 
-                 $print_clazz = 'no';
 
-             }else{
 
-                 $print_status = "已打印";
 
-                 $print_clazz = 'ok2';
 
-             }
 
-             
 
-             $line .= '<div class="list_block">';
 
-             $line .= "<span class=\"order_id\" data-transport=\"{$item['transport']}\" data-printtime=\"{$item['print_time']}\">{$item['oid']}</span>";
 
-             $line .= "<span class=\"order_barcode\" title=\"{$item['order_barcode']}\">{$item['order_barcode']}</span>";
 
- //             $line .= "<span class=\"goods_no {$repeat}\">{$item['goods_no']}</span>";
 
-             $line .= "<span class=\"goods_info\" title=\"{$item['goods_info']}\">{$item['goods_info']}</span>";
 
- //             $line .= "<span class=\"transport\">{$item['transport']}</span>";
 
-             $line .= "<span class=\"order_status {$class}\">{$order_status}</span>";
 
-             $line .= "<span class=\"in_time\">{$in_time}</span>";
 
-             $line .= "<span class=\"out_time\">{$out_time}</span>";
 
-             $line .= "<span class=\"memo\" title=\"{$item['memo']}\">{$item['memo']}</span>";
 
-             $line .= "<span class=\"print_status {$print_clazz}\" title=\"{$print_status}\">{$print_status}</span>";
 
-             $line .= "<span class=\"print_date\">{$item['print_date']}</span>";
 
-             $line .= '<span class="options">';
 
-             $line .= "<input type=\"button\" class=\"print_bc\" data-id=\"{$item['oid']}\" value=\"打印\">";
 
-             if(!empty($key) && $key==$this->skey){
 
-                 $line .= "<input type=\"button\" class=\"update_memo\" data-id=\"{$item['oid']}\" value=\"备注\">";
 
-                 if($item['order_status'] == '1' || $item['order_status'] == '2'){
 
-                     $line .= "<input type=\"button\" class=\"cancel_order\" data-barcode=\"{$item['order_barcode']}\" value=\"取消\">";
 
-                 }
 
-             }
 
-             $line .= '</span></div>';
 
-         }
 
-         return $line;
 
-     }
 
-     
 
-     public function searchOrders(){
 
-         if(!isset($_GET['key'])){
 
-             return false;
 
-         }else{
 
-             $key = $this->common->my_filter_input($_GET['key']);
 
-         }
 
-         
 
-         $sql = 'SELECT `oid`,`order_barcode`,`order_status`,`goods_no`,`goods_info`,`out_time`,`gir`,`in_time`,`print_time`,`memo`,`transport`,`print_times`,`print_date` ';
 
-         $sql .= 'FROM `app_wigsout` ';
 
-         if(isset($_GET['code'])){
 
-             $code = $this->common->my_filter_input($_GET['code']);
 
-             $sql .= "WHERE `order_barcode`='{$code}' OR `goods_no`='{$code}';";
 
-         }
 
-         
 
-         $query = $this->db->querySql($sql);
 
-         
 
-         $line = "";
 
-         while($item = $this->db->queryRs($query)) {
 
-             if($item['order_status'] == '2'){
 
-                 $order_status = "已入库";
 
-                 $in_time = $item['in_time'];
 
-                 $out_time = '暂无';
 
-                 $class = 'ok1';
 
-             }elseif($item['order_status'] == '5'){
 
-                 $order_status = "未入库";
 
-                 $in_time = '暂无';
 
-                 $out_time = '暂无';
 
-                 $class = 'no';
 
-             }elseif($item['order_status'] == '3'){
 
-                 $order_status = "已出库";
 
-                 $in_time = $item['in_time'];
 
-                 $out_time = $item['out_time'];
 
-                 $class = 'ok2';
 
-             }
 
-             
 
-             if($item['gir'] == 1){
 
-                 $repeat = 'repeat';
 
-             }else{
 
-                 $repeat = '';
 
-             }
 
-             
 
-             if($item['print_times'] == 0){
 
-                 $print_status = "未打印";
 
-                 $print_clazz = 'no';
 
-             }else{
 
-                 $print_status = "已打印";
 
-                 $print_clazz = 'ok2';
 
-             }
 
-             
 
-             $line .= '<div class="list_block">';
 
-             $line .= "<span class=\"order_id\" data-transport=\"{$item['transport']}\" data-printtime=\"{$item['print_time']}\">{$item['oid']}</span>";
 
-             $line .= "<span class=\"order_barcode\" title=\"{$item['order_barcode']}\">{$item['order_barcode']}</span>";
 
- //             $line .= "<span class=\"goods_no {$repeat}\">{$item['goods_no']}</span>";
 
-             $line .= "<span class=\"goods_info\" title=\"{$item['goods_info']}\">{$item['goods_info']}</span>";
 
- //             $line .= "<span class=\"transport\">{$item['transport']}</span>";
 
-             $line .= "<span class=\"order_status {$class}\">{$order_status}</span>";
 
-             $line .= "<span class=\"in_time\">{$in_time}</span>";
 
-             $line .= "<span class=\"out_time\">{$out_time}</span>";
 
-             $line .= "<span class=\"memo\" title=\"{$item['memo']}\">{$item['memo']}</span>";
 
-             $line .= "<span class=\"print_status {$print_clazz}\" title=\"{$print_status}\">{$print_status}</span>";
 
-             $line .= "<span class=\"print_date\">{$item['print_date']}</span>";
 
-             $line .= '<span class="options">';
 
-             $line .= "<input type=\"button\" class=\"print_bc\" data-id=\"{$item['oid']}\" value=\"打印\">";
 
-             if(!empty($key) && $key==$this->skey){
 
-                 $line .= "<input type=\"button\" class=\"update_memo\" data-id=\"{$item['oid']}\" value=\"备注\">";
 
-                 if($item['order_status'] == '1' || $item['order_status'] == '2'){
 
-                     $line .= "<input type=\"button\" class=\"cancel_order\" data-barcode=\"{$item['order_barcode']}\" value=\"取消\">";
 
-                 }
 
-             }
 
-             $line .= '</span></div>';
 
-         }
 
-         if(!empty($line)){
 
-             return $line;
 
-         }else{
 
-             return -1;
 
-         }
 
-     }
 
-     
 
-     public function updateOrder(){
 
-         if(isset($_GET['code']) && !empty($_GET['code']) && isset($_GET['status']) && !empty($_GET['status'])){
 
-             $code = $this->common->my_filter_input($_GET['code']);
 
-             $order_status = $this->common->my_filter_input($_GET['status']);
 
-         }else{
 
-             return false;
 
-         }
 
-         
 
-         $sql_status = "SELECT `order_status`,`out_time`,`in_time`,`update_time` FROM `app_wigsout` WHERE `order_barcode`='{$code}' ORDER BY `oid` DESC;";
 
-         $query = $this->db->querySql($sql_status);
 
-         $arr_status = $this->db->queryRsAll($query);
 
-         if(empty($arr_status)){
 
-             return json_encode(array(
 
-                 'no' => '-10'
 
-             ));
 
-         }
 
-         
 
-         $now = date("Y-m-d H:i:s", time());
 
-         $sql = "UPDATE `app_wigsout` SET `order_status`='{$order_status}',`in_time`='{$now}',`out_time`='{$now}' WHERE `order_barcode`='{$code}' AND `order_status`!=4;";
 
-         if($arr_status[0]['order_status'] == 5 && $order_status == 2){
 
-             $this->db->querySql($sql);
 
-             if($this->db->queryAR() == 1){
 
-                 return json_encode(array(
 
-                     'no' => '1'
 
-                 ));
 
-             }else{
 
-                 return json_encode(array(
 
-                     'no' => '-1'
 
-                 ));
 
-             }
 
-         }elseif($arr_status[0]['order_status'] == 2 && $order_status == 3){
 
-             $this->db->querySql($sql);
 
-             if($this->db->queryAR() == 1){
 
-                 return json_encode(array(
 
-                     'no' => '2'
 
-                 ));
 
-             }else{
 
-                 return json_encode(array(
 
-                     'no' => '-2'
 
-                 ));
 
-             }
 
-         }elseif(($arr_status[0]['order_status'] == 5 OR $arr_status[0]['order_status'] == 2) && $order_status == 4){
 
-             $this->db->querySql($sql);
 
-             if($this->db->queryAR() == 1){
 
-                 return json_encode(array(
 
-                     'no' => '3'
 
-                 ));
 
-             }else{
 
-                 return json_encode(array(
 
-                     'no' => '-3'
 
-                 ));
 
-             }
 
-         }elseif($arr_status[0]['order_status'] == 5 && $order_status == 3){
 
-             return json_encode(array(
 
-                 'no' => '-4'
 
-             ));
 
-         }elseif($arr_status[0]['order_status'] == 2 && $order_status == 2){
 
-             return json_encode(array(
 
-                 'no' => '-5',
 
-                 'time' => $arr_status[0]['in_time'],
 
-             ));
 
-         }elseif($arr_status[0]['order_status'] == 3 && $order_status == 2){
 
-             return json_encode(array(
 
-                 'no' => '-6',
 
-                 'time' => $arr_status[0]['out_time'],
 
-             ));
 
-         }elseif($arr_status[0]['order_status'] == 3 && $order_status == 3){
 
-             return json_encode(array(
 
-                 'no' => '-7',
 
-                 'time' => $arr_status[0]['out_time'],
 
-             ));
 
-         }elseif($arr_status[0]['order_status'] == 4 && $order_status == 2){
 
-             return json_encode(array(
 
-                 'no' => '-8',
 
-                 'time' => $arr_status[0]['update_time'],
 
-             ));
 
-         }elseif($arr_status[0]['order_status'] == 4 && $order_status == 3){
 
-             return json_encode(array(
 
-                 'no' => '-9',
 
-                 'time' => $arr_status[0]['update_time'],
 
-             ));
 
-         }else{
 
-             return json_encode(array(
 
-                 'no' => '-11'
 
-             ));
 
-         }
 
-     }
 
-     
 
-     public function getStatistics(){
 
-         if(!isset($_GET['startDate']) || !isset($_GET['endDate'])){
 
-             return false;
 
-         } else {
 
-             $startDate = $_GET['startDate'] . ' 00:00:00';
 
-             $endDate = $_GET['endDate'].' 23:59:59';
 
-         }
 
-         
 
-         $yesterday_start = date("Y-m-d", strtotime('-1 day')) . ' 00:00:00';
 
-         $yesterday_end = date("Y-m-d", strtotime('-1 day')) . ' 23:59:59';
 
-         $sql_yesterday = "SELECT COUNT(`oid`) AS `total_yesterday_out` FROM `app_wigsout`";
 
-         $sql_yesterday .= " WHERE `print_time` BETWEEN '{$yesterday_start}' AND '{$yesterday_end}' AND `order_status`='3';";
 
-         
 
-         $sql_total = "SELECT COUNT(`oid`) AS `total_num` FROM `app_wigsout` ";
 
-         $sql_total .= "WHERE `print_time` BETWEEN '{$startDate}' AND '{$endDate}';";
 
-         
 
-         $sql_in = "SELECT COUNT(`oid`) AS `total_in` FROM `app_wigsout` ";
 
-         $sql_in .= "WHERE `print_time` BETWEEN '{$startDate}' AND '{$endDate}' AND `order_status`='2';";
 
-         
 
-         $sql_out = "SELECT COUNT(`oid`) AS `total_out` FROM `app_wigsout` ";
 
-         $sql_out .= "WHERE `print_time` BETWEEN '{$startDate}' AND '{$endDate}' AND `order_status`='3';";
 
-         
 
-         $sql_cancel = "SELECT COUNT(`oid`) AS `total_out` FROM `app_wigsout` ";
 
-         $sql_cancel .= "WHERE `print_time` BETWEEN '{$startDate}' AND '{$endDate}' AND `order_status`='4';";
 
-         
 
-         $query_yesterday = $this->db->querySql($sql_yesterday);
 
-         $rs_yesterday = $this->db->queryRs($query_yesterday);
 
-         
 
-         $query_total = $this->db->querySql($sql_total);
 
-         $rs_total = $this->db->queryRs($query_total);
 
-         
 
-         $query_in = $this->db->querySql($sql_in);
 
-         $rs_in = $this->db->queryRs($query_in);
 
-         
 
-         $query_out = $this->db->querySql($sql_out);
 
-         $rs_out = $this->db->queryRs($query_out);
 
-         
 
-         $query_cancel = $this->db->querySql($sql_cancel);
 
-         $rs_cancel = $this->db->queryRs($query_cancel);
 
-         
 
-         $rs = array();
 
-         $rs['yesterday'] = $rs_yesterday[0];
 
-         $rs['total'] = $rs_total[0];
 
-         $rs['in'] = $rs_in[0];
 
-         $rs['out'] = $rs_out[0];
 
-         $rs['cancel'] = $rs_cancel[0];
 
-         $rs['not_in'] = $rs['total'] - $rs['out'] - $rs['cancel'] - $rs['in'];
 
-         return json_encode($rs);
 
-     }
 
-     
 
-     public function exportExcel(){
 
-         set_time_limit(120);
 
-         $PHPExcel = new \PHPExcel();
 
-         if(!isset($_GET['shop'])  || !isset($_GET['status']) || !isset($_GET['startDate']) || !isset($_GET['endDate'])  || !isset($_GET['type'])){
 
-             return false;
 
-         }else{
 
-             $shop = $this->common->my_filter_input($_GET['shop']);
 
-             $status = $this->common->my_filter_input($_GET['status']);
 
-             $type = $this->common->my_filter_input($_GET['type']);
 
-             $startDate = $_GET['startDate'] . ' 00:00:00';
 
-             $endDate = $_GET['endDate'].' 23:59:59';
 
-         }
 
-         
 
-         $shop_type = '';
 
-         switch($shop){
 
-             case 1:
 
-                 $shop_type = 'AAASSS';
 
-                 break;
 
-             case 2:
 
-                 $shop_type = 'Alipearl';
 
-                 break;
 
-             case 3:
 
-                 $shop_type = 'QQ';
 
-                 break;
 
-             case 4:
 
-                 $shop_type = 'SuperNova';
 
-                 break;
 
-             case 5:
 
-                 $shop_type = 'West-Kiss';
 
-                 break;
 
-             case 6:
 
-                 $shop_type = 'Yolissa';
 
-                 break;
 
-             default:
 
-                 $shop_type = '';
 
-         }
 
-         $sql = 'SELECT `oid`,`order_barcode`,`order_status`,`goods_no`,`goods_info`,`out_time`,`in_time`,`print_time`,`transport` ';
 
-         $sql .= 'FROM `app_wigsout` ';
 
-         $sql .= "WHERE `print_time` BETWEEN '{$startDate}' AND '{$endDate}' ";
 
-         
 
-         if($shop != 0){
 
-             $sql .= " AND `order_barcode` LIKE '{$shop_type}%' ";
 
-         }
 
-         
 
-         if($status != 0){
 
-             $sql .= " AND `order_status`='{$status}' ";
 
-         }
 
-         if($type != 0){
 
-             $sql .= " AND `type`='{$type}' ";
 
-         }
 
-         $query = $this->db->querySql($sql);
 
-         $PHPExcel->setActiveSheetIndex(0)
 
-                 ->setCellValue('A1', '序号')
 
-                 ->setCellValue('B1', '条码编号')
 
-                 ->setCellValue('C1', '订单编号')
 
-                 ->setCellValue('D1', '货物明细')
 
-                 ->setCellValue('E1', '物流方式')
 
-                 ->setCellValue('F1', '状态')
 
-                 ->setCellValue('G1', '打印日期')
 
-                 ->setCellValue('H1', '入库日期')
 
-                 ->setCellValue('I1', '出库日期');
 
-         $k = 2;
 
-         while($item = $this->db->queryRs($query)) {
 
-             if($item['order_status'] == '2'){
 
-                 $order_status = "已入库";
 
-                 $in_time = $item['in_time'];
 
-                 $out_time = '暂无';
 
-             }elseif($item['order_status'] == '1'){
 
-                 $order_status = "未出库";
 
-                 $in_time = '暂无';
 
-                 $out_time = '暂无';
 
-             }elseif($item['order_status'] == '3'){
 
-                 $order_status = "已出库";
 
-                 $in_time = $item['in_time'];
 
-                 $out_time = $item['out_time'];
 
-             }
 
-             $PHPExcel->setActiveSheetIndex(0)
 
-             ->setCellValue('A'.$k, $k-1)
 
-             ->setCellValue('B'.$k, $item['order_barcode'])
 
-             ->setCellValue('C'.$k, $item['goods_no'])
 
-             ->setCellValue('D'.$k, $item['goods_info'])
 
-             ->setCellValue('E'.$k, $item['transport'])
 
-             ->setCellValue('F'.$k, $order_status)
 
-             ->setCellValue('G'.$k, $item['print_time'])
 
-             ->setCellValue('H'.$k, $in_time)
 
-             ->setCellValue('I'.$k, $out_time);
 
-             $k++;
 
-         }
 
-         
 
-         // set wdith
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(40);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(25);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(25);
 
-         $PHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(25);
 
-         
 
-         // set align
 
- //         $PHPExcel->getActiveSheet()->getStyle( 'A1:I1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 
 
-         $PHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
 
-         
 
-         $filename = 'wigsmgmt.'.date('His',time()).'.xls';
 
-         $PHPExcel->getActiveSheet()->setTitle('wigsmgmt');
 
-         $PHPExcel->setActiveSheetIndex(0);
 
-         
 
-         header("Content-Type: application/ms-excel; charset=utf-8");
 
-         header("Content-Disposition: attachment; filename={$filename}");
 
-         header("Expires: 0");
 
-         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 
-         header("Cache-Control: private",false);
 
-         $PHPWriter = new PHPExcel_Writer_Excel5($PHPExcel, 'Excel5');
 
-         $PHPWriter->save('php://output');
 
-     }
 
-     
 
-     public function pagination(){
 
-         if(!isset($_GET['shop']) || !isset($_GET['status']) || !isset($_GET['startDate']) || !isset($_GET['endDate']) || !isset($_GET['wh']) || !isset($_GET['type'])){
 
-             return false;
 
-         }else{
 
-             $shop = $this->common->my_filter_input($_GET['shop']);
 
-             $status = $this->common->my_filter_input($_GET['status']);
 
-             $startDate = $_GET['startDate'] . ' 00:00:00';
 
-             $endDate = $_GET['endDate'].' 23:59:59';
 
-             $wh = $this->common->my_filter_input($_GET['wh']);
 
-             $pnsn = isset($_GET['pnsn'])?$this->common->my_filter_input($_GET['pnsn']):15;
 
-             $type = $this->common->my_filter_input($_GET['type']);
 
-         }
 
-         
 
-         $shop_type = '';
 
-         switch($shop){
 
-             case 1:
 
-                 $shop_type = 'AAASSS';
 
-                 break;
 
-             case 2:
 
-                 $shop_type = 'Alipearl';
 
-                 break;
 
-             case 3:
 
-                 $shop_type = 'QQ';
 
-                 break;
 
-             case 4:
 
-                 $shop_type = 'SuperNova';
 
-                 break;
 
-             case 5:
 
-                 $shop_type = 'West-Kiss';
 
-                 break;
 
-             case 6:
 
-                 $shop_type = 'Yolissa';
 
-                 break;
 
-             default:
 
-                 $shop_type = '';
 
-         }
 
-         
 
-         $sql = "SELECT `oid` FROM `app_wigsout` ";
 
-         $sql .= "WHERE `print_time` BETWEEN '{$startDate}' AND '{$endDate}'";
 
-         if($shop != 0){
 
-             $sql .= " AND `order_barcode` LIKE '{$shop_type}%'";
 
-         }
 
-         if($status != 0){
 
-             $sql .= " AND `order_status`='{$status}'";
 
-         }
 
-         if($type != 0){
 
-             $sql .= " AND `type`='{$type}'";
 
-         }
 
-         $sql .= ';';
 
-         $query = $this->db->querySql($sql);
 
-         $total = $this->db->queryNum($query);
 
-         
 
-         if($total == 0){
 
-             $num = '0';
 
-         }else{
 
-             $num = ceil($total/$pnsn);
 
-             $wh_max = ceil($num/10);
 
-         }
 
-         
 
-         $direction = substr($wh, 0, 1);
 
-         $wh = substr($wh, 1);
 
-         if($direction == 'h'){
 
-             $whh = ($wh==0)?'0':$wh-1;
 
-             $wht = ($wh==0)?'1':$wh;
 
-         }elseif($direction == 't'){
 
-             $whh = ($wh==$wh_max)?($wh-1):$wh;
 
-             $wht = ($wh==$wh_max)?$wh:($wh+1);
 
-         }else{
 
-             $whh = '0';
 
-             $wht = '1';
 
-         }
 
-                 
 
-         $pagination = '<span class="total_page" data-ttpg="'.$num.'">共 '.$num.' 页</span>';
 
-         if($num > 1){
 
-             $pagination .= ($num>10)?"<span class=\"gtlt head\" data-wh=\"h{$whh}\"><<</span>":'';
 
-             $clazz = '';
 
-             for($i=1+$whh*10; $i<=10+$whh*10; $i++){
 
-                 if($i > $num){
 
-                     break;
 
-                 }else{
 
-                     if($i != 1+$whh*10){
 
-                         $clazz = 'page';
 
-                     }else{
 
-                         $clazz = 'page pn';
 
-                     }
 
-                     $param = $i . '_' . $shop .'_' . $status . '_' . substr($startDate, 0, 10) . '_' . substr($endDate, 0, 10);
 
-                     $pagination .= "<span class=\"{$clazz}\" onclick=\"getOFP('{$param}')\">".$i."</span>";
 
-                 }
 
-             }
 
-             $pagination .= ($num>10)?"<span class=\"gtlt tail\" data-wh=\"t{$wht}\">>></span>":'';
 
-         }
 
-         $pagination .= "<span>展示 <select class=\"pnsn\">";
 
-         $pns = array('15', '50', '100', '250', '500');
 
-         for($i=0; $i<5; $i++){
 
-             if($pnsn == $pns[$i]){
 
-                 $s = 'selected="selected"';
 
-             }else{
 
-                 $s = '';
 
-             }
 
-             $pagination .= "<option value=\"{$pns[$i]}\" {$s}>{$pns[$i]}条</option>";
 
-         }
 
-         $pagination .= "</select> 记录</span>";
 
-         return $pagination;
 
-     }
 
-     
 
-     //DISABLED
 
-     public function apiWigsOut(){
 
-         if($this->common->getIp() !== '39.98.183.27'){
 
-             return json_encode(array(
 
-                 'code' => '0',
 
-                 'msg' => 'Error: auth error'
 
-             ));
 
-         }
 
-         
 
-         $input = file_get_contents('php://input');
 
-         parse_str($input, $post); // 解析http_build_query数据
 
-         if(isset($post['timestamp']) && isset($post['key']) && isset($post['data'])){
 
-             $key = substr(md5($post['timestamp'].'.wigs'), 1, 20);
 
-             if($key !== $post['key']){
 
-                 return json_encode(array(
 
-                     'code' => '-2',
 
-                     'msg' => 'Error: verify error'
 
-                 ));
 
-             }
 
-         }else{
 
-             return json_encode(array(
 
-                 'code' => '-1',
 
-                 'msg' => 'Error: params error'
 
-             ));
 
-         }
 
-         
 
-         $insertValues = '';
 
-         $cancelOld = '';
 
-         foreach($post['data'] as $dk => $dv){
 
-             $insertValues .= '(';
 
-             $values = '';
 
-             foreach($dv as $wk => $wv){
 
-                 $values .= "\"{$wv}\",";
 
-                 if($wk == 'order_barcode'){
 
-                     $cancelOld .= "\"$wv\",";
 
-                 }
 
-             }
 
-             $values .= '2,"n/a"';
 
-             $insertValues .= $values . '),';
 
-         }
 
-         
 
-         $cancelOld = trim($cancelOld, ',');
 
-         $sql_cancel_old = "UPDATE `app_wigsout` SET `order_status`=4 WHERE `order_barcode` IN ({$cancelOld});";
 
-         $insertValues = trim($insertValues, ',');
 
-         $sql = "INSERT INTO `app_wigsout`(`transport`,`order_barcode`,`print_times`,`goods_no`,`goods_info`,`print_time`,`type`,`memo`) VALUES {$insertValues};";
 
-         $this->db->querySql("SET AUTOCOMMIT=0");
 
-         $this->db->begin();
 
-         
 
-         if(!($this->db->querySql($sql_cancel_old))){
 
-             $this->db->querySql("ROLLBACK");
 
-             return json_encode(array(
 
-                 'code' => '-5',
 
-                 'msg' => 'Error: server error'
 
-             ));
 
-         }else{
 
-             if(!($this->db->querySql($sql))){
 
-                 $this->db->querySql("ROLLBACK");
 
-                 return json_encode(array(
 
-                     'code' => '-3',
 
-                     'msg' => 'Error: server error'
 
-                 ));
 
-             }else{
 
-                 $sql_gir = "UPDATE `app_wigsout` SET `gir`=1 WHERE `goods_no` IN (";
 
-                 $sql_gir .= "SELECT * FROM (SELECT `goods_no` FROM `app_wigsout` GROUP BY `goods_no` HAVING COUNT(`goods_no`)>1) AS `tmp`) AND `gir`!=1;";
 
-                 if($this->db->querySql($sql_gir)){
 
-                     $this->db->commit();
 
-                     return json_encode(array(
 
-                         'code' => '1',
 
-                         'msg' => 'Success: request complete'
 
-                     ));
 
-                 }else{
 
-                     $this->db->querySql("ROLLBACK");
 
-                     return json_encode(array(
 
-                         'code' => '-4',
 
-                         'msg' => 'Error: server error'
 
-                     ));
 
-                 }
 
-             }
 
-         }
 
-     }
 
-     
 
-     public function updateMemo(){
 
-         if(isset($_POST['oid']) && !empty($_POST['oid']) && isset($_POST['memo']) && !empty($_POST['memo'])){
 
-             $oid = $this->common->my_filter_input($_POST['oid']);
 
-             $memo = $this->common->my_filter_input($_POST['memo']);
 
-         }else{
 
-             return false;
 
-         }
 
-         
 
-         $sql = "UPDATE `app_wigsout` SET `memo`='{$memo}' WHERE `oid`='{$oid}';";
 
-         if($this->db->querySql($sql)){
 
-             return 1;
 
-         }else{
 
-             return -1;
 
-         }
 
-     }
 
-     
 
-     public function updatePrint(){
 
-         if(isset($_POST['oid']) && !empty($_POST['oid'])){
 
-             $oid = $this->common->my_filter_input($_POST['oid']);
 
-         }else{
 
-             return false;
 
-         }
 
-         
 
-         $time_now = date("Y-m-d H:i:s", time());
 
-         $sql = "UPDATE `app_wigsout` SET `print_times`=`print_times`+1,`print_date`='{$time_now}' WHERE `oid`='{$oid}';";
 
-         if($this->db->querySql($sql)){
 
-             return 1;
 
-         }else{
 
-             return -1;
 
-         }
 
-     }
 
-     
 
-     public function printAll(){
 
-         $sql = 'SELECT `order_barcode`,`goods_info`,`transport`,`print_time` FROM `app_wigsout` WHERE `order_status`=2 AND `print_times`=0 ORDER BY `in_time`;';
 
-         $query = $this->db->querySql($sql);
 
-         $rs = $this->db->queryRsAll($query);
 
-         if(empty($rs)){
 
-             return -1;
 
-         }else{
 
-         	$time_now = date("Y-m-d H:i:s", time());
 
-             $sql_update = "UPDATE `app_wigsout` SET `print_times`=`print_times`+1,`print_date`='{$time_now}' WHERE `order_status`=2 AND `print_times`=0;";
 
-             $query_update = $this->db->querySql($sql_update);
 
-             $str = '';
 
-             foreach($rs as $val){
 
-                 $str .= '<div>'.$val['order_barcode'] . ' *** ' . $val['goods_info'] . ' *** ' . $val['transport'] . ' *** ' . $val['print_time'].'</div>';
 
-             }
 
-             return $str;
 
-         }
 
-     }
 
-     
 
-     public function syncData(){
 
-         $t = time()-1296000;
 
- 		$post = array();
 
-         for($i=1; $i<3; $i++){
 
-             $url = "http://1.wepolicy.cn/api/headgear/{$t}/{$i}";
 
-             $curl = curl_init();
 
-             curl_setopt($curl, CURLOPT_URL, $url);
 
-             curl_setopt($curl, CURLOPT_HEADER, 0);
 
-             curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 
-             $input = curl_exec($curl);
 
-             curl_close($curl);
 
- 			
 
- 			if(preg_match('/^\xEF\xBB\xBF/',$input)){
 
- 				$input = substr($input,3);
 
- 			}
 
-             $post[$i] = json_decode(trim($input), true);
 
-             foreach($post[$i] as $pik=>$piv){
 
-                 $post[$i][$pik]['type'] = $i;
 
-             }
 
-         }
 
-         $data = array_merge($post[1], $post[2]);
 
-         $insertValues = '';
 
- 		
 
-         foreach($data as $dk => $dv){
 
-             $sql_check = "SELECT oid FROM `app_wigsout` WHERE `order_barcode`='{$dv['number']}';";
 
-             $query_check = $this->db->querySql($sql_check);
 
-             $rs_num = $this->db->queryNum($query_check);
 
-             if($rs_num == 0){
 
-                 $values = '';
 
-                 foreach($dv as $wk => $wv){
 
- 					$wv = preg_replace('/"/', "''", $wv);
 
-                     $values .= "\"{$wv}\",";
 
-                 }
 
-                 $insertValues .= '(' . $values . '"n/a"),';
 
-             }else{
 
-                 continue;
 
-             }
 
-         }
 
-         
 
-         $insertValues = trim($insertValues, ',');
 
-         $sql = "INSERT INTO `app_wigsout`(`transport`,`order_barcode`,`goods_no`,`goods_info`,`print_time`,`type`,`memo`) VALUES {$insertValues};";
 
-         $this->db->querySql("SET AUTOCOMMIT=0");
 
-         $this->db->begin();
 
-         
 
-         if(!empty($insertValues)){
 
-             if(!($this->db->querySql($sql))){
 
-                 $this->db->querySql("ROLLBACK");
 
-                 return json_encode(array(
 
-                     'code' => '-3',
 
-                     'msg' => 'Error: server error'
 
-                 ));
 
-             }else{
 
-                 $sql_gir = "UPDATE `app_wigsout` SET `gir`=1 WHERE `goods_no` IN (";
 
-                 $sql_gir .= "SELECT * FROM (SELECT `goods_no` FROM `app_wigsout` GROUP BY `goods_no` HAVING COUNT(`goods_no`)>1) AS `tmp`) AND `gir`!=1;";
 
-                 if($this->db->querySql($sql_gir)){
 
-                     $this->db->commit();
 
-                     return json_encode(array(
 
-                         'code' => '1',
 
-                         'msg' => 'Success: request complete'
 
-                     ));
 
-                 }else{
 
-                     $this->db->querySql("ROLLBACK");
 
-                     return json_encode(array(
 
-                         'code' => '-4',
 
-                         'msg' => 'Error: server error'
 
-                     ));
 
-                 }
 
-             }
 
-         }else{
 
-             return json_encode(array(
 
-                 'code' => '0',
 
-                 'msg' => 'Error: data null'
 
-             ));
 
-         }
 
-         
 
- //         if(!empty($cancelOld) && !($this->db->querySql($sql_cancel_old))){
 
- //             $this->db->querySql("ROLLBACK");
 
- //             return json_encode(array(
 
- //                 'code' => '-5',
 
- //                 'msg' => 'Error: server error'
 
- //             ));
 
- //         }else{
 
-             
 
-             
 
- //         }
 
-     }
 
-     
 
-     public function __destruct(){
 
-         //TODO
 
-     }
 
- }
 
 
  |