Transfer.php 98 KB

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