load->library('session'); $this->load->_model('Model_whlabel_bh','whlabel_bh'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_purchase','purchase'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullorder_smt','fullorder_smt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_express','express'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_country','country'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_kdniao','kdniao'); $this->load->_model('Model_notice','notice'); $this->load->_model('Model_dhl','dhl'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_fullorderexcel','fullorderexcel'); $this->load->_model('Model_ljg','ljg'); $this->load->_model('Model_usps','usps'); $this->load->_model('Model_specialstock','specialstock'); $this->load->_model('Model_whlabellabel','whlabellabel'); $this->load->_model('Model_whlabelwz','whlabelwz'); $this->load->_model('Model_whlabelbarcode','whlabelbarcode'); $this->load->_model('Model_whlabeltransport','whlabeltransport'); $this->load->_model('Model_orderurl','orderurl'); $this->load->_model('Model_brand','brand'); $this->load->_model('Model_classid','classid'); $this->load->_model('Model_apiyy','apiyy'); $this->load->_model('Model_whlabel_bh_list','whlabel_bh_list'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_whlabel_bh_transfer','whlabel_bh_transfer'); $this->load->_model('Model_transfer','transfer'); } //定义方法的调用规则 获取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 == 'deltransfer')//删除 { $this->_deltransfer(); } else if($arg == 'cz')//删除 { $this->_cz(); } else if($arg == 'db')//删除 { $this->_db(); } else if($arg == 'kc')//删除 { $this->_kc(); } else if($arg == 'excel')//删除 { $this->_excel(); } else if($arg == 'xxpl')//删除 { $this->_xxpl(); } else if($arg == 'bbprint')//删除 { $this->_bbprint(); } else if($arg == 'operate') { $this->_operate(); } else if($arg == 'out') { $this->_out(); } else if($arg == 'bdbb') { $this->_bdbb(); } 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); $orderinfo = $this->input->post('orderinfo',true); $jm = $this->input->post('jm',true); $title = $this->input->post('title',true); $pm = $this->input->post('pm',true); $category = $this->input->post('category',true); $size = $this->input->post('size',true); $grade = $this->input->post('grade',true); $color = $this->input->post('color',true); $lowe = $this->input->post('lowe',true); $type = $this->input->post('type',true); $shipremarks = $this->input->post('shipremarks',true); $type = $this->input->post('type',true); $state = $this->input->post('state',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 "; if($timetk && $timetj) { $where .= " and time > '$timetk' and time < '$timetj'"; } if($orderinfo) { $where .= " and orderinfo like '%$orderinfo%'"; } if($type != '') { $where .= " and type = '$type'"; } if($jm) { $where .= " and jm like '%$jm%'"; } if($title) { $where .= " and title like '%$title%'"; } if($pm) { $where .= " and pm like '%$pm%'"; } if($category) { $where .= " and shipremarks like '%-$category-%'"; } if($size) { $where .= " and shipremarks like '%-$size-%'"; } if($grade) { $where .= " and shipremarks like '%-$grade-%'"; } if($color) { $where .= " and shipremarks like '%-$color-%'"; } if($lowe) { $where .= " and shipremarks like '%-$lowe-%'"; } if($type) { $where .= " and type = '$type'"; } if($state) { $where .= " and state = '$state'"; } if($shipremarks) { $where .= " and shipremarks like '%$shipremarks%'"; } //数据排序 $order_str = "time desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } $warehouse = $this->warehouse->find_all(); $ck = array(); foreach ($warehouse as $v) { $ck[$v['id']] = $v['title']; } //取得信息列表 $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,time,cscg',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { $d = $this->whlabel_bh->read($value['id']); $info_list[$key]['title'] = "".$d['jm'].'
'.$d['pm'].'
'.$value['title']; $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'"); $printnum = array_sum(array_column($printnum,'ts')); $info_list[$key]['printnum'] = $printnum; $info_list[$key]['num'] = $value['bhnum']-$printnum; $info_list[$key]['time'] = date('Y-m-d',$value['time']).'
'.date('H:i:s',$value['time']); $info_list[$key]['cscg'] = "打印布标"; } $total = $this->whlabel_bh->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; /** $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,kcnum,num,rknum,dbnum,state,time,scapi,dbapi',$order_str,$start,$perpage); foreach ($info_list as $key=>$value) { $d = $this->whlabel_bh->read($value['id']); if($d['print'] == 0) { $print = "

未打印

"; } else { $print = "

已打印

"; } if($value['state'] == 0) { $info_list[$key]['state'] = "

待生产/外购

传输料号

";//开 始 } else if($value['state'] == 1) { $info_list[$key]['state'] = "

生产/外购中

完成入库

".$print; } else if($value['state'] == 2) { $info_list[$key]['state'] = "

已完成

已全部入库

"; } $info_list[$key]['time'] = date('Y-m-d',$value['time']).'
'.date('H:i:s',$value['time']); $info_list[$key]['title'] = $d['jm'].'
'.$d['pm'].'
'.$value['title']; $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'"); $zc = ''; foreach ($zd as $v) { $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'
'; } $info_list[$key]['scapi'] = $zc; $info_list[$key]['dbapi'] = "调拨出库"; $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num')); } **/ } if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); } else { header('Location: /');exit; } $w = $this->shop->find_all("yyid != ''"); $this->data['yyck'] = $w; if($user['userid'] == 'ch') { $user['vip'] = 1; } $this->data['vip'] = $user['vip']; $this->_Template('whlabel_bh',$this->data); } //入库操作 public function _add() { $tc = $this->typeclass->find_all(); $typeclass = array(); foreach ($tc as $v) { $tcjm[$v['id']] = array($v['jm'],$v['classid']); $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']); } $post = $this->input->post(NULL, TRUE); if(isset($post['num'])) { $list = array(); $sku = $this->input->post('sku',true); $category = $this->input->post('category',true); $list['category'] = $category; $list['hairtype'] = $this->input->post('hairtype',true); $list['grade'] = $this->input->post('grade',true); $size = $this->input->post('size',true); $xzsku = $this->input->post('xzsku',true); $list['size'] = rtrim($size,','); $list['hairnumber'] = $this->input->post('hairnumber',true); $list['extension'] = $this->input->post('extension',true); if($category == 1297) { $list['sywignumber'] = $this->input->post('sywignumber',true); } if($category == 1702) { $list['syhairnumber'] = $this->input->post('syhairnumber',true); $list['syother'] = $this->input->post('syother',true); } if($category == 133) { $list['fittype'] = $this->input->post('fittype',true); $list['acother'] = $this->input->post('acother',true); } $list['color'] = $this->input->post('color',true); $list['lowe'] = $this->input->post('lowe',true); if($category == 127) { $list['type'] = $this->input->post('type',true); $list['headroad'] = $this->input->post('headroad',true); $list['density'] = $this->input->post('density',true); if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) { $list['lacesize'] = $this->input->post('lacesize',true); } $list['lacecolor'] = $this->input->post('lacecolor',true); $list['lacetypes'] = $this->input->post('lacetypes',true); } if($category == 128) { $list['lacetype'] = $this->input->post('lacetype',true); $list['haircap'] = $this->input->post('haircap',true); $list['density'] = $this->input->post('density',true); $list['lacecolor'] = $this->input->post('lacecolor',true); $list['lacetypes'] = $this->input->post('lacetypes',true); $list['wigother'] = $this->input->post('wigother',true); $list['wigother2'] = $this->input->post('wigother2',true); } if($category == 129) { $list['wide'] = $this->input->post('wide',true); } if($category == 131) { $list['gifttype'] = $this->input->post('gifttype',true); $list['giftother'] = $this->input->post('giftother',true); } if($category == 134) { $list['pieceweight'] = $this->input->post('pieceweight',true); } if($category == 1297) { $list['synthetictype'] = $this->input->post('synthetictype',true); $list['sywigother'] = $this->input->post('sywigother',true); } if($category == 130 || $category == 133 || $category == 1702) { $list['items'] = $this->input->post('items',true); $list['weight'] = $this->input->post('weight',true); } if($category == 1702) { $list['syhairther'] = $this->input->post('syhairther',true); } $classid = $this->classid->sku(); $pm = $classid; $jm = $classid; $sku = $sku; $title = '';$features = '';$cs = array(); $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>''); foreach($list as $k=>$v) { if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']])) { if($typeclass[$v]['bm'] != '') { $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm']; } } if($v != 0) { if($k != 'size') { $title .= $typeclass[$v]['title']." "; } $features .=$v.'-'; $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku']; if(isset($pm[$typeclass[$v]['classid']])) { if($typeclass[$v]['title'] == '9A') { $pm[$typeclass[$v]['classid']] = '9A'; } else if($typeclass[$v]['title'] == '10A') { $pm[$typeclass[$v]['classid']] = '10A'; } else { $clzh = $typeclass[$v]['zh']; if(stripos($typeclass[$v]['zh'],'|') !== false) { $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|')); $clzh = $clzh[0]; } $pm[$typeclass[$v]['classid']] = $clzh; } } if(isset($jm[$typeclass[$v]['classid']])) { if($typeclass[$v]['jm']) { $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm']; } } } } $jm = array_filter($jm);//去除空值 $jm = implode("-",$jm); $sku = array_filter($sku);//去除空值 $sku = implode("-",$sku); $pm = array_filter($pm);//去除空值 $pm = implode(" ",$pm); $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' ')); if($list['size']) { $typeclass = $this->typeclass->read($list['size']); $title .= $typeclass['title']; } $title = trim($title,' '); $post['num'] = $this->input->post('num',true); $ztime = $this->input->post('ztime',true); $post['ztime'] = strtotime($ztime); $post['bm'] = '03'.implode("",$bmpx); $post['jm'] = $jm; $post['sku'] = $sku; $post['pm'] = $pm; $post['title'] = $title; $post['features'] = '-'.$features; $post['number'] = date('YmdHis',time()).rand(100,999); if(!$post['num']) { $post['number'] = date("YmdHis").rand(100,999); } $time = time(); $post['time'] = $time;//操作时间 $post['printnum'] = $time; $post['type'] = 0; //传输料号开始 $lc = 0; $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm'])); if(isset($lh['Data'][0])) { if($lh['Data'][0]['m_isSucess'] != 1) { if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!') { echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit; } } } else { echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit; } if($this->whlabel_bh->insert($post)) { echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit; } else { echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit; } } $w = $this->shop->find_all("yyid != ''"); $this->data['yyck'] = $w; $purchase = $this->purchase->find_all("yyid != ''"); $this->data['purchase'] = $purchase; $this->data['data'] = (isset($_GET['data']))?$_GET['data']:''; $this->_Template('whlabel_bh_add',$this->data); } public function get_cjlp($data)//创建料品 { $list["0"]["Code"] = $data['jm'];//料号,SKU $list["0"]["Code1"] = ''; $list["0"]["Name"] = $data['zh'];//产品名称 $list["0"]["MainItemCategory"]["Code"] = $data['bm']; $list["0"]["Org"]["Code"] = 001; $list["0"]["OtherID"] = 1; $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1; $list["0"]["PurchaseInfo"]["PriceSource"] = 2; $list["0"]["PurchaseInfo"]["InquireRule"] = -1; $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0; $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1; $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true; $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true; $list["0"]["InventoryUOM"]["Code"] = '条'; $list["0"]["InventorySecondUOM"]["Code"] = ''; $list["0"]["IsDualUOM"] = false; $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4; $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1; $list["0"]["InventoryInfo"]["TurnOverRate"] = 1; $list["0"]["InventoryInfo"]["ReserveMode"] = -1; $list["0"]["InventoryInfo"]["SupplyMethod"] = -1; $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01; $list["0"]["DescFlexField"]["PubDescSeg5"] = 01; $list["0"]["Description"] = $data['title']; $list["0"]["ItemForm"] = 2001; $list["0"]["ItemFormAttribute"] = 10; $list["0"]["IsInventoryEnable"] = true; $list["0"]["IsPurchaseEnable"] = true; $list["0"]["IsSalesEnable"] = true; $list["0"]["IsBuildEnable"] = true; $list["0"]["IsOutsideOperationEnable"] = true; $list["0"]["IsMRPEnable"] = true; $list["0"]["IsBOMEnable"] = true; $list["0"]["IsCostCalByGrade"] = false; $list["0"]["IsCostCalByPotency"] = false; $list["0"]["IsGradeControl"] = false; $list["0"]["StandardGrade"] = -1; $list["0"]["StartGrade"] = -1; $list["0"]["EndGrade"] = -1; $list["0"]["IsPotencyControl"] = false; $list["0"]["StandardPotency"] = -1; $list["0"]["StartPotency"] = -1; $list["0"]["EndPotency"] = -1; $asd = $list; $list = json_encode($list); $token = $this->setting->get_yytoken_130(); $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create'; $header[] = "Content-Type: application/json"; $header[] = "Token: ".$token; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $list); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $res = curl_exec($ch); $res = json_decode($res,true); return $asd; } //修改产品 public function _edit($arg_array) { $tc = $this->typeclass->find_all(); $typeclass = array(); foreach ($tc as $v) { $tcjm[$v['id']] = array($v['jm'],$v['classid']); $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']); } $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $list = array(); $sku = $this->input->post('sku',true); $category = $this->input->post('category',true); $list['category'] = $category; $list['hairtype'] = $this->input->post('hairtype',true); $list['grade'] = $this->input->post('grade',true); $size = $this->input->post('size',true); $xzsku = $this->input->post('xzsku',true); $list['size'] = rtrim($size,','); $list['hairnumber'] = $this->input->post('hairnumber',true); $list['extension'] = $this->input->post('extension',true); if($category == 1297) { $list['sywignumber'] = $this->input->post('sywignumber',true); } if($category == 1702) { $list['syhairnumber'] = $this->input->post('syhairnumber',true); $list['syother'] = $this->input->post('syother',true); } if($category == 133) { $list['fittype'] = $this->input->post('fittype',true); $list['acother'] = $this->input->post('acother',true); } $list['color'] = $this->input->post('color',true); $list['lowe'] = $this->input->post('lowe',true); if($category == 127) { $list['type'] = $this->input->post('type',true); $list['headroad'] = $this->input->post('headroad',true); $list['density'] = $this->input->post('density',true); if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) { $list['lacesize'] = $this->input->post('lacesize',true); } $list['lacecolor'] = $this->input->post('lacecolor',true); $list['lacetypes'] = $this->input->post('lacetypes',true); } if($category == 128) { $list['lacetype'] = $this->input->post('lacetype',true); $list['haircap'] = $this->input->post('haircap',true); $list['density'] = $this->input->post('density',true); $list['lacecolor'] = $this->input->post('lacecolor',true); $list['lacetypes'] = $this->input->post('lacetypes',true); $list['wigother'] = $this->input->post('wigother',true); $list['wigother2'] = $this->input->post('wigother2',true); } if($category == 129) { $list['wide'] = $this->input->post('wide',true); } if($category == 131) { $list['gifttype'] = $this->input->post('gifttype',true); $list['giftother'] = $this->input->post('giftother',true); } if($category == 134) { $list['pieceweight'] = $this->input->post('pieceweight',true); } if($category == 1297) { $list['synthetictype'] = $this->input->post('synthetictype',true); $list['sywigother'] = $this->input->post('sywigother',true); } if($category == 130 || $category == 133 || $category == 1702) { $list['items'] = $this->input->post('items',true); $list['weight'] = $this->input->post('weight',true); } if($category == 1702) { $list['syhairther'] = $this->input->post('syhairther',true); } $classid = $this->classid->sku(); $pm = $classid; $jm = $classid; $sku = $sku; $title = '';$features = '';$cs = array(); $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>''); foreach($list as $k=>$v) { if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']])) { if($typeclass[$v]['bm'] != '') { $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm']; } } if($v != 0) { if($k != 'size') { $title .= $typeclass[$v]['title']." "; } $features .=$v.'-'; $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku']; if(isset($pm[$typeclass[$v]['classid']])) { if($typeclass[$v]['title'] == '9A') { $pm[$typeclass[$v]['classid']] = '9A'; } else if($typeclass[$v]['title'] == '10A') { $pm[$typeclass[$v]['classid']] = '10A'; } else { $clzh = $typeclass[$v]['zh']; if(stripos($typeclass[$v]['zh'],'|') !== false) { $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|')); $clzh = $clzh[0]; } $pm[$typeclass[$v]['classid']] = $clzh; } } if(isset($jm[$typeclass[$v]['classid']])) { if($typeclass[$v]['jm']) { $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm']; } } } } $jm = array_filter($jm);//去除空值 $jm = implode("-",$jm); $sku = array_filter($sku);//去除空值 $sku = implode("-",$sku); $pm = array_filter($pm);//去除空值 $pm = implode(" ",$pm); $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' ')); if($list['size']) { $typeclass = $this->typeclass->read($list['size']); $title .= $typeclass['title']; } $title = trim($title,' '); $post['num'] = $this->input->post('num',true); $ztime = $this->input->post('ztime',true); $post['ztime'] = strtotime($ztime); $post['bm'] = '03'.implode("",$bmpx); $post['jm'] = $jm; $post['sku'] = $sku; $post['pm'] = $pm; $post['title'] = $title; $post['features'] = '-'.$features; $ztime = $this->input->post('ztime',true); if($ztime) { $post['ztime'] = strtotime($ztime); } if($this->whlabel_bh->save($post,$id)) { echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit; } else { echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit; } } $w = $this->shop->find_all("yyid != ''"); $this->data['yyck'] = $w; $whlabel_bh = $this->whlabel_bh->read($arg_array[0]); $this->data['whlabel_bh'] = $whlabel_bh ; $purchase = $this->purchase->find_all("yyid != ''"); $this->data['purchase'] = $purchase; $this->_Template('whlabel_bh_edit',$this->data); } public function _cz() { $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $cz = $this->input->post('cz',true); $num = $this->input->post('num',true); $cz = $cz+1; $w = $this->whlabel_bh->read($id); if(!$w) { echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit; } //传输料号开始 $lc = 0; $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm'])); if(isset($lh['Data'][0])) { if($lh['Data'][0]['m_isSucess'] != 1) { if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!') { echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit; } } } else { echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit; } echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true)); /** 投产 if($w['scapi'] != 99) { if($w['state'] == $cz) { echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit; } if($w['type'] == '0') { $type = '生产'; $bhlx = 0; } else { $type = '外购'; $bhlx = 1; } $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000); if($yy['c'] == 0) { if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id)) { echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true)); } else { echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false)); } } else { echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit; } } else if($w['dbapi'] != 99 && $w['type'] == '0') { $cz = 1; if(!is_numeric($num)) { echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit; } if($num > $w['num']-$w['rknum']) { echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit; } if($w['rknum']+$num == $w['num']) { $dbapi = 99; $cz = 2; } else { $dbapi = 0; } $w['ts'] = $num; $rk = $this->apiyy->_newrk($w); if($rk['c'] == 0) { if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id)) { if($dbapi == 99) { echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true)); } else { echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true)); } } else { echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false)); } } else { $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id); echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit; } } else if($w['dbapi'] != 99 && $w['type'] == '1') { $cz = 1; if(!is_numeric($num)) { echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit; } if($num > $w['num']-$w['rknum']) { echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit; } if($w['rknum']+$num == $w['num']) { $dbapi = 99; $cz = 2; } else { $dbapi = 0; } $scid = explode('~',$w['scid']); $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']); if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id)) { if($dbapi == 99) { echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true)); } else { echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true)); } } else { echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit; } } **/ } } public function _db() { $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $num = $this->input->post('num',true); $warehouse = $this->input->post('warehouse',true); $w = $this->warehouse->read($warehouse); $data = $this->whlabel_bh->read($id); if(!$data) { echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit; } $d = $this->whlabel_bh_list->find_all("uid = '".$id."'"); $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num'))); if($num > $data['rknum']-$ydbnum) { echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit; } $data['dccbm'] = 13001;//默认从许昌仓调出 $data['ts'] = $num; $data['drcbm'] = $w['yybm']; $dc = $this->apiyy->get_cpdc($data); if(isset($dc['Data'][0])) { if($dc['Data'][0]['IsSucess'] != 1) { echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit; } else { $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130); if(isset($sh['Data'][0])) { $code = $sh['Data'][0]['Code']; echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false)); } else { $code = ''; echo json_encode(array('msg'=>'调出成功!','success'=>true)); } $p['uid'] = $id; $p['bm'] = $data['bm']; $p['sku'] = $data['jm']; $p['shipremarks'] = $data['shipremarks']; $p['title'] = $data['title']; $p['zh'] = $data['pm']; $p['fpdata'] = $data['features']; $p['num'] = $num; $p['warehouse'] = 13;//默认从许昌仓调出 $p['rwarehouse'] = $warehouse; $p['time'] = time();//操作时间 $p['code'] = $code; $this->whlabel_bh_list->insert($p); } } else { echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit; } } } public function _del() { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',trim($id_arr,',')); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } //循环删除记录 foreach ($id_arr as $v) { $w = $this->whlabel_bh->read($v); if($w['state'] > 0) { // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit; } } foreach ($id_arr as $v) { $this->whlabel_bh->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true)); } } public function _deltransfer() { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',trim($id_arr,',')); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } if(count($id_arr) > 1) { echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit; } foreach ($id_arr as $v) { $this->whlabel_bh_transfer->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true)); } } public function _kc() { $post = $this->input->post(NULL, TRUE); if(isset($post['category'])) { $list = array(); $sku = $this->input->post('sku',true); $features = $this->input->post('features',true); $category = $this->input->post('category',true); $list['category'] = $category; $list['hairtype'] = $this->input->post('hairtype',true); $list['grade'] = $this->input->post('grade',true); $size = $this->input->post('size',true); $xzsku = $this->input->post('xzsku',true); $list['size'] = rtrim($size,','); $list['hairnumber'] = $this->input->post('hairnumber',true); $list['extension'] = $this->input->post('extension',true); if($category == 1297) { $list['sywignumber'] = $this->input->post('sywignumber',true); } if($category == 1702) { $list['syhairnumber'] = $this->input->post('syhairnumber',true); $list['syother'] = $this->input->post('syother',true); } if($category == 133) { $list['fittype'] = $this->input->post('fittype',true); $list['acother'] = $this->input->post('acother',true); } $list['color'] = $this->input->post('color',true); $list['lowe'] = $this->input->post('lowe',true); if($category == 127) { $list['type'] = $this->input->post('type',true); $list['headroad'] = $this->input->post('headroad',true); $list['density'] = $this->input->post('density',true); if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) { $list['lacesize'] = $this->input->post('lacesize',true); } $list['lacecolor'] = $this->input->post('lacecolor',true); $list['lacetypes'] = $this->input->post('lacetypes',true); } if($category == 128) { $list['lacetype'] = $this->input->post('lacetype',true); $list['haircap'] = $this->input->post('haircap',true); $list['density'] = $this->input->post('density',true); $list['lacecolor'] = $this->input->post('lacecolor',true); $list['lacetypes'] = $this->input->post('lacetypes',true); $list['wigother'] = $this->input->post('wigother',true); $list['wigother2'] = $this->input->post('wigother2',true); } if($category == 129) { $list['wide'] = $this->input->post('wide',true); } if($category == 131) { $list['gifttype'] = $this->input->post('gifttype',true); $list['giftother'] = $this->input->post('giftother',true); } if($category == 134) { $list['pieceweight'] = $this->input->post('pieceweight',true); } if($category == 1297) { $list['synthetictype'] = $this->input->post('synthetictype',true); $list['sywigother'] = $this->input->post('sywigother',true); } if($category == 130 || $category == 133 || $category == 1702) { $list['items'] = $this->input->post('items',true); $list['weight'] = $this->input->post('weight',true); } if($category == 1702) { $list['syhairther'] = $this->input->post('syhairther',true); } $shipremarks = ''; $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>''); foreach($list as $k=>$v) { if($v != 0) { $shipremarks .=$v.'-'; } } $shipremarks = '-'.$shipremarks; if($features) { $shipremarks = $features; } $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓 if($w > 0) { echo json_encode(array('msg'=>$w,'success'=>true));exit; } else { echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false)); } } } public function _excel() { $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'])) { $number = $this->input->post('number',true); $sku = $this->input->post('sku',true); $title = $this->input->post('title',true); $pm = $this->input->post('pm',true); $category = $this->input->post('category',true); $size = $this->input->post('size',true); $grade = $this->input->post('grade',true); $color = $this->input->post('color',true); $lowe = $this->input->post('lowe',true); $state = $this->input->post('state',true); $shipremarks = $this->input->post('shipremarks',true); $type = $this->input->post('type',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($number) { $where .= " and number like '%$number%'"; } if($type != '') { $where .= " and type = '$type'"; } if($sku) { $where .= " and sku like '%$sku%'"; } if($title) { $where .= " and title like '%$title%'"; } if($pm) { $where .= " and pm like '%$pm%'"; } if($category) { $where .= " and shipremarks like '%-$category-%'"; } if($size) { $where .= " and shipremarks like '%-$size-%'"; } if($grade) { $where .= " and shipremarks like '%-$grade-%'"; } if($color) { $where .= " and shipremarks like '%-$color-%'"; } if($lowe) { $where .= " and shipremarks like '%-$lowe-%'"; } if($state) { $where .= " and state = '$state'"; } if($shipremarks) { $where .= " and shipremarks like '%$shipremarks%'"; } $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; } //取得信息列表 /** $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 } **/ $warehouse = $this->warehouse->find_all(); $ck = array(); foreach ($warehouse as $v) { $ck[$v['id']] = $v['title']; } $list = array(); $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time'); foreach ($rows as $key=>$value) { if($value['state'] == 0) { $rows[$key]['state'] = "待生产/外购"; } else if($value['state'] == 1) { $rows[$key]['state'] = "生产/外购中"; } else if($value['state'] == 2) { $rows[$key]['state'] = "已完成"; } $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'"); $zc = ''; foreach ($zd as $v) { $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'
'; } $rows[$key]['id'] = $zc; $rows[$key]['dbnum'] = array_sum(array_column($zd,'num')); $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录'; $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']); } $title = '备货详情'; $titlename = "> > >
状态 标题 流水码 简码 英文 中文 备注 备货数量 库存数量 生产/外购数量 入库数量 调拨数量 调拨详情生产时间操作时间
"; $filename = $title.".xls"; $tail = ""; $this->excel->get_fz2($rows,$titlename,$filename,$tail); } } public function _xxpl() { /* 订单加入键值-j */ $dir = '/data/excel/'.date('Ymd',time()).'/'; $config['upload_path'] = '.'.$dir ; $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999); $config['allowed_types'] = 'xls|xlsx|csv'; $config['max_size'] = 10240; $this->load->library('upload', $config); $this->upload->initialize($config); if ($this->upload->do_upload('userfile')) { $full_path = $dir.$this->upload->data('file_name'); $fileName = '.' . $full_path; if (!file_exists($fileName)) { echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit; } else { require_once "./data/excel/PHPExcel/IOFactory.php"; @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件 @$phpExcel->setActiveSheetIndex(0);// 设置为默认表 $sheetCount = $phpExcel->getSheetCount();// 获取表格数量 $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数 $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数 ++$column;//如果列数大于26行 $list = array(); for ($i = 2; $i <= $row; $i++) // 行数循环 { $data = array(); for ($c = 'A'; $c != $column; $c++) // 列数循环 { $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue(); } $list[] = $data; } } $tc = $this->typeclass->find_all(); $typeclass = array(); foreach ($tc as $v) { $typeclass[$v['jm']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']); } $i = 0;$j = 0;$ed = array(); $classid = $this->classid->sku(); foreach($list as $val) { $pm = $classid; $jm = $classid; $title = '';$features = '';$cs = array(); $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'',46=>''); $val = $val[1]; if($val == '') { continue; } $cfjm = explode('-',trim($val,'-')); foreach($cfjm as $v) { if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']])) { if($typeclass[$v]['classid'] == '18')//头套 { $bmpx[16] = '0103'; } else if($typeclass[$v]['classid'] == '25' || $typeclass[$v]['classid'] == '26')//发块 { $bmpx[16] = '0102'; } else if($typeclass[$v]['classid'] == '33')//接发 { $bmpx[16] = '0104'; } else if($typeclass[$v]['classid'] == '35')//配件 { $bmpx[16] = '0105'; } else if($typeclass[$v]['classid'] == '41')//化纤头套 { $bmpx[16] = '0201'; } else if($typeclass[$v]['classid'] == '46')//化纤其它 { $bmpx[16] = '0202'; } else if($typeclass[$v]['classid'] == '49')//礼物 { $bmpx[16] = '99'; } else { $bmpx[16] = '0101';//发条 } if($typeclass[$v]['bm'] != '') { $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm']; } } if(isset($typeclass[$v]['title'])) { $title .= $typeclass[$v]['title']." "; } if($v != 0) { if(isset($pm[$typeclass[$v]['classid']])) { if($typeclass[$v]['title'] == '9A') { $pm[$typeclass[$v]['classid']] = '9A'; } else if($typeclass[$v]['title'] == '10A') { $pm[$typeclass[$v]['classid']] = '10A'; } else { $clzh = $typeclass[$v]['zh']; if(stripos($typeclass[$v]['zh'],'|') !== false) { $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|')); $clzh = $clzh[0]; } $pm[$typeclass[$v]['classid']] = $clzh; } } } } $jm = $val; $pm = array_filter($pm);//去除空值 $pm = implode(" ",$pm); $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' ')); $title = trim($title,' '); $bm = '03'.implode("",$bmpx); $chuanshu = $this->_cslh($jm,$title,$pm,$bm); if($chuanshu['x'] != 2) { $j++; $ed[] = array($chuanshu['msg'],$jm,$bm); } } if($j > 0) { $time = date('Ymd',time()); $title = '错误信息-'.$time; $titlename = "
错误详情
"; $tail = "\n"; $filename = $title.".xls"; @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail); $dir = '/data/excel/'.$time.'/'; $file_name = 'error_'.$time.rand(1000,9999); if(!is_dir('.'.$dir))mkdir('.'.$dir,0777); $myfile = fopen(".".$dir.$file_name.".xls", "w") or die(); fwrite($myfile,$ecl); fclose($myfile); $error = $dir.$file_name.'.xls'; echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit; } else { echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit; } } else { echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit; } } public function _cslh($jm,$title,$pm,$bm) { $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm)); if(isset($lh['Data'][0])) { if($lh['Data'][0]['m_isSucess'] != 1) { if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!') { return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit; } } } else { return array('msg'=>'料号错误','x'=>1);exit; } return array('x'=>2);exit; } public function _bbprint() { $time = time(); $post = $this->input->post(NULL); if(isset($post['d'])) { $order = 0;$time = time(); $d = $this->input->post('d',true); $n = $this->input->post('n',true);//打印数量 $data = $this->whlabel_bh->read($d); if(!$data) { echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit; } $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'"); $printnum = array_sum(array_column($printnum,'ts')); if($data['bhnum']-$printnum-$n < 0) { echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit; } $post['number'] = $data['number']; $post['orderinfo'] = $data['orderinfo']; $post['type'] = 0;//0生产 1外购 $post['features'] = $data['features']; $post['jm'] = $data['jm']; $post['bm'] = $data['bm']; $post['pm'] = $data['pm']; $post['sku'] = $data['sku']; $post['features'] = $data['features']; $post['number'] = $data['number']; $post['title'] = $data['title']; $post['printtime'] = $time; $post['ts'] = $n; $post['rk'] = "|15|";//默认订单中心 打印后直接入库 $post['rktime'] = "|".$time."|"; $post['ctime15'] = $time; $post['time'] = $time; $post['gtime'] = date('Yms',$time); $rows = array(); $label = substr($time,1).rand(10,99); $post['label'] = $label; $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['jm'],'n'=>$n); if($this->whlabel_bh_transfer->insert($post)) { echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit; } else { $this->db->trans_rollback(); echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit; } } } public function _operate() { $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $api = $this->input->post('api',true); $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $orderinfo = $this->input->post('number',true); $color = $this->input->post('color',true); $pm = $this->input->post('pm',true); $purchase = $this->input->post('purchase',true); $transfer = $this->input->post('transfer',true); $lx = $this->input->post('lx',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1"; if($transfer) { $ctime = 'ctime'.$transfer; $where .= " and $ctime > '$timetk' and $ctime < '$timetj'"; } else { $where .= " and time > '$timetk' and time < '$timetj'"; } if($orderinfo) { $where .= " and orderinfo like '%$orderinfo%'"; } if($transfer) { $where .= " and rk like '%|".$transfer."|%'"; } if($purchase) { $where .= " and purchase = '$purchase'"; } if($pm) { $where .= " and pm like '%$pm%'"; } if($color) { $where .= " and fpdata like '%-".$color."-%'"; } //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage); $transfer = $this->transfer->find_all(); $t = array();$ot = array(); foreach ($transfer as $v) { $t[$v['id']] = $v['title']; $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0; } //格式化数据 foreach ($info_list as $key=>$value) { $dd = $this->whlabel_bh_transfer->read($value['id']); $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']); $rk = explode('|',trim($dd['rk'],'|')); $rktime = explode('|',trim($dd['rktime'],'|')); $ck = explode('|',trim($dd['ck'],'|')); $cktime = explode('|',trim($dd['cktime'],'|')); $info_list[$key]['time'] = ''; for($i=0;$i 0 && $rktime[$i] + $ot[$rk[$i]] < time()) { $d = ''.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超
'; } else { $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'
'; } $info_list[$key]['time'] .= $d; if(isset($ck[$i]) && $ck[$i] != '') { $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'
'; } } $info_list[$key]['time'] = trim($info_list[$key]['time'],'
'); } $total = $this->whlabel_bh_transfer->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; } if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $pid = "";$tid="";$sid="";$wid=""; $purchase = explode('|',trim($user['purchase'],'|')); $transfer = explode('|',trim($user['transfer'],'|')); $warehouse = explode('|',trim($user['warehouse'],'|')); foreach ($purchase as $value) { $pid .= " id = ".$value." or"; } foreach ($transfer as $value) { $tid .= " id = ".$value." or"; } foreach ($warehouse as $value) { $wid .= " id = ".$value." or"; } } else { header('Location: /');exit; } $kx = '';$zjtab = ''; $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc"); $this->data['warehouse'] = $warehouse; $purchase = $this->purchase->find_all("yyid != ''"); $this->data['purchase'] = $purchase; $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or')); $this->data['transfer'] = $transfer; $this->data['vip'] = $user['vip']; $this->_Template('whlabel_bh_operate',$this->data); } public function _out() { $post = $this->input->post(NULL, TRUE); if(isset($post['label'])) { $time = time(); $label = $this->input->post('label',true); $cz = $this->input->post('cz',true); $transfer = $this->input->post('transfer',true); if(!$label) { echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit; } if(!$transfer) { echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit; } $lb = $this->whlabel_bh_transfer->get_label($label); if(!$lb) { echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit; } $lbrk = array_reverse(explode('|',trim($lb['rk'],'|'))); $lbck = array_reverse(explode('|',trim($lb['ck'],'|'))); if($cz == 1) { $lb['rk'] .= $transfer.'|'; $lb['rktime'] .= $time.'|'; if($lbrk[0] == $transfer) { echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit; } } else if($cz == 2) { $lb['ck'] .= $transfer.'|'; $lb['cktime'] .= $time.'|'; if($lbck[0] == $transfer) { echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit; } } $cztime = 'ctime'.$transfer; //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个 if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测 { echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit; } if($this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id'])) { echo json_encode(array('music'=>'1','success'=>true));exit; } else { echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit; } } } public function _bdbb() { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',trim($id_arr,',')); if(!$id_arr) { echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit; } //循环删除记录 foreach ($id_arr as $v) { $t = $this->whlabel_bh_transfer->read($v); if(!isset($t['number'])) { echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit; } $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>$t['ts']); } echo json_encode(array('rows'=>($rows),'success'=>true));exit; } } }