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