Transfer.php 98 KB

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