Transfer.php 114 KB

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