Beihuogl.php 68 KB

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