Whlabel_bh.php 85 KB

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