Beihuogl.php 70 KB

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