| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471 | <?php defined('BASEPATH') OR exit('No direct script access allowed');class Zzququeu9 extends Start_Controller {    public function __construct(){        parent::__construct();        $this->load->library('session');        $this->load->_model('Model_zzquque_u9','zzquque_u9');        $this->load->_model("Model_logic_order","logic_order");        $this->load->_model("Model_logic_u9xgsd","logic_u9xgsd");        $this->load->_model("Model_logic_u9ztsd","logic_u9ztsd");        $this->load->_model('Model_zzququeu9_logs','zzququeu9_logs');        $this->load->_model("Model_logic_u9action","logic_u9action");        $this->load->_model("Model_whlabel_bh_transfer","whlabel_bh_transfer");    }    public function _remap($arg,$arg_array)    {		if($arg == 'dc')//调出单          {               $this->_dc($arg_array);          }          elseif($arg == 'cg')//采购          {               $this->_cg($arg_array);          }          elseif($arg == 'xs')//销售单          {               $this->_xs($arg_array);          }          elseif($arg == 'bzch')//标准出货          {               $this->_bzch($arg_array);          }          elseif($arg == 'bzsh')//标准收货          {               $this->_bzsh($arg_array);          }          elseif($arg == 'dr')//调入单          {               $this->_dr($arg_array);          }          elseif($arg == 'xs_two')//调入单          {               $this->_xs_two($arg_array);          }          elseif($arg == 'dczt')//在途的调出单          {               $this->_dczt($arg_array);          }          elseif($arg == 'add'){               $this->_add();          }          elseif($arg == 'excel'){               $this->_excel();          }          elseif($arg == 'mcindex')          {               $this->_mcindex();          }          elseif($arg == 'scdel')//删除          {               $this->_del($arg_array);          }          elseif($arg == 'waixiao')//编辑          {               $this->_waixiao($arg_array);          }          elseif($arg == 'wxcprk')//外销成品入库          {               $this->_wxcprk($arg_array);          }          elseif($arg == 'wxcprksh'){               $this->_wxcprksh($arg_array);          }          elseif($arg == 'wxxs'){               $this->_wxxs($arg_array);          }elseif($arg == 'gcbh_index'){               $this->_gcbh_index();          }elseif($arg == 'gcbhexcel'){               $this->_gcbhexcel();          }elseif($arg == 'bhcprk'){               $this->_bhcprk($arg_array);          }elseif($arg == 'cpkbh_index'){               $this->_cpkbh_index();          }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);						$timetk = $this->input->post('timetk',true);//订单开始时间			$timetj = $this->input->post('timetj',true);//订单结束时间			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);               $status = $this->input->post('status',true);			$order_no = $this->input->post('order_no',true);               $where='type = 10 ';    			if($order_no){    			    $where .= " and order_no = '".$order_no."' ";    			}    			 if($status){                    if($status == 1){                         $where .= " and dc_status = 0 ";                    }elseif($status == 2){                         $where .= " and dc_status = -1  ";                    }elseif($status == 3){                         $where .= " and dc_status = -2  ";                    }elseif($status == 4){                         $where .= " and dc_status = -3  ";                    }elseif($status == 5){                         $where .= " and dc_status < 3  ";                    }               }               if($timetk && $timetj){                   $where .= " and create_time  > ".$timetk." and create_time  < ".$timetj." ";               }              			if(empty($page))               {                    $start = 0;                    $perpage = 10;               }               else               {                    $start = ($page - 1)*$perpage;               }			               $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);               $type_list = $this->zzquque_u9->getType();               $list = [];               foreach($info_list as $k=>$v){                    $dc_no = "";                    if($v['dc_status'] == 0){                         $dc_no = "<span  data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";                    }elseif($v['dc_status'] == -1){                        $tmp_str = "异常信息";                         $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);                         if(isset($error[0])){                                if($error[0]['apply_api']=='lpck'){                                     $ret_data = json_decode($error[0]['ret_data'],true);                                     $apply_data = json_decode($error[0]['apply_data'],true);                                     if(isset($ret_data["ResMsg"])){                                           if(empty($apply_data['0'])){                                                $tmp_str = $ret_data["ResMsg"];                                           }else{                                                $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";                                           }                                                                                }else{                                           $tmp_str = "料品同步失败";                                     }                                 }else{                                              $ret_data = json_decode($error[0]['ret_data'],true);                                      if(isset($ret_data[0]["ResMsg"])){                                            $tmp_str = $ret_data[0]["ResMsg"];                                      }elseif(isset($ret_data['msg'])){                                           $tmp_str = $ret_data['msg'];                                      }else{                                            $tmp_str = "料品同步失败";                                      }                                 }                         }                                                 $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';                    }                    if(!empty($v['dc_no'])){                         $dc_no = $v['dc_no']."<br/>".$dc_no;                    }                    $cg_no = "";                    if($v['cg_status'] == 0){                         $cg_no .= "<span  data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>";                    }elseif($v['cg_status'] == 1){                         $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>";                    }elseif($v['cg_status'] == -1){                         $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="采购单创建失败"></i><p>';                    }elseif($v['cg_status'] == 2){                         $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>";                    }elseif($v['cg_status'] == -2){                         $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="采购单提交失败"></i><p>';                    }elseif($v['cg_status'] == -3){                         $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="采购单审核失败"></i><p>';                    }                    if(!empty($v['cg_no'])){                         $cg_no = $v['cg_no']."<br/>".$cg_no;                    }                    $xs_no = "";                    if($v['xs_status'] == 0){                         $xs_no .= "<span  data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";                    }elseif($v['xs_status'] == 1){                         $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";                    }elseif($v['xs_status'] == -1){                         $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="销售单创建失败"></i><p>';                    }elseif($v['xs_status'] == 2){                         $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";                    }elseif($v['xs_status'] == -2){                         $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="销售单提交失败"></i><p>';                    }elseif($v['xs_status'] == -3){                         $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="销售单审核失败"></i><p>';                    }                    if(!empty($v['xs_no'])){                         $xs_no = $v['xs_no']."<br/>".$xs_no;                    }                    $xs_two_no ='';                    if($v['xs_two_status'] == 0){                         $xs_two_no .= "<span  data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";                    }elseif($v['xs_two_status'] == 1){                         $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";                    }elseif($v['xs_two_status'] == -1){                         $xs_two_no .= "<span data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }elseif($v['xs_two_status'] == 2){                         $xs_two_no .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";                    }elseif($v['xs_two_status'] == -2){                         $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }elseif($v['xs_two_status'] == -3){                         $xs_two_no  .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }                    if(!empty($v['xs_two_no'])){                         $xs_two_no = $v['xs_two_no']."<br/>".$xs_two_no;                    }                                        $bzch_no ="";                    if($v['bzch_status'] == 0){                         $bzch_no  .= "<span  data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>";                    }elseif($v['bzch_status'] == 1){                         $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>";                    }elseif($v['bzch_status'] == -1){                         $bzch_no .= "<span data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }elseif($v['bzch_status'] == 2){                         $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>";                    }elseif($v['bzch_status'] == -2){                         $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }elseif($v['bzch_status'] == -3){                         $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }                    //$bzsh_no =empty($v['bzsh_no'])?"":$v['bzsh_no'];                    if(!empty($v['bzch_no'])){                         $bzch_no = $v['bzch_no']."<br/>".$bzch_no;                    }                    $dr_no = "";                    if($v['dr_status'] == 0){                         $dr_no .= "<span  data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>";                    }elseif($v['dr_status'] == 1){                         $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>";                    }elseif($v['dr_status'] == -1){                         $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }elseif($v['dr_status'] == 2){                         $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>";                    }elseif($v['dr_status'] == -2){                         $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }elseif($v['dr_status'] == -3){                         $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="123"></i><p>';                    }                    if(!empty($v['dr_no'])){                         $dr_no = $v['dr_no']."<br/>".$dr_no;                    }                    $list[] = [                         'id'=>$v['id'],                         'order_no'=>$v['order_no'],                         'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",                         'dc_no'=> $dc_no,                         'cg_no'=>$cg_no,                         'xs_no'=>$xs_no,                         'dr_no'=>$dr_no,                         'xs_two_no'=>$xs_two_no,                         'bzch_no'=>$bzch_no,                         //'bzsh_no'=>$bzsh_no,                                                 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),                         'update_time'=>date("Y-m-d H:i:s",$v['update_time']),                         'operate'=>($v['dc_status'] == 3)?"": "<span data-action='dr' data-id='".$v['id']."' onclick='doDel(this)' style='background-color:red'>删除</span>"                    ];               }             						$total = $this->zzquque_u9->find_count($where);			$pagenum = ceil($total/$perpage);			$over = $total-($start+$perpage);			$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));			echo json_encode($rows);exit;					}		$this->_Template('zzququeu9',$this->data);    }    public function _dc($arg_array){      $process= $arg_array[0];      $id = $arg_array[1];      $info = $this->zzquque_u9->read($id);           if($process == 1){          if(!in_array($info['dc_status'],[0,-1])){               echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));               exit;          }          $r = $this->logic_u9xgsd->createDc($info);          if($r['code'] == 1){               echo json_encode(array('msg'=>'创建调出单成功','success'=>true));               exit;          }else{               echo json_encode(array('msg'=>$r['msg'],'success'=>false));               exit;          }      }else if($process == 2){          if(!in_array($info['dc_status'],[1,-2])){               echo json_encode(array('msg'=>'当前状态不符合提交调出单的条件','success'=>false));               exit;          }          $r = $this->logic_u9xgsd->subDc($info);          if($r['code'] == 1){               echo json_encode(array('msg'=>'提交调出单成功','success'=>true));               exit;          }else{               echo json_encode(array('msg'=>$r['msg'],'success'=>false));               exit;          }      }else if($process == 3){          if(!in_array($info['dc_status'],[2,-3])){               echo json_encode(array('msg'=>'当前状态不符合审核调出单的条件','success'=>false));               exit;          }          $r = $this->logic_u9xgsd->shDc($info);          if($r['code'] == 1){               echo json_encode(array('msg'=>'审核调出单成功','success'=>true));               exit;          }else{               echo json_encode(array('msg'=>$r['msg'],'success'=>false));               exit;          }      }else{          echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));          exit;      }         }    public function _cg($arg_array){     $process= $arg_array[0];     $id = $arg_array[1];     $info = $this->zzquque_u9->read($id);     if($info['dc_status'] != 3){          echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));          exit;     }     if($process == 1){         if(!in_array($info['cg_status'],[0,-1])){              echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->createCg($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'创建采购单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 2){         if(!in_array($info['cg_status'],[1,-2])){              echo json_encode(array('msg'=>'当前状态不符合提交采购单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->subCg($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'提交采购单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 3){         if(!in_array($info['cg_status'],[2,-3])){              echo json_encode(array('msg'=>'当前状态不符合审核采购单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->shCg($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'审核采购单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else{         echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));         exit;     }    }    public function _xs($arg_array){     $process= $arg_array[0];     $id = $arg_array[1];     $info = $this->zzquque_u9->read($id);     if($info['dc_status'] != 3){          echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));          exit;     }     if($process == 1){         if(!in_array($info['xs_status'],[0,-1])){              echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->createXs($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'创建销售单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 2){         if(!in_array($info['xs_status'],[1,-2])){              echo json_encode(array('msg'=>'当前状态不符合提交销售单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->subXs($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'提交销售单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 3){         if(!in_array($info['xs_status'],[2,-3])){              echo json_encode(array('msg'=>'当前状态不符合审核销售单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->shXs($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'审核销售单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else{         echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));         exit;     }        }       public function _dr($arg_array){     $process= $arg_array[0];     $id = $arg_array[1];     $info = $this->zzquque_u9->read($id);     if($info['dc_status'] != 3){          echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));          exit;     }     if($process == 1){         if(!in_array($info['dr_status'],[0,-1])){              echo json_encode(array('msg'=>'当前状态不符合查询调入单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->createDr($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'查询调入单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 2){         if(!in_array($info['dr_status'],[1,-2])){              echo json_encode(array('msg'=>'当前状态不符合提交调入单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->subDr($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'提交调入单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 3){         if(!in_array($info['dr_status'],[2,-3])){              echo json_encode(array('msg'=>'当前状态不符合审核调入单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->shDr($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'审核调入单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else{         echo json_encode(array('msg'=>'当前状态不符合创建调入单的条件','success'=>false));         exit;     }        }    public function _xs_two($arg_array){     $process= $arg_array[0];     $id = $arg_array[1];     $info = $this->zzquque_u9->read($id);     if($info['dc_status'] != 3){          echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));          exit;     }     if($process == 1){         if(!in_array($info['xs_two_status'],[0,-1])){              echo json_encode(array('msg'=>'当前状态不符合查询香港销售单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->createXsTwo($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'创建香港销售单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 2){         if(!in_array($info['xs_two_status'],[1,-2])){              echo json_encode(array('msg'=>'当前状态不符合提交香港销售单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->subXsTwo($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'提交香港销售单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 3){         if(!in_array($info['xs_two_status'],[2,-3])){              echo json_encode(array('msg'=>'当前状态不符合审核香港销售单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->shXsTwo($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'审核香港销售单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else{         echo json_encode(array('msg'=>'当前状态不符合创建香港销售单的条件','success'=>false));         exit;     }      }    public function _bzch($arg_array){     $process= $arg_array[0];     $id = $arg_array[1];     $info = $this->zzquque_u9->read($id);     if($info['dc_status'] != 3){          echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));          exit;     }     if($info['xs_two_status'] != 3){          echo json_encode(array('msg'=>'香港销售单未审核不能执行后续操作','success'=>false));          exit;     }     if($process == 1){         if(!in_array($info['bzsh_status'],[0,-1])){              echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));              exit;         }         $r = $this->logic_u9xgsd->createCh($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'创建标准收货单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else if($process == 2){                  $r = $this->logic_u9xgsd->subAndShCh($info);         if($r['code'] == 1){              echo json_encode(array('msg'=>'审核标准收货单成功','success'=>true));              exit;         }else{              echo json_encode(array('msg'=>$r['msg'],'success'=>false));              exit;         }     }else{         echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));         exit;     }        }    public function _bzsh($arg_array){        }    public function  _add(){       $order_no  = $this->input->post('order_no',true);       if(empty($order_no)){          echo json_encode(['msg'=>'请输入要添加的订单编码!','success'=>false]);exit;          }        $info = $this->logic_order->getInfo("number = '" .$order_no."'");        if(empty($info)){           echo json_encode(['msg'=>'订单不存在!请仔细核对单号','success'=>false]);exit;         }        $num = $this->zzquque_u9->find_all("order_no = '".$info['number']."'");        if(empty($num)){             $this->zzquque_u9->insert([                'platform'=>$info['lv_platform'],                'warehouse'=>$info['type'],                'type'=>10,                'order_no'=>$info['number'],                'create_time'=>time(),                'update_time'=>time(),            ]);            echo json_encode(['msg'=>'添加成功','success'=>true]);exit;         }else{            echo json_encode(['msg'=>'订单不允许重复添加','success'=>false]);exit;         }                   }    public function _excel(){        $params = $this->input->get();        $where = " type = 10 ";        if(!empty($params['order_no'])){          $where .= " and  order_no =  '".$params['order_no']."' ";        }         if(!empty($params['timetk'])){          $where .= " and create_time >  ".strtotime($params['timetk'])." ";        }               if(!empty($params['timetj'])){          $where .= "and create_time <  ".strtotime($params['timetj'])." ";        }            if(!empty($params['status'])){                $status = $params['status'];               if($status == 1){                    $where .= " and dc_status = 0 ";               }elseif($status == 2){                    $where .= " and dc_status = -1  ";               }elseif($status == 3){                    $where .= " and dc_status = -2  ";               }elseif($status == 4){                    $where .= " and dc_status = -3  ";               }elseif($status == 5){                    $where .= " and dc_status < 3  ";               }        }                  $info_list = $this->zzquque_u9->find_all($where,'*','id desc');                    $type_list = $this->zzquque_u9->getType();          $list = [];          foreach($info_list as $k=>$v){               $dc_no = $v['dc_no'];               $error_str = "";               $error_json ="";               if($v['dc_status'] == -1){                    $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);                    $error_json = $error[0]['ret_data'];                    if($error[0]['apply_api']=='lpck'){                         $ret_data = json_decode($error[0]['ret_data'],true);                         $apply_data = json_decode($error[0]['apply_data'],true);                         if(isset($ret_data["ResMsg"])){                              if(empty($apply_data['0'])){                                   $error_str = $ret_data["ResMsg"];                              }else{                                   $error_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";                              }                                                       }else{                              $error_str = "料品同步失败";                         }                    }else{                         $ret_data = json_decode($error[0]['ret_data'],true);                         if(isset($ret_data[0]["ResMsg"])){                              $error_str = $ret_data[0]["ResMsg"];                         }elseif(isset($ret_data['msg'])){                              $error_str = $ret_data['msg'];                         }else{                              $error_str = "料品同步失败";                         }                    }                                   }                                                          $list[] = [                    'id'=>$v['id'],                    'order_no'=>$v['order_no'],                    'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",                    'dc_no'=> $dc_no,                    'error'=>$error_str,                    'error_json'=>$error_json,                    //'bzsh_no'=>$bzsh_no,                                        'create_time'=>date("Y-m-d H:i:s",$v['create_time']),               ];          }        $filename = date("Y-m-d")."u9小单导出.xls";		$str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">        <head>        <!--[if gte mso 9]><xml>        <x:ExcelWorkbook>        <x:ExcelWorksheets>        <x:ExcelWorksheet>        <x:Name>EXCEL</x:Name>        <x:WorksheetOptions>        <x:Print>        <x:ValidPrinterInfo />        </x:Print>        </x:WorksheetOptions>        </x:ExcelWorksheet>        </x:ExcelWorksheets>        </x:ExcelWorkbook>        </xml>        <![endif]-->        </head><body>";		$str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>"; 		$str .= "<tr><td>id</td><td>订单号</td><td>类型</td><td>调出单号</td><td>创建时间</td><td>错误信息</td><td>错误json</td></tr>";		foreach ($list as $key=>$value) 		{ 					    $str .= "<tr>";			$str .= "<td>". $value['id']. "</td>";			$str .= "<td>". $value['order_no']. "</td>";				$str .= "<td>". $value['type']. "</td>";				$str .= "<td>". $value['dc_no']. "</td>";			 $str .= "<td>". $value['create_time']. "</td>";			$str .= "<td>". $value['error']. "</td>";			$str .= "<td>". $value['error_json']. "</td>";              			$str .= "</tr>";		}		$str .= "</table></body></html>"; 		header( "Content-Type: application/vnd.ms-excel; name='excel'" ); 		header( "Content-type: application/octet-stream" ); 		header( "Content-Disposition: attachment; filename=".$filename ); 		header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); 		header( "Pragma: no-cache" ); 		header( "Expires: 0" ); 		exit($str);     }    public function _mcindex(){     $post = $this->input->post(NULL, TRUE);     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);//订单结束时间          $timetk = strtotime($timetk);          $timetj = strtotime($timetj);          $order_no = $this->input->post('order_no',true);          $type = $this->input->post('type',true);          if($type == 1){               $where=' ( type = 1)';          }elseif($type == 2){               $where=' ( type = 2)';          }else{               $where=' ( type = 1 or type = 2)';          }                    if($order_no){              $where .= " and order_no = '".$order_no."' ";          }          if($timetk && $timetj){              $where .= " and create_time  > ".$timetk." and create_time  < ".$timetj." ";          }          if(empty($page))          {               $start = 0;               $perpage = 1;          }          else          {               $start = ($page - 1)*$perpage;          }                    $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);          $type_list = $this->zzquque_u9->getType();          $list = [];          foreach($info_list as $k=>$v){               $dc_no = "";               if($v['dc_status'] == 0){                    if($v['type'] == 1){                         $dc_no = "<span  data-action='dczt' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";                    }                                  }elseif($v['dc_status'] == -1){                    $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);                    if($error[0]['apply_api']=='lpck'){                        $ret_data = json_decode($error[0]['ret_data'],true);                        $apply_data = json_decode($error[0]['apply_data'],true);                        if(isset($ret_data["ResMsg"])){                              if(empty($apply_data['0'])){                                   $tmp_str = $ret_data["ResMsg"];                              }else{                                   $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";                              }                                                      }else{                              $tmp_str = "料品同步失败";                        }                    }else{                         $tmp_str= "";                         $ret_data = json_decode($error[0]['ret_data'],true);                         if(isset($ret_data[0]["ResMsg"])){                               $tmp_str = $ret_data[0]["ResMsg"];                         }elseif(isset($ret_data['msg'])){                              $tmp_str = $ret_data['msg'];                         }elseif(isset($ret_data['Data'])){                              foreach($ret_data['Data'] as $iit){                                   if(!$iit['IsSucess']){                                        $tmp_str .= $iit['ErrorMsg']."<br>";                                   }                                                                 }                                                       }else{                               $tmp_str = "料品同步失败";                         }                    }                    $dc_no = "<span data-action='dczt' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';               }               if(!empty($v['dc_no'])){                    if($v['type'] == 1){                         $dc_no = $v['dc_no']."【销售组织】"."<br/>".$dc_no;                    }else{                         $dc_no = $v['dc_no']."【香港组织】"."<br/>".$dc_no;                    }               }               $cg_no = "";               if($v['type'] == 1){                    if($v['cg_status'] == 1){                         $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."'>采购单提交异常</span>";                    }elseif($v['cg_status'] == -1){                         $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' >创建采购单失败</span>";                    }elseif($v['cg_status'] == 2){                         $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单未审核</span>";                    }elseif($v['cg_status'] == -2){                         $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' >采购单提交失败</span>";                    }elseif($v['cg_status'] == -3){                         $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单审核失败</span>";                    }                    if(!empty($v['cg_no'])){                         $cg_no = $v['cg_no']."【香港组织】<br/>".$cg_no;                    }               }                             $xs_no = "";               if($v['type'] == 1){                   if($v['xs_status'] == 1){                         $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单未提交</span>";                    }elseif($v['xs_status'] == -1){                         $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' >销售单创建失败</span>";                    }elseif($v['xs_status'] == 2){                         $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单未审核</span>";                    }elseif($v['xs_status'] == -2){                         $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单提交失败</span>";                    }elseif($v['xs_status'] == -3){                         $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单审核失败</span>";                    }                    if(!empty($v['xs_no'])){                         $xs_no = $v['xs_no']."【销售组织】<br/>".$xs_no;                    }               }               $dr_no = "";               if($v['dr_status'] == 1){                    $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单未提交</span>";               }elseif($v['dr_status'] == -1){                    $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' >创建调入单失败</span>";               }elseif($v['dr_status'] == 2){                    $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单未审核</span>";               }elseif($v['dr_status'] == -2){                    $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单提交失败</span>";               }elseif($v['dr_status'] == -3){                    $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单审核失败</span>";               }               if(!empty($v['dr_no'])){                    $dr_no = $v['dr_no']."【香港组织】<br/>".$dr_no;               }               $type = "";               if(isset($type_list[$v['type']])){                    if($v['type'] == 2){                         $type = "<i style='color:#70B'>".$type_list[$v['type']]."</i>";                    }else{                         $type = "<i>".$type_list[$v['type']]."</i>";                    }                                   }else{                    $type = "<b style='color:red'>异常</b>";               }               $list[] = [                    'id'=>$v['id'],                    'order_no'=>$v['order_no'],                    'type'=>$type,                    'dc_no'=> $dc_no,                    'cg_no'=>$cg_no,                    'xs_no'=>$xs_no,                    'dr_no'=>$dr_no,                    // 'xs_two_no'=>"",                    // 'bzch_no'=>"",                    //'bzsh_no'=>$bzsh_no,                                       'create_time'=>date("Y-m-d H:i:s",$v['create_time']),                    'update_time'=>date("Y-m-d H:i:s",$v['update_time'])               ];          }          $total = $this->zzquque_u9->find_count($where);          $pagenum = ceil($total/$perpage);          $over = $total-($start+$perpage);          $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));          echo json_encode($rows);exit;         }     $this->_Template('zzququeu9zt',$this->data);    }    public function _dczt($arg_array){     $process= $arg_array[0];      $id = $arg_array[1];      $info = $this->zzquque_u9->read($id);      if($process == 1){          if(!in_array($info['dc_status'],[0,-1])){               echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));               exit;          }          $r = $this->logic_u9ztsd->createdDc($info);          if($r['code'] == 1){               echo json_encode(array('msg'=>'创建调出单成功','success'=>true));               exit;          }else{               echo json_encode(array('msg'=>$r['msg'],'success'=>false));               exit;          }      }else{          echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));          exit;      }         }    private function _del($arg_array){          $id = $arg_array[0];          $user = $this->user->get_api($_SESSION['api']);          if(!in_array($user['userid'],['ceshi','admin'])){               echo json_encode(array('msg'=>'权限不足,禁止删除!','success'=>false));          }          $info = $this->zzquque_u9->read($id);          //目前只删除小单的  在途的单子 不管对错都不处理留痕          if(($info['dc_status'] < 3) && ($info['type'] == 10)){               $this->zzquque_u9->remove($id);               echo json_encode(array('msg'=>'删除成功','success'=>true));          }else{               echo json_encode(array('msg'=>'不满足删除条件','success'=>true));          }              }    public function _waixiao(){     $post = $this->input->post(NULL, TRUE);     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);//订单结束时间          $timetk = strtotime($timetk);          $timetj = strtotime($timetj);          $order_no = $this->input->post('order_no',true);          $type = $this->input->post('type',true);          $where = " ( type = 20) ";          if($order_no){              $where .= " and order_no like '%".$order_no."%' ";          }          if($timetk && $timetj){              $where .= " and create_time  > ".$timetk." and create_time  < ".$timetj." ";          }          if(empty($page))          {               $start = 0;               $perpage = 1;          }          else          {               $start = ($page - 1)*$perpage;          }                    $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);          $type_list = $this->zzquque_u9->getType();          $list = [];          foreach($info_list as $k=>$v){               $bzsh_no = $v['bzsh_no'];               if($v['bzsh_status'] == 0){                                       $bzsh_no = "<span  data-action='wxcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";                                                   }elseif($v['bzsh_status'] == -1){                    $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);                                       $tmp_str= "";                    if(isset($error[0]['ret_data'])){                         $ret_data = json_decode($error[0]['ret_data'],true);                         if(isset($ret_data[0]["ResMsg"])){                                   $tmp_str = $ret_data[0]["ResMsg"];                         }elseif(isset($ret_data['msg'])){                              $tmp_str = $ret_data['msg'];                         }elseif(isset($ret_data['Data'])){                              foreach($ret_data['Data'] as $iit){                                   if(!$iit['m_isSucess']){                                        $tmp_str .= $iit['m_errorMsg']."<br>";                                   }                                                                 }                                                       }else{                                   $tmp_str = "系统执行失败,请重试";                         }                                             }else{                         $tmp_str = "";                    }                                       $bzsh_no = "<span data-action='wxcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';               }elseif($v['bzsh_status'] == 1){                    $bzsh_no = $v['bzsh_no']."<br/><span data-action='wxcprksh' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";               }                              $xs_no = " ";               if($v['xs_status'] == -1){                    $xs_no .= "<span data-action='wxxs' data-process='1'  onclick='doAction(this)'  data-id='".$v['id']."' >创建销售单</span>";               }elseif($v['xs_status'] == 0){                    $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";               }               if(!empty($v['xs_no'])){                    $xs_no = $v['xs_no']."<br/>".$xs_no;               }               $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];                                             $list[] = [                    'id'=>$v['id'],                    'order_no'=>$v['order_no'],                    'type'=>"工厂外销单",                    'bzsh_no'=> $bzsh_no,                    'xs_no'=>$xs_no,                    'bzch_no'=>$bzch_no,                    // 'xs_two_no'=>"",                    // 'bzch_no'=>"",                    //'bzsh_no'=>$bzsh_no,                                       'create_time'=>date("Y-m-d H:i:s",$v['create_time']),                    'update_time'=>date("Y-m-d H:i:s",$v['update_time'])               ];          }          $total = $this->zzquque_u9->find_count($where);          $pagenum = ceil($total/$perpage);          $over = $total-($start+$perpage);          $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));          echo json_encode($rows);exit;         }     $this->_Template('zzququeu9wx',$this->data);    }    public function _wxcprk($arg_array){      $id = $arg_array[0];      $info = $this->zzquque_u9->read($id);      if(empty($info)){          echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));          exit;      }      if($info['bzsh_status'] != 0){          echo json_encode(array('msg'=>"当前状态不符合创建成品入库单的条件",'success'=>false));          exit;      }      $res = $this->logic_u9action->doRkd($info);      if($res['code'] == 1){          echo json_encode(array('msg'=>'创建成品入库单成功','success'=>true));          exit;      }else{          echo json_encode(array('msg'=>$res['msg'],'success'=>false));          exit;      }    }    public function _wxcprksh($arg_array){          $id = $arg_array[0];          $info = $this->zzquque_u9->read($id);          if(empty($info)){               echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));               exit;          }          if($info['bzsh_status'] != 0){               echo json_encode(array('msg'=>"当前状态不符合审核成品入库单的条件",'success'=>false));               exit;          }          $res = $this->logic_u9action->checkRkd($info);          if($res['code'] == 1){               echo json_encode(array('msg'=>'审核成品入库单成功','success'=>true));               exit;          }else{               echo json_encode(array('msg'=>$res['msg'],'success'=>false));               exit;          }    }    public function _wxxs($arg_array){          $id = $arg_array[0];          $info = $this->zzquque_u9->read($id);          if(empty($info)){               echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));               exit;          }          if($info['xs_status'] != 0){               echo json_encode(array('msg'=>"当前状态不符合创建销售单的条件",'success'=>false));               exit;          }          $res = $this->logic_u9action->createXsd($info);          if($res['code'] == 1){               echo json_encode(array('msg'=>'创建销售单成功','success'=>true));               exit;          }else{               echo json_encode(array('msg'=>$res['msg'],'success'=>false));               exit;          }    }    public function _gcbh_index(){          $post = $this->input->post(NULL, TRUE);          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);//订单结束时间               $timetk = strtotime($timetk);               $timetj = strtotime($timetj);               $order_no = $this->input->post('order_no',true);               $type = $this->input->post('type',true);               $where = " ( type = 21) ";               if($order_no){               $where .= " and order_no like '%".$order_no."%' ";               }               if($timetk && $timetj){               $where .= " and create_time  > ".$timetk." and create_time  < ".$timetj." ";               }               if(empty($page))               {                    $start = 0;                    $perpage = 1;               }               else               {                    $start = ($page - 1)*$perpage;               }                              $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);               // $type_list = $this->zzquque_u9->getType();               $list = [];               foreach($info_list as $k=>$v){                    $bzsh_no = empty($v['bzsh_no'])?"":$v['bzsh_no'];                    if($v['bzsh_status'] == 0){                                             $bzsh_no = "<span  data-action='bhcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";                                                            }elseif($v['bzsh_status'] == -1){                         $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);                                             $tmp_str= "";                         if(isset($error[0]['ret_data'])){                              $ret_data = json_decode($error[0]['ret_data'],true);                              if(isset($ret_data[0]["ResMsg"])){                                        $tmp_str = $ret_data[0]["ResMsg"];                              }elseif(isset($ret_data['msg'])){                                   $tmp_str = $ret_data['msg'];                              }elseif(isset($ret_data['Data'])){                                   foreach($ret_data['Data'] as $iit){                                        if(!$iit['m_isSucess']){                                             $tmp_str .= $iit['m_errorMsg']."<br>";                                        }                                                                           }                                                                 }else{                                        $tmp_str = "系统执行失败,请重试";                              }                                                       }else{                              $tmp_str = "";                         }                                             $bzsh_no = "<span data-action='bhcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>".'<p style="color:blue"><i  class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';                    }elseif($v['bzsh_status'] == 1){                         //$bzsh_no = $v['bzsh_no']."<br/><span data-action='wxcprksh' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";                         $bzsh_no = $v['bzsh_no'];                    }                    $dc_no = empty($v['dc_no'])?" ":$v['dc_no'];                    // if($v['xs_status'] == -1){                    //      $xs_no .= "<span data-action='wxxs' data-process='1'  onclick='doAction(this)'  data-id='".$v['id']."' >创建销售单</span>";                    // }elseif($v['xs_status'] == 0){                    //      $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";                    // }                    // if(!empty($v['xs_no'])){                    //      $xs_no = $v['xs_no']."<br/>".$xs_no;                    // }                    // $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];                                                       $list[] = [                         'id'=>$v['id'],                         'order_no'=>$v['order_no'],                         'type'=>"工厂备货单",                         'bzsh_no'=> $bzsh_no,                         'dc_no'=>$dc_no,                         //'bzch_no'=>$bzch_no,                         // 'xs_two_no'=>"",                         // 'bzch_no'=>"",                         //'bzsh_no'=>$bzsh_no,                                             'create_time'=>date("Y-m-d H:i:s",$v['create_time']),                         'update_time'=>date("Y-m-d H:i:s",$v['update_time'])                    ];               }               $total = $this->zzquque_u9->find_count($where);               $pagenum = ceil($total/$perpage);               $over = $total-($start+$perpage);               $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));               echo json_encode($rows);exit;              }          $this->_Template('zzququeu9gcbh',$this->data);    }    public function _bhcprk($arg_array){          $id = $arg_array[0];          $info = $this->zzquque_u9->read($id);          if(empty($info)){          echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));          exit;          }          if($info['bzsh_status'] != 0){          echo json_encode(array('msg'=>"当前状态不符合创建成品入库单的条件",'success'=>false));          exit;          }          $res = $this->logic_u9bh->dpCprk($info);          if($res['code'] == 1){          echo json_encode(array('msg'=>'创建成品入库单成功','success'=>true));          exit;          }else{          echo json_encode(array('msg'=>$res['msg'],'success'=>false));          exit;          }    }    public function _gcbhexcel(){               $params = $this->input->get();     $where = " type = 21 ";     if(!empty($params['order_no'])){       $where .= " and  order_no =  '".$params['order_no']."' ";     }      if(!empty($params['timetk'])){       $where .= " and create_time >  ".strtotime($params['timetk'])." ";     }            if(!empty($params['timetj'])){       $where .= "and create_time <  ".strtotime($params['timetj'])." ";     }                    $info_list = $this->zzquque_u9->find_all($where,'*','id desc');              $type_list = $this->zzquque_u9->getType();       $list = [];       foreach($info_list as $k=>$v){          $error_str = "";          $error_json ="";          if($v['bzsh_status'] == -1){               $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);               $error_json = $error[0]['ret_data'];               if($error[0]['apply_api']=='scrk_cj'){                    $ret_data = json_decode($error[0]['ret_data'],true);                    if(isset($ret_data["Data"])){                         if(isset($ret_data['Data']['0'])){                              $error_str = $ret_data['Data']['0']["m_errorMsg"];                         }else{                              $error_str = "数据异常请联系技术";                         }                                             }else{                         $error_str = "数据异常请联系技术";                    }               }else{                    $ret_data = json_decode($error[0]['ret_data'],true);                    if(isset($ret_data[0]["ResMsg"])){                         $error_str = $ret_data[0]["ResMsg"];                    }elseif(isset($ret_data['msg'])){                         $error_str = $ret_data['msg'];                    }else{                         $error_str = "数据异常请联系技术";                    }               }                         }                    $transfer_info = $this->whlabel_bh_transfer->read($v['child_order_no']);          $pm = empty($transfer_info['pm'])?"异常":$transfer_info['pm'];                        $list[] = [                 'id'=>$v['id'],                 'order_no'=>$v['order_no'],                 'pm'=>$pm,                 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",                 'bzsh_no'=>empty($v['bzsh_no'])?"":$v['bzsh_no'],                 'dc_no'=>empty($v['dc_no'])?"":$v['dc_no'],                 'error_str'=>$error_str,                 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),            ];       }       $filename = date("Y-m-d")."u9小单导出.xls";       $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">          <head>          <!--[if gte mso 9]><xml>          <x:ExcelWorkbook>          <x:ExcelWorksheets>          <x:ExcelWorksheet>          <x:Name>EXCEL</x:Name>          <x:WorksheetOptions>          <x:Print>          <x:ValidPrinterInfo />          </x:Print>          </x:WorksheetOptions>          </x:ExcelWorksheet>          </x:ExcelWorksheets>          </x:ExcelWorkbook>          </xml>          <![endif]-->          </head><body>";          $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";           $str .= "<tr><td>id</td><td>订单号</td><td>品名</td><td>类型</td><td>成品入库单</td><td>调出单</td><td>错误信息</td><td>时间</td></tr>";          foreach ($list as $key=>$value)           {                $str .= "<tr>";               $str .= "<td>". $value['id']. "</td>";               $str .= "<td>". $value['order_no']. "</td>";	               $str .= "<td>". $value['pm']. "</td>";	               $str .= "<td>". $value['type']. "</td>";	               $str .= "<td>". $value['bzsh_no']. "</td>";               $str .= "<td>". $value['dc_no']. "</td>";               $str .= "<td>". $value['error_str']. "</td>";               $str .= "<td>". $value['create_time']. "</td>";               $str .= "</tr>";          }          $str .= "</table></body></html>";           header( "Content-Type: application/vnd.ms-excel; name='excel'" );           header( "Content-type: application/octet-stream" );           header( "Content-Disposition: attachment; filename=".$filename );           header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );           header( "Pragma: no-cache" );           header( "Expires: 0" );           exit($str);     }    public function _cpkbh_index(){          $post = $this->input->post(NULL, TRUE);          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);//订单结束时间               $timetk = strtotime($timetk);               $timetj = strtotime($timetj);               $order_no = $this->input->post('order_no',true);               $type = $this->input->post('type',true);               $where = " ( type = 22) ";               if($order_no){               $where .= " and order_no like '%".$order_no."%' ";               }               if($timetk && $timetj){               $where .= " and create_time  > ".$timetk." and create_time  < ".$timetj." ";               }               if(empty($page))               {                    $start = 0;                    $perpage = 1;               }               else               {                    $start = ($page - 1)*$perpage;               }                              $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);                            $list = [];               foreach($info_list as $k=>$v){                                        $xs_no = "";                    if($v['xs_status'] == 0){                         $xs_no = "<span  data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";                    }                    if(!empty($v['xs_no'])){                         $xs_no = $v['xs_no'];                    }                    $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];                                        $list[] = [                         'id'=>$v['id'],                         'order_no'=>$v['order_no'],                         'type'=>"成品备货单",                         'xs_no'=>$xs_no,                         'bzch_no'=>$bzch_no,                         'create_time'=>date("Y-m-d H:i:s",$v['create_time']),                         'update_time'=>date("Y-m-d H:i:s",$v['update_time'])                    ];               }               $total = $this->zzquque_u9->find_count($where);               $pagenum = ceil($total/$perpage);               $over = $total-($start+$perpage);               $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));               echo json_encode($rows);exit;              }          $this->_Template('zzququeu9cpkbh',$this->data);    }}
 |