Transfer.php 101 KB

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