Transfer.php 100 KB

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