| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160 | <?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');		$this->load->_model("Model_logic_u9tools","logic_u9tools");		$this->load->_model("Model_logic_ding","logic_ding");		$this->load->_model("Model_apiyyv1","apiyyv1");		$this->load->_model('Model_settingtest','settingtest');		$this->load->_model("Model_whlabel_bh_transfer_cr","whlabel_bh_transfer_cr");		$this->load->_model("Model_zzquque_u9","zzquque_u9");	}	//定义方法的调用规则 获取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 if($arg == 'rk')        {             $this->_rk();        }		else if($arg == 'ck')        {             $this->_ck();        }		else if($arg == 'ck')        {             $this->_ck();        }		else if($arg == 'transfer_log'){			 $this->_transfer_log();		}		else if($arg == 'transfer_detail'){			$this->_transfer_detail($arg_array);		}		else if($arg == 'cj_transfer_log'){			$this->_cj_transfer_log();		}		else if($arg == 'cj_transfer_zklog'){			$this->_cj_transfer_zklog();		}		else if($arg == 'cj_transfer_detail'){			$this->_cj_transfer_detail($arg_array);		}		else if($arg == 'cj_transfer_log_count'){			$this->_cj_transfer_log_count();		}		else if($arg == 'cj_transfer_log_zkcount'){			$this->_cj_transfer_log_zkcount();		}		else if($arg == "cj_transfer_scanout_excel"){			$this->_cj_transfer_scanout_excel();		}		else if($arg == "cj_transfer_scanout_xzlog"){			$this->_cj_transfer_scanout_xzlog();		}		else if($arg == 'excelwchz'){			$this->_excelwchz();		}		else if($arg == 'wdyindex'){			$this->_wdyindex();		}		else if($arg == 'edit_jgtime'){			$this->_edit_jgtime();		}else if($arg == 'excelcpkhz'){			$this->_excelcpkhz();		}		else if($arg == 'check_by_number'){			$this->_check_by_number();		}		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 = "id 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,printsl,time,extra_type',$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']);				if($value['extra_type'] == 1){					$info_list[$key]['extra_type'] =  "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";				}else{					$info_list[$key]['extra_type'] = "";				}						    }		    $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'));		    }			**/		}		$start_time = time() - 3600*24*29;		$end_time = time() + 3600*24;		$count_list = $this->whlabel_bh->find_all("extra_type = 1 and time > ".$start_time." and time < ".$end_time);		$wdysl = 0;		foreach($count_list as $k=>$v){			$wdysl = $wdysl + ($v['bhnum'] - $v['printsl']);		}		$this->data['wdysl'] = $wdysl;		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 _wdyindex(){		$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);			$timetk = $this->input->post('timetk',true);			$timetj = $this->input->post('timetj',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			$where = " bhnum > printsl and extra_type = 1 ";			if($timetk && $timetj)            {                $where .= " and time > '$timetk' and time < '$timetj'";            }			if($orderinfo)            {                $where  .= " and orderinfo like '%$orderinfo%'";            }			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 features like '%-$category-%'";            }			if($size)            {                $where  .= " and features like '%-$size-%'";            }			if($grade)            {                $where  .= " and features like '%-$grade-%'";            }			if($color)            {                $where  .= " and features like '%-$color-%'";            }			if($lowe)            {                $where  .= " and features like '%-$lowe-%'";            }			if($type)            {                $where  .= " and type = '$type'";            }			if($shipremarks)            {                $where  .= " and shipremarks like '%$shipremarks%'";            }            //数据排序            $order_str = "time desc";            if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }            //取得信息列表            $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,printsl,time,extra_type',$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']);				if($value['extra_type'] == 1){					if(($value['bhnum']-$printnum > 0) && ($value['printsl'] < $value['bhnum'])){						$info_list[$key]['extra_type'] =  "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";					}else{						$info_list[$key]['extra_type'] = "";					}									}else{					$info_list[$key]['extra_type'] = "";				}						    }		    $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;					}		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);		}		else		{			header('Location: /');exit;		}			$this->_Template('whlabel_bhwdy',$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['wigother1'] = $this->input->post('wigother1',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(1000,9999);			if(!$post['num'])			{			    $post['number'] = date("YmdHis").rand(1000,9999);			}			$time = time();			$post['time'] = $time;//操作时间			$post['printnum'] = $time;			$post['type'] = 0;			$post['extra_type'] = (int)trim($post['extra_type'],',');						//传输料号开始			$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['wigother1'] = $this->input->post('wigother1',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['wigother1'] = $this->input->post('wigother1',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('id'=>$v['id'],'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();			$typeclassid = [];			foreach($tc as $v){				$typeclassid[$v['id']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);			}			$i = 0;$j = 0;$ed = [];			$ck = [				"成品仓"=>'99001',				"美国仓"=>'02031',				"AP"=>'0103001',				"WK"=>'0103002',				"QV"=>'0103003',				"AS"=>'0103004',				"H"=>"0103005",				"AP英"=>"0103006",				"YMS"=>"0103007",				"AP新"=>"0103008",				"WK新"=>"0103009",				"H新"=>"0103010",				"Bilisar"=>"0103011",				"Estilar"=>"0103012",				"QM"=>"0103013",				"Afola"=>"0103014",				"拼多多-Finsa"=>"0106002",				"拼多多-艾彩"=>"0105001",				"拼多多-Estilar"=>"0106001",				"拼多多-QM"=>"0106003",			];			foreach($list as $k=>$v){								$res = $this->logic_u9tools->getGoodInfoByErpSku($v[0],$v[1],$typeclass,$typeclassid,$classid);				if($res['code']==1){					//传输料号开始					$post = $res['data'];					$post['number'] = $post['number'].$k;					$post['orderinfo'] = $v[2];					$post['num'] = $v[5];					$post['state'] = ($v[3] == '生产')?0:1;					$post['purchase'] = "";//供货商					$post['shipremarks'] = empty($v[6])?" ":$v[6];//					$post['rknum'] = 0;					$post['scapi'] = 0;					$post['dbapi'] = 0;					$post['bhnum'] = $v[5];					$post['extra_type'] = (strpos($v[2],"美国销售-") !== false)?1:0;					if(isset($ck[$v[4]])){						$post['kh'] = $ck[$v[4]];					}else{						$j++;						$ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);						continue;					}										$lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));					$this->logic_ding->sendToDing("备货批量导入出现的错误信息".json_encode($lh,JSON_UNESCAPED_UNICODE));					if(isset($lh['Data'][0]))					{						if($lh['Data'][0]['m_isSucess'] != 1)						{							if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')							{								$j++;								$ed[] = array($lh['Data'][0]['m_errorMsg'],$post['jm'],$post['bm']);							}						}					}					else					{						$j++;						$ed[] = array('料号错误',$post['jm'],$post['bm']);					}					if($this->whlabel_bh->insert($post))					{						$i++;					}					else					{						$j++;						$ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);					}				}else{					$j++;					$ed[] = array($res['msg'],$v[1],"");					}			}			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'] = 1;				// $post['rk'] = "";//默认订单中心 打印后直接入库				// $post['rktime'] = "";				// $post['ctime15'] = $time;				$post['time'] = $time;				$post['gtime'] = date('Yms',$time);				$post['wbid'] = $data['id'];				$rows = array();				$label = date("ymdHis").rand(1000,9999);				$post['label'] = $label;								// 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;			    // }				if(stripos($post['features'],'-126-') !== false)				{					$drck = '12003';//进入发条库				}				else if(stripos($post['features'],'-127-') !== false)				{					$drck = '12004';//进入发块库				}				else				{					$drck = '12006';//其它进入完成库				}				//创建u9的生产单				$token = $this->settingtest->get_yytoken_120();				$params = [					'org_code'=>"120",					'djhlx'=>'2000',					'scbm_code'=>"12008",					"time"=>time(),					'owner_org_code'=>"120",					'title'=>$post['orderinfo'],					'shipremarks'=>$data['shipremarks'],					'list'=>[						[							'drck'=>$drck,							'jm'=>$post['jm'],							'sl'=>$n,							'drck'=>$drck,						]					]				];								$res = $this->apiyyv1->scdCreate($params,$token);				$this->logic_ding->sendToDing("【".$post['orderinfo']."-".$data['id']."】生产备货同步u9||".json_encode($res,JSON_UNESCAPED_UNICODE));				if(!isset($res[0]['Data'])){					echo json_encode(array('msg'=>'u9同步返回异常,请重试!','success'=>false));exit;				}				if(!$res[0]['Data'][0]['m_isSucess']){					echo json_encode(array('msg'=>'u9同步失败,请重试!','success'=>false));exit;				}				$scid = $res[0]['Data'][0]['m_iD']."~".$res[0]['Data'][0]['m_code']."~".$drck;				$post['scid'] = $scid;				$post['scapi'] = 1;				$post['dbapi'] = 0;				$this->db->trans_begin();				$post['shipremarks'] = $data['shipremarks'];				for($i = 0;$i < $n;$i++){					$post['label'] = $label.$i;					$rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>1);					$this->whlabel_bh_transfer->insert($post);				}				$printsl = $data['printsl']*1 + $n*1; 				$this->whlabel_bh->save(['printsl'=>$printsl],$data['id']);				if ($this->db->trans_status() === TRUE)				{					$this->db->trans_commit();					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 _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['pm'],'n'=>1);            }            echo json_encode(array('rows'=>($rows),'success'=>true));exit;		}    }	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'],'|')));			$tdata = $this->transfer->find_all();			$t = array();			foreach ($tdata as $v)		    {				$t[$v['id']] = $v['title'];			}			if($cz == 1)			{				if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏				{					echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;				}			}			if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏			{				echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;			}			if($cz == 1)			{				$lb['rk'] .= $transfer.'|';				$lb['rktime'] .= $time.'|';				if($lbrk[0] == $transfer)				{					echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;				}				//必须走配货				if(($transfer != 1) && (strpos($lb['rk'],'|1|') === false) ){					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;			//如果是完成扫出 这样会通知erp生成一个调出单  			//中转库如果扫出的话 应该是马尾  其它的没有			if(($transfer == 3 || $transfer == 13) && $cz == 2 && $lb['dbapi'] < 99){				if(empty($lb['scid'])){					echo json_encode(array('msg'=>'此单在u9的信息异常,通知技术排查1!','success'=>false));exit;				}				$tmp_u9_info = explode('~',$lb['scid']);				if(count($tmp_u9_info)!=3){					echo json_encode(array('msg'=>'此单在u9的信息异常,通知技术排查2!','success'=>false));exit;				}				$doc_no = $tmp_u9_info[1];				$token = $this->settingtest->get_yytoken_120();				$res = $this->apiyyv1->cxScdStatus($doc_no,$token);				if(empty($res[0]['Data'])){					echo json_encode(array('msg'=>'erp查询u9生产单状态异常,通知技术排查3!','success'=>false));exit;				}				if(empty($res[0]['Data'][0]['docno'])){					echo json_encode(array('msg'=>'查询u9生产单的信息失败,通知技术排查4!','success'=>false));exit;				}				if($res[0]['Data'][0]['docno'] != $doc_no){					echo json_encode(array('msg'=>'查询u9生产单的信息和erp信息不照应,通知技术排查!','success'=>false));exit;				}				//docstate  0 开立  1审核 2开工				if($res[0]['Data'][0]['docstate'] < 2){					echo json_encode(array('msg'=>$doc_no.'生产单未开工,无法出库!','success'=>false));exit;				}				$this->db->trans_begin();				$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,'status'=>2,'dbapi'=>99),$lb['id']);				$this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);				$ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');				if($ct_info){					$this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);				}				$this->zzquque_u9->insert([					'platform'=>'',					'warehouse'=>0,					'type'=>21,     					'order_no'=>$lb['orderinfo'],					'child_order_no'=>$lb['id'],					'status'=>0,					'create_time'=>time(),					'update_time'=>time(),				]);				if ($this->db->trans_status() === TRUE){					$this->db->trans_commit();					echo json_encode(array('music'=>'1','success'=>true));exit;				}else{					$this->db->trans_rollback();					echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;				}							}						//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;			}			$save_data = [				'rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time			];			//配货入库需更新一下配货状态			if($transfer == 2 && $cz == 1 && $lb['status'] == 0){				$save_data['status'] = 1;			}			$this->db->trans_begin();			$this->whlabel_bh_transfer->save($save_data,$lb['id']);			if($cz == 2){				$this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);				$ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');				if($ct_info){					$this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);				}			}else{				$this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>0,'number'=>$lb['number']]);			}						if ($this->db->trans_status() === TRUE){				$this->db->trans_commit();				echo json_encode(array('music'=>'1','success'=>true));exit;			}else{				$this->db->trans_rollback();				echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;			}		}	}	protected function getOperateList(){		    $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);			$crk_select = $this->input->post('crk',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 features like '%-".$color."-%'";            }			if(!empty($crk_select)){				$where_arr = [];				$where_arr['time >='] =$timetk;				$where_arr['time <='] = $timetj;				if($transfer == 1){					$where_arr[] =['lx'=>$transfer];				}							$cr_model = $this->db->from('whlabel_bh_transfer_cr')->select('id,fid,is_over,lx,time');				if($crk_select == 1){					$where_arr['type'] =1;					$cr_tmp_list = $cr_model->where($where_arr)->get()->result_array();				}else{					$where_arr['type'] = 2;					$cr_tmp_list = $cr_model->where($where_arr)->get()->result_array();				}				$fids = array_column($cr_tmp_list,'fid');				$ids = array_unique($fids);				if(empty($ids)){					$where  = " id  = 1 ";				}else{					$where  .= " and id in (".implode(",",$ids).")";				}								// if($crk_select == 1){ 				// 	$where .=" and  rk != ck ";				// }				// if($crk_select == 2){				// 	$where .=" and  rk = ck  ";				// }			}            //数据排序            $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)		    {				$info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);				$log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);				$tmp_operate_str = "";				foreach($log_list as $k=>$v){					$tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";				}				$info_list[$key]['time'] = trim($tmp_operate_str,'<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),'where'=>$where);		    return $rows;	}		public function _operate()	{		$post = $this->input->post(NULL, TRUE);	    if(isset($post['page']))  		{			$rows = $this->getOperateList();		    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;		$ids = array_column($transfer,'id');		$end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;		$start_time = $end_time - 14 * 24 * 60 * 60;		//$count  =  $this->whlabel_bh_transfer_cr->find_count("type = 1 and is_over = 0 and lx in (".implode(",",$ids).") and time >= ".$start_time." and time <= ".$end_time );		//$this->data['count'] = $count;		$this->data['vip'] = $user['vip'];		$this->_Template('whlabel_bh_operate',$this->data);	}		public function _rk()	{		$post = $this->input->post(NULL, TRUE);	    if(isset($post['page']))  		{			$res = $this->getOperateList();		    $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);		    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;		}		$transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));		$this->data['transfer'] = $transfer;		$this->_Template('whlabel_bh_rk',$this->data);	}			public function _ck()	{		$post = $this->input->post(NULL, TRUE);	    if(isset($post['page']))  		{			$res = $this->getOperateList();		    $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);		    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;		}		$transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));		$this->data['transfer'] = $transfer;		$this->_Template('whlabel_bh_ck',$this->data);	}	//备货流转记录表	public function _transfer_log(){		$post = $this->input->post(NULL, TRUE);		if($post){			$page = $this->input->post('page',true);		    $perpage = $this->input->post('perpage',true);			$where = " extra_type = 1 ";			$orderinfo = $this->input->post('orderinfo',true);			$timetk = $this->input->post('timetk',true);			$timetj = $this->input->post('timetj',true);			$timetk = strtotime($timetk);			$timetj = strtotime($timetj);			if($timetk && $timetj)            {                $where .= " and time > '$timetk' and time < '$timetj'";            }			if($orderinfo){				$where.= " and orderinfo like '%$orderinfo%' ";			}			if(empty($page))		    {                $start = 0;		    	$perpage = 1;            }		    else		    {                $start = ($page - 1)*$perpage;            }			$list = $this->whlabel_bh->find_pc($where,'orderinfo',"id,orderinfo,jgtime",'id desc',$start,$perpage);				$rows = [];			foreach($list as $k=>$v){				$tmp_order_info = $this->whlabel_bh->find_all(" orderinfo = '".$v['orderinfo']."'","id,orderinfo,bhnum");				$tmp_ids = [];				$tmp_bhnum = 0;				foreach($tmp_order_info as $vv){					$tmp_ids[] = $vv['id'];					$tmp_bhnum += $vv['bhnum'];				}				$ydysl = $wdysl = $yphsl = $yjgsj = $wwgsl = 0;				if(!empty($tmp_ids)){					$list = $this->whlabel_bh_transfer->find_all(" wbid in (".implode(",",$tmp_ids).")");					foreach($list as $vv){						$ydysl += 1;						if($vv['status'] > 0){							$yphsl += 1;						}						if($vv['status'] == 2){							$yjgsj += 1;						}					}				}																$rows[$k]['id'] = $v['id'];				$rows[$k]['orderinfo'] = "<h9 class='window' data-h='/whlabel_bh/transfer_detail/".$v['id']."' data-t='备货单号:".$v['orderinfo']."'><p>".$v['orderinfo']."</p></h9>" ;				$rows[$k]['ddsl'] = $tmp_bhnum;   //订单数量				$rows[$k]['ydysl'] = $ydysl;	 //已打印数量				$rows[$k]['wdysl'] = $tmp_bhnum - $ydysl;  //未打印数量				$rows[$k]['yphsl'] = $yphsl;  //已配货数量				$rows[$k]['yjgsj'] = $yjgsj;  //已完工数量				$rows[$k]['wwgsl'] = $tmp_bhnum - $yjgsj;  //未完工数量				$rows[$k]['jgtime'] = empty($v['jgtime'])?'<i class="method fa fa-edit" data-id="'.$v['id'].'" onclick="edit_jgtime(this)"></i>':date("Y-m-d ",$v['jgtime']).'  <i class="method fa fa-edit" data-id="'.$v['id'].'"  onclick="edit_jgtime(this)"></i>';			}			$total = $this->whlabel_bh->find_count($where);			$pagenum = ceil($total/$perpage);			$over = $total-($start+$perpage);			$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));			echo json_encode($rows);exit;		}		$start_time = strtotime(date('Y-m-d')) -  14* 24 * 60 * 60;		$end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;		//		$tmp_list = $this->whlabel_bh->find_pc("extra_type = 1 and time >= ".$start_time." and time <= ".$end_time,'orderinfo',"id,orderinfo,jgtime",'id desc');		if(empty($tmp_list)){			$total_num = 0;			$over_num = 0;		}else{			$tmp_where = " ";			if(count($tmp_list) == 1){				$tmp_where = "orderinfo = '".$tmp_list[0]['orderinfo']."'";			}else{				foreach($tmp_list as $k=>$v){					$tmp_where .= " orderinfo = '".$v['orderinfo']."' or";				}				$tmp_where = rtrim($tmp_where,"or");			}			$all_list = $this->whlabel_bh->find_all($tmp_where);			$orderinfo_list =[];			$total_num = 0;			foreach($all_list as $k=>$v){				$orderinfo_list[$v['id']] = $v['id'];				$total_num += $v['bhnum'];			}			$wbids = array_values($orderinfo_list);			if(empty($wbids)){				$over_num = 0;			}else{				$over_num = $this->whlabel_bh_transfer->find_count(" status = 2 and wbid in (".implode(",",$wbids).")");			}					}				$this->data['total_num'] = $total_num;		$this->data['wwcsl'] = $total_num - $over_num;		$this->_Template('whlabel_bh_transfer_log',$this->data);	}	public function _edit_jgtime(){		$post = $this->input->post(NULL, TRUE);		$info = $this->whlabel_bh->read($post['id']);		if(empty($info)){			echo json_encode(['code'=>-1,'msg'=>'信息异常']);exit;		}		$jgtime = strtotime($post['jgtime']);		$list = $this->whlabel_bh->find_all(" orderinfo = '".$info['orderinfo']."'");		foreach($list as $k=>$v){			$this->whlabel_bh->save(['jgtime'=>$jgtime],$v['id']);		}		echo json_encode(['code'=>1,'msg'=>'操作成功']);exit;	}	public function _transfer_detail($arg_array){		$id = $arg_array[0];		$transfer_list = $this->transfer->find_all();		$t_list = array_column($transfer_list,'title','id');		$info = $this->whlabel_bh->read($id);		$list = $this->whlabel_bh_transfer->find_all(" orderinfo= '".$info['orderinfo']."'");		$ids = array_column($list,'id');		$final_list = [];		if(!empty($ids)){			$log_list = $this->whlabel_bh_transfer_cr->find_all( " type = 1 and  fid in (".implode(",",$ids).")","*","id asc");			$collect_list = [];			foreach($log_list as $k=>$v){				$collect_list[$v['lx']][$v['fid']] = $v;			}						foreach($collect_list as $k=>$v){				$js_num = $zk_num = $wc_num = 0;				foreach($v as $kk=>$vv){					$js_num += 1;					if($vv['is_over'] == 0){						$zk_num += 1;					}					if($vv['is_over'] == 1){						$wc_num += 1;					}				}				$final_list[$k] = [					'cj' => $t_list[$k],					'js_num' => $js_num,					'zk_num' => $zk_num,					'wc_num' => $wc_num,					'list' => $v,				];			}		}				// echo "<pre>";		// print_r($final_list);		// die;		$this->data['final_list'] = $final_list;		$this->_Template('whlabel_bh_transfer_detail',$this->data);	}	public function _cj_transfer_log(){		$post = $this->input->post(NULL, TRUE);		if(!empty($post)){			$orderinfo = $this->input->post('orderinfo',true);			$pm = $this->input->post('pm',true);			$tid = $this->input->post('tid',true);			$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);			$where = " rk like '%|".$tid."|%' ";			if($timetk && $timetj)            {                $where .= " and ctime".$tid." > '$timetk' and ctime".$tid." < '$timetj'";            }						if($pm){				if(empty($orderinfo)){					$rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]),'cwxx'=>"请先输入订单号");					echo json_encode($rows);exit;				}else{					$number_list  = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");					$numbers = array_column($number_list,'number');					if(empty($numbers)){						$rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));						echo json_encode($rows);exit;					}					$where.= " and number in (".implode(",",$numbers).") ";				}			}else{				if($orderinfo){					$number_list  = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");					$numbers = array_column($number_list,'number');					if(empty($numbers)){						$rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));						echo json_encode($rows);exit;					}					$where.= " and number in (".implode(",",$numbers).") ";				}			}			if(empty($page))		    {                $start = 0;		    	$perpage = 20;            }		    else		    {                $start = ($page - 1)*$perpage;            }									$list = $this->whlabel_bh_transfer->find_pc($where,'number',"id,number,orderinfo,pm",'id desc',$start,$perpage);						$count = $this->whlabel_bh_transfer->find_all($where,'COUNT(DISTINCT number) as total');			$total = $count[0]['total'];			$pagenum = ceil($total/$perpage);			$over = $total-($start+$perpage);			$final_list = [];			foreach($list as $k=>$v){				$yjs_arr =[];//避免多次扫入的重复计算				$yjs = $wck= $yck = 0;				$log_list = $this->whlabel_bh_transfer_cr->find_all("lx = ".$tid." and type = 1 and  number = ".$v['number'],"*",'id desc');								foreach($log_list as $kk=>$vv){					if(!isset($yjs_arr[$vv['fid']])){						$yjs += 1;						if($vv['is_over'] == 0){							$wck += 1;						}						if($vv['is_over'] == 1){							$yck += 1;						}						$yjs_arr[$vv['fid']] = 1;					}									}				$whlabel_bh_info = $this->whlabel_bh->find("number = ".$v['number']);				$final_list[$k]['id'] = $v['id'];				$final_list[$k]['orderinfo'] = $v['orderinfo'] ;				$final_list[$k]['number'] ="<h9 class='window' data-h='/whlabel_bh/cj_transfer_detail/".$v['number']."/".$tid."' data-t='备货单号:".$v['number']."'><p>".$v['number']."</p></h9>";				$final_list[$k]['pm'] = $v['pm'];				$final_list[$k]['ddsl'] = empty($whlabel_bh_info)?0:$whlabel_bh_info['bhnum'];				$final_list[$k]['yjs'] = $yjs;				$final_list[$k]['wck'] = $wck;				$final_list[$k]['yck'] = $yck;			}			$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));			echo json_encode($rows);exit;		}		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$usp = $user;									$transfer = explode('|',trim($user['transfer'],'|'));			$stid = "";			foreach ($transfer as $value) 		    {				$stid .= " id = ".$value." or";			}			if(empty($transfer)){				exit("您的账号没有赋予车间权限");			}			// if(count($transfer) > 1){			// 	exit("您的账号只能分配一个车间,多车间系统无法处理");			// }			$tid = $transfer[0];					}		else		{			header('Location: /');exit;		}		$transfer = $this->transfer->read($tid);		$this->data['transfer'] = $transfer;		$transfer_list  = $this->transfer->find_all( trim($stid,'or'));		$start_time = strtotime(date('Y-m-d')) -  14* 24 * 60 * 60;		$end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;					$log_list = $this->whlabel_bh_transfer_cr->find_all(" lx = ".$tid." and type = 1  and time >= ".$start_time." and time <= ".$end_time,"*","id desc");			$wwcsl = $jszs = $wgzs = 0;		$tmp_list = [];		foreach($log_list as $k=>$v){			if(!isset($tmp_list[$v['fid']])){				$tmp_list[$v['fid']] = $v;				$jszs += 1;				if($v['is_over'] == 1){					$wgzs += 1;				}else{					$wwcsl += 1;				}			}		}		 		$this->data['wwcsl'] = $wwcsl;		$this->data['jszs'] = $jszs;		$this->data['wgzs'] = $wgzs;		$this->data['transfer_list'] = $transfer_list;		$this->_Template('whlabel_bh_cj_transfer_log',$this->data);	}	public function _cj_transfer_zklog(){		$post = $this->input->post(NULL, TRUE);		if(!empty($post)){						$orderinfo = $this->input->post('orderinfo',true);			$pm = $this->input->post('pm',true);			$tid = $this->input->post('tid',true);			$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);			$where = "  time > '$timetk' and time < '$timetj'  and lx = ".$tid." and type = 1 and is_over = 0 ";			if(empty($page))		    {                $start = 0;		    	$perpage = 20;            }		    else		    {                $start = ($page - 1)*$perpage;            }									$list = $this->whlabel_bh_transfer_cr->find_all($where,"*",'id asc',$start,$perpage);			$count = $this->whlabel_bh_transfer_cr->find_all($where,'COUNT(*) as total');			$total = $count[0]['total'];			$pagenum = ceil($total/$perpage);			$over = $total-($start+$perpage);			$final_list = [];			foreach($list as $k=>$v){				$transfer_info = $this->whlabel_bh_transfer->read($v['fid']);				$final_list[$k]['id'] = $v['id'];				$final_list[$k]['orderinfo'] = $transfer_info['orderinfo'];				$final_list[$k]['pm'] = $transfer_info['pm'];				$final_list[$k]['time'] = date('Y-m-d H:i:s',$v['time']);			}			$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));			echo json_encode($rows);exit;		}		$tid = $this->input->get('tid',true);		if(isset($_SESSION['api']))		{			$user = $this->user->get_api($_SESSION['api']);			$transfer = explode('|',trim($user['transfer'],'|'));			$stid = "";			foreach ($transfer as $value) 		    {				$stid .= " id = ".$value." or";			}			if(empty($transfer)){				exit("您的账号没有赋予车间权限");			}		}		else		{			header('Location: /');exit;		}		$transfer = $this->transfer->read($tid);		$this->data['transfer'] = $transfer;		$transfer_list  = $this->transfer->find_all( trim($stid,'or'));		$this->data['transfer_list'] = $transfer_list;				$this->_Template('whlabel_bh_cj_transfer_zklog',$this->data);	}	//针对车间的变动筛选条件的	public function _cj_transfer_log_count(){		$orderinfo = $this->input->post('orderinfo',true);		$tid = $this->input->post('tid',true);		$timetk = $this->input->post('timetk',true);		$timetj = $this->input->post('timetj',true);		$pm = $this->input->post('pm',true);		$start_time = strtotime($timetk);		$end_time = strtotime($timetj);		$where = " lx = ".$tid." and type = 1  and time >= ".$start_time." and time <= ".$end_time;		// if($orderinfo){		// 	$number_list  = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");		// 	$numbers = array_column($number_list,'number');		// 	$where.= " and number in (".implode(",",$numbers).") ";		// }				if($pm){			if(empty($orderinfo)){				exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));			}else{				$number_list  = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");				$numbers = array_column($number_list,'number');				if(empty($numbers)){					exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));				}				$where.= " and number in (".implode(",",$numbers).") ";			}		}else{			if($orderinfo){				$number_list  = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");				$numbers = array_column($number_list,'number');				if(empty($numbers)){					exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));				}				$where.= " and number in (".implode(",",$numbers).") ";			}		}		$log_list = $this->whlabel_bh_transfer_cr->find_all($where);		$wwcsl = $jszs = $wgzs = 0;		$tmp_list = [];		foreach($log_list as $k=>$v){			if(!isset($tmp_list[$v['fid']])){				$tmp_list[$v['fid']] = $v;				$jszs += 1;				if($v['is_over'] == 1){					$wgzs += 1;				}else{					$wwcsl += 1;				}			}		}		 		exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => $wwcsl,'jszs'=>$jszs,'wgzs'=>$wgzs]]));	}	//针对车间的变动筛选条件的	public function _cj_transfer_log_zkcount(){				$tid = $this->input->post('tid',true);				$timetk = $this->input->post('timetk',true);		$timetj = $this->input->post('timetj',true);		$timetk = strtotime($timetk);		$timetj = strtotime($timetj);		$where = "  time > '$timetk' and time < '$timetj'  and lx = ".$tid." and type = 1 and is_over = 0 ";		$count = $this->whlabel_bh_transfer_cr->find_all($where,'COUNT(*) as total');		$total = $count[0]['total'];		exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => $total]]));	}	public function _cj_transfer_detail($arg_array){		$number = $arg_array[0];		$tid = $arg_array[1];		$transfer_info = $this->transfer->read($tid);		$whlabel_bh_info = $this->whlabel_bh->find(" number = ".$number);		$final_list = [];				$log_list = $this->whlabel_bh_transfer_cr->find_all( " number = ".$number." and lx = ".$tid,"*","id asc");		$collect_list = [];		foreach($log_list as $k=>$v){			if(isset($final_list[$v['fid']])){				if($v['type'] == 1){					$final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);				}else{					$final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);				}			}else{				if($v['type'] == 1){					$final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);				}else{					$final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);				}			}					}				$this->data['whlabel_bh_info'] = $whlabel_bh_info;		$this->data['transfer_info'] = $transfer_info;		$this->data['final_list'] = $final_list;		$this->_Template('whlabel_bh_cj_transfer_detail',$this->data);	}	public function _excelwchz(){		$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['fexcel']))  		{    			$number = $this->input->get('number',true);    			$pm = $this->input->get('pm',true);    			$color = $this->input->get('color',true);    			$transfer = $this->input->get('transfer',true);    			$ktime = $this->input->get('timetk',true);    			$jtime = $this->input->get('timetj',true);    			$ktime = strtotime($ktime);    			$jtime = strtotime($jtime);    			$where = " ctime3 >= ".$ktime." and ctime3 <= ".$jtime." ";$gj = "";$ck = "";        			$where .=" and status = 2 and ck like '%|".$transfer."|%' ";    			if($number)                {                    $where  .= " and number like '%$number%'";                }    			    			if($pm)                {                    $where  .= " and pm like '%$pm%'";                }    			    			if($color)                {                    $where  .= " and features like '%-$color-%'";                }			              				$list = array();				$rows = $this->whlabel_bh_transfer->find_all($where,'id,wbid,orderinfo,jm,pm,time,label,cktime');							            	foreach($rows as $k=>$v){					$cktime = explode("|",trim($v['cktime'],"|"));					$f_cktime = end($cktime);            	    if(isset($list[$v['wbid']])){            	        $list[$v['wbid']]['sl'] =  $list[$v['wbid']]['sl'] + 1;            	        $list[$v['wbid']]['time'][] = date("Y-m-d H:i:s",$f_cktime);            	        $list[$v['wbid']]['label'][] = $v['label'];            	    }else{            	        $list[$v['wbid']] = [            	            'wbid'=>$v['wbid'],            	            'orderinfo'=>$v['orderinfo'],            	            'jm'=>$v['jm'],            	            'pm'=>$v['pm'],            	            'sl'=>1,            	            'time'=>[            	                date("Y-m-d H:i:s",$f_cktime)            	             ],            	             'label'=>[            	                $v['label'],                 	            ]            	       ];            	    }            	}				$filename = date("Y-m-d")."工厂备货完成汇总.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></tr>";				foreach ($list as $key=>$value) 				{ 					$str .= "<tr>";					$str .= "<td>". $value['wbid']. "</td>";					$str .= "<td>". $value['orderinfo']. "</td>";						$str .= "<td>". $value['jm']. "</td>";						$str .= "<td>". $value['pm']. "</td>";						$str .= "<td>". $value['sl']. "</td>";					$str .="<td>";					$tmp = "";					foreach($value['time'] as $kk=>$vv){					  $tmp .=$vv."<br/>";					}					$str .= trim($tmp,"<br/>");					$str .="</td>";					$str .="<td>";					$tmp_l = "";					foreach($value['label'] as $kk=>$vv){					    $tmp_l .= "`".$vv."<br/>";					}					$str .= trim($tmp_l,"<br/>");					$str .="</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 _excelcpkhz(){		// $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['fexcel']))  		{    			    			    			$transfer = $this->input->get('transfer',true);    			$ktime = $this->input->get('timetk',true);    			$jtime = $this->input->get('timetj',true);    			$ktime = strtotime($ktime);    			$jtime = strtotime($jtime);    			$where = " time >= ".$ktime." and time <= ".$jtime." and lx = " .$transfer." and type = 1 " ;$gj = "";$ck = "";    						          				$list = array();				$rows = $this->whlabel_bh_transfer_cr->find_all($where,'*');				foreach($rows as $k=>$v){					if(!isset($list['fid'])){						$list[$v['fid']] = [							'fid'=>$v['fid'],							'time'=>date("Y-m-d H:i:s",$v['time'])						];					}				}				            	$fid_list = array_column($list,'fid');				if(!empty($fid_list)){					$tmp_list = $this->whlabel_bh_transfer->find_all(" id in (".implode(",",$fid_list).") ","id,wbid,orderinfo,jm,pm,time,label","id asc");					$tmp_list = array_column($tmp_list,null,'id');					foreach($list as $k=>$v){						if(isset($tmp_list[$k])){							$list[$v['fid']]['wbid'] = $tmp_list[$k]['wbid'];							$list[$v['fid']]['orderinfo'] = $tmp_list[$k]['orderinfo'];							$list[$v['fid']]['jm'] = $tmp_list[$k]['jm'];							$list[$v['fid']]['pm'] = $tmp_list[$k]['pm'];							$list[$v['fid']]['sl'] = 1;							$list[$v['fid']]['label'] = $tmp_list[$k]['label'];						}					}				}else{					$list = [];				}								$filename = date("YmdHi",$ktime)."~".date("YmdHi",$jtime)."工厂成品库扫入库汇总.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>订单ID</td><td>编号</td><td>简码</td><td>品名</td><td>数量</td><td>扫描时间</td><td>扫描条码</td></tr>";				foreach ($list as $key=>$value) 				{ 					$str .= "<tr>";					$str .= "<td>". $key. "</td>";					$str .= "<td>". $value['wbid']. "</td>";					$str .= "<td>". $value['orderinfo']. "</td>";						$str .= "<td>". $value['jm']. "</td>";						$str .= "<td>". $value['pm']. "</td>";						$str .= "<td>". $value['sl']. "</td>";					$str .= "<td>".$value['time']."</td>";					$str .= "<td>`".$value['label']."</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); 		}	}	/**	 * 使用的是orderinfo作为唯一标识	 */	private function _check_by_number(){		$orderinfo = $this->input->post('orderinfo',true);		$orderinfo = trim($orderinfo);		if(empty($orderinfo)){			exit(json_encode(['code'=>-1,'msg'=>'单号不能为空']));		}		$info = $this->whlabel_bh->find(" orderinfo like '%".$orderinfo."%'");		if(empty($info)){			exit(json_encode(['code'=>-1,'msg'=>'未找到该订单']));		}else{			exit(json_encode(['code'=>1,'msg'=>'未找到该订单']));		}	}		// 根据表单的时间导出成品库扫入库汇总excel	private function _cj_transfer_scanout_excel(){		$ktime = $this->input->get('timetk',true);		$jtime = $this->input->get('timetj',true);		$ktime = strtotime($ktime);		$jtime = strtotime($jtime);		$tid = $this->input->get('tid',true);				$transfer_info = $this->transfer->read($tid);				$where = " time >=  ".$ktime."  and  time  <=  ".$jtime."  and  lx  =  ".$tid."  and  type  =  2 ";		$list = $this->whlabel_bh_transfer_cr->find_all($where,"*","id asc");		$final_list = [];		foreach($list as $k=>$v){			if(isset($final_list[$v['number']])){				$final_list[$v['number']]['sl'] =  $final_list[$v['number']]['sl'] + 1;				$final_list[$v['number']]['scanout_time'][] = date("Y~m~d H:i:s",$v['time']);			}else{				$tmp_info = $this->whlabel_bh_transfer->read($v['fid']);				$final_list[$v['number']] = [					"orderinfo"=>empty($tmp_info['orderinfo'])?"":$tmp_info['orderinfo'],					"pm"=>$tmp_info['pm'],					"jm"=>$tmp_info['jm'],					"sl"=>1,					"scanout_time"=>[						date("Y~m~d H:i:s",$v['time'])					]				];			}		}		$filename = date("Ymd",$ktime)."~".date("Ymd",$jtime).$transfer_info['title']."扫出库汇总.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>订单号</td><td>品名</td><td>简码</td><td>数量</td><td>扫出时间</td></tr>";		foreach ($final_list as $key=>$value) 		{ 			$str .= "<tr>";			$str .= "<td>". $value['orderinfo']. "</td>";			$str .= "<td>". $value['pm']. "</td>";			$str .= "<td>". $value['jm']. "</td>";				$str .= "<td>". $value['sl']. "</td>";			$tmp = "<td>";			foreach($value['scanout_time'] as $kk=>$vv){				if($kk == 0){					$tmp .= $vv;				}else{					$tmp .= "<br/>".$vv;				}			}			$tmp .= "</td>";			$str .= $tmp;			$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 _cj_transfer_scanout_xzlog(){		$ktime = $this->input->get('timetk',true);		$jtime = $this->input->get('timetj',true);		$ktime = strtotime($ktime);		$jtime = strtotime($jtime);		$tid = $this->input->get('tid',true);				$transfer_info = $this->transfer->read($tid);				$where = " time >=  ".$ktime."  and  time  <=  ".$jtime."  and  lx  =  ".$tid."  and  type  =  2 ";		$list = $this->whlabel_bh_transfer_cr->find_all($where,"*","id asc");		$final_list = [];		foreach($list as $k=>$v){			$final_list[] = [				'id'=>$v['id'],				'fid'=>$v['fid'],				'lx'=>$transfer_info['title'],				'type'=>($v['type'] == 1)?"入库":"出库",				'time'=>date("Y~m~d H:i:s",$v['time']),			];		}		$filename = date("Ymd",$ktime)."~".date("Ymd",$jtime).$transfer_info['title']."扫出库日志记录.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>流转条码ID</td><td>部门</td><td>类型</td><td>扫出时间</td></tr>";		foreach ($final_list as $key=>$value) 		{ 			$str .= "<tr>";			$str .= "<td>". $value['id']. "</td>";			$str .= "<td>". $value['fid']. "</td>";			$str .= "<td>". $value['lx']. "</td>";			$str .= "<td>". $value['type']. "</td>";				$str .= "<td>". $value['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); 	}}
 |