load->library('session'); $this->load->_model('Model_user','user'); $this->load->_model('Model_transfer','transfer'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_systemtransfer','systemtransfer'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_purchase','purchase'); $this->load->_model('Model_classid','classid'); $this->load->_model('Model_express','express'); $this->load->_model('Model_apiyy','apiyy'); $this->load->_model('Model_shop','shop'); } //定义方法的调用规则 获取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 == 'print') { $this->_print(); } else if($arg == 'number') { $this->_number(); } else if($arg == 'numberprint') { $this->_numberprint(); } else if($arg == 'operate') { $this->_operate(); } else if($arg == 'out') { $this->_out(); } else if($arg == 'excel') { $this->_excel(); } else if($arg == 'bdbb') { $this->_bdbb(); } else { $this->_index(); } } //管理 public function _index() { $t = array(); $typeclass = $this->typeclass->find_all(); foreach ($typeclass as $v) { $t[$v['id']] = $v['title']; } $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $type = $this->input->post('type',true); $where = "1=1 "; //数据排序 $order_str = "id asc"; if($type) { $where .= "and type = '$type'"; } if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->transfer->find_all($where,'id,title,orvertime',$order_str,$start,$perpage); $total = $this->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; } $this->_Template('transfer',$this->data); } //添加 public function _add() { $post = $this->input->post(NULL, TRUE); if(isset($post['title'])) { $title = $this->input->post('title',true); if($this->transfer->find_all("title = '$title'")) { echo json_encode(array('msg'=>'名称重复!','success'=>false));exit; } if($this->transfer->insert($post)) { echo json_encode(array('msg'=>'添加成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit; } } $this->_Template('transfer_add',$this->data); } //修改 public function _edit($arg_array) { $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $title = $this->input->post('title',true); if($this->transfer->find_all("title = '$title' and id != '".$id."'")) { echo json_encode(array('msg'=>'名称重复!','success'=>false));exit; } if($this->transfer->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]; $transfer = $this->transfer->read($arg_array); $this->data['transfer'] = $transfer; $this->_Template('transfer_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->transfer->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true)); } } public function _print() { if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $sid = "";$wid="";$wtype=""; $userwh = explode('|',trim($user['warehouse'],'|')); foreach ($userwh as $value) { $wid .= " id = ".$value." or"; $wtype .= " type = ".$value." or"; } } $post = $this->input->post(NULL, TRUE); $classid = $this->classid->sku(); $pm = $classid; $scsku = $classid; if(isset($post['category'])) { $list = array();$num = "";$title = "";$features = ""; $order = 0; $xbqnum = $this->input->post('xbqnum',true);//打印数量 $t = $this->input->post('t',true);//打印数量 if($xbqnum > 99) { echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit; } if($xbqnum < 1) { echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit; } $post['purchase'] = $this->input->post('purchase',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); } 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); } if($category == 1702) { $list['syhairther'] = $this->input->post('syhairther',true); } foreach($list as $k=>$v) { if($v != 0) { $num .=$v; $features .=$v.'-'; $post[$k] = $v; $typeclass = $this->typeclass->read($v); if(isset($pm[$typeclass['classid']])) { $pm[$typeclass['classid']] = $typeclass['zh']; } $scsku[$typeclass['classid']] = $typeclass['bqsku']; if($k != 'size') { $title .= $typeclass['title']." "; } } } $typeclass = $this->typeclass->read($list['size']); $title .= $typeclass['title']; $time = time(); $post['printtime'] = $time; $post['title'] = rtrim($title,' '); $post['number'] = $num; $post['features'] = '-'.$features; $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features); $featurespp = explode('-',trim($featurespp,'-')); if(isset($featurespp[5])) { $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5]; } else { $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4]; } $post['time'] = $time;//操作时间 $scsku = implode("-",$scsku); $zh = implode(" ",$pm); $zh = str_replace('自然色 ','',trim($zh,' ')); $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh); $post['shipremarks'] = $zh; $scsku = str_replace('- ','-',trim($scsku,'-')); $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku); $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku; $post['sku'] = $bqsku; $post['rk'] = "|1|";//默认配货 打印后直接入库 $post['rktime'] = "|".$time."|"; $rows = array(); $this->db->trans_begin(); for($i=0;$i<$xbqnum;$i++) { $label = substr($time,1)*100; $post['label'] = $label+$i; $rows[] = array('num'=>$post['label'],'number'=>'','shipremarks'=>$zh,'ex'=>'','t'=>$t,'time'=>'布标打印时间:'.date('Y-m-d H:i:s',$time),'s'=>'('.($i+1).'/'.$xbqnum.')'); $this->systemtransfer->insert($post); } if ($this->db->trans_status() === TRUE) { $this->db->trans_commit(); echo json_encode(array('rows'=>($rows),'success'=>true));exit; } else { $this->db->trans_rollback(); echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit; } } $purchase = $this->purchase->find_all("yyid != ''"); $this->data['purchase'] = $purchase; $this->_Template('transfer_print',$this->data); } public function _number() { if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $pid = "";$tid="";$sid="";$wid=""; $purchase = explode('|',trim($user['purchase'],'|')); $transfer = explode('|',trim($user['transfer'],'|')); foreach ($purchase as $value) { $pid .= " id = ".$value." or"; } foreach ($transfer as $value) { $tid .= " id = ".$value." or"; } } else { header('Location: /');exit; } $post = $this->input->post(NULL, TRUE); if(isset($post['number'])) { $number = $this->input->post('number',true); $type = $this->input->post('type',true); $xbqnum = $this->input->post('xbqnum',true);//打印数量 $purchase = $this->input->post('purchase',true); $f = 'fullorder'; $y = $this->fullorder->get_number($number); if(!$y) { $f = 'fullordersmt'; $y = $this->fullordersmt->get_number($number); if(!$y) { $f = 'fullordertt'; $y = $this->fullordertt->get_number($number); if(!$y) { echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit; } } } if($y['librarytime'] > 0) { echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit; } $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;$typeclass = array(); $classid = $this->classid->sku(); $tc = $this->typeclass->find_all(); foreach($tc as $v) { $typeclass[$v['id']] = $v; } $bm = '03'; $fpdata = explode(';',trim($y['fpdata'],';')); $whlabelsc = explode('|',trim($y['whlabel'],'|')); foreach($fpdata as $key=>$val) { $pm = $classid; $jm = $classid; $sku = $classid; $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>''); $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val); $jvnr = explode('|',trim($features,'|')); if(stripos($jvnr[0],',') !== false) { $ft = explode(',',$jvnr[0]); $features = explode('-',trim($ft[1],'-')); array_splice($features,2,0,$ft[0]); } else { $features = explode('-',trim($jvnr[0],'-')); } $title = $jvnr[1]; foreach($features 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) { $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);//去除空值 $zh = implode(" ",$pm); $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' ')); $features = implode("-",$features); $cp[] = array('ordernumber'=>$number,'title'=>$title,'sku'=>$sku,'jm'=>$jm,'zh'=>$zh,'n'=>$jvnr[2],'b'=>$y['shipremarks'],'data'=>json_encode(array('ordernumber'=>$number,'features'=>$features,'number'=>$number,'title'=>$title,'jm'=>$jm,'sku'=>$sku,'pm'=>$zh,'bm'=>$bm.implode("",$bmpx)))); } echo json_encode(array('rows'=>$cp,'success'=>true));exit; } $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->_Template('transfer_number',$this->data); } public function _numberprint() { $time = time(); $post = $this->input->post(NULL); $classid = $this->classid->sku(); $pm = $classid; $scsku = $classid; if(isset($post['data'])) { $data = json_decode($post['data'],true); $f = 'fullorder'; $y = $this->fullorder->get_number($data['ordernumber']); if(!$y) { $f = 'fullordersmt'; $y = $this->fullordersmt->get_number($data['ordernumber']); if(!$y) { $f = 'fullordertt'; $y = $this->fullordertt->get_number($data['ordernumber']); if(!$y) { echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit; } } } if($y['printtime'] == 0) { echo json_encode(array('msg'=>'此单已重置,请询问梦体','success'=>false));exit; } $order = 0;$time = time(); $xbqnum = $this->input->post('n',true);//打印数量 if($xbqnum > 99) { echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit; } if($xbqnum < 1) { echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit; } $transfer = $this->input->post('transfer',true); $post['type'] = $this->input->post('type',true); $post['shipremarks'] = $this->input->post('b',true); $zps = $this->input->post('zps',true); $post['purchase'] = $this->input->post('purchase',true);//供应商 $post['time'] = $time;//操作时间 $post['jm'] = $data['jm']; $post['bm'] = $data['bm']; $post['pm'] = $data['pm']; $post['features'] = $data['features']; $post['number'] = $data['number']; $post['title'] = $data['title']; $post['sku'] = $data['sku']; $post['printtime'] = $y['printtime']; $post['rk'] = "|12|";//默认订单中心 打印后直接入库 $post['ck'] = "|12|"; $post['rktime'] = "|".$time."|"; $post['cktime'] = $post['rktime']; $post['ctime12'] = $time; $express = $this->express->read($y['express']); $rows = array();$t=''; $this->db->trans_begin(); $post['xbqnum'] = $xbqnum; $kh = $this->shop->read($y['shop']); $yy = $this->apiyy->_peihuo($post,$kh['yyid'],$y['number'],$post['xbqnum']); if($yy['c'] == 0) { $post['scapi'] = '99'; $post['scid'] = $yy['scid']; if(!$post['purchase']) { $post['purchase'] = ''; } $mqsl = $this->systemtransfer->find_count("number = '".$data['number']."'"); for($i=0;$i<$xbqnum;$i++) { if($post['zps']) { if($post['zps'] > 0) { $t = '总量:'.($mqsl+$i+1).'/'.$zps; } } $label = substr($time,1)*100; $post['label'] = $label+$i; $rows[] = array('num'=>$post['label'],'number'=>$post['number'],'shipremarks'=>$post['shipremarks'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$post['printtime']),'gtime'=>date('YmdH',time()),'s'=>'('.($i+1).'/'.$xbqnum.')','t'=>$t); $this->systemtransfer->insert($post); } } else { $this->db->trans_rollback(); echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit; } if($this->db->trans_status() === TRUE) { $this->db->trans_commit(); echo json_encode(array('rows'=>($rows),'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); $number = $this->input->post('number',true); $color = $this->input->post('color',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($number) { $where .= " and number = '$number'"; } if($transfer) { $where .= " and rk like '%|".$transfer."|%'"; } if($purchase) { $where .= " and purchase = '$purchase'"; } if($color) { $where .= " and fpdata like '%-".$color."-%'"; } if($lx) { if($lx == 1) { $where .= " and ordernumber = ''"; } else { $where .= " and ordernumber != ''"; } } //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } //取得信息列表 $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage); $transfer = $this->transfer->find_all(); $t = 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->systemtransfer->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->systemtransfer->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('transfer_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->systemtransfer->get_label($label); if(!$lb) { echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit; } if($lb['number']!='') { $nu = $this->fullorder->get_number($lb['number']); if(!$nu) { $nu = $this->fullordersmt->get_number($lb['number']); if(!$nu) { $nu = $this->fullordertt->get_number($lb['number']); } } if($nu['state'] == '214' || $nu['state'] == '217') { echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit; } } /** if($cz == 1 && stripos($lb['rk'],'|'.$transfer.'|') !== false) { echo json_encode(array('msg'=>'此条码已有入库操作!','success'=>false));exit; } if($cz == 2 && stripos($lb['ck'],'|'.$transfer.'|') !== false) { echo json_encode(array('msg'=>'此条码已有出库操作!','success'=>false));exit; } if($cz == 2 && stripos($lb['rk'],'|'.$transfer.'|') === false) { echo json_encode(array('msg'=>'此条码还未入库!','success'=>false));exit; } if($lb['printtime'] > 1705939200) { if($cz == 1 && $lb['rk'] != $lb['ck'] && stripos($lb['rk'],'|'.$transfer.'|') === false && stripos($lb['ck'],'|'.$transfer.'|') === false)//判断是否没走完流程就拿到下一步奏 { 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 == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1) { if($lb['type'] == 0) { $s = $this->shop->read($nu['shop']); $lb['kh'] = $s['yyid']; $lb['ts'] = 1; $rk = $this->apiyy->_newrk($lb); if($rk['c'] == 0) { if($this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$rk['scid'].time(),$cztime=>$time),$lb['id'])) { if($nu['state'] == '216') { echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit; } else { echo json_encode(array('music'=>'1','success'=>true));exit; } } else { echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit; } } else { if(stripos($rk['error'],'DocNo') !== false) { $rk['error'] = '未找到对应的生产订单 '.$lb['scid']; } $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']); echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit; } } else { $scid = explode('~',$lb['scid']); $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']); $rk = $this->apiyy->get_bzsh($rkdata); if(isset($rk['Data'][0])) { if($rk['Data'][0]['IsSucess'] == 1) { if($this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$lb['scid'].'~'.$rk['Data'][0]['Code'],$cztime=>$time),$lb['id'])) { if($nu['state'] == '216') { echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit; } else { echo json_encode(array('music'=>'1','success'=>true));exit; } } else { echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit; } } else { echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit; } } else { echo json_encode(array('msg'=>$rk,'success'=>false));exit; } } } 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->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id'])) { if($nu['state'] == '216') { echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit; } else { 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->systemtransfer->read($v); if(!isset($t['number'])) { echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit; } $y = $this->fullorder->get_number($t['number']); if(!$y) { $y = $this->fullordersmt->get_number($t['number']); if(!$y) { $y = $this->fullordertt->get_number($t['number']); if(!$y) { echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit; } } } $express = $this->express->read($y['express']); $rows[] = array('num'=>$t['label'],'number'=>$t['number'],'shipremarks'=>$t['shipremarks'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$t['printtime']),'gtime'=>date('YmdH',time()),'s'=>'1/1','t'=>"补打"); } echo json_encode(array('rows'=>($rows),'success'=>true));exit; } } public function _excel() { if(isset($_GET['fexcel'])) { $tc = array();$zh = array(); $typeclass = $this->typeclass->find_all(); foreach ($typeclass as $v) { $tc[$v['id']] = $v; } $number = $this->input->get('number',true); $color = $this->input->get('color',true); $gs = $this->input->get('gs',true); $transfer = $this->input->get('transfer',true); $timetk = $this->input->get('timetk',true); $timetj = $this->input->get('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1"; if($transfer) { if($transfer == 12) { $where .= " and printtime > '$timetk' and printtime < '$timetj'"; } else { $ctime = 'ctime'.$transfer; $where .= " and $ctime > '$timetk' and $ctime < '$timetj'"; } } else { $where .= " and time > '$timetk' and time < '$timetj'"; } if($transfer) { $where .= " and rk like '%|$transfer|%'"; } if($number) { $where .= " and number = '$number'"; } if($gs) { $where .= " and gs = '$gs'"; } if($color) { $where .= " and features like '%$color%'"; } $data = array(); $datafy = array(); $j = 0; $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime'); $lzbm = $this->transfer->find_all(); foreach ($info_list as $key=>$value) { $dj = '';$ys = '';$cc = '';$hx = '';$md = ''; $d = $this->systemtransfer->read($value['id']); $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']); $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$d['shipremarks']); $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']); $cp = explode('-',trim($d['features'],'-')); $rk = explode('|',trim($d['rk'],'|')); $rktime = explode('|',trim($d['rktime'],'|')); foreach ($cp as $v) { if(isset($tc[$v])) { if($tc[$v]['classid'] == 13) { $dj = $tc[$v]['title']; } else if($tc[$v]['classid'] == 8) { $ys = $tc[$v]['title']; } else if($tc[$v]['classid'] == 14) { $cc = $tc[$v]['title']; } else if($tc[$v]['classid'] == 15) { $hx = $tc[$v]['title']; } else if($tc[$v]['classid'] == 10) { $md = $tc[$v]['title']; } } } $rt = array(); foreach ($rk as $k=>$v) { $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]); } $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md)); foreach ($lzbm as $v) { if(isset($rt[count($fpdata[0])])) { $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])]; } else { $fpdata[0][count($fpdata[0])] = ''; } } $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度 unset($info_list[$key]['id']); } //echo "
";print_r($info_list);exit;
			$lzxq = '';
			foreach ($lzbm as $v)
		    {
				$lzxq .= ''.$v['title'].'';
			}
			$title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表'; 
            $titlename = "
订单编号 品名 简码 备注 打印时间 ".$lzxq."
订单产品信息货物流转时间
产品名称 尺寸 等级 颜色 花型 密度
"; $filename = $title.".xls"; $tail = "\n"; $this->excel->get_fz($info_list,$titlename,$filename,$tail,1); } } }