Beihuogl.php 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Beihuogl extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_bhsq','bhsq');
  7. $this->load->_model("Model_shop","shop");
  8. $this->load->_model("Model_typeclass","typeclass");
  9. $this->load->_model("Model_bhccwl","bhccwl");
  10. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  11. $this->load->_model("Model_whlabel","whlabel");
  12. $this->load->_model("Model_goods","goods");
  13. $this->load->_model("Model_settingtest","settingtest");
  14. $this->load->_model("Model_bhdcd","bhdcd");
  15. $this->load->_model("Model_whlabellabel","whlabellabel");
  16. }
  17. //定义方法的调用规则 获取URI第二段值
  18. public function _remap($arg,$arg_array)
  19. {
  20. if(!isset($_SESSION['api'])){
  21. header('Location: /');exit;
  22. }
  23. if($arg == 'dyapply')//
  24. {
  25. $this->_dyapply();
  26. }
  27. elseif($arg == 'dyapplyadd')//
  28. {
  29. $this->_dyapplyadd();
  30. }
  31. elseif($arg == 'dyapplyedit')//
  32. {
  33. $this->_dyapplyedit($arg_array);
  34. }
  35. elseif($arg == 'dyapplygxzt')//
  36. {
  37. $this->_dyapplygxzt();
  38. }
  39. elseif($arg == 'dyapplyexcel'){
  40. $this->_dyapplyexcel();
  41. }
  42. elseif($arg == 'ccwlshlist'){
  43. $this->_ccwlshlist();
  44. }
  45. elseif($arg == 'ccwlbhindex'){
  46. $this->_ccwlbhindex();
  47. }elseif($arg == 'dyapplysave'){
  48. $this->_dyapplysave();
  49. }elseif($arg == 'ccwlbhmake'){
  50. $this->_ccwlbhmake();
  51. }elseif($arg == 'ccwlbhedit'){
  52. $this->_ccwlbhedit($arg_array);
  53. }elseif($arg == 'ccwleditxzbh'){
  54. $this->_ccwleditxzbh();
  55. }elseif($arg == 'ccwlbhsavexzbh'){
  56. $this->_ccwlbhsavexzbh();
  57. }elseif($arg == 'ccwldelitem'){
  58. $this->_ccwldelitem();
  59. }elseif($arg == 'ccwlbhsave'){
  60. $this->_ccwlbhsave();
  61. }elseif($arg == 'ckbhindex'){
  62. $this->_ckbhindex();
  63. }elseif($arg == 'ckbhedit'){
  64. $this->_ckbhedit($arg_array);
  65. }elseif($arg == 'makeu9scd'){
  66. $this->_makeu9scd($arg_array);
  67. }elseif($arg == 'showckbh'){
  68. $this->_showckbh($arg_array);
  69. }elseif($arg == 'ddscscd'){
  70. $this->_ddscscd();
  71. }elseif($arg == 'ckdcd'){
  72. $this->_ckdcd();
  73. }elseif($arg == 'ckbherprk'){
  74. $this->_ckbherprk($arg_array);
  75. }elseif($arg == 'bhdcdsave'){
  76. $this->_bhdcdsave();
  77. }elseif($arg == 'u9scdexcel')
  78. {
  79. $this->_u9scdexcel($arg_array);
  80. }elseif($arg == 'ccwlskucheck'){
  81. $this->_ccwlskucheck();
  82. }elseif($arg == 'printlabel'){
  83. $this->_printlabel();
  84. }elseif($arg == 'deldyapply'){
  85. $this->_deldyapply();
  86. }elseif($arg == 'dcdjzrk'){
  87. $this->_dcdjzrk();
  88. }
  89. else
  90. {
  91. $this->_index();
  92. }
  93. }
  94. private function _index(){
  95. exit('No direct script access allowed 1');
  96. }
  97. //备货申请单的列表
  98. private function _dyapply(){
  99. if($this->input->method() === 'post'){
  100. $vip_id = $this->input->post('vip_id',true);
  101. $page = $this->input->post('page',true);
  102. $perpage = $this->input->post('perpage',true);
  103. $sqr = $this->input->post('sqr',true);
  104. $sqr = trim($sqr);
  105. $shop_id = $this->input->post('shop_id',true);
  106. $plat_id = $this->input->post('plat_id',true);
  107. $shop_ids = $this->input->post('shop_ids',true);
  108. $ktime = $this->input->post('ktime',true);
  109. $jtime = $this->input->post('jtime',true);
  110. $ktime = strtotime($ktime);
  111. $jtime = strtotime($jtime);
  112. $where = "add_time >= ".$ktime." and add_time < ".$jtime." ";
  113. if(!empty($sqr)){
  114. $where .= " and sqr = '".$sqr."' ";
  115. }
  116. if($shop_id > -1){
  117. $where .= " and shop_id = ".$shop_id." ";
  118. }else{
  119. if($vip_id == 1){
  120. }else{
  121. $where .= " and shop_id in (".$shop_ids.") ";
  122. }
  123. }
  124. if($plat_id > -1){
  125. $where .= " and plat_id = ".$plat_id." ";
  126. }
  127. //数据排序
  128. $order_str = "id desc";
  129. if(empty($page))
  130. {
  131. $start = 0;
  132. $perpage = 1;
  133. }
  134. else
  135. {
  136. $start = ($page - 1)*$perpage;
  137. }
  138. $list = $this->bhsq->find_all($where,"id,shop_id,plat_id,title,sku,sqr,sq_num,sq_status,add_time,update_time",$order_str,$start,$perpage);
  139. if(empty($list)){
  140. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  141. echo json_encode($rows);exit;
  142. }
  143. $shop_list = $this->shop->find_all("1=1","id,shopname");
  144. $shop_list = array_column($shop_list,'shopname','id');
  145. $plat_list = $this->typeclass->find_all("classid = 32","id,title");
  146. $plat_list = array_column($plat_list,'title','id');
  147. $status_list = $this->bhsq->getSqStatus();
  148. foreach($list as $k=>$v){
  149. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"无";
  150. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"无";
  151. $list[$k]['sq_status'] = isset($status_list[$v['sq_status']])?$status_list[$v['sq_status']]:"";
  152. $list[$k]['add_time'] = date("Y-m-d",$v['add_time']);
  153. $str = "";
  154. if($v['sq_status'] == 1 || $v['sq_status'] == 3){
  155. $str .= "<div style='text-align:center;'>";
  156. $str .= "<a href='javascript:void(0)'class='window' data-h='/beihuogl/dyapplyedit/".$v['id']."' data-t='修改' style='margin-right:4px;color: #fff;background-color:#228B22;padding:4px 10px;border-radius:5px;font-size:15px'>编辑</a>";
  157. $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color:#4169E1;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='2' onclick='update_status(this)'>发布</a>";
  158. $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #444;background-color: #ddd;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='0' onclick='update_status(this)'>取消</a>";
  159. $str .= "</div>";
  160. }
  161. if($v['sq_status'] == 0){
  162. $str .= "<div style='text-align:center;'>";
  163. $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #DC143C;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='0' onclick='del_bhsq(this)'>删除</a>";
  164. $str .= "</div>";
  165. }
  166. $list[$k]['update_time'] = $str;
  167. }
  168. $total = $this->bhsq->find_count($where);
  169. $pagenum = ceil($total/$perpage);
  170. $over = $total-($start+$perpage);
  171. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  172. echo json_encode($rows);exit;
  173. }else{
  174. $user = $this->user->get_api($_SESSION['api']);
  175. $usersp = explode('|',trim($user['shop'],'|'));
  176. $this->data['usersp'] = implode(",",$usersp);
  177. $vip_id = 0;
  178. if(in_array($user['id'],[10,28])){
  179. $vip_id = 1;
  180. }
  181. $this->data['vip_id'] = $vip_id;
  182. $this->_Template('beihuogl_dyapply',$this->data);
  183. }
  184. }
  185. //备货申请单的添加
  186. private function _dyapplyadd(){
  187. if($this->input->method() === 'post'){
  188. $data = $this->input->post();
  189. $time = strtotime(date("Y-m-d"),time());
  190. $info = $this->bhsq->find("real_time >= ".$time,"*",'id desc');
  191. if(empty($info)){
  192. $num = 1;
  193. }else{
  194. $arr = explode('-',$info['sb_no']);
  195. $num = (int)$arr[2]+1;
  196. }
  197. $num = str_pad($num, 3, '0', STR_PAD_LEFT);
  198. $sb_no = "SQ-".date("ymd")."-".$num;
  199. $insert_arr = [];
  200. $time = time();
  201. foreach($data['title'] as $k=>$v){
  202. $insert_arr[] = [
  203. 'sb_no'=>$sb_no,
  204. 'sku'=>$data['sku'][$k],
  205. 'title'=>$data['title'][$k],
  206. 'shop_id'=>$data['shop_id'],
  207. 'plat_id'=>$data['plat_id'],
  208. 'sqr'=>$data['sqr'],
  209. 'sq_num'=>$data['sq_num'][$k],
  210. 'ccwl_num'=>$data['sq_num'][$k],
  211. 'ck_num'=>$data['sq_num'][$k],
  212. 'sq_status'=>1,
  213. 'remark'=>$data['remark'],
  214. 'add_time'=>$time,
  215. 'real_time'=>$time,
  216. 'update_time'=>$time,
  217. ];
  218. }
  219. $r =$this->db->insert_batch('bhsq',$insert_arr);
  220. if($r){
  221. echo json_encode(['code'=>1,'msg'=>'添加成功']);
  222. }else{
  223. echo json_encode(['code'=>-1,'msg'=>'添加失败']);
  224. }
  225. exit;
  226. }else{
  227. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  228. $this->data['plat_list'] = $plat_list;
  229. $this->_Template('beihuogl_dyapplyadd',$this->data);
  230. }
  231. }
  232. //备货申请单的 修改
  233. private function _dyapplyedit($arg_array){
  234. if($this->input->method() === 'post'){
  235. $data = $this->input->post();
  236. $id = $data['id'];
  237. $update_arr = [
  238. 'shop_id'=>$data['shop_id'],
  239. 'plat_id'=>$data['plat_id'],
  240. 'sqr'=>$data['sqr'],
  241. 'sq_num'=>$data['sq_num'],
  242. 'ccwl_num'=>$data['sq_num'],
  243. 'ck_num'=>$data['sq_num'],
  244. 'sku'=>$data['sku'],
  245. 'remark'=>$data['remark'],
  246. ];
  247. $r = $this->bhsq->save($update_arr,$id);
  248. if($r){
  249. echo json_encode(['msg'=>'添加成功','success'=>true]);
  250. }else{
  251. echo json_encode(['msg'=>'添加失败','success'=>false]);
  252. }
  253. exit;
  254. }else{
  255. $id = $arg_array[0];
  256. $info = $this->bhsq->find("id = ".$id);
  257. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  258. $this->data['plat_list'] = $plat_list;
  259. $this->data['info'] = $info;
  260. $this->_Template('beihuogl_dyapplyedit',$this->data);
  261. }
  262. }
  263. //备货申请单的 状态申请 如 发布 或者取消
  264. private function _dyapplygxzt(){
  265. if($this->input->method() === 'post'){
  266. $data = $this->input->post();
  267. $id = (int)$data['id'];
  268. $type = (int)$data['status'];
  269. $update_arr = [];
  270. $update_arr['sq_status'] = $type;
  271. if($type == 2){
  272. $update_arr['public_time'] = time();
  273. }
  274. if($type == 3){
  275. $update_arr['ccwl_status'] = 0;
  276. $update_arr['ck_status'] = 0;
  277. $update_arr['features'] = '';
  278. $update_arr['jm'] = '';
  279. $update_arr['public_time'] = 0;
  280. $update_arr['bh_no'] = '';
  281. $update_arr['u9sc_no'] = '';
  282. }
  283. $r = $this->bhsq->save($update_arr,$id);
  284. if($r){
  285. echo json_encode(['msg'=>'修改成功','success'=>true]);
  286. }else{
  287. echo json_encode(['msg'=>'修改失败','success'=>false]);
  288. }
  289. exit;
  290. }else{
  291. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  292. }
  293. }
  294. private function _deldyapply(){
  295. if($this->input->method() === 'post'){
  296. $data = $this->input->post();
  297. $id = $data['id'];
  298. $info = $this->bhsq->read($id);
  299. if($info['sq_status'] != 0){
  300. echo json_encode(['msg'=>'此条记录不符合删除条件','success'=>false]);
  301. exit;
  302. }
  303. $r = $this->bhsq->remove($id);
  304. if($r){
  305. echo json_encode(['msg'=>'删除成功','success'=>true]);
  306. }else{
  307. echo json_encode(['msg'=>'删除失败','success'=>false]);
  308. }
  309. exit;
  310. }else{
  311. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  312. }
  313. }
  314. //备货申请单的
  315. private function _dyapplysave(){
  316. if($this->input->method() === 'post'){
  317. $data = $this->input->post();
  318. $id = (int)$data['id'];
  319. $val = $this->input->post('val',true);
  320. $column = $data['column'];
  321. if($column == 'ccwl_num'){
  322. $update_arr = [
  323. 'ccwl_num'=>(int)$val,
  324. 'ck_num'=>(int)$val,
  325. ];
  326. }elseif($column == 'sku'){
  327. $update_arr = [
  328. 'sku'=>$val,
  329. ];
  330. }elseif($column == 'ck_num'){
  331. $update_arr = [
  332. 'ck_num'=>(int)$val,
  333. ];
  334. }elseif($column == 'drck'){
  335. $update_arr = [
  336. 'drck'=>(int)$val,
  337. ];
  338. }else{
  339. echo json_encode(['msg'=>'修改信息不合规','success'=>false]);
  340. exit;
  341. }
  342. $r = $this->bhsq->save($update_arr,$id);
  343. if($r){
  344. echo json_encode(['msg'=>'修改成功','success'=>true]);
  345. }else{
  346. echo json_encode(['msg'=>'修改失败','success'=>false]);
  347. }
  348. exit;
  349. }else{
  350. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  351. }
  352. }
  353. private function _dyapplyexcel(){
  354. if($this->input->method() === 'post'){
  355. $data = $this->input->post('list',true);
  356. if(empty($data)){
  357. $json_data = $this->input->raw_input_stream;
  358. $tmp_data = json_decode($json_data,true);
  359. $data = $tmp_data['list'];
  360. if(empty($data)){
  361. echo json_encode(['success'=>false,'msg'=>'未获取要保存的数据']);
  362. exit;
  363. }
  364. }
  365. $shop_list = $this->shop->find_all("1=1","id,shortname,type");
  366. $shop_list = array_column($shop_list,null,'shortname');
  367. $time = strtotime(date("Y-m-d"),time());
  368. $info = $this->bhsq->find("real_time >= ".$time,"*",'id desc');
  369. if(empty($info)){
  370. $num = 1;
  371. }else{
  372. $arr = explode('-',$info['sb_no']);
  373. $num = (int)$arr[2]+1;
  374. }
  375. $time = time();
  376. $num = str_pad($num, 3, '0', STR_PAD_LEFT);
  377. $sb_no = "SQ-".date("ymd")."-".$num;
  378. $insert_arr = [];
  379. $error_list= [];
  380. foreach($data as $k=>$v){
  381. $shopshortname = trim($v[4]);
  382. if($shopshortname == '无'){
  383. $shop_info = [
  384. 'id'=>0,
  385. 'type'=>0,
  386. ];
  387. }else{
  388. $shop_info = isset($shop_list[$shopshortname])?$shop_list[$shopshortname]:[];
  389. if(empty($shop_info)){
  390. $error_list[] = [
  391. 'msg'=>"第".($k+1).'行店铺不存在,请核对表格信息'.$shopshortname,
  392. ];
  393. continue;
  394. }
  395. }
  396. $num = (int)$v[3];
  397. if(empty($num)){
  398. $error_list[] = [
  399. 'msg'=>"第".($k+1).'行数量不能为空,请核对表格信息',
  400. ];
  401. continue;
  402. }
  403. $tmp_time = trim($v[0]);
  404. if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $tmp_time)) {
  405. $add_time = strtotime($tmp_time);
  406. }else{
  407. $error_list[] = [
  408. 'msg'=>"第".($k+1).'行日期格式不正确,请核对表格信息',
  409. ];
  410. continue;
  411. }
  412. if(empty($v[5])){
  413. $error_list[] = [
  414. 'msg'=>"第".($k+1).'行申请人信息不能为空,请核对表格信息',
  415. ];
  416. continue;
  417. }
  418. if(empty($v[1])){
  419. $error_list[] = [
  420. 'msg'=>"第".($k+1).'行产品信息不能为空,请核对表格信息',
  421. ];
  422. continue;
  423. }
  424. $insert_arr[] = [
  425. 'sb_no'=>$sb_no,
  426. 'sku'=>trim($v[2]),
  427. 'title'=>trim($v[1]),
  428. 'shop_id'=>$shop_info['id'],
  429. 'plat_id'=>$shop_info['type'],
  430. 'sqr'=>trim($v[5]),
  431. 'sq_num'=>$num,
  432. 'ccwl_num'=>$num,
  433. 'ck_num'=>$num,
  434. 'sq_status'=>1,
  435. 'remark'=>$v[6],
  436. 'add_time'=>$add_time,
  437. 'real_time'=>$time,
  438. 'update_time'=>$time,
  439. ];
  440. }
  441. $r =$this->db->insert_batch('bhsq',$insert_arr);
  442. if($r){
  443. if(empty($error_list)){
  444. echo json_encode(['success'=>true,'msg'=>'添加成功']);
  445. }else{
  446. echo json_encode(['success'=>true,'msg'=>'添加成功','error_list'=>$error_list]);
  447. }
  448. }else{
  449. echo json_encode(['success'=>false,'msg'=>'添加失败','error_list'=>$error_list]);
  450. }
  451. exit;
  452. }else{
  453. echo json_encode(['success'=>true,'msg'=>'请求失败']);
  454. exit;
  455. }
  456. }
  457. //仓储物流部的备货申请单的列表
  458. private function _ccwlshlist(){
  459. if($this->input->method() === 'post'){
  460. $vip_id = $this->input->post('vip_id',true);
  461. $page = $this->input->post('page',true);
  462. $perpage = $this->input->post('perpage',true);
  463. $sqr = $this->input->post('sqr',true);
  464. $sqr = trim($sqr);
  465. $shop_id = $this->input->post('shop_id',true);
  466. $plat_id = $this->input->post('plat_id',true);
  467. $shop_ids = $this->input->post('shop_ids',true);
  468. $ktime = $this->input->post('ktime',true);
  469. $jtime = $this->input->post('jtime',true);
  470. $ktime = strtotime($ktime);
  471. $jtime = strtotime($jtime);
  472. $where = "sq_status = 2 and ccwl_status = 0 ";
  473. $where .= " and add_time >= ".$ktime." and add_time < ".$jtime." ";
  474. if(!empty($sqr)){
  475. $where .= " and sqr = '".$sqr."' ";
  476. }
  477. if(!empty($shop_id)){
  478. $where .= " and shop_id = ".$shop_id." ";
  479. }else{
  480. if($vip_id == 1){
  481. }else{
  482. $where .= " and shop_id in (".$shop_ids.") ";
  483. }
  484. }
  485. if(!empty($plat_id)){
  486. $where .= " and plat_id = ".$plat_id." ";
  487. }
  488. //数据排序
  489. $order_str = "id desc";
  490. if(empty($page))
  491. {
  492. $start = 0;
  493. $perpage = 1;
  494. }
  495. else
  496. {
  497. $start = ($page - 1)*$perpage;
  498. }
  499. $list = $this->bhsq->find_all($where,"id,shop_id,plat_id,title,sku,sqr,sq_num,ccwl_num,add_time,update_time,erp_check",$order_str,$start,$perpage);
  500. if(empty($list)){
  501. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  502. echo json_encode($rows);exit;
  503. }
  504. $shop_list = $this->shop->find_all("1=1","id,shopname");
  505. $shop_list = array_column($shop_list,'shopname','id');
  506. $plat_list = $this->typeclass->find_all("classid = 32","id,title");
  507. $plat_list = array_column($plat_list,'title','id');
  508. foreach($list as $k=>$v){
  509. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"无";
  510. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"无";
  511. $list[$k]['add_time'] = date("Y-m-d",$v['add_time']);
  512. if($v['erp_check'] == 1){
  513. $list[$k]['sku'] = "<i style='color:red'>".$v['sku']."</i> <i class='fa fa-edit' data-id='".$v['id']."' data-sku='".$v['sku']."' onclick='edit_sku(this)'></i>";
  514. }else{
  515. $list[$k]['sku'] = $v['sku']." <i class='fa fa-edit' data-id='".$v['id']."' data-sku='".$v['sku']."' onclick='edit_sku(this)'></i>";
  516. }
  517. $list[$k]['ccwl_num'] = $v['ccwl_num']." <i class='fa fa-edit' data-id='".$v['id']."' data-num='".$v['ccwl_num']."' onclick='edit_ccwl(this)'></i>";
  518. $list[$k]['update_time'] = "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color:#4169E1;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='3' onclick='update_status(this)'>驳回</a>";
  519. unset($list[$k]['erp_check']);
  520. }
  521. $total = $this->bhsq->find_count($where);
  522. $pagenum = ceil($total/$perpage);
  523. $over = $total-($start+$perpage);
  524. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  525. echo json_encode($rows);exit;
  526. }else{
  527. $user = $this->user->get_api($_SESSION['api']);
  528. $usersp = explode('|',trim($user['shop'],'|'));
  529. $this->data['usersp'] = implode(",",$usersp);
  530. $vip_id = 0;
  531. if(in_array($user['id'],[10,28])){
  532. $vip_id = 1;
  533. }
  534. $this->data['vip_id'] = $vip_id;
  535. $this->_Template('beihuogl_ccwlshlist',$this->data);
  536. }
  537. }
  538. //一键校验选中SKU
  539. private function _ccwlskucheck(){
  540. if($this->input->method() === 'post'){
  541. $data = $this->input->post();
  542. if(empty($data['arr_id'])){
  543. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  544. exit;
  545. }
  546. $list = $this->bhsq->find_all('id in ('.implode(',',$data['arr_id']).')');
  547. $error_list = [];
  548. $success_ids = [];
  549. $errors_ids = [];
  550. foreach($list as $k=>$v){
  551. if(empty($v['sku'])){
  552. $error_list[] = [
  553. 'msg'=>$v['value'].'请录入SKU',
  554. ];
  555. $errors_ids[] = $v['id'];
  556. continue;
  557. }
  558. $num = $this->goods->find_count("sku = '".$v['sku']."'");
  559. if(!empty($num)){
  560. $success_ids[] = $v['id'];
  561. continue;
  562. }
  563. $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc');
  564. if(empty($whlabel_info)){
  565. $error_list[] = [
  566. 'msg'=>$v['sku'].'未在进销存浏览那找到对应信息',
  567. ];
  568. $errors_ids[] = $v['id'];
  569. }
  570. }
  571. $this->db->where_in('id', $errors_ids);
  572. $this->db->update('bhsq', ['erp_check'=>1]);
  573. $this->db->where_in('id', $success_ids);
  574. $this->db->update('bhsq', ['erp_check'=>0]);
  575. if(empty($error_list)){
  576. echo json_encode(['success'=>true,'msg'=>'校验成功,没有异常信息']);
  577. exit;
  578. }else{
  579. echo json_encode(['success'=>true,'msg'=>'校验失败,请核对填写信息','error_list'=>$error_list]);
  580. exit;
  581. }
  582. }else{
  583. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  584. exit;
  585. }
  586. }
  587. //仓储物流合成备货单
  588. private function _ccwlbhmake(){
  589. if($this->input->method() === 'post'){
  590. $data = $this->input->post();
  591. $bh_no = $data['bh_no'];
  592. $select_id = $data['arr_id'];
  593. if(empty($select_id)){
  594. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  595. exit;
  596. }
  597. if(empty($bh_no)){
  598. $tmp_time = strtotime(date("Y-m-d"),time());
  599. $num = $this->bhccwl->find_count("create_time >= ".$tmp_time);
  600. $num = $num+1;
  601. $num = str_pad($num, 3, '0', STR_PAD_LEFT);
  602. $bh_no = "BH-".date("ymd")."-".$num;
  603. }
  604. $list = $this->bhsq->find_all('id in ('.implode(',',$select_id).')');
  605. foreach($list as $k=>$v){
  606. if(empty($v['sku'])){
  607. echo json_encode(['success'=>false,'msg'=>'提交的数据中有的sku为空,请核对填写信息']);
  608. exit;
  609. }
  610. }
  611. $classid = $this->logic_u9tools->getClass();
  612. $typeclass = $this->logic_u9tools->getTypeClass();
  613. foreach($list as $k=>$v){
  614. $whlabel_info = $this->goods->find("sku = '".$v['sku']."'",'sku,features,jm','id desc');
  615. if(empty($whlabel_info)){
  616. $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc');
  617. if(empty($whlabel_info)){
  618. echo json_encode(['success'=>false,'msg'=>$v['sku'].'未在进销存浏览那找到对应信息']);
  619. exit;
  620. }
  621. $r = $this->logic_u9tools->getOneU9bmHasGift($whlabel_info['features'],$classid,$typeclass);
  622. $this->bhsq->save([
  623. 'jm'=>$r['jm'],
  624. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  625. 'features'=>$whlabel_info['features'],
  626. ],$v['id']);
  627. }else{
  628. $this->bhsq->save([
  629. 'jm'=>$whlabel_info['jm'],
  630. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  631. 'features'=>$whlabel_info['features'],
  632. ],$v['id']);
  633. }
  634. }
  635. $this->db->trans_start();
  636. $this->db->where_in('id',$select_id);
  637. $this->db->update('bhsq',[
  638. 'bh_no'=>$bh_no,
  639. 'sq_status'=>4,
  640. 'ccwl_status'=>1,
  641. ]);
  642. $this->db->select('SUM(ccwl_num) as total_ccwl_num');
  643. $this->db->where_in('id',$select_id);
  644. $query = $this->db->get('bhsq');
  645. $result = $query->row();
  646. $total_ccwl_num = $result->total_ccwl_num? $result->total_ccwl_num:0;
  647. $time = time();
  648. $this->bhccwl->insert([
  649. 'bh_no'=>$bh_no,
  650. 'status'=>0,
  651. 'num'=>$total_ccwl_num,
  652. 'create_time'=>$time,
  653. 'update_time'=>$time,
  654. ]);
  655. if($this->db->trans_status() === FALSE){
  656. $this->db->trans_rollback();
  657. echo json_encode(['success'=>false,'msg'=>'生成备货单失败']);
  658. exit;
  659. }else{
  660. $this->db->trans_commit();
  661. echo json_encode(['success'=>true,'msg'=>'生成备货单成功']);
  662. exit;
  663. }
  664. }else{
  665. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  666. exit;
  667. }
  668. }
  669. private function getU9Drck($features){
  670. if(stripos($features,'-126-') !== false)
  671. {
  672. $drck = '12003';//进入发条库
  673. }
  674. else if(stripos($features,'-127-') !== false)
  675. {
  676. $drck = '12004';//进入发块库
  677. }
  678. else
  679. {
  680. $drck = '12006';//其它进入完成库
  681. }
  682. return $drck;
  683. }
  684. //仓储物流部的备货单列表
  685. private function _ccwlbhindex(){
  686. if($this->input->method() === 'post'){
  687. $page = $this->input->post('page',true);
  688. $perpage = $this->input->post('perpage',true);
  689. $bh_no = $this->input->post('bh_no',true);
  690. $status = $this->input->post('status',true);
  691. $ktime = $this->input->post('ktime',true);
  692. $jtime = $this->input->post('jtime',true);
  693. $ktime = strtotime($ktime);
  694. $jtime = strtotime($jtime);
  695. $where = "create_time >= ".$ktime." and create_time < ".$jtime." ";
  696. if(!empty($bh_no)){
  697. $where .= " and bh_no = '".$bh_no."' ";
  698. }
  699. if($status > -1){
  700. $where .= " and status = ".$status." ";
  701. }
  702. //数据排序
  703. $order_str = "id desc";
  704. if(empty($page))
  705. {
  706. $start = 0;
  707. $perpage = 1;
  708. }
  709. else
  710. {
  711. $start = ($page - 1)*$perpage;
  712. }
  713. $list = $this->bhccwl->find_all($where,"id,bh_no,status,create_time,public_time,update_time",$order_str,$start,$perpage);
  714. if(empty($list)){
  715. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  716. echo json_encode($rows);exit;
  717. }
  718. $status_list = $this->bhccwl->getStatus();
  719. foreach($list as $k=>$v){
  720. $list[$k]['status'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
  721. $list[$k]['create_time'] = date("Y-m-d",$v['create_time']);
  722. $list[$k]['public_time'] = empty($v['public_time'])?"":date("Y-m-d",$v['public_time']);
  723. $str = "";
  724. if($v['status'] == 0){
  725. $str .= "<div style='text-align:center;'>";
  726. $str .= "<a href='javascript:void(0)'class='window' data-h='/beihuogl/ccwlbhedit/".$v['id']."' data-t='修改' style='margin-right:4px;color: #fff;background-color:#228B22;padding:4px 10px;border-radius:5px;font-size:15px'>编辑</a>";
  727. $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color:#4169E1;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='1' onclick='update_status(this)'>发布</a>";
  728. $str .= "</div>";
  729. }
  730. $list[$k]['update_time'] = $str;
  731. }
  732. $total = $this->bhccwl->find_count($where);
  733. $pagenum = ceil($total/$perpage);
  734. $over = $total-($start+$perpage);
  735. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  736. echo json_encode($rows);exit;
  737. }else{
  738. $this->_Template('beihuogl_ccwlbhindex',$this->data);
  739. }
  740. }
  741. //仓储物流部备货 在编辑页面添加数据
  742. private function _ccwlbhsavexzbh(){
  743. if($this->input->method() === 'post'){
  744. $data = $this->input->post();
  745. $select_id = $data['select_id'];
  746. $id = $data['id'];
  747. $bh_no = $data['bh_no'];
  748. if(empty($select_id)){
  749. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  750. exit;
  751. }
  752. $info = $this->bhccwl->read($id);
  753. if(empty($info)){
  754. echo json_encode(['success'=>false,'msg'=>'数据不存在']);
  755. exit;
  756. }
  757. if($info['bh_no'] != $bh_no){
  758. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);
  759. exit;
  760. }
  761. $bh_no = $info['bh_no'];
  762. $list = $this->bhsq->find_all('id in ('.implode(',',$select_id).') ' );
  763. foreach($list as $k=>$v){
  764. if(empty($v['sku'])){
  765. echo json_encode(['success'=>false,'msg'=>'提交的数据中有的sku为空,请核对填写信息']);
  766. exit;
  767. }
  768. if(!empty($v['bh_no'])){
  769. echo json_encode(['success'=>false,'msg'=>'提交的数据中有的已经被调用,请联系技术核对']);
  770. exit;
  771. }
  772. }
  773. $classid = $this->logic_u9tools->getClass();
  774. $typeclass = $this->logic_u9tools->getTypeClass();
  775. foreach($list as $k=>$v){
  776. $whlabel_info = $this->goods->find("sku = '".$v['sku']."'",'sku,features,jm','id desc');
  777. if(empty($whlabel_info)){
  778. $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc');
  779. if(empty($whlabel_info)){
  780. echo json_encode(['success'=>false,'msg'=>$v['sku'].'未在进销存浏览那找到对应信息']);
  781. exit;
  782. }
  783. if(empty($v['jm'])){
  784. $r = $this->logic_u9tools->getOneU9bmHasGift($whlabel_info['features'],$classid,$typeclass);
  785. $this->bhsq->save([
  786. 'jm'=>$r['jm'],
  787. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  788. 'features'=>$whlabel_info['features'],
  789. ],$v['id']);
  790. }
  791. $list[$k]['jm'] = $r['jm'];
  792. }else{
  793. $this->bhsq->save([
  794. 'jm'=>$whlabel_info['jm'],
  795. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  796. 'features'=>$whlabel_info['features'],
  797. ],$v['id']);
  798. $list[$k]['jm'] = $whlabel_info['jm'];
  799. }
  800. }
  801. $status_list = $this->bhccwl->getStatus();
  802. $info['status_show'] = isset($status_list[$info['status']])?$status_list[$info['status']]:"";
  803. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  804. $plat_list = array_column($plat_list,'title','id');
  805. $shop_list = $this->shop->find_all("1=1","id,shopname");
  806. $shop_list = array_column($shop_list,'shopname','id');
  807. foreach($list as $k=>$v){
  808. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  809. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"";
  810. $list[$k]['public_time'] = date("Y-m-d",$v['public_time']);
  811. $list[$k]['bh_no'] = $info['bh_no'];
  812. }
  813. echo json_encode(['success'=>true,'msg'=>'编辑成功','data'=>$list]);exit;
  814. }else{
  815. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  816. exit;
  817. }
  818. }
  819. private function _ccwlbhedit($arg_array){
  820. if($this->input->method() === 'post'){
  821. $select_id = $this->input->post('arr_id',true);
  822. if(empty($select_id)){
  823. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  824. exit;
  825. }
  826. $id = $this->input->post('id',true);
  827. $info = $this->bhccwl->read($id);
  828. $bh_no = $info['bh_no'];
  829. $this->db->where_in('id',$select_id);
  830. $this->db->update('bhsq',[
  831. 'bh_no'=>$bh_no,
  832. 'sq_status'=>4,
  833. 'ccwl_status'=>1,
  834. ]);
  835. $this->db->select('SUM(ccwl_num) as total_ccwl_num');
  836. $this->db->where_in('id',$select_id);
  837. $query = $this->db->get('bhsq');
  838. $result = $query->row();
  839. $total_ccwl_num = $result->total_ccwl_num? $result->total_ccwl_num:0;
  840. $time = time();
  841. $this->bhccwl->save([
  842. 'num'=>$total_ccwl_num,
  843. 'update_time'=>$time,
  844. ],$info['id']);
  845. echo json_encode(['success'=>true,'msg'=>'修改成功']);exit;
  846. }else{
  847. $id = $arg_array[0];
  848. $info = $this->bhccwl->find("id = ".$id);
  849. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' and sq_status = 4 and ccwl_status = 1");
  850. $status_list = $this->bhccwl->getStatus();
  851. $info['status_show'] = isset($status_list[$info['status']])?$status_list[$info['status']]:"";
  852. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  853. $plat_list = array_column($plat_list,'title','id');
  854. $shop_list = $this->shop->find_all("1=1","id,shopname");
  855. $shop_list = array_column($shop_list,'shopname','id');
  856. foreach($list as $k=>$v){
  857. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  858. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"";
  859. $list[$k]['public_time'] = date("Y-m-d",$v['public_time']);
  860. }
  861. // $this->data['info'] = $info;
  862. $this->data['list'] = $list;
  863. $this->data['info'] = $info;
  864. $this->_Template('beihuogl_ccwlbhedit',$this->data);
  865. }
  866. }
  867. private function _ccwldelitem(){
  868. if($this->input->method() === 'post'){
  869. $data = $this->input->post();
  870. $id = $data['id'];
  871. $bh_no = $data['bh_no'];
  872. $info = $this->bhsq->read($id);
  873. $ccwl_num = $info['ccwl_num'];
  874. if(empty($info)){
  875. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  876. }
  877. if(empty($info['bh_no'])){
  878. if($info['sq_status'] == 2 && $info['ccwl_status'] == 0){
  879. echo json_encode(['success'=>true,'msg'=>'删除成功']);exit;
  880. }else{
  881. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit;
  882. }
  883. }
  884. if($info['bh_no'] != $bh_no){
  885. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit;
  886. }
  887. $ccwl_info = $this->bhccwl->find("bh_no = '".$info['bh_no']."'");
  888. $ccwl_info['num'] = $ccwl_info['num'] - $ccwl_num;
  889. $this->db->trans_start();
  890. $this->bhccwl->save([
  891. 'num'=>$ccwl_info['num'],
  892. ],$ccwl_info['id']);
  893. $this->bhsq->save([
  894. 'sq_status'=>2,
  895. 'ccwl_status'=>0,
  896. 'bh_no'=>''
  897. ],$id);
  898. if($this->db->trans_status() === FALSE){
  899. $this->db->trans_rollback();
  900. echo json_encode(['success'=>false,'msg'=>'删除失败']);exit;
  901. }else{
  902. $this->db->trans_commit();
  903. echo json_encode(['success'=>true,'msg'=>'删除成功']);exit;
  904. }
  905. }else{
  906. echo json_encode(['success'=>false,'msg'=>'请求失败']);exit;
  907. }
  908. }
  909. private function _ccwleditxzbh(){
  910. if($this->input->method() === 'post'){
  911. $data = $this->input->post();
  912. //超过三月没审核的 就不展示了
  913. $time = time() - 60*24*3600;
  914. $where = "sq_status = 2 and ccwl_status = 0 and public_time > ".$time." ";
  915. if(!empty($data['sqr'])){
  916. $where .= " and sqr = '".$data['sqr']."' ";
  917. }
  918. if(!empty($data['shop_id'])){
  919. $where .= " and shop_id = ".$data['shop_id']." ";
  920. }
  921. if(!empty($data['plat_id'])){
  922. $where .= " and plat_id = ".$data['plat_id']." ";
  923. }
  924. if(!empty($data['sku'])){
  925. $where .= " and sku = '".$data['sku']."' ";
  926. }
  927. $order_str = "id desc";
  928. $list = $this->bhsq->find_all($where,"*",$order_str,0,20);
  929. $shop_list = $this->shop->find_all("1=1","id,shopname");
  930. $shop_list = array_column($shop_list,'shopname','id');
  931. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  932. $plat_list = array_column($plat_list,'title','id');
  933. foreach($list as $k=>$v){
  934. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  935. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"";
  936. $list[$k]['public_time'] = date("Y-m-d",$v['public_time']);
  937. }
  938. if(empty($list)){
  939. echo json_encode(['success'=>false,'msg'=>'查询失败']);exit;
  940. }else{
  941. echo json_encode(['success'=>true,'msg'=>'查询成功','data'=>$list]);exit;
  942. }
  943. }else{
  944. $data = $this->input->get();
  945. $this->data['id'] = $data['id'];
  946. $this->data['bh_no'] = $data['bh_no'];
  947. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  948. $this->data['plat_list'] = $plat_list;
  949. $this->_Template('beihuogl_ccwleditxzbh',$this->data);
  950. }
  951. }
  952. private function _ccwlbhsave(){
  953. if($this->input->method() === 'post'){
  954. $data = $this->input->post();
  955. $id = $data['id'];
  956. $val = $data['val'];
  957. $column = $data['column'];
  958. $update_arr = [];
  959. if($column == 'status'){
  960. $update_arr = [
  961. 'status'=>(int)$val,
  962. 'update_time'=>time(),
  963. 'public_time'=>time(),
  964. ];
  965. }else{
  966. echo json_encode(['success'=>false,'msg'=>'请求参数未设置']);exit;
  967. }
  968. $r = $this->bhccwl->save($update_arr,$id);
  969. if($r){
  970. echo json_encode(['success'=>true,'msg'=>'修改成功']);exit;
  971. }else{
  972. echo json_encode(['success'=>false,'msg'=>'修改失败']);exit;
  973. }
  974. }else{
  975. echo json_encode(['success'=>false,'msg'=>'请求失败']);exit;
  976. }
  977. }
  978. //仓库的备货单列表
  979. private function _ckbhindex(){
  980. if($this->input->method() === 'post'){
  981. $page = $this->input->post('page',true);
  982. $perpage = $this->input->post('perpage',true);
  983. $bh_no = $this->input->post('bh_no',true);
  984. $status = $this->input->post('status',true);
  985. $ktime = $this->input->post('ktime',true);
  986. $jtime = $this->input->post('jtime',true);
  987. $ktime = strtotime($ktime);
  988. $jtime = strtotime($jtime);
  989. $where = "public_time >= ".$ktime." and public_time < ".$jtime." and status = 1 ";
  990. if(!empty($bh_no)){
  991. $where .= " and bh_no = '".$bh_no."' ";
  992. }
  993. if($status > -1){
  994. $where .= " and status = ".$status." ";
  995. }
  996. //数据排序
  997. $order_str = "id desc";
  998. if(empty($page))
  999. {
  1000. $start = 0;
  1001. $perpage = 1;
  1002. }
  1003. else
  1004. {
  1005. $start = ($page - 1)*$perpage;
  1006. }
  1007. $list = $this->bhccwl->find_all($where,"id,bh_no,ck_status,public_time,ckpublic_time",$order_str,$start,$perpage);
  1008. if(empty($list)){
  1009. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  1010. echo json_encode($rows);exit;
  1011. }
  1012. $status_list = $this->bhccwl->getCkStatus();
  1013. foreach($list as $k=>$v){
  1014. $list[$k]['bh_no'] = "<h9 class='window' data-h='/beihuogl/showckbh/".$v['id']."' data-t='订单号:".$v['bh_no']."'><p>".$v['bh_no']."</p></h9>";
  1015. $list[$k]['ck_status'] = isset($status_list[$v['ck_status']])?$status_list[$v['ck_status']]:"";
  1016. $list[$k]['public_time'] = empty($v['public_time'])?"":date("Y-m-d",$v['public_time']);
  1017. $list[$k]['ckpublic_time'] = empty($v['ckpublic_time'])?"":date("Y-m-d",$v['ckpublic_time']);
  1018. $str = "";
  1019. if($v['ck_status'] == 0){
  1020. $str .= "<div style='text-align:center;'>";
  1021. $str .= "<a href='javascript:void(0)'class='window' data-h='/beihuogl/ckbhedit/".$v['id']."' data-t='修改' style='margin-right:4px;color: #fff;background-color:#228B22;padding:4px 10px;border-radius:5px;font-size:15px'>审核</a>";
  1022. // $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color:#4169E1;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='1' onclick='update_status(this)'>审核</a>";
  1023. $str .= "</div>";
  1024. }
  1025. if($v['ck_status'] == 1 || $v['ck_status'] == 2){
  1026. $str .= "<div style='text-align:center;'>";
  1027. $str .= "<a href='javascript:void(0)' class='window' data-h='/beihuogl/makeu9scd/".$v['id']."' data-t='修改' style='margin-right:4px;color: #fff;background-color:#0099FF;padding:4px 10px;border-radius:5px;font-size:15px' >生成u9生产单</a>";
  1028. $str .= "</div>";
  1029. }
  1030. if($v['ck_status'] > 2){
  1031. $str .= "<div style='text-align:center;'>";
  1032. $str .= "<a href='/beihuogl/u9scdexcel/".$v['id']."' data-t='修改' style='margin-right:4px;color: #fff;background-color:#D2691E;padding:4px 10px;border-radius:5px;font-size:15px' >生产单EXCEL下载</a>";
  1033. $str .= "</div>";
  1034. }
  1035. $list[$k]['update_time'] = $str;
  1036. }
  1037. $total = $this->bhccwl->find_count($where);
  1038. $pagenum = ceil($total/$perpage);
  1039. $over = $total-($start+$perpage);
  1040. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1041. echo json_encode($rows);exit;
  1042. }else{
  1043. $this->_Template('beihuogl_ckbhindex',$this->data);
  1044. }
  1045. }
  1046. private function _ckbhedit($arg_array){
  1047. if($this->input->method() === 'post'){
  1048. $id = $this->input->post('id',true);
  1049. $bh_no = $this->input->post('bh_no',true);
  1050. $info = $this->bhccwl->read($id);
  1051. if(empty($info)){
  1052. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1053. }
  1054. if($info['ck_status'] == 0 && $info['status'] == 1){
  1055. }else{
  1056. echo json_encode(['success'=>false,'msg'=>'状态不对,不可审核']);exit;
  1057. }
  1058. if($info['bh_no'] != $bh_no){
  1059. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit;
  1060. }
  1061. $num = 0;
  1062. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1063. foreach($list as $k=>$v){
  1064. $num += $v['ck_num'];
  1065. }
  1066. $r = $this->bhccwl->save([
  1067. 'ck_status'=>1,
  1068. 'ck_num'=>$num,
  1069. 'update_time'=>time(),
  1070. 'ckpublic_time'=>time(),
  1071. ],$id);
  1072. if($r){
  1073. echo json_encode(['success'=>true,'msg'=>'审核成功']);exit;
  1074. }else{
  1075. echo json_encode(['success'=>false,'msg'=>'审核失败']);exit;
  1076. }
  1077. }else{
  1078. $id = $arg_array[0];
  1079. $info = $this->bhccwl->find("id = ".$id);
  1080. $status_list = $this->bhccwl->getCkStatus();
  1081. $info['ck_status_show'] = isset($status_list[$info['ck_status']])?$status_list[$info['ck_status']]:"";
  1082. $drck_list = $this->bhccwl->getDrck();
  1083. $this->data['drck_list'] = $drck_list;
  1084. $this->data['drck_json'] = json_encode($drck_list);
  1085. $this->data['info'] = $info;
  1086. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."'");
  1087. $shop_list = $this->shop->find_all("1=1","id,shopname");
  1088. $shop_list = array_column($shop_list,'shopname','id');
  1089. foreach($list as $k=>$v){
  1090. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  1091. $list[$k]['drck_show'] = isset($drck_list[$v['drck']])?$drck_list[$v['drck']]:"";
  1092. }
  1093. $this->data['list'] = $list;
  1094. $this->_Template('beihuogl_ckbhedit',$this->data);
  1095. }
  1096. }
  1097. private function _makeu9scd($arg_array){
  1098. if($this->input->method() === 'post'){
  1099. $data = $this->input->post(null,true);
  1100. $info = $this->bhccwl->read($data['id']);
  1101. if(empty($info)){
  1102. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1103. }
  1104. if($info['ck_status'] == 1 && $info['status'] == 1){
  1105. }else{
  1106. echo json_encode(['success'=>false,'msg'=>'状态不对,不可生成u9生产单']);
  1107. exit;
  1108. }
  1109. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' and is_u9sc = 0 ");
  1110. $params = [
  1111. 'org_code'=>"120",//组织代码 龙盈工厂
  1112. 'djhlx'=>'2000',//单号类型 备货生产单
  1113. 'scbm_code'=>"12008",//龙盈生产部门
  1114. "time"=>time(),
  1115. 'owner_org_code'=>"120",
  1116. 'title'=>$info['bh_no'],
  1117. 'shipremarks'=>$info['bh_no'],
  1118. ];
  1119. $final_list = [];
  1120. foreach($list as $k=>$v){
  1121. $final_list[] =[
  1122. 'do_id'=>$v['id'],
  1123. 'drck'=>$v['drck'],
  1124. 'jm'=>$v['jm'],
  1125. 'sl'=>$v['ck_num'],
  1126. ];
  1127. }
  1128. $params['list'] = $final_list;
  1129. $token = $this->settingtest->get_yytoken_120();
  1130. $res = $this->apiyyv1->scdCreate($params,$token);
  1131. if(empty($res[0]['Data'])){
  1132. $this->logic_ding->sendToDing("生成u9生产单失败,错误信息:".json_encode($res,JSON_UNESCAPED_UNICODE));
  1133. echo json_encode(['success'=>false,'msg'=>'生成u9生产单失败']);exit;
  1134. }
  1135. $this->logic_ding->sendToDing("生成u9生产单成功,进行记录:".json_encode($res,JSON_UNESCAPED_UNICODE));
  1136. $r_s_list = $res[0]['Data'];
  1137. foreach($list as $k=>$v){
  1138. $list[$k]['u9_data'] = $r_s_list[$k];
  1139. }
  1140. //m_isSucess
  1141. $flag_status = 0;//判断是否有创建失败的
  1142. $u9sc_status = 0;//判断是否有创建成功的
  1143. foreach($list as $k=>$v){
  1144. if($v['u9_data']['m_isSucess']== 1){
  1145. $u9sc_status += 1;
  1146. $this->bhsq->save([
  1147. 'is_u9sc'=>1,
  1148. 'u9sc_no'=>$v['u9_data']['m_code'],
  1149. ],$v['id']);
  1150. }else{
  1151. $flag_status += 0;
  1152. $this->bhsq->save([
  1153. 'u9sc_remark'=>$v['u9_data']['m_errorMsg'],
  1154. ],$v['id']);
  1155. }
  1156. }
  1157. $len = count($list);
  1158. //都创建失败了 就直接gg
  1159. if($u9sc_status == 0){
  1160. echo json_encode(['success'=>false,'msg'=>'生成u9生产单失败']);exit;
  1161. }
  1162. if(($u9sc_status < $len) && ( $flag_status< $len) ){
  1163. $this->bhccwl->save([
  1164. 'ck_status'=>2,
  1165. ],$info['id']);
  1166. echo json_encode(['success'=>true,'msg'=>'生成u9生产单部分成功']);exit;
  1167. }
  1168. if($u9sc_status == $len){
  1169. $this->bhccwl->save([
  1170. 'ck_status'=>3,
  1171. ],$info['id']);
  1172. echo json_encode(['success'=>true,'msg'=>'生成u9生产单成功']);exit;
  1173. }
  1174. echo json_encode(['success'=>false,'msg'=>'代码异常']);exit;
  1175. }else{
  1176. $id = $arg_array[0];
  1177. $info = $this->bhccwl->read($id);
  1178. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1179. $shop_list = $this->shop->find_all("1=1","id,shopname");
  1180. $shop_list = array_column($shop_list,'shopname','id');
  1181. $drck_list = $this->bhccwl->getDrck();
  1182. $status_list = $this->bhccwl->getCkStatus();
  1183. $info['ck_status_show'] = isset($status_list[$info['ck_status']])?$status_list[$info['ck_status']]:"";
  1184. foreach($list as $k=>$v){
  1185. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  1186. $list[$k]['drck_show'] = isset($drck_list[$v['drck']])?$drck_list[$v['drck']]:"";
  1187. }
  1188. $this->data['list'] = $list;
  1189. $this->data['info'] = $info;
  1190. $this->_Template('beihuogl_makeu9scd',$this->data);
  1191. }
  1192. }
  1193. private function _ddscscd(){
  1194. if($this->input->method() === 'post'){
  1195. $id = $this->input->post('id',true);
  1196. $bh_no = $this->input->post('bh_no',true);
  1197. $bhsq_info = $this->bhsq->read($id);
  1198. $bhccwl_info = $this->bhccwl->find("bh_no = '".$bhsq_info['bh_no']."' ");
  1199. if(empty($bhccwl_info)){
  1200. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1201. }
  1202. // if($bhccwl_info['ck_status'] != 1){
  1203. // echo json_encode(['success'=>false,'msg'=>'状态不对,不可生成u9生产单']);
  1204. // exit;
  1205. // }
  1206. if(!in_array($bhccwl_info['ck_status'],[1,2])){
  1207. echo json_encode(['success'=>false,'msg'=>'状态不对,不可生成u9生产单']);
  1208. exit;
  1209. }
  1210. if(!empty($bhsq_info['u9sc_no'])){
  1211. echo json_encode(['success'=>false,'msg'=>'状态不允许生成生产单,有疑问联系技术处理']);
  1212. exit;
  1213. }
  1214. $params = [
  1215. 'org_code'=>"120",//组织代码 龙盈工厂
  1216. 'djhlx'=>'2000',//单号类型 备货生产单
  1217. 'scbm_code'=>"12008",//龙盈生产部门
  1218. "time"=>time(),
  1219. 'owner_org_code'=>"120",
  1220. 'title'=>$bhccwl_info['bh_no'],
  1221. 'shipremarks'=>$bhccwl_info['bh_no'],
  1222. ];
  1223. $list[] = [
  1224. 'do_id'=>$bhsq_info['id'],
  1225. 'drck'=>$bhsq_info['drck'],
  1226. 'jm'=>$bhsq_info['jm'],
  1227. 'sl'=>$bhsq_info['ck_num'],
  1228. ];
  1229. $params['list'] = $list;
  1230. $token = $this->settingtest->get_yytoken_120();
  1231. $res = $this->apiyyv1->scdCreate($params,$token);
  1232. if(empty($res[0]['Data'])){
  1233. echo json_encode(['success'=>false,'msg'=>'生成u9生产单失败']);exit;
  1234. }
  1235. if($res[0]['Data'][0]['m_isSucess']== 1){
  1236. $this->bhsq->save([
  1237. 'is_u9sc'=>1,
  1238. 'u9sc_no'=>$res[0]['Data'][0]['m_code'],
  1239. ],$bhsq_info['id']);
  1240. $tmp_list = $this->bhsq->find_all("bh_no = '".$bh_no."' and is_u9sc = 0 ");
  1241. if(empty($tmp_list)){
  1242. $tmp_status = 3;
  1243. }else{
  1244. $tmp_status = 2;
  1245. }
  1246. $this->bhccwl->save([
  1247. 'ck_status'=>$tmp_status,
  1248. ],$bhccwl_info['id']);
  1249. echo json_encode(['success'=>true,'msg'=>'生成u9生产单成功']);exit;
  1250. }else{
  1251. $this->bhsq->save([
  1252. 'u9sc_remark'=>$res[0]['Data'][0]['m_errorMsg'],
  1253. ],$bhsq_info['id']);
  1254. echo json_encode(['success'=>false,'msg'=>$res[0]['Data'][0]["m_errorMsg"]]);exit;
  1255. }
  1256. }else{
  1257. exit('No direct script access allowed');
  1258. }
  1259. }
  1260. private function _showckbh($arg_array){
  1261. if($this->input->method() === 'post'){
  1262. exit('No direct script access allowed');
  1263. }
  1264. $id = $arg_array[0];
  1265. $drck_list = $this->bhccwl->getDrck();
  1266. $shop_list = $this->shop->find_all("1=1","id,shopname");
  1267. $shop_list = array_column($shop_list,'shopname','id');
  1268. $info = $this->bhccwl->read($id);
  1269. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1270. $list_dcd = $this->bhdcd->find_all("bh_no = '".$info['bh_no']."' ");
  1271. foreach($list as $k=>$v){
  1272. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  1273. $list[$k]['drck_show'] = isset($drck_list[$v['drck']])?$drck_list[$v['drck']]:"";
  1274. }
  1275. $this->data['info'] = $info;
  1276. $this->data['list'] = $list;
  1277. $this->data['list_dcd'] = $list_dcd;
  1278. $this->_Template('beihuogl_showckbh',$this->data);
  1279. }
  1280. //仓库录入调出单
  1281. private function _ckdcd(){
  1282. if($this->input->method() === 'post'){
  1283. $lrdcd = $this->input->post('lrdcd',true);
  1284. if(empty($lrdcd)){
  1285. //列表展示
  1286. $page = $this->input->post('page',true);
  1287. $perpage = $this->input->post('perpage',true);
  1288. $bh_no = $this->input->post('bh_no',true);
  1289. $dcd_no = $this->input->post('dcd_no',true);
  1290. $status = $this->input->post('status',true);
  1291. $ktime = $this->input->post('ktime',true);
  1292. $jtime = $this->input->post('jtime',true);
  1293. $ktime = strtotime($ktime);
  1294. $jtime = strtotime($jtime);
  1295. $where = "create_time >= ".$ktime." and create_time < ".$jtime." ";
  1296. if(!empty($bh_no)){
  1297. $where .= " and bh_no = '".$bh_no."' ";
  1298. }
  1299. if($status > -1){
  1300. $where .= " and status = ".$status." ";
  1301. }
  1302. if(!empty($dcd_no)){
  1303. $where .= " and dcd_no = '".$dcd_no."' ";
  1304. }
  1305. //数据排序
  1306. $order_str = "id desc";
  1307. if(empty($page))
  1308. {
  1309. $start = 0;
  1310. $perpage = 1;
  1311. }
  1312. else
  1313. {
  1314. $start = ($page - 1)*$perpage;
  1315. }
  1316. $list = $this->bhdcd->find_all($where,"id,bh_no,dcd_no,drd_no,status,jm,num,kw,create_time,rk_time,is_rk",$order_str,$start,$perpage);
  1317. if(empty($list)){
  1318. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  1319. echo json_encode($rows);exit;
  1320. }
  1321. $status_list = $this->bhdcd->getStatus();
  1322. foreach($list as $k=>$v){
  1323. $list[$k]['dcd_no'] = "<h9 class='window' data-h='/beihuogl/ckbherprk/".$v['dcd_no']."' data-t='订单号:".$v['dcd_no']."'><p>".$v['dcd_no']."</p></h9>";
  1324. $list[$k]['status'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
  1325. $list[$k]['drd_no'] = empty($v['drd_no'])?"":$v['drd_no'];
  1326. $list[$k]['kw'] = empty($v['kw'])?"":$v['kw'];
  1327. $list[$k]['create_time'] = empty($v['create_time'])?"":date("Y-m-d",$v['create_time']);
  1328. $str = "";
  1329. if($v['is_rk'] == 0){
  1330. $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color:#DC143C;padding:4px 8px;border-radius:5px;font-size:13px' onclick='dcdjzrk(this)' data-id='".$v['id']."' data-num='".$v['num']."'>禁止入库</a>";
  1331. }
  1332. if(!empty($v['rk_time'])){
  1333. $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color:#D2691E;padding:4px 8px;border-radius:5px;font-size:13px' onclick='dybq(this)' data-id='".$v['id']."' >打印标签</a>";
  1334. }
  1335. $list[$k]['rk_time'] = $str;
  1336. unset($list[$k]['is_rk']);
  1337. }
  1338. $total = $this->bhdcd->find_count($where);
  1339. $pagenum = ceil($total/$perpage);
  1340. $over = $total-($start+$perpage);
  1341. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1342. echo json_encode($rows);exit;
  1343. }else{
  1344. if(empty($lrdcd)){
  1345. echo json_encode(['success'=>false,'msg'=>'调出单号不可以为空']);exit;
  1346. }
  1347. $num = $this->bhdcd->find("dcd_no = '".$lrdcd."'");
  1348. if(!empty($num)){
  1349. echo json_encode(['success'=>false,'msg'=>'调出单号已录入,不可重复录入']);exit;
  1350. }
  1351. //查询录入执行的调出单
  1352. $token = $this->settingtest->get_yytoken_120();
  1353. $res = $this->apiyyv1->cxDcdAboutErp($lrdcd,$token);
  1354. if(empty($res[0]['Data'])){
  1355. echo json_encode(['success'=>false,'msg'=>'请检查调出单号,未在u9获取相关信息']);exit;
  1356. }
  1357. $time = time();
  1358. $final_list = [];
  1359. foreach($res[0]['Data'] as $k=>$v){
  1360. $good_info = $this->goods->find("jm = '".$v['iteminfo_itemcode']."' ");
  1361. $tmp_sku = '';
  1362. $tmp_title = '';
  1363. $tmp_features = '';
  1364. $tmp_number='';
  1365. if(!empty($good_info)){
  1366. $tmp_sku = $good_info['sku'];
  1367. $tmp_title = $good_info['title'];
  1368. $tmp_features = $good_info['features'];
  1369. $tmp_number = str_replace("-","", $good_info['features']);
  1370. }
  1371. $final_list[] = [
  1372. 'sku'=>$tmp_sku,
  1373. 'dcd_no'=>$v['docno'],
  1374. 'jm'=>$v['iteminfo_itemcode'],
  1375. 'zh'=>$v['iteminfo_itemname'],
  1376. 'num'=>$v['costuomqty'],
  1377. 'real_num'=>$v['costuomqty'],
  1378. 'bh_no'=>$v['erp_no'],
  1379. 'create_time'=>$time,
  1380. 'title'=>$tmp_title,
  1381. 'features'=>$tmp_features,
  1382. 'number'=>$tmp_number,
  1383. ];
  1384. }
  1385. $r =$this->db->insert_batch('bhdcd',$final_list);
  1386. if($r){
  1387. echo json_encode(['success'=>true,'msg'=>'录入成功']);
  1388. }else{
  1389. echo json_encode(['success'=>false,'msg'=>'录入失败']);
  1390. }
  1391. exit;
  1392. }
  1393. }else{
  1394. $status_list = $this->bhdcd->getStatus();
  1395. $this->data['status_list'] = $status_list;
  1396. $this->_Template('beihuogl_ckdcd',$this->data);
  1397. }
  1398. }
  1399. private function _ckbherprk($arg_array){
  1400. if($this->input->method() === 'post'){
  1401. $data = $this->input->post(null,true);
  1402. $dcd_no = $data['dcd_no'];
  1403. $drd_no = $data['drd_no'];
  1404. $list = $this->bhdcd->find_all("dcd_no = '".$dcd_no."' and is_rk = 0");
  1405. $whlabel_arr = [];
  1406. $time = time();
  1407. $err_list= [];
  1408. foreach($list as $k=>$v){
  1409. if(empty($v['sku'])){
  1410. $err_list[] = $v['jm']."不存在";
  1411. continue;
  1412. }
  1413. for($i=0;$i<$v['num'];$i++){
  1414. $whlabel_arr[] = [
  1415. 'sku'=>$v['sku'],
  1416. 'number'=>$v['number'],
  1417. 'features'=>$v['features'],
  1418. 'title'=>$v['title'],
  1419. 'zh'=>$v['zh'],
  1420. 'warehouse'=>'13',
  1421. 'enter'=>$time,
  1422. 'state'=>0,
  1423. 'retreatwarehouse'=>'13',
  1424. 'time'=>$time,
  1425. 'details'=>$v['kw'],
  1426. 'bs'=>1,
  1427. 'rktype'=>9,
  1428. ];
  1429. }
  1430. }
  1431. if(!empty($err_list)){
  1432. echo json_encode(['success'=>false,'msg'=>implode('<br/>', $err_list)]);exit;
  1433. }
  1434. $this->db->trans_start();
  1435. $this->db->insert_batch('whlabel',$whlabel_arr);
  1436. $this->db->where('dcd_no',$dcd_no);
  1437. //$this->db->where('drd_no',$drd_no);
  1438. $this->db->update('bhdcd',['status'=>3,'rk_time'=>$time,'is_rk'=>1]);
  1439. if($this->db->trans_status() === FALSE){
  1440. $this->db->trans_rollback();
  1441. echo json_encode(['success'=>false,'msg'=>'录入失败']);exit;
  1442. }else{
  1443. $this->db->trans_commit();
  1444. echo json_encode(['success'=>true,'msg'=>'录入成功']);
  1445. }
  1446. }else{
  1447. $dcd_no = $arg_array[0];
  1448. $list = $this->bhdcd->find_all("dcd_no = '".$dcd_no."'");
  1449. $jm_list = array_column($list,'jm');
  1450. $status_list = $this->bhdcd->getStatus();
  1451. $in_where = "( ";
  1452. foreach($jm_list as $k=>$v){
  1453. $in_where .= "'".$v."',";
  1454. }
  1455. $in_where = rtrim($in_where,",");
  1456. $in_where .= " )";
  1457. foreach($list as $k=>$v){
  1458. $list[$k]['status_show'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
  1459. $list[$k]['drd_no'] = empty($v['drd_no'])?"":$v['drd_no'];
  1460. if(!empty($v['kw'])){
  1461. $list[$k]['kw'] = $v['kw'];
  1462. }else{
  1463. if(!empty($list[$k]['sku'])){
  1464. $whlabel_info = $this->whlabel->find(" warehouse = '13' and (sku = '".$list[$k]['sku']."') and ( details != '' and details IS NOT NULL )","*","id desc");
  1465. if(!empty($whlabel_info)){
  1466. if(!empty($whlabel_info['details'])){
  1467. $list[$k]['kw'] = $whlabel_info['details'];
  1468. $this->bhdcd->save([
  1469. 'kw'=>$whlabel_info['details'],
  1470. ],$v['id']);
  1471. }else{
  1472. $list[$k]['kw'] = "";
  1473. }
  1474. }else{
  1475. $list[$k]['kw'] = "";
  1476. }
  1477. }else{
  1478. $list[$k]['kw'] = "";
  1479. }
  1480. }
  1481. $list[$k]['create_time'] = empty($v['create_time'])?"":date("Y-m-d H:i:s",$v['create_time']);
  1482. }
  1483. $this->data['list'] = $list;
  1484. $this->_Template('beihuogl_ckbherprk',$this->data);
  1485. }
  1486. }
  1487. private function _bhdcdsave(){
  1488. if($this->input->method() === 'post'){
  1489. $id = $this->input->post('id',true);
  1490. $val = $this->input->post('val',true);
  1491. $column = $this->input->post('column',true);
  1492. $info = $this->bhdcd->read($id);
  1493. $update_arr = [];
  1494. if($column == 'real_num'){
  1495. if($val > $info['num']){
  1496. echo json_encode(['success'=>false,'msg'=>'录入数量不能大于原数量']);exit;
  1497. }
  1498. $update_arr = [
  1499. 'real_num'=>(int)$val,
  1500. ];
  1501. }elseif($column == 'kw'){
  1502. $winfo = $this->whlabel->find("warehouse = '13' and sku = '".$info['sku']."' ","*","id desc");
  1503. if(!empty($winfo)){
  1504. $winfo = $this->whlabel->find("warehouse = '13' and sku = '".$info['sku']."' and details = '".$val."'","*","id desc");
  1505. if(empty($winfo)){
  1506. echo json_encode(['success'=>false,'msg'=>'请仔细核查该库位信息']);exit;
  1507. }
  1508. }
  1509. $update_arr = [
  1510. 'kw'=>trim($val),
  1511. ];
  1512. }else{
  1513. echo json_encode(['success'=>false,'msg'=>'请求参数未设置']);exit;
  1514. }
  1515. $r = $this->bhdcd->save($update_arr,$id);
  1516. if($r){
  1517. echo json_encode(['success'=>true,'msg'=>'保存成功']);
  1518. }else{
  1519. echo json_encode(['success'=>false,'msg'=>'保存失败']);
  1520. }
  1521. }else{
  1522. echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
  1523. }
  1524. }
  1525. private function _u9scdexcel($arg_array){
  1526. $id = $arg_array[0];
  1527. $info = $this->bhccwl->read($id);
  1528. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1529. //生成excel
  1530. $filename = $info['bh_no']."备货生产单.xls";
  1531. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1532. <head>
  1533. <!--[if gte mso 9]><xml>
  1534. <x:ExcelWorkbook>
  1535. <x:ExcelWorksheets>
  1536. <x:ExcelWorksheet>
  1537. <x:Name>EXCEL</x:Name>
  1538. <x:WorksheetOptions>
  1539. <x:Print>
  1540. <x:ValidPrinterInfo />
  1541. </x:Print>
  1542. </x:WorksheetOptions>
  1543. </x:ExcelWorksheet>
  1544. </x:ExcelWorksheets>
  1545. </x:ExcelWorkbook>
  1546. </xml>
  1547. <![endif]-->
  1548. </head><body>";
  1549. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  1550. $str .= "<tr><td>备货单号</td><td>中文品名</td><td>u9料号</td><td>生产数量</td><td>u9生产单号</td></tr>";
  1551. foreach ($list as $key=>$value)
  1552. {
  1553. $str .= "<tr>";
  1554. $str .= "<td>". $value['bh_no']. "</td>";
  1555. $str .= "<td>". $value['title']. "</td>";
  1556. $str .= "<td>". $value['jm']. "</td>";
  1557. $str .= "<td>". $value['ck_num']. "</td>";
  1558. $str .= "<td>". $value['u9sc_no']. "</td>";
  1559. $str .= "</tr>";
  1560. }
  1561. $str .= "</table></body></html>";
  1562. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1563. header( "Content-type: application/octet-stream" );
  1564. header( "Content-Disposition: attachment; filename=".$filename );
  1565. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1566. header( "Pragma: no-cache" );
  1567. header( "Expires: 0" );
  1568. exit($str);
  1569. }
  1570. //打印标签
  1571. private function _printlabel(){
  1572. if($this->input->method() === 'post'){
  1573. $id = $this->input->post('id',true);
  1574. $xbqnum = $this->input->post('num',true);
  1575. $info = $this->bhdcd->read($id);
  1576. if(empty($info)){
  1577. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1578. }
  1579. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $info['features']);
  1580. $featurespp = explode('-', trim($featurespp, '-'));
  1581. if (isset($featurespp[5])) {
  1582. $tmp_featurespp = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  1583. } else {
  1584. $tmp_featurespp = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  1585. }
  1586. $label = '';
  1587. $cpid = $this->whlabellabel->find_count();
  1588. $cpid = $cpid + 1;
  1589. $time = time();
  1590. $label = time().rand(10,99);
  1591. $label = substr($label,1);
  1592. $insert_arr = [
  1593. 'purchase'=>1,
  1594. 'shop'=>'',
  1595. 'sku'=>$info['sku'],
  1596. 'number'=>$info['number'],
  1597. 'features'=>$info['features'],
  1598. 'featurespp'=>$tmp_featurespp,
  1599. 'title'=>$info['title'],
  1600. 'label'=>$label,
  1601. 'warehouse'=>13,
  1602. 'time'=>$time,
  1603. 'details'=>$info['kw'],
  1604. 'cpid'=>$cpid,
  1605. 'jm'=>$info['jm'],
  1606. 'cpbz'=>''
  1607. ];
  1608. $this->db->trans_begin();
  1609. $this->whlabellabel->insert($insert_arr);
  1610. if ($this->db->trans_status() === TRUE) {
  1611. $this->db->trans_commit();
  1612. } else {
  1613. $this->db->trans_rollback();
  1614. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  1615. exit;
  1616. }
  1617. $details = '位置:(' . $info['kw'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' ;
  1618. $details = ' <b style="font-size: 18px;">'."许昌仓</b> ".$details;
  1619. $purchase = "龙盈工厂";
  1620. echo json_encode(array('title' => $info['title'], 'num' => $label, 'bqsku' => $info['sku'], 'xbqnum' => $xbqnum, 'zh' => str_replace('自然色 ', '', rtrim($info['zh'], ' ')), 'details' => $details, 'purchase' => $purchase, 'cpbz' => "", 'usa' => 0, 'success' => true));
  1621. exit; //特殊仓目前不需要仓库选项
  1622. }else{
  1623. echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
  1624. }
  1625. }
  1626. private function _dcdjzrk(){
  1627. if($this->input->method() === 'post'){
  1628. $id = $this->input->post('id',true);
  1629. $info = $this->bhdcd->read($id);
  1630. if($info['is_rk'] == 0){
  1631. $this->bhdcd->save(['is_rk'=>1],$id);
  1632. echo json_encode(['success'=>true,'msg'=>'此条信息已禁止入库']);exit;
  1633. }else{
  1634. echo json_encode(['success'=>true,'msg'=>'此条信息已禁止入库']);exit;
  1635. }
  1636. }else{
  1637. echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
  1638. }
  1639. }
  1640. }