|
|
@@ -188,6 +188,10 @@ class Whlabel extends Start_Controller
|
|
|
$this->_gbhtype(); //更改备货状态
|
|
|
} else if($arg == 'excelrjs'){
|
|
|
$this->_excelrjs();
|
|
|
+ } else if($arg == 'excelctjs'){
|
|
|
+ $this->_excelctjs();
|
|
|
+ }else if($arg == 'excelcrjs'){
|
|
|
+ $this->_excelcrjs();
|
|
|
}else if($arg == "w_t_cs"){
|
|
|
$this->_w_t_cs(); //首页
|
|
|
}else {
|
|
|
@@ -7735,4 +7739,765 @@ class Whlabel extends Start_Controller
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //出库、退库导出
|
|
|
+ public function _excelctjs()
|
|
|
+ {
|
|
|
+ $classid = $this->classid->sku();
|
|
|
+ $pm = $classid;
|
|
|
+ $typeclass = array();
|
|
|
+ $tc = $this->typeclass->find_all();
|
|
|
+ foreach ($tc as $v) {
|
|
|
+ $typeclass[$v['id']] = $v;
|
|
|
+ }
|
|
|
+ $prc = array();
|
|
|
+ $purchase = $this->purchase->find_all();
|
|
|
+ foreach ($purchase as $k => $v) {
|
|
|
+ $prc[$v['id']] = $v['title'];
|
|
|
+ }
|
|
|
+ if (isset($_GET['excel'])) {
|
|
|
+ $wh = array();
|
|
|
+ $w = $this->warehouse->find_all('1=1', 'id,title');
|
|
|
+ foreach ($w as $v) {
|
|
|
+ $wh[$v['id']] = $v['title'];
|
|
|
+ }
|
|
|
+ $type = $this->input->get('excel', true);
|
|
|
+ $category = $this->input->get('category', true);
|
|
|
+ $size = $this->input->get('size', true);
|
|
|
+ $grade = $this->input->get('grade', true);
|
|
|
+ $color = $this->input->get('color', true);
|
|
|
+ $lowe = $this->input->get('lowe', true);
|
|
|
+ $sku = $this->input->get('sku', true);
|
|
|
+ $title = $this->input->get('title', true);
|
|
|
+ $warehouse = $this->input->get('warehouse', true);
|
|
|
+ $purchase = $this->input->get('purchase', true);
|
|
|
+ $lacetype = $this->input->get('lacetype', true);
|
|
|
+ $haircap = $this->input->get('haircap', true);
|
|
|
+ $lacecolor = $this->input->get('lacecolor', true);
|
|
|
+ $density = $this->input->get('density', true);
|
|
|
+
|
|
|
+ $details = $this->input->get('details', true);
|
|
|
+
|
|
|
+ $state = $this->input->get('state', true);
|
|
|
+
|
|
|
+ $shop = $this->input->get('shop', true);
|
|
|
+
|
|
|
+ $hairnumber = $this->input->get('hairnumber', true);
|
|
|
+
|
|
|
+ $type_leixi = $this->input->get('type', true);
|
|
|
+
|
|
|
+ $cpbz = $this->input->get('cpbz', true);
|
|
|
+ $sm = $this->input->get('sm', true);
|
|
|
+
|
|
|
+ $sid = $this->input->get('sid', true);
|
|
|
+ $ktime = $this->input->get('ktime', true);
|
|
|
+ $jtime = $this->input->get('jtime', true);
|
|
|
+ $ktime = strtotime($ktime);
|
|
|
+ $jtime = strtotime($jtime);
|
|
|
+ //$where = " 1=1 ";
|
|
|
+ //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
|
|
|
+ $where = " sku != '' ";
|
|
|
+ $gj = "";
|
|
|
+ $ck = "";
|
|
|
+ if ($category) {
|
|
|
+ $where .= " and features like '%-$category-%'";
|
|
|
+ }
|
|
|
+ if ($size) {
|
|
|
+ $where .= " and features like '%-$size-%'";
|
|
|
+ }
|
|
|
+ if ($grade) {
|
|
|
+ $where .= " and features like '%-$grade-%'";
|
|
|
+ }
|
|
|
+ if ($color) {
|
|
|
+ $where .= " and features like '%-$color-%'";
|
|
|
+ }
|
|
|
+ if ($lowe) {
|
|
|
+ $where .= " and features like '%-$lowe-%'";
|
|
|
+ }
|
|
|
+ if ($warehouse) {
|
|
|
+ $where .= " and warehouse = '$warehouse'";
|
|
|
+ }
|
|
|
+ if ($purchase) {
|
|
|
+ $where .= " and purchase = '$purchase'";
|
|
|
+ }
|
|
|
+ if ($state) {
|
|
|
+ $where .= " and state = '$state'";
|
|
|
+ }
|
|
|
+ if ($lacetype) {
|
|
|
+ $where .= " and features like '%-$lacetype-%'";
|
|
|
+ }
|
|
|
+ if ($lacecolor) {
|
|
|
+ $where .= " and features like '%-$lacecolor-%'";
|
|
|
+ }
|
|
|
+ if ($density) {
|
|
|
+ $where .= " and features like '%-$density-%'";
|
|
|
+ }
|
|
|
+ if ($haircap) {
|
|
|
+ $where .= " and features like '%-$haircap-%'";
|
|
|
+ }
|
|
|
+ if ($details) {
|
|
|
+ $where .= " and details = '$details'";
|
|
|
+ }
|
|
|
+ if ($shop) {
|
|
|
+ $where .= " and shop like '%$shop%'";
|
|
|
+ }
|
|
|
+ if ($title) {
|
|
|
+ $title = trim($title, ' ');
|
|
|
+ $title = trim($title, ' ');
|
|
|
+ $where .= " and title like '%$title%'";
|
|
|
+ }
|
|
|
+ if (!empty($hairnumber)) {
|
|
|
+ $where .= " and features like '%-128-%' ";
|
|
|
+ if ($hairnumber < 0) {
|
|
|
+ $class_list = $this->typeclass->find_all('classid = 43');
|
|
|
+ foreach ($class_list as $v) {
|
|
|
+ $where .= " and features not like '%-" . $v['id'] . "-%'";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $where .= " and features like '%-$hairnumber-%'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($type_leixi) {
|
|
|
+ $where .= " and type = '$type_leixi'";
|
|
|
+ }
|
|
|
+ if ($cpbz) {
|
|
|
+ $where .= " and cpbz like '%$cpbz%' ";
|
|
|
+ }
|
|
|
+ if ($sm) {
|
|
|
+ $where .= " and sm like '%$sm%' ";
|
|
|
+ }
|
|
|
+ if ($sku) {
|
|
|
+ $sku = trim($sku, ' ');
|
|
|
+ $sku = trim($sku, ' ');
|
|
|
+ $where .= " and sku like '%$sku%'";
|
|
|
+ }
|
|
|
+ if ($ktime && $jtime) {
|
|
|
+ if ($type == 1) {
|
|
|
+ $tl = '出库';
|
|
|
+ $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
|
|
|
+ } else if ($type == 2) {
|
|
|
+ $tl = '退库';
|
|
|
+ $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
|
|
|
+ } else if ($type == 3) {
|
|
|
+ $gj = " and enter > '$ktime' and enter < '$jtime'";
|
|
|
+ $ck = " and outk > '$ktime' and outk < '$jtime'";
|
|
|
+ } else if ($type == 4) {
|
|
|
+ $tl = '出库+零售';
|
|
|
+ $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
|
|
|
+ } else if ($type == 5) {
|
|
|
+ $tl = '零售';
|
|
|
+ $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $sidwhere = '';
|
|
|
+ if ($sid) {
|
|
|
+ $sd = "";
|
|
|
+ $s = explode(',', trim($sid, ','));
|
|
|
+ foreach ($s as $value) {
|
|
|
+ $sd .= " id = " . $value . " or";
|
|
|
+ }
|
|
|
+ $sidwhere = " and (" . rtrim($sd, 'or') . ")";
|
|
|
+ }
|
|
|
+ //数据排序
|
|
|
+ $order_str = "time desc";
|
|
|
+ if (empty($page)) {
|
|
|
+ $start = 0;
|
|
|
+ $perpage = 1;
|
|
|
+ } else {
|
|
|
+ $start = ($page - 1) * $perpage;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //取得信息列表
|
|
|
+ if ($type != 3 && $type != 5) {
|
|
|
+ if ($type == 1 || $type == 4) {
|
|
|
+ $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
|
|
|
+ foreach ($info_list as $key => $value) {
|
|
|
+ $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
|
|
|
+ $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
|
|
|
+ $warehouse = $this->warehouse->read($value['warehouse']);
|
|
|
+ $info_list[$key]['warehouse'] = $warehouse['title'];
|
|
|
+ $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
|
|
|
+ $features = explode('-', trim($features, '-'));
|
|
|
+ $pm = $classid;
|
|
|
+ foreach ($features as $k => $v) {
|
|
|
+ if ($v != 0) {
|
|
|
+ if (!isset($typeclass[$v])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isset($pm[$typeclass[$v]['classid']])) {
|
|
|
+ if (stripos($typeclass[$v]['zh'], '|') !== false) {
|
|
|
+ $tz = explode('|', $typeclass[$v]['zh']);
|
|
|
+ $pm[$typeclass[$v]['classid']] = $tz[0];
|
|
|
+ } else {
|
|
|
+ $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $zh = implode(" ", $pm);
|
|
|
+ $zh = str_replace('自然色 ', '', trim($zh, ' '));
|
|
|
+ $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
|
|
|
+ $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
|
|
|
+ $info_list[$key]['features'] = $zh;
|
|
|
+ }
|
|
|
+
|
|
|
+ $final_list = [];
|
|
|
+ foreach($info_list as $k=>$v){
|
|
|
+ $number = "";
|
|
|
+ if(!empty($v['orderinfo'])){
|
|
|
+ $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
|
|
|
+ if(!empty($tmp_info['number'])){
|
|
|
+ $number = $tmp_info['number'];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ $final_list[] = [
|
|
|
+ 'warehouse'=>$v['warehouse'],
|
|
|
+ 'purchase'=>$v['purchase'],
|
|
|
+ 'sku'=>$v['sku'],
|
|
|
+ 'title'=>$v['title'],
|
|
|
+ 'features'=>$v['features'],
|
|
|
+ 'label'=>$v['label'],
|
|
|
+ 'orderinfo'=>$v['orderinfo'],
|
|
|
+ 'number'=>$number,
|
|
|
+ 'waybill'=>$v['waybill'],
|
|
|
+ 'outk'=>$v['outk'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
|
|
|
+ foreach ($info_list as $key => $value) {
|
|
|
+ $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
|
|
|
+ $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
|
|
|
+ $warehouse = $this->warehouse->read($value['warehouse']);
|
|
|
+ $info_list[$key]['warehouse'] = $warehouse['title'];
|
|
|
+ $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
|
|
|
+ $features = explode('-', trim($features, '-'));
|
|
|
+ $pm = $classid;
|
|
|
+ foreach ($features as $k => $v) {
|
|
|
+ if ($v != 0) {
|
|
|
+ if (!isset($typeclass[$v])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isset($pm[$typeclass[$v]['classid']])) {
|
|
|
+ if (stripos($typeclass[$v]['zh'], '|') !== false) {
|
|
|
+ $tz = explode('|', $typeclass[$v]['zh']);
|
|
|
+ $pm[$typeclass[$v]['classid']] = $tz[0];
|
|
|
+ } else {
|
|
|
+ $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $zh = implode(" ", $pm);
|
|
|
+ $zh = str_replace('自然色 ', '', trim($zh, ' '));
|
|
|
+ $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
|
|
|
+ $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
|
|
|
+ $info_list[$key]['features'] = $zh;
|
|
|
+ }
|
|
|
+
|
|
|
+ $final_list = [];
|
|
|
+ foreach($info_list as $k=>$v){
|
|
|
+
|
|
|
+ $number = "";
|
|
|
+ if(!empty($v['orderinfo'])){
|
|
|
+ $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
|
|
|
+ if(!empty($tmp_info['number'])){
|
|
|
+ $number = $tmp_info['number'];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ $final_list[] = [
|
|
|
+ 'warehouse'=>$v['warehouse'],
|
|
|
+ 'purchase'=>$v['purchase'],
|
|
|
+ 'sku'=>$v['sku'],
|
|
|
+ 'title'=>$v['title'],
|
|
|
+ 'features'=>$v['features'],
|
|
|
+ 'label'=>$v['label'],
|
|
|
+ 'orderinfo'=>$v['orderinfo'],
|
|
|
+ 'number'=>$number,
|
|
|
+ 'waybill'=>$v['waybill'],
|
|
|
+ 'retreat'=>$v['retreat'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(empty($final_list)){
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
|
|
|
+ }else{
|
|
|
+ // $final_list = [];
|
|
|
+ // foreach($list as $v){
|
|
|
+ // $final_list[] = array_values($v);
|
|
|
+ // }
|
|
|
+ $end_list = [];
|
|
|
+ foreach($final_list as $v){
|
|
|
+ $end_list[] = array_values($v);
|
|
|
+ }
|
|
|
+ $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
|
|
|
+
|
|
|
+ array_unshift($end_list,[
|
|
|
+ "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
|
|
|
+ ]);
|
|
|
+ array_unshift($end_list,[
|
|
|
+ $title,"","","",""
|
|
|
+ ]);
|
|
|
+ exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $end_list,'title'=>$title)));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
|
|
|
+ // $titlename = "<table border=1>
|
|
|
+ // <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
|
|
|
+ // <tr align='center'>
|
|
|
+ // <td>仓库</td>
|
|
|
+ // <td>供应商</td>
|
|
|
+ // <td>SKU</td>
|
|
|
+ // <td>商品名称</td>
|
|
|
+ // <td>商品中文</td>
|
|
|
+ // <td>标签</td>
|
|
|
+ // <td>订单号</td>
|
|
|
+ // <td>订单编码</td>
|
|
|
+ // <td>运单号</td>
|
|
|
+ // <td>" . $tl . "时间(中国时间)</td>
|
|
|
+ // </tr>
|
|
|
+ // </table>";
|
|
|
+ // $filename = $title . ".xls";
|
|
|
+ // $tail = "";
|
|
|
+ // $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
|
|
|
+ } else if ($type == 5) {
|
|
|
+ $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
|
|
|
+
|
|
|
+ foreach ($info_list as $key => $value) {
|
|
|
+ $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
|
|
|
+ $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
|
|
|
+ $warehouse = $this->warehouse->read($value['warehouse']);
|
|
|
+ $info_list[$key]['warehouse'] = $warehouse['title'];
|
|
|
+ $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
|
|
|
+ $features = explode('-', trim($features, '-'));
|
|
|
+ $pm = $classid;
|
|
|
+ foreach ($features as $k => $v) {
|
|
|
+ if ($v != 0) {
|
|
|
+ if (!isset($typeclass[$v])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isset($pm[$typeclass[$v]['classid']])) {
|
|
|
+ if (stripos($typeclass[$v]['zh'], '|') !== false) {
|
|
|
+ $tz = explode('|', $typeclass[$v]['zh']);
|
|
|
+ $pm[$typeclass[$v]['classid']] = $tz[0];
|
|
|
+ } else {
|
|
|
+ $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $zh = implode(" ", $pm);
|
|
|
+ $zh = str_replace('自然色 ', '', trim($zh, ' '));
|
|
|
+ $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
|
|
|
+ $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
|
|
|
+ $info_list[$key]['features'] = $zh;
|
|
|
+ }
|
|
|
+ if(empty($info_list)){
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
|
|
|
+ }else{
|
|
|
+ $final_list = [];
|
|
|
+ foreach($info_list as $v){
|
|
|
+ $final_list[] = array_values($v);
|
|
|
+ }
|
|
|
+ $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
|
|
|
+
|
|
|
+ array_unshift($final_list,[
|
|
|
+ "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
|
|
|
+ ]);
|
|
|
+ array_unshift($final_list,[
|
|
|
+ $title,"","","",""
|
|
|
+ ]);
|
|
|
+ exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
|
|
|
+ // $titlename = "<table border=1>
|
|
|
+ // <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
|
|
|
+ // <tr align='center'>
|
|
|
+ // <td>仓库</td>
|
|
|
+ // <td>供应商</td>
|
|
|
+ // <td>SKU</td>
|
|
|
+ // <td>商品名称</td>
|
|
|
+ // <td>商品中文</td>
|
|
|
+ // <td>标签</td>
|
|
|
+ // <td>" . $tl . "时间(中国时间)</td>
|
|
|
+ // </tr>
|
|
|
+ // </table>";
|
|
|
+ // $filename = $title . ".xls";
|
|
|
+ // $tail = "";
|
|
|
+ // $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
|
|
|
+ } else {
|
|
|
+ /**
|
|
|
+ $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
|
|
|
+ $rows = array();$list = array();
|
|
|
+ foreach ($info_list as $key=>$value)
|
|
|
+ {
|
|
|
+ $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
|
|
|
+ }
|
|
|
+ **/
|
|
|
+ $wh = array();
|
|
|
+ $w = $this->warehouse->find_all('1=1', 'id,title');
|
|
|
+ foreach ($w as $v) {
|
|
|
+ $wh[$v['id']] = $v['title'];
|
|
|
+ }
|
|
|
+ $wt = array();
|
|
|
+ $whlabel_type = $this->whlabel_type->find_all();
|
|
|
+ foreach ($whlabel_type as $v) {
|
|
|
+ $wt[$v['id']] = $v['title'];
|
|
|
+ }
|
|
|
+ $classid = $this->classid->sku();
|
|
|
+ $list = array();
|
|
|
+ $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
|
|
|
+ foreach ($rows as $key => $value) {
|
|
|
+ $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
|
|
|
+ $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
|
|
|
+ $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
|
|
|
+ $details = array();
|
|
|
+ $cpid = array();
|
|
|
+ $cpbz = array();
|
|
|
+ $c = 0;
|
|
|
+ $g = 0;
|
|
|
+ $x = 0;
|
|
|
+ $t = 0;
|
|
|
+ $s = 0;
|
|
|
+ $q = 0;
|
|
|
+ foreach ($sd as $k => $v) {
|
|
|
+ if ($v['state'] == 0) {
|
|
|
+ $c++;
|
|
|
+ }
|
|
|
+ if ($v['state'] != 9) {
|
|
|
+ $g++;
|
|
|
+ }
|
|
|
+ if ($v['outk'] > 1) {
|
|
|
+ $x++;
|
|
|
+ }
|
|
|
+ if ($v['retreat'] > 0) {
|
|
|
+ $t++;
|
|
|
+ }
|
|
|
+ if ($v['state'] == 8) {
|
|
|
+ $s++;
|
|
|
+ }
|
|
|
+ if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
|
|
|
+ $q++;
|
|
|
+ }
|
|
|
+ $details[$v['details']] = $v['details'];
|
|
|
+ if ($v['cpid'] != 0) {
|
|
|
+ $cpid[$v['cpid']] = $v['cpid'];
|
|
|
+ }
|
|
|
+ if ($v['cpbz'] != '') {
|
|
|
+ $cpbz[$v['cpbz']] = $v['cpbz'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($wt[$value['type']])) {
|
|
|
+ $rows[$key]['type'] = $wt[$value['type']];
|
|
|
+ } else {
|
|
|
+ $rows[$key]['type'] = '未设置';
|
|
|
+ }
|
|
|
+ $rows[$key]['details'] = implode("、", $details);
|
|
|
+ $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
|
|
|
+ $ftime = time() - 15 * 24 * 3600;
|
|
|
+ $rows[$key]['warehouse'] = $wh[$value['warehouse']];
|
|
|
+ $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
|
|
|
+ $rows[$key]['g'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state != 9' . $gj);
|
|
|
+ $rows[$key]['c'] = $c;
|
|
|
+ $rows[$key]['x'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state = 1' . $ck);
|
|
|
+ $rows[$key]['t'] = $t;
|
|
|
+
|
|
|
+
|
|
|
+ $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
|
|
|
+ $rows[$key]['z'] = $z;
|
|
|
+ // $jm = $classid;
|
|
|
+
|
|
|
+ $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
|
|
|
+ $features = explode('-', trim($features, '-'));
|
|
|
+ // $pm = $classid;
|
|
|
+ // foreach ($features as $k => $v) {
|
|
|
+ // if ($v != 0) {
|
|
|
+ // if (!isset($typeclass[$v])) {
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ // if (isset($pm[$typeclass[$v]['classid']])) {
|
|
|
+ // if (stripos($typeclass[$v]['zh'], '|') !== false) {
|
|
|
+ // $tz = explode('|', $typeclass[$v]['zh']);
|
|
|
+ // $pm[$typeclass[$v]['classid']] = $tz[0];
|
|
|
+ // } else {
|
|
|
+ // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
|
|
|
+ // }
|
|
|
+ // if (isset($jm[$typeclass[$v]['classid']])) {
|
|
|
+ // if ($typeclass[$v]['jm']) {
|
|
|
+ // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // $zh = implode(" ", $pm);
|
|
|
+ // $zh = str_replace('自然色 ', '', trim($zh, ' '));
|
|
|
+ // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
|
|
|
+ // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
|
|
|
+ // $rows[$key]['features'] = $zh;
|
|
|
+ // $jm = array_filter($jm); //去除空值
|
|
|
+ // $jm = implode("-", $jm);
|
|
|
+ // $rows[$key]['jm'] = $jm;
|
|
|
+ $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
|
|
|
+ // echo "<pre>";
|
|
|
+ // print_r($tmp_list);
|
|
|
+ // die;
|
|
|
+ $final_list =[];
|
|
|
+ foreach($tmp_list as $k=>$v){
|
|
|
+ $final_list[] = [
|
|
|
+ "warehouse"=>$v['warehouse'],
|
|
|
+ "purchase"=>$v['purchase'],
|
|
|
+ "details"=>$v['details'],
|
|
|
+ "cpid"=>$v['cpid'],
|
|
|
+ "sku"=>$v['sku'],
|
|
|
+ "title"=>$v['title'],
|
|
|
+ "features"=>$v['pm'],
|
|
|
+ "cpbz"=>$v['cpbz'],
|
|
|
+ "sm"=>$v['sm'],
|
|
|
+ "type"=>$v['type'],
|
|
|
+ "g"=>$v["g"],
|
|
|
+ "c"=>$v["c"],
|
|
|
+ "x"=>$v["x"],
|
|
|
+ "t"=>$v["t"],
|
|
|
+ "z"=>$v["z"],
|
|
|
+ "jm"=>$v["jm"],
|
|
|
+ "weight"=>$v["weight"],
|
|
|
+ "asd"=>$v["asd"],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
|
|
|
+
|
|
|
+ if(empty($final_list)){
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
|
|
|
+ }else{
|
|
|
+ $end_list = [];
|
|
|
+ foreach($final_list as $v){
|
|
|
+ $end_list[] = array_values($v);
|
|
|
+ }
|
|
|
+ $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
|
|
|
+
|
|
|
+ array_unshift($end_list,[
|
|
|
+ "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
|
|
|
+ ]);
|
|
|
+ array_unshift($end_list,[
|
|
|
+ $title,"","","",""
|
|
|
+ ]);
|
|
|
+ exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $end_list,'title'=>$title)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // $titlename = "<table border=1>
|
|
|
+ // <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
|
|
|
+ // <tr align='center'>
|
|
|
+ // <td>仓库</td>
|
|
|
+ // <td>供应商</td>
|
|
|
+ // <td>位置</td>
|
|
|
+ // <td>库存编码</td>
|
|
|
+ // <td>SKU</td>
|
|
|
+ // <td>商品名称</td>
|
|
|
+ // <td>商品中文</td>
|
|
|
+ // <td>产品备注</td>
|
|
|
+ // <td>说明</td>
|
|
|
+ // <td>类型</td>
|
|
|
+ // <td>入库总量</td>
|
|
|
+ // <td>库存数量</td>
|
|
|
+ // <td>销售数量</td>
|
|
|
+ // <td>退货数量</td>
|
|
|
+ // <td>占单数量</td>
|
|
|
+ // <td>料号</td>
|
|
|
+ // <td>重量</td>
|
|
|
+ // <td>类目</td>
|
|
|
+ // </tr>
|
|
|
+ // </table>";
|
|
|
+ // $filename = $title . ".xls";
|
|
|
+ // $tail = "";
|
|
|
+ // $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //出库+入库数据整合
|
|
|
+ public function _excelcrjs()
|
|
|
+ {
|
|
|
+ if (isset($_GET['excel'])) {
|
|
|
+ $type = $this->input->get('excel', true);
|
|
|
+ $category = $this->input->get('category', true);
|
|
|
+ $size = $this->input->get('size', true);
|
|
|
+ $grade = $this->input->get('grade', true);
|
|
|
+ $color = $this->input->get('color', true);
|
|
|
+ $lowe = $this->input->get('lowe', true);
|
|
|
+ $sku = $this->input->get('sku', true);
|
|
|
+ $warehouse = $this->input->get('warehouse', true);
|
|
|
+ $purchase = $this->input->get('purchase', true);
|
|
|
+ $state = $this->input->get('state', true);
|
|
|
+ $sid = $this->input->get('sid', true);
|
|
|
+ $ktime = $this->input->get('ktime', true);
|
|
|
+ $jtime = $this->input->get('jtime', true);
|
|
|
+ $ktime = strtotime($ktime);
|
|
|
+ $jtime = strtotime($jtime);
|
|
|
+ $where = "1=1";
|
|
|
+ $gj = "";
|
|
|
+ $ck = "";
|
|
|
+ if ($category) {
|
|
|
+ $where .= " and features like '%-$category-%'";
|
|
|
+ }
|
|
|
+ if ($size) {
|
|
|
+ $where .= " and features like '%-$size-%'";
|
|
|
+ }
|
|
|
+ if ($grade) {
|
|
|
+ $where .= " and features like '%-$grade-%'";
|
|
|
+ }
|
|
|
+ if ($color) {
|
|
|
+ $where .= " and features like '%-$color-%'";
|
|
|
+ }
|
|
|
+ if ($lowe) {
|
|
|
+ $where .= " and features like '%-$lowe-%'";
|
|
|
+ }
|
|
|
+ if ($warehouse) {
|
|
|
+ $where .= " and warehouse = '$warehouse'";
|
|
|
+ }
|
|
|
+ if ($purchase) {
|
|
|
+ $where .= " and purchase = '$purchase'";
|
|
|
+ }
|
|
|
+ if ($state) {
|
|
|
+ $where .= " and state = '$state'";
|
|
|
+ }
|
|
|
+ if ($sku) {
|
|
|
+ $where .= " and sku like '%$sku%'";
|
|
|
+ }
|
|
|
+ if ($ktime && $jtime) {
|
|
|
+ $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
|
|
|
+ }
|
|
|
+ $sidwhere = '';
|
|
|
+ if ($sid) {
|
|
|
+ $sd = "";
|
|
|
+ $s = explode(',', trim($sid, ','));
|
|
|
+ foreach ($s as $value) {
|
|
|
+ $sd .= " id = " . $value . " or";
|
|
|
+ }
|
|
|
+ $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ //取得信息列表
|
|
|
+ $timeread = $ktime;
|
|
|
+ $timenum = ceil(($jtime - $ktime) / (24 * 3600));
|
|
|
+ $timelist = array();
|
|
|
+ for ($i = 0; $i < $timenum; $i++) {
|
|
|
+ $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
|
|
|
+ $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
|
|
|
+ //echo "<pre>";
|
|
|
+ //print_r($info_list);
|
|
|
+ //exit();
|
|
|
+ $rows = array();
|
|
|
+ $list = array();
|
|
|
+ foreach ($info_list as $key => $value) {
|
|
|
+ $thistime = $timelist;
|
|
|
+ if (isset($rows[strtolower($value['sku'])])) {
|
|
|
+ if ($value['outk'] > $ktime && $value['state'] < $jtime) {
|
|
|
+ $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
|
|
|
+ }
|
|
|
+ if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
|
|
|
+ $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
|
|
|
+ $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
|
|
|
+ }
|
|
|
+ if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
|
|
|
+ $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
|
|
|
+ }
|
|
|
+ $rows[strtolower($value['sku'])] = $thistime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($rows)){
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
|
|
|
+ }else{
|
|
|
+ $final_list = [];
|
|
|
+ foreach($rows as $v){
|
|
|
+ $final_list[] = array_values($v);
|
|
|
+ }
|
|
|
+ $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
|
|
|
+ $first_line = [];
|
|
|
+ $first_line[] = "SKU";
|
|
|
+ foreach ($timelist as $k => $v) {
|
|
|
+ $first_line[] = $k . "出库";
|
|
|
+ $first_line[] = $k . "入库";
|
|
|
+ }
|
|
|
+
|
|
|
+ array_unshift($final_list,$first_line);
|
|
|
+
|
|
|
+ exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
|
|
|
+ // <head>
|
|
|
+ // <!--[if gte mso 9]><xml>
|
|
|
+ // <x:ExcelWorkbook>
|
|
|
+ // <x:ExcelWorksheets>
|
|
|
+ // <x:ExcelWorksheet>
|
|
|
+ // <x:Name>EXCEL</x:Name>
|
|
|
+ // <x:WorksheetOptions>
|
|
|
+ // <x:Print>
|
|
|
+ // <x:ValidPrinterInfo />
|
|
|
+ // </x:Print>
|
|
|
+ // </x:WorksheetOptions>
|
|
|
+ // </x:ExcelWorksheet>
|
|
|
+ // </x:ExcelWorksheets>
|
|
|
+ // </x:ExcelWorkbook>
|
|
|
+ // </xml>
|
|
|
+ // <![endif]-->
|
|
|
+ // </head><body>";
|
|
|
+
|
|
|
+ // $str .= "<table border=1><tr><td>SKU</td>";
|
|
|
+ // foreach ($timelist as $k => $v) {
|
|
|
+ // $str .= "<td>" . $k . "出库</td>";
|
|
|
+ // $str .= "<td>" . $k . "入库</td>";
|
|
|
+ // }
|
|
|
+ // $str .= "</tr></table>";
|
|
|
+ // $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
|
|
|
+ // foreach ($rows as $key => $val) {
|
|
|
+ // $str .= "<tr><td>" . strtoupper($key) . "</td>";
|
|
|
+ // foreach ($val as $k => $v) {
|
|
|
+ // $str .= "<td>" . $val[$k]['c'] . "</td>";
|
|
|
+ // if ($val[$k]['r'] > 0) {
|
|
|
+ // $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
|
|
|
+ // } else {
|
|
|
+ // $str .= "<td>" . $val[$k]['r'] . "</td>";
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // $str .= "</tr>";
|
|
|
+ // }
|
|
|
+ // $str .= "</table>";
|
|
|
+ // $str .= "</body></html>";
|
|
|
+ // header("Content-Type: application/vnd.ms-excel; name='excel'");
|
|
|
+ // header("Content-type: application/octet-stream");
|
|
|
+ // header("Content-Disposition: attachment; filename=" . time() . '.xls');
|
|
|
+ // header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
|
|
+ // header("Pragma: no-cache");
|
|
|
+ // header("Expires: 0");
|
|
|
+ // exit($str);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|