Beihuogl.php 89 KB

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