Transfer.php 113 KB

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