Transfer.php 101 KB

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