Transfer.php 101 KB

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