Whlabel_bh.php 72 KB

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