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