Transfer.php 98 KB

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