Transfer.php 102 KB

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