Transfer.php 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Transfer extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_user','user');
  7. $this->load->_model('Model_transfer','transfer');
  8. $this->load->_model('Model_typeclass','typeclass');
  9. $this->load->_model('Model_warehouse','warehouse');
  10. $this->load->_model('Model_systemtransfer','systemtransfer');
  11. $this->load->_model('Model_excel','excel');
  12. $this->load->_model('Model_fullorder','fullorder');
  13. $this->load->_model('Model_fullordertt','fullordertt');
  14. $this->load->_model('Model_fullordersmt','fullordersmt');
  15. $this->load->_model('Model_purchase','purchase');
  16. $this->load->_model('Model_classid','classid');
  17. $this->load->_model('Model_express','express');
  18. $this->load->_model('Model_apiyy','apiyy');
  19. $this->load->_model('Model_shop','shop');
  20. $this->load->_model('Model_systemtransfer_cr','systemtransfer_cr');
  21. $this->load->_model("Model_logic_ding","logic_ding");
  22. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  23. $this->load->_model("Model_logic_order","logic_order");
  24. }
  25. //定义方法的调用规则 获取URI第二段值
  26. public function _remap($arg,$arg_array)
  27. {
  28. if($arg == 'add')
  29. {
  30. $this->_add();
  31. }
  32. else if($arg == 'edit')
  33. {
  34. $this->_edit($arg_array);
  35. }
  36. else if($arg == 'del')
  37. {
  38. $this->_del();
  39. }
  40. else if($arg == 'print')
  41. {
  42. $this->_print();
  43. }
  44. else if($arg == 'number')
  45. {
  46. $this->_number();
  47. }
  48. else if($arg == 'numberprint')
  49. {
  50. $this->_numberprint();
  51. }
  52. else if($arg == 'operate')
  53. {
  54. $this->_operate();
  55. }
  56. else if($arg == 'out')
  57. {
  58. $this->_out();
  59. }
  60. else if($arg == 'excel')
  61. {
  62. $this->_excel();
  63. }
  64. else if($arg == 'bdbb')
  65. {
  66. $this->_bdbb();
  67. }
  68. else if($arg == 'rk')
  69. {
  70. $this->_rk();
  71. }
  72. else if($arg == 'cqrk'){
  73. $this->_cqrk();
  74. }
  75. else if($arg == 'ck')
  76. {
  77. $this->_ck();
  78. }
  79. else if($arg == 'jgl')//交工率
  80. {
  81. $this->_jgl();
  82. }
  83. else if($arg == 'linqi')
  84. {
  85. $this->_linqi();
  86. }
  87. else if($arg == 'jiaji'){
  88. $this->_jiaji();
  89. }
  90. else if($arg == 'overtime_export'){
  91. $this->_overtime_export();
  92. }
  93. else if($arg == 'scz'){
  94. $this->_scz();
  95. }
  96. else if($arg == 'wjsrk'){
  97. $this->_wjsrk();
  98. }
  99. else if($arg == 'wjsrkexcel'){
  100. $this->_wjsrkexcel();
  101. }
  102. else if($arg == 'cqrkexcel'){
  103. $this->_cqrkexcel();
  104. }
  105. else if($arg == 'sczexcel'){
  106. $this->_sczexcel();
  107. }else if($arg == 'czbmsfcz'){
  108. $this->_czbmIsOutExcel();
  109. }else if($arg == 'ycrk'){
  110. $this->_ycrk();
  111. }else if($arg == 'ycrkindex'){
  112. $this->_ycrkindex();
  113. }
  114. else
  115. {
  116. $this->_index();
  117. }
  118. }
  119. //管理
  120. public function _index()
  121. {
  122. $t = array();
  123. $typeclass = $this->typeclass->find_all();
  124. foreach ($typeclass as $v)
  125. {
  126. $t[$v['id']] = $v['title'];
  127. }
  128. $post = $this->input->post(NULL, TRUE);
  129. if(isset($post['page']))
  130. {
  131. $page = $this->input->post('page',true);
  132. $perpage = $this->input->post('perpage',true);
  133. $type = $this->input->post('type',true);
  134. $where = "1=1 ";
  135. //数据排序
  136. $order_str = "id asc";
  137. if($type)
  138. {
  139. $where .= "and type = '$type'";
  140. }
  141. if(empty($page))
  142. {
  143. $start = 0;
  144. $perpage = 1;
  145. }
  146. else
  147. {
  148. $start = ($page - 1)*$perpage;
  149. }
  150. //取得信息列表
  151. $info_list = $this->transfer->find_all($where,'id,title,orvertime,overtime_one,overtime_two',$order_str,$start,$perpage);
  152. $total = $this->transfer->find_count($where);
  153. $pagenum = ceil($total/$perpage);
  154. $over = $total-($start+$perpage);
  155. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  156. echo json_encode($rows);exit;
  157. }
  158. $this->_Template('transfer',$this->data);
  159. }
  160. //添加
  161. public function _add()
  162. {
  163. $post = $this->input->post(NULL, TRUE);
  164. if(isset($post['title']))
  165. {
  166. $title = $this->input->post('title',true);
  167. if($this->transfer->find_all("title = '$title'"))
  168. {
  169. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  170. }
  171. if($this->transfer->insert($post))
  172. {
  173. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  174. }
  175. else
  176. {
  177. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  178. }
  179. }
  180. $this->_Template('transfer_add',$this->data);
  181. }
  182. //修改
  183. public function _edit($arg_array)
  184. {
  185. $post = $this->input->post(NULL, TRUE);
  186. if(isset($post['id']))
  187. {
  188. $id = $this->input->post('id',true);
  189. $title = $this->input->post('title',true);
  190. if($this->transfer->find_all("title = '$title' and id != '".$id."'"))
  191. {
  192. echo json_encode(array('msg'=>'名称重复!','success'=>false));exit;
  193. }
  194. if($this->transfer->save($post,$id))
  195. {
  196. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  197. }
  198. else
  199. {
  200. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  201. }
  202. }
  203. $arg_array = $arg_array[0];
  204. $transfer = $this->transfer->read($arg_array);
  205. $this->data['transfer'] = $transfer;
  206. $this->_Template('transfer_edit',$this->data);
  207. }
  208. //删除
  209. public function _del()
  210. {
  211. $post = $this->input->post(NULL, TRUE);
  212. if(isset($post['s']))
  213. {
  214. $id_arr = $this->input->post('s');
  215. $id_arr = explode(',',$id_arr);
  216. if(!$id_arr)
  217. {
  218. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  219. }
  220. //循环删除记录
  221. foreach ($id_arr as $v)
  222. {
  223. $this->transfer->remove($v);
  224. }
  225. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  226. }
  227. }
  228. public function _print()
  229. {
  230. if(isset($_SESSION['api']))
  231. {
  232. $user = $this->user->get_api($_SESSION['api']);
  233. $usp = $user;
  234. $sid = "";$wid="";$wtype="";
  235. $userwh = explode('|',trim($user['warehouse'],'|'));
  236. foreach ($userwh as $value)
  237. {
  238. $wid .= " id = ".$value." or";
  239. $wtype .= " type = ".$value." or";
  240. }
  241. }
  242. $post = $this->input->post(NULL, TRUE);
  243. $classid = $this->classid->sku();
  244. $pm = $classid;
  245. $scsku = $classid;
  246. if(isset($post['category']))
  247. {
  248. $list = array();$num = "";$title = "";$features = "";
  249. $order = 0;
  250. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  251. $t = $this->input->post('t',true);//打印数量
  252. if($xbqnum > 99)
  253. {
  254. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  255. }
  256. if($xbqnum < 1)
  257. {
  258. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  259. }
  260. $post['purchase'] = $this->input->post('purchase',true);//所属工厂
  261. $category = $this->input->post('category',true);
  262. $list['category'] = $category;
  263. $list['hairtype'] = $this->input->post('hairtype',true);
  264. $list['grade'] = $this->input->post('grade',true);
  265. $size = $this->input->post('size',true);
  266. $xzsku = $this->input->post('xzsku',true);
  267. $list['size'] = rtrim($size,',');
  268. $list['hairnumber'] = $this->input->post('hairnumber',true);
  269. $list['extension'] = $this->input->post('extension',true);
  270. if($category == 1297)
  271. {
  272. $list['sywignumber'] = $this->input->post('sywignumber',true);
  273. }
  274. if($category == 1702)
  275. {
  276. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  277. $list['syother'] = $this->input->post('syother',true);
  278. }
  279. if($category == 133)
  280. {
  281. $list['fittype'] = $this->input->post('fittype',true);
  282. $list['acother'] = $this->input->post('acother',true);
  283. }
  284. $list['color'] = $this->input->post('color',true);
  285. $list['lowe'] = $this->input->post('lowe',true);
  286. if($category == 127)
  287. {
  288. $list['type'] = $this->input->post('type',true);
  289. $list['headroad'] = $this->input->post('headroad',true);
  290. $list['density'] = $this->input->post('density',true);
  291. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  292. {
  293. $list['lacesize'] = $this->input->post('lacesize',true);
  294. }
  295. $list['lacecolor'] = $this->input->post('lacecolor',true);
  296. $list['lacetypes'] = $this->input->post('lacetypes',true);
  297. }
  298. if($category == 128)
  299. {
  300. $list['lacetype'] = $this->input->post('lacetype',true);
  301. $list['haircap'] = $this->input->post('haircap',true);
  302. $list['density'] = $this->input->post('density',true);
  303. $list['lacecolor'] = $this->input->post('lacecolor',true);
  304. $list['lacetypes'] = $this->input->post('lacetypes',true);
  305. $list['wigother'] = $this->input->post('wigother',true);
  306. $list['wigother1'] = $this->input->post('wigother1',true);
  307. $list['wigother2'] = $this->input->post('wigother2',true);
  308. $list['product_related'] = $this->input->post('product_related', true);
  309. }
  310. if($category == 129)
  311. {
  312. $list['wide'] = $this->input->post('wide',true);
  313. }
  314. if($category == 131)
  315. {
  316. $list['gifttype'] = $this->input->post('gifttype',true);
  317. $list['giftother'] = $this->input->post('giftother',true);
  318. }
  319. if($category == 134)
  320. {
  321. $list['pieceweight'] = $this->input->post('pieceweight',true);
  322. }
  323. if($category == 1297)
  324. {
  325. $list['synthetictype'] = $this->input->post('synthetictype',true);
  326. $list['sywigother'] = $this->input->post('sywigother',true);
  327. }
  328. if($category == 130 || $category == 133 || $category == 1702)
  329. {
  330. $list['items'] = $this->input->post('items',true);
  331. $list['weight'] = $this->input->post('weight',true);
  332. }
  333. if($category == 1702)
  334. {
  335. $list['syhairther'] = $this->input->post('syhairther',true);
  336. }
  337. if($category == 130){
  338. $list['jfother'] = $this->input->post('jfother', true);
  339. }
  340. foreach($list as $k=>$v)
  341. {
  342. if($v != 0)
  343. {
  344. $num .=$v;
  345. $features .=$v.'-';
  346. $post[$k] = $v;
  347. $typeclass = $this->typeclass->read($v);
  348. if(isset($pm[$typeclass['classid']]))
  349. {
  350. $pm[$typeclass['classid']] = $typeclass['zh'];
  351. }
  352. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  353. if($k != 'size')
  354. {
  355. $title .= $typeclass['title']." ";
  356. }
  357. }
  358. }
  359. $typeclass = $this->typeclass->read($list['size']);
  360. $title .= $typeclass['title'];
  361. $time = time();
  362. $post['printtime'] = $time;
  363. $post['title'] = rtrim($title,' ');
  364. $post['number'] = $num;
  365. $post['features'] = '-'.$features;
  366. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  367. $featurespp = explode('-',trim($featurespp,'-'));
  368. if(isset($featurespp[5]))
  369. {
  370. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  371. }
  372. else
  373. {
  374. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  375. }
  376. $post['time'] = $time;//操作时间
  377. $scsku = implode("-",$scsku);
  378. $zh = implode(" ",$pm);
  379. $zh = str_replace('自然色 ','',trim($zh,' '));
  380. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  381. $post['shipremarks'] = $zh;
  382. $scsku = str_replace('- ','-',trim($scsku,'-'));
  383. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  384. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;
  385. $post['sku'] = $bqsku;
  386. $post['rk'] = "|1|";//默认配货 打印后直接入库
  387. $post['rktime'] = "|".$time."|";
  388. $rows = array();
  389. $this->db->trans_begin();
  390. for($i=0;$i<$xbqnum;$i++)
  391. {
  392. $label = substr($time,1)*100;
  393. $post['label'] = $label+$i;
  394. $rows[] = array('num'=>$post['label'],'number'=>'','shipremarks'=>$zh,'ex'=>'','t'=>$t,'time'=>'布标打印时间:'.date('Y-m-d H:i:s',$time),'s'=>'('.($i+1).'/'.$xbqnum.')');
  395. $this->systemtransfer->insert($post);
  396. }
  397. if ($this->db->trans_status() === TRUE)
  398. {
  399. $this->db->trans_commit();
  400. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  401. }
  402. else
  403. {
  404. $this->db->trans_rollback();
  405. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  406. }
  407. }
  408. $purchase = $this->purchase->find_all("yyid != ''");
  409. $this->data['purchase'] = $purchase;
  410. $this->_Template('transfer_print',$this->data);
  411. }
  412. public function _number()
  413. {
  414. if(isset($_SESSION['api']))
  415. {
  416. $user = $this->user->get_api($_SESSION['api']);
  417. $pid = "";$tid="";$sid="";$wid="";
  418. $purchase = explode('|',trim($user['purchase'],'|'));
  419. $transfer = explode('|',trim($user['transfer'],'|'));
  420. foreach ($purchase as $value)
  421. {
  422. $pid .= " id = ".$value." or";
  423. }
  424. foreach ($transfer as $value)
  425. {
  426. $tid .= " id = ".$value." or";
  427. }
  428. }
  429. else
  430. {
  431. header('Location: /');exit;
  432. }
  433. $post = $this->input->post(NULL, TRUE);
  434. if(isset($post['number']))
  435. {
  436. $number = $this->input->post('number',true);
  437. $type = $this->input->post('type',true);
  438. $xbqnum = $this->input->post('xbqnum',true);//打印数量
  439. $purchase = $this->input->post('purchase',true);
  440. // $f = 'fullorder';
  441. // $y = $this->fullorder->get_number($number);
  442. // if(!$y)
  443. // {
  444. // $f = 'fullordersmt';
  445. // $y = $this->fullordersmt->get_number($number);
  446. // if(!$y)
  447. // {
  448. // $f = 'fullordertt';
  449. // $y = $this->fullordertt->get_number($number);
  450. // if(!$y)
  451. // {
  452. // echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  453. // }
  454. // }
  455. // }
  456. $y = $this->logic_order->getInfo("number = '".$number."'");
  457. if(!$y)
  458. {
  459. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  460. }
  461. $f = $y['lv_platform'];
  462. if($y['librarytime'] > 0)
  463. {
  464. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  465. }
  466. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;$typeclass = array();
  467. $classid = $this->classid->sku();
  468. $tc = $this->typeclass->find_all();
  469. foreach($tc as $v)
  470. {
  471. $typeclass[$v['id']] = $v;
  472. }
  473. $bm = '03';
  474. $fpdata = explode(';',trim($y['fpdata'],';'));
  475. $whlabelsc = explode('|',trim($y['whlabel'],'|'));
  476. foreach($fpdata as $key=>$val)
  477. {
  478. $pm = $classid;
  479. $jm = $classid;
  480. $sku = $classid;
  481. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  482. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
  483. $jvnr = explode('|',trim($features,'|'));
  484. if(stripos($jvnr[0],',') !== false)
  485. {
  486. $ft = explode(',',$jvnr[0]);
  487. $features = explode('-',trim($ft[1],'-'));
  488. array_splice($features,2,0,$ft[0]);
  489. }
  490. else
  491. {
  492. $features = explode('-',trim($jvnr[0],'-'));
  493. }
  494. $title = $jvnr[1];
  495. foreach($features as $k=>$v)
  496. {
  497. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  498. {
  499. if($typeclass[$v]['bm'] != '')
  500. {
  501. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  502. }
  503. }
  504. if($v != 0)
  505. {
  506. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  507. if(isset($pm[$typeclass[$v]['classid']]))
  508. {
  509. if($typeclass[$v]['title'] == '9A')
  510. {
  511. $pm[$typeclass[$v]['classid']] = '9A';
  512. }
  513. else if($typeclass[$v]['title'] == '10A')
  514. {
  515. $pm[$typeclass[$v]['classid']] = '10A';
  516. }
  517. else
  518. {
  519. $clzh = $typeclass[$v]['zh'];
  520. if(stripos($typeclass[$v]['zh'],'|') !== false)
  521. {
  522. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  523. $clzh = $clzh[0];
  524. }
  525. $pm[$typeclass[$v]['classid']] = $clzh;
  526. }
  527. }
  528. if(isset($jm[$typeclass[$v]['classid']]))
  529. {
  530. if($typeclass[$v]['jm'])
  531. {
  532. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  533. }
  534. }
  535. }
  536. }
  537. $jm = array_filter($jm);//去除空值
  538. $jm = implode("-",$jm);
  539. $sku = array_filter($sku);//去除空值
  540. $sku = implode("-",$sku);
  541. $pm = array_filter($pm);//去除空值
  542. $zh = implode(" ",$pm);
  543. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  544. $features = implode("-",$features);
  545. $y['shipremarks'] = str_replace("'",'"',$y['shipremarks']);
  546. $cp[] = array('ordernumber'=>$number,'title'=>$title,'sku'=>$sku,'jm'=>$jm,'zh'=>$zh,'n'=>$jvnr[2],'b'=>$y['shipremarks'],'is_jiaji'=>$y['is_jiaji'],'data'=>json_encode(array('ordernumber'=>$number,'features'=>$features,'number'=>$number,'title'=>$title,'jm'=>$jm,'sku'=>$sku,'pm'=>$zh,'bm'=>$bm.implode("",$bmpx))));
  547. }
  548. ob_clean();
  549. echo json_encode(array('rows'=>$cp,'success'=>true));exit;
  550. }
  551. $purchase = $this->purchase->find_all("yyid != ''");
  552. $this->data['purchase'] = $purchase;
  553. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  554. $this->data['transfer'] = $transfer;
  555. $this->_Template('transfer_number',$this->data);
  556. }
  557. public function _numberprint()
  558. {
  559. $time = time();
  560. $post = $this->input->post(NULL);
  561. $classid = $this->classid->sku();
  562. $pm = $classid;
  563. $scsku = $classid;
  564. if(isset($post['data']))
  565. {
  566. $data = json_decode($post['data'],true);
  567. // $f = 'fullorder';
  568. // $y = $this->fullorder->get_number($data['ordernumber']);
  569. // if(!$y)
  570. // {
  571. // $f = 'fullordersmt';
  572. // $y = $this->fullordersmt->get_number($data['ordernumber']);
  573. // if(!$y)
  574. // {
  575. // $f = 'fullordertt';
  576. // $y = $this->fullordertt->get_number($data['ordernumber']);
  577. // if(!$y)
  578. // {
  579. // echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit;
  580. // }
  581. // }
  582. // }
  583. $y = $this->logic_order->getInfo("number = '".$data['ordernumber']."'");
  584. if(!$y)
  585. {
  586. echo json_encode(array('msg'=>$data['ordernumber'].'没有找到此订单,请检查是否扫描错误'.$data['ordernumber'],'success'=>false));exit;
  587. }
  588. $f = $y['lv_platform'];
  589. if($y['printtime'] == 0)
  590. {
  591. echo json_encode(array('msg'=>'此单已重置,请询问梦体','success'=>false));exit;
  592. }
  593. $order = 0;$time = time();
  594. $xbqnum = $this->input->post('n',true);//打印数量
  595. if($xbqnum > 99)
  596. {
  597. echo json_encode(array('msg'=>'打印数量不可超过99!','success'=>false));exit;
  598. }
  599. if($xbqnum < 1)
  600. {
  601. echo json_encode(array('msg'=>'打印数量错误!','success'=>false));exit;
  602. }
  603. $transfer = $this->input->post('transfer',true);
  604. $post['type'] = $this->input->post('type',true);
  605. $post['shipremarks'] = $this->input->post('b',true);
  606. $post['ph'] = $this->input->post('ph',true);
  607. $is_jiaji = $this->input->post('is_jiaji',true);
  608. if($is_jiaji == 2){
  609. $post['is_jiaji'] = 2;
  610. }else{
  611. $post['is_jiaji'] = 0;
  612. }
  613. $zps = $this->input->post('zps',true);
  614. $post['purchase'] = $this->input->post('purchase',true);//供应商
  615. $post['time'] = $time;//操作时间
  616. $post['jm'] = $data['jm'];
  617. $post['bm'] = $data['bm'];
  618. $post['pm'] = $data['pm'];
  619. $post['features'] = $data['features'];
  620. $post['number'] = $data['number'];
  621. $post['title'] = $data['title'];
  622. $post['sku'] = $data['sku'];
  623. $post['printtime'] = $y['printtime'];
  624. $post['rk'] = "|12|";//默认订单中心 打印后直接入库
  625. $post['ck'] = "|12|";
  626. $post['rktime'] = "|".$time."|";
  627. $post['cktime'] = $post['rktime'];
  628. $post['ctime12'] = $time;
  629. $express = $this->express->read($y['express']);
  630. $rows = array();$t='';
  631. $this->db->trans_begin();
  632. $post['xbqnum'] = $xbqnum;
  633. $kh = $this->shop->read($y['shop']);
  634. $yy = $this->apiyy->_peihuo($post,$kh['yyid'],$y['number'],$post['xbqnum']);
  635. //$this->logic_ding->sendToDing("小布表打印异常".json_encode($yy)."|".json_encode($y['number']));
  636. if($yy['c'] == 0)
  637. {
  638. $post['scapi'] = '99';
  639. $post['scid'] = $yy['scid'];
  640. if(!$post['purchase'])
  641. {
  642. $post['purchase'] = '';
  643. }
  644. $mqsl = $this->systemtransfer->find_count("number = '".$data['number']."'");
  645. //able_ext 实在打印小单布标时判断是否可以打印备货单
  646. $able_ext = 0;
  647. $tmp_fetaures = explode('-',$data['features']);
  648. //只有头套和马尾才会要配货单
  649. if(in_array(128, $tmp_fetaures)){
  650. $able_ext = 1;
  651. }
  652. if(in_array(133, $tmp_fetaures)){
  653. if(in_array(673, $tmp_fetaures)){
  654. $able_ext = 1;
  655. }
  656. }
  657. for($i=0;$i<$xbqnum;$i++)
  658. {
  659. if($post['zps'])
  660. {
  661. if($post['zps'] > 0)
  662. {
  663. $t = '总量:'.($mqsl+$i+1).'/'.$zps;
  664. }
  665. }
  666. $label = $time.rand(1000,9999); //substr($time,1)*100;
  667. $post['label'] = $label+$i;
  668. $rows[] = array('num'=>$post['label'],'number'=>$post['number'],'shipremarks'=>$post['shipremarks'],'ph'=>$post['ph'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$post['printtime']),'gtime'=>date('YmdH',time()),'s'=>'('.($i+1).'/'.$xbqnum.')','t'=>$t,'able_ext'=>$able_ext,'is_jiaji'=>$is_jiaji);
  669. $this->systemtransfer->insert($post);
  670. }
  671. }
  672. else
  673. {
  674. $this->db->trans_rollback();
  675. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  676. }
  677. if($this->db->trans_status() === TRUE)
  678. {
  679. $this->db->trans_commit();
  680. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  681. }
  682. else
  683. {
  684. $this->db->trans_rollback();
  685. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  686. }
  687. }
  688. }
  689. public function _operate()
  690. {
  691. $post = $this->input->post(NULL, TRUE);
  692. if(isset($post['page']))
  693. {
  694. $api = $this->input->post('api',true);
  695. $page = $this->input->post('page',true);
  696. $perpage = $this->input->post('perpage',true);
  697. $number = $this->input->post('number',true);
  698. $color = $this->input->post('color',true);
  699. $purchase = $this->input->post('purchase',true);
  700. $transfer = $this->input->post('transfer',true);
  701. $lx = $this->input->post('lx',true);
  702. $type = $this->input->post('type',true);
  703. $pm = $this->input->post('pm',true);
  704. $jiaji = $this->input->post('jiaji',true);
  705. $xztime = $this->input->post('xztime',true);
  706. $timetk = $this->input->post('timetk',true);
  707. $timetj = $this->input->post('timetj',true);
  708. $timetk = strtotime($timetk);
  709. $timetj = strtotime($timetj);
  710. $where = '1=1';
  711. if($number)
  712. {
  713. $where .= " and number = '$number'";
  714. }
  715. if($pm){
  716. $where .= " and pm like '%".$pm."%'";
  717. }
  718. if($purchase)
  719. {
  720. $where .= " and purchase = '$purchase'";
  721. }
  722. if($color)
  723. {
  724. $where .= " and fpdata like '%-".$color."-%'";
  725. }
  726. if($lx)
  727. {
  728. if($lx == 1)
  729. {
  730. $where .= " and ordernumber = ''";
  731. }
  732. else
  733. {
  734. $where .= " and ordernumber != ''";
  735. }
  736. }
  737. if($jiaji){
  738. if($jiaji == 1){
  739. $where .= " and is_jiaji = 0";
  740. }
  741. if($jiaji == 2){
  742. $where .= " and is_jiaji = 2";
  743. }
  744. }
  745. //数据排序
  746. $order_str = "id desc";
  747. if(empty($page))
  748. {
  749. $start = 0;
  750. $perpage = 1;
  751. }
  752. else
  753. {
  754. $start = ($page - 1)*$perpage;
  755. }
  756. if($xztime == 'printtime')
  757. {
  758. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  759. if($type)
  760. {
  761. if($type == 3){
  762. if($transfer)
  763. {
  764. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  765. }
  766. }else{
  767. $type = ($type==1)?'rk':'ck';
  768. if($transfer)
  769. {
  770. $where .= " and $type like '%|".$transfer."|%'";
  771. }
  772. }
  773. }
  774. else
  775. {
  776. if($transfer)
  777. {
  778. $where .= " and rk like '%|".$transfer."|%'";
  779. }
  780. }
  781. }
  782. else
  783. {
  784. $cr = "time > '$timetk' and time < '$timetj'";
  785. if($transfer)
  786. {
  787. $cr .= " and lx = '".$transfer."' ";
  788. }
  789. if($type)
  790. {
  791. if($type == 3){
  792. $cr .= " and is_over = 0 ";
  793. }else{
  794. $cr .= " and type = '".$type."' ";
  795. }
  796. }
  797. $fid = '';
  798. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  799. foreach ($info_list_cr as $v)
  800. {
  801. $fid .= "id = '".$v['fid']."' or ";
  802. }
  803. if($fid)
  804. {
  805. $where .= ' and ('.trim($fid,'or ').')';
  806. }
  807. else
  808. {
  809. $where .= ' and id = 0';
  810. }
  811. }
  812. //取得信息列表
  813. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  814. $transfer = $this->transfer->find_all();
  815. $t = array();
  816. $t[0] = "";
  817. foreach ($transfer as $v)
  818. {
  819. $t[$v['id']] = $v['title'];
  820. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  821. }
  822. //格式化数据
  823. foreach ($info_list as $key=>$value)
  824. {
  825. if($value['is_jiaji'] == 2){
  826. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  827. }else{
  828. $info_list[$key]['is_jiaji'] = "常规";
  829. }
  830. // if(empty($value['ycrk_type'])){
  831. // $info_list[$key]['ycrk_type'] = "<p style='background-color: #f0f0f0 !important;color:#000 !important' onclick='addYcrk(".$value['id'].")'>异常入库</p>";
  832. // }else{
  833. // $info_list[$key]['ycrk_type'] = "";
  834. // }
  835. $dd = $this->systemtransfer->read($value['id']);
  836. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  837. $rk = explode('|',trim($dd['rk'],'|'));
  838. $rktime = explode('|',trim($dd['rktime'],'|'));
  839. $ck = explode('|',trim($dd['ck'],'|'));
  840. $cktime = explode('|',trim($dd['cktime'],'|'));
  841. $info_list[$key]['time'] = '';
  842. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  843. //"<h9 class='window' data-h='/returngoods/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p></h9>"
  844. $info_list[$key]['number'] = "<h9 class='window' data-h='/colour/seebynumber/".$value['number']."' data-t='订单号:".$value['number']."'><p>".$value['number']."</p></h9>";
  845. /**
  846. for($i=0;$i<count($rk);$i++)
  847. {
  848. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  849. {
  850. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  851. }
  852. else
  853. {
  854. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  855. }
  856. $info_list[$key]['time'] .= $d;
  857. if(isset($ck[$i]) && $ck[$i] != '')
  858. {
  859. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  860. }
  861. }
  862. **/
  863. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  864. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  865. foreach ($data as $k=>$v)
  866. {
  867. // $type = ($v['type']==1)?'入库':'出库';
  868. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  869. $type = ($v['type']==1)?'入库':'出库';
  870. if($v['orver_flag'] == 1){
  871. if($v['is_over'] == 0){
  872. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></a>";
  873. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  874. }else{
  875. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  876. }
  877. }elseif($v['orver_flag'] == 2){
  878. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></a>";
  879. }elseif($v['orver_flag'] == 3){
  880. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></a>";
  881. }elseif(($v['orver_flag'] == 0)&&(empty($v['lx']))){
  882. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:red'>订单已完成:".date('Y-m-d H:i',$v['time']) ."</a>";
  883. }else{
  884. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  885. }
  886. if($v['extra_status'] == 1){
  887. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  888. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  889. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  890. }else{
  891. $info_list[$key]['time'] .= "<br>";
  892. }
  893. }
  894. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  895. unset($info_list[$key]['ctime12']);
  896. }
  897. $total = $this->systemtransfer->find_count($where);
  898. $pagenum = ceil($total/$perpage);
  899. $over = $total-($start+$perpage);
  900. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  901. echo json_encode($rows);exit;
  902. }
  903. if(isset($_SESSION['api']))
  904. {
  905. $user = $this->user->get_api($_SESSION['api']);
  906. $usp = $user;
  907. $pid = "";$tid="";$sid="";$wid="";
  908. $purchase = explode('|',trim($user['purchase'],'|'));
  909. $transfer = explode('|',trim($user['transfer'],'|'));
  910. $warehouse = explode('|',trim($user['warehouse'],'|'));
  911. foreach ($purchase as $value)
  912. {
  913. $pid .= " id = ".$value." or";
  914. }
  915. foreach ($transfer as $value)
  916. {
  917. $tid .= " id = ".$value." or";
  918. }
  919. foreach ($warehouse as $value)
  920. {
  921. $wid .= " id = ".$value." or";
  922. }
  923. }
  924. else
  925. {
  926. header('Location: /');exit;
  927. }
  928. $sc_flag = 0; //生产中按钮的标识符号 为1的是可以查看 0 不可以
  929. //只有admin和toutao用户可以查看
  930. if(in_array($user['id'],[10,44,50])){
  931. $sc_flag = 1;
  932. }
  933. $this->data['sc_flag'] = $sc_flag;
  934. $kx = '';$zjtab = '';
  935. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  936. $this->data['warehouse'] = $warehouse;
  937. $purchase = $this->purchase->find_all("yyid != ''");
  938. $this->data['purchase'] = $purchase;
  939. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  940. $this->data['transfer'] = $transfer;
  941. $this->data['vip'] = $user['vip'];
  942. $transfer_ids = array_column($transfer,'id');
  943. $transfer_str = implode(",",$transfer_ids);
  944. $this->data['cz_1_num'] = $this->systemtransfer_cr->find_count("orver_flag = 1 and is_over = 0 and time > ".(time()-3600*24*14) ." and lx in (".$transfer_str.")");
  945. $this->data['cz_2_num'] = $this->systemtransfer_cr->find_count("orver_flag = 2 and is_over = 0 and time > ".(time()-3600*24*14) ." and lx in (".$transfer_str.")");
  946. //$jiaji_num = 0;
  947. // $jiaji_num = $this->systemtransfer->find_count(" is_jiaji = 2 and time > ".(time()-3600*24*7)." and rk not like '%|11|%'" );
  948. foreach($transfer_ids as $k=>$v){
  949. if($v == 11){
  950. unset($transfer_ids[$k]);
  951. }
  952. }
  953. if(empty($transfer_ids)){
  954. $this->data['jiaji_num'] = -1;
  955. }else{
  956. $transfer_str = implode(",",$transfer_ids);
  957. $sql_r = $this->db->query("select s.id,s.is_jiaji,s.rk,c.is_over,c.time,c.lx,c.id from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".(time()-3600*24*14) ." and c.lx in (".$transfer_str.") where s.is_jiaji = 2 and s.rk not like '%|11|%'");
  958. // print_r("select s.id,s.is_jiaji,s.rk,c.is_over,c.time,c.lx,c.id from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".(time()-3600*24*7) ." and c.lx in (".$transfer_str.") where s.is_jiaji = 2 and s.rk not like '%|11|%'");
  959. $tmp_list= $sql_r->result_array();
  960. $this->data['jiaji_num'] = count($tmp_list);
  961. }
  962. $this->_Template('transfer_operate',$this->data);
  963. }
  964. public function _out()
  965. {
  966. $post = $this->input->post(NULL, TRUE);
  967. if(isset($post['label']))
  968. {
  969. $time = time();
  970. $label = $this->input->post('label',true);
  971. $cz = $this->input->post('cz',true);
  972. $transfer = $this->input->post('transfer',true);
  973. if(!$label)
  974. {
  975. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  976. }
  977. if(!$transfer)
  978. {
  979. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  980. }
  981. $lb = $this->systemtransfer->get_label($label);
  982. if(!$lb)
  983. {
  984. $this->logic_ding->sendToDing("检测货物流转异常的编码".$transfer."|".$label);
  985. echo json_encode(array('msg'=>'错误!未找到此条码,请联系申天','success'=>false));exit;
  986. }
  987. if($lb['id'] == 136872 || $label == '17573171077300'){
  988. echo json_encode(array('msg'=>'此单请退 回配货库','success'=>false));exit;
  989. }
  990. //东恒的如果扫过完成 就不允许再扫入
  991. if($lb['type'] == 2){
  992. if((strpos($lb['rk'],3)!== false) && ($transfer !=3)){
  993. echo json_encode(array('msg'=>'东恒的货物不允许重复扫描!','success'=>false));exit;
  994. }
  995. }
  996. if($lb['number']!='')
  997. {
  998. $nu = $this->fullorder->get_number($lb['number']);
  999. if(!$nu)
  1000. {
  1001. $nu = $this->fullordersmt->get_number($lb['number']);
  1002. if(!$nu)
  1003. {
  1004. $nu = $this->fullordertt->get_number($lb['number']);
  1005. }
  1006. }
  1007. //取消的订单还是要继续生产的 所以还允许继续扫入扫出 只是后续的出入库中不在限定时间
  1008. // if($nu['state'] == '214' || $nu['state'] == '217')
  1009. // {
  1010. // echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit;
  1011. // }
  1012. }
  1013. $tdata = $this->transfer->find_all();
  1014. $t = array();
  1015. foreach ($tdata as $v)
  1016. {
  1017. $t[$v['id']] = $v['title'];
  1018. }
  1019. /**
  1020. if($cz == 1 && stripos($lb['rk'],'|'.$transfer.'|') !== false)
  1021. {
  1022. echo json_encode(array('msg'=>'此条码已有入库操作!','success'=>false));exit;
  1023. }
  1024. if($cz == 2 && stripos($lb['ck'],'|'.$transfer.'|') !== false)
  1025. {
  1026. echo json_encode(array('msg'=>'此条码已有出库操作!','success'=>false));exit;
  1027. }
  1028. **/
  1029. // if(stripos($lb['ck'],'|1|') === false && $transfer != 1 && stripos($nu['fpdata'],'-128-') !== false)
  1030. // {
  1031. // echo json_encode(array('msg'=>'必须有配货出库才可后续操作!','success'=>false));exit;
  1032. // }
  1033. //如果是外销单 成品库不许扫入
  1034. if($transfer == 11 && $cz == 1 && $lb['type'] == 2){
  1035. echo json_encode(array('msg'=>'工厂的外销单成品库不许扫入!','success'=>false));exit;
  1036. }
  1037. //重新定义配货的原则问题
  1038. //先检测订单是否含有 128 头套 或者配件 如果有 133 进行下一步检测
  1039. $sku_arr = explode("-",$lb['features']);
  1040. if(in_array(128,$sku_arr)||in_array(133,$sku_arr)){
  1041. // 145 Full Lace Wig
  1042. // 1170 HDFullLaceWig
  1043. // 1249 FullLaceBobwithBang
  1044. // 1484 FullLaceBob
  1045. //如果是这4中全蕾丝那么配货就不处理
  1046. if(in_array(145,$sku_arr) || in_array(1170,$sku_arr) || in_array(1249,$sku_arr) || in_array(1484,$sku_arr)){
  1047. }else{
  1048. if(stripos($lb['ck'],'|1|') === false && $transfer != 1 )
  1049. {
  1050. echo json_encode(array('msg'=>'头套和配件除了全蕾丝外必须走配货!','success'=>false));exit;
  1051. }
  1052. }
  1053. }
  1054. if($cz == 2 && stripos($lb['rk'],'|'.$transfer.'|') === false)
  1055. {
  1056. echo json_encode(array('msg'=>'此条码还未入库!','success'=>false));exit;
  1057. }
  1058. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1059. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1060. if($transfer != 3 && $transfer != 11 )
  1061. {
  1062. if($cz == 1)
  1063. {
  1064. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1065. {
  1066. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1067. }
  1068. }
  1069. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1070. {
  1071. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1072. }
  1073. }
  1074. if($cz == 1)
  1075. {
  1076. $lb['rk'] .= $transfer.'|';
  1077. $lb['rktime'] .= $time.'|';
  1078. if($lbrk[0] == $transfer)
  1079. {
  1080. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1081. }
  1082. }
  1083. else if($cz == 2)
  1084. {
  1085. $lb['ck'] .= $transfer.'|';
  1086. $lb['cktime'] .= $time.'|';
  1087. if($lbck[0] == $transfer)
  1088. {
  1089. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1090. }
  1091. }
  1092. $this->_doCancelWlz($lb['id']);
  1093. $cztime = 'ctime'.$transfer;
  1094. $this->logic_ding->sendToDing("检测货物流转打印情况".$transfer."|".$cz."|".$lb['number']."|".$lb['id']);
  1095. if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1096. //if(($transfer == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1)//单入库
  1097. {
  1098. if($lb['type'] == 0)
  1099. {
  1100. $s = $this->shop->read($nu['shop']);
  1101. $lb['kh'] = $s['yyid'];
  1102. $lb['ts'] = 1;
  1103. $rk = $this->apiyy->_newrk($lb);
  1104. if($rk['c'] == 0)
  1105. {
  1106. $this->db->trans_begin();
  1107. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$rk['scid'].time(),$cztime=>$time),$lb['id']);
  1108. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1109. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1110. if($cz == 2){
  1111. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1112. }
  1113. if ($this->db->trans_status() === TRUE)
  1114. {
  1115. $this->db->trans_commit();
  1116. if($nu['state'] == '216')
  1117. {
  1118. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1119. }
  1120. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1121. //标记订单已经取消
  1122. $this->_doCheckCancelFlag($lb['id']);
  1123. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1124. }
  1125. else
  1126. {
  1127. if($lb['is_jiaji'] == 2){
  1128. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1129. }elseif($lb['type'] == 2){
  1130. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1131. }else{
  1132. echo json_encode(array('music'=>'1','success'=>true));exit;
  1133. }
  1134. }
  1135. }
  1136. else
  1137. {
  1138. $this->db->trans_rollback();
  1139. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1140. }
  1141. }
  1142. else
  1143. {
  1144. if(stripos($rk['error'],'DocNo') !== false)
  1145. {
  1146. $rk['error'] = '未找到对应的生产订单 '.$lb['scid'];
  1147. }
  1148. $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']);
  1149. echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit;
  1150. }
  1151. }elseif($lb['type'] == 2){
  1152. $this->db->trans_begin();
  1153. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,$cztime=>$time),$lb['id']);
  1154. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1155. $this->zzquque_u9->insert([
  1156. 'platform'=>'',
  1157. 'warehouse'=>0,
  1158. 'type'=>20, //5代表美仓
  1159. 'order_no'=>$lb['number'],
  1160. 'child_order_no'=>$lb['id'],
  1161. 'status'=>0,
  1162. 'create_time'=>time(),
  1163. 'update_time'=>time(),
  1164. ]);
  1165. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1166. if($cz == 2){
  1167. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1168. }
  1169. if ($this->db->trans_status() === TRUE)
  1170. {
  1171. $this->db->trans_commit();
  1172. if($nu['state'] == '216')
  1173. {
  1174. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1175. }
  1176. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1177. //标记订单已经取消
  1178. $this->_doCheckCancelFlag($lb['id']);
  1179. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1180. }
  1181. else
  1182. {
  1183. if($lb['is_jiaji'] == 2){
  1184. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1185. }elseif($lb['type'] == 2){
  1186. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1187. }else{
  1188. echo json_encode(array('music'=>'1','success'=>true));exit;
  1189. }
  1190. }
  1191. }
  1192. else
  1193. {
  1194. $this->db->trans_rollback();
  1195. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1196. }
  1197. }
  1198. else
  1199. {
  1200. $scid = explode('~',$lb['scid']);
  1201. $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']);
  1202. $rk = $this->apiyy->get_bzsh($rkdata);
  1203. if(isset($rk['Data'][0]))
  1204. {
  1205. if($rk['Data'][0]['IsSucess'] == 1)
  1206. {
  1207. $this->db->trans_begin();
  1208. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$lb['scid'].'~'.$rk['Data'][0]['Code'],$cztime=>$time),$lb['id']);
  1209. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1210. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1211. if($cz == 2){
  1212. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1213. }
  1214. if ($this->db->trans_status() === TRUE)
  1215. {
  1216. $this->db->trans_commit();
  1217. if($nu['state'] == '216')
  1218. {
  1219. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1220. }
  1221. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1222. //标记订单已经取消
  1223. $this->_doCheckCancelFlag($lb['id']);
  1224. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1225. }
  1226. else
  1227. {
  1228. if($lb['is_jiaji'] == 2){
  1229. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1230. }else{
  1231. echo json_encode(array('music'=>'1','success'=>true));exit;
  1232. }
  1233. }
  1234. }
  1235. else
  1236. {
  1237. $this->db->trans_rollback();
  1238. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1239. }
  1240. }
  1241. else
  1242. {
  1243. echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit;
  1244. }
  1245. }
  1246. else
  1247. {
  1248. echo json_encode(array('msg'=>$rk,'success'=>false));exit;
  1249. }
  1250. }
  1251. }
  1252. //if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//只入库
  1253. if($transfer == 11 && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库
  1254. {
  1255. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1256. }
  1257. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id']);
  1258. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1259. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1260. if($cz == 2){
  1261. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1262. }
  1263. if ($this->db->trans_status() === TRUE)
  1264. {
  1265. $this->db->trans_commit();
  1266. if($nu['state'] == '216')
  1267. {
  1268. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1269. }
  1270. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1271. //标记订单已经取消
  1272. $this->_doCheckCancelFlag($lb['id']);
  1273. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1274. }
  1275. else
  1276. {
  1277. if($lb['is_jiaji'] == 2){
  1278. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1279. }else{
  1280. echo json_encode(array('music'=>'1','success'=>true));exit;
  1281. }
  1282. }
  1283. }
  1284. else
  1285. {
  1286. $this->db->trans_rollback();
  1287. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1288. }
  1289. }
  1290. }
  1291. //检测取消标记是否添加 同时也检查下 该流转单是否被标记为取消单
  1292. private function _doCheckCancelFlag($fid){
  1293. $info = $this->systemtransfer->read($fid);
  1294. if($info['status'] != 11){
  1295. $this->systemtransfer->save(['status'=>11],$fid);
  1296. }
  1297. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1298. if(empty($list)){
  1299. return;
  1300. }
  1301. $is_cancel = false;
  1302. foreach($list as $val){
  1303. if($val['orver_flag'] == 3){
  1304. $is_cancel = true;
  1305. }
  1306. }
  1307. if($is_cancel){
  1308. return ;
  1309. }
  1310. $this->systemtransfer_cr->save(['orver_flag'=>3],$list[0]['id']);
  1311. }
  1312. //检测是否可以取消长期未流转
  1313. private function _doCancelWlz($fid){
  1314. //$info = $this->systemtransfer->read($fid);
  1315. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1316. if(empty($list)){
  1317. return;
  1318. }
  1319. $id = $list[0]['id'];
  1320. $scan_time = $list[0]['time'];
  1321. if($list[0]['type'] == 2){
  1322. if(time() - $scan_time < 3600 * 24 * 3){
  1323. $this->systemtransfer_cr->save([
  1324. 'extra_status'=>0,
  1325. ],$id);
  1326. }else{
  1327. $this->systemtransfer_cr->save([
  1328. 'extra_status'=>3,
  1329. ],$id);
  1330. }
  1331. }
  1332. }
  1333. //检测是否超时 车间流转环节
  1334. private function _doCheckIsOverTime($fid,$transfer){
  1335. $list = $this->systemtransfer_cr->find_all("fid = ".$fid." and lx = ".$transfer." and is_over = 0","*",'id desc',0,2);
  1336. if(count($list) < 2){
  1337. return ;
  1338. }
  1339. if($list[0]['type'] != 2){
  1340. return;
  1341. }
  1342. if($list[1]['type'] != 1){
  1343. return;
  1344. }
  1345. if($list[1]['orver_flag'] == 2){
  1346. $this->systemtransfer_cr->save(array('is_over'=>1,'orver_flag'=>2),$list[0]['id']);
  1347. }else{
  1348. $this->systemtransfer_cr->save(array('is_over'=>1),$list[0]['id']);
  1349. }
  1350. $this->systemtransfer_cr->save(array('is_over'=>1),$list[1]['id']);
  1351. }
  1352. public function _bdbb()
  1353. {
  1354. $post = $this->input->post(NULL, TRUE);
  1355. if(isset($post['s']))
  1356. {
  1357. $id_arr = $this->input->post('s');
  1358. $id_arr = explode(',',trim($id_arr,','));
  1359. if(!$id_arr)
  1360. {
  1361. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1362. }
  1363. //循环删除记录
  1364. foreach ($id_arr as $v)
  1365. {
  1366. $t = $this->systemtransfer->read($v);
  1367. if(!isset($t['number']))
  1368. {
  1369. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1370. }
  1371. $y = $this->fullorder->get_number($t['number']);
  1372. if(!$y)
  1373. {
  1374. $y = $this->fullordersmt->get_number($t['number']);
  1375. if(!$y)
  1376. {
  1377. $y = $this->fullordertt->get_number($t['number']);
  1378. if(!$y)
  1379. {
  1380. echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit;
  1381. }
  1382. }
  1383. }
  1384. $time = time();
  1385. $label = $time.rand(10000,99999); //substr($time,1)*100
  1386. $this->systemtransfer->save(array('label'=>$label),$v);
  1387. $express = $this->express->read($y['express']);
  1388. $rows[] = array('num'=>$label,'number'=>$t['number'],'shipremarks'=>$t['shipremarks'],'ex'=>$express['servicename'],'time'=>''.date('Y-m-d',$t['printtime']),'gtime'=>date('YmdH',time()),'s'=>'1/1','t'=>"补打");
  1389. }
  1390. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1391. }
  1392. }
  1393. public function _excel()
  1394. {
  1395. if(isset($_GET['fexcel']))
  1396. {
  1397. $tc = array();$zh = array();
  1398. $typeclass = $this->typeclass->find_all();
  1399. foreach ($typeclass as $v)
  1400. {
  1401. $tc[$v['id']] = $v;
  1402. }
  1403. $number = $this->input->get('number',true);
  1404. $color = $this->input->get('color',true);
  1405. $gs = $this->input->get('gs',true);
  1406. $transfer = $this->input->get('transfer',true);
  1407. $type = $this->input->get('type',true);
  1408. $timetk = $this->input->get('timetk',true);
  1409. $timetj = $this->input->get('timetj',true);
  1410. $purchase = $this->input->get('purchase',true);
  1411. $lx = $this->input->get('lx',true);
  1412. $timetk = strtotime($timetk);
  1413. $timetj = strtotime($timetj);
  1414. $where = "1=1";
  1415. $cr = "time > '$timetk' and time < '$timetj'";
  1416. if($number)
  1417. {
  1418. $where .= " and number = '$number'";
  1419. }
  1420. if($transfer)
  1421. {
  1422. $cr .= " and lx = '".$transfer."'";
  1423. }
  1424. if($type)
  1425. {
  1426. //$cr .= " and type = '".$type."'";
  1427. if($type == 3){
  1428. $cr .= " and is_over = 0 ";
  1429. }else{
  1430. $cr .= " and type = '".$type."' ";
  1431. }
  1432. }
  1433. if($purchase)
  1434. {
  1435. $where .= " and purchase = '$purchase'";
  1436. }
  1437. if($color)
  1438. {
  1439. $where .= " and fpdata like '%-".$color."-%'";
  1440. }
  1441. if($lx)
  1442. {
  1443. if($lx == 1)
  1444. {
  1445. $where .= " and ordernumber = ''";
  1446. }
  1447. else
  1448. {
  1449. $where .= " and ordernumber != ''";
  1450. }
  1451. }
  1452. $fid = '';
  1453. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  1454. foreach ($info_list_cr as $v)
  1455. {
  1456. $fid .= "id = '".$v['fid']."' or ";
  1457. }
  1458. if($fid)
  1459. {
  1460. $where .= ' and ('.trim($fid,'or ').')';
  1461. }
  1462. else
  1463. {
  1464. $where .= ' and id = 0';
  1465. }
  1466. $data = array();
  1467. $datafy = array();
  1468. $j = 0;
  1469. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime');
  1470. $lzbm = $this->transfer->find_all();
  1471. foreach ($info_list as $key=>$value)
  1472. {
  1473. $dj = '';$ys = '';$cc = '';$hx = '';$md = '';
  1474. $d = $this->systemtransfer->read($value['id']);
  1475. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1476. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$d['shipremarks']);
  1477. $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']);
  1478. $cp = explode('-',trim($d['features'],'-'));
  1479. $rk = explode('|',trim($d['rk'],'|'));
  1480. $rktime = explode('|',trim($d['rktime'],'|'));
  1481. foreach ($cp as $v)
  1482. {
  1483. if(isset($tc[$v]))
  1484. {
  1485. if($tc[$v]['classid'] == 13)
  1486. {
  1487. $dj = $tc[$v]['title'];
  1488. }
  1489. else if($tc[$v]['classid'] == 8)
  1490. {
  1491. $ys = $tc[$v]['title'];
  1492. }
  1493. else if($tc[$v]['classid'] == 14)
  1494. {
  1495. $cc = $tc[$v]['title'];
  1496. }
  1497. else if($tc[$v]['classid'] == 15)
  1498. {
  1499. $hx = $tc[$v]['title'];
  1500. }
  1501. else if($tc[$v]['classid'] == 10)
  1502. {
  1503. $md = $tc[$v]['title'];
  1504. }
  1505. }
  1506. }
  1507. $rt = array();
  1508. foreach ($rk as $k=>$v)
  1509. {
  1510. $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]);
  1511. }
  1512. $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md));
  1513. foreach ($lzbm as $v)
  1514. {
  1515. if(isset($rt[count($fpdata[0])]))
  1516. {
  1517. //$fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1518. $num = $this->systemtransfer_cr->find_count("fid = ".$value['id']." and lx = ".$v['id']." and orver_flag = 2");
  1519. if($num > 0){
  1520. $fpdata[0][count($fpdata[0])] = "<span style='color:red;font-weight:bold;'>".$rt[count($fpdata[0])]."<span>";
  1521. }else{
  1522. $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1523. }
  1524. }
  1525. else
  1526. {
  1527. $fpdata[0][count($fpdata[0])] = '';
  1528. }
  1529. }
  1530. $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度
  1531. unset($info_list[$key]['id']);
  1532. }
  1533. //echo "<pre>";print_r($info_list);exit;
  1534. $lzxq = '';
  1535. foreach ($lzbm as $v)
  1536. {
  1537. $lzxq .= '<td>'.$v['title'].'</td>';
  1538. }
  1539. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表';
  1540. $titlename = "<table border=1>
  1541. <tr>
  1542. <td>订单编号</td>
  1543. <td>品名</td>
  1544. <td>简码</td>
  1545. <td>备注</td>
  1546. <td>打印时间</td>
  1547. <td>
  1548. <table border=1>
  1549. <tr><td colspan='6' align='center'>订单产品信息</td><td colspan='".count($lzbm)."' align='center'>货物流转时间</td></tr>
  1550. <tr>
  1551. <td>产品名称</td>
  1552. <td>尺寸</td>
  1553. <td>等级</td>
  1554. <td>颜色</td>
  1555. <td>花型</td>
  1556. <td>密度</td>
  1557. ".$lzxq."
  1558. </tr>
  1559. </table>
  1560. </td>
  1561. </tr>
  1562. </table>";
  1563. $filename = $title.".xls";
  1564. $tail = "\n";
  1565. $this->excel->get_fz($info_list,$titlename,$filename,$tail,1);
  1566. }
  1567. }
  1568. public function _rk()
  1569. {
  1570. $post = $this->input->post(NULL, TRUE);
  1571. if(isset($post['page']))
  1572. {
  1573. $api = $this->input->post('api',true);
  1574. $page = $this->input->post('page',true);
  1575. $perpage = $this->input->post('perpage',true);
  1576. $number = $this->input->post('number',true);
  1577. $color = $this->input->post('color',true);
  1578. $purchase = $this->input->post('purchase',true);
  1579. $transfer = $this->input->post('transfer',true);
  1580. $lx = $this->input->post('lx',true);
  1581. $timetk = $this->input->post('timetk',true);
  1582. $timetj = $this->input->post('timetj',true);
  1583. $timetk = strtotime($timetk);
  1584. $timetj = strtotime($timetj);
  1585. $where = "1=1";
  1586. if($transfer)
  1587. {
  1588. $ctime = 'ctime'.$transfer;
  1589. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1590. }
  1591. else
  1592. {
  1593. $where .= " and time > '$timetk' and time < '$timetj'";
  1594. }
  1595. if($number)
  1596. {
  1597. $where .= " and number = '$number'";
  1598. }
  1599. if($transfer)
  1600. {
  1601. $where .= " and rk like '%|".$transfer."|%'";
  1602. }
  1603. if($purchase)
  1604. {
  1605. $where .= " and purchase = '$purchase'";
  1606. }
  1607. if($color)
  1608. {
  1609. $where .= " and fpdata like '%-".$color."-%'";
  1610. }
  1611. if($lx)
  1612. {
  1613. if($lx == 1)
  1614. {
  1615. $where .= " and ordernumber = ''";
  1616. }
  1617. else
  1618. {
  1619. $where .= " and ordernumber != ''";
  1620. }
  1621. }
  1622. //数据排序
  1623. $order_str = "id desc";
  1624. if(empty($page))
  1625. {
  1626. $start = 0;
  1627. $perpage = 1;
  1628. }
  1629. else
  1630. {
  1631. $start = ($page - 1)*$perpage;
  1632. }
  1633. //取得信息列表
  1634. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1635. $transfer = $this->transfer->find_all();
  1636. $t = array();
  1637. foreach ($transfer as $v)
  1638. {
  1639. $t[$v['id']] = $v['title'];
  1640. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1641. }
  1642. //格式化数据
  1643. foreach ($info_list as $key=>$value)
  1644. {
  1645. $dd = $this->systemtransfer->read($value['id']);
  1646. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1647. $rk = explode('|',trim($dd['rk'],'|'));
  1648. $rktime = explode('|',trim($dd['rktime'],'|'));
  1649. $ck = explode('|',trim($dd['ck'],'|'));
  1650. $cktime = explode('|',trim($dd['cktime'],'|'));
  1651. $info_list[$key]['time'] = '';
  1652. for($i=0;$i<count($rk);$i++)
  1653. {
  1654. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1655. {
  1656. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1657. }
  1658. else
  1659. {
  1660. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1661. }
  1662. $info_list[$key]['time'] .= $d;
  1663. if(isset($ck[$i]) && $ck[$i] != '')
  1664. {
  1665. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1666. }
  1667. }
  1668. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1669. }
  1670. $total = $this->systemtransfer->find_count($where);
  1671. $pagenum = ceil($total/$perpage);
  1672. $over = $total-($start+$perpage);
  1673. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1674. echo json_encode($rows);exit;
  1675. }
  1676. if(isset($_SESSION['api']))
  1677. {
  1678. $user = $this->user->get_api($_SESSION['api']);
  1679. $usp = $user;
  1680. $pid = "";$tid="";$sid="";$wid="";
  1681. $purchase = explode('|',trim($user['purchase'],'|'));
  1682. $transfer = explode('|',trim($user['transfer'],'|'));
  1683. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1684. foreach ($purchase as $value)
  1685. {
  1686. $pid .= " id = ".$value." or";
  1687. }
  1688. foreach ($transfer as $value)
  1689. {
  1690. $tid .= " id = ".$value." or";
  1691. }
  1692. foreach ($warehouse as $value)
  1693. {
  1694. $wid .= " id = ".$value." or";
  1695. }
  1696. }
  1697. else
  1698. {
  1699. header('Location: /');exit;
  1700. }
  1701. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1702. $this->data['transfer'] = $transfer;
  1703. $this->_Template('transfer_rk',$this->data);
  1704. }
  1705. public function _ck()
  1706. {
  1707. $post = $this->input->post(NULL, TRUE);
  1708. if(isset($post['page']))
  1709. {
  1710. $api = $this->input->post('api',true);
  1711. $page = $this->input->post('page',true);
  1712. $perpage = $this->input->post('perpage',true);
  1713. $number = $this->input->post('number',true);
  1714. $color = $this->input->post('color',true);
  1715. $purchase = $this->input->post('purchase',true);
  1716. $transfer = $this->input->post('transfer',true);
  1717. $lx = $this->input->post('lx',true);
  1718. $timetk = $this->input->post('timetk',true);
  1719. $timetj = $this->input->post('timetj',true);
  1720. $timetk = strtotime($timetk);
  1721. $timetj = strtotime($timetj);
  1722. $where = "1=1";
  1723. if($transfer)
  1724. {
  1725. $ctime = 'ctime'.$transfer;
  1726. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1727. }
  1728. else
  1729. {
  1730. $where .= " and time > '$timetk' and time < '$timetj'";
  1731. }
  1732. if($number)
  1733. {
  1734. $where .= " and number = '$number'";
  1735. }
  1736. if($transfer)
  1737. {
  1738. $where .= " and ck like '%|".$transfer."|%'";
  1739. }
  1740. if($purchase)
  1741. {
  1742. $where .= " and purchase = '$purchase'";
  1743. }
  1744. if($color)
  1745. {
  1746. $where .= " and fpdata like '%-".$color."-%'";
  1747. }
  1748. if($lx)
  1749. {
  1750. if($lx == 1)
  1751. {
  1752. $where .= " and ordernumber = ''";
  1753. }
  1754. else
  1755. {
  1756. $where .= " and ordernumber != ''";
  1757. }
  1758. }
  1759. //数据排序
  1760. $order_str = "id desc";
  1761. if(empty($page))
  1762. {
  1763. $start = 0;
  1764. $perpage = 1;
  1765. }
  1766. else
  1767. {
  1768. $start = ($page - 1)*$perpage;
  1769. }
  1770. //取得信息列表
  1771. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1772. $transfer = $this->transfer->find_all();
  1773. $t = array();
  1774. foreach ($transfer as $v)
  1775. {
  1776. $t[$v['id']] = $v['title'];
  1777. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1778. }
  1779. //格式化数据
  1780. foreach ($info_list as $key=>$value)
  1781. {
  1782. $dd = $this->systemtransfer->read($value['id']);
  1783. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1784. $rk = explode('|',trim($dd['rk'],'|'));
  1785. $rktime = explode('|',trim($dd['rktime'],'|'));
  1786. $ck = explode('|',trim($dd['ck'],'|'));
  1787. $cktime = explode('|',trim($dd['cktime'],'|'));
  1788. $info_list[$key]['time'] = '';
  1789. for($i=0;$i<count($rk);$i++)
  1790. {
  1791. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1792. {
  1793. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1794. }
  1795. else
  1796. {
  1797. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1798. }
  1799. $info_list[$key]['time'] .= $d;
  1800. if(isset($ck[$i]) && $ck[$i] != '')
  1801. {
  1802. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1803. }
  1804. }
  1805. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1806. }
  1807. $total = $this->systemtransfer->find_count($where);
  1808. $pagenum = ceil($total/$perpage);
  1809. $over = $total-($start+$perpage);
  1810. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1811. echo json_encode($rows);exit;
  1812. }
  1813. if(isset($_SESSION['api']))
  1814. {
  1815. $user = $this->user->get_api($_SESSION['api']);
  1816. $usp = $user;
  1817. $pid = "";$tid="";$sid="";$wid="";
  1818. $purchase = explode('|',trim($user['purchase'],'|'));
  1819. $transfer = explode('|',trim($user['transfer'],'|'));
  1820. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1821. foreach ($purchase as $value)
  1822. {
  1823. $pid .= " id = ".$value." or";
  1824. }
  1825. foreach ($transfer as $value)
  1826. {
  1827. $tid .= " id = ".$value." or";
  1828. }
  1829. foreach ($warehouse as $value)
  1830. {
  1831. $wid .= " id = ".$value." or";
  1832. }
  1833. }
  1834. else
  1835. {
  1836. header('Location: /');exit;
  1837. }
  1838. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1839. $this->data['transfer'] = $transfer;
  1840. $this->_Template('transfer_ck',$this->data);
  1841. }
  1842. public function _jgl()
  1843. {
  1844. $post = $this->input->post(NULL, TRUE);
  1845. if(isset($post['printtime']))
  1846. {
  1847. $pt = $this->input->post('printtime',true);
  1848. $wt = $this->input->post('wgtime',true);
  1849. $printtime = strtotime($pt);
  1850. $wgtime = strtotime($wt);
  1851. $sy = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."'");
  1852. $wg = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."' and ctime11 < '$wgtime' and ctime11 != '0'");
  1853. if($printtime == $wgtime || $printtime > $wgtime)
  1854. {
  1855. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>时间选择错误</p>",'success'=>true));exit;
  1856. }
  1857. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>".(($wgtime-$printtime)/86400)."天 完工数量:".$wg.", 总数量:".$sy.", 完工率:".number_format(($wg/$sy*100),2)."%</p>",'success'=>true));exit;
  1858. }
  1859. $this->_Template('transfer_wgl',$this->data);
  1860. }
  1861. public function _linqi(){
  1862. $post = $this->input->post(NULL, TRUE);
  1863. if(isset($post['page']))
  1864. {
  1865. $api = $this->input->post('api',true);
  1866. $page = $this->input->post('page',true);
  1867. $perpage = $this->input->post('perpage',true);
  1868. $transfer = $this->input->post('transfer',true);
  1869. $transfer_ids = $this->input->post('transfer_ids',true);
  1870. $orver_flag = $this->input->post('orver_flag',true);
  1871. $timetk = $this->input->post('timetk',true);
  1872. $timetj = $this->input->post('timetj',true);
  1873. $timetk = strtotime($timetk);
  1874. $timetj = strtotime($timetj);
  1875. $transfer_list = $this->transfer->find_all();
  1876. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1877. $where = 'type = 1 ';
  1878. $where .= " and is_over = 0 and orver_flag = ".$orver_flag." ";
  1879. //数据排序
  1880. $order_str = "id desc";
  1881. if(empty($page))
  1882. {
  1883. $start = 0;
  1884. $perpage = 1;
  1885. }
  1886. else
  1887. {
  1888. $start = ($page - 1)*$perpage;
  1889. }
  1890. if($transfer){
  1891. $where .= " and lx = '$transfer'";
  1892. }else{
  1893. $where .= " and lx in (".$transfer_ids.") ";
  1894. }
  1895. $where .= " and time > '$timetk' and time < '$timetj'";
  1896. $where .= " and ycrk_type = 0 ";
  1897. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  1898. $final_list = [];
  1899. foreach ($list as $key => $value) {
  1900. $info = $this->systemtransfer->read($value['fid']);
  1901. $final_list[$key]['id'] = $value['id'];
  1902. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  1903. if($info['is_jiaji'] == 2){
  1904. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  1905. }else{
  1906. $final_list[$key]['is_jiaji'] = "常规";
  1907. }
  1908. $final_list[$key]['pm'] = $info['pm'];
  1909. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  1910. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  1911. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  1912. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  1913. foreach ($data as $k=>$v)
  1914. {
  1915. $type = ($v['type']==1)?'入库':'出库';
  1916. if($v['orver_flag'] == 1){
  1917. if($v['is_over'] == 0){
  1918. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>".'<br>';
  1919. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  1920. }else{
  1921. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  1922. }
  1923. }elseif($v['orver_flag'] == 2){
  1924. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>".'<br>';
  1925. }else{
  1926. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  1927. }
  1928. }
  1929. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1930. }
  1931. $total = $this->systemtransfer_cr->find_count($where);
  1932. $pagenum = ceil($total/$perpage);
  1933. $over = $total-($start+$perpage);
  1934. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  1935. echo json_encode($rows);exit;
  1936. }
  1937. if(isset($_SESSION['api']))
  1938. {
  1939. $user = $this->user->get_api($_SESSION['api']);
  1940. $usp = $user;
  1941. $pid = "";$tid="";$sid="";$wid="";
  1942. $purchase = explode('|',trim($user['purchase'],'|'));
  1943. $transfer = explode('|',trim($user['transfer'],'|'));
  1944. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1945. foreach ($purchase as $value)
  1946. {
  1947. $pid .= " id = ".$value." or";
  1948. }
  1949. foreach ($transfer as $value)
  1950. {
  1951. $tid .= " id = ".$value." or";
  1952. }
  1953. foreach ($warehouse as $value)
  1954. {
  1955. $wid .= " id = ".$value." or";
  1956. }
  1957. }
  1958. else
  1959. {
  1960. header('Location: /');exit;
  1961. }
  1962. $kx = '';$zjtab = '';
  1963. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1964. $this->data['transfer'] = $transfer;
  1965. $transfer_ids = array_column($transfer, 'id');
  1966. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  1967. $this->data['vip'] = $user['vip'];
  1968. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  1969. $this->_Template('transfer_linqi',$this->data);
  1970. }
  1971. //按照条件导出超时车间
  1972. public function _overtime_export(){
  1973. $transfer_id = $this->input->get('transfer', TRUE);
  1974. $timetk = $this->input->get('timetk', TRUE);
  1975. $timetj = $this->input->get('timetj', TRUE);
  1976. $timetk = strtotime($timetk);
  1977. $timetj = strtotime($timetj);
  1978. if(isset($_SESSION['api']))
  1979. {
  1980. $user = $this->user->get_api($_SESSION['api']);
  1981. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1982. $tmp_transfer_list = $this->transfer->find_all();
  1983. $transfer_list = array_column($tmp_transfer_list, 'title', 'id');
  1984. }
  1985. else
  1986. {
  1987. header('Location: /');exit;
  1988. }
  1989. $where = " orver_flag = 2 and type = 1";
  1990. if(empty($transfer_id)){
  1991. $where .= " and lx in (".implode(',',$transfer_ids).") ";
  1992. }else{
  1993. $where .= " and lx = ".$transfer_id." ";
  1994. }
  1995. $where .= " and time > '$timetk' and time < '$timetj'";
  1996. $list = $this->systemtransfer_cr->find_all($where,'*');
  1997. $fid_list = array_column($list, 'fid');
  1998. if(empty($fid_list)){
  1999. echo "没有数据" ;
  2000. die ;
  2001. }
  2002. $order_list = $this->systemtransfer->find_all("id in (".implode(',',$fid_list).")");
  2003. $where_two = " orver_flag = 2 and type = 2";
  2004. if(empty($transfer_id)){
  2005. $where_two .= " and lx in (".implode(',',$transfer_ids).") ";
  2006. }else{
  2007. $where_two .= " and lx = ".$transfer_id." ";
  2008. }
  2009. $where_two .= " and time > '$timetk' and time < '$timetj'";
  2010. $list_two = $this->systemtransfer_cr->find_all($where_two,'*');
  2011. $final_list = [];
  2012. // foreach($list as $k => $v){
  2013. // $final_list[$v['fid']]['fid'] = $v['fid'];
  2014. // $final_list[$v['fid']]['lx'] = $v['lx'];
  2015. // $final_list[$v['fid']]['start_type'] = $v['type'];
  2016. // $final_list[$v['fid']]['start_time'] = date('Y-m-d H:i:s',$v['time']);
  2017. // $final_list[$v['fid']]['condition'] = json_decode($v['limit_time_str'],true);
  2018. // $final_list[$v['fid']]['end_time'] = "";
  2019. // $final_list[$v['fid']]['lx_name'] = isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'';
  2020. // }
  2021. // foreach($order_list as $k=>$v){
  2022. // if(isset($final_list[$v['id']])){
  2023. // $final_list[$v['id']]['number'] = $v['number'];
  2024. // $final_list[$v['id']]['pm'] = $v['pm'];
  2025. // }
  2026. // }
  2027. // foreach($list_two as $k => $v){
  2028. // if(isset($final_list[$v['fid']])){
  2029. // if($v['lx'] ==$final_list[$v['fid']]['lx']){
  2030. // $final_list[$v['fid']]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2031. // }
  2032. // }
  2033. // }
  2034. foreach($list as $k => $v){
  2035. $final_list[] = [
  2036. 'fid' => $v['fid'],
  2037. 'lx' => $v['lx'],
  2038. 'start_type' => $v['type'],
  2039. 'start_time' => date('Y-m-d H:i:s',$v['time']),
  2040. 'condition' => json_decode($v['limit_time_str'],true),
  2041. 'end_time' => "",
  2042. 'lx_name' => isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'',
  2043. ];
  2044. }
  2045. foreach($order_list as $k=>$v){
  2046. foreach($final_list as $kk => $vv){
  2047. if($v['id'] == $vv['fid']){
  2048. $final_list[$kk]['number'] = $v['number'];
  2049. $final_list[$kk]['pm'] = $v['pm'];
  2050. }
  2051. }
  2052. }
  2053. foreach($list_two as $k => $v){
  2054. foreach($final_list as $kk => $vv){
  2055. if(($v['fid'] == $vv['fid']) && ($v['lx'] == $vv['lx'])){
  2056. $final_list[$kk]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2057. }
  2058. }
  2059. }
  2060. $filename = date("Y-m-d")."超时单导出.xls";
  2061. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2062. <head>
  2063. <!--[if gte mso 9]><xml>
  2064. <x:ExcelWorkbook>
  2065. <x:ExcelWorksheets>
  2066. <x:ExcelWorksheet>
  2067. <x:Name>EXCEL</x:Name>
  2068. <x:WorksheetOptions>
  2069. <x:Print>
  2070. <x:ValidPrinterInfo />
  2071. </x:Print>
  2072. </x:WorksheetOptions>
  2073. </x:ExcelWorksheet>
  2074. </x:ExcelWorksheets>
  2075. </x:ExcelWorkbook>
  2076. </xml>
  2077. <![endif]-->
  2078. </head><body>";
  2079. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2080. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>入库日期</td><td>出库日期</td></tr>";
  2081. foreach ($final_list as $key=>$value)
  2082. {
  2083. if(empty($value['number'])){
  2084. continue;
  2085. }
  2086. $str .= "<tr>";
  2087. $str .= "<td>". $value['number']. "</td>";
  2088. $str .= "<td>". $value['pm']. "</td>";
  2089. $str .= "<td>". $value['lx_name']. "</td>";
  2090. $str .= "<td>". $value['start_time']. "</td>";
  2091. $str .= "<td>". $value['end_time']. "</td>";
  2092. $str .= "</tr>";
  2093. }
  2094. $str .= "</table></body></html>";
  2095. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2096. header( "Content-type: application/octet-stream" );
  2097. header( "Content-Disposition: attachment; filename=".$filename );
  2098. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2099. header( "Pragma: no-cache" );
  2100. header( "Expires: 0" );
  2101. exit($str);
  2102. }
  2103. public function _jiaji(){
  2104. $post = $this->input->post(NULL, TRUE);
  2105. if(isset($post['page']))
  2106. {
  2107. $api = $this->input->post('api',true);
  2108. $page = $this->input->post('page',true);
  2109. $perpage = $this->input->post('perpage',true);
  2110. $transfer = $this->input->post('transfer',true);
  2111. $transfer_ids = $this->input->post('transfer_ids',true);
  2112. $orver_flag = $this->input->post('orver_flag',true);
  2113. $timetk = $this->input->post('timetk',true);
  2114. $timetj = $this->input->post('timetj',true);
  2115. $timetk = strtotime($timetk);
  2116. $timetj = strtotime($timetj);
  2117. $transfer_list = $this->transfer->find_all();
  2118. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2119. if(isset($_SESSION['api']))
  2120. {
  2121. $user = $this->user->get_api($_SESSION['api']);
  2122. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  2123. }
  2124. else
  2125. {
  2126. $transfer_ids = array_keys($t);
  2127. }
  2128. if(empty($page))
  2129. {
  2130. $start = 0;
  2131. $perpage = 1;
  2132. }
  2133. else
  2134. {
  2135. $start = ($page - 1)*$perpage;
  2136. }
  2137. $sql_r = "select s.* from crowd_systemtransfer as s inner join crowd_systemtransfer_cr as c on c.fid = s.id and c.is_over = 0 and c.time > ".$timetk ." and c.time < ".$timetj." ";
  2138. if($transfer){
  2139. $sql_r .= " and c.lx = ".$transfer." ";
  2140. }else{
  2141. foreach($transfer_ids as $k=>$v){
  2142. if($v == 11){
  2143. unset($transfer_ids[$k]);
  2144. }
  2145. }
  2146. $transfer_str = implode(",",$transfer_ids);
  2147. $sql_r .= " and c.lx in (".$transfer_str.") ";
  2148. }
  2149. $sql_r .=" where s.is_jiaji = 2 and s.rk not like '%|11|%' " ;
  2150. $rows_r = $this->db->query($sql_r);
  2151. $get_list = $rows_r->result_array();
  2152. $total = count($get_list);
  2153. $split_list = array_chunk($get_list,$perpage);
  2154. $pagenum = ceil(count($split_list));
  2155. $key = $page - 1;
  2156. $list = isset($split_list[$key])?$split_list[$key]:[];
  2157. $final_list = [];
  2158. foreach ($list as $key => $value) {
  2159. $final_list[$key]['id'] = $value['id'];
  2160. $final_list[$key]['number'] = isset($value['number'])?$value['number']:'';
  2161. if($value['is_jiaji'] == 2){
  2162. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2163. }else{
  2164. $final_list[$key]['is_jiaji'] = "常规";
  2165. }
  2166. $final_list[$key]['pm'] = $value['pm'];
  2167. $final_list[$key]['shipremarks'] = $value['shipremarks'];
  2168. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2169. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2170. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2171. foreach ($data as $k=>$v)
  2172. {
  2173. $type = ($v['type']==1)?'入库':'出库';
  2174. if($v['orver_flag'] == 1){
  2175. if($v['is_over'] == 0){
  2176. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>".'<br>';
  2177. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2178. }else{
  2179. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2180. }
  2181. }elseif($v['orver_flag'] == 2){
  2182. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>".'<br>';
  2183. }else{
  2184. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2185. }
  2186. }
  2187. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2188. }
  2189. $over = $total-($start+$perpage);
  2190. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2191. echo json_encode($rows);exit;
  2192. }
  2193. if(isset($_SESSION['api']))
  2194. {
  2195. $user = $this->user->get_api($_SESSION['api']);
  2196. $usp = $user;
  2197. $pid = "";$tid="";$sid="";$wid="";
  2198. $purchase = explode('|',trim($user['purchase'],'|'));
  2199. $transfer = explode('|',trim($user['transfer'],'|'));
  2200. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2201. foreach ($purchase as $value)
  2202. {
  2203. $pid .= " id = ".$value." or";
  2204. }
  2205. foreach ($transfer as $value)
  2206. {
  2207. if($value){
  2208. if($value != 11){
  2209. $tid .= " id = ".$value." or";
  2210. }
  2211. }
  2212. }
  2213. foreach ($warehouse as $value)
  2214. {
  2215. $wid .= " id = ".$value." or";
  2216. }
  2217. }
  2218. else
  2219. {
  2220. header('Location: /');exit;
  2221. }
  2222. $kx = '';$zjtab = '';
  2223. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2224. $this->data['transfer'] = $transfer;
  2225. $transfer_ids = array_column($transfer, 'id');
  2226. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2227. $this->data['vip'] = $user['vip'];
  2228. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2229. $this->_Template('transfer_jiaji',$this->data);
  2230. }
  2231. public function _scz(){
  2232. $post = $this->input->post(NULL, TRUE);
  2233. if(isset($post['page']))
  2234. {
  2235. $page = $this->input->post('page',true);
  2236. $perpage = $this->input->post('perpage',true);
  2237. $transfer = $this->input->post('transfer',true);
  2238. $transfer_ids = $this->input->post('transfer_ids',true);
  2239. $timetk = $this->input->post('timetk',true);
  2240. $timetj = $this->input->post('timetj',true);
  2241. $timetk = strtotime($timetk);
  2242. $timetj = strtotime($timetj);
  2243. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2244. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2245. // $transfer_ids = array_keys($t);
  2246. if(empty($page))
  2247. {
  2248. $start = 0;
  2249. $perpage = 1;
  2250. }
  2251. else
  2252. {
  2253. $start = ($page - 1)*$perpage;
  2254. }
  2255. $where = "time > '$timetk' and time < '$timetj'";
  2256. $where .= " and rk not like '%11|' ";
  2257. if(!empty($transfer)){
  2258. $where .= " and rk like '%|".$transfer."|%' ";
  2259. }
  2260. // if($transfer)
  2261. // {
  2262. // $cr .= " and lx = '".$transfer."' ";
  2263. // }else{
  2264. // $cr .= " and lx in (".implode(",",$transfer_ids).") ";
  2265. // }
  2266. // $cr .= " and is_over = 0 ";
  2267. // $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  2268. // $fid = [];
  2269. // foreach ($info_list_cr as $v)
  2270. // {
  2271. // $fid[] = $v['fid'];
  2272. // }
  2273. // if(empty($fid)){
  2274. // $rows = array('total'=>0,'over'=>0,'pagenum'=>0,'rows'=>([]));
  2275. // echo json_encode($rows);exit;
  2276. // }
  2277. // $fid = array_unique($fid);
  2278. $order_str = "id desc";
  2279. //取得信息列表
  2280. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  2281. $transfer = $this->transfer->find_all();
  2282. $t = array();
  2283. foreach ($transfer as $v)
  2284. {
  2285. $t[$v['id']] = $v['title'];
  2286. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2287. }
  2288. //格式化数据
  2289. foreach ($info_list as $key=>$value)
  2290. {
  2291. if($value['is_jiaji'] == 2){
  2292. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2293. }else{
  2294. $info_list[$key]['is_jiaji'] = "常规";
  2295. }
  2296. $dd = $this->systemtransfer->read($value['id']);
  2297. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2298. $rk = explode('|',trim($dd['rk'],'|'));
  2299. $rktime = explode('|',trim($dd['rktime'],'|'));
  2300. $ck = explode('|',trim($dd['ck'],'|'));
  2301. $cktime = explode('|',trim($dd['cktime'],'|'));
  2302. $info_list[$key]['time'] = '';
  2303. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2304. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2305. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2306. foreach ($data as $k=>$v)
  2307. {
  2308. // $type = ($v['type']==1)?'入库':'出库';
  2309. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2310. $type = ($v['type']==1)?'入库':'出库';
  2311. if($v['orver_flag'] == 1){
  2312. if($v['is_over'] == 0){
  2313. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></a>".'<br>';
  2314. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2315. }else{
  2316. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2317. }
  2318. }elseif($v['orver_flag'] == 2){
  2319. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></a>".'<br>';
  2320. }elseif($v['orver_flag'] == 3){
  2321. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></a>".'<br>';
  2322. }else{
  2323. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>".'<br>';
  2324. }
  2325. }
  2326. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2327. unset($info_list[$key]['ctime12']);
  2328. }
  2329. $total = $this->systemtransfer->find_count($where);
  2330. $pagenum = ceil($total/$perpage);
  2331. $over = $total-($start+$perpage);
  2332. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2333. echo json_encode($rows);exit;
  2334. }
  2335. if(isset($_SESSION['api']))
  2336. {
  2337. $user = $this->user->get_api($_SESSION['api']);
  2338. if(!in_array($user['id'],[10,44,50])){
  2339. exit('No direct script access allowed');
  2340. }
  2341. }
  2342. else
  2343. {
  2344. header('Location: /');exit;
  2345. }
  2346. $kx = '';$zjtab = '';
  2347. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2348. $this->data['transfer'] = $transfer;
  2349. $transfer_ids = array_column($transfer, 'id');
  2350. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2351. $this->_Template('transfer_scz',$this->data);
  2352. }
  2353. public function _sczexcel(){
  2354. $timetk = $this->input->get('timetk',true);
  2355. $timetj = $this->input->get('timetj',true);
  2356. $timetk = strtotime($timetk);
  2357. $timetj = strtotime($timetj);
  2358. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2359. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2360. // $transfer_ids = array_keys($t);
  2361. $where = "time > '$timetk' and time < '$timetj'";
  2362. $where .= " and rk not like '%11|' ";
  2363. if(!empty($transfer)){
  2364. $where .= " and rk like '%|".$transfer."|%' ";
  2365. }
  2366. $order_str = "id desc";
  2367. //取得信息列表
  2368. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str);
  2369. $transfer = $this->transfer->find_all();
  2370. $t = array();
  2371. foreach ($transfer as $v)
  2372. {
  2373. $t[$v['id']] = $v['title'];
  2374. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2375. }
  2376. //格式化数据
  2377. foreach ($info_list as $key=>$value)
  2378. {
  2379. if($value['is_jiaji'] == 2){
  2380. $info_list[$key]['is_jiaji'] = "<span style='color:red'>加急</span>";
  2381. }else{
  2382. $info_list[$key]['is_jiaji'] = "常规";
  2383. }
  2384. $dd = $this->systemtransfer->read($value['id']);
  2385. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2386. $rk = explode('|',trim($dd['rk'],'|'));
  2387. $rktime = explode('|',trim($dd['rktime'],'|'));
  2388. $ck = explode('|',trim($dd['ck'],'|'));
  2389. $cktime = explode('|',trim($dd['cktime'],'|'));
  2390. $info_list[$key]['time'] = '';
  2391. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2392. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2393. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2394. foreach ($data as $k=>$v)
  2395. {
  2396. // $type = ($v['type']==1)?'入库':'出库';
  2397. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2398. $type = ($v['type']==1)?'入库':'出库';
  2399. if($v['orver_flag'] == 1){
  2400. if($v['is_over'] == 0){
  2401. $info_list[$key]['time'] .= "<span style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='font-weight:900;'>即将超时 </l></span>".'<br>';
  2402. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2403. }else{
  2404. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2405. }
  2406. }elseif($v['orver_flag'] == 2){
  2407. $info_list[$key]['time'] .= "<span style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>超时! </l></span>".'<br>';
  2408. }elseif($v['orver_flag'] == 3){
  2409. $info_list[$key]['time'] .= "<span style='color:#06f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l font-weight:900'>【该单已取消】 </l></span>".'<br>';
  2410. }else{
  2411. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2412. }
  2413. }
  2414. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2415. unset($info_list[$key]['ctime12']);
  2416. }
  2417. $filename = date("Y-m-d")."生产中订单.xls";
  2418. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2419. <head>
  2420. <!--[if gte mso 9]><xml>
  2421. <x:ExcelWorkbook>
  2422. <x:ExcelWorksheets>
  2423. <x:ExcelWorksheet>
  2424. <x:Name>EXCEL</x:Name>
  2425. <x:WorksheetOptions>
  2426. <x:Print>
  2427. <x:ValidPrinterInfo />
  2428. </x:Print>
  2429. </x:WorksheetOptions>
  2430. </x:ExcelWorksheet>
  2431. </x:ExcelWorksheets>
  2432. </x:ExcelWorkbook>
  2433. </xml>
  2434. <![endif]-->
  2435. </head><body>";
  2436. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2437. $str .= "<tr><td>订单编号</td><td>加急</td><td>品名</td><td>备注</td><td>打印时间</td><td>操作</td></tr>";
  2438. foreach ($info_list as $key=>$value)
  2439. {
  2440. $str .= "<tr>";
  2441. $str .= "<td>". $value['number']. "</td>";
  2442. $str .= "<td>". $value['is_jiaji']. "</td>";
  2443. $str .= "<td>". $value['pm']. "</td>";
  2444. $str .= "<td>". $value['shipremarks']. "</td>";
  2445. $str .= "<td>". $value['printtime']. "</td>";
  2446. $str .= "<td>". $value['time']. "</td>";
  2447. $str .= "</tr>";
  2448. }
  2449. $str .= "</table></body></html>";
  2450. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2451. header( "Content-type: application/octet-stream" );
  2452. header( "Content-Disposition: attachment; filename=".$filename );
  2453. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2454. header( "Pragma: no-cache" );
  2455. header( "Expires: 0" );
  2456. exit($str);
  2457. }
  2458. public function _wjsrk(){
  2459. $post = $this->input->post(NULL, TRUE);
  2460. if(isset($post['page']))
  2461. {
  2462. $api = $this->input->post('api',true);
  2463. $page = $this->input->post('page',true);
  2464. $perpage = $this->input->post('perpage',true);
  2465. $transfer = $this->input->post('transfer',true);
  2466. $transfer_ids = $this->input->post('transfer_ids',true);
  2467. $orver_flag = $this->input->post('orver_flag',true);
  2468. $timetk = $this->input->post('timetk',true);
  2469. $timetj = $this->input->post('timetj',true);
  2470. $timetk = strtotime($timetk);
  2471. $timetj = strtotime($timetj);
  2472. $transfer_list = $this->transfer->find_all();
  2473. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2474. $where = 'extra_status in (1,2) ';
  2475. //数据排序
  2476. $order_str = "id desc";
  2477. if(empty($page))
  2478. {
  2479. $start = 0;
  2480. $perpage = 1;
  2481. }
  2482. else
  2483. {
  2484. $start = ($page - 1)*$perpage;
  2485. }
  2486. if($transfer){
  2487. $where .= " and lx = '$transfer'";
  2488. }else{
  2489. $where .= " and lx in (".$transfer_ids.") ";
  2490. }
  2491. $where .= " and time > '$timetk' and time < '$timetj'";
  2492. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2493. $final_list = [];
  2494. foreach ($list as $key => $value) {
  2495. $info = $this->systemtransfer->read($value['fid']);
  2496. $final_list[$key]['id'] = $value['id'];
  2497. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2498. if($info['is_jiaji'] == 2){
  2499. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2500. }else{
  2501. $final_list[$key]['is_jiaji'] = "常规";
  2502. }
  2503. $final_list[$key]['pm'] = $info['pm'];
  2504. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2505. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2506. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2507. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2508. foreach ($data as $k=>$v)
  2509. {
  2510. $type = ($v['type']==1)?'入库':'出库';
  2511. if($v['orver_flag'] == 1){
  2512. if($v['is_over'] == 0){
  2513. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>";
  2514. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2515. }else{
  2516. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2517. }
  2518. }elseif($v['orver_flag'] == 2){
  2519. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>";
  2520. }else{
  2521. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2522. }
  2523. if($v['extra_status'] == 1){
  2524. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2525. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2526. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2527. }else{
  2528. $info_list[$key]['time'] .= "<br>";
  2529. }
  2530. }
  2531. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2532. }
  2533. $total = $this->systemtransfer_cr->find_count($where);
  2534. $pagenum = ceil($total/$perpage);
  2535. $over = $total-($start+$perpage);
  2536. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2537. echo json_encode($rows);exit;
  2538. }
  2539. if(isset($_SESSION['api']))
  2540. {
  2541. $user = $this->user->get_api($_SESSION['api']);
  2542. $usp = $user;
  2543. $pid = "";$tid="";$sid="";$wid="";
  2544. $purchase = explode('|',trim($user['purchase'],'|'));
  2545. $transfer = explode('|',trim($user['transfer'],'|'));
  2546. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2547. foreach ($purchase as $value)
  2548. {
  2549. $pid .= " id = ".$value." or";
  2550. }
  2551. foreach ($transfer as $value)
  2552. {
  2553. $tid .= " id = ".$value." or";
  2554. }
  2555. foreach ($warehouse as $value)
  2556. {
  2557. $wid .= " id = ".$value." or";
  2558. }
  2559. }
  2560. else
  2561. {
  2562. header('Location: /');exit;
  2563. }
  2564. $kx = '';$zjtab = '';
  2565. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2566. $this->data['transfer'] = $transfer;
  2567. $transfer_ids = array_column($transfer, 'id');
  2568. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2569. $this->data['vip'] = $user['vip'];
  2570. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2571. $this->_Template('transfer_wjsrk',$this->data);
  2572. }
  2573. public function _wjsrkexcel(){
  2574. $api = $this->input->get('api',true);
  2575. $transfer = $this->input->get('transfer',true);
  2576. $timetk = $this->input->get('timetk',true);
  2577. $timetj = $this->input->get('timetj',true);
  2578. $timetk = strtotime($timetk);
  2579. $timetj = strtotime($timetj);
  2580. $transfer_list = $this->transfer->find_all();
  2581. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2582. $where = 'extra_status in (1,2) ';
  2583. //数据排序
  2584. $order_str = "id desc";
  2585. if($transfer){
  2586. $where .= " and lx = '$transfer'";
  2587. }else{
  2588. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2589. $transfer_ids = array_column($transfer, 'id');
  2590. $transfer_ids = implode(",",$transfer_ids);
  2591. $where .= " and lx in (".$transfer_ids.") ";
  2592. }
  2593. $where .= " and time > '$timetk' and time < '$timetj'";
  2594. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2595. $final_list = [];
  2596. foreach ($list as $key => $value) {
  2597. $info = $this->systemtransfer->read($value['fid']);
  2598. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2599. $final_list[$key]['pm'] = $info['pm'];
  2600. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2601. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2602. }
  2603. $filename = date("Y-m-d")."超期未流转单导出.xls";
  2604. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2605. <head>
  2606. <!--[if gte mso 9]><xml>
  2607. <x:ExcelWorkbook>
  2608. <x:ExcelWorksheets>
  2609. <x:ExcelWorksheet>
  2610. <x:Name>EXCEL</x:Name>
  2611. <x:WorksheetOptions>
  2612. <x:Print>
  2613. <x:ValidPrinterInfo />
  2614. </x:Print>
  2615. </x:WorksheetOptions>
  2616. </x:ExcelWorksheet>
  2617. </x:ExcelWorksheets>
  2618. </x:ExcelWorkbook>
  2619. </xml>
  2620. <![endif]-->
  2621. </head><body>";
  2622. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2623. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2624. foreach ($final_list as $key=>$value)
  2625. {
  2626. if(empty($value['number'])){
  2627. continue;
  2628. }
  2629. $str .= "<tr>";
  2630. $str .= "<td>". $value['number']. "</td>";
  2631. $str .= "<td>". $value['pm']. "</td>";
  2632. $str .= "<td>". $value['lx_name']. "</td>";
  2633. $str .= "<td>". $value['time']. "</td>";
  2634. $str .= "</tr>";
  2635. }
  2636. $str .= "</table></body></html>";
  2637. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2638. header( "Content-type: application/octet-stream" );
  2639. header( "Content-Disposition: attachment; filename=".$filename );
  2640. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2641. header( "Pragma: no-cache" );
  2642. header( "Expires: 0" );
  2643. exit($str);
  2644. }
  2645. public function _cqrk(){
  2646. $post = $this->input->post(NULL, TRUE);
  2647. if(isset($post['page']))
  2648. {
  2649. $api = $this->input->post('api',true);
  2650. $page = $this->input->post('page',true);
  2651. $perpage = $this->input->post('perpage',true);
  2652. $transfer = $this->input->post('transfer',true);
  2653. $transfer_ids = $this->input->post('transfer_ids',true);
  2654. $orver_flag = $this->input->post('orver_flag',true);
  2655. $timetk = $this->input->post('timetk',true);
  2656. $timetj = $this->input->post('timetj',true);
  2657. $timetk = strtotime($timetk);
  2658. $timetj = strtotime($timetj);
  2659. $transfer_list = $this->transfer->find_all();
  2660. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2661. $where = 'extra_status in (2,3) ';
  2662. //数据排序
  2663. $order_str = "id desc";
  2664. if(empty($page))
  2665. {
  2666. $start = 0;
  2667. $perpage = 1;
  2668. }
  2669. else
  2670. {
  2671. $start = ($page - 1)*$perpage;
  2672. }
  2673. if($transfer){
  2674. $where .= " and lx = '$transfer'";
  2675. }else{
  2676. $where .= " and lx in (".$transfer_ids.") ";
  2677. }
  2678. $where .= " and time > '$timetk' and time < '$timetj'";
  2679. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2680. $final_list = [];
  2681. foreach ($list as $key => $value) {
  2682. $info = $this->systemtransfer->read($value['fid']);
  2683. $final_list[$key]['id'] = $value['id'];
  2684. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2685. if($info['is_jiaji'] == 2){
  2686. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2687. }else{
  2688. $final_list[$key]['is_jiaji'] = "常规";
  2689. }
  2690. $final_list[$key]['pm'] = $info['pm'];
  2691. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2692. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2693. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2694. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2695. foreach ($data as $k=>$v)
  2696. {
  2697. $type = ($v['type']==1)?'入库':'出库';
  2698. if($v['orver_flag'] == 1){
  2699. if($v['is_over'] == 0){
  2700. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900;'> 即将超时 </l></a>";
  2701. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2702. }else{
  2703. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2704. }
  2705. }elseif($v['orver_flag'] == 2){
  2706. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#f33'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ." <l style='padding-left:10px;font-weight:900'> 超 时 ! </l></a>";
  2707. }else{
  2708. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</a>";
  2709. }
  2710. if($v['extra_status'] == 1){
  2711. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2712. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2713. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2714. }else{
  2715. $info_list[$key]['time'] .= "<br>";
  2716. }
  2717. }
  2718. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2719. }
  2720. $total = $this->systemtransfer_cr->find_count($where);
  2721. $pagenum = ceil($total/$perpage);
  2722. $over = $total-($start+$perpage);
  2723. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2724. echo json_encode($rows);exit;
  2725. }
  2726. if(isset($_SESSION['api']))
  2727. {
  2728. $user = $this->user->get_api($_SESSION['api']);
  2729. $usp = $user;
  2730. $pid = "";$tid="";$sid="";$wid="";
  2731. $purchase = explode('|',trim($user['purchase'],'|'));
  2732. $transfer = explode('|',trim($user['transfer'],'|'));
  2733. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2734. foreach ($purchase as $value)
  2735. {
  2736. $pid .= " id = ".$value." or";
  2737. }
  2738. foreach ($transfer as $value)
  2739. {
  2740. $tid .= " id = ".$value." or";
  2741. }
  2742. foreach ($warehouse as $value)
  2743. {
  2744. $wid .= " id = ".$value." or";
  2745. }
  2746. }
  2747. else
  2748. {
  2749. header('Location: /');exit;
  2750. }
  2751. $kx = '';$zjtab = '';
  2752. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2753. $this->data['transfer'] = $transfer;
  2754. $transfer_ids = array_column($transfer, 'id');
  2755. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2756. $this->data['vip'] = $user['vip'];
  2757. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2758. $this->_Template('transfer_cqrk',$this->data);
  2759. }
  2760. public function _cqrkexcel(){
  2761. $api = $this->input->get('api',true);
  2762. $transfer = $this->input->get('transfer',true);
  2763. $timetk = $this->input->get('timetk',true);
  2764. $timetj = $this->input->get('timetj',true);
  2765. $timetk = strtotime($timetk);
  2766. $timetj = strtotime($timetj);
  2767. $transfer_list = $this->transfer->find_all();
  2768. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2769. $where = 'extra_status in (2,3) ';
  2770. //数据排序
  2771. $order_str = "id desc";
  2772. if($transfer){
  2773. $where .= " and lx = '$transfer'";
  2774. }else{
  2775. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2776. $transfer_ids = array_column($transfer, 'id');
  2777. $transfer_ids = implode(",",$transfer_ids);
  2778. $where .= " and lx in (".$transfer_ids.") ";
  2779. }
  2780. $where .= " and time > '$timetk' and time < '$timetj'";
  2781. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2782. $final_list = [];
  2783. foreach ($list as $key => $value) {
  2784. $info = $this->systemtransfer->read($value['fid']);
  2785. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2786. $final_list[$key]['pm'] = $info['pm'];
  2787. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2788. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2789. }
  2790. $filename = date("Y-m-d")."超期3天未流转单导出.xls";
  2791. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2792. <head>
  2793. <!--[if gte mso 9]><xml>
  2794. <x:ExcelWorkbook>
  2795. <x:ExcelWorksheets>
  2796. <x:ExcelWorksheet>
  2797. <x:Name>EXCEL</x:Name>
  2798. <x:WorksheetOptions>
  2799. <x:Print>
  2800. <x:ValidPrinterInfo />
  2801. </x:Print>
  2802. </x:WorksheetOptions>
  2803. </x:ExcelWorksheet>
  2804. </x:ExcelWorksheets>
  2805. </x:ExcelWorkbook>
  2806. </xml>
  2807. <![endif]-->
  2808. </head><body>";
  2809. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2810. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2811. foreach ($final_list as $key=>$value)
  2812. {
  2813. if(empty($value['number'])){
  2814. continue;
  2815. }
  2816. $str .= "<tr>";
  2817. $str .= "<td>". $value['number']. "</td>";
  2818. $str .= "<td>". $value['pm']. "</td>";
  2819. $str .= "<td>". $value['lx_name']. "</td>";
  2820. $str .= "<td>". $value['time']. "</td>";
  2821. $str .= "</tr>";
  2822. }
  2823. $str .= "</table></body></html>";
  2824. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2825. header( "Content-type: application/octet-stream" );
  2826. header( "Content-Disposition: attachment; filename=".$filename );
  2827. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2828. header( "Pragma: no-cache" );
  2829. header( "Expires: 0" );
  2830. exit($str);
  2831. }
  2832. /**
  2833. * 导出excel 操作部门是否出库
  2834. */
  2835. public function _czbmIsOutExcel(){
  2836. if($this->input->method() == 'get'){
  2837. $number = $this->input->get('number',true);
  2838. $color = $this->input->get('color',true);
  2839. $purchase = $this->input->get('purchase',true);
  2840. $transfer = $this->input->get('transfer',true);
  2841. $lx = $this->input->get('lx',true);
  2842. $type = $this->input->get('type',true);
  2843. $pm = $this->input->get('pm',true);
  2844. $jiaji = $this->input->get('jiaji',true);
  2845. $timetk = $this->input->get('timetk',true);
  2846. $timetj = $this->input->get('timetj',true);
  2847. $timetk = strtotime($timetk);
  2848. $timetj = strtotime($timetj);
  2849. $where = '1=1';
  2850. if($number)
  2851. {
  2852. $where .= " and number = '$number'";
  2853. }
  2854. if($pm){
  2855. $where .= " and pm like '%".$pm."%'";
  2856. }
  2857. if($purchase)
  2858. {
  2859. $where .= " and purchase = '$purchase'";
  2860. }
  2861. if($color)
  2862. {
  2863. $where .= " and fpdata like '%-".$color."-%'";
  2864. }
  2865. if($lx)
  2866. {
  2867. if($lx == 1)
  2868. {
  2869. $where .= " and ordernumber = ''";
  2870. }
  2871. else
  2872. {
  2873. $where .= " and ordernumber != ''";
  2874. }
  2875. }
  2876. if($jiaji){
  2877. if($jiaji == 1){
  2878. $where .= " and is_jiaji = 0";
  2879. }
  2880. if($jiaji == 2){
  2881. $where .= " and is_jiaji = 2";
  2882. }
  2883. }
  2884. //数据排序
  2885. $order_str = "id desc";
  2886. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  2887. if($type)
  2888. {
  2889. if($type == 3){
  2890. if($transfer)
  2891. {
  2892. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  2893. }
  2894. }else{
  2895. $type = ($type==1)?'rk':'ck';
  2896. if($transfer)
  2897. {
  2898. $where .= " and $type like '%|".$transfer."|%'";
  2899. }
  2900. }
  2901. }
  2902. else
  2903. {
  2904. if($transfer)
  2905. {
  2906. $where .= " and rk like '%|".$transfer."|%'";
  2907. }
  2908. }
  2909. //取得信息列表
  2910. $info_list = $this->systemtransfer->find_all($where,'*',$order_str);
  2911. $transfer = $this->transfer->find_all();
  2912. $t = array();
  2913. foreach ($transfer as $v)
  2914. {
  2915. $t[$v['id']] = $v['title'];
  2916. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2917. }
  2918. $final_list = [];
  2919. //格式化数据
  2920. foreach ($info_list as $key=>$value)
  2921. {
  2922. $transfer_list = $this->_get_transfer_data($value,$t);
  2923. $final_list[] = [
  2924. 'number'=>$value['number'],
  2925. 'pm'=>$value['pm'],
  2926. 'transfer_list'=>$transfer_list,
  2927. ];
  2928. }
  2929. $filename = date("Y-m-d")."操作部门库存是否存在.xls";
  2930. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2931. <head>
  2932. <!--[if gte mso 9]><xml>
  2933. <x:ExcelWorkbook>
  2934. <x:ExcelWorksheets>
  2935. <x:ExcelWorksheet>
  2936. <x:Name>EXCEL</x:Name>
  2937. <x:WorksheetOptions>
  2938. <x:Print>
  2939. <x:ValidPrinterInfo />
  2940. </x:Print>
  2941. </x:WorksheetOptions>
  2942. </x:ExcelWorksheet>
  2943. </x:ExcelWorksheets>
  2944. </x:ExcelWorkbook>
  2945. </xml>
  2946. <![endif]-->
  2947. </head><body>";
  2948. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2949. $str .= "<tr><td>订单编号</td><td>品名</td><td>操作部门</td><td>扫入日期</td><td>扫出日期</td><td>是否出库</td></tr>";
  2950. foreach ($final_list as $key=>$value)
  2951. {
  2952. if(empty($value['number'])){
  2953. continue;
  2954. }
  2955. $str .= "<tr>";
  2956. $str .= "<td>". $value['number']. "</td>";
  2957. $str .= "<td>". $value['pm']. "</td>";
  2958. $tmp_czbm = '';
  2959. $tmp_srrq = '';
  2960. $tmp_scrq = '';
  2961. $tmp_is_out = '';
  2962. foreach ($value['transfer_list'] as $k=>$v)
  2963. {
  2964. $tmp_czbm .= $v['lx_show'].'<br/>';
  2965. $tmp_srrq .= empty($v['rk_time'])?'无<br/>': date('Y-m-d H:i:s',$v['rk_time']).'<br/>';
  2966. $tmp_scrq .= empty($v['ck_time'])?'无<br/>': date('Y-m-d H:i:s',$v['ck_time']).'<br/>';
  2967. if($v['is_over'] == 2){
  2968. $tmp_is_out .= '是<br/>';
  2969. }elseif($v['is_over'] == 1){
  2970. $tmp_is_out .= '否<br/>';
  2971. }else{
  2972. $tmp_is_out .= '异常<br/>';
  2973. }
  2974. }
  2975. $tmp_czbm = trim($tmp_czbm,'<br/>');
  2976. $tmp_srrq = trim($tmp_srrq,'<br/>');
  2977. $tmp_scrq = trim($tmp_scrq,'<br/>');
  2978. $tmp_is_out = trim($tmp_is_out,'<br/>');
  2979. $str .= "<td>". $tmp_czbm. "</td>";
  2980. $str .= "<td>". $tmp_srrq. "</td>";
  2981. $str .= "<td>". $tmp_scrq. "</td>";
  2982. $str .= "<td>". $tmp_is_out. "</td>";
  2983. $str .= "</tr>";
  2984. }
  2985. $str .= "</table></body></html>";
  2986. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2987. header( "Content-type: application/octet-stream" );
  2988. header( "Content-Disposition: attachment; filename=".$filename );
  2989. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2990. header( "Pragma: no-cache" );
  2991. header( "Expires: 0" );
  2992. exit($str);
  2993. }
  2994. }
  2995. public function _get_transfer_data($info,$t){
  2996. $rk_list = explode('|',trim($info['rk'],'|'));
  2997. $rk_time = explode('|',trim($info['rktime'],'|'));
  2998. $ck_list = explode('|',trim($info['ck'],'|'));
  2999. $ck_time = explode('|',trim($info['cktime'],'|'));
  3000. if(count($rk_time) < count($ck_time)){
  3001. return [
  3002. 'code'=>-1,
  3003. 'msg'=>'数据异常,('.$info['id'].')联系技术',
  3004. ];
  3005. }
  3006. $tran_list = [];
  3007. $len = count($rk_list);
  3008. $ck_index = 0;
  3009. for($i = 0;$i < $len;$i++){
  3010. if(isset($rk_list[$i]) && empty($ck_list[$ck_index]) ){
  3011. $tran_list[] = [
  3012. 'lx'=>$rk_list[$i],
  3013. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3014. 'rk_time'=>$rk_time[$i],
  3015. 'ck_time'=>'',
  3016. 'is_over'=>1,//未出库
  3017. ];
  3018. }else{
  3019. if($rk_list[$i] == $ck_list[$ck_index]){
  3020. $tran_list[] = [
  3021. 'lx'=>$rk_list[$i],
  3022. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3023. 'rk_time'=>$rk_time[$i],
  3024. 'ck_time'=>$ck_time[$ck_index],
  3025. 'is_over'=>2,//已出库
  3026. ];
  3027. $ck_index++;
  3028. }else if($rk_list[$i] != $ck_list[$ck_index]){
  3029. if($rk_list[$i] == $ck_list[$ck_index-1]){
  3030. //估计是之前完成 或者 成品库 强制扫入
  3031. $tran_list[] = [
  3032. 'lx'=>$rk_list[$i],
  3033. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3034. 'rk_time'=>$rk_time[$i],
  3035. 'ck_time'=>$ck_time[$ck_index-1],
  3036. 'is_over'=>2,//已出库
  3037. ];
  3038. }else if( !empty($ck_list[$ck_index+1]) &&($rk_list[$i] == $ck_list[$ck_index+1])){
  3039. //估计是完成 或者 成品库 强制扫出了
  3040. $tran_list[] = [
  3041. 'lx'=>$rk_list[$i],
  3042. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3043. 'rk_time'=>$rk_time[$i],
  3044. 'ck_time'=>$ck_time[$ck_index+1],
  3045. 'is_over'=>2,//已出库
  3046. ];
  3047. $ck_index++;
  3048. $ck_index++;
  3049. }else{
  3050. //估计是完成 或者 成品库 强制扫出了
  3051. $tran_list[] = [
  3052. 'lx'=>$rk_list[$i],
  3053. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3054. 'rk_time'=>$rk_time[$i],
  3055. 'ck_time'=>'',
  3056. 'is_over'=>-3,//已出库
  3057. ];
  3058. }
  3059. }
  3060. }
  3061. }
  3062. return $tran_list;
  3063. }
  3064. public function _ycrk(){
  3065. if($this->input->method() == 'get'){
  3066. echo json_encode(array('msg'=>'请求方式不正确','success'=>false));exit;
  3067. }
  3068. $id = $this->input->post('id',true);
  3069. $type = $this->input->post('type',true);
  3070. if(!in_array($type,[1,2,3])){
  3071. echo json_encode(array('msg'=>'入库类别异常,联系技术','success'=>false));exit;
  3072. }
  3073. $info = $this->systemtransfer->read($id);
  3074. if(empty($info)){
  3075. echo json_encode(array('msg'=>'数据不存在','success'=>false));exit;
  3076. }
  3077. if(!empty($info['ycrk_type'])){
  3078. echo json_encode(array('msg'=>'已添加异常入库,不要重复添加','success'=>false));exit;
  3079. }
  3080. //更新数据
  3081. $this->systemtransfer->save([
  3082. 'ycrk_type'=>$type,
  3083. ],$id);
  3084. $list = $this->systemtransfer_cr->find_all('fid = '.$id,'*','id desc');
  3085. foreach ($list as $key=>$value) {
  3086. $this->systemtransfer_cr->save([
  3087. 'ycrk_type'=>$type,
  3088. ],$value['id']);
  3089. }
  3090. $this->systemtransfer_cr->insert([
  3091. 'fid'=>$id,'lx'=>0,'type'=>$type,'time'=>time(),'is_over'=>0,'over_flag'=>0,
  3092. 'extra_status'=>0,'ycrk_type'=>$type,
  3093. ]);
  3094. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  3095. }
  3096. public function _ycrkindex(){
  3097. if($this->input->method() == 'get'){
  3098. if(isset($_SESSION['api']))
  3099. {
  3100. $user = $this->user->get_api($_SESSION['api']);
  3101. $usp = $user;
  3102. $pid = "";$tid="";$sid="";$wid="";
  3103. $purchase = explode('|',trim($user['purchase'],'|'));
  3104. $transfer = explode('|',trim($user['transfer'],'|'));
  3105. $warehouse = explode('|',trim($user['warehouse'],'|'));
  3106. foreach ($purchase as $value)
  3107. {
  3108. $pid .= " id = ".$value." or";
  3109. }
  3110. foreach ($transfer as $value)
  3111. {
  3112. $tid .= " id = ".$value." or";
  3113. }
  3114. foreach ($warehouse as $value)
  3115. {
  3116. $wid .= " id = ".$value." or";
  3117. }
  3118. }
  3119. else
  3120. {
  3121. header('Location: /');exit;
  3122. }
  3123. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  3124. $this->data['transfer'] = $transfer;
  3125. $transfer_ids = array_column($transfer, 'id');
  3126. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  3127. $this->_Template('transfer_ycrkindex',$this->data);
  3128. }else{
  3129. $page = $this->input->post('page',true);
  3130. $perpage = $this->input->post('perpage',true);
  3131. $transfer_ids = $this->input->post('transfer_ids',true);
  3132. $timetk = $this->input->post('timetk',true);
  3133. $timetj = $this->input->post('timetj',true);
  3134. $timetk = strtotime($timetk);
  3135. $timetj = strtotime($timetj);
  3136. $transfer_list = $this->transfer->find_all();
  3137. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  3138. $where = 'lx = 0 and ycrk_type != 0 ';
  3139. //数据排序
  3140. $order_str = "id desc";
  3141. if(empty($page))
  3142. {
  3143. $start = 0;
  3144. $perpage = 1;
  3145. }
  3146. else
  3147. {
  3148. $start = ($page - 1)*$perpage;
  3149. }
  3150. $where .= " and time > '$timetk' and time < '$timetj'";
  3151. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  3152. $final_list = [];
  3153. foreach ($list as $key => $value) {
  3154. $info = $this->systemtransfer->read($value['fid']);
  3155. $final_list[$key]['id'] = $value['id'];
  3156. $final_list[$key]['number'] = $info['number'];
  3157. $ycrk_type_str = "";
  3158. if($value['ycrk_type'] == 3){
  3159. $ycrk_type_str = "外销单入库";
  3160. }else if($value['ycrk_type'] == 2){
  3161. $ycrk_type_str = "成品库入库";
  3162. }else{
  3163. $ycrk_type_str = "配货入库";
  3164. }
  3165. $final_list[$key]['ycrk_type'] = $ycrk_type_str;
  3166. $final_list[$key]['pm'] = $info['pm'];
  3167. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  3168. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  3169. $final_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  3170. }
  3171. $total = $this->systemtransfer_cr->find_count($where);
  3172. $pagenum = ceil($total/$perpage);
  3173. $over = $total-($start+$perpage);
  3174. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  3175. echo json_encode($rows);exit;
  3176. }
  3177. }
  3178. }