Transfer.php 110 KB

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