Whlabel_bh.php 73 KB

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