load->library('session'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_country','country'); $this->load->_model('Model_express','express'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_systemwigsout','systemwigsout'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_transfer','transfer'); $this->load->_model('Model_systemtransfer','systemtransfer'); $this->load->_model('Model_whlabeltransport', 'whlabeltransport'); $this->load->_model('Model_systemtransfer_cr', 'systemtransfer_cr'); $this->load->_model("Model_logic_order",'logic_order'); $this->load->_model("Model_logic_ding","logic_ding"); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'add')//添加 { $this->_add(); } else if($arg == 'edit') { $this->_edit($arg_array); } else if($arg == 'del') { $this->_del(); } else if($arg == 'rows') { $this->_rows(); } else if($arg == 'list') { $this->_list(); } else if($arg == 'kcpd') { $this->_kcpd(); } else if($arg == 'orderlist') { $this->_orderlist(); } else if($arg == 'orderlistck')//华荣厂查看 { $this->_orderlistck(); } else if($arg == 'orderlistexcel') { $this->_orderlistexcel(); } else if($arg == 'ordersee') { $this->_ordersee($arg_array); } else { $this->_index(); } } //管理 public function _index() { $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $title = $this->input->post('title',true); $where = "1=1 "; if($title) { $where .= " and title = '$title'"; } //数据排序 $order_str = "id asc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->warehouse->find_all($where,'id,title,show,zd,zdms,fpzd,wz,fpsx,express,bdcountry,yybm',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { if($value['show'] == 1) { $info_list[$key]['show'] = "是"; } else { $info_list[$key]['show'] = "否"; } if($value['zd'] == 1) { $info_list[$key]['zd'] = "启用"; } else { $info_list[$key]['zd'] = "无"; } if($value['zdms'] == 1) { $info_list[$key]['zdms'] = "单独占单"; } else if(($value['zdms'] == 2)) { $info_list[$key]['zdms'] = "全占"; } else if(($value['zdms'] == 3)) { $info_list[$key]['zdms'] = "混占"; } else { $info_list[$key]['zdms'] = "无"; } if($value['express'] == 0) { $info_list[$key]['express'] = "无"; } else { $express = $this->express->read($value['express']); $info_list[$key]['express'] = $express['servicename']; } if($value['fpzd'] == 1) { $info_list[$key]['fpzd'] = "自动"; } else { $info_list[$key]['fpzd'] = "否"; } if($value['wz'] == 1) { $info_list[$key]['wz'] = "开启"; } else { $info_list[$key]['wz'] = "关闭"; } if($value['bdcountry'] != 0) { $country = $this->country->read($value['bdcountry']); $info_list[$key]['bdcountry'] = $country['name']; } else { $info_list[$key]['bdcountry'] = ""; } } $total = $this->warehouse->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list)); echo json_encode($rows);exit; } $this->_Template('warehouse',$this->data); } //添加 public function _add() { $post = $this->input->post(NULL, TRUE); if(isset($post['title'])) { $post['title'] = $this->input->post('title',true); $post['company'] = $this->input->post('company',true); $post['user'] = $this->input->post('user',true); $post['show'] = $this->input->post('show',true); //$post['function'] = $this->input->post('function',true); //$post['functiontext'] = $this->input->post('functiontext',true); $post['country'] = $this->input->post('country',true); $post['name'] = $this->input->post('name',true); $post['phone'] = $this->input->post('phone',true); $post['province'] = $this->input->post('province',true); $post['city'] = $this->input->post('city',true); $post['zipcode'] = $this->input->post('zipcode',true); $post['address'] = $this->input->post('address',true); $post['address2'] = $this->input->post('address2',true); $post['hz'] = $this->input->post('hz',true); $post['zd'] = $this->input->post('zd',true); $post['bdck'] = $this->input->post('bdck',true); if($post['zd'] == 1 && $post['bdck'] == '') { echo json_encode(array('msg'=>'开启占单模式必须填写绑定库','success'=>false));exit; } if($post['zd'] == 1 && $post['hz'] == '') { echo json_encode(array('msg'=>'开启占单模式必须填写占单后缀','success'=>false));exit; } if($post['zd'] == 1 && !ctype_alpha($post['hz'])) { echo json_encode(array('msg'=>'占单后缀只允许是字母','success'=>false));exit; } if($this->warehouse->insert($post)) { echo json_encode(array('msg'=>'添加成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit; } } $country = $this->country->find_all(); $this->data['country'] = $country; $this->_Template('warehouse_add',$this->data); } //修改 public function _edit($arg_array) { $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $data = $this->warehouse->read($id); $post['title'] = $this->input->post('title',true); $post['company'] = $this->input->post('company',true); $post['user'] = $this->input->post('user',true); $post['show'] = $this->input->post('show',true); /** $post['out'] = $this->input->post('out',true); if($post['out'] == 1) { //$post['mode'] = $this->input->post('mode',true); $post['mode'] = 0; } else { $post['mode'] = 0; } **/ //$post['function'] = $this->input->post('function',true); //$post['functiontext'] = $this->input->post('functiontext',true); $post['country'] = $this->input->post('country',true); $post['name'] = $this->input->post('name',true); $post['phone'] = $this->input->post('phone',true); $post['province'] = $this->input->post('province',true); $post['city'] = $this->input->post('city',true); $post['zipcode'] = $this->input->post('zipcode',true); $post['address'] = $this->input->post('address',true); $post['address2'] = $this->input->post('address2',true); $post['hz'] = $this->input->post('hz',true); $post['zd'] = $this->input->post('zd',true); $post['bdck'] = $this->input->post('bdck',true); if($post['zd'] == 1 && $post['bdck'] == '' && $data['bdck'] == '') { echo json_encode(array('msg'=>'开启占单模式必须填写绑定库','success'=>false));exit; } if($post['zd'] == 1 && $post['hz'] == '' && $data['hz'] == '') { echo json_encode(array('msg'=>'开启占单模式必须填写占单后缀','success'=>false));exit; } if($post['hz'] && !ctype_alpha($post['hz'])) { echo json_encode(array('msg'=>'占单后缀只允许是字母','success'=>false));exit; } if($data['bdck'] != '') { $post['bdck'] = $data['bdck']; } if($data['hz'] != '') { $post['hz'] = $data['hz']; } if($this->warehouse->save($post,$id)) { echo json_encode(array('msg'=>'修改成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit; } } $arg_array = $arg_array[0]; $warehouse = $this->warehouse->read($arg_array); $country = $this->country->find_all(); $this->data['country'] = $country; $this->data['warehouse'] = $warehouse; $this->_Template('warehouse_edit',$this->data); } //删除 public function _del() { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',$id_arr); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } //循环删除记录 foreach ($id_arr as $v) { $this->warehouse->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true)); } } //获取数据 public function _rows() { $post = $this->input->post(NULL, TRUE); if(isset($post['rows'])) { $rows = $this->input->post('rows',true); $bn = array('0'=>array('id'=>'3','title'=>'销售出库'),'1'=>array('id'=>'4','title'=>'非更换SKU方式调拨出库')); $cn = array('0'=>array('id'=>'5','title'=>'采购入库'),'1'=>array('id'=>'6','title'=>'单产品入库'),'2'=>array('id'=>'7','title'=>'非更换SKU方式调拨入库')); $an = array('0'=>array('id'=>'1','title'=>'出库','bn'=>$bn),'1'=>array('id'=>'2','title'=>'入库','bn'=>$cn)); $warehouse = array(); if($rows != "null") { $warehouse = $this->warehouse->read($rows);//找出次ID的权限内容 if($warehouse['function']) { $warehouse = explode('|',trim($warehouse['function'],'|'));//数组化权限内容 } } echo json_encode(array('msg'=>($an),'power'=>($warehouse),'success'=>true)); } } public function _list() { $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $warehouse = $this->warehouse->read($id); if(isset($warehouse['zd'])) { if(($warehouse['zd'] == '1' && $warehouse['ys'] == '1') || $warehouse['zd'] == '0') { $zd = '0'; } else { $zd = '1'; } echo json_encode(array('msg'=>$zd,'success'=>true));exit; } else { echo json_encode(array('msg'=>'错误,请重试','success'=>false)); } } } public function _kcpd() { header("Access-Control-Allow-Origin: *"); //echo json_encode(array('msg'=>'','success'=>true));exit; //暂时不用 $post = $this->input->post(NULL, TRUE); if(isset($post['warehouse'])) { $warehouse = $this->input->post('warehouse',true); $warehouse = $this->warehouse->read($warehouse); $whlabel = $this->input->post('whlabel',true); $shop = $this->input->post('shop',true); $data = $this->input->post('data',true); $data = str_replace('--','-',$data); $number = $this->input->post('number',true); // 替换下面代码 换成logic_order的方法 // $y = $this->fullordersmt->get_number($number); // if(!$y) // { // $y = $this->fullorder->get_number($number); // } // if(!$y) // { // $y = $this->fullordertt->get_number($number); // } $y = $this->logic_order->getInfo("number = '".$number."'"); if(!preg_match('/[0-9]/',$whlabel)) { echo json_encode(array('msg'=>"无",'success'=>true));exit; } $typeclass = array(); $tdata = $this->typeclass->find_all(); foreach ($tdata as $v) { $typeclass[$v['id']] = $v['classid']; } $kxw = ''; if(1==1)//($warehouse['zd'] == '0' || ($warehouse['zd'] == '1' && stripos($whlabel,$warehouse['hz'].'|') === false)) { $kxw = '可用现货仓:';$tdfh = '';$cs = array(); $warehousedata = $this->warehouse->find_all("zd = '1' and id != '8'"); $pp = explode('|',trim($whlabel,'|')); $ccpp = explode('|',trim($data,'|')); $mgc = 0;//美国仓计数 foreach ($warehousedata as $v) { //看日志发现这有个错误 居然没有国家 很有可能是 没有此订单 又怕影响其他 干脆直接跳过本次循环吧 if(empty($y['country'])){ continue; } if($y['country'] != '192' && $v['id'] == 5) { continue; } $x = 0;$j = 0;$save = array();$tdxh = 0;$thqd = 0;$thqdzh = '';$tdwh = 0;$tdshopwh = 0;$htpd = 0;$wearToGo = 0;$hdtx = ''; foreach ($pp as $va) { $num = explode('-',$va); if($num[1] < 1) { continue; } $wh = $this->whlabel->find_count("state = '0' and number = '$num[0]' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')"); $x++; if($wh < $num[1]) { $cp = $ccpp[$x-1]; $cp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$cp); $save[] = $x-1;//提前先加X不然出错,所以要减1 $cc = explode(',',$cp); if($v['id'] == '5')//美国仓提档检测是否有货 { $tmp_cc = (int)$cc[0]; //之所以这样写 是为了避免 没有尺寸的代码 造成的字符串加1 这种不可以 如果没有长度 就不会提档 tdxh如果为0 会提示加一档有现货 if($tmp_cc > 0){ $xcc = $this->typeclass->read($cc[0]+1); if($xcc['classid'] == '14') { $tdnum = $this->str_replace_limit($cc[0],$xcc['id'],$num[0]); $tdwh = $this->whlabel->find_count("state = '0' and number = '$tdnum' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')"); } } if($tdwh < $num[1]) { $tdxh += 1;//提前先加X不然出错,所以要减1 } } //美国仓提档检测是否有货结束 //103 Body Wave 1647 LooseBody if(stripos($cp,'-103-') !== false || stripos($cp,'-1647-') !== false) { $htpd += 1; $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { //曲度后边加了长度 if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } if(stripos($newcp,'-103-') !== false) { $gpp = str_replace('-103-','-1647-',$newcp); $thqdzh = 'Loose Body'; } else { $gpp = str_replace('-1647-','-103-',$newcp); $thqdzh = 'Body'; } $qdth_wh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($qdth_wh < $num[1]) { $thqd += 1;//提前先加X不然出错,所以要减1 } } /** if(stripos($cp,'-1181-') !== false) { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } $gpp = str_replace('-1181-','-2071-',$newcp); $wtgo_wh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($wtgo_wh >= $num[1]) { $wearToGo += 1; } } */ /** /HKK if(stripos($cp,'-2028-') !== false) { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } $gpp = str_replace('-2028-','-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 非HKK有货;'; } } else if(stripos($cp,'-128-') !== false) { $cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套 $cc1 = explode('-',trim($cc[1],'-')); $cptt[$typeclass[$cc[0]]] = $cc[0]; $newcp = '-'; foreach ($cc1 as $kk=>$vv) { $cptt[$typeclass[$vv]] = $vv; } if($cptt[44] != '') { continue; } else { $cptt[44] = '2028'; $cptt = array_filter($cptt); } $gpp = '-'.implode("-",$cptt).'-'; $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - HKK有货;'; } } **/ //RTGWL 注释掉了 // if(stripos($cp,'-2076-') !== false) // { // $cc1 = explode('-',trim($cc[1],'-')); // $newcp = '-'; // foreach ($cc1 as $kk=>$vv) // { // if($kk == 1) // { // $newcp .= $vv.'-'.$cc[0].'-'; // } // else // { // $newcp .= $vv.'-'; // } // } // $gpp = str_replace('-2076-','-',$newcp); // $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 // if($ccxh >= $num[1]) // { // $hdtx .= $v['title'].' - 非RTGWL有货;'; // } // } // else if(stripos($cp,'-128-') !== false) // { // $cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套 // $cc1 = explode('-',trim($cc[1],'-')); // $cptt[$typeclass[$cc[0]]] = $cc[0]; // $newcp = '-'; // foreach ($cc1 as $kk=>$vv) // { // $cptt[$typeclass[$vv]] = $vv; // } // if($cptt[44] != '') // { // continue; // } // else // { // $cptt[44] = '2076'; // $cptt = array_filter($cptt); // } // $gpp = '-'.implode("-",$cptt).'-'; // $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 // if($ccxh >= $num[1]) // { // $hdtx .= $v['title'].' - RTGWL有货;'; // } // } // 4*7没货的,5*7如果有货,给提醒 if(stripos($cp,'-1253-') !== false) { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } $gpp = str_replace('-1253-','-2062-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 5*7有货;'; } } // 5*5没货的,5*7、5*9如果有货,给提醒 if(stripos($cp,'-297-') !== false) //13*4 HD13*4 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } $gpp = str_replace('-297-','-2062-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 5*7有货;'; } $gpp2 = str_replace('-297-','-1254-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 5*9有货;'; } } // 180%货的,200、250如果有货,给提醒 if(stripos($cp,'-72-') !== false) //13*4 HD13*4 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } $gpp = str_replace('-72-','-73-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 200%密度有货;'; } $gpp2 = str_replace('-72-','-74-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 250%密度有货;'; } } if(stripos($cp,'-73-') !== false) //200% 250% { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } $gpp2 = str_replace('-73-','-74-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 250%密度有货;'; } } //HD相互提醒 if(stripos($cp,'-146-') !== false || stripos($cp,'-331-') !== false) //13*4 HD13*4 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } if(stripos($cp,'-146-') !== false) { $gpp = str_replace('-146-','-331-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - HD13*4有货;'; } } else if(stripos($cp,'-331-') !== false) { $gpp = str_replace('-331-','-146-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 13*4有货;'; } } } if(stripos($cp,'-322-') !== false || stripos($cp,'-341-') !== false)//13*6 HD13*6 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } if(stripos($cp,'-322-') !== false) { $gpp = str_replace('-322-','-341-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - HD13*6有货;'; } } else if(stripos($cp,'-341-') !== false) { $gpp = str_replace('-341-','-322-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 13*6有货;'; } } } if(stripos($cp,'-147-') !== false || stripos($cp,'-781-') !== false)//4*4 HD4*4 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } if(stripos($cp,'-147-') !== false) { $gpp = str_replace('-147-','-781-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - HD4*4有货;'; } } else if(stripos($cp,'-781-') !== false) { $gpp = str_replace('-781-','-147-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 4*4有货;'; } } } if(stripos($cp,'-297-') !== false || stripos($cp,'-540-') !== false)//5*5 HD5*5 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } if(stripos($cp,'-297-') !== false) { $gpp = str_replace('-297-','-540-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - HD5*5有货;'; } } else if(stripos($cp,'-540-') !== false) { $gpp = str_replace('-540-','-297-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 5*5有货;'; } } } if(stripos($cp,'-298-') !== false || stripos($cp,'-370-') !== false)//6*6 HD6*6 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } if(stripos($cp,'-298-') !== false) { $gpp = str_replace('-298-','-370-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - HD6*6有货;'; } } else if(stripos($cp,'-370-') !== false) { $gpp = str_replace('-370-','-298-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - 6*6有货;'; } } } if(stripos($cp,'-935-') !== false || stripos($cp,'-854-') !== false)//#P4/27/613 #P4/613 { $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } if(stripos($cp,'-935-') !== false) { $gpp = str_replace('-935-','-854-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - #P4/613;'; } } else if(stripos($cp,'-854-') !== false) { $gpp = str_replace('-854-','-935-',$newcp); $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用 if($ccxh >= $num[1]) { $hdtx .= $v['title'].' - #P4/27/613;'; } } } //HD相互提醒结束 if(isset($cc[1])){ $cc1 = explode('-',trim($cc[1],'-')); $newcp = '-'; foreach ($cc1 as $kk=>$vv) { if($kk == 1) { $newcp .= $vv.'-'.$cc[0].'-'; } else { $newcp .= $vv.'-'; } } }else{ //$this->logic_ding->sendToDing("仓库kcpd提醒cc".json_encode($cc).'cp'.json_encode($cp)."ccpp".json_encode($ccpp)."number:".$number); $newcp = $cc[0]; } //在途库存 $transportlist = $this->whlabeltransport->find_all("features = '".$newcp."' and cz = 0 and warehouse = '".$v['id']."'"); $transportMsg = ""; if(count($transportlist) > 0) { $transportItem = $transportlist[0]; $transportMsg = "
". $transportItem['sku'] . " 在途库存: " . $transportItem['num'] . " 预达时间: ".date("Y-m-d",$transportItem['stime']). "
备注 : " . $transportItem['text']; } } else { if($v['id'] == '5') { $mgc++; } else { $kxw .= $v['title'].';'; } } } if(!isset($save[0]))//非预设仓库提醒 { //$kxw .= $v['title'].';'; } else { if($v['id'] == '5' && $tdxh == '0') { $kxw .= $v['title'].'(当前尺寸无货,提一档有货) ;'; } if($thqd == 0 && $htpd > 0) { $kxw .= $v['title'].'(当前曲度无货,'.$thqdzh.'有货) ;'; } if($wearToGo > 0) { $kxw .= $v['title'].'(ReadytoGo有货) ;'; } if($hdtx != '') { $kxw .= $hdtx; } if (!empty($transportMsg)) { $kxw .= $transportMsg; } } } } if(isset($pp) && $mgc == count($pp)) { $kxw .= '美国店;'; } if($kxw == '可用现货仓:') { echo json_encode(array('msg'=>$kxw.'无','cs'=>$cs,'success'=>true));exit; } else { echo json_encode(array('msg'=>rtrim($kxw,';'),'success'=>true));exit; } } } public function str_replace_limit($search, $replace, $subject) { $pos = strpos($subject, $search); if ($pos !== false) { return substr_replace($subject, $replace, $pos, strlen($search)); } return $subject; } public function _orderlist() { $post = $this->input->post(NULL, TRUE); if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $fgshop = "";$sid = "";$wid="";$wtype=""; $usersp = explode('|',trim($user['shop'],'|')); $userwh = explode('|',trim($user['warehouse'],'|')); foreach ($usersp as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } foreach ($userwh as $value) { $wid .= " id = ".$value." or"; $wtype .= " type = ".$value." or"; } } if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $orderinfo = $this->input->post('orderinfo',true); $number = $this->input->post('number',true); $print = $this->input->post('print',true); $shop = $this->input->post('shop',true); $type = $this->input->post('type',true); $ckfl = $this->input->post('ckfl',true); $so = $this->input->post('so',true); $sfxh = $this->input->post('sfxh',true); $library = $this->input->post('library',true); $libraryconfirm = $this->input->post('libraryconfirm',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'"; if($orderinfo) { $where .= " and orderinfo = '$orderinfo'"; } if($number) { $where .= " and number = '$number'"; } if($print) { $where .= " and print = '$print'"; if($print == 3) { $where .= " and printtime > '$timetk' and printtime < '$timetj'"; } } if($shop) { $where .= " and shop = '$shop'"; } if($type) { $where .= " and type = '$type'"; } if($so) { $where .= " and shipremarks like '%$so%'"; } if($ckfl) { $where .= " and ckfl = '$ckfl'"; } if($library) { $where .= " and library = '$library'"; } if($type) { $where .= " and type = '$type'"; } if($libraryconfirm) { $where .= " and libraryconfirm = '$libraryconfirm'"; } //数据排序 $order_str = ($print != 3)?"id desc":"printtime desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } $t = array(); $transfer = $this->transfer->find_all(); foreach ($transfer as $v) { $t[$v['id']] = $v['title']; $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0; } //取得信息列表 $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage); $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage); $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage); $rows = array_merge($info_list,$info_listsmt,$info_listtt); //格式化数据 foreach ($rows as $key=>$value) { $rows[$key]['id'] = $value['id'].'-fullorder'; $shop = $this->shop->read($value['shop']); $rows[$key]['shop'] = $shop['shopname']; if($value['printtime'] > 0) { $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']); } else { $rows[$key]['printtime'] = '未打印'; } if(isset($value['librarytime']) && $value['librarytime'] > 0) { $rows[$key]['librarytime'] = date('Y-m-d H:s',$value['librarytime']); } else { $rows[$key]['librarytime'] = '未出库'; } $rows[$key]['orderinfo'] = "

".$value['orderinfo']."

"; $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']); $out = ''; $tf = $this->systemtransfer->find_all("number = '".$value['number']."'"); if(!empty($tf)){ if($tf[0]['is_jiaji']){ $rows[$key]['number'] = "".$rows[$key]['number']."加急!!!"; } } foreach ($tf as $k=>$v) { if(count($tf) > 1) { $out .= $k.'
'; } $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'"); $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'
'; foreach ($data as $k=>$v) { $type = ($v['type']==1)?'入库':'出库'; $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'
'; } } $rows[$key]['outread'] = trim($out,'
'); } $dlz = $this->fullorder->find_count($where); $smt = $this->fullordersmt->find_count($where); $tt = $this->fullordertt->find_count($where); //$total += $this->fullorder_smt->find_count($where); $total = $dlz+$smt+$tt; //$rows = array_slice($rows,$start,$perpage); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $tmp = array(); if($print == 3) { foreach ($rows as $key => $val) { $tmp[$key] = $val['printtime']; } array_multisort($tmp,SORT_DESC,$rows); } $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt) echo json_encode($rows);exit; } if(isset($_SESSION['api'])) { $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or')); $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc"); $this->data['wlshop'] = $wlshop; $this->data['warehouse'] = $warehouse; } $this->_Template('warehouse_orderlist',$this->data); } public function _orderlistck()//华荣厂查看 { $post = $this->input->post(NULL, TRUE); if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $fgshop = "";$sid = "";$wid="";$wtype=""; $usersp = explode('|',trim($user['shop'],'|')); $userwh = explode('|',trim($user['warehouse'],'|')); foreach ($usersp as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } foreach ($userwh as $value) { $wid .= " id = ".$value." or"; $wtype .= " type = ".$value." or"; } } if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $number = $this->input->post('number',true); $so = $this->input->post('so',true); $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'"; if($number) { $where .= " and number = '$number'"; } if($so) { $where .= " and shipremarks like '%$so%'"; } if(!$so && !$number) { $where = "id < 0"; } //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } $info_list = array(); $info_listsmt = array(); $dlz = 0; $smt = 0; //取得信息列表 $info_list = $this->fullorder->find_all($where,'id,number,shipremarks',$order_str,$start,$perpage); $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage); $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage); $rows = array_merge($info_list,$info_listsmt,$info_listtt); //格式化数据 foreach ($rows as $key=>$value) { $rows[$key]['id'] = $value['id'].'-fullorder'; $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']); $systemwigsout = $this->systemwigsout->get_number($value['number']); $wigsout = ''; if($systemwigsout) { $cz = explode('|',trim($systemwigsout['cz'],'|')); $cztime = explode('|',trim($systemwigsout['cztime'],'|')); $zw = array(); $t = $this->transfer->find_all("1=1"); foreach ($t as $v) { $zw[$v['id']] = $v['title']; } if($systemwigsout['cz'] != '' && count($cz) > 0) { for($i=0;$ifullorder->find_count($where); $smt = $this->fullordersmt->find_count($where); $tt = $this->fullordersmt->find_count($where); //$total += $this->fullorder_smt->find_count($where); $total = $dlz+$smt+$tt; //$rows = array_slice($rows,$start,$perpage); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $tmp = array(); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt) echo json_encode($rows);exit; } if(isset($_SESSION['api'])) { $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or')); $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc"); $this->data['wlshop'] = $wlshop; $this->data['warehouse'] = $warehouse; } $this->_Template('warehouse_orderlistck',$this->data); } public function _ordersee($arg_array) { $arg_array = $arg_array[0]; $fullorder = 'fullorder'; $data = $this->fullorder->read($arg_array); if(!$data) { $fullorder = 'fullordersmt'; $data = $this->fullordersmt->read($arg_array); } if(!$data) { $fullorder = 'fullordertt'; $data = $this->fullordertt->read($arg_array); } $fpdata = array(); $fullorder = $this->$fullorder->read($arg_array); if(stripos($fullorder['fpdata'],';') !== false) { $fpdata = explode(';',rtrim($fullorder['fpdata'],';')); foreach ($fpdata as $k=>$v) { $fpdata[$k] = explode('|',$v); } } $systemwigsout = $this->systemwigsout->get_number($fullorder['number']); $wigsout = array(); if($systemwigsout) { $cz = explode('|',trim($systemwigsout['cz'],'|')); $cztime = explode('|',trim($systemwigsout['cztime'],'|')); $zw = array(); $t = $this->transfer->find_all("1=1"); foreach ($t as $v) { $zw[$v['id']] = $v['title']; } if($systemwigsout['cz'] != '' && count($cz) > 0) { for($i=0;$idata['systemwigsout'] = $wigsout; $this->data['fpdata'] = $fpdata; $this->data['data'] = $data; $this->_Template('warehouse_ordersee',$this->data); } public function _orderlistexcel() { $post = $this->input->post(NULL, TRUE); if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $fgshop = "";$sid = "";$wid="";$wtype=""; $usersp = explode('|',trim($user['shop'],'|')); $userwh = explode('|',trim($user['warehouse'],'|')); foreach ($usersp as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } foreach ($userwh as $value) { $wid .= " id = ".$value." or"; $wtype .= " type = ".$value." or"; } } if(isset($_GET['excel'])) { $a = $this->input->get('a',true); $id_is = '';$id_smt = ''; if($a) { $a = explode(',',rtrim($a,',')); foreach ($a as $value) { $v = explode('-',$value); if($v[1] == 'fullorder') { $id_is .= "id = ".$v[0]." or "; } else { $id_smt .= "id = ".$v[0]." or "; } } if($id_is) { $id_is = " and (".rtrim($id_is,'or ').")"; } if($id_smt) { $id_smt = " and (".rtrim($id_smt,'or ').")"; } } $timetk = $this->input->get('timetk',true); $timetj = $this->input->get('timetj',true); $orderinfo = $this->input->get('orderinfo',true); $number = $this->input->get('number',true); $print = $this->input->get('print',true); $shop = $this->input->get('shop',true); $type = $this->input->get('type',true); $ckfl = $this->input->get('ckfl',true); $so = $this->input->get('so',true); $sfxh = $this->input->get('sfxh',true); $library = $this->input->get('library',true); $libraryconfirm = $this->input->get('libraryconfirm',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'"; if($orderinfo) { $where .= " and orderinfo = '$orderinfo'"; } if($number) { $where .= " and number = '$number'"; } if($print) { $where .= " and print = '$print'"; if($print == 3) { $where .= " and printtime > '$timetk' and printtime < '$timetj'"; } } if($shop) { $where .= " and shop = '$shop'"; } if($type) { $where .= " and type = '$type'"; } if($so) { $where .= " and shipremarks like '%$so%'"; } if($ckfl) { $where .= " and ckfl = '$ckfl'"; } if($library) { $where .= " and library = '$library'"; } if($libraryconfirm) { $where .= " and libraryconfirm = '$libraryconfirm'"; } $t = array(); $transfer = $this->transfer->find_all(); foreach ($transfer as $v) { $t[$v['id']] = $v['title']; $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0; } $order_str = ($print != 3)?"id desc":"printtime desc"; $info_list = $this->fullorder->find_all($where.$id_is,'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str); $info_listsmt = $this->fullordersmt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str); $info_listtt = $this->fullordertt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str); $rows = array_merge($info_list,$info_listsmt,$info_listtt); foreach ($rows as $key=>$value) { if($value['printtime'] > 0) { $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']); } else { $rows[$key]['printtime'] = '未打印'; } if($value['library'] == 1) { $rows[$key]['library'] = "未出库"; } else if($value['library'] == 2) { $rows[$key]['library'] = "已出库"; } else if($value['library'] == 3) { $rows[$key]['printtime'] = '已退库'; } if($value['libraryconfirm'] == 1) { $rows[$key]['libraryconfirm'] = '不允许出库'; } else { $rows[$key]['libraryconfirm'] = '允许出库'; } $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']); $out = ''; $tf = $this->systemtransfer->find_all("number = '".$value['number']."'"); foreach ($tf as $k=>$v) { if(count($tf) > 1) { $out .= $k.'
'; } $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'"); $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'
'; foreach ($data as $k=>$v) { $type = ($v['type']==1)?'入库':'出库'; $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'
'; } } $rows[$key]['systemwigsout'] = trim($out,'
'); } $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj).'进销存详情'; $titlename = "

".$title."

编号 仓库品名 条数 打印时间 出库状态 出库确认 禁止出库原因 追踪
"; $filename = $title.".xls"; $tail = ""; $this->excel->get_fz2($rows,$titlename,$filename,$tail); } } }