Beihuogl.php 65 KB

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