Beihuogl.php 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747
  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",$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. $list[$k]['sku'] = $v['sku']." <i class='fa fa-edit' data-id='".$v['id']."' data-sku='".$v['sku']."' onclick='edit_sku(this)'></i>";
  513. $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>";
  514. $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>";
  515. }
  516. $total = $this->bhsq->find_count($where);
  517. $pagenum = ceil($total/$perpage);
  518. $over = $total-($start+$perpage);
  519. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  520. echo json_encode($rows);exit;
  521. }else{
  522. $user = $this->user->get_api($_SESSION['api']);
  523. $usersp = explode('|',trim($user['shop'],'|'));
  524. $this->data['usersp'] = implode(",",$usersp);
  525. $vip_id = 0;
  526. if(in_array($user['id'],[10,28])){
  527. $vip_id = 1;
  528. }
  529. $this->data['vip_id'] = $vip_id;
  530. $this->_Template('beihuogl_ccwlshlist',$this->data);
  531. }
  532. }
  533. //一键校验选中SKU
  534. private function _ccwlskucheck(){
  535. if($this->input->method() === 'post'){
  536. $data = $this->input->post();
  537. if(empty($data['arr_id'])){
  538. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  539. exit;
  540. }
  541. $list = $this->bhsq->find_all('id in ('.implode(',',$data['arr_id']).')');
  542. $error_list = [];
  543. foreach($list as $k=>$v){
  544. if(empty($v['sku'])){
  545. $error_list[] = [
  546. 'msg'=>$v['value'].'请录入SKU',
  547. ];
  548. continue;
  549. }
  550. $num = $this->goods->find_count("sku = '".$v['sku']."'");
  551. if(!empty($num)){
  552. continue;
  553. }
  554. $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc');
  555. if(empty($whlabel_info)){
  556. $error_list[] = [
  557. 'msg'=>$v['sku'].'未在进销存浏览那找到对应信息',
  558. ];
  559. }
  560. }
  561. if(empty($error_list)){
  562. echo json_encode(['success'=>true,'msg'=>'校验成功,没有异常信息']);
  563. exit;
  564. }else{
  565. echo json_encode(['success'=>true,'msg'=>'校验失败,请核对填写信息','error_list'=>$error_list]);
  566. exit;
  567. }
  568. }else{
  569. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  570. exit;
  571. }
  572. }
  573. //仓储物流合成备货单
  574. private function _ccwlbhmake(){
  575. if($this->input->method() === 'post'){
  576. $data = $this->input->post();
  577. $bh_no = $data['bh_no'];
  578. $select_id = $data['arr_id'];
  579. if(empty($select_id)){
  580. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  581. exit;
  582. }
  583. if(empty($bh_no)){
  584. $tmp_time = strtotime(date("Y-m-d"),time());
  585. $num = $this->bhccwl->find_count("create_time >= ".$tmp_time);
  586. $num = $num+1;
  587. $num = str_pad($num, 3, '0', STR_PAD_LEFT);
  588. $bh_no = "BH-".date("ymd")."-".$num;
  589. }
  590. $list = $this->bhsq->find_all('id in ('.implode(',',$select_id).')');
  591. foreach($list as $k=>$v){
  592. if(empty($v['sku'])){
  593. echo json_encode(['success'=>false,'msg'=>'提交的数据中有的sku为空,请核对填写信息']);
  594. exit;
  595. }
  596. }
  597. $classid = $this->logic_u9tools->getClass();
  598. $typeclass = $this->logic_u9tools->getTypeClass();
  599. foreach($list as $k=>$v){
  600. $whlabel_info = $this->goods->find("sku = '".$v['sku']."'",'sku,features,jm','id desc');
  601. if(empty($whlabel_info)){
  602. $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc');
  603. if(empty($whlabel_info)){
  604. echo json_encode(['success'=>false,'msg'=>$v['sku'].'未在进销存浏览那找到对应信息']);
  605. exit;
  606. }
  607. $r = $this->logic_u9tools->getOneU9bmHasGift($whlabel_info['features'],$classid,$typeclass);
  608. $this->bhsq->save([
  609. 'jm'=>$r['jm'],
  610. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  611. 'features'=>$whlabel_info['features'],
  612. ],$v['id']);
  613. }else{
  614. $this->bhsq->save([
  615. 'jm'=>$whlabel_info['jm'],
  616. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  617. 'features'=>$whlabel_info['features'],
  618. ],$v['id']);
  619. }
  620. }
  621. $this->db->trans_start();
  622. $this->db->where_in('id',$select_id);
  623. $this->db->update('bhsq',[
  624. 'bh_no'=>$bh_no,
  625. 'sq_status'=>4,
  626. 'ccwl_status'=>1,
  627. ]);
  628. $this->db->select('SUM(ccwl_num) as total_ccwl_num');
  629. $this->db->where_in('id',$select_id);
  630. $query = $this->db->get('bhsq');
  631. $result = $query->row();
  632. $total_ccwl_num = $result->total_ccwl_num? $result->total_ccwl_num:0;
  633. $time = time();
  634. $this->bhccwl->insert([
  635. 'bh_no'=>$bh_no,
  636. 'status'=>0,
  637. 'num'=>$total_ccwl_num,
  638. 'create_time'=>$time,
  639. 'update_time'=>$time,
  640. ]);
  641. if($this->db->trans_status() === FALSE){
  642. $this->db->trans_rollback();
  643. echo json_encode(['success'=>false,'msg'=>'生成备货单失败']);
  644. exit;
  645. }else{
  646. $this->db->trans_commit();
  647. echo json_encode(['success'=>true,'msg'=>'生成备货单成功']);
  648. exit;
  649. }
  650. }else{
  651. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  652. exit;
  653. }
  654. }
  655. private function getU9Drck($features){
  656. if(stripos($features,'-126-') !== false)
  657. {
  658. $drck = '12003';//进入发条库
  659. }
  660. else if(stripos($features,'-127-') !== false)
  661. {
  662. $drck = '12004';//进入发块库
  663. }
  664. else
  665. {
  666. $drck = '12006';//其它进入完成库
  667. }
  668. return $drck;
  669. }
  670. //仓储物流部的备货单列表
  671. private function _ccwlbhindex(){
  672. if($this->input->method() === 'post'){
  673. $page = $this->input->post('page',true);
  674. $perpage = $this->input->post('perpage',true);
  675. $bh_no = $this->input->post('bh_no',true);
  676. $status = $this->input->post('status',true);
  677. $ktime = $this->input->post('ktime',true);
  678. $jtime = $this->input->post('jtime',true);
  679. $ktime = strtotime($ktime);
  680. $jtime = strtotime($jtime);
  681. $where = "create_time >= ".$ktime." and create_time < ".$jtime." ";
  682. if(!empty($bh_no)){
  683. $where .= " and bh_no = '".$bh_no."' ";
  684. }
  685. if($status > -1){
  686. $where .= " and status = ".$status." ";
  687. }
  688. //数据排序
  689. $order_str = "id desc";
  690. if(empty($page))
  691. {
  692. $start = 0;
  693. $perpage = 1;
  694. }
  695. else
  696. {
  697. $start = ($page - 1)*$perpage;
  698. }
  699. $list = $this->bhccwl->find_all($where,"id,bh_no,status,create_time,public_time,update_time",$order_str,$start,$perpage);
  700. if(empty($list)){
  701. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  702. echo json_encode($rows);exit;
  703. }
  704. $status_list = $this->bhccwl->getStatus();
  705. foreach($list as $k=>$v){
  706. $list[$k]['status'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
  707. $list[$k]['create_time'] = date("Y-m-d",$v['create_time']);
  708. $list[$k]['public_time'] = empty($v['public_time'])?"":date("Y-m-d",$v['public_time']);
  709. $str = "";
  710. if($v['status'] == 0){
  711. $str .= "<div style='text-align:center;'>";
  712. $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>";
  713. $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>";
  714. $str .= "</div>";
  715. }
  716. $list[$k]['update_time'] = $str;
  717. }
  718. $total = $this->bhccwl->find_count($where);
  719. $pagenum = ceil($total/$perpage);
  720. $over = $total-($start+$perpage);
  721. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  722. echo json_encode($rows);exit;
  723. }else{
  724. $this->_Template('beihuogl_ccwlbhindex',$this->data);
  725. }
  726. }
  727. //仓储物流部备货 在编辑页面添加数据
  728. private function _ccwlbhsavexzbh(){
  729. if($this->input->method() === 'post'){
  730. $data = $this->input->post();
  731. $select_id = $data['select_id'];
  732. $id = $data['id'];
  733. $bh_no = $data['bh_no'];
  734. if(empty($select_id)){
  735. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  736. exit;
  737. }
  738. $info = $this->bhccwl->read($id);
  739. if(empty($info)){
  740. echo json_encode(['success'=>false,'msg'=>'数据不存在']);
  741. exit;
  742. }
  743. if($info['bh_no'] != $bh_no){
  744. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);
  745. exit;
  746. }
  747. $bh_no = $info['bh_no'];
  748. $list = $this->bhsq->find_all('id in ('.implode(',',$select_id).') ' );
  749. foreach($list as $k=>$v){
  750. if(empty($v['sku'])){
  751. echo json_encode(['success'=>false,'msg'=>'提交的数据中有的sku为空,请核对填写信息']);
  752. exit;
  753. }
  754. if(!empty($v['bh_no'])){
  755. echo json_encode(['success'=>false,'msg'=>'提交的数据中有的已经被调用,请联系技术核对']);
  756. exit;
  757. }
  758. }
  759. $classid = $this->logic_u9tools->getClass();
  760. $typeclass = $this->logic_u9tools->getTypeClass();
  761. foreach($list as $k=>$v){
  762. $whlabel_info = $this->goods->find("sku = '".$v['sku']."'",'sku,features,jm','id desc');
  763. if(empty($whlabel_info)){
  764. $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc');
  765. if(empty($whlabel_info)){
  766. echo json_encode(['success'=>false,'msg'=>$v['sku'].'未在进销存浏览那找到对应信息']);
  767. exit;
  768. }
  769. if(empty($v['jm'])){
  770. $r = $this->logic_u9tools->getOneU9bmHasGift($whlabel_info['features'],$classid,$typeclass);
  771. $this->bhsq->save([
  772. 'jm'=>$r['jm'],
  773. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  774. 'features'=>$whlabel_info['features'],
  775. ],$v['id']);
  776. }
  777. $list[$k]['jm'] = $r['jm'];
  778. }else{
  779. $this->bhsq->save([
  780. 'jm'=>$whlabel_info['jm'],
  781. 'drck'=>$this->getU9Drck($whlabel_info['features']),
  782. 'features'=>$whlabel_info['features'],
  783. ],$v['id']);
  784. $list[$k]['jm'] = $whlabel_info['jm'];
  785. }
  786. }
  787. $status_list = $this->bhccwl->getStatus();
  788. $info['status_show'] = isset($status_list[$info['status']])?$status_list[$info['status']]:"";
  789. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  790. $plat_list = array_column($plat_list,'title','id');
  791. $shop_list = $this->shop->find_all("1=1","id,shopname");
  792. $shop_list = array_column($shop_list,'shopname','id');
  793. foreach($list as $k=>$v){
  794. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  795. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"";
  796. $list[$k]['public_time'] = date("Y-m-d",$v['public_time']);
  797. $list[$k]['bh_no'] = $info['bh_no'];
  798. }
  799. echo json_encode(['success'=>true,'msg'=>'编辑成功','data'=>$list]);exit;
  800. }else{
  801. echo json_encode(['success'=>false,'msg'=>'请求失败']);
  802. exit;
  803. }
  804. }
  805. private function _ccwlbhedit($arg_array){
  806. if($this->input->method() === 'post'){
  807. $select_id = $this->input->post('arr_id',true);
  808. if(empty($select_id)){
  809. echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']);
  810. exit;
  811. }
  812. $id = $this->input->post('id',true);
  813. $info = $this->bhccwl->read($id);
  814. $bh_no = $info['bh_no'];
  815. $this->db->where_in('id',$select_id);
  816. $this->db->update('bhsq',[
  817. 'bh_no'=>$bh_no,
  818. 'sq_status'=>4,
  819. 'ccwl_status'=>1,
  820. ]);
  821. $this->db->select('SUM(ccwl_num) as total_ccwl_num');
  822. $this->db->where_in('id',$select_id);
  823. $query = $this->db->get('bhsq');
  824. $result = $query->row();
  825. $total_ccwl_num = $result->total_ccwl_num? $result->total_ccwl_num:0;
  826. $time = time();
  827. $this->bhccwl->save([
  828. 'num'=>$total_ccwl_num,
  829. 'update_time'=>$time,
  830. ],$info['id']);
  831. echo json_encode(['success'=>true,'msg'=>'修改成功']);exit;
  832. }else{
  833. $id = $arg_array[0];
  834. $info = $this->bhccwl->find("id = ".$id);
  835. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' and sq_status = 4 and ccwl_status = 1");
  836. $status_list = $this->bhccwl->getStatus();
  837. $info['status_show'] = isset($status_list[$info['status']])?$status_list[$info['status']]:"";
  838. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  839. $plat_list = array_column($plat_list,'title','id');
  840. $shop_list = $this->shop->find_all("1=1","id,shopname");
  841. $shop_list = array_column($shop_list,'shopname','id');
  842. foreach($list as $k=>$v){
  843. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  844. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"";
  845. $list[$k]['public_time'] = date("Y-m-d",$v['public_time']);
  846. }
  847. // $this->data['info'] = $info;
  848. $this->data['list'] = $list;
  849. $this->data['info'] = $info;
  850. $this->_Template('beihuogl_ccwlbhedit',$this->data);
  851. }
  852. }
  853. private function _ccwldelitem(){
  854. if($this->input->method() === 'post'){
  855. $data = $this->input->post();
  856. $id = $data['id'];
  857. $bh_no = $data['bh_no'];
  858. $info = $this->bhsq->read($id);
  859. $ccwl_num = $info['ccwl_num'];
  860. if(empty($info)){
  861. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  862. }
  863. if(empty($info['bh_no'])){
  864. if($info['sq_status'] == 2 && $info['ccwl_status'] == 0){
  865. echo json_encode(['success'=>true,'msg'=>'删除成功']);exit;
  866. }else{
  867. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit;
  868. }
  869. }
  870. if($info['bh_no'] != $bh_no){
  871. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit;
  872. }
  873. $ccwl_info = $this->bhccwl->find("bh_no = '".$info['bh_no']."'");
  874. $ccwl_info['num'] = $ccwl_info['num'] - $ccwl_num;
  875. $this->db->trans_start();
  876. $this->bhccwl->save([
  877. 'num'=>$ccwl_info['num'],
  878. ],$ccwl_info['id']);
  879. $this->bhsq->save([
  880. 'sq_status'=>2,
  881. 'ccwl_status'=>0,
  882. 'bh_no'=>''
  883. ],$id);
  884. if($this->db->trans_status() === FALSE){
  885. $this->db->trans_rollback();
  886. echo json_encode(['success'=>false,'msg'=>'删除失败']);exit;
  887. }else{
  888. $this->db->trans_commit();
  889. echo json_encode(['success'=>true,'msg'=>'删除成功']);exit;
  890. }
  891. }else{
  892. echo json_encode(['success'=>false,'msg'=>'请求失败']);exit;
  893. }
  894. }
  895. private function _ccwleditxzbh(){
  896. if($this->input->method() === 'post'){
  897. $data = $this->input->post();
  898. //超过三月没审核的 就不展示了
  899. $time = time() - 60*24*3600;
  900. $where = "sq_status = 2 and ccwl_status = 0 and public_time > ".$time." ";
  901. if(!empty($data['sqr'])){
  902. $where .= " and sqr = '".$data['sqr']."' ";
  903. }
  904. if(!empty($data['shop_id'])){
  905. $where .= " and shop_id = ".$data['shop_id']." ";
  906. }
  907. if(!empty($data['plat_id'])){
  908. $where .= " and plat_id = ".$data['plat_id']." ";
  909. }
  910. if(!empty($data['sku'])){
  911. $where .= " and sku = '".$data['sku']."' ";
  912. }
  913. $order_str = "id desc";
  914. $list = $this->bhsq->find_all($where,"*",$order_str,0,20);
  915. $shop_list = $this->shop->find_all("1=1","id,shopname");
  916. $shop_list = array_column($shop_list,'shopname','id');
  917. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  918. $plat_list = array_column($plat_list,'title','id');
  919. foreach($list as $k=>$v){
  920. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  921. $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"";
  922. $list[$k]['public_time'] = date("Y-m-d",$v['public_time']);
  923. }
  924. if(empty($list)){
  925. echo json_encode(['success'=>false,'msg'=>'查询失败']);exit;
  926. }else{
  927. echo json_encode(['success'=>true,'msg'=>'查询成功','data'=>$list]);exit;
  928. }
  929. }else{
  930. $data = $this->input->get();
  931. $this->data['id'] = $data['id'];
  932. $this->data['bh_no'] = $data['bh_no'];
  933. $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
  934. $this->data['plat_list'] = $plat_list;
  935. $this->_Template('beihuogl_ccwleditxzbh',$this->data);
  936. }
  937. }
  938. private function _ccwlbhsave(){
  939. if($this->input->method() === 'post'){
  940. $data = $this->input->post();
  941. $id = $data['id'];
  942. $val = $data['val'];
  943. $column = $data['column'];
  944. $update_arr = [];
  945. if($column == 'status'){
  946. $update_arr = [
  947. 'status'=>(int)$val,
  948. 'update_time'=>time(),
  949. 'public_time'=>time(),
  950. ];
  951. }else{
  952. echo json_encode(['success'=>false,'msg'=>'请求参数未设置']);exit;
  953. }
  954. $r = $this->bhccwl->save($update_arr,$id);
  955. if($r){
  956. echo json_encode(['success'=>true,'msg'=>'修改成功']);exit;
  957. }else{
  958. echo json_encode(['success'=>false,'msg'=>'修改失败']);exit;
  959. }
  960. }else{
  961. echo json_encode(['success'=>false,'msg'=>'请求失败']);exit;
  962. }
  963. }
  964. //仓库的备货单列表
  965. private function _ckbhindex(){
  966. if($this->input->method() === 'post'){
  967. $page = $this->input->post('page',true);
  968. $perpage = $this->input->post('perpage',true);
  969. $bh_no = $this->input->post('bh_no',true);
  970. $status = $this->input->post('status',true);
  971. $ktime = $this->input->post('ktime',true);
  972. $jtime = $this->input->post('jtime',true);
  973. $ktime = strtotime($ktime);
  974. $jtime = strtotime($jtime);
  975. $where = "public_time >= ".$ktime." and public_time < ".$jtime." and status = 1 ";
  976. if(!empty($bh_no)){
  977. $where .= " and bh_no = '".$bh_no."' ";
  978. }
  979. if($status > -1){
  980. $where .= " and status = ".$status." ";
  981. }
  982. //数据排序
  983. $order_str = "id desc";
  984. if(empty($page))
  985. {
  986. $start = 0;
  987. $perpage = 1;
  988. }
  989. else
  990. {
  991. $start = ($page - 1)*$perpage;
  992. }
  993. $list = $this->bhccwl->find_all($where,"id,bh_no,ck_status,public_time,ckpublic_time",$order_str,$start,$perpage);
  994. if(empty($list)){
  995. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  996. echo json_encode($rows);exit;
  997. }
  998. $status_list = $this->bhccwl->getCkStatus();
  999. foreach($list as $k=>$v){
  1000. $list[$k]['bh_no'] = "<h9 class='window' data-h='/beihuogl/showckbh/".$v['id']."' data-t='订单号:".$v['bh_no']."'><p>".$v['bh_no']."</p></h9>";
  1001. $list[$k]['ck_status'] = isset($status_list[$v['ck_status']])?$status_list[$v['ck_status']]:"";
  1002. $list[$k]['public_time'] = empty($v['public_time'])?"":date("Y-m-d",$v['public_time']);
  1003. $list[$k]['ckpublic_time'] = empty($v['ckpublic_time'])?"":date("Y-m-d",$v['ckpublic_time']);
  1004. $str = "";
  1005. if($v['ck_status'] == 0){
  1006. $str .= "<div style='text-align:center;'>";
  1007. $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>";
  1008. // $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>";
  1009. $str .= "</div>";
  1010. }
  1011. if($v['ck_status'] == 1 || $v['ck_status'] == 2){
  1012. $str .= "<div style='text-align:center;'>";
  1013. $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>";
  1014. $str .= "</div>";
  1015. }
  1016. if($v['ck_status'] > 2){
  1017. $str .= "<div style='text-align:center;'>";
  1018. $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>";
  1019. $str .= "</div>";
  1020. }
  1021. $list[$k]['update_time'] = $str;
  1022. }
  1023. $total = $this->bhccwl->find_count($where);
  1024. $pagenum = ceil($total/$perpage);
  1025. $over = $total-($start+$perpage);
  1026. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1027. echo json_encode($rows);exit;
  1028. }else{
  1029. $this->_Template('beihuogl_ckbhindex',$this->data);
  1030. }
  1031. }
  1032. private function _ckbhedit($arg_array){
  1033. if($this->input->method() === 'post'){
  1034. $id = $this->input->post('id',true);
  1035. $bh_no = $this->input->post('bh_no',true);
  1036. $info = $this->bhccwl->read($id);
  1037. if(empty($info)){
  1038. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1039. }
  1040. if($info['ck_status'] == 0 && $info['status'] == 1){
  1041. }else{
  1042. echo json_encode(['success'=>false,'msg'=>'状态不对,不可审核']);exit;
  1043. }
  1044. if($info['bh_no'] != $bh_no){
  1045. echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit;
  1046. }
  1047. $num = 0;
  1048. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1049. foreach($list as $k=>$v){
  1050. $num += $v['ck_num'];
  1051. }
  1052. $r = $this->bhccwl->save([
  1053. 'ck_status'=>1,
  1054. 'ck_num'=>$num,
  1055. 'update_time'=>time(),
  1056. 'ckpublic_time'=>time(),
  1057. ],$id);
  1058. if($r){
  1059. echo json_encode(['success'=>true,'msg'=>'审核成功']);exit;
  1060. }else{
  1061. echo json_encode(['success'=>false,'msg'=>'审核失败']);exit;
  1062. }
  1063. }else{
  1064. $id = $arg_array[0];
  1065. $info = $this->bhccwl->find("id = ".$id);
  1066. $status_list = $this->bhccwl->getCkStatus();
  1067. $info['ck_status_show'] = isset($status_list[$info['ck_status']])?$status_list[$info['ck_status']]:"";
  1068. $drck_list = $this->bhccwl->getDrck();
  1069. $this->data['drck_list'] = $drck_list;
  1070. $this->data['drck_json'] = json_encode($drck_list);
  1071. $this->data['info'] = $info;
  1072. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."'");
  1073. $shop_list = $this->shop->find_all("1=1","id,shopname");
  1074. $shop_list = array_column($shop_list,'shopname','id');
  1075. foreach($list as $k=>$v){
  1076. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  1077. $list[$k]['drck_show'] = isset($drck_list[$v['drck']])?$drck_list[$v['drck']]:"";
  1078. }
  1079. $this->data['list'] = $list;
  1080. $this->_Template('beihuogl_ckbhedit',$this->data);
  1081. }
  1082. }
  1083. private function _makeu9scd($arg_array){
  1084. if($this->input->method() === 'post'){
  1085. $data = $this->input->post(null,true);
  1086. $info = $this->bhccwl->read($data['id']);
  1087. if(empty($info)){
  1088. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1089. }
  1090. if($info['ck_status'] == 1 && $info['status'] == 1){
  1091. }else{
  1092. echo json_encode(['success'=>false,'msg'=>'状态不对,不可生成u9生产单']);
  1093. exit;
  1094. }
  1095. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' and is_u9sc = 0 ");
  1096. $params = [
  1097. 'org_code'=>"120",//组织代码 龙盈工厂
  1098. 'djhlx'=>'2000',//单号类型 备货生产单
  1099. 'scbm_code'=>"12008",//龙盈生产部门
  1100. "time"=>time(),
  1101. 'owner_org_code'=>"120",
  1102. 'title'=>$info['bh_no'],
  1103. 'shipremarks'=>$info['bh_no'],
  1104. ];
  1105. $final_list = [];
  1106. foreach($list as $k=>$v){
  1107. $final_list[] =[
  1108. 'do_id'=>$v['id'],
  1109. 'drck'=>$v['drck'],
  1110. 'jm'=>$v['jm'],
  1111. 'sl'=>$v['ck_num'],
  1112. ];
  1113. }
  1114. $params['list'] = $final_list;
  1115. $token = $this->settingtest->get_yytoken_120();
  1116. $res = $this->apiyyv1->scdCreate($params,$token);
  1117. if(empty($res[0]['Data'])){
  1118. $this->logic_ding->sendToDing("生成u9生产单失败,错误信息:".json_encode($res,JSON_UNESCAPED_UNICODE));
  1119. echo json_encode(['success'=>false,'msg'=>'生成u9生产单失败']);exit;
  1120. }
  1121. $this->logic_ding->sendToDing("生成u9生产单成功,进行记录:".json_encode($res,JSON_UNESCAPED_UNICODE));
  1122. $r_s_list = $res[0]['Data'];
  1123. foreach($list as $k=>$v){
  1124. $list[$k]['u9_data'] = $r_s_list[$k];
  1125. }
  1126. //m_isSucess
  1127. $flag_status = 0;//判断是否有创建失败的
  1128. $u9sc_status = 0;//判断是否有创建成功的
  1129. foreach($list as $k=>$v){
  1130. if($v['u9_data']['m_isSucess']== 1){
  1131. $u9sc_status += 1;
  1132. $this->bhsq->save([
  1133. 'is_u9sc'=>1,
  1134. 'u9sc_no'=>$v['u9_data']['m_code'],
  1135. ],$v['id']);
  1136. }else{
  1137. $flag_status += 0;
  1138. $this->bhsq->save([
  1139. 'u9sc_remark'=>$v['u9_data']['m_errorMsg'],
  1140. ],$v['id']);
  1141. }
  1142. }
  1143. $len = count($list);
  1144. //都创建失败了 就直接gg
  1145. if($u9sc_status == 0){
  1146. echo json_encode(['success'=>false,'msg'=>'生成u9生产单失败']);exit;
  1147. }
  1148. if(($u9sc_status < $len) && ( $flag_status< $len) ){
  1149. $this->bhccwl->save([
  1150. 'ck_status'=>2,
  1151. ],$info['id']);
  1152. echo json_encode(['success'=>true,'msg'=>'生成u9生产单部分成功']);exit;
  1153. }
  1154. if($u9sc_status == $len){
  1155. $this->bhccwl->save([
  1156. 'ck_status'=>3,
  1157. ],$info['id']);
  1158. echo json_encode(['success'=>true,'msg'=>'生成u9生产单成功']);exit;
  1159. }
  1160. echo json_encode(['success'=>false,'msg'=>'代码异常']);exit;
  1161. }else{
  1162. $id = $arg_array[0];
  1163. $info = $this->bhccwl->read($id);
  1164. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1165. $shop_list = $this->shop->find_all("1=1","id,shopname");
  1166. $shop_list = array_column($shop_list,'shopname','id');
  1167. $drck_list = $this->bhccwl->getDrck();
  1168. $status_list = $this->bhccwl->getCkStatus();
  1169. $info['ck_status_show'] = isset($status_list[$info['ck_status']])?$status_list[$info['ck_status']]:"";
  1170. foreach($list as $k=>$v){
  1171. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  1172. $list[$k]['drck_show'] = isset($drck_list[$v['drck']])?$drck_list[$v['drck']]:"";
  1173. }
  1174. $this->data['list'] = $list;
  1175. $this->data['info'] = $info;
  1176. $this->_Template('beihuogl_makeu9scd',$this->data);
  1177. }
  1178. }
  1179. private function _ddscscd(){
  1180. if($this->input->method() === 'post'){
  1181. $id = $this->input->post('id',true);
  1182. $bh_no = $this->input->post('bh_no',true);
  1183. $bhsq_info = $this->bhsq->read($id);
  1184. $bhccwl_info = $this->bhccwl->find("bh_no = '".$bhsq_info['bh_no']."' ");
  1185. if(empty($bhccwl_info)){
  1186. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1187. }
  1188. // if($bhccwl_info['ck_status'] != 1){
  1189. // echo json_encode(['success'=>false,'msg'=>'状态不对,不可生成u9生产单']);
  1190. // exit;
  1191. // }
  1192. if(!in_array($bhccwl_info['ck_status'],[1,2])){
  1193. echo json_encode(['success'=>false,'msg'=>'状态不对,不可生成u9生产单']);
  1194. exit;
  1195. }
  1196. if(!empty($bhsq_info['u9sc_no'])){
  1197. echo json_encode(['success'=>false,'msg'=>'状态不允许生成生产单,有疑问联系技术处理']);
  1198. exit;
  1199. }
  1200. $params = [
  1201. 'org_code'=>"120",//组织代码 龙盈工厂
  1202. 'djhlx'=>'2000',//单号类型 备货生产单
  1203. 'scbm_code'=>"12008",//龙盈生产部门
  1204. "time"=>time(),
  1205. 'owner_org_code'=>"120",
  1206. 'title'=>$bhccwl_info['bh_no'],
  1207. 'shipremarks'=>$bhccwl_info['bh_no'],
  1208. ];
  1209. $list[] = [
  1210. 'do_id'=>$bhsq_info['id'],
  1211. 'drck'=>$bhsq_info['drck'],
  1212. 'jm'=>$bhsq_info['jm'],
  1213. 'sl'=>$bhsq_info['ck_num'],
  1214. ];
  1215. $params['list'] = $list;
  1216. $token = $this->settingtest->get_yytoken_120();
  1217. $res = $this->apiyyv1->scdCreate($params,$token);
  1218. if(empty($res[0]['Data'])){
  1219. echo json_encode(['success'=>false,'msg'=>'生成u9生产单失败']);exit;
  1220. }
  1221. if($res[0]['Data'][0]['m_isSucess']== 1){
  1222. $this->bhsq->save([
  1223. 'is_u9sc'=>1,
  1224. 'u9sc_no'=>$res[0]['Data'][0]['m_code'],
  1225. ],$bhsq_info['id']);
  1226. $tmp_list = $this->bhsq->find_all("bh_no = '".$bh_no."' and is_u9sc = 0 ");
  1227. if(empty($tmp_list)){
  1228. $tmp_status = 3;
  1229. }else{
  1230. $tmp_status = 2;
  1231. }
  1232. $this->bhccwl->save([
  1233. 'ck_status'=>$tmp_status,
  1234. ],$bhccwl_info['id']);
  1235. echo json_encode(['success'=>true,'msg'=>'生成u9生产单成功']);exit;
  1236. }else{
  1237. $this->bhsq->save([
  1238. 'u9sc_remark'=>$res[0]['Data'][0]['m_errorMsg'],
  1239. ],$bhsq_info['id']);
  1240. echo json_encode(['success'=>false,'msg'=>$res[0]['Data'][0]["m_errorMsg"]]);exit;
  1241. }
  1242. }else{
  1243. exit('No direct script access allowed');
  1244. }
  1245. }
  1246. private function _showckbh($arg_array){
  1247. if($this->input->method() === 'post'){
  1248. exit('No direct script access allowed');
  1249. }
  1250. $id = $arg_array[0];
  1251. $drck_list = $this->bhccwl->getDrck();
  1252. $shop_list = $this->shop->find_all("1=1","id,shopname");
  1253. $shop_list = array_column($shop_list,'shopname','id');
  1254. $info = $this->bhccwl->read($id);
  1255. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1256. $list_dcd = $this->bhdcd->find_all("bh_no = '".$info['bh_no']."' ");
  1257. foreach($list as $k=>$v){
  1258. $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"";
  1259. $list[$k]['drck_show'] = isset($drck_list[$v['drck']])?$drck_list[$v['drck']]:"";
  1260. }
  1261. $this->data['info'] = $info;
  1262. $this->data['list'] = $list;
  1263. $this->data['list_dcd'] = $list_dcd;
  1264. $this->_Template('beihuogl_showckbh',$this->data);
  1265. }
  1266. //仓库录入调出单
  1267. private function _ckdcd(){
  1268. if($this->input->method() === 'post'){
  1269. $lrdcd = $this->input->post('lrdcd',true);
  1270. if(empty($lrdcd)){
  1271. //列表展示
  1272. $page = $this->input->post('page',true);
  1273. $perpage = $this->input->post('perpage',true);
  1274. $bh_no = $this->input->post('bh_no',true);
  1275. $dcd_no = $this->input->post('dcd_no',true);
  1276. $status = $this->input->post('status',true);
  1277. $ktime = $this->input->post('ktime',true);
  1278. $jtime = $this->input->post('jtime',true);
  1279. $ktime = strtotime($ktime);
  1280. $jtime = strtotime($jtime);
  1281. $where = "create_time >= ".$ktime." and create_time < ".$jtime." ";
  1282. if(!empty($bh_no)){
  1283. $where .= " and bh_no = '".$bh_no."' ";
  1284. }
  1285. if($status > -1){
  1286. $where .= " and status = ".$status." ";
  1287. }
  1288. if(!empty($dcd_no)){
  1289. $where .= " and dcd_no = '".$dcd_no."' ";
  1290. }
  1291. //数据排序
  1292. $order_str = "id desc";
  1293. if(empty($page))
  1294. {
  1295. $start = 0;
  1296. $perpage = 1;
  1297. }
  1298. else
  1299. {
  1300. $start = ($page - 1)*$perpage;
  1301. }
  1302. $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);
  1303. if(empty($list)){
  1304. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  1305. echo json_encode($rows);exit;
  1306. }
  1307. $status_list = $this->bhdcd->getStatus();
  1308. foreach($list as $k=>$v){
  1309. $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>";
  1310. $list[$k]['status'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
  1311. $list[$k]['drd_no'] = empty($v['drd_no'])?"":$v['drd_no'];
  1312. $list[$k]['kw'] = empty($v['kw'])?"":$v['kw'];
  1313. $list[$k]['create_time'] = empty($v['create_time'])?"":date("Y-m-d",$v['create_time']);
  1314. $str = "";
  1315. if($v['is_rk'] == 0){
  1316. $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>";
  1317. }
  1318. if(!empty($v['rk_time'])){
  1319. $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>";
  1320. }
  1321. $list[$k]['rk_time'] = $str;
  1322. unset($list[$k]['is_rk']);
  1323. }
  1324. $total = $this->bhdcd->find_count($where);
  1325. $pagenum = ceil($total/$perpage);
  1326. $over = $total-($start+$perpage);
  1327. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1328. echo json_encode($rows);exit;
  1329. }else{
  1330. if(empty($lrdcd)){
  1331. echo json_encode(['success'=>false,'msg'=>'调出单号不可以为空']);exit;
  1332. }
  1333. $num = $this->bhdcd->find("dcd_no = '".$lrdcd."'");
  1334. if(!empty($num)){
  1335. echo json_encode(['success'=>false,'msg'=>'调出单号已录入,不可重复录入']);exit;
  1336. }
  1337. //查询录入执行的调出单
  1338. $token = $this->settingtest->get_yytoken_120();
  1339. $res = $this->apiyyv1->cxDcdAboutErp($lrdcd,$token);
  1340. if(empty($res[0]['Data'])){
  1341. echo json_encode(['success'=>false,'msg'=>'请检查调出单号,未在u9获取相关信息']);exit;
  1342. }
  1343. $time = time();
  1344. $final_list = [];
  1345. foreach($res[0]['Data'] as $k=>$v){
  1346. $good_info = $this->goods->find("jm = '".$v['iteminfo_itemcode']."' ");
  1347. $tmp_sku = '';
  1348. $tmp_title = '';
  1349. $tmp_features = '';
  1350. $tmp_number='';
  1351. if(!empty($good_info)){
  1352. $tmp_sku = $good_info['sku'];
  1353. $tmp_title = $good_info['title'];
  1354. $tmp_features = $good_info['features'];
  1355. $tmp_number = str_replace("-","", $good_info['features']);
  1356. }
  1357. $final_list[] = [
  1358. 'sku'=>$tmp_sku,
  1359. 'dcd_no'=>$v['docno'],
  1360. 'jm'=>$v['iteminfo_itemcode'],
  1361. 'zh'=>$v['iteminfo_itemname'],
  1362. 'num'=>$v['costuomqty'],
  1363. 'real_num'=>$v['costuomqty'],
  1364. 'bh_no'=>$v['erp_no'],
  1365. 'create_time'=>$time,
  1366. 'title'=>$tmp_title,
  1367. 'features'=>$tmp_features,
  1368. 'number'=>$tmp_number,
  1369. ];
  1370. }
  1371. $r =$this->db->insert_batch('bhdcd',$final_list);
  1372. if($r){
  1373. echo json_encode(['success'=>true,'msg'=>'录入成功']);
  1374. }else{
  1375. echo json_encode(['success'=>false,'msg'=>'录入失败']);
  1376. }
  1377. exit;
  1378. }
  1379. }else{
  1380. $status_list = $this->bhdcd->getStatus();
  1381. $this->data['status_list'] = $status_list;
  1382. $this->_Template('beihuogl_ckdcd',$this->data);
  1383. }
  1384. }
  1385. private function _ckbherprk($arg_array){
  1386. if($this->input->method() === 'post'){
  1387. $data = $this->input->post(null,true);
  1388. $dcd_no = $data['dcd_no'];
  1389. $drd_no = $data['drd_no'];
  1390. $list = $this->bhdcd->find_all("dcd_no = '".$dcd_no."' and is_rk = 0");
  1391. $whlabel_arr = [];
  1392. $time = time();
  1393. $err_list= [];
  1394. foreach($list as $k=>$v){
  1395. if(empty($v['sku'])){
  1396. $err_list[] = $v['jm']."不存在";
  1397. continue;
  1398. }
  1399. for($i=0;$i<$v['num'];$i++){
  1400. $whlabel_arr[] = [
  1401. 'sku'=>$v['sku'],
  1402. 'number'=>$v['number'],
  1403. 'features'=>$v['features'],
  1404. 'title'=>$v['title'],
  1405. 'zh'=>$v['zh'],
  1406. 'warehouse'=>'13',
  1407. 'enter'=>$time,
  1408. 'state'=>0,
  1409. 'retreatwarehouse'=>'13',
  1410. 'time'=>$time,
  1411. 'details'=>$v['kw'],
  1412. 'bs'=>1,
  1413. 'rktype'=>9,
  1414. ];
  1415. }
  1416. }
  1417. if(!empty($err_list)){
  1418. echo json_encode(['success'=>false,'msg'=>implode('<br/>', $err_list)]);exit;
  1419. }
  1420. $this->db->trans_start();
  1421. $this->db->insert_batch('whlabel',$whlabel_arr);
  1422. $this->db->where('dcd_no',$dcd_no);
  1423. //$this->db->where('drd_no',$drd_no);
  1424. $this->db->update('bhdcd',['status'=>3,'rk_time'=>$time,'is_rk'=>1]);
  1425. if($this->db->trans_status() === FALSE){
  1426. $this->db->trans_rollback();
  1427. echo json_encode(['success'=>false,'msg'=>'录入失败']);exit;
  1428. }else{
  1429. $this->db->trans_commit();
  1430. echo json_encode(['success'=>true,'msg'=>'录入成功']);
  1431. }
  1432. }else{
  1433. $dcd_no = $arg_array[0];
  1434. $list = $this->bhdcd->find_all("dcd_no = '".$dcd_no."'");
  1435. $jm_list = array_column($list,'jm');
  1436. $status_list = $this->bhdcd->getStatus();
  1437. $in_where = "( ";
  1438. foreach($jm_list as $k=>$v){
  1439. $in_where .= "'".$v."',";
  1440. }
  1441. $in_where = rtrim($in_where,",");
  1442. $in_where .= " )";
  1443. foreach($list as $k=>$v){
  1444. $list[$k]['status_show'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
  1445. $list[$k]['drd_no'] = empty($v['drd_no'])?"":$v['drd_no'];
  1446. if(!empty($v['kw'])){
  1447. $list[$k]['kw'] = $v['kw'];
  1448. }else{
  1449. if(!empty($list[$k]['sku'])){
  1450. $whlabel_info = $this->whlabel->find(" warehouse = '13' and (sku = '".$list[$k]['sku']."') and ( details != '' and details IS NOT NULL )","*","id desc");
  1451. if(!empty($whlabel_info)){
  1452. if(!empty($whlabel_info['details'])){
  1453. $list[$k]['kw'] = $whlabel_info['details'];
  1454. $this->bhdcd->save([
  1455. 'kw'=>$whlabel_info['details'],
  1456. ],$v['id']);
  1457. }else{
  1458. $list[$k]['kw'] = "";
  1459. }
  1460. }else{
  1461. $list[$k]['kw'] = "";
  1462. }
  1463. }else{
  1464. $list[$k]['kw'] = "";
  1465. }
  1466. }
  1467. $list[$k]['create_time'] = empty($v['create_time'])?"":date("Y-m-d H:i:s",$v['create_time']);
  1468. }
  1469. $this->data['list'] = $list;
  1470. $this->_Template('beihuogl_ckbherprk',$this->data);
  1471. }
  1472. }
  1473. private function _bhdcdsave(){
  1474. if($this->input->method() === 'post'){
  1475. $id = $this->input->post('id',true);
  1476. $val = $this->input->post('val',true);
  1477. $column = $this->input->post('column',true);
  1478. $info = $this->bhdcd->read($id);
  1479. $update_arr = [];
  1480. if($column == 'real_num'){
  1481. if($val > $info['num']){
  1482. echo json_encode(['success'=>false,'msg'=>'录入数量不能大于原数量']);exit;
  1483. }
  1484. $update_arr = [
  1485. 'real_num'=>(int)$val,
  1486. ];
  1487. }elseif($column == 'kw'){
  1488. $winfo = $this->whlabel->find("warehouse = '13' and sku = '".$info['sku']."' ","*","id desc");
  1489. if(!empty($winfo)){
  1490. $winfo = $this->whlabel->find("warehouse = '13' and sku = '".$info['sku']."' and details = '".$val."'","*","id desc");
  1491. if(empty($winfo)){
  1492. echo json_encode(['success'=>false,'msg'=>'请仔细核查该库位信息']);exit;
  1493. }
  1494. }
  1495. $update_arr = [
  1496. 'kw'=>trim($val),
  1497. ];
  1498. }else{
  1499. echo json_encode(['success'=>false,'msg'=>'请求参数未设置']);exit;
  1500. }
  1501. $r = $this->bhdcd->save($update_arr,$id);
  1502. if($r){
  1503. echo json_encode(['success'=>true,'msg'=>'保存成功']);
  1504. }else{
  1505. echo json_encode(['success'=>false,'msg'=>'保存失败']);
  1506. }
  1507. }else{
  1508. echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
  1509. }
  1510. }
  1511. private function _u9scdexcel($arg_array){
  1512. $id = $arg_array[0];
  1513. $info = $this->bhccwl->read($id);
  1514. $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' ");
  1515. //生成excel
  1516. $filename = $info['bh_no']."备货生产单.xls";
  1517. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1518. <head>
  1519. <!--[if gte mso 9]><xml>
  1520. <x:ExcelWorkbook>
  1521. <x:ExcelWorksheets>
  1522. <x:ExcelWorksheet>
  1523. <x:Name>EXCEL</x:Name>
  1524. <x:WorksheetOptions>
  1525. <x:Print>
  1526. <x:ValidPrinterInfo />
  1527. </x:Print>
  1528. </x:WorksheetOptions>
  1529. </x:ExcelWorksheet>
  1530. </x:ExcelWorksheets>
  1531. </x:ExcelWorkbook>
  1532. </xml>
  1533. <![endif]-->
  1534. </head><body>";
  1535. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  1536. $str .= "<tr><td>备货单号</td><td>中文品名</td><td>u9料号</td><td>生产数量</td><td>u9生产单号</td></tr>";
  1537. foreach ($list as $key=>$value)
  1538. {
  1539. $str .= "<tr>";
  1540. $str .= "<td>". $value['bh_no']. "</td>";
  1541. $str .= "<td>". $value['title']. "</td>";
  1542. $str .= "<td>". $value['jm']. "</td>";
  1543. $str .= "<td>". $value['ck_num']. "</td>";
  1544. $str .= "<td>". $value['u9sc_no']. "</td>";
  1545. $str .= "</tr>";
  1546. }
  1547. $str .= "</table></body></html>";
  1548. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1549. header( "Content-type: application/octet-stream" );
  1550. header( "Content-Disposition: attachment; filename=".$filename );
  1551. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1552. header( "Pragma: no-cache" );
  1553. header( "Expires: 0" );
  1554. exit($str);
  1555. }
  1556. //打印标签
  1557. private function _printlabel(){
  1558. if($this->input->method() === 'post'){
  1559. $id = $this->input->post('id',true);
  1560. $xbqnum = $this->input->post('num',true);
  1561. $info = $this->bhdcd->read($id);
  1562. if(empty($info)){
  1563. echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
  1564. }
  1565. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $info['features']);
  1566. $featurespp = explode('-', trim($featurespp, '-'));
  1567. if (isset($featurespp[5])) {
  1568. $tmp_featurespp = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  1569. } else {
  1570. $tmp_featurespp = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  1571. }
  1572. $label = '';
  1573. $cpid = $this->whlabellabel->find_count();
  1574. $cpid = $cpid + 1;
  1575. $time = time();
  1576. $label = time().rand(10,99);
  1577. $label = substr($label,1);
  1578. $insert_arr = [
  1579. 'purchase'=>1,
  1580. 'shop'=>'',
  1581. 'sku'=>$info['sku'],
  1582. 'number'=>$info['number'],
  1583. 'features'=>$info['features'],
  1584. 'featurespp'=>$tmp_featurespp,
  1585. 'title'=>$info['title'],
  1586. 'label'=>$label,
  1587. 'warehouse'=>13,
  1588. 'time'=>$time,
  1589. 'details'=>$info['kw'],
  1590. 'cpid'=>$cpid,
  1591. 'jm'=>$info['jm'],
  1592. 'cpbz'=>''
  1593. ];
  1594. $this->db->trans_begin();
  1595. $this->whlabellabel->insert($insert_arr);
  1596. if ($this->db->trans_status() === TRUE) {
  1597. $this->db->trans_commit();
  1598. } else {
  1599. $this->db->trans_rollback();
  1600. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  1601. exit;
  1602. }
  1603. $details = '位置:(' . $info['kw'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' ;
  1604. $details = ' <b style="font-size: 18px;">'."许昌仓</b> ".$details;
  1605. $purchase = "龙盈工厂";
  1606. 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));
  1607. exit; //特殊仓目前不需要仓库选项
  1608. }else{
  1609. echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
  1610. }
  1611. }
  1612. private function _dcdjzrk(){
  1613. if($this->input->method() === 'post'){
  1614. $id = $this->input->post('id',true);
  1615. $info = $this->bhdcd->read($id);
  1616. if($info['is_rk'] == 0){
  1617. $this->bhdcd->save(['is_rk'=>1],$id);
  1618. echo json_encode(['success'=>true,'msg'=>'此条信息已禁止入库']);exit;
  1619. }else{
  1620. echo json_encode(['success'=>true,'msg'=>'此条信息已禁止入库']);exit;
  1621. }
  1622. }else{
  1623. echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
  1624. }
  1625. }
  1626. }