Beihuogl.php 70 KB

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