Transfer.php 114 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489
  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. if(!empty($info_list[$key]['ycrk_type'])){
  895. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  896. }else{
  897. $info_list[$key]['time'] = "<div onclick='addYcrk(".$info_list[$key]['id'].")'>".trim($info_list[$key]['time'],'<br>')."</div>";
  898. }
  899. unset($info_list[$key]['ctime12']);
  900. }
  901. $total = $this->systemtransfer->find_count($where);
  902. $pagenum = ceil($total/$perpage);
  903. $over = $total-($start+$perpage);
  904. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  905. echo json_encode($rows);exit;
  906. }
  907. if(isset($_SESSION['api']))
  908. {
  909. $user = $this->user->get_api($_SESSION['api']);
  910. $usp = $user;
  911. $pid = "";$tid="";$sid="";$wid="";
  912. $purchase = explode('|',trim($user['purchase'],'|'));
  913. $transfer = explode('|',trim($user['transfer'],'|'));
  914. $warehouse = explode('|',trim($user['warehouse'],'|'));
  915. foreach ($purchase as $value)
  916. {
  917. $pid .= " id = ".$value." or";
  918. }
  919. foreach ($transfer as $value)
  920. {
  921. $tid .= " id = ".$value." or";
  922. }
  923. foreach ($warehouse as $value)
  924. {
  925. $wid .= " id = ".$value." or";
  926. }
  927. }
  928. else
  929. {
  930. header('Location: /');exit;
  931. }
  932. $sc_flag = 0; //生产中按钮的标识符号 为1的是可以查看 0 不可以
  933. //只有admin和toutao用户可以查看
  934. if(in_array($user['id'],[10,44,50])){
  935. $sc_flag = 1;
  936. }
  937. $this->data['sc_flag'] = $sc_flag;
  938. $kx = '';$zjtab = '';
  939. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  940. $this->data['warehouse'] = $warehouse;
  941. $purchase = $this->purchase->find_all("yyid != ''");
  942. $this->data['purchase'] = $purchase;
  943. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  944. $this->data['transfer'] = $transfer;
  945. $this->data['vip'] = $user['vip'];
  946. $transfer_ids = array_column($transfer,'id');
  947. $transfer_str = implode(",",$transfer_ids);
  948. $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.")");
  949. $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.")");
  950. //$jiaji_num = 0;
  951. // $jiaji_num = $this->systemtransfer->find_count(" is_jiaji = 2 and time > ".(time()-3600*24*7)." and rk not like '%|11|%'" );
  952. foreach($transfer_ids as $k=>$v){
  953. if($v == 11){
  954. unset($transfer_ids[$k]);
  955. }
  956. }
  957. if(empty($transfer_ids)){
  958. $this->data['jiaji_num'] = -1;
  959. }else{
  960. $transfer_str = implode(",",$transfer_ids);
  961. $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|%'");
  962. // 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|%'");
  963. $tmp_list= $sql_r->result_array();
  964. $this->data['jiaji_num'] = count($tmp_list);
  965. }
  966. $this->_Template('transfer_operate',$this->data);
  967. }
  968. public function _out()
  969. {
  970. $post = $this->input->post(NULL, TRUE);
  971. if(isset($post['label']))
  972. {
  973. $time = time();
  974. $label = $this->input->post('label',true);
  975. $cz = $this->input->post('cz',true);
  976. $transfer = $this->input->post('transfer',true);
  977. if(!$label)
  978. {
  979. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  980. }
  981. if(!$transfer)
  982. {
  983. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  984. }
  985. $lb = $this->systemtransfer->get_label($label);
  986. if(!$lb)
  987. {
  988. $this->logic_ding->sendToDing("检测货物流转异常的编码".$transfer."|".$label);
  989. echo json_encode(array('msg'=>'错误!未找到此条码,请联系申天','success'=>false));exit;
  990. }
  991. if($lb['id'] == 136872 || $label == '17573171077300'){
  992. echo json_encode(array('msg'=>'此单请退 回配货库','success'=>false));exit;
  993. }
  994. //东恒的如果扫过完成 就不允许再扫入
  995. if($lb['type'] == 2){
  996. if((strpos($lb['rk'],3)!== false) && ($transfer !=3)){
  997. echo json_encode(array('msg'=>'东恒的货物不允许重复扫描!','success'=>false));exit;
  998. }
  999. }
  1000. if($lb['number']!='')
  1001. {
  1002. $nu = $this->fullorder->get_number($lb['number']);
  1003. if(!$nu)
  1004. {
  1005. $nu = $this->fullordersmt->get_number($lb['number']);
  1006. if(!$nu)
  1007. {
  1008. $nu = $this->fullordertt->get_number($lb['number']);
  1009. }
  1010. }
  1011. //取消的订单还是要继续生产的 所以还允许继续扫入扫出 只是后续的出入库中不在限定时间
  1012. // if($nu['state'] == '214' || $nu['state'] == '217')
  1013. // {
  1014. // echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit;
  1015. // }
  1016. }
  1017. $tdata = $this->transfer->find_all();
  1018. $t = array();
  1019. foreach ($tdata as $v)
  1020. {
  1021. $t[$v['id']] = $v['title'];
  1022. }
  1023. /**
  1024. if($cz == 1 && stripos($lb['rk'],'|'.$transfer.'|') !== false)
  1025. {
  1026. echo json_encode(array('msg'=>'此条码已有入库操作!','success'=>false));exit;
  1027. }
  1028. if($cz == 2 && stripos($lb['ck'],'|'.$transfer.'|') !== false)
  1029. {
  1030. echo json_encode(array('msg'=>'此条码已有出库操作!','success'=>false));exit;
  1031. }
  1032. **/
  1033. // if(stripos($lb['ck'],'|1|') === false && $transfer != 1 && stripos($nu['fpdata'],'-128-') !== false)
  1034. // {
  1035. // echo json_encode(array('msg'=>'必须有配货出库才可后续操作!','success'=>false));exit;
  1036. // }
  1037. //如果是外销单 成品库不许扫入
  1038. if($transfer == 11 && $cz == 1 && $lb['type'] == 2){
  1039. echo json_encode(array('msg'=>'工厂的外销单成品库不许扫入!','success'=>false));exit;
  1040. }
  1041. //重新定义配货的原则问题
  1042. //先检测订单是否含有 128 头套 或者配件 如果有 133 进行下一步检测
  1043. $sku_arr = explode("-",$lb['features']);
  1044. if(in_array(128,$sku_arr)||in_array(133,$sku_arr)){
  1045. // 145 Full Lace Wig
  1046. // 1170 HDFullLaceWig
  1047. // 1249 FullLaceBobwithBang
  1048. // 1484 FullLaceBob
  1049. //如果是这4中全蕾丝那么配货就不处理
  1050. if(in_array(145,$sku_arr) || in_array(1170,$sku_arr) || in_array(1249,$sku_arr) || in_array(1484,$sku_arr)){
  1051. }else{
  1052. if(stripos($lb['ck'],'|1|') === false && $transfer != 1 )
  1053. {
  1054. echo json_encode(array('msg'=>'头套和配件除了全蕾丝外必须走配货!','success'=>false));exit;
  1055. }
  1056. }
  1057. }
  1058. if($cz == 2 && stripos($lb['rk'],'|'.$transfer.'|') === false)
  1059. {
  1060. echo json_encode(array('msg'=>'此条码还未入库!','success'=>false));exit;
  1061. }
  1062. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1063. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1064. if($transfer != 3 && $transfer != 11 )
  1065. {
  1066. if($cz == 1)
  1067. {
  1068. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1069. {
  1070. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1071. }
  1072. }
  1073. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1074. {
  1075. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1076. }
  1077. }
  1078. if($cz == 1)
  1079. {
  1080. $lb['rk'] .= $transfer.'|';
  1081. $lb['rktime'] .= $time.'|';
  1082. if($lbrk[0] == $transfer)
  1083. {
  1084. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1085. }
  1086. }
  1087. else if($cz == 2)
  1088. {
  1089. $lb['ck'] .= $transfer.'|';
  1090. $lb['cktime'] .= $time.'|';
  1091. if($lbck[0] == $transfer)
  1092. {
  1093. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1094. }
  1095. }
  1096. $this->_doCancelWlz($lb['id']);
  1097. $cztime = 'ctime'.$transfer;
  1098. $this->logic_ding->sendToDing("检测货物流转打印情况".$transfer."|".$cz."|".$lb['number']."|".$lb['id']);
  1099. if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1100. //if(($transfer == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1)//单入库
  1101. {
  1102. if($lb['type'] == 0)
  1103. {
  1104. $s = $this->shop->read($nu['shop']);
  1105. $lb['kh'] = $s['yyid'];
  1106. $lb['ts'] = 1;
  1107. $rk = $this->apiyy->_newrk($lb);
  1108. if($rk['c'] == 0)
  1109. {
  1110. $this->db->trans_begin();
  1111. $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']);
  1112. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1113. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1114. if($cz == 2){
  1115. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1116. }
  1117. if ($this->db->trans_status() === TRUE)
  1118. {
  1119. $this->db->trans_commit();
  1120. if($nu['state'] == '216')
  1121. {
  1122. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1123. }
  1124. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1125. //标记订单已经取消
  1126. $this->_doCheckCancelFlag($lb['id']);
  1127. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1128. }
  1129. else
  1130. {
  1131. if($lb['is_jiaji'] == 2){
  1132. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1133. }elseif($lb['type'] == 2){
  1134. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1135. }else{
  1136. echo json_encode(array('music'=>'1','success'=>true));exit;
  1137. }
  1138. }
  1139. }
  1140. else
  1141. {
  1142. $this->db->trans_rollback();
  1143. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1144. }
  1145. }
  1146. else
  1147. {
  1148. if(stripos($rk['error'],'DocNo') !== false)
  1149. {
  1150. $rk['error'] = '未找到对应的生产订单 '.$lb['scid'];
  1151. }
  1152. $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']);
  1153. echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit;
  1154. }
  1155. }elseif($lb['type'] == 2){
  1156. $this->db->trans_begin();
  1157. $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']);
  1158. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1159. $this->zzquque_u9->insert([
  1160. 'platform'=>'',
  1161. 'warehouse'=>0,
  1162. 'type'=>20, //5代表美仓
  1163. 'order_no'=>$lb['number'],
  1164. 'child_order_no'=>$lb['id'],
  1165. 'status'=>0,
  1166. 'create_time'=>time(),
  1167. 'update_time'=>time(),
  1168. ]);
  1169. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1170. if($cz == 2){
  1171. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1172. }
  1173. if ($this->db->trans_status() === TRUE)
  1174. {
  1175. $this->db->trans_commit();
  1176. if($nu['state'] == '216')
  1177. {
  1178. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1179. }
  1180. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1181. //标记订单已经取消
  1182. $this->_doCheckCancelFlag($lb['id']);
  1183. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1184. }
  1185. else
  1186. {
  1187. if($lb['is_jiaji'] == 2){
  1188. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1189. }elseif($lb['type'] == 2){
  1190. echo json_encode(array('music'=>'1','is_jiaji'=>3,'success'=>true));exit;
  1191. }else{
  1192. echo json_encode(array('music'=>'1','success'=>true));exit;
  1193. }
  1194. }
  1195. }
  1196. else
  1197. {
  1198. $this->db->trans_rollback();
  1199. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1200. }
  1201. }
  1202. else
  1203. {
  1204. $scid = explode('~',$lb['scid']);
  1205. $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']);
  1206. $rk = $this->apiyy->get_bzsh($rkdata);
  1207. if(isset($rk['Data'][0]))
  1208. {
  1209. if($rk['Data'][0]['IsSucess'] == 1)
  1210. {
  1211. $this->db->trans_begin();
  1212. $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']);
  1213. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1214. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1215. if($cz == 2){
  1216. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1217. }
  1218. if ($this->db->trans_status() === TRUE)
  1219. {
  1220. $this->db->trans_commit();
  1221. if($nu['state'] == '216')
  1222. {
  1223. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1224. }
  1225. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1226. //标记订单已经取消
  1227. $this->_doCheckCancelFlag($lb['id']);
  1228. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1229. }
  1230. else
  1231. {
  1232. if($lb['is_jiaji'] == 2){
  1233. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1234. }else{
  1235. echo json_encode(array('music'=>'1','success'=>true));exit;
  1236. }
  1237. }
  1238. }
  1239. else
  1240. {
  1241. $this->db->trans_rollback();
  1242. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1243. }
  1244. }
  1245. else
  1246. {
  1247. echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit;
  1248. }
  1249. }
  1250. else
  1251. {
  1252. echo json_encode(array('msg'=>$rk,'success'=>false));exit;
  1253. }
  1254. }
  1255. }
  1256. //if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//只入库
  1257. if($transfer == 11 && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库
  1258. {
  1259. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1260. }
  1261. $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']);
  1262. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1263. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1264. if($cz == 2){
  1265. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1266. }
  1267. if ($this->db->trans_status() === TRUE)
  1268. {
  1269. $this->db->trans_commit();
  1270. if($nu['state'] == '216')
  1271. {
  1272. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1273. }
  1274. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1275. //标记订单已经取消
  1276. $this->_doCheckCancelFlag($lb['id']);
  1277. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1278. }
  1279. else
  1280. {
  1281. if($lb['is_jiaji'] == 2){
  1282. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1283. }else{
  1284. echo json_encode(array('music'=>'1','success'=>true));exit;
  1285. }
  1286. }
  1287. }
  1288. else
  1289. {
  1290. $this->db->trans_rollback();
  1291. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1292. }
  1293. }
  1294. }
  1295. //检测取消标记是否添加 同时也检查下 该流转单是否被标记为取消单
  1296. private function _doCheckCancelFlag($fid){
  1297. $info = $this->systemtransfer->read($fid);
  1298. if($info['status'] != 11){
  1299. $this->systemtransfer->save(['status'=>11],$fid);
  1300. }
  1301. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1302. if(empty($list)){
  1303. return;
  1304. }
  1305. $is_cancel = false;
  1306. foreach($list as $val){
  1307. if($val['orver_flag'] == 3){
  1308. $is_cancel = true;
  1309. }
  1310. }
  1311. if($is_cancel){
  1312. return ;
  1313. }
  1314. $this->systemtransfer_cr->save(['orver_flag'=>3],$list[0]['id']);
  1315. }
  1316. //检测是否可以取消长期未流转
  1317. private function _doCancelWlz($fid){
  1318. //$info = $this->systemtransfer->read($fid);
  1319. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1320. if(empty($list)){
  1321. return;
  1322. }
  1323. $id = $list[0]['id'];
  1324. $scan_time = $list[0]['time'];
  1325. if($list[0]['type'] == 2){
  1326. if(time() - $scan_time < 3600 * 24 * 3){
  1327. $this->systemtransfer_cr->save([
  1328. 'extra_status'=>0,
  1329. ],$id);
  1330. }else{
  1331. $this->systemtransfer_cr->save([
  1332. 'extra_status'=>3,
  1333. ],$id);
  1334. }
  1335. }
  1336. }
  1337. //检测是否超时 车间流转环节
  1338. private function _doCheckIsOverTime($fid,$transfer){
  1339. $list = $this->systemtransfer_cr->find_all("fid = ".$fid." and lx = ".$transfer." and is_over = 0","*",'id desc',0,2);
  1340. if(count($list) < 2){
  1341. return ;
  1342. }
  1343. if($list[0]['type'] != 2){
  1344. return;
  1345. }
  1346. if($list[1]['type'] != 1){
  1347. return;
  1348. }
  1349. if($list[1]['orver_flag'] == 2){
  1350. $this->systemtransfer_cr->save(array('is_over'=>1,'orver_flag'=>2),$list[0]['id']);
  1351. }else{
  1352. $this->systemtransfer_cr->save(array('is_over'=>1),$list[0]['id']);
  1353. }
  1354. $this->systemtransfer_cr->save(array('is_over'=>1),$list[1]['id']);
  1355. }
  1356. public function _bdbb()
  1357. {
  1358. $post = $this->input->post(NULL, TRUE);
  1359. if(isset($post['s']))
  1360. {
  1361. $id_arr = $this->input->post('s');
  1362. $id_arr = explode(',',trim($id_arr,','));
  1363. if(!$id_arr)
  1364. {
  1365. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1366. }
  1367. //循环删除记录
  1368. foreach ($id_arr as $v)
  1369. {
  1370. $t = $this->systemtransfer->read($v);
  1371. if(!isset($t['number']))
  1372. {
  1373. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1374. }
  1375. $y = $this->fullorder->get_number($t['number']);
  1376. if(!$y)
  1377. {
  1378. $y = $this->fullordersmt->get_number($t['number']);
  1379. if(!$y)
  1380. {
  1381. $y = $this->fullordertt->get_number($t['number']);
  1382. if(!$y)
  1383. {
  1384. echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit;
  1385. }
  1386. }
  1387. }
  1388. $time = time();
  1389. $label = $time.rand(10000,99999); //substr($time,1)*100
  1390. $this->systemtransfer->save(array('label'=>$label),$v);
  1391. $express = $this->express->read($y['express']);
  1392. $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'=>"补打");
  1393. }
  1394. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1395. }
  1396. }
  1397. public function _excel()
  1398. {
  1399. if(isset($_GET['fexcel']))
  1400. {
  1401. $tc = array();$zh = array();
  1402. $typeclass = $this->typeclass->find_all();
  1403. foreach ($typeclass as $v)
  1404. {
  1405. $tc[$v['id']] = $v;
  1406. }
  1407. $number = $this->input->get('number',true);
  1408. $color = $this->input->get('color',true);
  1409. $gs = $this->input->get('gs',true);
  1410. $transfer = $this->input->get('transfer',true);
  1411. $type = $this->input->get('type',true);
  1412. $timetk = $this->input->get('timetk',true);
  1413. $timetj = $this->input->get('timetj',true);
  1414. $purchase = $this->input->get('purchase',true);
  1415. $lx = $this->input->get('lx',true);
  1416. $timetk = strtotime($timetk);
  1417. $timetj = strtotime($timetj);
  1418. $where = "1=1";
  1419. $cr = "time > '$timetk' and time < '$timetj'";
  1420. if($number)
  1421. {
  1422. $where .= " and number = '$number'";
  1423. }
  1424. if($transfer)
  1425. {
  1426. $cr .= " and lx = '".$transfer."'";
  1427. }
  1428. if($type)
  1429. {
  1430. //$cr .= " and type = '".$type."'";
  1431. if($type == 3){
  1432. $cr .= " and is_over = 0 ";
  1433. }else{
  1434. $cr .= " and type = '".$type."' ";
  1435. }
  1436. }
  1437. if($purchase)
  1438. {
  1439. $where .= " and purchase = '$purchase'";
  1440. }
  1441. if($color)
  1442. {
  1443. $where .= " and fpdata like '%-".$color."-%'";
  1444. }
  1445. if($lx)
  1446. {
  1447. if($lx == 1)
  1448. {
  1449. $where .= " and ordernumber = ''";
  1450. }
  1451. else
  1452. {
  1453. $where .= " and ordernumber != ''";
  1454. }
  1455. }
  1456. $fid = '';
  1457. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  1458. foreach ($info_list_cr as $v)
  1459. {
  1460. $fid .= "id = '".$v['fid']."' or ";
  1461. }
  1462. if($fid)
  1463. {
  1464. $where .= ' and ('.trim($fid,'or ').')';
  1465. }
  1466. else
  1467. {
  1468. $where .= ' and id = 0';
  1469. }
  1470. $data = array();
  1471. $datafy = array();
  1472. $j = 0;
  1473. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime');
  1474. $lzbm = $this->transfer->find_all();
  1475. foreach ($info_list as $key=>$value)
  1476. {
  1477. $dj = '';$ys = '';$cc = '';$hx = '';$md = '';
  1478. $d = $this->systemtransfer->read($value['id']);
  1479. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1480. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$d['shipremarks']);
  1481. $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']);
  1482. $cp = explode('-',trim($d['features'],'-'));
  1483. $rk = explode('|',trim($d['rk'],'|'));
  1484. $rktime = explode('|',trim($d['rktime'],'|'));
  1485. foreach ($cp as $v)
  1486. {
  1487. if(isset($tc[$v]))
  1488. {
  1489. if($tc[$v]['classid'] == 13)
  1490. {
  1491. $dj = $tc[$v]['title'];
  1492. }
  1493. else if($tc[$v]['classid'] == 8)
  1494. {
  1495. $ys = $tc[$v]['title'];
  1496. }
  1497. else if($tc[$v]['classid'] == 14)
  1498. {
  1499. $cc = $tc[$v]['title'];
  1500. }
  1501. else if($tc[$v]['classid'] == 15)
  1502. {
  1503. $hx = $tc[$v]['title'];
  1504. }
  1505. else if($tc[$v]['classid'] == 10)
  1506. {
  1507. $md = $tc[$v]['title'];
  1508. }
  1509. }
  1510. }
  1511. $rt = array();
  1512. foreach ($rk as $k=>$v)
  1513. {
  1514. $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]);
  1515. }
  1516. $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md));
  1517. foreach ($lzbm as $v)
  1518. {
  1519. if(isset($rt[count($fpdata[0])]))
  1520. {
  1521. //$fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1522. $num = $this->systemtransfer_cr->find_count("fid = ".$value['id']." and lx = ".$v['id']." and orver_flag = 2");
  1523. if($num > 0){
  1524. $fpdata[0][count($fpdata[0])] = "<span style='color:red;font-weight:bold;'>".$rt[count($fpdata[0])]."<span>";
  1525. }else{
  1526. $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1527. }
  1528. }
  1529. else
  1530. {
  1531. $fpdata[0][count($fpdata[0])] = '';
  1532. }
  1533. }
  1534. $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度
  1535. unset($info_list[$key]['id']);
  1536. }
  1537. //echo "<pre>";print_r($info_list);exit;
  1538. $lzxq = '';
  1539. foreach ($lzbm as $v)
  1540. {
  1541. $lzxq .= '<td>'.$v['title'].'</td>';
  1542. }
  1543. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表';
  1544. $titlename = "<table border=1>
  1545. <tr>
  1546. <td>订单编号</td>
  1547. <td>品名</td>
  1548. <td>简码</td>
  1549. <td>备注</td>
  1550. <td>打印时间</td>
  1551. <td>
  1552. <table border=1>
  1553. <tr><td colspan='6' align='center'>订单产品信息</td><td colspan='".count($lzbm)."' align='center'>货物流转时间</td></tr>
  1554. <tr>
  1555. <td>产品名称</td>
  1556. <td>尺寸</td>
  1557. <td>等级</td>
  1558. <td>颜色</td>
  1559. <td>花型</td>
  1560. <td>密度</td>
  1561. ".$lzxq."
  1562. </tr>
  1563. </table>
  1564. </td>
  1565. </tr>
  1566. </table>";
  1567. $filename = $title.".xls";
  1568. $tail = "\n";
  1569. $this->excel->get_fz($info_list,$titlename,$filename,$tail,1);
  1570. }
  1571. }
  1572. public function _rk()
  1573. {
  1574. $post = $this->input->post(NULL, TRUE);
  1575. if(isset($post['page']))
  1576. {
  1577. $api = $this->input->post('api',true);
  1578. $page = $this->input->post('page',true);
  1579. $perpage = $this->input->post('perpage',true);
  1580. $number = $this->input->post('number',true);
  1581. $color = $this->input->post('color',true);
  1582. $purchase = $this->input->post('purchase',true);
  1583. $transfer = $this->input->post('transfer',true);
  1584. $lx = $this->input->post('lx',true);
  1585. $timetk = $this->input->post('timetk',true);
  1586. $timetj = $this->input->post('timetj',true);
  1587. $timetk = strtotime($timetk);
  1588. $timetj = strtotime($timetj);
  1589. $where = "1=1";
  1590. if($transfer)
  1591. {
  1592. $ctime = 'ctime'.$transfer;
  1593. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1594. }
  1595. else
  1596. {
  1597. $where .= " and time > '$timetk' and time < '$timetj'";
  1598. }
  1599. if($number)
  1600. {
  1601. $where .= " and number = '$number'";
  1602. }
  1603. if($transfer)
  1604. {
  1605. $where .= " and rk like '%|".$transfer."|%'";
  1606. }
  1607. if($purchase)
  1608. {
  1609. $where .= " and purchase = '$purchase'";
  1610. }
  1611. if($color)
  1612. {
  1613. $where .= " and fpdata like '%-".$color."-%'";
  1614. }
  1615. if($lx)
  1616. {
  1617. if($lx == 1)
  1618. {
  1619. $where .= " and ordernumber = ''";
  1620. }
  1621. else
  1622. {
  1623. $where .= " and ordernumber != ''";
  1624. }
  1625. }
  1626. //数据排序
  1627. $order_str = "id desc";
  1628. if(empty($page))
  1629. {
  1630. $start = 0;
  1631. $perpage = 1;
  1632. }
  1633. else
  1634. {
  1635. $start = ($page - 1)*$perpage;
  1636. }
  1637. //取得信息列表
  1638. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1639. $transfer = $this->transfer->find_all();
  1640. $t = array();
  1641. foreach ($transfer as $v)
  1642. {
  1643. $t[$v['id']] = $v['title'];
  1644. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1645. }
  1646. //格式化数据
  1647. foreach ($info_list as $key=>$value)
  1648. {
  1649. $dd = $this->systemtransfer->read($value['id']);
  1650. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1651. $rk = explode('|',trim($dd['rk'],'|'));
  1652. $rktime = explode('|',trim($dd['rktime'],'|'));
  1653. $ck = explode('|',trim($dd['ck'],'|'));
  1654. $cktime = explode('|',trim($dd['cktime'],'|'));
  1655. $info_list[$key]['time'] = '';
  1656. for($i=0;$i<count($rk);$i++)
  1657. {
  1658. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1659. {
  1660. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1661. }
  1662. else
  1663. {
  1664. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1665. }
  1666. $info_list[$key]['time'] .= $d;
  1667. if(isset($ck[$i]) && $ck[$i] != '')
  1668. {
  1669. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1670. }
  1671. }
  1672. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1673. }
  1674. $total = $this->systemtransfer->find_count($where);
  1675. $pagenum = ceil($total/$perpage);
  1676. $over = $total-($start+$perpage);
  1677. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1678. echo json_encode($rows);exit;
  1679. }
  1680. if(isset($_SESSION['api']))
  1681. {
  1682. $user = $this->user->get_api($_SESSION['api']);
  1683. $usp = $user;
  1684. $pid = "";$tid="";$sid="";$wid="";
  1685. $purchase = explode('|',trim($user['purchase'],'|'));
  1686. $transfer = explode('|',trim($user['transfer'],'|'));
  1687. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1688. foreach ($purchase as $value)
  1689. {
  1690. $pid .= " id = ".$value." or";
  1691. }
  1692. foreach ($transfer as $value)
  1693. {
  1694. $tid .= " id = ".$value." or";
  1695. }
  1696. foreach ($warehouse as $value)
  1697. {
  1698. $wid .= " id = ".$value." or";
  1699. }
  1700. }
  1701. else
  1702. {
  1703. header('Location: /');exit;
  1704. }
  1705. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1706. $this->data['transfer'] = $transfer;
  1707. $this->_Template('transfer_rk',$this->data);
  1708. }
  1709. public function _ck()
  1710. {
  1711. $post = $this->input->post(NULL, TRUE);
  1712. if(isset($post['page']))
  1713. {
  1714. $api = $this->input->post('api',true);
  1715. $page = $this->input->post('page',true);
  1716. $perpage = $this->input->post('perpage',true);
  1717. $number = $this->input->post('number',true);
  1718. $color = $this->input->post('color',true);
  1719. $purchase = $this->input->post('purchase',true);
  1720. $transfer = $this->input->post('transfer',true);
  1721. $lx = $this->input->post('lx',true);
  1722. $timetk = $this->input->post('timetk',true);
  1723. $timetj = $this->input->post('timetj',true);
  1724. $timetk = strtotime($timetk);
  1725. $timetj = strtotime($timetj);
  1726. $where = "1=1";
  1727. if($transfer)
  1728. {
  1729. $ctime = 'ctime'.$transfer;
  1730. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1731. }
  1732. else
  1733. {
  1734. $where .= " and time > '$timetk' and time < '$timetj'";
  1735. }
  1736. if($number)
  1737. {
  1738. $where .= " and number = '$number'";
  1739. }
  1740. if($transfer)
  1741. {
  1742. $where .= " and ck like '%|".$transfer."|%'";
  1743. }
  1744. if($purchase)
  1745. {
  1746. $where .= " and purchase = '$purchase'";
  1747. }
  1748. if($color)
  1749. {
  1750. $where .= " and fpdata like '%-".$color."-%'";
  1751. }
  1752. if($lx)
  1753. {
  1754. if($lx == 1)
  1755. {
  1756. $where .= " and ordernumber = ''";
  1757. }
  1758. else
  1759. {
  1760. $where .= " and ordernumber != ''";
  1761. }
  1762. }
  1763. //数据排序
  1764. $order_str = "id desc";
  1765. if(empty($page))
  1766. {
  1767. $start = 0;
  1768. $perpage = 1;
  1769. }
  1770. else
  1771. {
  1772. $start = ($page - 1)*$perpage;
  1773. }
  1774. //取得信息列表
  1775. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1776. $transfer = $this->transfer->find_all();
  1777. $t = array();
  1778. foreach ($transfer as $v)
  1779. {
  1780. $t[$v['id']] = $v['title'];
  1781. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1782. }
  1783. //格式化数据
  1784. foreach ($info_list as $key=>$value)
  1785. {
  1786. $dd = $this->systemtransfer->read($value['id']);
  1787. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1788. $rk = explode('|',trim($dd['rk'],'|'));
  1789. $rktime = explode('|',trim($dd['rktime'],'|'));
  1790. $ck = explode('|',trim($dd['ck'],'|'));
  1791. $cktime = explode('|',trim($dd['cktime'],'|'));
  1792. $info_list[$key]['time'] = '';
  1793. for($i=0;$i<count($rk);$i++)
  1794. {
  1795. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1796. {
  1797. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1798. }
  1799. else
  1800. {
  1801. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1802. }
  1803. $info_list[$key]['time'] .= $d;
  1804. if(isset($ck[$i]) && $ck[$i] != '')
  1805. {
  1806. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1807. }
  1808. }
  1809. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1810. }
  1811. $total = $this->systemtransfer->find_count($where);
  1812. $pagenum = ceil($total/$perpage);
  1813. $over = $total-($start+$perpage);
  1814. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1815. echo json_encode($rows);exit;
  1816. }
  1817. if(isset($_SESSION['api']))
  1818. {
  1819. $user = $this->user->get_api($_SESSION['api']);
  1820. $usp = $user;
  1821. $pid = "";$tid="";$sid="";$wid="";
  1822. $purchase = explode('|',trim($user['purchase'],'|'));
  1823. $transfer = explode('|',trim($user['transfer'],'|'));
  1824. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1825. foreach ($purchase as $value)
  1826. {
  1827. $pid .= " id = ".$value." or";
  1828. }
  1829. foreach ($transfer as $value)
  1830. {
  1831. $tid .= " id = ".$value." or";
  1832. }
  1833. foreach ($warehouse as $value)
  1834. {
  1835. $wid .= " id = ".$value." or";
  1836. }
  1837. }
  1838. else
  1839. {
  1840. header('Location: /');exit;
  1841. }
  1842. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1843. $this->data['transfer'] = $transfer;
  1844. $this->_Template('transfer_ck',$this->data);
  1845. }
  1846. public function _jgl()
  1847. {
  1848. $post = $this->input->post(NULL, TRUE);
  1849. if(isset($post['printtime']))
  1850. {
  1851. $pt = $this->input->post('printtime',true);
  1852. $wt = $this->input->post('wgtime',true);
  1853. $printtime = strtotime($pt);
  1854. $wgtime = strtotime($wt);
  1855. $sy = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."'");
  1856. $wg = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."' and ctime11 < '$wgtime' and ctime11 != '0'");
  1857. if($printtime == $wgtime || $printtime > $wgtime)
  1858. {
  1859. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>时间选择错误</p>",'success'=>true));exit;
  1860. }
  1861. 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;
  1862. }
  1863. $this->_Template('transfer_wgl',$this->data);
  1864. }
  1865. public function _linqi(){
  1866. $post = $this->input->post(NULL, TRUE);
  1867. if(isset($post['page']))
  1868. {
  1869. $api = $this->input->post('api',true);
  1870. $page = $this->input->post('page',true);
  1871. $perpage = $this->input->post('perpage',true);
  1872. $transfer = $this->input->post('transfer',true);
  1873. $transfer_ids = $this->input->post('transfer_ids',true);
  1874. $orver_flag = $this->input->post('orver_flag',true);
  1875. $timetk = $this->input->post('timetk',true);
  1876. $timetj = $this->input->post('timetj',true);
  1877. $timetk = strtotime($timetk);
  1878. $timetj = strtotime($timetj);
  1879. $transfer_list = $this->transfer->find_all();
  1880. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1881. $where = 'type = 1 ';
  1882. $where .= " and is_over = 0 and orver_flag = ".$orver_flag." ";
  1883. //数据排序
  1884. $order_str = "id desc";
  1885. if(empty($page))
  1886. {
  1887. $start = 0;
  1888. $perpage = 1;
  1889. }
  1890. else
  1891. {
  1892. $start = ($page - 1)*$perpage;
  1893. }
  1894. if($transfer){
  1895. $where .= " and lx = '$transfer'";
  1896. }else{
  1897. $where .= " and lx in (".$transfer_ids.") ";
  1898. }
  1899. $where .= " and time > '$timetk' and time < '$timetj'";
  1900. $where .= " and ycrk_type = 0 ";
  1901. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  1902. $final_list = [];
  1903. foreach ($list as $key => $value) {
  1904. $info = $this->systemtransfer->read($value['fid']);
  1905. $final_list[$key]['id'] = $value['id'];
  1906. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  1907. if($info['is_jiaji'] == 2){
  1908. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  1909. }else{
  1910. $final_list[$key]['is_jiaji'] = "常规";
  1911. }
  1912. $final_list[$key]['pm'] = $info['pm'];
  1913. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  1914. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  1915. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  1916. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  1917. foreach ($data as $k=>$v)
  1918. {
  1919. $type = ($v['type']==1)?'入库':'出库';
  1920. if($v['orver_flag'] == 1){
  1921. if($v['is_over'] == 0){
  1922. $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>';
  1923. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  1924. }else{
  1925. $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>';
  1926. }
  1927. }elseif($v['orver_flag'] == 2){
  1928. $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>';
  1929. }else{
  1930. $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>';
  1931. }
  1932. }
  1933. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1934. }
  1935. $total = $this->systemtransfer_cr->find_count($where);
  1936. $pagenum = ceil($total/$perpage);
  1937. $over = $total-($start+$perpage);
  1938. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  1939. echo json_encode($rows);exit;
  1940. }
  1941. if(isset($_SESSION['api']))
  1942. {
  1943. $user = $this->user->get_api($_SESSION['api']);
  1944. $usp = $user;
  1945. $pid = "";$tid="";$sid="";$wid="";
  1946. $purchase = explode('|',trim($user['purchase'],'|'));
  1947. $transfer = explode('|',trim($user['transfer'],'|'));
  1948. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1949. foreach ($purchase as $value)
  1950. {
  1951. $pid .= " id = ".$value." or";
  1952. }
  1953. foreach ($transfer as $value)
  1954. {
  1955. $tid .= " id = ".$value." or";
  1956. }
  1957. foreach ($warehouse as $value)
  1958. {
  1959. $wid .= " id = ".$value." or";
  1960. }
  1961. }
  1962. else
  1963. {
  1964. header('Location: /');exit;
  1965. }
  1966. $kx = '';$zjtab = '';
  1967. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1968. $this->data['transfer'] = $transfer;
  1969. $transfer_ids = array_column($transfer, 'id');
  1970. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  1971. $this->data['vip'] = $user['vip'];
  1972. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  1973. $this->_Template('transfer_linqi',$this->data);
  1974. }
  1975. //按照条件导出超时车间
  1976. public function _overtime_export(){
  1977. $transfer_id = $this->input->get('transfer', TRUE);
  1978. $timetk = $this->input->get('timetk', TRUE);
  1979. $timetj = $this->input->get('timetj', TRUE);
  1980. $timetk = strtotime($timetk);
  1981. $timetj = strtotime($timetj);
  1982. if(isset($_SESSION['api']))
  1983. {
  1984. $user = $this->user->get_api($_SESSION['api']);
  1985. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1986. $tmp_transfer_list = $this->transfer->find_all();
  1987. $transfer_list = array_column($tmp_transfer_list, 'title', 'id');
  1988. }
  1989. else
  1990. {
  1991. header('Location: /');exit;
  1992. }
  1993. $where = " orver_flag = 2 and type = 1";
  1994. if(empty($transfer_id)){
  1995. $where .= " and lx in (".implode(',',$transfer_ids).") ";
  1996. }else{
  1997. $where .= " and lx = ".$transfer_id." ";
  1998. }
  1999. $where .= " and time > '$timetk' and time < '$timetj'";
  2000. $list = $this->systemtransfer_cr->find_all($where,'*');
  2001. $fid_list = array_column($list, 'fid');
  2002. if(empty($fid_list)){
  2003. echo "没有数据" ;
  2004. die ;
  2005. }
  2006. $order_list = $this->systemtransfer->find_all("id in (".implode(',',$fid_list).")");
  2007. $where_two = " orver_flag = 2 and type = 2";
  2008. if(empty($transfer_id)){
  2009. $where_two .= " and lx in (".implode(',',$transfer_ids).") ";
  2010. }else{
  2011. $where_two .= " and lx = ".$transfer_id." ";
  2012. }
  2013. $where_two .= " and time > '$timetk' and time < '$timetj'";
  2014. $list_two = $this->systemtransfer_cr->find_all($where_two,'*');
  2015. $final_list = [];
  2016. // foreach($list as $k => $v){
  2017. // $final_list[$v['fid']]['fid'] = $v['fid'];
  2018. // $final_list[$v['fid']]['lx'] = $v['lx'];
  2019. // $final_list[$v['fid']]['start_type'] = $v['type'];
  2020. // $final_list[$v['fid']]['start_time'] = date('Y-m-d H:i:s',$v['time']);
  2021. // $final_list[$v['fid']]['condition'] = json_decode($v['limit_time_str'],true);
  2022. // $final_list[$v['fid']]['end_time'] = "";
  2023. // $final_list[$v['fid']]['lx_name'] = isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'';
  2024. // }
  2025. // foreach($order_list as $k=>$v){
  2026. // if(isset($final_list[$v['id']])){
  2027. // $final_list[$v['id']]['number'] = $v['number'];
  2028. // $final_list[$v['id']]['pm'] = $v['pm'];
  2029. // }
  2030. // }
  2031. // foreach($list_two as $k => $v){
  2032. // if(isset($final_list[$v['fid']])){
  2033. // if($v['lx'] ==$final_list[$v['fid']]['lx']){
  2034. // $final_list[$v['fid']]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2035. // }
  2036. // }
  2037. // }
  2038. foreach($list as $k => $v){
  2039. $final_list[] = [
  2040. 'fid' => $v['fid'],
  2041. 'lx' => $v['lx'],
  2042. 'start_type' => $v['type'],
  2043. 'start_time' => date('Y-m-d H:i:s',$v['time']),
  2044. 'condition' => json_decode($v['limit_time_str'],true),
  2045. 'end_time' => "",
  2046. 'lx_name' => isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'',
  2047. ];
  2048. }
  2049. foreach($order_list as $k=>$v){
  2050. foreach($final_list as $kk => $vv){
  2051. if($v['id'] == $vv['fid']){
  2052. $final_list[$kk]['number'] = $v['number'];
  2053. $final_list[$kk]['pm'] = $v['pm'];
  2054. }
  2055. }
  2056. }
  2057. foreach($list_two as $k => $v){
  2058. foreach($final_list as $kk => $vv){
  2059. if(($v['fid'] == $vv['fid']) && ($v['lx'] == $vv['lx'])){
  2060. $final_list[$kk]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2061. }
  2062. }
  2063. }
  2064. $filename = date("Y-m-d")."超时单导出.xls";
  2065. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2066. <head>
  2067. <!--[if gte mso 9]><xml>
  2068. <x:ExcelWorkbook>
  2069. <x:ExcelWorksheets>
  2070. <x:ExcelWorksheet>
  2071. <x:Name>EXCEL</x:Name>
  2072. <x:WorksheetOptions>
  2073. <x:Print>
  2074. <x:ValidPrinterInfo />
  2075. </x:Print>
  2076. </x:WorksheetOptions>
  2077. </x:ExcelWorksheet>
  2078. </x:ExcelWorksheets>
  2079. </x:ExcelWorkbook>
  2080. </xml>
  2081. <![endif]-->
  2082. </head><body>";
  2083. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2084. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>入库日期</td><td>出库日期</td></tr>";
  2085. foreach ($final_list as $key=>$value)
  2086. {
  2087. if(empty($value['number'])){
  2088. continue;
  2089. }
  2090. $str .= "<tr>";
  2091. $str .= "<td>". $value['number']. "</td>";
  2092. $str .= "<td>". $value['pm']. "</td>";
  2093. $str .= "<td>". $value['lx_name']. "</td>";
  2094. $str .= "<td>". $value['start_time']. "</td>";
  2095. $str .= "<td>". $value['end_time']. "</td>";
  2096. $str .= "</tr>";
  2097. }
  2098. $str .= "</table></body></html>";
  2099. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2100. header( "Content-type: application/octet-stream" );
  2101. header( "Content-Disposition: attachment; filename=".$filename );
  2102. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2103. header( "Pragma: no-cache" );
  2104. header( "Expires: 0" );
  2105. exit($str);
  2106. }
  2107. public function _jiaji(){
  2108. $post = $this->input->post(NULL, TRUE);
  2109. if(isset($post['page']))
  2110. {
  2111. $api = $this->input->post('api',true);
  2112. $page = $this->input->post('page',true);
  2113. $perpage = $this->input->post('perpage',true);
  2114. $transfer = $this->input->post('transfer',true);
  2115. $transfer_ids = $this->input->post('transfer_ids',true);
  2116. $orver_flag = $this->input->post('orver_flag',true);
  2117. $timetk = $this->input->post('timetk',true);
  2118. $timetj = $this->input->post('timetj',true);
  2119. $timetk = strtotime($timetk);
  2120. $timetj = strtotime($timetj);
  2121. $transfer_list = $this->transfer->find_all();
  2122. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2123. if(isset($_SESSION['api']))
  2124. {
  2125. $user = $this->user->get_api($_SESSION['api']);
  2126. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  2127. }
  2128. else
  2129. {
  2130. $transfer_ids = array_keys($t);
  2131. }
  2132. if(empty($page))
  2133. {
  2134. $start = 0;
  2135. $perpage = 1;
  2136. }
  2137. else
  2138. {
  2139. $start = ($page - 1)*$perpage;
  2140. }
  2141. $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." ";
  2142. if($transfer){
  2143. $sql_r .= " and c.lx = ".$transfer." ";
  2144. }else{
  2145. foreach($transfer_ids as $k=>$v){
  2146. if($v == 11){
  2147. unset($transfer_ids[$k]);
  2148. }
  2149. }
  2150. $transfer_str = implode(",",$transfer_ids);
  2151. $sql_r .= " and c.lx in (".$transfer_str.") ";
  2152. }
  2153. $sql_r .=" where s.is_jiaji = 2 and s.rk not like '%|11|%' " ;
  2154. $rows_r = $this->db->query($sql_r);
  2155. $get_list = $rows_r->result_array();
  2156. $total = count($get_list);
  2157. $split_list = array_chunk($get_list,$perpage);
  2158. $pagenum = ceil(count($split_list));
  2159. $key = $page - 1;
  2160. $list = isset($split_list[$key])?$split_list[$key]:[];
  2161. $final_list = [];
  2162. foreach ($list as $key => $value) {
  2163. $final_list[$key]['id'] = $value['id'];
  2164. $final_list[$key]['number'] = isset($value['number'])?$value['number']:'';
  2165. if($value['is_jiaji'] == 2){
  2166. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2167. }else{
  2168. $final_list[$key]['is_jiaji'] = "常规";
  2169. }
  2170. $final_list[$key]['pm'] = $value['pm'];
  2171. $final_list[$key]['shipremarks'] = $value['shipremarks'];
  2172. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2173. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2174. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2175. foreach ($data as $k=>$v)
  2176. {
  2177. $type = ($v['type']==1)?'入库':'出库';
  2178. if($v['orver_flag'] == 1){
  2179. if($v['is_over'] == 0){
  2180. $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>';
  2181. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2182. }else{
  2183. $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>';
  2184. }
  2185. }elseif($v['orver_flag'] == 2){
  2186. $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>';
  2187. }else{
  2188. $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>';
  2189. }
  2190. }
  2191. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2192. }
  2193. $over = $total-($start+$perpage);
  2194. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2195. echo json_encode($rows);exit;
  2196. }
  2197. if(isset($_SESSION['api']))
  2198. {
  2199. $user = $this->user->get_api($_SESSION['api']);
  2200. $usp = $user;
  2201. $pid = "";$tid="";$sid="";$wid="";
  2202. $purchase = explode('|',trim($user['purchase'],'|'));
  2203. $transfer = explode('|',trim($user['transfer'],'|'));
  2204. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2205. foreach ($purchase as $value)
  2206. {
  2207. $pid .= " id = ".$value." or";
  2208. }
  2209. foreach ($transfer as $value)
  2210. {
  2211. if($value){
  2212. if($value != 11){
  2213. $tid .= " id = ".$value." or";
  2214. }
  2215. }
  2216. }
  2217. foreach ($warehouse as $value)
  2218. {
  2219. $wid .= " id = ".$value." or";
  2220. }
  2221. }
  2222. else
  2223. {
  2224. header('Location: /');exit;
  2225. }
  2226. $kx = '';$zjtab = '';
  2227. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2228. $this->data['transfer'] = $transfer;
  2229. $transfer_ids = array_column($transfer, 'id');
  2230. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2231. $this->data['vip'] = $user['vip'];
  2232. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2233. $this->_Template('transfer_jiaji',$this->data);
  2234. }
  2235. public function _scz(){
  2236. $post = $this->input->post(NULL, TRUE);
  2237. if(isset($post['page']))
  2238. {
  2239. $page = $this->input->post('page',true);
  2240. $perpage = $this->input->post('perpage',true);
  2241. $transfer = $this->input->post('transfer',true);
  2242. $transfer_ids = $this->input->post('transfer_ids',true);
  2243. $timetk = $this->input->post('timetk',true);
  2244. $timetj = $this->input->post('timetj',true);
  2245. $timetk = strtotime($timetk);
  2246. $timetj = strtotime($timetj);
  2247. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2248. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2249. // $transfer_ids = array_keys($t);
  2250. if(empty($page))
  2251. {
  2252. $start = 0;
  2253. $perpage = 1;
  2254. }
  2255. else
  2256. {
  2257. $start = ($page - 1)*$perpage;
  2258. }
  2259. $where = "time > '$timetk' and time < '$timetj'";
  2260. $where .= " and rk not like '%11|' ";
  2261. if(!empty($transfer)){
  2262. $where .= " and rk like '%|".$transfer."|%' ";
  2263. }
  2264. // if($transfer)
  2265. // {
  2266. // $cr .= " and lx = '".$transfer."' ";
  2267. // }else{
  2268. // $cr .= " and lx in (".implode(",",$transfer_ids).") ";
  2269. // }
  2270. // $cr .= " and is_over = 0 ";
  2271. // $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  2272. // $fid = [];
  2273. // foreach ($info_list_cr as $v)
  2274. // {
  2275. // $fid[] = $v['fid'];
  2276. // }
  2277. // if(empty($fid)){
  2278. // $rows = array('total'=>0,'over'=>0,'pagenum'=>0,'rows'=>([]));
  2279. // echo json_encode($rows);exit;
  2280. // }
  2281. // $fid = array_unique($fid);
  2282. $order_str = "id desc";
  2283. //取得信息列表
  2284. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  2285. $transfer = $this->transfer->find_all();
  2286. $t = array();
  2287. foreach ($transfer as $v)
  2288. {
  2289. $t[$v['id']] = $v['title'];
  2290. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2291. }
  2292. //格式化数据
  2293. foreach ($info_list as $key=>$value)
  2294. {
  2295. if($value['is_jiaji'] == 2){
  2296. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2297. }else{
  2298. $info_list[$key]['is_jiaji'] = "常规";
  2299. }
  2300. $dd = $this->systemtransfer->read($value['id']);
  2301. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2302. $rk = explode('|',trim($dd['rk'],'|'));
  2303. $rktime = explode('|',trim($dd['rktime'],'|'));
  2304. $ck = explode('|',trim($dd['ck'],'|'));
  2305. $cktime = explode('|',trim($dd['cktime'],'|'));
  2306. $info_list[$key]['time'] = '';
  2307. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2308. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2309. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2310. foreach ($data as $k=>$v)
  2311. {
  2312. // $type = ($v['type']==1)?'入库':'出库';
  2313. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2314. $type = ($v['type']==1)?'入库':'出库';
  2315. if($v['orver_flag'] == 1){
  2316. if($v['is_over'] == 0){
  2317. $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>';
  2318. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2319. }else{
  2320. $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>';
  2321. }
  2322. }elseif($v['orver_flag'] == 2){
  2323. $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>';
  2324. }elseif($v['orver_flag'] == 3){
  2325. $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>';
  2326. }else{
  2327. $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>';
  2328. }
  2329. }
  2330. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2331. unset($info_list[$key]['ctime12']);
  2332. }
  2333. $total = $this->systemtransfer->find_count($where);
  2334. $pagenum = ceil($total/$perpage);
  2335. $over = $total-($start+$perpage);
  2336. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2337. echo json_encode($rows);exit;
  2338. }
  2339. if(isset($_SESSION['api']))
  2340. {
  2341. $user = $this->user->get_api($_SESSION['api']);
  2342. if(!in_array($user['id'],[10,44,50])){
  2343. exit('No direct script access allowed');
  2344. }
  2345. }
  2346. else
  2347. {
  2348. header('Location: /');exit;
  2349. }
  2350. $kx = '';$zjtab = '';
  2351. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2352. $this->data['transfer'] = $transfer;
  2353. $transfer_ids = array_column($transfer, 'id');
  2354. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2355. $this->_Template('transfer_scz',$this->data);
  2356. }
  2357. public function _sczexcel(){
  2358. $timetk = $this->input->get('timetk',true);
  2359. $timetj = $this->input->get('timetj',true);
  2360. $timetk = strtotime($timetk);
  2361. $timetj = strtotime($timetj);
  2362. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2363. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2364. // $transfer_ids = array_keys($t);
  2365. $where = "time > '$timetk' and time < '$timetj'";
  2366. $where .= " and rk not like '%11|' ";
  2367. if(!empty($transfer)){
  2368. $where .= " and rk like '%|".$transfer."|%' ";
  2369. }
  2370. $order_str = "id desc";
  2371. //取得信息列表
  2372. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str);
  2373. $transfer = $this->transfer->find_all();
  2374. $t = array();
  2375. foreach ($transfer as $v)
  2376. {
  2377. $t[$v['id']] = $v['title'];
  2378. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2379. }
  2380. //格式化数据
  2381. foreach ($info_list as $key=>$value)
  2382. {
  2383. if($value['is_jiaji'] == 2){
  2384. $info_list[$key]['is_jiaji'] = "<span style='color:red'>加急</span>";
  2385. }else{
  2386. $info_list[$key]['is_jiaji'] = "常规";
  2387. }
  2388. $dd = $this->systemtransfer->read($value['id']);
  2389. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2390. $rk = explode('|',trim($dd['rk'],'|'));
  2391. $rktime = explode('|',trim($dd['rktime'],'|'));
  2392. $ck = explode('|',trim($dd['ck'],'|'));
  2393. $cktime = explode('|',trim($dd['cktime'],'|'));
  2394. $info_list[$key]['time'] = '';
  2395. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2396. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2397. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2398. foreach ($data as $k=>$v)
  2399. {
  2400. // $type = ($v['type']==1)?'入库':'出库';
  2401. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2402. $type = ($v['type']==1)?'入库':'出库';
  2403. if($v['orver_flag'] == 1){
  2404. if($v['is_over'] == 0){
  2405. $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>';
  2406. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2407. }else{
  2408. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2409. }
  2410. }elseif($v['orver_flag'] == 2){
  2411. $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>';
  2412. }elseif($v['orver_flag'] == 3){
  2413. $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>';
  2414. }else{
  2415. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2416. }
  2417. }
  2418. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2419. unset($info_list[$key]['ctime12']);
  2420. }
  2421. $filename = date("Y-m-d")."生产中订单.xls";
  2422. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2423. <head>
  2424. <!--[if gte mso 9]><xml>
  2425. <x:ExcelWorkbook>
  2426. <x:ExcelWorksheets>
  2427. <x:ExcelWorksheet>
  2428. <x:Name>EXCEL</x:Name>
  2429. <x:WorksheetOptions>
  2430. <x:Print>
  2431. <x:ValidPrinterInfo />
  2432. </x:Print>
  2433. </x:WorksheetOptions>
  2434. </x:ExcelWorksheet>
  2435. </x:ExcelWorksheets>
  2436. </x:ExcelWorkbook>
  2437. </xml>
  2438. <![endif]-->
  2439. </head><body>";
  2440. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2441. $str .= "<tr><td>订单编号</td><td>加急</td><td>品名</td><td>备注</td><td>打印时间</td><td>操作</td></tr>";
  2442. foreach ($info_list as $key=>$value)
  2443. {
  2444. $str .= "<tr>";
  2445. $str .= "<td>". $value['number']. "</td>";
  2446. $str .= "<td>". $value['is_jiaji']. "</td>";
  2447. $str .= "<td>". $value['pm']. "</td>";
  2448. $str .= "<td>". $value['shipremarks']. "</td>";
  2449. $str .= "<td>". $value['printtime']. "</td>";
  2450. $str .= "<td>". $value['time']. "</td>";
  2451. $str .= "</tr>";
  2452. }
  2453. $str .= "</table></body></html>";
  2454. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2455. header( "Content-type: application/octet-stream" );
  2456. header( "Content-Disposition: attachment; filename=".$filename );
  2457. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2458. header( "Pragma: no-cache" );
  2459. header( "Expires: 0" );
  2460. exit($str);
  2461. }
  2462. public function _wjsrk(){
  2463. $post = $this->input->post(NULL, TRUE);
  2464. if(isset($post['page']))
  2465. {
  2466. $api = $this->input->post('api',true);
  2467. $page = $this->input->post('page',true);
  2468. $perpage = $this->input->post('perpage',true);
  2469. $transfer = $this->input->post('transfer',true);
  2470. $transfer_ids = $this->input->post('transfer_ids',true);
  2471. $orver_flag = $this->input->post('orver_flag',true);
  2472. $timetk = $this->input->post('timetk',true);
  2473. $timetj = $this->input->post('timetj',true);
  2474. $timetk = strtotime($timetk);
  2475. $timetj = strtotime($timetj);
  2476. $transfer_list = $this->transfer->find_all();
  2477. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2478. $where = 'extra_status in (1,2) ';
  2479. //数据排序
  2480. $order_str = "id desc";
  2481. if(empty($page))
  2482. {
  2483. $start = 0;
  2484. $perpage = 1;
  2485. }
  2486. else
  2487. {
  2488. $start = ($page - 1)*$perpage;
  2489. }
  2490. if($transfer){
  2491. $where .= " and lx = '$transfer'";
  2492. }else{
  2493. $where .= " and lx in (".$transfer_ids.") ";
  2494. }
  2495. $where .= " and time > '$timetk' and time < '$timetj'";
  2496. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2497. $final_list = [];
  2498. foreach ($list as $key => $value) {
  2499. $info = $this->systemtransfer->read($value['fid']);
  2500. $final_list[$key]['id'] = $value['id'];
  2501. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2502. if($info['is_jiaji'] == 2){
  2503. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2504. }else{
  2505. $final_list[$key]['is_jiaji'] = "常规";
  2506. }
  2507. $final_list[$key]['pm'] = $info['pm'];
  2508. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2509. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2510. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2511. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2512. foreach ($data as $k=>$v)
  2513. {
  2514. $type = ($v['type']==1)?'入库':'出库';
  2515. if($v['orver_flag'] == 1){
  2516. if($v['is_over'] == 0){
  2517. $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>";
  2518. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2519. }else{
  2520. $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>";
  2521. }
  2522. }elseif($v['orver_flag'] == 2){
  2523. $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>";
  2524. }else{
  2525. $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>";
  2526. }
  2527. if($v['extra_status'] == 1){
  2528. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2529. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2530. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2531. }else{
  2532. $info_list[$key]['time'] .= "<br>";
  2533. }
  2534. }
  2535. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2536. }
  2537. $total = $this->systemtransfer_cr->find_count($where);
  2538. $pagenum = ceil($total/$perpage);
  2539. $over = $total-($start+$perpage);
  2540. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2541. echo json_encode($rows);exit;
  2542. }
  2543. if(isset($_SESSION['api']))
  2544. {
  2545. $user = $this->user->get_api($_SESSION['api']);
  2546. $usp = $user;
  2547. $pid = "";$tid="";$sid="";$wid="";
  2548. $purchase = explode('|',trim($user['purchase'],'|'));
  2549. $transfer = explode('|',trim($user['transfer'],'|'));
  2550. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2551. foreach ($purchase as $value)
  2552. {
  2553. $pid .= " id = ".$value." or";
  2554. }
  2555. foreach ($transfer as $value)
  2556. {
  2557. $tid .= " id = ".$value." or";
  2558. }
  2559. foreach ($warehouse as $value)
  2560. {
  2561. $wid .= " id = ".$value." or";
  2562. }
  2563. }
  2564. else
  2565. {
  2566. header('Location: /');exit;
  2567. }
  2568. $kx = '';$zjtab = '';
  2569. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2570. $this->data['transfer'] = $transfer;
  2571. $transfer_ids = array_column($transfer, 'id');
  2572. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2573. $this->data['vip'] = $user['vip'];
  2574. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2575. $this->_Template('transfer_wjsrk',$this->data);
  2576. }
  2577. public function _wjsrkexcel(){
  2578. $api = $this->input->get('api',true);
  2579. $transfer = $this->input->get('transfer',true);
  2580. $timetk = $this->input->get('timetk',true);
  2581. $timetj = $this->input->get('timetj',true);
  2582. $timetk = strtotime($timetk);
  2583. $timetj = strtotime($timetj);
  2584. $transfer_list = $this->transfer->find_all();
  2585. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2586. $where = 'extra_status in (1,2) ';
  2587. //数据排序
  2588. $order_str = "id desc";
  2589. if($transfer){
  2590. $where .= " and lx = '$transfer'";
  2591. }else{
  2592. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2593. $transfer_ids = array_column($transfer, 'id');
  2594. $transfer_ids = implode(",",$transfer_ids);
  2595. $where .= " and lx in (".$transfer_ids.") ";
  2596. }
  2597. $where .= " and time > '$timetk' and time < '$timetj'";
  2598. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2599. $final_list = [];
  2600. foreach ($list as $key => $value) {
  2601. $info = $this->systemtransfer->read($value['fid']);
  2602. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2603. $final_list[$key]['pm'] = $info['pm'];
  2604. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2605. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2606. }
  2607. $filename = date("Y-m-d")."超期未流转单导出.xls";
  2608. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2609. <head>
  2610. <!--[if gte mso 9]><xml>
  2611. <x:ExcelWorkbook>
  2612. <x:ExcelWorksheets>
  2613. <x:ExcelWorksheet>
  2614. <x:Name>EXCEL</x:Name>
  2615. <x:WorksheetOptions>
  2616. <x:Print>
  2617. <x:ValidPrinterInfo />
  2618. </x:Print>
  2619. </x:WorksheetOptions>
  2620. </x:ExcelWorksheet>
  2621. </x:ExcelWorksheets>
  2622. </x:ExcelWorkbook>
  2623. </xml>
  2624. <![endif]-->
  2625. </head><body>";
  2626. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2627. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2628. foreach ($final_list as $key=>$value)
  2629. {
  2630. if(empty($value['number'])){
  2631. continue;
  2632. }
  2633. $str .= "<tr>";
  2634. $str .= "<td>". $value['number']. "</td>";
  2635. $str .= "<td>". $value['pm']. "</td>";
  2636. $str .= "<td>". $value['lx_name']. "</td>";
  2637. $str .= "<td>". $value['time']. "</td>";
  2638. $str .= "</tr>";
  2639. }
  2640. $str .= "</table></body></html>";
  2641. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2642. header( "Content-type: application/octet-stream" );
  2643. header( "Content-Disposition: attachment; filename=".$filename );
  2644. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2645. header( "Pragma: no-cache" );
  2646. header( "Expires: 0" );
  2647. exit($str);
  2648. }
  2649. public function _cqrk(){
  2650. $post = $this->input->post(NULL, TRUE);
  2651. if(isset($post['page']))
  2652. {
  2653. $api = $this->input->post('api',true);
  2654. $page = $this->input->post('page',true);
  2655. $perpage = $this->input->post('perpage',true);
  2656. $transfer = $this->input->post('transfer',true);
  2657. $transfer_ids = $this->input->post('transfer_ids',true);
  2658. $orver_flag = $this->input->post('orver_flag',true);
  2659. $timetk = $this->input->post('timetk',true);
  2660. $timetj = $this->input->post('timetj',true);
  2661. $timetk = strtotime($timetk);
  2662. $timetj = strtotime($timetj);
  2663. $transfer_list = $this->transfer->find_all();
  2664. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2665. $where = 'extra_status in (2,3) ';
  2666. //数据排序
  2667. $order_str = "id desc";
  2668. if(empty($page))
  2669. {
  2670. $start = 0;
  2671. $perpage = 1;
  2672. }
  2673. else
  2674. {
  2675. $start = ($page - 1)*$perpage;
  2676. }
  2677. if($transfer){
  2678. $where .= " and lx = '$transfer'";
  2679. }else{
  2680. $where .= " and lx in (".$transfer_ids.") ";
  2681. }
  2682. $where .= " and time > '$timetk' and time < '$timetj'";
  2683. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2684. $final_list = [];
  2685. foreach ($list as $key => $value) {
  2686. $info = $this->systemtransfer->read($value['fid']);
  2687. $final_list[$key]['id'] = $value['id'];
  2688. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2689. if($info['is_jiaji'] == 2){
  2690. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2691. }else{
  2692. $final_list[$key]['is_jiaji'] = "常规";
  2693. }
  2694. $final_list[$key]['pm'] = $info['pm'];
  2695. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2696. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2697. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2698. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2699. foreach ($data as $k=>$v)
  2700. {
  2701. $type = ($v['type']==1)?'入库':'出库';
  2702. if($v['orver_flag'] == 1){
  2703. if($v['is_over'] == 0){
  2704. $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>";
  2705. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2706. }else{
  2707. $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>";
  2708. }
  2709. }elseif($v['orver_flag'] == 2){
  2710. $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>";
  2711. }else{
  2712. $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>";
  2713. }
  2714. if($v['extra_status'] == 1){
  2715. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2716. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2717. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2718. }else{
  2719. $info_list[$key]['time'] .= "<br>";
  2720. }
  2721. }
  2722. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2723. }
  2724. $total = $this->systemtransfer_cr->find_count($where);
  2725. $pagenum = ceil($total/$perpage);
  2726. $over = $total-($start+$perpage);
  2727. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2728. echo json_encode($rows);exit;
  2729. }
  2730. if(isset($_SESSION['api']))
  2731. {
  2732. $user = $this->user->get_api($_SESSION['api']);
  2733. $usp = $user;
  2734. $pid = "";$tid="";$sid="";$wid="";
  2735. $purchase = explode('|',trim($user['purchase'],'|'));
  2736. $transfer = explode('|',trim($user['transfer'],'|'));
  2737. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2738. foreach ($purchase as $value)
  2739. {
  2740. $pid .= " id = ".$value." or";
  2741. }
  2742. foreach ($transfer as $value)
  2743. {
  2744. $tid .= " id = ".$value." or";
  2745. }
  2746. foreach ($warehouse as $value)
  2747. {
  2748. $wid .= " id = ".$value." or";
  2749. }
  2750. }
  2751. else
  2752. {
  2753. header('Location: /');exit;
  2754. }
  2755. $kx = '';$zjtab = '';
  2756. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2757. $this->data['transfer'] = $transfer;
  2758. $transfer_ids = array_column($transfer, 'id');
  2759. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2760. $this->data['vip'] = $user['vip'];
  2761. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2762. $this->_Template('transfer_cqrk',$this->data);
  2763. }
  2764. public function _cqrkexcel(){
  2765. $api = $this->input->get('api',true);
  2766. $transfer = $this->input->get('transfer',true);
  2767. $timetk = $this->input->get('timetk',true);
  2768. $timetj = $this->input->get('timetj',true);
  2769. $timetk = strtotime($timetk);
  2770. $timetj = strtotime($timetj);
  2771. $transfer_list = $this->transfer->find_all();
  2772. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2773. $where = 'extra_status in (2,3) ';
  2774. //数据排序
  2775. $order_str = "id desc";
  2776. if($transfer){
  2777. $where .= " and lx = '$transfer'";
  2778. }else{
  2779. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2780. $transfer_ids = array_column($transfer, 'id');
  2781. $transfer_ids = implode(",",$transfer_ids);
  2782. $where .= " and lx in (".$transfer_ids.") ";
  2783. }
  2784. $where .= " and time > '$timetk' and time < '$timetj'";
  2785. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2786. $final_list = [];
  2787. foreach ($list as $key => $value) {
  2788. $info = $this->systemtransfer->read($value['fid']);
  2789. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2790. $final_list[$key]['pm'] = $info['pm'];
  2791. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2792. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2793. }
  2794. $filename = date("Y-m-d")."超期3天未流转单导出.xls";
  2795. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2796. <head>
  2797. <!--[if gte mso 9]><xml>
  2798. <x:ExcelWorkbook>
  2799. <x:ExcelWorksheets>
  2800. <x:ExcelWorksheet>
  2801. <x:Name>EXCEL</x:Name>
  2802. <x:WorksheetOptions>
  2803. <x:Print>
  2804. <x:ValidPrinterInfo />
  2805. </x:Print>
  2806. </x:WorksheetOptions>
  2807. </x:ExcelWorksheet>
  2808. </x:ExcelWorksheets>
  2809. </x:ExcelWorkbook>
  2810. </xml>
  2811. <![endif]-->
  2812. </head><body>";
  2813. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2814. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2815. foreach ($final_list as $key=>$value)
  2816. {
  2817. if(empty($value['number'])){
  2818. continue;
  2819. }
  2820. $str .= "<tr>";
  2821. $str .= "<td>". $value['number']. "</td>";
  2822. $str .= "<td>". $value['pm']. "</td>";
  2823. $str .= "<td>". $value['lx_name']. "</td>";
  2824. $str .= "<td>". $value['time']. "</td>";
  2825. $str .= "</tr>";
  2826. }
  2827. $str .= "</table></body></html>";
  2828. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2829. header( "Content-type: application/octet-stream" );
  2830. header( "Content-Disposition: attachment; filename=".$filename );
  2831. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2832. header( "Pragma: no-cache" );
  2833. header( "Expires: 0" );
  2834. exit($str);
  2835. }
  2836. /**
  2837. * 导出excel 操作部门是否出库
  2838. */
  2839. public function _czbmIsOutExcel(){
  2840. if($this->input->method() == 'get'){
  2841. $number = $this->input->get('number',true);
  2842. $color = $this->input->get('color',true);
  2843. $purchase = $this->input->get('purchase',true);
  2844. $transfer = $this->input->get('transfer',true);
  2845. $lx = $this->input->get('lx',true);
  2846. $type = $this->input->get('type',true);
  2847. $pm = $this->input->get('pm',true);
  2848. $jiaji = $this->input->get('jiaji',true);
  2849. $timetk = $this->input->get('timetk',true);
  2850. $timetj = $this->input->get('timetj',true);
  2851. $timetk = strtotime($timetk);
  2852. $timetj = strtotime($timetj);
  2853. $where = '1=1';
  2854. if($number)
  2855. {
  2856. $where .= " and number = '$number'";
  2857. }
  2858. if($pm){
  2859. $where .= " and pm like '%".$pm."%'";
  2860. }
  2861. if($purchase)
  2862. {
  2863. $where .= " and purchase = '$purchase'";
  2864. }
  2865. if($color)
  2866. {
  2867. $where .= " and fpdata like '%-".$color."-%'";
  2868. }
  2869. if($lx)
  2870. {
  2871. if($lx == 1)
  2872. {
  2873. $where .= " and ordernumber = ''";
  2874. }
  2875. else
  2876. {
  2877. $where .= " and ordernumber != ''";
  2878. }
  2879. }
  2880. if($jiaji){
  2881. if($jiaji == 1){
  2882. $where .= " and is_jiaji = 0";
  2883. }
  2884. if($jiaji == 2){
  2885. $where .= " and is_jiaji = 2";
  2886. }
  2887. }
  2888. //数据排序
  2889. $order_str = "id desc";
  2890. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  2891. if($type)
  2892. {
  2893. if($type == 3){
  2894. if($transfer)
  2895. {
  2896. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  2897. }
  2898. }else{
  2899. $type = ($type==1)?'rk':'ck';
  2900. if($transfer)
  2901. {
  2902. $where .= " and $type like '%|".$transfer."|%'";
  2903. }
  2904. }
  2905. }
  2906. else
  2907. {
  2908. if($transfer)
  2909. {
  2910. $where .= " and rk like '%|".$transfer."|%'";
  2911. }
  2912. }
  2913. //取得信息列表
  2914. $info_list = $this->systemtransfer->find_all($where,'*',$order_str);
  2915. $transfer = $this->transfer->find_all();
  2916. $t = array();
  2917. foreach ($transfer as $v)
  2918. {
  2919. $t[$v['id']] = $v['title'];
  2920. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2921. }
  2922. $final_list = [];
  2923. //格式化数据
  2924. foreach ($info_list as $key=>$value)
  2925. {
  2926. $transfer_list = $this->_get_transfer_data($value,$t);
  2927. $final_list[] = [
  2928. 'number'=>$value['number'],
  2929. 'pm'=>$value['pm'],
  2930. 'transfer_list'=>$transfer_list,
  2931. ];
  2932. }
  2933. $filename = date("Y-m-d")."操作部门库存是否存在.xls";
  2934. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2935. <head>
  2936. <!--[if gte mso 9]><xml>
  2937. <x:ExcelWorkbook>
  2938. <x:ExcelWorksheets>
  2939. <x:ExcelWorksheet>
  2940. <x:Name>EXCEL</x:Name>
  2941. <x:WorksheetOptions>
  2942. <x:Print>
  2943. <x:ValidPrinterInfo />
  2944. </x:Print>
  2945. </x:WorksheetOptions>
  2946. </x:ExcelWorksheet>
  2947. </x:ExcelWorksheets>
  2948. </x:ExcelWorkbook>
  2949. </xml>
  2950. <![endif]-->
  2951. </head><body>";
  2952. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2953. $str .= "<tr><td>订单编号</td><td>品名</td><td>操作部门</td><td>扫入日期</td><td>扫出日期</td><td>是否出库</td></tr>";
  2954. foreach ($final_list as $key=>$value)
  2955. {
  2956. if(empty($value['number'])){
  2957. continue;
  2958. }
  2959. $str .= "<tr>";
  2960. $str .= "<td>". $value['number']. "</td>";
  2961. $str .= "<td>". $value['pm']. "</td>";
  2962. $tmp_czbm = '';
  2963. $tmp_srrq = '';
  2964. $tmp_scrq = '';
  2965. $tmp_is_out = '';
  2966. foreach ($value['transfer_list'] as $k=>$v)
  2967. {
  2968. $tmp_czbm .= $v['lx_show'].'<br/>';
  2969. $tmp_srrq .= empty($v['rk_time'])?'无<br/>': date('Y-m-d H:i:s',$v['rk_time']).'<br/>';
  2970. $tmp_scrq .= empty($v['ck_time'])?'无<br/>': date('Y-m-d H:i:s',$v['ck_time']).'<br/>';
  2971. if($v['is_over'] == 2){
  2972. $tmp_is_out .= '是<br/>';
  2973. }elseif($v['is_over'] == 1){
  2974. $tmp_is_out .= '否<br/>';
  2975. }else{
  2976. $tmp_is_out .= '异常<br/>';
  2977. }
  2978. }
  2979. $tmp_czbm = trim($tmp_czbm,'<br/>');
  2980. $tmp_srrq = trim($tmp_srrq,'<br/>');
  2981. $tmp_scrq = trim($tmp_scrq,'<br/>');
  2982. $tmp_is_out = trim($tmp_is_out,'<br/>');
  2983. $str .= "<td>". $tmp_czbm. "</td>";
  2984. $str .= "<td>". $tmp_srrq. "</td>";
  2985. $str .= "<td>". $tmp_scrq. "</td>";
  2986. $str .= "<td>". $tmp_is_out. "</td>";
  2987. $str .= "</tr>";
  2988. }
  2989. $str .= "</table></body></html>";
  2990. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2991. header( "Content-type: application/octet-stream" );
  2992. header( "Content-Disposition: attachment; filename=".$filename );
  2993. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2994. header( "Pragma: no-cache" );
  2995. header( "Expires: 0" );
  2996. exit($str);
  2997. }
  2998. }
  2999. public function _get_transfer_data($info,$t){
  3000. $rk_list = explode('|',trim($info['rk'],'|'));
  3001. $rk_time = explode('|',trim($info['rktime'],'|'));
  3002. $ck_list = explode('|',trim($info['ck'],'|'));
  3003. $ck_time = explode('|',trim($info['cktime'],'|'));
  3004. if(count($rk_time) < count($ck_time)){
  3005. return [
  3006. 'code'=>-1,
  3007. 'msg'=>'数据异常,('.$info['id'].')联系技术',
  3008. ];
  3009. }
  3010. $tran_list = [];
  3011. $len = count($rk_list);
  3012. $ck_index = 0;
  3013. for($i = 0;$i < $len;$i++){
  3014. if(isset($rk_list[$i]) && empty($ck_list[$ck_index]) ){
  3015. $tran_list[] = [
  3016. 'lx'=>$rk_list[$i],
  3017. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3018. 'rk_time'=>$rk_time[$i],
  3019. 'ck_time'=>'',
  3020. 'is_over'=>1,//未出库
  3021. ];
  3022. }else{
  3023. if($rk_list[$i] == $ck_list[$ck_index]){
  3024. $tran_list[] = [
  3025. 'lx'=>$rk_list[$i],
  3026. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3027. 'rk_time'=>$rk_time[$i],
  3028. 'ck_time'=>$ck_time[$ck_index],
  3029. 'is_over'=>2,//已出库
  3030. ];
  3031. $ck_index++;
  3032. }else if($rk_list[$i] != $ck_list[$ck_index]){
  3033. if($rk_list[$i] == $ck_list[$ck_index-1]){
  3034. //估计是之前完成 或者 成品库 强制扫入
  3035. $tran_list[] = [
  3036. 'lx'=>$rk_list[$i],
  3037. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3038. 'rk_time'=>$rk_time[$i],
  3039. 'ck_time'=>$ck_time[$ck_index-1],
  3040. 'is_over'=>2,//已出库
  3041. ];
  3042. }else if( !empty($ck_list[$ck_index+1]) &&($rk_list[$i] == $ck_list[$ck_index+1])){
  3043. //估计是完成 或者 成品库 强制扫出了
  3044. $tran_list[] = [
  3045. 'lx'=>$rk_list[$i],
  3046. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3047. 'rk_time'=>$rk_time[$i],
  3048. 'ck_time'=>$ck_time[$ck_index+1],
  3049. 'is_over'=>2,//已出库
  3050. ];
  3051. $ck_index++;
  3052. $ck_index++;
  3053. }else{
  3054. //估计是完成 或者 成品库 强制扫出了
  3055. $tran_list[] = [
  3056. 'lx'=>$rk_list[$i],
  3057. 'lx_show'=>(isset($t[$rk_list[$i]])?$t[$rk_list[$i]]:''),
  3058. 'rk_time'=>$rk_time[$i],
  3059. 'ck_time'=>'',
  3060. 'is_over'=>-3,//已出库
  3061. ];
  3062. }
  3063. }
  3064. }
  3065. }
  3066. return $tran_list;
  3067. }
  3068. public function _ycrk(){
  3069. if($this->input->method() == 'get'){
  3070. echo json_encode(array('msg'=>'请求方式不正确','success'=>false));exit;
  3071. }
  3072. $id = $this->input->post('id',true);
  3073. $type = $this->input->post('type',true);
  3074. if(!in_array($type,[1,2,3])){
  3075. echo json_encode(array('msg'=>'入库类别异常,联系技术','success'=>false));exit;
  3076. }
  3077. $info = $this->systemtransfer->read($id);
  3078. if(empty($info)){
  3079. echo json_encode(array('msg'=>'数据不存在','success'=>false));exit;
  3080. }
  3081. if(!empty($info['ycrk_type'])){
  3082. echo json_encode(array('msg'=>'已添加异常入库,不要重复添加','success'=>false));exit;
  3083. }
  3084. //更新数据
  3085. $this->systemtransfer->save([
  3086. 'ycrk_type'=>$type,
  3087. ],$id);
  3088. $list = $this->systemtransfer_cr->find_all('fid = '.$id,'*','id desc');
  3089. foreach ($list as $key=>$value) {
  3090. $this->systemtransfer_cr->save([
  3091. 'ycrk_type'=>$type,
  3092. ],$value['id']);
  3093. }
  3094. $this->systemtransfer_cr->insert([
  3095. 'fid'=>$id,'lx'=>0,'type'=>$type,'time'=>time(),'is_over'=>0,'over_flag'=>0,
  3096. 'extra_status'=>0,'ycrk_type'=>$type,
  3097. ]);
  3098. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  3099. }
  3100. public function _ycrkindex(){
  3101. if($this->input->method() == 'get'){
  3102. if(isset($_SESSION['api']))
  3103. {
  3104. $user = $this->user->get_api($_SESSION['api']);
  3105. $usp = $user;
  3106. $pid = "";$tid="";$sid="";$wid="";
  3107. $purchase = explode('|',trim($user['purchase'],'|'));
  3108. $transfer = explode('|',trim($user['transfer'],'|'));
  3109. $warehouse = explode('|',trim($user['warehouse'],'|'));
  3110. foreach ($purchase as $value)
  3111. {
  3112. $pid .= " id = ".$value." or";
  3113. }
  3114. foreach ($transfer as $value)
  3115. {
  3116. $tid .= " id = ".$value." or";
  3117. }
  3118. foreach ($warehouse as $value)
  3119. {
  3120. $wid .= " id = ".$value." or";
  3121. }
  3122. }
  3123. else
  3124. {
  3125. header('Location: /');exit;
  3126. }
  3127. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  3128. $this->data['transfer'] = $transfer;
  3129. $transfer_ids = array_column($transfer, 'id');
  3130. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  3131. $this->_Template('transfer_ycrkindex',$this->data);
  3132. }else{
  3133. $page = $this->input->post('page',true);
  3134. $perpage = $this->input->post('perpage',true);
  3135. $transfer_ids = $this->input->post('transfer_ids',true);
  3136. $timetk = $this->input->post('timetk',true);
  3137. $timetj = $this->input->post('timetj',true);
  3138. $timetk = strtotime($timetk);
  3139. $timetj = strtotime($timetj);
  3140. $ycrk_type = $this->input->post('ycrk_type',true);
  3141. $transfer_list = $this->transfer->find_all();
  3142. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  3143. if(empty($ycrk_type)){
  3144. $where = 'lx = 0 and ycrk_type != 0 ';
  3145. }else{
  3146. $where = 'lx = 0 and ycrk_type = '.$ycrk_type;
  3147. }
  3148. //数据排序
  3149. $order_str = "id desc";
  3150. if(empty($page))
  3151. {
  3152. $start = 0;
  3153. $perpage = 1;
  3154. }
  3155. else
  3156. {
  3157. $start = ($page - 1)*$perpage;
  3158. }
  3159. $where .= " and time > '$timetk' and time < '$timetj'";
  3160. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  3161. $final_list = [];
  3162. foreach ($list as $key => $value) {
  3163. $info = $this->systemtransfer->read($value['fid']);
  3164. $final_list[$key]['id'] = $value['id'];
  3165. $final_list[$key]['number'] = $info['number'];
  3166. $ycrk_type_str = "";
  3167. if($value['ycrk_type'] == 3){
  3168. $ycrk_type_str = "外销单入库";
  3169. }else if($value['ycrk_type'] == 2){
  3170. $ycrk_type_str = "成品库入库";
  3171. }else{
  3172. $ycrk_type_str = "配货入库";
  3173. }
  3174. $final_list[$key]['ycrk_type'] = $ycrk_type_str;
  3175. $final_list[$key]['pm'] = $info['pm'];
  3176. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  3177. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  3178. $final_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  3179. }
  3180. $total = $this->systemtransfer_cr->find_count($where);
  3181. $pagenum = ceil($total/$perpage);
  3182. $over = $total-($start+$perpage);
  3183. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  3184. echo json_encode($rows);exit;
  3185. }
  3186. }
  3187. }