Transfer.php 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009
  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. echo json_encode(array('rows'=>$cp,'success'=>true));exit;
  532. }
  533. $purchase = $this->purchase->find_all("yyid != ''");
  534. $this->data['purchase'] = $purchase;
  535. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  536. $this->data['transfer'] = $transfer;
  537. $this->_Template('transfer_number',$this->data);
  538. }
  539. public function _numberprint()
  540. {
  541. $time = time();
  542. $post = $this->input->post(NULL);
  543. $classid = $this->classid->sku();
  544. $pm = $classid;
  545. $scsku = $classid;
  546. if(isset($post['data']))
  547. {
  548. $this->logic_ding->sendToDing("小布表打印请求数据".json_encode($post));
  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. //$this->logic_ding->sendToDing("小布表打印异常".json_encode($post));
  612. $yy = $this->apiyy->_peihuo($post,$kh['yyid'],$y['number'],$post['xbqnum']);
  613. $this->logic_ding->sendToDing("小布表打印异常".json_encode($yy)."|".json_encode($y['number']));
  614. if($yy['c'] == 0)
  615. {
  616. $post['scapi'] = '99';
  617. $post['scid'] = $yy['scid'];
  618. if(!$post['purchase'])
  619. {
  620. $post['purchase'] = '';
  621. }
  622. $mqsl = $this->systemtransfer->find_count("number = '".$data['number']."'");
  623. //able_ext 实在打印小单布标时判断是否可以打印备货单
  624. $able_ext = 0;
  625. $tmp_fetaures = explode('-',$data['features']);
  626. //只有头套和马尾才会要配货单
  627. if(in_array(128, $tmp_fetaures)){
  628. $able_ext = 1;
  629. }
  630. if(in_array(133, $tmp_fetaures)){
  631. if(in_array(673, $tmp_fetaures)){
  632. $able_ext = 1;
  633. }
  634. }
  635. for($i=0;$i<$xbqnum;$i++)
  636. {
  637. if($post['zps'])
  638. {
  639. if($post['zps'] > 0)
  640. {
  641. $t = '总量:'.($mqsl+$i+1).'/'.$zps;
  642. }
  643. }
  644. $label = substr($time,1)*100;
  645. $post['label'] = $label+$i;
  646. $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);
  647. $this->systemtransfer->insert($post);
  648. }
  649. }
  650. else
  651. {
  652. $this->db->trans_rollback();
  653. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  654. }
  655. if($this->db->trans_status() === TRUE)
  656. {
  657. $this->db->trans_commit();
  658. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  659. }
  660. else
  661. {
  662. $this->db->trans_rollback();
  663. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  664. }
  665. }
  666. }
  667. public function _operate()
  668. {
  669. $post = $this->input->post(NULL, TRUE);
  670. if(isset($post['page']))
  671. {
  672. $api = $this->input->post('api',true);
  673. $page = $this->input->post('page',true);
  674. $perpage = $this->input->post('perpage',true);
  675. $number = $this->input->post('number',true);
  676. $color = $this->input->post('color',true);
  677. $purchase = $this->input->post('purchase',true);
  678. $transfer = $this->input->post('transfer',true);
  679. $lx = $this->input->post('lx',true);
  680. $type = $this->input->post('type',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($purchase)
  693. {
  694. $where .= " and purchase = '$purchase'";
  695. }
  696. if($color)
  697. {
  698. $where .= " and fpdata like '%-".$color."-%'";
  699. }
  700. if($lx)
  701. {
  702. if($lx == 1)
  703. {
  704. $where .= " and ordernumber = ''";
  705. }
  706. else
  707. {
  708. $where .= " and ordernumber != ''";
  709. }
  710. }
  711. if($jiaji){
  712. if($jiaji == 1){
  713. $where .= " and is_jiaji = 0";
  714. }
  715. if($jiaji == 2){
  716. $where .= " and is_jiaji = 2";
  717. }
  718. }
  719. //数据排序
  720. $order_str = "id desc";
  721. if(empty($page))
  722. {
  723. $start = 0;
  724. $perpage = 1;
  725. }
  726. else
  727. {
  728. $start = ($page - 1)*$perpage;
  729. }
  730. if($xztime == 'printtime')
  731. {
  732. $where .= " and ctime12 > '$timetk' and ctime12 < '$timetj'";
  733. if($type)
  734. {
  735. if($type == 3){
  736. if($transfer)
  737. {
  738. $where .= " and rk like '%|".$transfer."|%' and rk != ck";
  739. }
  740. }else{
  741. $type = ($type==1)?'rk':'ck';
  742. if($transfer)
  743. {
  744. $where .= " and $type like '%|".$transfer."|%'";
  745. }
  746. }
  747. }
  748. else
  749. {
  750. if($transfer)
  751. {
  752. $where .= " and rk like '%|".$transfer."|%'";
  753. }
  754. }
  755. }
  756. else
  757. {
  758. $cr = "time > '$timetk' and time < '$timetj'";
  759. if($transfer)
  760. {
  761. $cr .= " and lx = '".$transfer."' ";
  762. }
  763. if($type)
  764. {
  765. if($type == 3){
  766. $cr .= " and is_over = 0 ";
  767. }else{
  768. $cr .= " and type = '".$type."' ";
  769. }
  770. }
  771. $fid = '';
  772. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  773. foreach ($info_list_cr as $v)
  774. {
  775. $fid .= "id = '".$v['fid']."' or ";
  776. }
  777. if($fid)
  778. {
  779. $where .= ' and ('.trim($fid,'or ').')';
  780. }
  781. else
  782. {
  783. $where .= ' and id = 0';
  784. }
  785. }
  786. //取得信息列表
  787. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  788. $transfer = $this->transfer->find_all();
  789. $t = array();
  790. foreach ($transfer as $v)
  791. {
  792. $t[$v['id']] = $v['title'];
  793. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  794. }
  795. //格式化数据
  796. foreach ($info_list as $key=>$value)
  797. {
  798. if($value['is_jiaji'] == 2){
  799. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  800. }else{
  801. $info_list[$key]['is_jiaji'] = "常规";
  802. }
  803. $dd = $this->systemtransfer->read($value['id']);
  804. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  805. $rk = explode('|',trim($dd['rk'],'|'));
  806. $rktime = explode('|',trim($dd['rktime'],'|'));
  807. $ck = explode('|',trim($dd['ck'],'|'));
  808. $cktime = explode('|',trim($dd['cktime'],'|'));
  809. $info_list[$key]['time'] = '';
  810. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  811. /**
  812. for($i=0;$i<count($rk);$i++)
  813. {
  814. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  815. {
  816. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  817. }
  818. else
  819. {
  820. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  821. }
  822. $info_list[$key]['time'] .= $d;
  823. if(isset($ck[$i]) && $ck[$i] != '')
  824. {
  825. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  826. }
  827. }
  828. **/
  829. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  830. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  831. foreach ($data as $k=>$v)
  832. {
  833. // $type = ($v['type']==1)?'入库':'出库';
  834. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  835. $type = ($v['type']==1)?'入库':'出库';
  836. if($v['orver_flag'] == 1){
  837. if($v['is_over'] == 0){
  838. $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>";
  839. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  840. }else{
  841. $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>";
  842. }
  843. }elseif($v['orver_flag'] == 2){
  844. $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>";
  845. }elseif($v['orver_flag'] == 3){
  846. $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>";
  847. }else{
  848. $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>";
  849. }
  850. if($v['extra_status'] == 1){
  851. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  852. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  853. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  854. }else{
  855. $info_list[$key]['time'] .= "<br>";
  856. }
  857. }
  858. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  859. unset($info_list[$key]['ctime12']);
  860. }
  861. $total = $this->systemtransfer->find_count($where);
  862. $pagenum = ceil($total/$perpage);
  863. $over = $total-($start+$perpage);
  864. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  865. echo json_encode($rows);exit;
  866. }
  867. if(isset($_SESSION['api']))
  868. {
  869. $user = $this->user->get_api($_SESSION['api']);
  870. $usp = $user;
  871. $pid = "";$tid="";$sid="";$wid="";
  872. $purchase = explode('|',trim($user['purchase'],'|'));
  873. $transfer = explode('|',trim($user['transfer'],'|'));
  874. $warehouse = explode('|',trim($user['warehouse'],'|'));
  875. foreach ($purchase as $value)
  876. {
  877. $pid .= " id = ".$value." or";
  878. }
  879. foreach ($transfer as $value)
  880. {
  881. $tid .= " id = ".$value." or";
  882. }
  883. foreach ($warehouse as $value)
  884. {
  885. $wid .= " id = ".$value." or";
  886. }
  887. }
  888. else
  889. {
  890. header('Location: /');exit;
  891. }
  892. $sc_flag = 0; //生产中按钮的标识符号 为1的是可以查看 0 不可以
  893. //只有admin和toutao用户可以查看
  894. if(in_array($user['id'],[10,44,50])){
  895. $sc_flag = 1;
  896. }
  897. $this->data['sc_flag'] = $sc_flag;
  898. $kx = '';$zjtab = '';
  899. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  900. $this->data['warehouse'] = $warehouse;
  901. $purchase = $this->purchase->find_all("yyid != ''");
  902. $this->data['purchase'] = $purchase;
  903. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  904. $this->data['transfer'] = $transfer;
  905. $this->data['vip'] = $user['vip'];
  906. $transfer_ids = array_column($transfer,'id');
  907. $transfer_str = implode(",",$transfer_ids);
  908. $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.")");
  909. $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.")");
  910. //$jiaji_num = 0;
  911. // $jiaji_num = $this->systemtransfer->find_count(" is_jiaji = 2 and time > ".(time()-3600*24*7)." and rk not like '%|11|%'" );
  912. foreach($transfer_ids as $k=>$v){
  913. if($v == 11){
  914. unset($transfer_ids[$k]);
  915. }
  916. }
  917. if(empty($transfer_ids)){
  918. $this->data['jiaji_num'] = -1;
  919. }else{
  920. $transfer_str = implode(",",$transfer_ids);
  921. $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|%'");
  922. // 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|%'");
  923. $tmp_list= $sql_r->result_array();
  924. $this->data['jiaji_num'] = count($tmp_list);
  925. }
  926. $this->_Template('transfer_operate',$this->data);
  927. }
  928. public function _out()
  929. {
  930. $post = $this->input->post(NULL, TRUE);
  931. if(isset($post['label']))
  932. {
  933. $time = time();
  934. $label = $this->input->post('label',true);
  935. $cz = $this->input->post('cz',true);
  936. $transfer = $this->input->post('transfer',true);
  937. if(!$label)
  938. {
  939. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  940. }
  941. if(!$transfer)
  942. {
  943. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  944. }
  945. $lb = $this->systemtransfer->get_label($label);
  946. if(!$lb)
  947. {
  948. $this->logic_ding->sendToDing("检测货物流转异常的编码".$transfer."|".$label);
  949. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  950. }
  951. if($lb['number']!='')
  952. {
  953. $nu = $this->fullorder->get_number($lb['number']);
  954. if(!$nu)
  955. {
  956. $nu = $this->fullordersmt->get_number($lb['number']);
  957. if(!$nu)
  958. {
  959. $nu = $this->fullordertt->get_number($lb['number']);
  960. }
  961. }
  962. //取消的订单还是要继续生产的 所以还允许继续扫入扫出 只是后续的出入库中不在限定时间
  963. // if($nu['state'] == '214' || $nu['state'] == '217')
  964. // {
  965. // echo json_encode(array('msg'=>'错误,此单已取消!请联系店员核实','success'=>false));exit;
  966. // }
  967. }
  968. $tdata = $this->transfer->find_all();
  969. $t = array();
  970. foreach ($tdata as $v)
  971. {
  972. $t[$v['id']] = $v['title'];
  973. }
  974. /**
  975. if($cz == 1 && stripos($lb['rk'],'|'.$transfer.'|') !== false)
  976. {
  977. echo json_encode(array('msg'=>'此条码已有入库操作!','success'=>false));exit;
  978. }
  979. if($cz == 2 && stripos($lb['ck'],'|'.$transfer.'|') !== false)
  980. {
  981. echo json_encode(array('msg'=>'此条码已有出库操作!','success'=>false));exit;
  982. }
  983. **/
  984. // if(stripos($lb['ck'],'|1|') === false && $transfer != 1 && stripos($nu['fpdata'],'-128-') !== false)
  985. // {
  986. // echo json_encode(array('msg'=>'必须有配货出库才可后续操作!','success'=>false));exit;
  987. // }
  988. //重新定义配货的原则问题
  989. //先检测订单是否含有 128 头套 或者配件 如果有 133 进行下一步检测
  990. $sku_arr = explode("-",$lb['features']);
  991. if(in_array(128,$sku_arr)||in_array(133,$sku_arr)){
  992. // 145 Full Lace Wig
  993. // 1170 HDFullLaceWig
  994. // 1249 FullLaceBobwithBang
  995. // 1484 FullLaceBob
  996. //如果是这4中全蕾丝那么配货就不处理
  997. if(in_array(145,$sku_arr) || in_array(1170,$sku_arr) || in_array(1249,$sku_arr) || in_array(1484,$sku_arr)){
  998. }else{
  999. if(stripos($lb['ck'],'|1|') === false && $transfer != 1 )
  1000. {
  1001. echo json_encode(array('msg'=>'头套和配件除了全蕾丝外必须走配货!','success'=>false));exit;
  1002. }
  1003. }
  1004. }
  1005. if($cz == 2 && stripos($lb['rk'],'|'.$transfer.'|') === false)
  1006. {
  1007. echo json_encode(array('msg'=>'此条码还未入库!','success'=>false));exit;
  1008. }
  1009. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1010. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1011. if($transfer != 3 && $transfer != 11 && $transfer != 2)
  1012. {
  1013. if($cz == 1)
  1014. {
  1015. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1016. {
  1017. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1018. }
  1019. }
  1020. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1021. {
  1022. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1023. }
  1024. }
  1025. if($cz == 1)
  1026. {
  1027. $lb['rk'] .= $transfer.'|';
  1028. $lb['rktime'] .= $time.'|';
  1029. if($lbrk[0] == $transfer)
  1030. {
  1031. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1032. }
  1033. }
  1034. else if($cz == 2)
  1035. {
  1036. $lb['ck'] .= $transfer.'|';
  1037. $lb['cktime'] .= $time.'|';
  1038. if($lbck[0] == $transfer)
  1039. {
  1040. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1041. }
  1042. }
  1043. $this->_doCancelWlz($lb['id']);
  1044. $cztime = 'ctime'.$transfer;
  1045. $this->logic_ding->sendToDing("检测货物流转打印情况".$transfer."|".$cz."|".$lb['number']."|".$lb['id']);
  1046. if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1047. //if(($transfer == 8 || $transfer == 13) && $lb['dbapi'] < 99 && $cz == 1)//单入库
  1048. {
  1049. if($lb['type'] == 0)
  1050. {
  1051. $s = $this->shop->read($nu['shop']);
  1052. $lb['kh'] = $s['yyid'];
  1053. $lb['ts'] = 1;
  1054. $rk = $this->apiyy->_newrk($lb);
  1055. if($rk['c'] == 0)
  1056. {
  1057. $this->db->trans_begin();
  1058. $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']);
  1059. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1060. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1061. if($cz == 2){
  1062. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1063. }
  1064. if ($this->db->trans_status() === TRUE)
  1065. {
  1066. $this->db->trans_commit();
  1067. if($nu['state'] == '216')
  1068. {
  1069. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1070. }
  1071. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1072. //标记订单已经取消
  1073. $this->_doCheckCancelFlag($lb['id']);
  1074. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1075. }
  1076. else
  1077. {
  1078. if($lb['is_jiaji'] == 2){
  1079. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1080. }else{
  1081. echo json_encode(array('music'=>'1','success'=>true));exit;
  1082. }
  1083. }
  1084. }
  1085. else
  1086. {
  1087. $this->db->trans_rollback();
  1088. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1089. }
  1090. }
  1091. else
  1092. {
  1093. if(stripos($rk['error'],'DocNo') !== false)
  1094. {
  1095. $rk['error'] = '未找到对应的生产订单 '.$lb['scid'];
  1096. }
  1097. $this->systemtransfer->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$lb['id']);
  1098. echo json_encode(array('msg'=>'订单号:'.$lb['number'].' 用友报错:'.$rk['error'],'success'=>false));exit;
  1099. }
  1100. }elseif($lb['type'] == 2){
  1101. $this->db->trans_begin();
  1102. $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']);
  1103. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1104. $this->zzquque_u9->insert([
  1105. 'platform'=>'',
  1106. 'warehouse'=>0,
  1107. 'type'=>20, //5代表美仓
  1108. 'order_no'=>$lb['number'],
  1109. 'child_order_no'=>$lb['id'],
  1110. 'status'=>0,
  1111. 'create_time'=>time(),
  1112. 'update_time'=>time(),
  1113. ]);
  1114. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1115. if($cz == 2){
  1116. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1117. }
  1118. if ($this->db->trans_status() === TRUE)
  1119. {
  1120. $this->db->trans_commit();
  1121. if($nu['state'] == '216')
  1122. {
  1123. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1124. }
  1125. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1126. //标记订单已经取消
  1127. $this->_doCheckCancelFlag($lb['id']);
  1128. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1129. }
  1130. else
  1131. {
  1132. if($lb['is_jiaji'] == 2){
  1133. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1134. }else{
  1135. echo json_encode(array('music'=>'1','success'=>true));exit;
  1136. }
  1137. }
  1138. }
  1139. else
  1140. {
  1141. $this->db->trans_rollback();
  1142. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1143. }
  1144. }
  1145. else
  1146. {
  1147. $scid = explode('~',$lb['scid']);
  1148. $rkdata = array('od'=>$scid[1],'ts'=>1,'title'=>$lb['title']);
  1149. $rk = $this->apiyy->get_bzsh($rkdata);
  1150. if(isset($rk['Data'][0]))
  1151. {
  1152. if($rk['Data'][0]['IsSucess'] == 1)
  1153. {
  1154. $this->db->trans_begin();
  1155. $this->systemtransfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),'dbapi'=>99,'scid'=>$lb['scid'].'~'.$rk['Data'][0]['Code'],$cztime=>$time),$lb['id']);
  1156. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1157. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1158. if($cz == 2){
  1159. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1160. }
  1161. if ($this->db->trans_status() === TRUE)
  1162. {
  1163. $this->db->trans_commit();
  1164. if($nu['state'] == '216')
  1165. {
  1166. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1167. }
  1168. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1169. //标记订单已经取消
  1170. $this->_doCheckCancelFlag($lb['id']);
  1171. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1172. }
  1173. else
  1174. {
  1175. if($lb['is_jiaji'] == 2){
  1176. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1177. }else{
  1178. echo json_encode(array('music'=>'1','success'=>true));exit;
  1179. }
  1180. }
  1181. }
  1182. else
  1183. {
  1184. $this->db->trans_rollback();
  1185. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1186. }
  1187. }
  1188. else
  1189. {
  1190. echo json_encode(array('msg'=>$rk['Data'][0]['ErrorMsg'],'success'=>false));exit;
  1191. }
  1192. }
  1193. else
  1194. {
  1195. echo json_encode(array('msg'=>$rk,'success'=>false));exit;
  1196. }
  1197. }
  1198. }
  1199. //if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//只入库
  1200. if($transfer == 11 && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库
  1201. {
  1202. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1203. }
  1204. $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']);
  1205. $this->systemtransfer_cr->insert(array('fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>$time));
  1206. //处理定时任务每三分钟 执行一次的bug 在出库的时候直接同步相关信息
  1207. if($cz == 2){
  1208. $this->_doCheckIsOverTime($lb['id'],$transfer);
  1209. }
  1210. if ($this->db->trans_status() === TRUE)
  1211. {
  1212. $this->db->trans_commit();
  1213. if($nu['state'] == '216')
  1214. {
  1215. echo json_encode(array('msg'=>'数据已录入成功!提示:此订单已出库,可选择终止生产。','success'=>false));exit;
  1216. }
  1217. elseif(($nu['state'] == '217') || ($nu['state'] == '214')){
  1218. //标记订单已经取消
  1219. $this->_doCheckCancelFlag($lb['id']);
  1220. echo json_encode(array('msg'=>'数据已录入成功!提示:【该单已取消】,可选择终止生产。','success'=>false));exit;
  1221. }
  1222. else
  1223. {
  1224. if($lb['is_jiaji'] == 2){
  1225. echo json_encode(array('music'=>'1','is_jiaji'=>2,'success'=>true));exit;
  1226. }else{
  1227. echo json_encode(array('music'=>'1','success'=>true));exit;
  1228. }
  1229. }
  1230. }
  1231. else
  1232. {
  1233. $this->db->trans_rollback();
  1234. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1235. }
  1236. }
  1237. }
  1238. //检测取消标记是否添加 同时也检查下 该流转单是否被标记为取消单
  1239. private function _doCheckCancelFlag($fid){
  1240. $info = $this->systemtransfer->read($fid);
  1241. if($info['status'] != 11){
  1242. $this->systemtransfer->save(['status'=>11],$fid);
  1243. }
  1244. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1245. if(empty($list)){
  1246. return;
  1247. }
  1248. $is_cancel = false;
  1249. foreach($list as $val){
  1250. if($val['orver_flag'] == 3){
  1251. $is_cancel = true;
  1252. }
  1253. }
  1254. if($is_cancel){
  1255. return ;
  1256. }
  1257. $this->systemtransfer_cr->save(['orver_flag'=>3],$list[0]['id']);
  1258. }
  1259. //检测是否可以取消长期未流转
  1260. private function _doCancelWlz($fid){
  1261. //$info = $this->systemtransfer->read($fid);
  1262. $list = $this->systemtransfer_cr->find_all("fid = ".$fid,'*','id desc');
  1263. if(empty($list)){
  1264. return;
  1265. }
  1266. $id = $list[0]['id'];
  1267. $scan_time = $list[0]['time'];
  1268. if($list[0]['type'] == 2){
  1269. if(time() - $scan_time < 3600 * 24 * 3){
  1270. $this->systemtransfer_cr->save([
  1271. 'extra_status'=>0,
  1272. ],$id);
  1273. }else{
  1274. $this->systemtransfer_cr->save([
  1275. 'extra_status'=>3,
  1276. ],$id);
  1277. }
  1278. }
  1279. }
  1280. //检测是否超时 车间流转环节
  1281. private function _doCheckIsOverTime($fid,$transfer){
  1282. $list = $this->systemtransfer_cr->find_all("fid = ".$fid." and lx = ".$transfer." and is_over = 0","*",'id desc',0,2);
  1283. if(count($list) < 2){
  1284. return ;
  1285. }
  1286. if($list[0]['type'] != 2){
  1287. return;
  1288. }
  1289. if($list[1]['type'] != 1){
  1290. return;
  1291. }
  1292. if($list[1]['orver_flag'] == 2){
  1293. $this->systemtransfer_cr->save(array('is_over'=>1,'orver_flag'=>2),$list[0]['id']);
  1294. }else{
  1295. $this->systemtransfer_cr->save(array('is_over'=>1),$list[0]['id']);
  1296. }
  1297. $this->systemtransfer_cr->save(array('is_over'=>1),$list[1]['id']);
  1298. }
  1299. public function _bdbb()
  1300. {
  1301. $post = $this->input->post(NULL, TRUE);
  1302. if(isset($post['s']))
  1303. {
  1304. $id_arr = $this->input->post('s');
  1305. $id_arr = explode(',',trim($id_arr,','));
  1306. if(!$id_arr)
  1307. {
  1308. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1309. }
  1310. //循环删除记录
  1311. foreach ($id_arr as $v)
  1312. {
  1313. $t = $this->systemtransfer->read($v);
  1314. if(!isset($t['number']))
  1315. {
  1316. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1317. }
  1318. $y = $this->fullorder->get_number($t['number']);
  1319. if(!$y)
  1320. {
  1321. $y = $this->fullordersmt->get_number($t['number']);
  1322. if(!$y)
  1323. {
  1324. $y = $this->fullordertt->get_number($t['number']);
  1325. if(!$y)
  1326. {
  1327. echo json_encode(array('msg'=>$t['number'].'没有找到此订单','success'=>false));exit;
  1328. }
  1329. }
  1330. }
  1331. $express = $this->express->read($y['express']);
  1332. $rows[] = array('num'=>$t['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'=>"补打");
  1333. }
  1334. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1335. }
  1336. }
  1337. public function _excel()
  1338. {
  1339. if(isset($_GET['fexcel']))
  1340. {
  1341. $tc = array();$zh = array();
  1342. $typeclass = $this->typeclass->find_all();
  1343. foreach ($typeclass as $v)
  1344. {
  1345. $tc[$v['id']] = $v;
  1346. }
  1347. $number = $this->input->get('number',true);
  1348. $color = $this->input->get('color',true);
  1349. $gs = $this->input->get('gs',true);
  1350. $transfer = $this->input->get('transfer',true);
  1351. $type = $this->input->get('type',true);
  1352. $timetk = $this->input->get('timetk',true);
  1353. $timetj = $this->input->get('timetj',true);
  1354. $purchase = $this->input->get('purchase',true);
  1355. $lx = $this->input->get('lx',true);
  1356. $timetk = strtotime($timetk);
  1357. $timetj = strtotime($timetj);
  1358. $where = "1=1";
  1359. $cr = "time > '$timetk' and time < '$timetj'";
  1360. if($number)
  1361. {
  1362. $where .= " and number = '$number'";
  1363. }
  1364. if($transfer)
  1365. {
  1366. $cr .= " and lx = '".$transfer."'";
  1367. }
  1368. if($type)
  1369. {
  1370. //$cr .= " and type = '".$type."'";
  1371. if($type == 3){
  1372. $cr .= " and is_over = 0 ";
  1373. }else{
  1374. $cr .= " and type = '".$type."' ";
  1375. }
  1376. }
  1377. if($purchase)
  1378. {
  1379. $where .= " and purchase = '$purchase'";
  1380. }
  1381. if($color)
  1382. {
  1383. $where .= " and fpdata like '%-".$color."-%'";
  1384. }
  1385. if($lx)
  1386. {
  1387. if($lx == 1)
  1388. {
  1389. $where .= " and ordernumber = ''";
  1390. }
  1391. else
  1392. {
  1393. $where .= " and ordernumber != ''";
  1394. }
  1395. }
  1396. $fid = '';
  1397. $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  1398. foreach ($info_list_cr as $v)
  1399. {
  1400. $fid .= "id = '".$v['fid']."' or ";
  1401. }
  1402. if($fid)
  1403. {
  1404. $where .= ' and ('.trim($fid,'or ').')';
  1405. }
  1406. else
  1407. {
  1408. $where .= ' and id = 0';
  1409. }
  1410. $data = array();
  1411. $datafy = array();
  1412. $j = 0;
  1413. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,jm,shipremarks,printtime');
  1414. $lzbm = $this->transfer->find_all();
  1415. foreach ($info_list as $key=>$value)
  1416. {
  1417. $dj = '';$ys = '';$cc = '';$hx = '';$md = '';
  1418. $d = $this->systemtransfer->read($value['id']);
  1419. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1420. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$d['shipremarks']);
  1421. $d['features'] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$d['features']);
  1422. $cp = explode('-',trim($d['features'],'-'));
  1423. $rk = explode('|',trim($d['rk'],'|'));
  1424. $rktime = explode('|',trim($d['rktime'],'|'));
  1425. foreach ($cp as $v)
  1426. {
  1427. if(isset($tc[$v]))
  1428. {
  1429. if($tc[$v]['classid'] == 13)
  1430. {
  1431. $dj = $tc[$v]['title'];
  1432. }
  1433. else if($tc[$v]['classid'] == 8)
  1434. {
  1435. $ys = $tc[$v]['title'];
  1436. }
  1437. else if($tc[$v]['classid'] == 14)
  1438. {
  1439. $cc = $tc[$v]['title'];
  1440. }
  1441. else if($tc[$v]['classid'] == 15)
  1442. {
  1443. $hx = $tc[$v]['title'];
  1444. }
  1445. else if($tc[$v]['classid'] == 10)
  1446. {
  1447. $md = $tc[$v]['title'];
  1448. }
  1449. }
  1450. }
  1451. $rt = array();
  1452. foreach ($rk as $k=>$v)
  1453. {
  1454. $rt[$v+5] = date('Y-m-d H:i:s',$rktime[$k]);
  1455. }
  1456. $fpdata = array(array('0'=>$d['title'],'1'=>$cc,'2'=>$dj,'3'=>$ys,'4'=>$hx,'5'=>$md));
  1457. foreach ($lzbm as $v)
  1458. {
  1459. if(isset($rt[count($fpdata[0])]))
  1460. {
  1461. //$fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1462. $num = $this->systemtransfer_cr->find_count("fid = ".$value['id']." and lx = ".$v['id']." and orver_flag = 2");
  1463. if($num > 0){
  1464. $fpdata[0][count($fpdata[0])] = "<span style='color:red;font-weight:bold;'>".$rt[count($fpdata[0])]."<span>";
  1465. }else{
  1466. $fpdata[0][count($fpdata[0])] = $rt[count($fpdata[0])];
  1467. }
  1468. }
  1469. else
  1470. {
  1471. $fpdata[0][count($fpdata[0])] = '';
  1472. }
  1473. }
  1474. $info_list[$key]['fpdata'] = $fpdata;//名称,尺寸,等级,颜色,花型,密度
  1475. unset($info_list[$key]['id']);
  1476. }
  1477. //echo "<pre>";print_r($info_list);exit;
  1478. $lzxq = '';
  1479. foreach ($lzbm as $v)
  1480. {
  1481. $lzxq .= '<td>'.$v['title'].'</td>';
  1482. }
  1483. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 统计表';
  1484. $titlename = "<table border=1>
  1485. <tr>
  1486. <td>订单编号</td>
  1487. <td>品名</td>
  1488. <td>简码</td>
  1489. <td>备注</td>
  1490. <td>打印时间</td>
  1491. <td>
  1492. <table border=1>
  1493. <tr><td colspan='6' align='center'>订单产品信息</td><td colspan='".count($lzbm)."' align='center'>货物流转时间</td></tr>
  1494. <tr>
  1495. <td>产品名称</td>
  1496. <td>尺寸</td>
  1497. <td>等级</td>
  1498. <td>颜色</td>
  1499. <td>花型</td>
  1500. <td>密度</td>
  1501. ".$lzxq."
  1502. </tr>
  1503. </table>
  1504. </td>
  1505. </tr>
  1506. </table>";
  1507. $filename = $title.".xls";
  1508. $tail = "\n";
  1509. $this->excel->get_fz($info_list,$titlename,$filename,$tail,1);
  1510. }
  1511. }
  1512. public function _rk()
  1513. {
  1514. $post = $this->input->post(NULL, TRUE);
  1515. if(isset($post['page']))
  1516. {
  1517. $api = $this->input->post('api',true);
  1518. $page = $this->input->post('page',true);
  1519. $perpage = $this->input->post('perpage',true);
  1520. $number = $this->input->post('number',true);
  1521. $color = $this->input->post('color',true);
  1522. $purchase = $this->input->post('purchase',true);
  1523. $transfer = $this->input->post('transfer',true);
  1524. $lx = $this->input->post('lx',true);
  1525. $timetk = $this->input->post('timetk',true);
  1526. $timetj = $this->input->post('timetj',true);
  1527. $timetk = strtotime($timetk);
  1528. $timetj = strtotime($timetj);
  1529. $where = "1=1";
  1530. if($transfer)
  1531. {
  1532. $ctime = 'ctime'.$transfer;
  1533. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1534. }
  1535. else
  1536. {
  1537. $where .= " and time > '$timetk' and time < '$timetj'";
  1538. }
  1539. if($number)
  1540. {
  1541. $where .= " and number = '$number'";
  1542. }
  1543. if($transfer)
  1544. {
  1545. $where .= " and rk like '%|".$transfer."|%'";
  1546. }
  1547. if($purchase)
  1548. {
  1549. $where .= " and purchase = '$purchase'";
  1550. }
  1551. if($color)
  1552. {
  1553. $where .= " and fpdata like '%-".$color."-%'";
  1554. }
  1555. if($lx)
  1556. {
  1557. if($lx == 1)
  1558. {
  1559. $where .= " and ordernumber = ''";
  1560. }
  1561. else
  1562. {
  1563. $where .= " and ordernumber != ''";
  1564. }
  1565. }
  1566. //数据排序
  1567. $order_str = "id desc";
  1568. if(empty($page))
  1569. {
  1570. $start = 0;
  1571. $perpage = 1;
  1572. }
  1573. else
  1574. {
  1575. $start = ($page - 1)*$perpage;
  1576. }
  1577. //取得信息列表
  1578. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1579. $transfer = $this->transfer->find_all();
  1580. $t = array();
  1581. foreach ($transfer as $v)
  1582. {
  1583. $t[$v['id']] = $v['title'];
  1584. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1585. }
  1586. //格式化数据
  1587. foreach ($info_list as $key=>$value)
  1588. {
  1589. $dd = $this->systemtransfer->read($value['id']);
  1590. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1591. $rk = explode('|',trim($dd['rk'],'|'));
  1592. $rktime = explode('|',trim($dd['rktime'],'|'));
  1593. $ck = explode('|',trim($dd['ck'],'|'));
  1594. $cktime = explode('|',trim($dd['cktime'],'|'));
  1595. $info_list[$key]['time'] = '';
  1596. for($i=0;$i<count($rk);$i++)
  1597. {
  1598. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1599. {
  1600. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1601. }
  1602. else
  1603. {
  1604. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1605. }
  1606. $info_list[$key]['time'] .= $d;
  1607. if(isset($ck[$i]) && $ck[$i] != '')
  1608. {
  1609. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1610. }
  1611. }
  1612. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1613. }
  1614. $total = $this->systemtransfer->find_count($where);
  1615. $pagenum = ceil($total/$perpage);
  1616. $over = $total-($start+$perpage);
  1617. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1618. echo json_encode($rows);exit;
  1619. }
  1620. if(isset($_SESSION['api']))
  1621. {
  1622. $user = $this->user->get_api($_SESSION['api']);
  1623. $usp = $user;
  1624. $pid = "";$tid="";$sid="";$wid="";
  1625. $purchase = explode('|',trim($user['purchase'],'|'));
  1626. $transfer = explode('|',trim($user['transfer'],'|'));
  1627. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1628. foreach ($purchase as $value)
  1629. {
  1630. $pid .= " id = ".$value." or";
  1631. }
  1632. foreach ($transfer as $value)
  1633. {
  1634. $tid .= " id = ".$value." or";
  1635. }
  1636. foreach ($warehouse as $value)
  1637. {
  1638. $wid .= " id = ".$value." or";
  1639. }
  1640. }
  1641. else
  1642. {
  1643. header('Location: /');exit;
  1644. }
  1645. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1646. $this->data['transfer'] = $transfer;
  1647. $this->_Template('transfer_rk',$this->data);
  1648. }
  1649. public function _ck()
  1650. {
  1651. $post = $this->input->post(NULL, TRUE);
  1652. if(isset($post['page']))
  1653. {
  1654. $api = $this->input->post('api',true);
  1655. $page = $this->input->post('page',true);
  1656. $perpage = $this->input->post('perpage',true);
  1657. $number = $this->input->post('number',true);
  1658. $color = $this->input->post('color',true);
  1659. $purchase = $this->input->post('purchase',true);
  1660. $transfer = $this->input->post('transfer',true);
  1661. $lx = $this->input->post('lx',true);
  1662. $timetk = $this->input->post('timetk',true);
  1663. $timetj = $this->input->post('timetj',true);
  1664. $timetk = strtotime($timetk);
  1665. $timetj = strtotime($timetj);
  1666. $where = "1=1";
  1667. if($transfer)
  1668. {
  1669. $ctime = 'ctime'.$transfer;
  1670. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1671. }
  1672. else
  1673. {
  1674. $where .= " and time > '$timetk' and time < '$timetj'";
  1675. }
  1676. if($number)
  1677. {
  1678. $where .= " and number = '$number'";
  1679. }
  1680. if($transfer)
  1681. {
  1682. $where .= " and ck like '%|".$transfer."|%'";
  1683. }
  1684. if($purchase)
  1685. {
  1686. $where .= " and purchase = '$purchase'";
  1687. }
  1688. if($color)
  1689. {
  1690. $where .= " and fpdata like '%-".$color."-%'";
  1691. }
  1692. if($lx)
  1693. {
  1694. if($lx == 1)
  1695. {
  1696. $where .= " and ordernumber = ''";
  1697. }
  1698. else
  1699. {
  1700. $where .= " and ordernumber != ''";
  1701. }
  1702. }
  1703. //数据排序
  1704. $order_str = "id desc";
  1705. if(empty($page))
  1706. {
  1707. $start = 0;
  1708. $perpage = 1;
  1709. }
  1710. else
  1711. {
  1712. $start = ($page - 1)*$perpage;
  1713. }
  1714. //取得信息列表
  1715. $info_list = $this->systemtransfer->find_all($where,'id,number,pm,shipremarks,printtime,time',$order_str,$start,$perpage);
  1716. $transfer = $this->transfer->find_all();
  1717. $t = array();
  1718. foreach ($transfer as $v)
  1719. {
  1720. $t[$v['id']] = $v['title'];
  1721. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1722. }
  1723. //格式化数据
  1724. foreach ($info_list as $key=>$value)
  1725. {
  1726. $dd = $this->systemtransfer->read($value['id']);
  1727. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1728. $rk = explode('|',trim($dd['rk'],'|'));
  1729. $rktime = explode('|',trim($dd['rktime'],'|'));
  1730. $ck = explode('|',trim($dd['ck'],'|'));
  1731. $cktime = explode('|',trim($dd['cktime'],'|'));
  1732. $info_list[$key]['time'] = '';
  1733. for($i=0;$i<count($rk);$i++)
  1734. {
  1735. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1736. {
  1737. $d = ' <em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br> ';
  1738. }
  1739. else
  1740. {
  1741. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1742. }
  1743. $info_list[$key]['time'] .= $d;
  1744. if(isset($ck[$i]) && $ck[$i] != '')
  1745. {
  1746. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1747. }
  1748. }
  1749. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1750. }
  1751. $total = $this->systemtransfer->find_count($where);
  1752. $pagenum = ceil($total/$perpage);
  1753. $over = $total-($start+$perpage);
  1754. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$where);
  1755. echo json_encode($rows);exit;
  1756. }
  1757. if(isset($_SESSION['api']))
  1758. {
  1759. $user = $this->user->get_api($_SESSION['api']);
  1760. $usp = $user;
  1761. $pid = "";$tid="";$sid="";$wid="";
  1762. $purchase = explode('|',trim($user['purchase'],'|'));
  1763. $transfer = explode('|',trim($user['transfer'],'|'));
  1764. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1765. foreach ($purchase as $value)
  1766. {
  1767. $pid .= " id = ".$value." or";
  1768. }
  1769. foreach ($transfer as $value)
  1770. {
  1771. $tid .= " id = ".$value." or";
  1772. }
  1773. foreach ($warehouse as $value)
  1774. {
  1775. $wid .= " id = ".$value." or";
  1776. }
  1777. }
  1778. else
  1779. {
  1780. header('Location: /');exit;
  1781. }
  1782. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1783. $this->data['transfer'] = $transfer;
  1784. $this->_Template('transfer_ck',$this->data);
  1785. }
  1786. public function _jgl()
  1787. {
  1788. $post = $this->input->post(NULL, TRUE);
  1789. if(isset($post['printtime']))
  1790. {
  1791. $pt = $this->input->post('printtime',true);
  1792. $wt = $this->input->post('wgtime',true);
  1793. $printtime = strtotime($pt);
  1794. $wgtime = strtotime($wt);
  1795. $sy = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."'");
  1796. $wg = $this->systemtransfer->find_count("printtime > '$printtime' and printtime < '".($printtime+24*3600)."' and ctime11 < '$wgtime' and ctime11 != '0'");
  1797. if($printtime == $wgtime || $printtime > $wgtime)
  1798. {
  1799. echo json_encode(array('msg'=>"<p style='height:140px;line-height:140px'>时间选择错误</p>",'success'=>true));exit;
  1800. }
  1801. 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;
  1802. }
  1803. $this->_Template('transfer_wgl',$this->data);
  1804. }
  1805. public function _linqi(){
  1806. $post = $this->input->post(NULL, TRUE);
  1807. if(isset($post['page']))
  1808. {
  1809. $api = $this->input->post('api',true);
  1810. $page = $this->input->post('page',true);
  1811. $perpage = $this->input->post('perpage',true);
  1812. $transfer = $this->input->post('transfer',true);
  1813. $transfer_ids = $this->input->post('transfer_ids',true);
  1814. $orver_flag = $this->input->post('orver_flag',true);
  1815. $timetk = $this->input->post('timetk',true);
  1816. $timetj = $this->input->post('timetj',true);
  1817. $timetk = strtotime($timetk);
  1818. $timetj = strtotime($timetj);
  1819. $transfer_list = $this->transfer->find_all();
  1820. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  1821. $where = 'type = 1 ';
  1822. $where .= " and is_over = 0 and orver_flag = ".$orver_flag." ";
  1823. //数据排序
  1824. $order_str = "id desc";
  1825. if(empty($page))
  1826. {
  1827. $start = 0;
  1828. $perpage = 1;
  1829. }
  1830. else
  1831. {
  1832. $start = ($page - 1)*$perpage;
  1833. }
  1834. if($transfer){
  1835. $where .= " and lx = '$transfer'";
  1836. }else{
  1837. $where .= " and lx in (".$transfer_ids.") ";
  1838. }
  1839. $where .= " and time > '$timetk' and time < '$timetj'";
  1840. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  1841. $final_list = [];
  1842. foreach ($list as $key => $value) {
  1843. $info = $this->systemtransfer->read($value['fid']);
  1844. $final_list[$key]['id'] = $value['id'];
  1845. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  1846. if($info['is_jiaji'] == 2){
  1847. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  1848. }else{
  1849. $final_list[$key]['is_jiaji'] = "常规";
  1850. }
  1851. $final_list[$key]['pm'] = $info['pm'];
  1852. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  1853. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  1854. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  1855. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  1856. foreach ($data as $k=>$v)
  1857. {
  1858. $type = ($v['type']==1)?'入库':'出库';
  1859. if($v['orver_flag'] == 1){
  1860. if($v['is_over'] == 0){
  1861. $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>';
  1862. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  1863. }else{
  1864. $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>';
  1865. }
  1866. }elseif($v['orver_flag'] == 2){
  1867. $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>';
  1868. }else{
  1869. $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>';
  1870. }
  1871. }
  1872. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1873. }
  1874. $total = $this->systemtransfer_cr->find_count($where);
  1875. $pagenum = ceil($total/$perpage);
  1876. $over = $total-($start+$perpage);
  1877. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  1878. echo json_encode($rows);exit;
  1879. }
  1880. if(isset($_SESSION['api']))
  1881. {
  1882. $user = $this->user->get_api($_SESSION['api']);
  1883. $usp = $user;
  1884. $pid = "";$tid="";$sid="";$wid="";
  1885. $purchase = explode('|',trim($user['purchase'],'|'));
  1886. $transfer = explode('|',trim($user['transfer'],'|'));
  1887. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1888. foreach ($purchase as $value)
  1889. {
  1890. $pid .= " id = ".$value." or";
  1891. }
  1892. foreach ($transfer as $value)
  1893. {
  1894. $tid .= " id = ".$value." or";
  1895. }
  1896. foreach ($warehouse as $value)
  1897. {
  1898. $wid .= " id = ".$value." or";
  1899. }
  1900. }
  1901. else
  1902. {
  1903. header('Location: /');exit;
  1904. }
  1905. $kx = '';$zjtab = '';
  1906. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1907. $this->data['transfer'] = $transfer;
  1908. $transfer_ids = array_column($transfer, 'id');
  1909. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  1910. $this->data['vip'] = $user['vip'];
  1911. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  1912. $this->_Template('transfer_linqi',$this->data);
  1913. }
  1914. //按照条件导出超时车间
  1915. public function _overtime_export(){
  1916. $transfer_id = $this->input->get('transfer', TRUE);
  1917. $timetk = $this->input->get('timetk', TRUE);
  1918. $timetj = $this->input->get('timetj', TRUE);
  1919. $timetk = strtotime($timetk);
  1920. $timetj = strtotime($timetj);
  1921. if(isset($_SESSION['api']))
  1922. {
  1923. $user = $this->user->get_api($_SESSION['api']);
  1924. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  1925. $tmp_transfer_list = $this->transfer->find_all();
  1926. $transfer_list = array_column($tmp_transfer_list, 'title', 'id');
  1927. }
  1928. else
  1929. {
  1930. header('Location: /');exit;
  1931. }
  1932. $where = " orver_flag = 2 and type = 1";
  1933. if(empty($transfer_id)){
  1934. $where .= " and lx in (".implode(',',$transfer_ids).") ";
  1935. }else{
  1936. $where .= " and lx = ".$transfer_id." ";
  1937. }
  1938. $where .= " and time > '$timetk' and time < '$timetj'";
  1939. $list = $this->systemtransfer_cr->find_all($where,'*');
  1940. $fid_list = array_column($list, 'fid');
  1941. if(empty($fid_list)){
  1942. echo "没有数据" ;
  1943. die ;
  1944. }
  1945. $order_list = $this->systemtransfer->find_all("id in (".implode(',',$fid_list).")");
  1946. $where_two = " orver_flag = 2 and type = 2";
  1947. if(empty($transfer_id)){
  1948. $where_two .= " and lx in (".implode(',',$transfer_ids).") ";
  1949. }else{
  1950. $where_two .= " and lx = ".$transfer_id." ";
  1951. }
  1952. $where_two .= " and time > '$timetk' and time < '$timetj'";
  1953. $list_two = $this->systemtransfer_cr->find_all($where_two,'*');
  1954. $final_list = [];
  1955. // foreach($list as $k => $v){
  1956. // $final_list[$v['fid']]['fid'] = $v['fid'];
  1957. // $final_list[$v['fid']]['lx'] = $v['lx'];
  1958. // $final_list[$v['fid']]['start_type'] = $v['type'];
  1959. // $final_list[$v['fid']]['start_time'] = date('Y-m-d H:i:s',$v['time']);
  1960. // $final_list[$v['fid']]['condition'] = json_decode($v['limit_time_str'],true);
  1961. // $final_list[$v['fid']]['end_time'] = "";
  1962. // $final_list[$v['fid']]['lx_name'] = isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'';
  1963. // }
  1964. // foreach($order_list as $k=>$v){
  1965. // if(isset($final_list[$v['id']])){
  1966. // $final_list[$v['id']]['number'] = $v['number'];
  1967. // $final_list[$v['id']]['pm'] = $v['pm'];
  1968. // }
  1969. // }
  1970. // foreach($list_two as $k => $v){
  1971. // if(isset($final_list[$v['fid']])){
  1972. // if($v['lx'] ==$final_list[$v['fid']]['lx']){
  1973. // $final_list[$v['fid']]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  1974. // }
  1975. // }
  1976. // }
  1977. foreach($list as $k => $v){
  1978. $final_list[] = [
  1979. 'fid' => $v['fid'],
  1980. 'lx' => $v['lx'],
  1981. 'start_type' => $v['type'],
  1982. 'start_time' => date('Y-m-d H:i:s',$v['time']),
  1983. 'condition' => json_decode($v['limit_time_str'],true),
  1984. 'end_time' => "",
  1985. 'lx_name' => isset($transfer_list[$v['lx']])?$transfer_list[$v['lx']]:'',
  1986. ];
  1987. }
  1988. foreach($order_list as $k=>$v){
  1989. foreach($final_list as $kk => $vv){
  1990. if($v['id'] == $vv['fid']){
  1991. $final_list[$kk]['number'] = $v['number'];
  1992. $final_list[$kk]['pm'] = $v['pm'];
  1993. }
  1994. }
  1995. }
  1996. foreach($list_two as $k => $v){
  1997. foreach($final_list as $kk => $vv){
  1998. if(($v['fid'] == $vv['fid']) && ($v['lx'] == $vv['lx'])){
  1999. $final_list[$kk]['end_time'] = date('Y-m-d H:i:s',$v['time']);
  2000. }
  2001. }
  2002. }
  2003. $filename = date("Y-m-d")."超时单导出.xls";
  2004. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2005. <head>
  2006. <!--[if gte mso 9]><xml>
  2007. <x:ExcelWorkbook>
  2008. <x:ExcelWorksheets>
  2009. <x:ExcelWorksheet>
  2010. <x:Name>EXCEL</x:Name>
  2011. <x:WorksheetOptions>
  2012. <x:Print>
  2013. <x:ValidPrinterInfo />
  2014. </x:Print>
  2015. </x:WorksheetOptions>
  2016. </x:ExcelWorksheet>
  2017. </x:ExcelWorksheets>
  2018. </x:ExcelWorkbook>
  2019. </xml>
  2020. <![endif]-->
  2021. </head><body>";
  2022. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2023. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>入库日期</td><td>出库日期</td></tr>";
  2024. foreach ($final_list as $key=>$value)
  2025. {
  2026. if(empty($value['number'])){
  2027. continue;
  2028. }
  2029. $str .= "<tr>";
  2030. $str .= "<td>". $value['number']. "</td>";
  2031. $str .= "<td>". $value['pm']. "</td>";
  2032. $str .= "<td>". $value['lx_name']. "</td>";
  2033. $str .= "<td>". $value['start_time']. "</td>";
  2034. $str .= "<td>". $value['end_time']. "</td>";
  2035. $str .= "</tr>";
  2036. }
  2037. $str .= "</table></body></html>";
  2038. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2039. header( "Content-type: application/octet-stream" );
  2040. header( "Content-Disposition: attachment; filename=".$filename );
  2041. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2042. header( "Pragma: no-cache" );
  2043. header( "Expires: 0" );
  2044. exit($str);
  2045. }
  2046. public function _jiaji(){
  2047. $post = $this->input->post(NULL, TRUE);
  2048. if(isset($post['page']))
  2049. {
  2050. $api = $this->input->post('api',true);
  2051. $page = $this->input->post('page',true);
  2052. $perpage = $this->input->post('perpage',true);
  2053. $transfer = $this->input->post('transfer',true);
  2054. $transfer_ids = $this->input->post('transfer_ids',true);
  2055. $orver_flag = $this->input->post('orver_flag',true);
  2056. $timetk = $this->input->post('timetk',true);
  2057. $timetj = $this->input->post('timetj',true);
  2058. $timetk = strtotime($timetk);
  2059. $timetj = strtotime($timetj);
  2060. $transfer_list = $this->transfer->find_all();
  2061. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2062. if(isset($_SESSION['api']))
  2063. {
  2064. $user = $this->user->get_api($_SESSION['api']);
  2065. $transfer_ids = explode('|',trim($user['transfer'],'|'));
  2066. }
  2067. else
  2068. {
  2069. $transfer_ids = array_keys($t);
  2070. }
  2071. if(empty($page))
  2072. {
  2073. $start = 0;
  2074. $perpage = 1;
  2075. }
  2076. else
  2077. {
  2078. $start = ($page - 1)*$perpage;
  2079. }
  2080. $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." ";
  2081. if($transfer){
  2082. $sql_r .= " and c.lx = ".$transfer." ";
  2083. }else{
  2084. foreach($transfer_ids as $k=>$v){
  2085. if($v == 11){
  2086. unset($transfer_ids[$k]);
  2087. }
  2088. }
  2089. $transfer_str = implode(",",$transfer_ids);
  2090. $sql_r .= " and c.lx in (".$transfer_str.") ";
  2091. }
  2092. $sql_r .=" where s.is_jiaji = 2 and s.rk not like '%|11|%' " ;
  2093. $rows_r = $this->db->query($sql_r);
  2094. $get_list = $rows_r->result_array();
  2095. $total = count($get_list);
  2096. $split_list = array_chunk($get_list,$perpage);
  2097. $pagenum = ceil(count($split_list));
  2098. $key = $page - 1;
  2099. $list = isset($split_list[$key])?$split_list[$key]:[];
  2100. $final_list = [];
  2101. foreach ($list as $key => $value) {
  2102. $final_list[$key]['id'] = $value['id'];
  2103. $final_list[$key]['number'] = isset($value['number'])?$value['number']:'';
  2104. if($value['is_jiaji'] == 2){
  2105. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2106. }else{
  2107. $final_list[$key]['is_jiaji'] = "常规";
  2108. }
  2109. $final_list[$key]['pm'] = $value['pm'];
  2110. $final_list[$key]['shipremarks'] = $value['shipremarks'];
  2111. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2112. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2113. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2114. foreach ($data as $k=>$v)
  2115. {
  2116. $type = ($v['type']==1)?'入库':'出库';
  2117. if($v['orver_flag'] == 1){
  2118. if($v['is_over'] == 0){
  2119. $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>';
  2120. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2121. }else{
  2122. $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>';
  2123. }
  2124. }elseif($v['orver_flag'] == 2){
  2125. $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>';
  2126. }else{
  2127. $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>';
  2128. }
  2129. }
  2130. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2131. }
  2132. $over = $total-($start+$perpage);
  2133. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2134. echo json_encode($rows);exit;
  2135. }
  2136. if(isset($_SESSION['api']))
  2137. {
  2138. $user = $this->user->get_api($_SESSION['api']);
  2139. $usp = $user;
  2140. $pid = "";$tid="";$sid="";$wid="";
  2141. $purchase = explode('|',trim($user['purchase'],'|'));
  2142. $transfer = explode('|',trim($user['transfer'],'|'));
  2143. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2144. foreach ($purchase as $value)
  2145. {
  2146. $pid .= " id = ".$value." or";
  2147. }
  2148. foreach ($transfer as $value)
  2149. {
  2150. if($value){
  2151. if($value != 11){
  2152. $tid .= " id = ".$value." or";
  2153. }
  2154. }
  2155. }
  2156. foreach ($warehouse as $value)
  2157. {
  2158. $wid .= " id = ".$value." or";
  2159. }
  2160. }
  2161. else
  2162. {
  2163. header('Location: /');exit;
  2164. }
  2165. $kx = '';$zjtab = '';
  2166. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2167. $this->data['transfer'] = $transfer;
  2168. $transfer_ids = array_column($transfer, 'id');
  2169. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2170. $this->data['vip'] = $user['vip'];
  2171. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2172. $this->_Template('transfer_jiaji',$this->data);
  2173. }
  2174. public function _scz(){
  2175. $post = $this->input->post(NULL, TRUE);
  2176. if(isset($post['page']))
  2177. {
  2178. $page = $this->input->post('page',true);
  2179. $perpage = $this->input->post('perpage',true);
  2180. $transfer = $this->input->post('transfer',true);
  2181. $transfer_ids = $this->input->post('transfer_ids',true);
  2182. $timetk = $this->input->post('timetk',true);
  2183. $timetj = $this->input->post('timetj',true);
  2184. $timetk = strtotime($timetk);
  2185. $timetj = strtotime($timetj);
  2186. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2187. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2188. // $transfer_ids = array_keys($t);
  2189. if(empty($page))
  2190. {
  2191. $start = 0;
  2192. $perpage = 1;
  2193. }
  2194. else
  2195. {
  2196. $start = ($page - 1)*$perpage;
  2197. }
  2198. $where = "time > '$timetk' and time < '$timetj'";
  2199. $where .= " and rk not like '%11|' ";
  2200. if(!empty($transfer)){
  2201. $where .= " and rk like '%|".$transfer."|%' ";
  2202. }
  2203. // if($transfer)
  2204. // {
  2205. // $cr .= " and lx = '".$transfer."' ";
  2206. // }else{
  2207. // $cr .= " and lx in (".implode(",",$transfer_ids).") ";
  2208. // }
  2209. // $cr .= " and is_over = 0 ";
  2210. // $info_list_cr = $this->systemtransfer_cr->find_all($cr);
  2211. // $fid = [];
  2212. // foreach ($info_list_cr as $v)
  2213. // {
  2214. // $fid[] = $v['fid'];
  2215. // }
  2216. // if(empty($fid)){
  2217. // $rows = array('total'=>0,'over'=>0,'pagenum'=>0,'rows'=>([]));
  2218. // echo json_encode($rows);exit;
  2219. // }
  2220. // $fid = array_unique($fid);
  2221. $order_str = "id desc";
  2222. //取得信息列表
  2223. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str,$start,$perpage);
  2224. $transfer = $this->transfer->find_all();
  2225. $t = array();
  2226. foreach ($transfer as $v)
  2227. {
  2228. $t[$v['id']] = $v['title'];
  2229. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2230. }
  2231. //格式化数据
  2232. foreach ($info_list as $key=>$value)
  2233. {
  2234. if($value['is_jiaji'] == 2){
  2235. $info_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2236. }else{
  2237. $info_list[$key]['is_jiaji'] = "常规";
  2238. }
  2239. $dd = $this->systemtransfer->read($value['id']);
  2240. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2241. $rk = explode('|',trim($dd['rk'],'|'));
  2242. $rktime = explode('|',trim($dd['rktime'],'|'));
  2243. $ck = explode('|',trim($dd['ck'],'|'));
  2244. $cktime = explode('|',trim($dd['cktime'],'|'));
  2245. $info_list[$key]['time'] = '';
  2246. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2247. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2248. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2249. foreach ($data as $k=>$v)
  2250. {
  2251. // $type = ($v['type']==1)?'入库':'出库';
  2252. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2253. $type = ($v['type']==1)?'入库':'出库';
  2254. if($v['orver_flag'] == 1){
  2255. if($v['is_over'] == 0){
  2256. $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>';
  2257. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2258. }else{
  2259. $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>';
  2260. }
  2261. }elseif($v['orver_flag'] == 2){
  2262. $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>';
  2263. }elseif($v['orver_flag'] == 3){
  2264. $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>';
  2265. }else{
  2266. $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>';
  2267. }
  2268. }
  2269. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2270. unset($info_list[$key]['ctime12']);
  2271. }
  2272. $total = $this->systemtransfer->find_count($where);
  2273. $pagenum = ceil($total/$perpage);
  2274. $over = $total-($start+$perpage);
  2275. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2276. echo json_encode($rows);exit;
  2277. }
  2278. if(isset($_SESSION['api']))
  2279. {
  2280. $user = $this->user->get_api($_SESSION['api']);
  2281. if(!in_array($user['id'],[10,44,50])){
  2282. exit('No direct script access allowed');
  2283. }
  2284. }
  2285. else
  2286. {
  2287. header('Location: /');exit;
  2288. }
  2289. $kx = '';$zjtab = '';
  2290. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2291. $this->data['transfer'] = $transfer;
  2292. $transfer_ids = array_column($transfer, 'id');
  2293. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2294. $this->_Template('transfer_scz',$this->data);
  2295. }
  2296. public function _sczexcel(){
  2297. $timetk = $this->input->get('timetk',true);
  2298. $timetj = $this->input->get('timetj',true);
  2299. $timetk = strtotime($timetk);
  2300. $timetj = strtotime($timetj);
  2301. // $transfer_list = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2302. // $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2303. // $transfer_ids = array_keys($t);
  2304. $where = "time > '$timetk' and time < '$timetj'";
  2305. $where .= " and rk not like '%11|' ";
  2306. if(!empty($transfer)){
  2307. $where .= " and rk like '%|".$transfer."|%' ";
  2308. }
  2309. $order_str = "id desc";
  2310. //取得信息列表
  2311. $info_list = $this->systemtransfer->find_all($where,'id,number,is_jiaji,pm,shipremarks,printtime,time,ctime12',$order_str);
  2312. $transfer = $this->transfer->find_all();
  2313. $t = array();
  2314. foreach ($transfer as $v)
  2315. {
  2316. $t[$v['id']] = $v['title'];
  2317. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  2318. }
  2319. //格式化数据
  2320. foreach ($info_list as $key=>$value)
  2321. {
  2322. if($value['is_jiaji'] == 2){
  2323. $info_list[$key]['is_jiaji'] = "<span style='color:red'>加急</span>";
  2324. }else{
  2325. $info_list[$key]['is_jiaji'] = "常规";
  2326. }
  2327. $dd = $this->systemtransfer->read($value['id']);
  2328. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  2329. $rk = explode('|',trim($dd['rk'],'|'));
  2330. $rktime = explode('|',trim($dd['rktime'],'|'));
  2331. $ck = explode('|',trim($dd['ck'],'|'));
  2332. $cktime = explode('|',trim($dd['cktime'],'|'));
  2333. $info_list[$key]['time'] = '';
  2334. $data = $this->systemtransfer_cr->find_all("fid = '".$value['id']."'");
  2335. //$info_list[$key]['time'] = "订单出库 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  2336. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$value['ctime12']).'<br>';
  2337. foreach ($data as $k=>$v)
  2338. {
  2339. // $type = ($v['type']==1)?'入库':'出库';
  2340. // $info_list[$key]['time'] .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  2341. $type = ($v['type']==1)?'入库':'出库';
  2342. if($v['orver_flag'] == 1){
  2343. if($v['is_over'] == 0){
  2344. $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>';
  2345. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2346. }else{
  2347. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2348. }
  2349. }elseif($v['orver_flag'] == 2){
  2350. $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>';
  2351. }elseif($v['orver_flag'] == 3){
  2352. $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>';
  2353. }else{
  2354. $info_list[$key]['time'] .= "<span style='color:#000'>".$t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']) ."</span>".'<br>';
  2355. }
  2356. }
  2357. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2358. unset($info_list[$key]['ctime12']);
  2359. }
  2360. $filename = date("Y-m-d")."生产中订单.xls";
  2361. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2362. <head>
  2363. <!--[if gte mso 9]><xml>
  2364. <x:ExcelWorkbook>
  2365. <x:ExcelWorksheets>
  2366. <x:ExcelWorksheet>
  2367. <x:Name>EXCEL</x:Name>
  2368. <x:WorksheetOptions>
  2369. <x:Print>
  2370. <x:ValidPrinterInfo />
  2371. </x:Print>
  2372. </x:WorksheetOptions>
  2373. </x:ExcelWorksheet>
  2374. </x:ExcelWorksheets>
  2375. </x:ExcelWorkbook>
  2376. </xml>
  2377. <![endif]-->
  2378. </head><body>";
  2379. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2380. $str .= "<tr><td>订单编号</td><td>加急</td><td>品名</td><td>备注</td><td>打印时间</td><td>操作</td></tr>";
  2381. foreach ($info_list as $key=>$value)
  2382. {
  2383. $str .= "<tr>";
  2384. $str .= "<td>". $value['number']. "</td>";
  2385. $str .= "<td>". $value['is_jiaji']. "</td>";
  2386. $str .= "<td>". $value['pm']. "</td>";
  2387. $str .= "<td>". $value['shipremarks']. "</td>";
  2388. $str .= "<td>". $value['printtime']. "</td>";
  2389. $str .= "<td>". $value['time']. "</td>";
  2390. $str .= "</tr>";
  2391. }
  2392. $str .= "</table></body></html>";
  2393. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2394. header( "Content-type: application/octet-stream" );
  2395. header( "Content-Disposition: attachment; filename=".$filename );
  2396. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2397. header( "Pragma: no-cache" );
  2398. header( "Expires: 0" );
  2399. exit($str);
  2400. }
  2401. public function _wjsrk(){
  2402. $post = $this->input->post(NULL, TRUE);
  2403. if(isset($post['page']))
  2404. {
  2405. $api = $this->input->post('api',true);
  2406. $page = $this->input->post('page',true);
  2407. $perpage = $this->input->post('perpage',true);
  2408. $transfer = $this->input->post('transfer',true);
  2409. $transfer_ids = $this->input->post('transfer_ids',true);
  2410. $orver_flag = $this->input->post('orver_flag',true);
  2411. $timetk = $this->input->post('timetk',true);
  2412. $timetj = $this->input->post('timetj',true);
  2413. $timetk = strtotime($timetk);
  2414. $timetj = strtotime($timetj);
  2415. $transfer_list = $this->transfer->find_all();
  2416. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2417. $where = 'extra_status in (1,2) ';
  2418. //数据排序
  2419. $order_str = "id desc";
  2420. if(empty($page))
  2421. {
  2422. $start = 0;
  2423. $perpage = 1;
  2424. }
  2425. else
  2426. {
  2427. $start = ($page - 1)*$perpage;
  2428. }
  2429. if($transfer){
  2430. $where .= " and lx = '$transfer'";
  2431. }else{
  2432. $where .= " and lx in (".$transfer_ids.") ";
  2433. }
  2434. $where .= " and time > '$timetk' and time < '$timetj'";
  2435. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2436. $final_list = [];
  2437. foreach ($list as $key => $value) {
  2438. $info = $this->systemtransfer->read($value['fid']);
  2439. $final_list[$key]['id'] = $value['id'];
  2440. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2441. if($info['is_jiaji'] == 2){
  2442. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2443. }else{
  2444. $final_list[$key]['is_jiaji'] = "常规";
  2445. }
  2446. $final_list[$key]['pm'] = $info['pm'];
  2447. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2448. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2449. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2450. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2451. foreach ($data as $k=>$v)
  2452. {
  2453. $type = ($v['type']==1)?'入库':'出库';
  2454. if($v['orver_flag'] == 1){
  2455. if($v['is_over'] == 0){
  2456. $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>";
  2457. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2458. }else{
  2459. $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>";
  2460. }
  2461. }elseif($v['orver_flag'] == 2){
  2462. $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>";
  2463. }else{
  2464. $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>";
  2465. }
  2466. if($v['extra_status'] == 1){
  2467. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2468. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2469. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2470. }else{
  2471. $info_list[$key]['time'] .= "<br>";
  2472. }
  2473. }
  2474. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2475. }
  2476. $total = $this->systemtransfer_cr->find_count($where);
  2477. $pagenum = ceil($total/$perpage);
  2478. $over = $total-($start+$perpage);
  2479. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2480. echo json_encode($rows);exit;
  2481. }
  2482. if(isset($_SESSION['api']))
  2483. {
  2484. $user = $this->user->get_api($_SESSION['api']);
  2485. $usp = $user;
  2486. $pid = "";$tid="";$sid="";$wid="";
  2487. $purchase = explode('|',trim($user['purchase'],'|'));
  2488. $transfer = explode('|',trim($user['transfer'],'|'));
  2489. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2490. foreach ($purchase as $value)
  2491. {
  2492. $pid .= " id = ".$value." or";
  2493. }
  2494. foreach ($transfer as $value)
  2495. {
  2496. $tid .= " id = ".$value." or";
  2497. }
  2498. foreach ($warehouse as $value)
  2499. {
  2500. $wid .= " id = ".$value." or";
  2501. }
  2502. }
  2503. else
  2504. {
  2505. header('Location: /');exit;
  2506. }
  2507. $kx = '';$zjtab = '';
  2508. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2509. $this->data['transfer'] = $transfer;
  2510. $transfer_ids = array_column($transfer, 'id');
  2511. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2512. $this->data['vip'] = $user['vip'];
  2513. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2514. $this->_Template('transfer_wjsrk',$this->data);
  2515. }
  2516. public function _wjsrkexcel(){
  2517. $api = $this->input->get('api',true);
  2518. $transfer = $this->input->get('transfer',true);
  2519. $timetk = $this->input->get('timetk',true);
  2520. $timetj = $this->input->get('timetj',true);
  2521. $timetk = strtotime($timetk);
  2522. $timetj = strtotime($timetj);
  2523. $transfer_list = $this->transfer->find_all();
  2524. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2525. $where = 'extra_status in (1,2) ';
  2526. //数据排序
  2527. $order_str = "id desc";
  2528. if($transfer){
  2529. $where .= " and lx = '$transfer'";
  2530. }else{
  2531. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2532. $transfer_ids = array_column($transfer, 'id');
  2533. $transfer_ids = implode(",",$transfer_ids);
  2534. $where .= " and lx in (".$transfer_ids.") ";
  2535. }
  2536. $where .= " and time > '$timetk' and time < '$timetj'";
  2537. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2538. $final_list = [];
  2539. foreach ($list as $key => $value) {
  2540. $info = $this->systemtransfer->read($value['fid']);
  2541. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2542. $final_list[$key]['pm'] = $info['pm'];
  2543. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2544. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2545. }
  2546. $filename = date("Y-m-d")."超期未流转单导出.xls";
  2547. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2548. <head>
  2549. <!--[if gte mso 9]><xml>
  2550. <x:ExcelWorkbook>
  2551. <x:ExcelWorksheets>
  2552. <x:ExcelWorksheet>
  2553. <x:Name>EXCEL</x:Name>
  2554. <x:WorksheetOptions>
  2555. <x:Print>
  2556. <x:ValidPrinterInfo />
  2557. </x:Print>
  2558. </x:WorksheetOptions>
  2559. </x:ExcelWorksheet>
  2560. </x:ExcelWorksheets>
  2561. </x:ExcelWorkbook>
  2562. </xml>
  2563. <![endif]-->
  2564. </head><body>";
  2565. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2566. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2567. foreach ($final_list as $key=>$value)
  2568. {
  2569. if(empty($value['number'])){
  2570. continue;
  2571. }
  2572. $str .= "<tr>";
  2573. $str .= "<td>". $value['number']. "</td>";
  2574. $str .= "<td>". $value['pm']. "</td>";
  2575. $str .= "<td>". $value['lx_name']. "</td>";
  2576. $str .= "<td>". $value['time']. "</td>";
  2577. $str .= "</tr>";
  2578. }
  2579. $str .= "</table></body></html>";
  2580. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2581. header( "Content-type: application/octet-stream" );
  2582. header( "Content-Disposition: attachment; filename=".$filename );
  2583. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2584. header( "Pragma: no-cache" );
  2585. header( "Expires: 0" );
  2586. exit($str);
  2587. }
  2588. public function _cqrk(){
  2589. $post = $this->input->post(NULL, TRUE);
  2590. if(isset($post['page']))
  2591. {
  2592. $api = $this->input->post('api',true);
  2593. $page = $this->input->post('page',true);
  2594. $perpage = $this->input->post('perpage',true);
  2595. $transfer = $this->input->post('transfer',true);
  2596. $transfer_ids = $this->input->post('transfer_ids',true);
  2597. $orver_flag = $this->input->post('orver_flag',true);
  2598. $timetk = $this->input->post('timetk',true);
  2599. $timetj = $this->input->post('timetj',true);
  2600. $timetk = strtotime($timetk);
  2601. $timetj = strtotime($timetj);
  2602. $transfer_list = $this->transfer->find_all();
  2603. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2604. $where = 'extra_status in (2,3) ';
  2605. //数据排序
  2606. $order_str = "id desc";
  2607. if(empty($page))
  2608. {
  2609. $start = 0;
  2610. $perpage = 1;
  2611. }
  2612. else
  2613. {
  2614. $start = ($page - 1)*$perpage;
  2615. }
  2616. if($transfer){
  2617. $where .= " and lx = '$transfer'";
  2618. }else{
  2619. $where .= " and lx in (".$transfer_ids.") ";
  2620. }
  2621. $where .= " and time > '$timetk' and time < '$timetj'";
  2622. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str,$start,$perpage);
  2623. $final_list = [];
  2624. foreach ($list as $key => $value) {
  2625. $info = $this->systemtransfer->read($value['fid']);
  2626. $final_list[$key]['id'] = $value['id'];
  2627. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2628. if($info['is_jiaji'] == 2){
  2629. $final_list[$key]['is_jiaji'] = "<a href='javascript:void(0)' style='color:red'>加急</a>";
  2630. }else{
  2631. $final_list[$key]['is_jiaji'] = "常规";
  2632. }
  2633. $final_list[$key]['pm'] = $info['pm'];
  2634. $final_list[$key]['shipremarks'] = $info['shipremarks'];
  2635. $final_list[$key]['printtime'] = date('Y-m-d H:i:s',$info['printtime']);
  2636. $data = $this->systemtransfer_cr->find_all("fid = '".$info['id']."'");
  2637. $info_list[$key]['time'] = "布标打印 :".date('Y-m-d H:i',$info['ctime12']).'<br>';
  2638. foreach ($data as $k=>$v)
  2639. {
  2640. $type = ($v['type']==1)?'入库':'出库';
  2641. if($v['orver_flag'] == 1){
  2642. if($v['is_over'] == 0){
  2643. $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>";
  2644. // $info_list[$key]['time'] .= '<i style="padding:10px;color:#90f;font-weight:bold;"> 即将超时</i>'.'<br>';
  2645. }else{
  2646. $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>";
  2647. }
  2648. }elseif($v['orver_flag'] == 2){
  2649. $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>";
  2650. }else{
  2651. $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>";
  2652. }
  2653. if($v['extra_status'] == 1){
  2654. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#90f'>【下道工序未及时入库】</a><br>";
  2655. }elseif($v['extra_status'] == 2 || $v['extra_status'] == 3){
  2656. $info_list[$key]['time'] .= "<a href='javascript:void(0);' style='color:#A52A2A'>【工序间流转超过3天】</a><br>";
  2657. }else{
  2658. $info_list[$key]['time'] .= "<br>";
  2659. }
  2660. }
  2661. $final_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  2662. }
  2663. $total = $this->systemtransfer_cr->find_count($where);
  2664. $pagenum = ceil($total/$perpage);
  2665. $over = $total-($start+$perpage);
  2666. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2667. echo json_encode($rows);exit;
  2668. }
  2669. if(isset($_SESSION['api']))
  2670. {
  2671. $user = $this->user->get_api($_SESSION['api']);
  2672. $usp = $user;
  2673. $pid = "";$tid="";$sid="";$wid="";
  2674. $purchase = explode('|',trim($user['purchase'],'|'));
  2675. $transfer = explode('|',trim($user['transfer'],'|'));
  2676. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2677. foreach ($purchase as $value)
  2678. {
  2679. $pid .= " id = ".$value." or";
  2680. }
  2681. foreach ($transfer as $value)
  2682. {
  2683. $tid .= " id = ".$value." or";
  2684. }
  2685. foreach ($warehouse as $value)
  2686. {
  2687. $wid .= " id = ".$value." or";
  2688. }
  2689. }
  2690. else
  2691. {
  2692. header('Location: /');exit;
  2693. }
  2694. $kx = '';$zjtab = '';
  2695. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2696. $this->data['transfer'] = $transfer;
  2697. $transfer_ids = array_column($transfer, 'id');
  2698. $this->data['transfer_ids'] =implode(",",$transfer_ids) ;
  2699. $this->data['vip'] = $user['vip'];
  2700. $this->data['orver_flag'] = $this->input->get('orver_flag', TRUE);
  2701. $this->_Template('transfer_cqrk',$this->data);
  2702. }
  2703. public function _cqrkexcel(){
  2704. $api = $this->input->get('api',true);
  2705. $transfer = $this->input->get('transfer',true);
  2706. $timetk = $this->input->get('timetk',true);
  2707. $timetj = $this->input->get('timetj',true);
  2708. $timetk = strtotime($timetk);
  2709. $timetj = strtotime($timetj);
  2710. $transfer_list = $this->transfer->find_all();
  2711. $t = $transfer_list = array_column($transfer_list, 'title', 'id');
  2712. $where = 'extra_status in (2,3) ';
  2713. //数据排序
  2714. $order_str = "id desc";
  2715. if($transfer){
  2716. $where .= " and lx = '$transfer'";
  2717. }else{
  2718. $transfer = $this->transfer->find_all('id not in (8,9,11,12,15,16)');
  2719. $transfer_ids = array_column($transfer, 'id');
  2720. $transfer_ids = implode(",",$transfer_ids);
  2721. $where .= " and lx in (".$transfer_ids.") ";
  2722. }
  2723. $where .= " and time > '$timetk' and time < '$timetj'";
  2724. $list = $this->systemtransfer_cr->find_all($where,'*',$order_str);
  2725. $final_list = [];
  2726. foreach ($list as $key => $value) {
  2727. $info = $this->systemtransfer->read($value['fid']);
  2728. $final_list[$key]['number'] = isset($info['number'])?$info['number']:'';
  2729. $final_list[$key]['pm'] = $info['pm'];
  2730. $final_list[$key]['lx_name'] = isset($transfer_list[$value['lx']])?$transfer_list[$value['lx']]:'';
  2731. $final_list[$key]['time'] = date('Y-m-d H:i:s',$info['time']);
  2732. }
  2733. $filename = date("Y-m-d")."超期3天未流转单导出.xls";
  2734. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2735. <head>
  2736. <!--[if gte mso 9]><xml>
  2737. <x:ExcelWorkbook>
  2738. <x:ExcelWorksheets>
  2739. <x:ExcelWorksheet>
  2740. <x:Name>EXCEL</x:Name>
  2741. <x:WorksheetOptions>
  2742. <x:Print>
  2743. <x:ValidPrinterInfo />
  2744. </x:Print>
  2745. </x:WorksheetOptions>
  2746. </x:ExcelWorksheet>
  2747. </x:ExcelWorksheets>
  2748. </x:ExcelWorkbook>
  2749. </xml>
  2750. <![endif]-->
  2751. </head><body>";
  2752. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2753. $str .= "<tr><td>订单编号</td><td>品名</td><td>车间</td><td>扫出日期</td></tr>";
  2754. foreach ($final_list as $key=>$value)
  2755. {
  2756. if(empty($value['number'])){
  2757. continue;
  2758. }
  2759. $str .= "<tr>";
  2760. $str .= "<td>". $value['number']. "</td>";
  2761. $str .= "<td>". $value['pm']. "</td>";
  2762. $str .= "<td>". $value['lx_name']. "</td>";
  2763. $str .= "<td>". $value['time']. "</td>";
  2764. $str .= "</tr>";
  2765. }
  2766. $str .= "</table></body></html>";
  2767. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2768. header( "Content-type: application/octet-stream" );
  2769. header( "Content-Disposition: attachment; filename=".$filename );
  2770. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2771. header( "Pragma: no-cache" );
  2772. header( "Expires: 0" );
  2773. exit($str);
  2774. }
  2775. }