Transfer.php 110 KB

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