Beihuogl.php 87 KB

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