Whlabel_bh.php 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel_bh extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_whlabel_bh_list','whlabel_bh_list');
  36. $this->load->_model('Model_whlabel','whlabel');
  37. $this->load->_model('Model_whlabel_bh_transfer','whlabel_bh_transfer');
  38. $this->load->_model('Model_transfer','transfer');
  39. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  40. $this->load->_model("Model_logic_ding","logic_ding");
  41. $this->load->_model("Model_apiyyv1","apiyyv1");
  42. $this->load->_model('Model_settingtest','settingtest');
  43. $this->load->_model("Model_whlabel_bh_transfer_cr","whlabel_bh_transfer_cr");
  44. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg,$arg_array)
  48. {
  49. if($arg == 'add')
  50. {
  51. $this->_add();
  52. }
  53. else if($arg == 'edit')
  54. {
  55. $this->_edit($arg_array);
  56. }
  57. else if($arg == 'del')//删除
  58. {
  59. $this->_del();
  60. }
  61. else if($arg == 'deltransfer')//删除
  62. {
  63. $this->_deltransfer();
  64. }
  65. else if($arg == 'cz')//删除
  66. {
  67. $this->_cz();
  68. }
  69. else if($arg == 'db')//删除
  70. {
  71. $this->_db();
  72. }
  73. else if($arg == 'kc')//删除
  74. {
  75. $this->_kc();
  76. }
  77. else if($arg == 'excel')//删除
  78. {
  79. $this->_excel();
  80. }
  81. else if($arg == 'xxpl')//删除
  82. {
  83. $this->_xxpl();
  84. }
  85. else if($arg == 'bbprint')//删除
  86. {
  87. $this->_bbprint();
  88. }
  89. else if($arg == 'operate')
  90. {
  91. $this->_operate();
  92. }
  93. else if($arg == 'out')
  94. {
  95. $this->_out();
  96. }
  97. else if($arg == 'bdbb')
  98. {
  99. $this->_bdbb();
  100. }
  101. else if($arg == 'rk')
  102. {
  103. $this->_rk();
  104. }
  105. else if($arg == 'ck')
  106. {
  107. $this->_ck();
  108. }
  109. else if($arg == 'ck')
  110. {
  111. $this->_ck();
  112. }
  113. else if($arg == 'transfer_log'){
  114. $this->_transfer_log();
  115. }
  116. else if($arg == 'transfer_detail'){
  117. $this->_transfer_detail($arg_array);
  118. }
  119. else if($arg == 'cj_transfer_log'){
  120. $this->_cj_transfer_log();
  121. }
  122. else if($arg == 'cj_transfer_detail'){
  123. $this->_cj_transfer_detail($arg_array);
  124. }
  125. else if($arg == 'cj_transfer_log_count'){
  126. $this->_cj_transfer_log_count();
  127. }
  128. else if($arg == 'excelwchz'){
  129. $this->_excelwchz();
  130. }
  131. else
  132. {
  133. $this->_index();
  134. }
  135. }
  136. //管理
  137. public function _index()
  138. {
  139. $post = $this->input->post(NULL, TRUE);
  140. if(isset($post['page']))
  141. {
  142. $page = $this->input->post('page',true);
  143. $perpage = $this->input->post('perpage',true);
  144. $orderinfo = $this->input->post('orderinfo',true);
  145. $jm = $this->input->post('jm',true);
  146. $title = $this->input->post('title',true);
  147. $pm = $this->input->post('pm',true);
  148. $category = $this->input->post('category',true);
  149. $size = $this->input->post('size',true);
  150. $grade = $this->input->post('grade',true);
  151. $color = $this->input->post('color',true);
  152. $lowe = $this->input->post('lowe',true);
  153. $type = $this->input->post('type',true);
  154. $shipremarks = $this->input->post('shipremarks',true);
  155. $type = $this->input->post('type',true);
  156. $state = $this->input->post('state',true);
  157. $timetk = $this->input->post('timetk',true);
  158. $timetj = $this->input->post('timetj',true);
  159. $timetk = strtotime($timetk);
  160. $timetj = strtotime($timetj);
  161. $where = "1=1 ";
  162. if($timetk && $timetj)
  163. {
  164. $where .= " and time > '$timetk' and time < '$timetj'";
  165. }
  166. if($orderinfo)
  167. {
  168. $where .= " and orderinfo like '%$orderinfo%'";
  169. }
  170. if($type != '')
  171. {
  172. $where .= " and type = '$type'";
  173. }
  174. if($jm)
  175. {
  176. $where .= " and jm like '%$jm%'";
  177. }
  178. if($title)
  179. {
  180. $where .= " and title like '%$title%'";
  181. }
  182. if($pm)
  183. {
  184. $where .= " and pm like '%$pm%'";
  185. }
  186. if($category)
  187. {
  188. $where .= " and shipremarks like '%-$category-%'";
  189. }
  190. if($size)
  191. {
  192. $where .= " and shipremarks like '%-$size-%'";
  193. }
  194. if($grade)
  195. {
  196. $where .= " and shipremarks like '%-$grade-%'";
  197. }
  198. if($color)
  199. {
  200. $where .= " and shipremarks like '%-$color-%'";
  201. }
  202. if($lowe)
  203. {
  204. $where .= " and shipremarks like '%-$lowe-%'";
  205. }
  206. if($type)
  207. {
  208. $where .= " and type = '$type'";
  209. }
  210. if($state)
  211. {
  212. $where .= " and state = '$state'";
  213. }
  214. if($shipremarks)
  215. {
  216. $where .= " and shipremarks like '%$shipremarks%'";
  217. }
  218. //数据排序
  219. $order_str = "time desc";
  220. if(empty($page))
  221. {
  222. $start = 0;
  223. $perpage = 1;
  224. }
  225. else
  226. {
  227. $start = ($page - 1)*$perpage;
  228. }
  229. $warehouse = $this->warehouse->find_all();
  230. $ck = array();
  231. foreach ($warehouse as $v)
  232. {
  233. $ck[$v['id']] = $v['title'];
  234. }
  235. //取得信息列表
  236. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,printsl,time,extra_type',$order_str,$start,$perpage);
  237. foreach ($info_list as $key=>$value)
  238. {
  239. $d = $this->whlabel_bh->read($value['id']);
  240. $info_list[$key]['title'] = "<font data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>".$d['jm'].'</font><br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  241. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
  242. $printnum = array_sum(array_column($printnum,'ts'));
  243. $info_list[$key]['printnum'] = $printnum;
  244. $info_list[$key]['num'] = $value['bhnum']-$printnum;
  245. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  246. if($value['extra_type'] == 1){
  247. $info_list[$key]['extra_type'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
  248. }else{
  249. $info_list[$key]['extra_type'] = "";
  250. }
  251. }
  252. $total = $this->whlabel_bh->find_count($where);
  253. $pagenum = ceil($total/$perpage);
  254. $over = $total-($start+$perpage);
  255. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  256. echo json_encode($rows);exit;
  257. /**
  258. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,kcnum,num,rknum,dbnum,state,time,scapi,dbapi',$order_str,$start,$perpage);
  259. foreach ($info_list as $key=>$value)
  260. {
  261. $d = $this->whlabel_bh->read($value['id']);
  262. if($d['print'] == 0)
  263. {
  264. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #2ca8a1;'>未打印</span></p>";
  265. }
  266. else
  267. {
  268. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #999;'>已打印</span></p>";
  269. }
  270. if($value['state'] == 0)
  271. {
  272. $info_list[$key]['state'] = "<p>待生产/外购</p><p><span data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>传输料号</span></p>";//开 始
  273. }
  274. else if($value['state'] == 1)
  275. {
  276. $info_list[$key]['state'] = "<p>生产/外购中</p><p><span data-id='".$value['id']."' data-cz='1' class='whlabel_bh_ks'>完成入库</span></p>".$print;
  277. }
  278. else if($value['state'] == 2)
  279. {
  280. $info_list[$key]['state'] = "<p>已完成</p><p>已全部入库</p>";
  281. }
  282. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  283. $info_list[$key]['title'] = $d['jm'].'<br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  284. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  285. $zc = '';
  286. foreach ($zd as $v)
  287. {
  288. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  289. }
  290. $info_list[$key]['scapi'] = $zc;
  291. $info_list[$key]['dbapi'] = "<span data-id='".$value['id']."' class='whlabel_bh_db'>调拨出库</span>";
  292. $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  293. }
  294. **/
  295. }
  296. if(isset($_SESSION['api']))
  297. {
  298. $user = $this->user->get_api($_SESSION['api']);
  299. }
  300. else
  301. {
  302. header('Location: /');exit;
  303. }
  304. $w = $this->shop->find_all("yyid != ''");
  305. $this->data['yyck'] = $w;
  306. if($user['userid'] == 'ch')
  307. {
  308. $user['vip'] = 1;
  309. }
  310. $this->data['vip'] = $user['vip'];
  311. $this->_Template('whlabel_bh',$this->data);
  312. }
  313. //入库操作
  314. public function _add()
  315. {
  316. $tc = $this->typeclass->find_all();
  317. $typeclass = array();
  318. foreach ($tc as $v)
  319. {
  320. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  321. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  322. }
  323. $post = $this->input->post(NULL, TRUE);
  324. if(isset($post['num']))
  325. {
  326. $list = array();
  327. $sku = $this->input->post('sku',true);
  328. $category = $this->input->post('category',true);
  329. $list['category'] = $category;
  330. $list['hairtype'] = $this->input->post('hairtype',true);
  331. $list['grade'] = $this->input->post('grade',true);
  332. $size = $this->input->post('size',true);
  333. $xzsku = $this->input->post('xzsku',true);
  334. $list['size'] = rtrim($size,',');
  335. $list['hairnumber'] = $this->input->post('hairnumber',true);
  336. $list['extension'] = $this->input->post('extension',true);
  337. if($category == 1297)
  338. {
  339. $list['sywignumber'] = $this->input->post('sywignumber',true);
  340. }
  341. if($category == 1702)
  342. {
  343. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  344. $list['syother'] = $this->input->post('syother',true);
  345. }
  346. if($category == 133)
  347. {
  348. $list['fittype'] = $this->input->post('fittype',true);
  349. $list['acother'] = $this->input->post('acother',true);
  350. }
  351. $list['color'] = $this->input->post('color',true);
  352. $list['lowe'] = $this->input->post('lowe',true);
  353. if($category == 127)
  354. {
  355. $list['type'] = $this->input->post('type',true);
  356. $list['headroad'] = $this->input->post('headroad',true);
  357. $list['density'] = $this->input->post('density',true);
  358. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  359. {
  360. $list['lacesize'] = $this->input->post('lacesize',true);
  361. }
  362. $list['lacecolor'] = $this->input->post('lacecolor',true);
  363. $list['lacetypes'] = $this->input->post('lacetypes',true);
  364. }
  365. if($category == 128)
  366. {
  367. $list['lacetype'] = $this->input->post('lacetype',true);
  368. $list['haircap'] = $this->input->post('haircap',true);
  369. $list['density'] = $this->input->post('density',true);
  370. $list['lacecolor'] = $this->input->post('lacecolor',true);
  371. $list['lacetypes'] = $this->input->post('lacetypes',true);
  372. $list['wigother'] = $this->input->post('wigother',true);
  373. $list['wigother1'] = $this->input->post('wigother1',true);
  374. $list['wigother2'] = $this->input->post('wigother2',true);
  375. }
  376. if($category == 129)
  377. {
  378. $list['wide'] = $this->input->post('wide',true);
  379. }
  380. if($category == 131)
  381. {
  382. $list['gifttype'] = $this->input->post('gifttype',true);
  383. $list['giftother'] = $this->input->post('giftother',true);
  384. }
  385. if($category == 134)
  386. {
  387. $list['pieceweight'] = $this->input->post('pieceweight',true);
  388. }
  389. if($category == 1297)
  390. {
  391. $list['synthetictype'] = $this->input->post('synthetictype',true);
  392. $list['sywigother'] = $this->input->post('sywigother',true);
  393. }
  394. if($category == 130 || $category == 133 || $category == 1702)
  395. {
  396. $list['items'] = $this->input->post('items',true);
  397. $list['weight'] = $this->input->post('weight',true);
  398. }
  399. if($category == 1702)
  400. {
  401. $list['syhairther'] = $this->input->post('syhairther',true);
  402. }
  403. $classid = $this->classid->sku();
  404. $pm = $classid;
  405. $jm = $classid;
  406. $sku = $sku;
  407. $title = '';$features = '';$cs = array();
  408. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  409. foreach($list as $k=>$v)
  410. {
  411. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  412. {
  413. if($typeclass[$v]['bm'] != '')
  414. {
  415. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  416. }
  417. }
  418. if($v != 0)
  419. {
  420. if($k != 'size')
  421. {
  422. $title .= $typeclass[$v]['title']." ";
  423. }
  424. $features .=$v.'-';
  425. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  426. if(isset($pm[$typeclass[$v]['classid']]))
  427. {
  428. if($typeclass[$v]['title'] == '9A')
  429. {
  430. $pm[$typeclass[$v]['classid']] = '9A';
  431. }
  432. else if($typeclass[$v]['title'] == '10A')
  433. {
  434. $pm[$typeclass[$v]['classid']] = '10A';
  435. }
  436. else
  437. {
  438. $clzh = $typeclass[$v]['zh'];
  439. if(stripos($typeclass[$v]['zh'],'|') !== false)
  440. {
  441. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  442. $clzh = $clzh[0];
  443. }
  444. $pm[$typeclass[$v]['classid']] = $clzh;
  445. }
  446. }
  447. if(isset($jm[$typeclass[$v]['classid']]))
  448. {
  449. if($typeclass[$v]['jm'])
  450. {
  451. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  452. }
  453. }
  454. }
  455. }
  456. $jm = array_filter($jm);//去除空值
  457. $jm = implode("-",$jm);
  458. $sku = array_filter($sku);//去除空值
  459. $sku = implode("-",$sku);
  460. $pm = array_filter($pm);//去除空值
  461. $pm = implode(" ",$pm);
  462. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  463. if($list['size'])
  464. {
  465. $typeclass = $this->typeclass->read($list['size']);
  466. $title .= $typeclass['title'];
  467. }
  468. $title = trim($title,' ');
  469. $post['num'] = $this->input->post('num',true);
  470. $ztime = $this->input->post('ztime',true);
  471. $post['ztime'] = strtotime($ztime);
  472. $post['bm'] = '03'.implode("",$bmpx);
  473. $post['jm'] = $jm;
  474. $post['sku'] = $sku;
  475. $post['pm'] = $pm;
  476. $post['title'] = $title;
  477. $post['features'] = '-'.$features;
  478. $post['number'] = date('YmdHis',time()).rand(1000,9999);
  479. if(!$post['num'])
  480. {
  481. $post['number'] = date("YmdHis").rand(1000,9999);
  482. }
  483. $time = time();
  484. $post['time'] = $time;//操作时间
  485. $post['printnum'] = $time;
  486. $post['type'] = 0;
  487. $post['extra_type'] = (int)trim($post['extra_type'],',');
  488. //传输料号开始
  489. $lc = 0;
  490. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  491. if(isset($lh['Data'][0]))
  492. {
  493. if($lh['Data'][0]['m_isSucess'] != 1)
  494. {
  495. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  496. {
  497. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
  498. }
  499. }
  500. }
  501. else
  502. {
  503. echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit;
  504. }
  505. if($this->whlabel_bh->insert($post))
  506. {
  507. echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
  508. }
  509. else
  510. {
  511. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  512. }
  513. }
  514. $w = $this->shop->find_all("yyid != ''");
  515. $this->data['yyck'] = $w;
  516. $purchase = $this->purchase->find_all("yyid != ''");
  517. $this->data['purchase'] = $purchase;
  518. $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
  519. $this->_Template('whlabel_bh_add',$this->data);
  520. }
  521. public function get_cjlp($data)//创建料品
  522. {
  523. $list["0"]["Code"] = $data['jm'];//料号,SKU
  524. $list["0"]["Code1"] = '';
  525. $list["0"]["Name"] = $data['zh'];//产品名称
  526. $list["0"]["MainItemCategory"]["Code"] = $data['bm'];
  527. $list["0"]["Org"]["Code"] = 001;
  528. $list["0"]["OtherID"] = 1;
  529. $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1;
  530. $list["0"]["PurchaseInfo"]["PriceSource"] = 2;
  531. $list["0"]["PurchaseInfo"]["InquireRule"] = -1;
  532. $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0;
  533. $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1;
  534. $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true;
  535. $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true;
  536. $list["0"]["InventoryUOM"]["Code"] = '条';
  537. $list["0"]["InventorySecondUOM"]["Code"] = '';
  538. $list["0"]["IsDualUOM"] = false;
  539. $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4;
  540. $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1;
  541. $list["0"]["InventoryInfo"]["TurnOverRate"] = 1;
  542. $list["0"]["InventoryInfo"]["ReserveMode"] = -1;
  543. $list["0"]["InventoryInfo"]["SupplyMethod"] = -1;
  544. $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01;
  545. $list["0"]["DescFlexField"]["PubDescSeg5"] = 01;
  546. $list["0"]["Description"] = $data['title'];
  547. $list["0"]["ItemForm"] = 2001;
  548. $list["0"]["ItemFormAttribute"] = 10;
  549. $list["0"]["IsInventoryEnable"] = true;
  550. $list["0"]["IsPurchaseEnable"] = true;
  551. $list["0"]["IsSalesEnable"] = true;
  552. $list["0"]["IsBuildEnable"] = true;
  553. $list["0"]["IsOutsideOperationEnable"] = true;
  554. $list["0"]["IsMRPEnable"] = true;
  555. $list["0"]["IsBOMEnable"] = true;
  556. $list["0"]["IsCostCalByGrade"] = false;
  557. $list["0"]["IsCostCalByPotency"] = false;
  558. $list["0"]["IsGradeControl"] = false;
  559. $list["0"]["StandardGrade"] = -1;
  560. $list["0"]["StartGrade"] = -1;
  561. $list["0"]["EndGrade"] = -1;
  562. $list["0"]["IsPotencyControl"] = false;
  563. $list["0"]["StandardPotency"] = -1;
  564. $list["0"]["StartPotency"] = -1;
  565. $list["0"]["EndPotency"] = -1;
  566. $asd = $list;
  567. $list = json_encode($list);
  568. $token = $this->setting->get_yytoken_130();
  569. $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create';
  570. $header[] = "Content-Type: application/json";
  571. $header[] = "Token: ".$token;
  572. $ch = curl_init();
  573. curl_setopt($ch, CURLOPT_URL, $url);
  574. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  575. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  576. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  577. curl_setopt($ch, CURLOPT_POST, 1);
  578. curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
  579. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  580. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  581. $res = curl_exec($ch);
  582. $res = json_decode($res,true);
  583. return $asd;
  584. }
  585. //修改产品
  586. public function _edit($arg_array)
  587. {
  588. $tc = $this->typeclass->find_all();
  589. $typeclass = array();
  590. foreach ($tc as $v)
  591. {
  592. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  593. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  594. }
  595. $post = $this->input->post(NULL, TRUE);
  596. if(isset($post['id']))
  597. {
  598. $id = $this->input->post('id',true);
  599. $list = array();
  600. $sku = $this->input->post('sku',true);
  601. $category = $this->input->post('category',true);
  602. $list['category'] = $category;
  603. $list['hairtype'] = $this->input->post('hairtype',true);
  604. $list['grade'] = $this->input->post('grade',true);
  605. $size = $this->input->post('size',true);
  606. $xzsku = $this->input->post('xzsku',true);
  607. $list['size'] = rtrim($size,',');
  608. $list['hairnumber'] = $this->input->post('hairnumber',true);
  609. $list['extension'] = $this->input->post('extension',true);
  610. if($category == 1297)
  611. {
  612. $list['sywignumber'] = $this->input->post('sywignumber',true);
  613. }
  614. if($category == 1702)
  615. {
  616. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  617. $list['syother'] = $this->input->post('syother',true);
  618. }
  619. if($category == 133)
  620. {
  621. $list['fittype'] = $this->input->post('fittype',true);
  622. $list['acother'] = $this->input->post('acother',true);
  623. }
  624. $list['color'] = $this->input->post('color',true);
  625. $list['lowe'] = $this->input->post('lowe',true);
  626. if($category == 127)
  627. {
  628. $list['type'] = $this->input->post('type',true);
  629. $list['headroad'] = $this->input->post('headroad',true);
  630. $list['density'] = $this->input->post('density',true);
  631. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  632. {
  633. $list['lacesize'] = $this->input->post('lacesize',true);
  634. }
  635. $list['lacecolor'] = $this->input->post('lacecolor',true);
  636. $list['lacetypes'] = $this->input->post('lacetypes',true);
  637. }
  638. if($category == 128)
  639. {
  640. $list['lacetype'] = $this->input->post('lacetype',true);
  641. $list['haircap'] = $this->input->post('haircap',true);
  642. $list['density'] = $this->input->post('density',true);
  643. $list['lacecolor'] = $this->input->post('lacecolor',true);
  644. $list['lacetypes'] = $this->input->post('lacetypes',true);
  645. $list['wigother'] = $this->input->post('wigother',true);
  646. $list['wigother1'] = $this->input->post('wigother1',true);
  647. $list['wigother2'] = $this->input->post('wigother2',true);
  648. }
  649. if($category == 129)
  650. {
  651. $list['wide'] = $this->input->post('wide',true);
  652. }
  653. if($category == 131)
  654. {
  655. $list['gifttype'] = $this->input->post('gifttype',true);
  656. $list['giftother'] = $this->input->post('giftother',true);
  657. }
  658. if($category == 134)
  659. {
  660. $list['pieceweight'] = $this->input->post('pieceweight',true);
  661. }
  662. if($category == 1297)
  663. {
  664. $list['synthetictype'] = $this->input->post('synthetictype',true);
  665. $list['sywigother'] = $this->input->post('sywigother',true);
  666. }
  667. if($category == 130 || $category == 133 || $category == 1702)
  668. {
  669. $list['items'] = $this->input->post('items',true);
  670. $list['weight'] = $this->input->post('weight',true);
  671. }
  672. if($category == 1702)
  673. {
  674. $list['syhairther'] = $this->input->post('syhairther',true);
  675. }
  676. $classid = $this->classid->sku();
  677. $pm = $classid;
  678. $jm = $classid;
  679. $sku = $sku;
  680. $title = '';$features = '';$cs = array();
  681. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  682. foreach($list as $k=>$v)
  683. {
  684. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  685. {
  686. if($typeclass[$v]['bm'] != '')
  687. {
  688. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  689. }
  690. }
  691. if($v != 0)
  692. {
  693. if($k != 'size')
  694. {
  695. $title .= $typeclass[$v]['title']." ";
  696. }
  697. $features .=$v.'-';
  698. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  699. if(isset($pm[$typeclass[$v]['classid']]))
  700. {
  701. if($typeclass[$v]['title'] == '9A')
  702. {
  703. $pm[$typeclass[$v]['classid']] = '9A';
  704. }
  705. else if($typeclass[$v]['title'] == '10A')
  706. {
  707. $pm[$typeclass[$v]['classid']] = '10A';
  708. }
  709. else
  710. {
  711. $clzh = $typeclass[$v]['zh'];
  712. if(stripos($typeclass[$v]['zh'],'|') !== false)
  713. {
  714. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  715. $clzh = $clzh[0];
  716. }
  717. $pm[$typeclass[$v]['classid']] = $clzh;
  718. }
  719. }
  720. if(isset($jm[$typeclass[$v]['classid']]))
  721. {
  722. if($typeclass[$v]['jm'])
  723. {
  724. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  725. }
  726. }
  727. }
  728. }
  729. $jm = array_filter($jm);//去除空值
  730. $jm = implode("-",$jm);
  731. $sku = array_filter($sku);//去除空值
  732. $sku = implode("-",$sku);
  733. $pm = array_filter($pm);//去除空值
  734. $pm = implode(" ",$pm);
  735. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  736. if($list['size'])
  737. {
  738. $typeclass = $this->typeclass->read($list['size']);
  739. $title .= $typeclass['title'];
  740. }
  741. $title = trim($title,' ');
  742. $post['num'] = $this->input->post('num',true);
  743. $ztime = $this->input->post('ztime',true);
  744. $post['ztime'] = strtotime($ztime);
  745. $post['bm'] = '03'.implode("",$bmpx);
  746. $post['jm'] = $jm;
  747. $post['sku'] = $sku;
  748. $post['pm'] = $pm;
  749. $post['title'] = $title;
  750. $post['features'] = '-'.$features;
  751. $ztime = $this->input->post('ztime',true);
  752. if($ztime)
  753. {
  754. $post['ztime'] = strtotime($ztime);
  755. }
  756. if($this->whlabel_bh->save($post,$id))
  757. {
  758. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  759. }
  760. else
  761. {
  762. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  763. }
  764. }
  765. $w = $this->shop->find_all("yyid != ''");
  766. $this->data['yyck'] = $w;
  767. $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
  768. $this->data['whlabel_bh'] = $whlabel_bh ;
  769. $purchase = $this->purchase->find_all("yyid != ''");
  770. $this->data['purchase'] = $purchase;
  771. $this->_Template('whlabel_bh_edit',$this->data);
  772. }
  773. public function _cz()
  774. {
  775. $post = $this->input->post(NULL, TRUE);
  776. if(isset($post['id']))
  777. {
  778. $id = $this->input->post('id',true);
  779. $cz = $this->input->post('cz',true);
  780. $num = $this->input->post('num',true);
  781. $cz = $cz+1;
  782. $w = $this->whlabel_bh->read($id);
  783. if(!$w)
  784. {
  785. echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
  786. }
  787. //传输料号开始
  788. $lc = 0;
  789. $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
  790. if(isset($lh['Data'][0]))
  791. {
  792. if($lh['Data'][0]['m_isSucess'] != 1)
  793. {
  794. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  795. {
  796. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
  797. }
  798. }
  799. }
  800. else
  801. {
  802. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  803. }
  804. echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true));
  805. /** 投产
  806. if($w['scapi'] != 99)
  807. {
  808. if($w['state'] == $cz)
  809. {
  810. echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
  811. }
  812. if($w['type'] == '0')
  813. {
  814. $type = '生产';
  815. $bhlx = 0;
  816. }
  817. else
  818. {
  819. $type = '外购';
  820. $bhlx = 1;
  821. }
  822. $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
  823. if($yy['c'] == 0)
  824. {
  825. if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
  826. {
  827. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
  828. }
  829. else
  830. {
  831. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  832. }
  833. }
  834. else
  835. {
  836. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  837. }
  838. }
  839. else if($w['dbapi'] != 99 && $w['type'] == '0')
  840. {
  841. $cz = 1;
  842. if(!is_numeric($num))
  843. {
  844. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  845. }
  846. if($num > $w['num']-$w['rknum'])
  847. {
  848. echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
  849. }
  850. if($w['rknum']+$num == $w['num'])
  851. {
  852. $dbapi = 99;
  853. $cz = 2;
  854. }
  855. else
  856. {
  857. $dbapi = 0;
  858. }
  859. $w['ts'] = $num;
  860. $rk = $this->apiyy->_newrk($w);
  861. if($rk['c'] == 0)
  862. {
  863. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
  864. {
  865. if($dbapi == 99)
  866. {
  867. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  868. }
  869. else
  870. {
  871. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  872. }
  873. }
  874. else
  875. {
  876. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  877. }
  878. }
  879. else
  880. {
  881. $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
  882. echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
  883. }
  884. }
  885. else if($w['dbapi'] != 99 && $w['type'] == '1')
  886. {
  887. $cz = 1;
  888. if(!is_numeric($num))
  889. {
  890. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  891. }
  892. if($num > $w['num']-$w['rknum'])
  893. {
  894. echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
  895. }
  896. if($w['rknum']+$num == $w['num'])
  897. {
  898. $dbapi = 99;
  899. $cz = 2;
  900. }
  901. else
  902. {
  903. $dbapi = 0;
  904. }
  905. $scid = explode('~',$w['scid']);
  906. $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
  907. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
  908. {
  909. if($dbapi == 99)
  910. {
  911. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  912. }
  913. else
  914. {
  915. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  916. }
  917. }
  918. else
  919. {
  920. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  921. }
  922. }
  923. **/
  924. }
  925. }
  926. public function _db()
  927. {
  928. $post = $this->input->post(NULL, TRUE);
  929. if(isset($post['id']))
  930. {
  931. $id = $this->input->post('id',true);
  932. $num = $this->input->post('num',true);
  933. $warehouse = $this->input->post('warehouse',true);
  934. $w = $this->warehouse->read($warehouse);
  935. $data = $this->whlabel_bh->read($id);
  936. if(!$data)
  937. {
  938. echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
  939. }
  940. $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
  941. $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
  942. if($num > $data['rknum']-$ydbnum)
  943. {
  944. echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
  945. }
  946. $data['dccbm'] = 13001;//默认从许昌仓调出
  947. $data['ts'] = $num;
  948. $data['drcbm'] = $w['yybm'];
  949. $dc = $this->apiyy->get_cpdc($data);
  950. if(isset($dc['Data'][0]))
  951. {
  952. if($dc['Data'][0]['IsSucess'] != 1)
  953. {
  954. echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
  955. }
  956. else
  957. {
  958. $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
  959. if(isset($sh['Data'][0]))
  960. {
  961. $code = $sh['Data'][0]['Code'];
  962. echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
  963. }
  964. else
  965. {
  966. $code = '';
  967. echo json_encode(array('msg'=>'调出成功!','success'=>true));
  968. }
  969. $p['uid'] = $id;
  970. $p['bm'] = $data['bm'];
  971. $p['sku'] = $data['jm'];
  972. $p['shipremarks'] = $data['shipremarks'];
  973. $p['title'] = $data['title'];
  974. $p['zh'] = $data['pm'];
  975. $p['fpdata'] = $data['features'];
  976. $p['num'] = $num;
  977. $p['warehouse'] = 13;//默认从许昌仓调出
  978. $p['rwarehouse'] = $warehouse;
  979. $p['time'] = time();//操作时间
  980. $p['code'] = $code;
  981. $this->whlabel_bh_list->insert($p);
  982. }
  983. }
  984. else
  985. {
  986. echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
  987. }
  988. }
  989. }
  990. public function _del()
  991. {
  992. $post = $this->input->post(NULL, TRUE);
  993. if(isset($post['s']))
  994. {
  995. $id_arr = $this->input->post('s');
  996. $id_arr = explode(',',trim($id_arr,','));
  997. if(!$id_arr)
  998. {
  999. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1000. }
  1001. //循环删除记录
  1002. foreach ($id_arr as $v)
  1003. {
  1004. $w = $this->whlabel_bh->read($v);
  1005. if($w['state'] > 0)
  1006. {
  1007. // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
  1008. }
  1009. }
  1010. foreach ($id_arr as $v)
  1011. {
  1012. $this->whlabel_bh->remove($v);
  1013. }
  1014. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1015. }
  1016. }
  1017. public function _deltransfer()
  1018. {
  1019. $post = $this->input->post(NULL, TRUE);
  1020. if(isset($post['s']))
  1021. {
  1022. $id_arr = $this->input->post('s');
  1023. $id_arr = explode(',',trim($id_arr,','));
  1024. if(!$id_arr)
  1025. {
  1026. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1027. }
  1028. if(count($id_arr) > 1)
  1029. {
  1030. echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
  1031. }
  1032. foreach ($id_arr as $v)
  1033. {
  1034. $this->whlabel_bh_transfer->remove($v);
  1035. }
  1036. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1037. }
  1038. }
  1039. public function _kc()
  1040. {
  1041. $post = $this->input->post(NULL, TRUE);
  1042. if(isset($post['category']))
  1043. {
  1044. $list = array();
  1045. $sku = $this->input->post('sku',true);
  1046. $features = $this->input->post('features',true);
  1047. $category = $this->input->post('category',true);
  1048. $list['category'] = $category;
  1049. $list['hairtype'] = $this->input->post('hairtype',true);
  1050. $list['grade'] = $this->input->post('grade',true);
  1051. $size = $this->input->post('size',true);
  1052. $xzsku = $this->input->post('xzsku',true);
  1053. $list['size'] = rtrim($size,',');
  1054. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1055. $list['extension'] = $this->input->post('extension',true);
  1056. if($category == 1297)
  1057. {
  1058. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1059. }
  1060. if($category == 1702)
  1061. {
  1062. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1063. $list['syother'] = $this->input->post('syother',true);
  1064. }
  1065. if($category == 133)
  1066. {
  1067. $list['fittype'] = $this->input->post('fittype',true);
  1068. $list['acother'] = $this->input->post('acother',true);
  1069. }
  1070. $list['color'] = $this->input->post('color',true);
  1071. $list['lowe'] = $this->input->post('lowe',true);
  1072. if($category == 127)
  1073. {
  1074. $list['type'] = $this->input->post('type',true);
  1075. $list['headroad'] = $this->input->post('headroad',true);
  1076. $list['density'] = $this->input->post('density',true);
  1077. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1078. {
  1079. $list['lacesize'] = $this->input->post('lacesize',true);
  1080. }
  1081. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1082. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1083. }
  1084. if($category == 128)
  1085. {
  1086. $list['lacetype'] = $this->input->post('lacetype',true);
  1087. $list['haircap'] = $this->input->post('haircap',true);
  1088. $list['density'] = $this->input->post('density',true);
  1089. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1090. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1091. $list['wigother'] = $this->input->post('wigother',true);
  1092. $list['wigother1'] = $this->input->post('wigother1',true);
  1093. $list['wigother2'] = $this->input->post('wigother2',true);
  1094. }
  1095. if($category == 129)
  1096. {
  1097. $list['wide'] = $this->input->post('wide',true);
  1098. }
  1099. if($category == 131)
  1100. {
  1101. $list['gifttype'] = $this->input->post('gifttype',true);
  1102. $list['giftother'] = $this->input->post('giftother',true);
  1103. }
  1104. if($category == 134)
  1105. {
  1106. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1107. }
  1108. if($category == 1297)
  1109. {
  1110. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1111. $list['sywigother'] = $this->input->post('sywigother',true);
  1112. }
  1113. if($category == 130 || $category == 133 || $category == 1702)
  1114. {
  1115. $list['items'] = $this->input->post('items',true);
  1116. $list['weight'] = $this->input->post('weight',true);
  1117. }
  1118. if($category == 1702)
  1119. {
  1120. $list['syhairther'] = $this->input->post('syhairther',true);
  1121. }
  1122. $shipremarks = '';
  1123. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1124. foreach($list as $k=>$v)
  1125. {
  1126. if($v != 0)
  1127. {
  1128. $shipremarks .=$v.'-';
  1129. }
  1130. }
  1131. $shipremarks = '-'.$shipremarks;
  1132. if($features)
  1133. {
  1134. $shipremarks = $features;
  1135. }
  1136. $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
  1137. if($w > 0)
  1138. {
  1139. echo json_encode(array('msg'=>$w,'success'=>true));exit;
  1140. }
  1141. else
  1142. {
  1143. echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
  1144. }
  1145. }
  1146. }
  1147. public function _excel()
  1148. {
  1149. $classid = $this->classid->sku();
  1150. $pm = $classid;
  1151. $typeclass = array();
  1152. $tc = $this->typeclass->find_all();
  1153. foreach ($tc as $v)
  1154. {
  1155. $typeclass[$v['id']] = $v;
  1156. }
  1157. $prc = array();
  1158. $purchase = $this->purchase->find_all();
  1159. foreach($purchase as $k=>$v)
  1160. {
  1161. $prc[$v['id']] = $v['title'];
  1162. }
  1163. if(isset($_GET['excel']))
  1164. {
  1165. $number = $this->input->post('number',true);
  1166. $sku = $this->input->post('sku',true);
  1167. $title = $this->input->post('title',true);
  1168. $pm = $this->input->post('pm',true);
  1169. $category = $this->input->post('category',true);
  1170. $size = $this->input->post('size',true);
  1171. $grade = $this->input->post('grade',true);
  1172. $color = $this->input->post('color',true);
  1173. $lowe = $this->input->post('lowe',true);
  1174. $state = $this->input->post('state',true);
  1175. $shipremarks = $this->input->post('shipremarks',true);
  1176. $type = $this->input->post('type',true);
  1177. $sid = $this->input->get('sid',true);
  1178. $ktime = $this->input->get('ktime',true);
  1179. $jtime = $this->input->get('jtime',true);
  1180. $ktime = strtotime($ktime);
  1181. $jtime = strtotime($jtime);
  1182. $where = "1=1";$gj = "";$ck = "";
  1183. if($number)
  1184. {
  1185. $where .= " and number like '%$number%'";
  1186. }
  1187. if($type != '')
  1188. {
  1189. $where .= " and type = '$type'";
  1190. }
  1191. if($sku)
  1192. {
  1193. $where .= " and sku like '%$sku%'";
  1194. }
  1195. if($title)
  1196. {
  1197. $where .= " and title like '%$title%'";
  1198. }
  1199. if($pm)
  1200. {
  1201. $where .= " and pm like '%$pm%'";
  1202. }
  1203. if($category)
  1204. {
  1205. $where .= " and shipremarks like '%-$category-%'";
  1206. }
  1207. if($size)
  1208. {
  1209. $where .= " and shipremarks like '%-$size-%'";
  1210. }
  1211. if($grade)
  1212. {
  1213. $where .= " and shipremarks like '%-$grade-%'";
  1214. }
  1215. if($color)
  1216. {
  1217. $where .= " and shipremarks like '%-$color-%'";
  1218. }
  1219. if($lowe)
  1220. {
  1221. $where .= " and shipremarks like '%-$lowe-%'";
  1222. }
  1223. if($state)
  1224. {
  1225. $where .= " and state = '$state'";
  1226. }
  1227. if($shipremarks)
  1228. {
  1229. $where .= " and shipremarks like '%$shipremarks%'";
  1230. }
  1231. $sidwhere = '';
  1232. if($sid)
  1233. {
  1234. $sd = "";
  1235. $s = explode(',',trim($sid,','));
  1236. foreach ($s as $value)
  1237. {
  1238. $sd .= " id = ".$value." or";
  1239. }
  1240. $sidwhere = " and (".rtrim($sd,'or').")";
  1241. }
  1242. //数据排序
  1243. $order_str = "time desc";
  1244. if(empty($page))
  1245. {
  1246. $start = 0;
  1247. $perpage = 1;
  1248. }
  1249. else
  1250. {
  1251. $start = ($page - 1)*$perpage;
  1252. }
  1253. //取得信息列表
  1254. /**
  1255. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  1256. $rows = array();$list = array();
  1257. foreach ($info_list as $key=>$value)
  1258. {
  1259. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1260. }
  1261. **/
  1262. $warehouse = $this->warehouse->find_all();
  1263. $ck = array();
  1264. foreach ($warehouse as $v)
  1265. {
  1266. $ck[$v['id']] = $v['title'];
  1267. }
  1268. $list = array();
  1269. $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
  1270. foreach ($rows as $key=>$value)
  1271. {
  1272. if($value['state'] == 0)
  1273. {
  1274. $rows[$key]['state'] = "待生产/外购";
  1275. }
  1276. else if($value['state'] == 1)
  1277. {
  1278. $rows[$key]['state'] = "生产/外购中";
  1279. }
  1280. else if($value['state'] == 2)
  1281. {
  1282. $rows[$key]['state'] = "已完成";
  1283. }
  1284. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  1285. $zc = '';
  1286. foreach ($zd as $v)
  1287. {
  1288. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  1289. }
  1290. $rows[$key]['id'] = $zc;
  1291. $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  1292. $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
  1293. $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  1294. }
  1295. $title = '备货详情';
  1296. $titlename = "<table border=1>
  1297. <tr align='center'>
  1298. <td>状态</td>
  1299. <td>标题</td>
  1300. <td>流水码</td>
  1301. <td>简码</td>
  1302. <td>英文</td>
  1303. <td>中文</td>
  1304. <td>备注</td>
  1305. <td>备货数量</td>
  1306. <td>库存数量</td>
  1307. <td>生产/外购数量</td>
  1308. <td>入库数量</td>
  1309. <td>调拨数量</td>
  1310. <td>调拨详情</td>>
  1311. <td>生产时间</td>>
  1312. <td>操作时间</td>>
  1313. </tr>
  1314. </table>";
  1315. $filename = $title.".xls";
  1316. $tail = "";
  1317. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1318. }
  1319. }
  1320. public function _xxpl()
  1321. {
  1322. /* 订单加入键值-j */
  1323. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1324. $config['upload_path'] = '.'.$dir ;
  1325. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1326. $config['allowed_types'] = 'xls|xlsx|csv';
  1327. $config['max_size'] = 10240;
  1328. $this->load->library('upload', $config);
  1329. $this->upload->initialize($config);
  1330. if ($this->upload->do_upload('userfile'))
  1331. {
  1332. $full_path = $dir.$this->upload->data('file_name');
  1333. $fileName = '.' . $full_path;
  1334. if (!file_exists($fileName))
  1335. {
  1336. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1337. }
  1338. else
  1339. {
  1340. require_once "./data/excel/PHPExcel/IOFactory.php";
  1341. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1342. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1343. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1344. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1345. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1346. ++$column;//如果列数大于26行
  1347. $list = array();
  1348. for ($i = 2; $i <= $row; $i++) // 行数循环
  1349. {
  1350. $data = array();
  1351. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1352. {
  1353. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1354. }
  1355. $list[] = $data;
  1356. }
  1357. }
  1358. $tc = $this->typeclass->find_all();
  1359. $typeclass = array();
  1360. foreach ($tc as $v)
  1361. {
  1362. $typeclass[$v['jm']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1363. }
  1364. $i = 0;$j = 0;$ed = array();
  1365. $classid = $this->classid->sku();
  1366. $typeclassid = [];
  1367. foreach($tc as $v){
  1368. $typeclassid[$v['id']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1369. }
  1370. $i = 0;$j = 0;$ed = [];
  1371. $ck = [
  1372. "成品仓"=>'99001',
  1373. "美国仓"=>'02031',
  1374. "AP"=>'0103001',
  1375. "WK"=>'0103002',
  1376. "QV"=>'0103003',
  1377. "AS"=>'0103004',
  1378. "H"=>"0103005",
  1379. "AP英"=>"0103006",
  1380. "YMS"=>"0103007",
  1381. "AP新"=>"0103008",
  1382. "WK新"=>"0103009",
  1383. "H新"=>"0103010",
  1384. "Bilisar"=>"0103011",
  1385. "Estilar"=>"0103012",
  1386. "QM"=>"0103013",
  1387. "Afola"=>"0103014",
  1388. "拼多多-Finsa"=>"0106002",
  1389. "拼多多-艾彩"=>"0105001",
  1390. "拼多多-Estilar"=>"0106001",
  1391. "拼多多-QM"=>"0106003",
  1392. ];
  1393. foreach($list as $k=>$v){
  1394. $res = $this->logic_u9tools->getGoodInfoByErpSku($v[0],$v[1],$typeclass,$typeclassid,$classid);
  1395. if($res['code']==1){
  1396. //传输料号开始
  1397. $post = $res['data'];
  1398. $post['number'] = $post['number'].$k;
  1399. $post['orderinfo'] = $v[2];
  1400. $post['num'] = $v[5];
  1401. $post['state'] = ($v[3] == '生产')?0:1;
  1402. $post['purchase'] = "";//供货商
  1403. $post['shipremarks'] = empty($v[6])?" ":$v[6];//
  1404. $post['rknum'] = 0;
  1405. $post['scapi'] = 0;
  1406. $post['dbapi'] = 0;
  1407. $post['bhnum'] = $v[5];
  1408. $post['extra_type'] = (strpos($v[2],"美国销售-") !== false)?1:0;
  1409. if(isset($ck[$v[4]])){
  1410. $post['kh'] = $ck[$v[4]];
  1411. }else{
  1412. $j++;
  1413. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1414. continue;
  1415. }
  1416. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  1417. $this->logic_ding->sendToDing("备货批量导入出现的错误信息".json_encode($lh,JSON_UNESCAPED_UNICODE));
  1418. if(isset($lh['Data'][0]))
  1419. {
  1420. if($lh['Data'][0]['m_isSucess'] != 1)
  1421. {
  1422. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1423. {
  1424. $j++;
  1425. $ed[] = array($lh['Data'][0]['m_errorMsg'],$post['jm'],$post['bm']);
  1426. }
  1427. }
  1428. }
  1429. else
  1430. {
  1431. $j++;
  1432. $ed[] = array('料号错误',$post['jm'],$post['bm']);
  1433. }
  1434. if($this->whlabel_bh->insert($post))
  1435. {
  1436. $i++;
  1437. }
  1438. else
  1439. {
  1440. $j++;
  1441. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1442. }
  1443. }else{
  1444. $j++;
  1445. $ed[] = array($res['msg'],$v[1],"");
  1446. }
  1447. }
  1448. if($j > 0)
  1449. {
  1450. $time = date('Ymd',time());
  1451. $title = '错误信息-'.$time;
  1452. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  1453. $tail = "\n";
  1454. $filename = $title.".xls";
  1455. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  1456. $dir = '/data/excel/'.$time.'/';
  1457. $file_name = 'error_'.$time.rand(1000,9999);
  1458. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  1459. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  1460. fwrite($myfile,$ecl);
  1461. fclose($myfile);
  1462. $error = $dir.$file_name.'.xls';
  1463. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  1464. }
  1465. else
  1466. {
  1467. echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
  1468. }
  1469. }
  1470. else
  1471. {
  1472. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1473. }
  1474. }
  1475. public function _cslh($jm,$title,$pm,$bm)
  1476. {
  1477. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
  1478. if(isset($lh['Data'][0]))
  1479. {
  1480. if($lh['Data'][0]['m_isSucess'] != 1)
  1481. {
  1482. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1483. {
  1484. return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
  1485. }
  1486. }
  1487. }
  1488. else
  1489. {
  1490. return array('msg'=>'料号错误','x'=>1);exit;
  1491. }
  1492. return array('x'=>2);exit;
  1493. }
  1494. public function _bbprint()
  1495. {
  1496. $time = time();
  1497. $post = $this->input->post(NULL);
  1498. if(isset($post['d']))
  1499. {
  1500. $order = 0;$time = time();
  1501. $d = $this->input->post('d',true);
  1502. $n = $this->input->post('n',true);//打印数量
  1503. $data = $this->whlabel_bh->read($d);
  1504. if(!$data)
  1505. {
  1506. echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
  1507. }
  1508. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
  1509. $printnum = array_sum(array_column($printnum,'ts'));
  1510. if(($data['bhnum'] + 1)-$printnum-$n < 0)
  1511. {
  1512. echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
  1513. }
  1514. $post['number'] = $data['number'];
  1515. $post['orderinfo'] = $data['orderinfo'];
  1516. $post['type'] = 0;//0生产 1外购
  1517. $post['features'] = $data['features'];
  1518. $post['jm'] = $data['jm'];
  1519. $post['bm'] = $data['bm'];
  1520. $post['pm'] = $data['pm'];
  1521. $post['sku'] = $data['sku'];
  1522. $post['features'] = $data['features'];
  1523. $post['number'] = $data['number'];
  1524. $post['title'] = $data['title'];
  1525. $post['printtime'] = $time;
  1526. $post['ts'] = 1;
  1527. // $post['rk'] = "";//默认订单中心 打印后直接入库
  1528. // $post['rktime'] = "";
  1529. // $post['ctime15'] = $time;
  1530. $post['time'] = $time;
  1531. $post['gtime'] = date('Yms',$time);
  1532. $post['wbid'] = $data['id'];
  1533. $rows = array();
  1534. $label = date("ymdHis").rand(1000,9999);
  1535. $post['label'] = $label;
  1536. // if($this->whlabel_bh_transfer->insert($post))
  1537. // {
  1538. // echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1539. // }
  1540. // else
  1541. // {
  1542. // $this->db->trans_rollback();
  1543. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1544. // }
  1545. if(stripos($post['features'],'-126-') !== false)
  1546. {
  1547. $drck = '12003';//进入发条库
  1548. }
  1549. else if(stripos($post['features'],'-127-') !== false)
  1550. {
  1551. $drck = '12004';//进入发块库
  1552. }
  1553. else
  1554. {
  1555. $drck = '12006';//其它进入完成库
  1556. }
  1557. //创建u9的生产单
  1558. $token = $this->settingtest->get_yytoken_120();
  1559. $params = [
  1560. 'org_code'=>"120",
  1561. 'djhlx'=>'2000',
  1562. 'scbm_code'=>"12008",
  1563. "time"=>time(),
  1564. 'owner_org_code'=>"120",
  1565. 'title'=>$post['orderinfo'],
  1566. 'shipremarks'=>$data['shipremarks'],
  1567. 'list'=>[
  1568. [
  1569. 'drck'=>$drck,
  1570. 'jm'=>$post['jm'],
  1571. 'sl'=>$n,
  1572. 'drck'=>$drck,
  1573. ]
  1574. ]
  1575. ];
  1576. $res = $this->apiyyv1->scdCreate($params,$token);
  1577. $this->logic_ding->sendToDing("【".$post['orderinfo']."-".$data['id']."】生产备货同步u9||".json_encode($res,JSON_UNESCAPED_UNICODE));
  1578. if(!isset($res[0]['Data'])){
  1579. echo json_encode(array('msg'=>'u9同步返回异常,请重试!','success'=>false));exit;
  1580. }
  1581. if(!$res[0]['Data'][0]['m_isSucess']){
  1582. echo json_encode(array('msg'=>'u9同步失败,请重试!','success'=>false));exit;
  1583. }
  1584. $scid = $res[0]['Data'][0]['m_iD']."~".$res[0]['Data'][0]['m_code']."~".$drck;
  1585. $post['scid'] = $scid;
  1586. $post['scapi'] = 1;
  1587. $post['dbapi'] = 0;
  1588. $this->db->trans_begin();
  1589. $post['shipremarks'] = $data['shipremarks'];
  1590. for($i = 0;$i < $n;$i++){
  1591. $post['label'] = $label.$i;
  1592. $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>1);
  1593. $this->whlabel_bh_transfer->insert($post);
  1594. }
  1595. $printsl = $data['printsl']*1 + $n*1;
  1596. $this->whlabel_bh->save(['printsl'=>$printsl],$data['id']);
  1597. if ($this->db->trans_status() === TRUE)
  1598. {
  1599. $this->db->trans_commit();
  1600. echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1601. }else{
  1602. $this->db->trans_rollback();
  1603. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1604. }
  1605. }
  1606. }
  1607. public function _bdbb()
  1608. {
  1609. $post = $this->input->post(NULL, TRUE);
  1610. if(isset($post['s']))
  1611. {
  1612. $id_arr = $this->input->post('s');
  1613. $id_arr = explode(',',trim($id_arr,','));
  1614. if(!$id_arr)
  1615. {
  1616. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1617. }
  1618. //循环删除记录
  1619. foreach ($id_arr as $v)
  1620. {
  1621. $t = $this->whlabel_bh_transfer->read($v);
  1622. if(!isset($t['number']))
  1623. {
  1624. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1625. }
  1626. $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>1);
  1627. }
  1628. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1629. }
  1630. }
  1631. public function _out()
  1632. {
  1633. $post = $this->input->post(NULL, TRUE);
  1634. if(isset($post['label']))
  1635. {
  1636. $time = time();
  1637. $label = $this->input->post('label',true);
  1638. $cz = $this->input->post('cz',true);
  1639. $transfer = $this->input->post('transfer',true);
  1640. if(!$label)
  1641. {
  1642. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1643. }
  1644. if(!$transfer)
  1645. {
  1646. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  1647. }
  1648. $lb = $this->whlabel_bh_transfer->get_label($label);
  1649. if(!$lb)
  1650. {
  1651. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  1652. }
  1653. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1654. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1655. $tdata = $this->transfer->find_all();
  1656. $t = array();
  1657. foreach ($tdata as $v)
  1658. {
  1659. $t[$v['id']] = $v['title'];
  1660. }
  1661. if($cz == 1)
  1662. {
  1663. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1664. {
  1665. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1666. }
  1667. }
  1668. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1669. {
  1670. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1671. }
  1672. if($cz == 1)
  1673. {
  1674. $lb['rk'] .= $transfer.'|';
  1675. $lb['rktime'] .= $time.'|';
  1676. if($lbrk[0] == $transfer)
  1677. {
  1678. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1679. }
  1680. //必须走配货
  1681. if(($transfer != 1) && (strpos($lb['rk'],'|1|') === false) ){
  1682. echo json_encode(array('msg'=>'请先到配货!','success'=>false));exit;
  1683. }
  1684. }
  1685. else if($cz == 2)
  1686. {
  1687. $lb['ck'] .= $transfer.'|';
  1688. $lb['cktime'] .= $time.'|';
  1689. if($lbck[0] == $transfer)
  1690. {
  1691. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1692. }
  1693. }
  1694. $cztime = 'ctime'.$transfer;
  1695. //如果是完成扫出 这样会通知erp生成一个调出单
  1696. //中转库如果扫出的话 应该是马尾 其它的没有
  1697. if(($transfer == 3 || $transfer == 13) && $cz == 2 && $lb['dbapi'] < 99){
  1698. $this->db->trans_begin();
  1699. $this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time,'status'=>2,'dbapi'=>99),$lb['id']);
  1700. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1701. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1702. if($ct_info){
  1703. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1704. }
  1705. $this->zzquque_u9->insert([
  1706. 'platform'=>'',
  1707. 'warehouse'=>0,
  1708. 'type'=>21,
  1709. 'order_no'=>$lb['orderinfo'],
  1710. 'child_order_no'=>$lb['id'],
  1711. 'status'=>0,
  1712. 'create_time'=>time(),
  1713. 'update_time'=>time(),
  1714. ]);
  1715. if ($this->db->trans_status() === TRUE){
  1716. $this->db->trans_commit();
  1717. echo json_encode(array('music'=>'1','success'=>true));exit;
  1718. }else{
  1719. $this->db->trans_rollback();
  1720. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1721. }
  1722. }
  1723. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1724. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1725. {
  1726. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1727. }
  1728. $save_data = [
  1729. 'rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time
  1730. ];
  1731. //配货入库需更新一下配货状态
  1732. if($transfer == 1 && $cz == 2 && $lb['status'] == 0){
  1733. $save_data['status'] = 1;
  1734. }
  1735. $this->db->trans_begin();
  1736. $this->whlabel_bh_transfer->save($save_data,$lb['id']);
  1737. if($cz == 2){
  1738. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1739. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1740. if($ct_info){
  1741. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1742. }
  1743. }else{
  1744. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>0,'number'=>$lb['number']]);
  1745. }
  1746. if ($this->db->trans_status() === TRUE){
  1747. $this->db->trans_commit();
  1748. echo json_encode(array('music'=>'1','success'=>true));exit;
  1749. }else{
  1750. $this->db->trans_rollback();
  1751. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1752. }
  1753. }
  1754. }
  1755. protected function getOperateList(){
  1756. $api = $this->input->post('api',true);
  1757. $page = $this->input->post('page',true);
  1758. $perpage = $this->input->post('perpage',true);
  1759. $orderinfo = $this->input->post('number',true);
  1760. $color = $this->input->post('color',true);
  1761. $pm = $this->input->post('pm',true);
  1762. $purchase = $this->input->post('purchase',true);
  1763. $transfer = $this->input->post('transfer',true);
  1764. $lx = $this->input->post('lx',true);
  1765. $timetk = $this->input->post('timetk',true);
  1766. $timetj = $this->input->post('timetj',true);
  1767. $timetk = strtotime($timetk);
  1768. $timetj = strtotime($timetj);
  1769. $where = "1=1";
  1770. if($transfer)
  1771. {
  1772. $ctime = 'ctime'.$transfer;
  1773. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1774. }
  1775. else
  1776. {
  1777. $where .= " and time > '$timetk' and time < '$timetj'";
  1778. }
  1779. if($orderinfo)
  1780. {
  1781. $where .= " and orderinfo like '%$orderinfo%'";
  1782. }
  1783. if($transfer)
  1784. {
  1785. $where .= " and rk like '%|".$transfer."|%'";
  1786. }
  1787. if($purchase)
  1788. {
  1789. $where .= " and purchase = '$purchase'";
  1790. }
  1791. if($pm)
  1792. {
  1793. $where .= " and pm like '%$pm%'";
  1794. }
  1795. if($color)
  1796. {
  1797. $where .= " and fpdata like '%-".$color."-%'";
  1798. }
  1799. //数据排序
  1800. $order_str = "id desc";
  1801. if(empty($page))
  1802. {
  1803. $start = 0;
  1804. $perpage = 1;
  1805. }
  1806. else
  1807. {
  1808. $start = ($page - 1)*$perpage;
  1809. }
  1810. //取得信息列表
  1811. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1812. $transfer = $this->transfer->find_all();
  1813. $t = array();$ot = array();
  1814. foreach ($transfer as $v)
  1815. {
  1816. $t[$v['id']] = $v['title'];
  1817. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1818. }
  1819. //格式化数据
  1820. foreach ($info_list as $key=>$value)
  1821. {
  1822. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1823. $log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);
  1824. $tmp_operate_str = "";
  1825. foreach($log_list as $k=>$v){
  1826. $tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";
  1827. }
  1828. $info_list[$key]['time'] = trim($tmp_operate_str,'<br>');
  1829. }
  1830. $total = $this->whlabel_bh_transfer->find_count($where);
  1831. $pagenum = ceil($total/$perpage);
  1832. $over = $total-($start+$perpage);
  1833. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'where'=>$where);
  1834. return $rows;
  1835. }
  1836. public function _operate()
  1837. {
  1838. $post = $this->input->post(NULL, TRUE);
  1839. if(isset($post['page']))
  1840. {
  1841. $rows = $this->getOperateList();
  1842. echo json_encode($rows);exit;
  1843. }
  1844. if(isset($_SESSION['api']))
  1845. {
  1846. $user = $this->user->get_api($_SESSION['api']);
  1847. $usp = $user;
  1848. $pid = "";$tid="";$sid="";$wid="";
  1849. $purchase = explode('|',trim($user['purchase'],'|'));
  1850. $transfer = explode('|',trim($user['transfer'],'|'));
  1851. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1852. foreach ($purchase as $value)
  1853. {
  1854. $pid .= " id = ".$value." or";
  1855. }
  1856. foreach ($transfer as $value)
  1857. {
  1858. $tid .= " id = ".$value." or";
  1859. }
  1860. foreach ($warehouse as $value)
  1861. {
  1862. $wid .= " id = ".$value." or";
  1863. }
  1864. }
  1865. else
  1866. {
  1867. header('Location: /');exit;
  1868. }
  1869. $kx = '';$zjtab = '';
  1870. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1871. $this->data['warehouse'] = $warehouse;
  1872. $purchase = $this->purchase->find_all("yyid != ''");
  1873. $this->data['purchase'] = $purchase;
  1874. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1875. $this->data['transfer'] = $transfer;
  1876. $ids = array_column($transfer,'id');
  1877. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  1878. $start_time = $end_time - 14 * 24 * 60 * 60;
  1879. //$count = $this->whlabel_bh_transfer_cr->find_count("type = 1 and is_over = 0 and lx in (".implode(",",$ids).") and time >= ".$start_time." and time <= ".$end_time );
  1880. //$this->data['count'] = $count;
  1881. $this->data['vip'] = $user['vip'];
  1882. $this->_Template('whlabel_bh_operate',$this->data);
  1883. }
  1884. public function _rk()
  1885. {
  1886. $post = $this->input->post(NULL, TRUE);
  1887. if(isset($post['page']))
  1888. {
  1889. $res = $this->getOperateList();
  1890. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1891. echo json_encode($rows);exit;
  1892. }
  1893. if(isset($_SESSION['api']))
  1894. {
  1895. $user = $this->user->get_api($_SESSION['api']);
  1896. $usp = $user;
  1897. $pid = "";$tid="";$sid="";$wid="";
  1898. $purchase = explode('|',trim($user['purchase'],'|'));
  1899. $transfer = explode('|',trim($user['transfer'],'|'));
  1900. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1901. foreach ($purchase as $value)
  1902. {
  1903. $pid .= " id = ".$value." or";
  1904. }
  1905. foreach ($transfer as $value)
  1906. {
  1907. $tid .= " id = ".$value." or";
  1908. }
  1909. foreach ($warehouse as $value)
  1910. {
  1911. $wid .= " id = ".$value." or";
  1912. }
  1913. }
  1914. else
  1915. {
  1916. header('Location: /');exit;
  1917. }
  1918. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1919. $this->data['transfer'] = $transfer;
  1920. $this->_Template('whlabel_bh_rk',$this->data);
  1921. }
  1922. public function _ck()
  1923. {
  1924. $post = $this->input->post(NULL, TRUE);
  1925. if(isset($post['page']))
  1926. {
  1927. $res = $this->getOperateList();
  1928. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1929. echo json_encode($rows);exit;
  1930. }
  1931. if(isset($_SESSION['api']))
  1932. {
  1933. $user = $this->user->get_api($_SESSION['api']);
  1934. $usp = $user;
  1935. $pid = "";$tid="";$sid="";$wid="";
  1936. $purchase = explode('|',trim($user['purchase'],'|'));
  1937. $transfer = explode('|',trim($user['transfer'],'|'));
  1938. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1939. foreach ($purchase as $value)
  1940. {
  1941. $pid .= " id = ".$value." or";
  1942. }
  1943. foreach ($transfer as $value)
  1944. {
  1945. $tid .= " id = ".$value." or";
  1946. }
  1947. foreach ($warehouse as $value)
  1948. {
  1949. $wid .= " id = ".$value." or";
  1950. }
  1951. }
  1952. else
  1953. {
  1954. header('Location: /');exit;
  1955. }
  1956. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1957. $this->data['transfer'] = $transfer;
  1958. $this->_Template('whlabel_bh_ck',$this->data);
  1959. }
  1960. //备货流转记录表
  1961. public function _transfer_log(){
  1962. $post = $this->input->post(NULL, TRUE);
  1963. if($post){
  1964. $page = $this->input->post('page',true);
  1965. $perpage = $this->input->post('perpage',true);
  1966. $where = " extra_type = 1 ";
  1967. $orderinfo = $this->input->post('orderinfo',true);
  1968. $timetk = $this->input->post('timetk',true);
  1969. $timetj = $this->input->post('timetj',true);
  1970. $timetk = strtotime($timetk);
  1971. $timetj = strtotime($timetj);
  1972. if($timetk && $timetj)
  1973. {
  1974. $where .= " and time > '$timetk' and time < '$timetj'";
  1975. }
  1976. if($orderinfo){
  1977. $where.= " and orderinfo like '%$orderinfo%' ";
  1978. }
  1979. if(empty($page))
  1980. {
  1981. $start = 0;
  1982. $perpage = 1;
  1983. }
  1984. else
  1985. {
  1986. $start = ($page - 1)*$perpage;
  1987. }
  1988. $list = $this->whlabel_bh->find_pc($where,'orderinfo',"id,orderinfo",'id desc',$start,$perpage);
  1989. $rows = [];
  1990. foreach($list as $k=>$v){
  1991. $tmp_order_info = $this->whlabel_bh->find_all(" orderinfo = '".$v['orderinfo']."'","id,orderinfo,bhnum");
  1992. $tmp_ids = [];
  1993. $tmp_bhnum = 0;
  1994. foreach($tmp_order_info as $vv){
  1995. $tmp_ids[] = $vv['id'];
  1996. $tmp_bhnum += $vv['bhnum'];
  1997. }
  1998. $ydysl = $wdysl = $yphsl = $yjgsj = $wwgsl = 0;
  1999. if(!empty($tmp_ids)){
  2000. $list = $this->whlabel_bh_transfer->find_all(" wbid in (".implode(",",$tmp_ids).")");
  2001. foreach($list as $vv){
  2002. $ydysl += 1;
  2003. if($vv['status'] == 1){
  2004. $yphsl += 1;
  2005. }
  2006. if($vv['status'] == 2){
  2007. $yjgsj += 1;
  2008. }
  2009. }
  2010. }
  2011. $rows[$k]['id'] = $v['id'];
  2012. $rows[$k]['orderinfo'] = "<h9 class='window' data-h='/whlabel_bh/transfer_detail/".$v['id']."' data-t='备货单号:".$v['orderinfo']."'><p>".$v['orderinfo']."</p></h9>" ;
  2013. $rows[$k]['ddsl'] = $tmp_bhnum; //订单数量
  2014. $rows[$k]['ydysl'] = $ydysl; //已打印数量
  2015. $rows[$k]['wdysl'] = $tmp_bhnum - $ydysl; //未打印数量
  2016. $rows[$k]['yphsl'] = $yphsl; //已配货数量
  2017. $rows[$k]['yjgsj'] = $yjgsj; //已完工数量
  2018. $rows[$k]['wwgsl'] = $tmp_bhnum - $yjgsj; //未完工数量
  2019. }
  2020. $total = $this->whlabel_bh->find_count($where);
  2021. $pagenum = ceil($total/$perpage);
  2022. $over = $total-($start+$perpage);
  2023. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  2024. echo json_encode($rows);exit;
  2025. }
  2026. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2027. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2028. $all_list = $this->whlabel_bh->find_all("extra_type = 1 and time >= ".$start_time." and time <= ".$end_time);
  2029. $orderinfo_list =[];
  2030. $total_num = 0;
  2031. foreach($all_list as $k=>$v){
  2032. $orderinfo_list[$v['id']] = $v['id'];
  2033. $total_num += $v['bhnum'];
  2034. }
  2035. $wbids = array_values($orderinfo_list);
  2036. if(empty($wbids)){
  2037. $over_num = 0;
  2038. }else{
  2039. $over_num = $this->whlabel_bh_transfer->find_count(" status = 2 and wbid in (".implode(",",$wbids).")");
  2040. }
  2041. $this->data['total_num'] = $total_num;
  2042. $this->data['wwcsl'] = $total_num - $over_num;
  2043. $this->_Template('whlabel_bh_transfer_log',$this->data);
  2044. }
  2045. public function _transfer_detail($arg_array){
  2046. $id = $arg_array[0];
  2047. $transfer_list = $this->transfer->find_all();
  2048. $t_list = array_column($transfer_list,'title','id');
  2049. $info = $this->whlabel_bh->read($id);
  2050. $list = $this->whlabel_bh_transfer->find_all(" orderinfo= '".$info['orderinfo']."'");
  2051. $ids = array_column($list,'id');
  2052. $final_list = [];
  2053. if(!empty($ids)){
  2054. $log_list = $this->whlabel_bh_transfer_cr->find_all( " type = 1 and fid in (".implode(",",$ids).")","*","id asc");
  2055. $collect_list = [];
  2056. foreach($log_list as $k=>$v){
  2057. $collect_list[$v['lx']][$v['fid']] = $v;
  2058. }
  2059. foreach($collect_list as $k=>$v){
  2060. $js_num = $zk_num = $wc_num = 0;
  2061. foreach($v as $kk=>$vv){
  2062. $js_num += 1;
  2063. if($vv['is_over'] == 0){
  2064. $zk_num += 1;
  2065. }
  2066. if($vv['is_over'] == 1){
  2067. $wc_num += 1;
  2068. }
  2069. }
  2070. $final_list[$k] = [
  2071. 'cj' => $t_list[$k],
  2072. 'js_num' => $js_num,
  2073. 'zk_num' => $zk_num,
  2074. 'wc_num' => $wc_num,
  2075. 'list' => $v,
  2076. ];
  2077. }
  2078. }
  2079. // echo "<pre>";
  2080. // print_r($final_list);
  2081. // die;
  2082. $this->data['final_list'] = $final_list;
  2083. $this->_Template('whlabel_bh_transfer_detail',$this->data);
  2084. }
  2085. public function _cj_transfer_log(){
  2086. $post = $this->input->post(NULL, TRUE);
  2087. if(!empty($post)){
  2088. $orderinfo = $this->input->post('orderinfo',true);
  2089. $pm = $this->input->post('pm',true);
  2090. $tid = $this->input->post('tid',true);
  2091. $page = $this->input->post('page',true);
  2092. $perpage = $this->input->post('perpage',true);
  2093. $timetk = $this->input->post('timetk',true);
  2094. $timetj = $this->input->post('timetj',true);
  2095. $timetk = strtotime($timetk);
  2096. $timetj = strtotime($timetj);
  2097. $where = " rk like '%|".$tid."|%' ";
  2098. if($timetk && $timetj)
  2099. {
  2100. $where .= " and time > '$timetk' and time < '$timetj'";
  2101. }
  2102. if($pm){
  2103. if(empty($orderinfo)){
  2104. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]),'cwxx'=>"请先输入订单号");
  2105. echo json_encode($rows);exit;
  2106. }else{
  2107. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2108. $numbers = array_column($number_list,'number');
  2109. if(empty($numbers)){
  2110. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2111. echo json_encode($rows);exit;
  2112. }
  2113. $where.= " and number in (".implode(",",$numbers).") ";
  2114. }
  2115. }else{
  2116. if($orderinfo){
  2117. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2118. $numbers = array_column($number_list,'number');
  2119. if(empty($numbers)){
  2120. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2121. echo json_encode($rows);exit;
  2122. }
  2123. $where.= " and number in (".implode(",",$numbers).") ";
  2124. }
  2125. }
  2126. if(empty($page))
  2127. {
  2128. $start = 0;
  2129. $perpage = 20;
  2130. }
  2131. else
  2132. {
  2133. $start = ($page - 1)*$perpage;
  2134. }
  2135. $list = $this->whlabel_bh_transfer->find_pc($where,'number',"id,number,orderinfo,pm",'id desc',$start,$perpage);
  2136. $count = $this->whlabel_bh_transfer->find_all($where,'COUNT(DISTINCT number) as total');
  2137. $total = $count[0]['total'];
  2138. $pagenum = ceil($total/$perpage);
  2139. $over = $total-($start+$perpage);
  2140. $final_list = [];
  2141. foreach($list as $k=>$v){
  2142. $yjs_arr =[];//避免多次扫入的重复计算
  2143. $yjs = $wck= $yck = 0;
  2144. $log_list = $this->whlabel_bh_transfer_cr->find_all("lx = ".$tid." and type = 1 and number = ".$v['number'],"*",'id desc');
  2145. foreach($log_list as $kk=>$vv){
  2146. if(!isset($yjs_arr[$vv['fid']])){
  2147. $yjs += 1;
  2148. if($vv['is_over'] == 0){
  2149. $wck += 1;
  2150. }
  2151. if($vv['is_over'] == 1){
  2152. $yck += 1;
  2153. }
  2154. $yjs_arr[$vv['fid']] = 1;
  2155. }
  2156. }
  2157. $whlabel_bh_info = $this->whlabel_bh->find("number = ".$v['number']);
  2158. $final_list[$k]['id'] = $v['id'];
  2159. $final_list[$k]['orderinfo'] = $v['orderinfo'] ;
  2160. $final_list[$k]['number'] ="<h9 class='window' data-h='/whlabel_bh/cj_transfer_detail/".$v['number']."/".$tid."' data-t='备货单号:".$v['number']."'><p>".$v['number']."</p></h9>";
  2161. $final_list[$k]['pm'] = $v['pm'];
  2162. $final_list[$k]['ddsl'] = empty($whlabel_bh_info)?0:$whlabel_bh_info['bhnum'];
  2163. $final_list[$k]['yjs'] = $yjs;
  2164. $final_list[$k]['wck'] = $wck;
  2165. $final_list[$k]['yck'] = $yck;
  2166. }
  2167. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2168. echo json_encode($rows);exit;
  2169. }
  2170. if(isset($_SESSION['api']))
  2171. {
  2172. $user = $this->user->get_api($_SESSION['api']);
  2173. $usp = $user;
  2174. $transfer = explode('|',trim($user['transfer'],'|'));
  2175. $stid = "";
  2176. foreach ($transfer as $value)
  2177. {
  2178. $stid .= " id = ".$value." or";
  2179. }
  2180. if(empty($transfer)){
  2181. exit("您的账号没有赋予车间权限");
  2182. }
  2183. // if(count($transfer) > 1){
  2184. // exit("您的账号只能分配一个车间,多车间系统无法处理");
  2185. // }
  2186. $tid = $transfer[0];
  2187. }
  2188. else
  2189. {
  2190. header('Location: /');exit;
  2191. }
  2192. $transfer = $this->transfer->read($tid);
  2193. $this->data['transfer'] = $transfer;
  2194. $transfer_list = $this->transfer->find_all( trim($stid,'or'));
  2195. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2196. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2197. $log_list = $this->whlabel_bh_transfer_cr->find_all(" lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time,"*","id desc");
  2198. $wwcsl = $jszs = $wgzs = 0;
  2199. $tmp_list = [];
  2200. foreach($log_list as $k=>$v){
  2201. if(!isset($tmp_list[$v['fid']])){
  2202. $tmp_list[$v['fid']] = $v;
  2203. $jszs += 1;
  2204. if($v['is_over'] == 1){
  2205. $wgzs += 1;
  2206. }else{
  2207. $wwcsl += 1;
  2208. }
  2209. }
  2210. }
  2211. $this->data['wwcsl'] = $wwcsl;
  2212. $this->data['jszs'] = $jszs;
  2213. $this->data['wgzs'] = $wgzs;
  2214. $this->data['transfer_list'] = $transfer_list;
  2215. $this->_Template('whlabel_bh_cj_transfer_log',$this->data);
  2216. }
  2217. //针对车间的变动筛选条件的
  2218. public function _cj_transfer_log_count(){
  2219. $orderinfo = $this->input->post('orderinfo',true);
  2220. $tid = $this->input->post('tid',true);
  2221. $timetk = $this->input->post('timetk',true);
  2222. $timetj = $this->input->post('timetj',true);
  2223. $pm = $this->input->post('pm',true);
  2224. $start_time = strtotime($timetk);
  2225. $end_time = strtotime($timetj);
  2226. $where = " lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time;
  2227. // if($orderinfo){
  2228. // $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2229. // $numbers = array_column($number_list,'number');
  2230. // $where.= " and number in (".implode(",",$numbers).") ";
  2231. // }
  2232. if($pm){
  2233. if(empty($orderinfo)){
  2234. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2235. }else{
  2236. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2237. $numbers = array_column($number_list,'number');
  2238. if(empty($numbers)){
  2239. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2240. }
  2241. $where.= " and number in (".implode(",",$numbers).") ";
  2242. }
  2243. }else{
  2244. if($orderinfo){
  2245. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2246. $numbers = array_column($number_list,'number');
  2247. if(empty($numbers)){
  2248. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2249. }
  2250. $where.= " and number in (".implode(",",$numbers).") ";
  2251. }
  2252. }
  2253. $log_list = $this->whlabel_bh_transfer_cr->find_all($where);
  2254. $wwcsl = $jszs = $wgzs = 0;
  2255. $tmp_list = [];
  2256. foreach($log_list as $k=>$v){
  2257. if(!isset($tmp_list[$v['fid']])){
  2258. $tmp_list[$v['fid']] = $v;
  2259. $jszs += 1;
  2260. if($v['is_over'] == 1){
  2261. $wgzs += 1;
  2262. }else{
  2263. $wwcsl += 1;
  2264. }
  2265. }
  2266. }
  2267. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => $wwcsl,'jszs'=>$jszs,'wgzs'=>$wgzs]]));
  2268. }
  2269. public function _cj_transfer_detail($arg_array){
  2270. $number = $arg_array[0];
  2271. $tid = $arg_array[1];
  2272. $transfer_info = $this->transfer->read($tid);
  2273. $whlabel_bh_info = $this->whlabel_bh->find(" number = ".$number);
  2274. $final_list = [];
  2275. $log_list = $this->whlabel_bh_transfer_cr->find_all( " number = ".$number." and lx = ".$tid,"*","id asc");
  2276. $collect_list = [];
  2277. foreach($log_list as $k=>$v){
  2278. if(isset($final_list[$v['fid']])){
  2279. if($v['type'] == 1){
  2280. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2281. }else{
  2282. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2283. }
  2284. }else{
  2285. if($v['type'] == 1){
  2286. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2287. }else{
  2288. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2289. }
  2290. }
  2291. }
  2292. $this->data['whlabel_bh_info'] = $whlabel_bh_info;
  2293. $this->data['transfer_info'] = $transfer_info;
  2294. $this->data['final_list'] = $final_list;
  2295. $this->_Template('whlabel_bh_cj_transfer_detail',$this->data);
  2296. }
  2297. public function _excelwchz(){
  2298. $classid = $this->classid->sku();
  2299. $pm = $classid;
  2300. $typeclass = array();
  2301. $tc = $this->typeclass->find_all();
  2302. foreach ($tc as $v)
  2303. {
  2304. $typeclass[$v['id']] = $v;
  2305. }
  2306. $prc = array();
  2307. $purchase = $this->purchase->find_all();
  2308. foreach($purchase as $k=>$v)
  2309. {
  2310. $prc[$v['id']] = $v['title'];
  2311. }
  2312. if(isset($_GET['fexcel']))
  2313. {
  2314. $number = $this->input->get('number',true);
  2315. $pm = $this->input->get('pm',true);
  2316. $color = $this->input->get('color',true);
  2317. $transfer = $this->input->get('transfer',true);
  2318. $ktime = $this->input->get('timetk',true);
  2319. $jtime = $this->input->get('timetj',true);
  2320. $ktime = strtotime($ktime);
  2321. $jtime = strtotime($jtime);
  2322. $where = " time >= ".$ktime." and time <= ".$jtime." ";$gj = "";$ck = "";
  2323. $where .=" and status = 2 and ck like '%|".$transfer."|' ";
  2324. if($number)
  2325. {
  2326. $where .= " and number like '%$number%'";
  2327. }
  2328. if($pm)
  2329. {
  2330. $where .= " and pm like '%$pm%'";
  2331. }
  2332. if($color)
  2333. {
  2334. $where .= " and features like '%-$color-%'";
  2335. }
  2336. $list = array();
  2337. $rows = $this->whlabel_bh_transfer->find_all($where,'id,wbid,orderinfo,jm,pm,time,label');
  2338. foreach($rows as $k=>$v){
  2339. if(isset($list[$v['wbid']])){
  2340. $list[$v['wbid']]['sl'] = $list[$v['wbid']]['sl'] + 1;
  2341. $list[$v['wbid']]['time'][] = date("Y-m-d H:i:s",$v['time']);
  2342. $list[$v['wbid']]['label'][] = $v['label'];
  2343. }else{
  2344. $list[$v['wbid']] = [
  2345. 'wbid'=>$v['wbid'],
  2346. 'orderinfo'=>$v['orderinfo'],
  2347. 'jm'=>$v['jm'],
  2348. 'pm'=>$v['pm'],
  2349. 'sl'=>1,
  2350. 'time'=>[
  2351. date("Y-m-d H:i:s",$v['time'])
  2352. ],
  2353. 'label'=>[
  2354. $v['label'],
  2355. ]
  2356. ];
  2357. }
  2358. }
  2359. $filename = date("Y-m-d")."工厂备货完成汇总.xls";
  2360. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2361. <head>
  2362. <!--[if gte mso 9]><xml>
  2363. <x:ExcelWorkbook>
  2364. <x:ExcelWorksheets>
  2365. <x:ExcelWorksheet>
  2366. <x:Name>EXCEL</x:Name>
  2367. <x:WorksheetOptions>
  2368. <x:Print>
  2369. <x:ValidPrinterInfo />
  2370. </x:Print>
  2371. </x:WorksheetOptions>
  2372. </x:ExcelWorksheet>
  2373. </x:ExcelWorksheets>
  2374. </x:ExcelWorkbook>
  2375. </xml>
  2376. <![endif]-->
  2377. </head><body>";
  2378. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2379. $str .= "<tr><td>ID</td><td>编号</td><td>简码</td><td>品名</td><td>数量</td><td>扫描时间</td><td>扫描条码</td></tr>";
  2380. foreach ($list as $key=>$value)
  2381. {
  2382. $str .= "<tr>";
  2383. $str .= "<td>". $value['wbid']. "</td>";
  2384. $str .= "<td>". $value['orderinfo']. "</td>";
  2385. $str .= "<td>". $value['jm']. "</td>";
  2386. $str .= "<td>". $value['pm']. "</td>";
  2387. $str .= "<td>". $value['sl']. "</td>";
  2388. $str .="<td>";
  2389. $tmp = "";
  2390. foreach($value['time'] as $kk=>$vv){
  2391. $tmp .=$vv."<br/>";
  2392. }
  2393. $str .= trim($tmp,"<br/>");
  2394. $str .="</td>";
  2395. $str .="<td>";
  2396. $tmp_l = "";
  2397. foreach($value['label'] as $kk=>$vv){
  2398. $tmp_l .= "`".$vv."<br/>";
  2399. }
  2400. $str .= trim($tmp_l,"<br/>");
  2401. $str .="</td>";
  2402. $str .= "</tr>";
  2403. }
  2404. $str .= "</table></body></html>";
  2405. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2406. header( "Content-type: application/octet-stream" );
  2407. header( "Content-Disposition: attachment; filename=".$filename );
  2408. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2409. header( "Pragma: no-cache" );
  2410. header( "Expires: 0" );
  2411. exit($str);
  2412. }
  2413. }
  2414. }