Beihuogl.php 87 KB

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