Transfer.php 114 KB

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