Zzququeu9.php 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Zzququeu9 extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_zzquque_u9','zzquque_u9');
  8. $this->load->_model("Model_logic_order","logic_order");
  9. $this->load->_model("Model_logic_u9xgsd","logic_u9xgsd");
  10. $this->load->_model("Model_logic_u9ztsd","logic_u9ztsd");
  11. $this->load->_model('Model_zzququeu9_logs','zzququeu9_logs');
  12. $this->load->_model("Model_logic_u9action","logic_u9action");
  13. }
  14. public function _remap($arg,$arg_array)
  15. {
  16. if($arg == 'dc')//调出单
  17. {
  18. $this->_dc($arg_array);
  19. }
  20. elseif($arg == 'cg')//采购
  21. {
  22. $this->_cg($arg_array);
  23. }
  24. elseif($arg == 'xs')//销售单
  25. {
  26. $this->_xs($arg_array);
  27. }
  28. elseif($arg == 'bzch')//标准出货
  29. {
  30. $this->_bzch($arg_array);
  31. }
  32. elseif($arg == 'bzsh')//标准收货
  33. {
  34. $this->_bzsh($arg_array);
  35. }
  36. elseif($arg == 'dr')//调入单
  37. {
  38. $this->_dr($arg_array);
  39. }
  40. elseif($arg == 'xs_two')//调入单
  41. {
  42. $this->_xs_two($arg_array);
  43. }
  44. elseif($arg == 'dczt')//在途的调出单
  45. {
  46. $this->_dczt($arg_array);
  47. }
  48. elseif($arg == 'add'){
  49. $this->_add();
  50. }
  51. elseif($arg == 'excel'){
  52. $this->_excel();
  53. }
  54. elseif($arg == 'mcindex')
  55. {
  56. $this->_mcindex();
  57. }
  58. elseif($arg == 'scdel')//删除
  59. {
  60. $this->_del($arg_array);
  61. }
  62. elseif($arg == 'waixiao')//编辑
  63. {
  64. $this->_waixiao($arg_array);
  65. }
  66. elseif($arg == 'wxcprk')//外销成品入库
  67. {
  68. $this->_wxcprk($arg_array);
  69. }
  70. elseif($arg == 'wxcprksh'){
  71. $this->_wxcprksh($arg_array);
  72. }
  73. elseif($arg == 'wxxs'){
  74. $this->_wxxs($arg_array);
  75. }elseif($arg == 'gcbh_index'){
  76. $this->_gcbh_index();
  77. }else
  78. {
  79. $this->_index();
  80. }
  81. }
  82. public function _index(){
  83. $post = $this->input->post(NULL, TRUE);
  84. if(isset($post['page']))
  85. {
  86. $page = $this->input->post('page',true);
  87. $perpage = $this->input->post('perpage',true);
  88. $timetk = $this->input->post('timetk',true);//订单开始时间
  89. $timetj = $this->input->post('timetj',true);//订单结束时间
  90. $timetk = strtotime($timetk);
  91. $timetj = strtotime($timetj);
  92. $status = $this->input->post('status',true);
  93. $order_no = $this->input->post('order_no',true);
  94. $where='type = 10 ';
  95. if($order_no){
  96. $where .= " and order_no = '".$order_no."' ";
  97. }
  98. if($status){
  99. if($status == 1){
  100. $where .= " and dc_status = 0 ";
  101. }elseif($status == 2){
  102. $where .= " and dc_status = -1 ";
  103. }elseif($status == 3){
  104. $where .= " and dc_status = -2 ";
  105. }elseif($status == 4){
  106. $where .= " and dc_status = -3 ";
  107. }elseif($status == 5){
  108. $where .= " and dc_status < 3 ";
  109. }
  110. }
  111. if($timetk && $timetj){
  112. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  113. }
  114. if(empty($page))
  115. {
  116. $start = 0;
  117. $perpage = 10;
  118. }
  119. else
  120. {
  121. $start = ($page - 1)*$perpage;
  122. }
  123. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  124. $type_list = $this->zzquque_u9->getType();
  125. $list = [];
  126. foreach($info_list as $k=>$v){
  127. $dc_no = "";
  128. if($v['dc_status'] == 0){
  129. $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  130. }elseif($v['dc_status'] == -1){
  131. $tmp_str = "异常信息";
  132. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  133. if(isset($error[0])){
  134. if($error[0]['apply_api']=='lpck'){
  135. $ret_data = json_decode($error[0]['ret_data'],true);
  136. $apply_data = json_decode($error[0]['apply_data'],true);
  137. if(isset($ret_data["ResMsg"])){
  138. if(empty($apply_data['0'])){
  139. $tmp_str = $ret_data["ResMsg"];
  140. }else{
  141. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  142. }
  143. }else{
  144. $tmp_str = "料品同步失败";
  145. }
  146. }else{
  147. $ret_data = json_decode($error[0]['ret_data'],true);
  148. if(isset($ret_data[0]["ResMsg"])){
  149. $tmp_str = $ret_data[0]["ResMsg"];
  150. }elseif(isset($ret_data['msg'])){
  151. $tmp_str = $ret_data['msg'];
  152. }else{
  153. $tmp_str = "料品同步失败";
  154. }
  155. }
  156. }
  157. $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';
  158. }
  159. if(!empty($v['dc_no'])){
  160. $dc_no = $v['dc_no']."<br/>".$dc_no;
  161. }
  162. $cg_no = "";
  163. if($v['cg_status'] == 0){
  164. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>";
  165. }elseif($v['cg_status'] == 1){
  166. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>";
  167. }elseif($v['cg_status'] == -1){
  168. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="采购单创建失败"></i><p>';
  169. }elseif($v['cg_status'] == 2){
  170. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>";
  171. }elseif($v['cg_status'] == -2){
  172. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="采购单提交失败"></i><p>';
  173. }elseif($v['cg_status'] == -3){
  174. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="采购单审核失败"></i><p>';
  175. }
  176. if(!empty($v['cg_no'])){
  177. $cg_no = $v['cg_no']."<br/>".$cg_no;
  178. }
  179. $xs_no = "";
  180. if($v['xs_status'] == 0){
  181. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  182. }elseif($v['xs_status'] == 1){
  183. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  184. }elseif($v['xs_status'] == -1){
  185. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="销售单创建失败"></i><p>';
  186. }elseif($v['xs_status'] == 2){
  187. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  188. }elseif($v['xs_status'] == -2){
  189. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="销售单提交失败"></i><p>';
  190. }elseif($v['xs_status'] == -3){
  191. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="销售单审核失败"></i><p>';
  192. }
  193. if(!empty($v['xs_no'])){
  194. $xs_no = $v['xs_no']."<br/>".$xs_no;
  195. }
  196. $xs_two_no ='';
  197. if($v['xs_two_status'] == 0){
  198. $xs_two_no .= "<span data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  199. }elseif($v['xs_two_status'] == 1){
  200. $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  201. }elseif($v['xs_two_status'] == -1){
  202. $xs_two_no .= "<span data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  203. }elseif($v['xs_two_status'] == 2){
  204. $xs_two_no .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  205. }elseif($v['xs_two_status'] == -2){
  206. $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  207. }elseif($v['xs_two_status'] == -3){
  208. $xs_two_no .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  209. }
  210. if(!empty($v['xs_two_no'])){
  211. $xs_two_no = $v['xs_two_no']."<br/>".$xs_two_no;
  212. }
  213. $bzch_no ="";
  214. if($v['bzch_status'] == 0){
  215. $bzch_no .= "<span data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>";
  216. }elseif($v['bzch_status'] == 1){
  217. $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>";
  218. }elseif($v['bzch_status'] == -1){
  219. $bzch_no .= "<span data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  220. }elseif($v['bzch_status'] == 2){
  221. $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>";
  222. }elseif($v['bzch_status'] == -2){
  223. $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  224. }elseif($v['bzch_status'] == -3){
  225. $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  226. }
  227. //$bzsh_no =empty($v['bzsh_no'])?"":$v['bzsh_no'];
  228. if(!empty($v['bzch_no'])){
  229. $bzch_no = $v['bzch_no']."<br/>".$bzch_no;
  230. }
  231. $dr_no = "";
  232. if($v['dr_status'] == 0){
  233. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>";
  234. }elseif($v['dr_status'] == 1){
  235. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>";
  236. }elseif($v['dr_status'] == -1){
  237. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  238. }elseif($v['dr_status'] == 2){
  239. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>";
  240. }elseif($v['dr_status'] == -2){
  241. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  242. }elseif($v['dr_status'] == -3){
  243. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  244. }
  245. if(!empty($v['dr_no'])){
  246. $dr_no = $v['dr_no']."<br/>".$dr_no;
  247. }
  248. $list[] = [
  249. 'id'=>$v['id'],
  250. 'order_no'=>$v['order_no'],
  251. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  252. 'dc_no'=> $dc_no,
  253. 'cg_no'=>$cg_no,
  254. 'xs_no'=>$xs_no,
  255. 'dr_no'=>$dr_no,
  256. 'xs_two_no'=>$xs_two_no,
  257. 'bzch_no'=>$bzch_no,
  258. //'bzsh_no'=>$bzsh_no,
  259. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  260. 'update_time'=>date("Y-m-d H:i:s",$v['update_time']),
  261. 'operate'=>($v['dc_status'] == 3)?"": "<span data-action='dr' data-id='".$v['id']."' onclick='doDel(this)' style='background-color:red'>删除</span>"
  262. ];
  263. }
  264. $total = $this->zzquque_u9->find_count($where);
  265. $pagenum = ceil($total/$perpage);
  266. $over = $total-($start+$perpage);
  267. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  268. echo json_encode($rows);exit;
  269. }
  270. $this->_Template('zzququeu9',$this->data);
  271. }
  272. public function _dc($arg_array){
  273. $process= $arg_array[0];
  274. $id = $arg_array[1];
  275. $info = $this->zzquque_u9->read($id);
  276. if($process == 1){
  277. if(!in_array($info['dc_status'],[0,-1])){
  278. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  279. exit;
  280. }
  281. $r = $this->logic_u9xgsd->createDc($info);
  282. if($r['code'] == 1){
  283. echo json_encode(array('msg'=>'创建调出单成功','success'=>true));
  284. exit;
  285. }else{
  286. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  287. exit;
  288. }
  289. }else if($process == 2){
  290. if(!in_array($info['dc_status'],[1,-2])){
  291. echo json_encode(array('msg'=>'当前状态不符合提交调出单的条件','success'=>false));
  292. exit;
  293. }
  294. $r = $this->logic_u9xgsd->subDc($info);
  295. if($r['code'] == 1){
  296. echo json_encode(array('msg'=>'提交调出单成功','success'=>true));
  297. exit;
  298. }else{
  299. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  300. exit;
  301. }
  302. }else if($process == 3){
  303. if(!in_array($info['dc_status'],[2,-3])){
  304. echo json_encode(array('msg'=>'当前状态不符合审核调出单的条件','success'=>false));
  305. exit;
  306. }
  307. $r = $this->logic_u9xgsd->shDc($info);
  308. if($r['code'] == 1){
  309. echo json_encode(array('msg'=>'审核调出单成功','success'=>true));
  310. exit;
  311. }else{
  312. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  313. exit;
  314. }
  315. }else{
  316. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  317. exit;
  318. }
  319. }
  320. public function _cg($arg_array){
  321. $process= $arg_array[0];
  322. $id = $arg_array[1];
  323. $info = $this->zzquque_u9->read($id);
  324. if($info['dc_status'] != 3){
  325. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  326. exit;
  327. }
  328. if($process == 1){
  329. if(!in_array($info['cg_status'],[0,-1])){
  330. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  331. exit;
  332. }
  333. $r = $this->logic_u9xgsd->createCg($info);
  334. if($r['code'] == 1){
  335. echo json_encode(array('msg'=>'创建采购单成功','success'=>true));
  336. exit;
  337. }else{
  338. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  339. exit;
  340. }
  341. }else if($process == 2){
  342. if(!in_array($info['cg_status'],[1,-2])){
  343. echo json_encode(array('msg'=>'当前状态不符合提交采购单的条件','success'=>false));
  344. exit;
  345. }
  346. $r = $this->logic_u9xgsd->subCg($info);
  347. if($r['code'] == 1){
  348. echo json_encode(array('msg'=>'提交采购单成功','success'=>true));
  349. exit;
  350. }else{
  351. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  352. exit;
  353. }
  354. }else if($process == 3){
  355. if(!in_array($info['cg_status'],[2,-3])){
  356. echo json_encode(array('msg'=>'当前状态不符合审核采购单的条件','success'=>false));
  357. exit;
  358. }
  359. $r = $this->logic_u9xgsd->shCg($info);
  360. if($r['code'] == 1){
  361. echo json_encode(array('msg'=>'审核采购单成功','success'=>true));
  362. exit;
  363. }else{
  364. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  365. exit;
  366. }
  367. }else{
  368. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  369. exit;
  370. }
  371. }
  372. public function _xs($arg_array){
  373. $process= $arg_array[0];
  374. $id = $arg_array[1];
  375. $info = $this->zzquque_u9->read($id);
  376. if($info['dc_status'] != 3){
  377. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  378. exit;
  379. }
  380. if($process == 1){
  381. if(!in_array($info['xs_status'],[0,-1])){
  382. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  383. exit;
  384. }
  385. $r = $this->logic_u9xgsd->createXs($info);
  386. if($r['code'] == 1){
  387. echo json_encode(array('msg'=>'创建销售单成功','success'=>true));
  388. exit;
  389. }else{
  390. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  391. exit;
  392. }
  393. }else if($process == 2){
  394. if(!in_array($info['xs_status'],[1,-2])){
  395. echo json_encode(array('msg'=>'当前状态不符合提交销售单的条件','success'=>false));
  396. exit;
  397. }
  398. $r = $this->logic_u9xgsd->subXs($info);
  399. if($r['code'] == 1){
  400. echo json_encode(array('msg'=>'提交销售单成功','success'=>true));
  401. exit;
  402. }else{
  403. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  404. exit;
  405. }
  406. }else if($process == 3){
  407. if(!in_array($info['xs_status'],[2,-3])){
  408. echo json_encode(array('msg'=>'当前状态不符合审核销售单的条件','success'=>false));
  409. exit;
  410. }
  411. $r = $this->logic_u9xgsd->shXs($info);
  412. if($r['code'] == 1){
  413. echo json_encode(array('msg'=>'审核销售单成功','success'=>true));
  414. exit;
  415. }else{
  416. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  417. exit;
  418. }
  419. }else{
  420. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  421. exit;
  422. }
  423. }
  424. public function _dr($arg_array){
  425. $process= $arg_array[0];
  426. $id = $arg_array[1];
  427. $info = $this->zzquque_u9->read($id);
  428. if($info['dc_status'] != 3){
  429. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  430. exit;
  431. }
  432. if($process == 1){
  433. if(!in_array($info['dr_status'],[0,-1])){
  434. echo json_encode(array('msg'=>'当前状态不符合查询调入单的条件','success'=>false));
  435. exit;
  436. }
  437. $r = $this->logic_u9xgsd->createDr($info);
  438. if($r['code'] == 1){
  439. echo json_encode(array('msg'=>'查询调入单成功','success'=>true));
  440. exit;
  441. }else{
  442. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  443. exit;
  444. }
  445. }else if($process == 2){
  446. if(!in_array($info['dr_status'],[1,-2])){
  447. echo json_encode(array('msg'=>'当前状态不符合提交调入单的条件','success'=>false));
  448. exit;
  449. }
  450. $r = $this->logic_u9xgsd->subDr($info);
  451. if($r['code'] == 1){
  452. echo json_encode(array('msg'=>'提交调入单成功','success'=>true));
  453. exit;
  454. }else{
  455. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  456. exit;
  457. }
  458. }else if($process == 3){
  459. if(!in_array($info['dr_status'],[2,-3])){
  460. echo json_encode(array('msg'=>'当前状态不符合审核调入单的条件','success'=>false));
  461. exit;
  462. }
  463. $r = $this->logic_u9xgsd->shDr($info);
  464. if($r['code'] == 1){
  465. echo json_encode(array('msg'=>'审核调入单成功','success'=>true));
  466. exit;
  467. }else{
  468. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  469. exit;
  470. }
  471. }else{
  472. echo json_encode(array('msg'=>'当前状态不符合创建调入单的条件','success'=>false));
  473. exit;
  474. }
  475. }
  476. public function _xs_two($arg_array){
  477. $process= $arg_array[0];
  478. $id = $arg_array[1];
  479. $info = $this->zzquque_u9->read($id);
  480. if($info['dc_status'] != 3){
  481. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  482. exit;
  483. }
  484. if($process == 1){
  485. if(!in_array($info['xs_two_status'],[0,-1])){
  486. echo json_encode(array('msg'=>'当前状态不符合查询香港销售单的条件','success'=>false));
  487. exit;
  488. }
  489. $r = $this->logic_u9xgsd->createXsTwo($info);
  490. if($r['code'] == 1){
  491. echo json_encode(array('msg'=>'创建香港销售单成功','success'=>true));
  492. exit;
  493. }else{
  494. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  495. exit;
  496. }
  497. }else if($process == 2){
  498. if(!in_array($info['xs_two_status'],[1,-2])){
  499. echo json_encode(array('msg'=>'当前状态不符合提交香港销售单的条件','success'=>false));
  500. exit;
  501. }
  502. $r = $this->logic_u9xgsd->subXsTwo($info);
  503. if($r['code'] == 1){
  504. echo json_encode(array('msg'=>'提交香港销售单成功','success'=>true));
  505. exit;
  506. }else{
  507. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  508. exit;
  509. }
  510. }else if($process == 3){
  511. if(!in_array($info['xs_two_status'],[2,-3])){
  512. echo json_encode(array('msg'=>'当前状态不符合审核香港销售单的条件','success'=>false));
  513. exit;
  514. }
  515. $r = $this->logic_u9xgsd->shXsTwo($info);
  516. if($r['code'] == 1){
  517. echo json_encode(array('msg'=>'审核香港销售单成功','success'=>true));
  518. exit;
  519. }else{
  520. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  521. exit;
  522. }
  523. }else{
  524. echo json_encode(array('msg'=>'当前状态不符合创建香港销售单的条件','success'=>false));
  525. exit;
  526. }
  527. }
  528. public function _bzch($arg_array){
  529. $process= $arg_array[0];
  530. $id = $arg_array[1];
  531. $info = $this->zzquque_u9->read($id);
  532. if($info['dc_status'] != 3){
  533. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  534. exit;
  535. }
  536. if($info['xs_two_status'] != 3){
  537. echo json_encode(array('msg'=>'香港销售单未审核不能执行后续操作','success'=>false));
  538. exit;
  539. }
  540. if($process == 1){
  541. if(!in_array($info['bzsh_status'],[0,-1])){
  542. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  543. exit;
  544. }
  545. $r = $this->logic_u9xgsd->createCh($info);
  546. if($r['code'] == 1){
  547. echo json_encode(array('msg'=>'创建标准收货单成功','success'=>true));
  548. exit;
  549. }else{
  550. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  551. exit;
  552. }
  553. }else if($process == 2){
  554. $r = $this->logic_u9xgsd->subAndShCh($info);
  555. if($r['code'] == 1){
  556. echo json_encode(array('msg'=>'审核标准收货单成功','success'=>true));
  557. exit;
  558. }else{
  559. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  560. exit;
  561. }
  562. }else{
  563. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  564. exit;
  565. }
  566. }
  567. public function _bzsh($arg_array){
  568. }
  569. public function _add(){
  570. $order_no = $this->input->post('order_no',true);
  571. if(empty($order_no)){
  572. echo json_encode(['msg'=>'请输入要添加的订单编码!','success'=>false]);exit;
  573. }
  574. $info = $this->logic_order->getInfo("number = '" .$order_no."'");
  575. if(empty($info)){
  576. echo json_encode(['msg'=>'订单不存在!请仔细核对单号','success'=>false]);exit;
  577. }
  578. $num = $this->zzquque_u9->find_all("order_no = '".$info['number']."'");
  579. if(empty($num)){
  580. $this->zzquque_u9->insert([
  581. 'platform'=>$info['lv_platform'],
  582. 'warehouse'=>$info['type'],
  583. 'type'=>10,
  584. 'order_no'=>$info['number'],
  585. 'create_time'=>time(),
  586. 'update_time'=>time(),
  587. ]);
  588. echo json_encode(['msg'=>'添加成功','success'=>true]);exit;
  589. }else{
  590. echo json_encode(['msg'=>'订单不允许重复添加','success'=>false]);exit;
  591. }
  592. }
  593. public function _excel(){
  594. $params = $this->input->get();
  595. $where = " type = 10 ";
  596. if(!empty($params['order_no'])){
  597. $where .= " and order_no = '".$params['order_no']."' ";
  598. }
  599. if(!empty($params['timetk'])){
  600. $where .= " and create_time > ".strtotime($params['timetk'])." ";
  601. }
  602. if(!empty($params['timetj'])){
  603. $where .= "and create_time < ".strtotime($params['timetj'])." ";
  604. }
  605. if(!empty($params['status'])){
  606. $status = $params['status'];
  607. if($status == 1){
  608. $where .= " and dc_status = 0 ";
  609. }elseif($status == 2){
  610. $where .= " and dc_status = -1 ";
  611. }elseif($status == 3){
  612. $where .= " and dc_status = -2 ";
  613. }elseif($status == 4){
  614. $where .= " and dc_status = -3 ";
  615. }elseif($status == 5){
  616. $where .= " and dc_status < 3 ";
  617. }
  618. }
  619. $info_list = $this->zzquque_u9->find_all($where,'*','id desc');
  620. $type_list = $this->zzquque_u9->getType();
  621. $list = [];
  622. foreach($info_list as $k=>$v){
  623. $dc_no = $v['dc_no'];
  624. $error_str = "";
  625. $error_json ="";
  626. if($v['dc_status'] == -1){
  627. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  628. $error_json = $error[0]['ret_data'];
  629. if($error[0]['apply_api']=='lpck'){
  630. $ret_data = json_decode($error[0]['ret_data'],true);
  631. $apply_data = json_decode($error[0]['apply_data'],true);
  632. if(isset($ret_data["ResMsg"])){
  633. if(empty($apply_data['0'])){
  634. $error_str = $ret_data["ResMsg"];
  635. }else{
  636. $error_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  637. }
  638. }else{
  639. $error_str = "料品同步失败";
  640. }
  641. }else{
  642. $ret_data = json_decode($error[0]['ret_data'],true);
  643. if(isset($ret_data[0]["ResMsg"])){
  644. $error_str = $ret_data[0]["ResMsg"];
  645. }elseif(isset($ret_data['msg'])){
  646. $error_str = $ret_data['msg'];
  647. }else{
  648. $error_str = "料品同步失败";
  649. }
  650. }
  651. }
  652. $list[] = [
  653. 'id'=>$v['id'],
  654. 'order_no'=>$v['order_no'],
  655. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  656. 'dc_no'=> $dc_no,
  657. 'error'=>$error_str,
  658. 'error_json'=>$error_json,
  659. //'bzsh_no'=>$bzsh_no,
  660. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  661. ];
  662. }
  663. $filename = date("Y-m-d")."u9小单导出.xls";
  664. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  665. <head>
  666. <!--[if gte mso 9]><xml>
  667. <x:ExcelWorkbook>
  668. <x:ExcelWorksheets>
  669. <x:ExcelWorksheet>
  670. <x:Name>EXCEL</x:Name>
  671. <x:WorksheetOptions>
  672. <x:Print>
  673. <x:ValidPrinterInfo />
  674. </x:Print>
  675. </x:WorksheetOptions>
  676. </x:ExcelWorksheet>
  677. </x:ExcelWorksheets>
  678. </x:ExcelWorkbook>
  679. </xml>
  680. <![endif]-->
  681. </head><body>";
  682. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  683. $str .= "<tr><td>id</td><td>订单号</td><td>类型</td><td>调出单号</td><td>创建时间</td><td>错误信息</td><td>错误json</td></tr>";
  684. foreach ($list as $key=>$value)
  685. {
  686. $str .= "<tr>";
  687. $str .= "<td>". $value['id']. "</td>";
  688. $str .= "<td>". $value['order_no']. "</td>";
  689. $str .= "<td>". $value['type']. "</td>";
  690. $str .= "<td>". $value['dc_no']. "</td>";
  691. $str .= "<td>". $value['create_time']. "</td>";
  692. $str .= "<td>". $value['error']. "</td>";
  693. $str .= "<td>". $value['error_json']. "</td>";
  694. $str .= "</tr>";
  695. }
  696. $str .= "</table></body></html>";
  697. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  698. header( "Content-type: application/octet-stream" );
  699. header( "Content-Disposition: attachment; filename=".$filename );
  700. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  701. header( "Pragma: no-cache" );
  702. header( "Expires: 0" );
  703. exit($str);
  704. }
  705. public function _mcindex(){
  706. $post = $this->input->post(NULL, TRUE);
  707. if(isset($post['page']))
  708. {
  709. $page = $this->input->post('page',true);
  710. $perpage = $this->input->post('perpage',true);
  711. $timetk = $this->input->post('timetk',true);//订单开始时间
  712. $timetj = $this->input->post('timetj',true);//订单结束时间
  713. $timetk = strtotime($timetk);
  714. $timetj = strtotime($timetj);
  715. $order_no = $this->input->post('order_no',true);
  716. $type = $this->input->post('type',true);
  717. if($type == 1){
  718. $where=' ( type = 1)';
  719. }elseif($type == 2){
  720. $where=' ( type = 2)';
  721. }else{
  722. $where=' ( type = 1 or type = 2)';
  723. }
  724. if($order_no){
  725. $where .= " and order_no = '".$order_no."' ";
  726. }
  727. if($timetk && $timetj){
  728. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  729. }
  730. if(empty($page))
  731. {
  732. $start = 0;
  733. $perpage = 1;
  734. }
  735. else
  736. {
  737. $start = ($page - 1)*$perpage;
  738. }
  739. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  740. $type_list = $this->zzquque_u9->getType();
  741. $list = [];
  742. foreach($info_list as $k=>$v){
  743. $dc_no = "";
  744. if($v['dc_status'] == 0){
  745. if($v['type'] == 1){
  746. $dc_no = "<span data-action='dczt' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  747. }
  748. }elseif($v['dc_status'] == -1){
  749. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  750. if($error[0]['apply_api']=='lpck'){
  751. $ret_data = json_decode($error[0]['ret_data'],true);
  752. $apply_data = json_decode($error[0]['apply_data'],true);
  753. if(isset($ret_data["ResMsg"])){
  754. if(empty($apply_data['0'])){
  755. $tmp_str = $ret_data["ResMsg"];
  756. }else{
  757. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  758. }
  759. }else{
  760. $tmp_str = "料品同步失败";
  761. }
  762. }else{
  763. $tmp_str= "";
  764. $ret_data = json_decode($error[0]['ret_data'],true);
  765. if(isset($ret_data[0]["ResMsg"])){
  766. $tmp_str = $ret_data[0]["ResMsg"];
  767. }elseif(isset($ret_data['msg'])){
  768. $tmp_str = $ret_data['msg'];
  769. }elseif(isset($ret_data['Data'])){
  770. foreach($ret_data['Data'] as $iit){
  771. if(!$iit['IsSucess']){
  772. $tmp_str .= $iit['ErrorMsg']."<br>";
  773. }
  774. }
  775. }else{
  776. $tmp_str = "料品同步失败";
  777. }
  778. }
  779. $dc_no = "<span data-action='dczt' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';
  780. }
  781. if(!empty($v['dc_no'])){
  782. if($v['type'] == 1){
  783. $dc_no = $v['dc_no']."【销售组织】"."<br/>".$dc_no;
  784. }else{
  785. $dc_no = $v['dc_no']."【香港组织】"."<br/>".$dc_no;
  786. }
  787. }
  788. $cg_no = "";
  789. if($v['type'] == 1){
  790. if($v['cg_status'] == 1){
  791. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."'>采购单提交异常</span>";
  792. }elseif($v['cg_status'] == -1){
  793. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' >创建采购单失败</span>";
  794. }elseif($v['cg_status'] == 2){
  795. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单未审核</span>";
  796. }elseif($v['cg_status'] == -2){
  797. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' >采购单提交失败</span>";
  798. }elseif($v['cg_status'] == -3){
  799. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单审核失败</span>";
  800. }
  801. if(!empty($v['cg_no'])){
  802. $cg_no = $v['cg_no']."【香港组织】<br/>".$cg_no;
  803. }
  804. }
  805. $xs_no = "";
  806. if($v['type'] == 1){
  807. if($v['xs_status'] == 1){
  808. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单未提交</span>";
  809. }elseif($v['xs_status'] == -1){
  810. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' >销售单创建失败</span>";
  811. }elseif($v['xs_status'] == 2){
  812. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单未审核</span>";
  813. }elseif($v['xs_status'] == -2){
  814. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单提交失败</span>";
  815. }elseif($v['xs_status'] == -3){
  816. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单审核失败</span>";
  817. }
  818. if(!empty($v['xs_no'])){
  819. $xs_no = $v['xs_no']."【销售组织】<br/>".$xs_no;
  820. }
  821. }
  822. $dr_no = "";
  823. if($v['dr_status'] == 1){
  824. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单未提交</span>";
  825. }elseif($v['dr_status'] == -1){
  826. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' >创建调入单失败</span>";
  827. }elseif($v['dr_status'] == 2){
  828. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单未审核</span>";
  829. }elseif($v['dr_status'] == -2){
  830. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单提交失败</span>";
  831. }elseif($v['dr_status'] == -3){
  832. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单审核失败</span>";
  833. }
  834. if(!empty($v['dr_no'])){
  835. $dr_no = $v['dr_no']."【香港组织】<br/>".$dr_no;
  836. }
  837. $type = "";
  838. if(isset($type_list[$v['type']])){
  839. if($v['type'] == 2){
  840. $type = "<i style='color:#70B'>".$type_list[$v['type']]."</i>";
  841. }else{
  842. $type = "<i>".$type_list[$v['type']]."</i>";
  843. }
  844. }else{
  845. $type = "<b style='color:red'>异常</b>";
  846. }
  847. $list[] = [
  848. 'id'=>$v['id'],
  849. 'order_no'=>$v['order_no'],
  850. 'type'=>$type,
  851. 'dc_no'=> $dc_no,
  852. 'cg_no'=>$cg_no,
  853. 'xs_no'=>$xs_no,
  854. 'dr_no'=>$dr_no,
  855. // 'xs_two_no'=>"",
  856. // 'bzch_no'=>"",
  857. //'bzsh_no'=>$bzsh_no,
  858. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  859. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  860. ];
  861. }
  862. $total = $this->zzquque_u9->find_count($where);
  863. $pagenum = ceil($total/$perpage);
  864. $over = $total-($start+$perpage);
  865. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  866. echo json_encode($rows);exit;
  867. }
  868. $this->_Template('zzququeu9zt',$this->data);
  869. }
  870. public function _dczt($arg_array){
  871. $process= $arg_array[0];
  872. $id = $arg_array[1];
  873. $info = $this->zzquque_u9->read($id);
  874. if($process == 1){
  875. if(!in_array($info['dc_status'],[0,-1])){
  876. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  877. exit;
  878. }
  879. $r = $this->logic_u9ztsd->createdDc($info);
  880. if($r['code'] == 1){
  881. echo json_encode(array('msg'=>'创建调出单成功','success'=>true));
  882. exit;
  883. }else{
  884. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  885. exit;
  886. }
  887. }else{
  888. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  889. exit;
  890. }
  891. }
  892. private function _del($arg_array){
  893. $id = $arg_array[0];
  894. $user = $this->user->get_api($_SESSION['api']);
  895. if(!in_array($user['userid'],['ceshi','admin'])){
  896. echo json_encode(array('msg'=>'权限不足,禁止删除!','success'=>false));
  897. }
  898. $info = $this->zzquque_u9->read($id);
  899. //目前只删除小单的 在途的单子 不管对错都不处理留痕
  900. if(($info['dc_status'] < 3) && ($info['type'] == 10)){
  901. $this->zzquque_u9->remove($id);
  902. echo json_encode(array('msg'=>'删除成功','success'=>true));
  903. }else{
  904. echo json_encode(array('msg'=>'不满足删除条件','success'=>true));
  905. }
  906. }
  907. public function _waixiao(){
  908. $post = $this->input->post(NULL, TRUE);
  909. if(isset($post['page']))
  910. {
  911. $page = $this->input->post('page',true);
  912. $perpage = $this->input->post('perpage',true);
  913. $timetk = $this->input->post('timetk',true);//订单开始时间
  914. $timetj = $this->input->post('timetj',true);//订单结束时间
  915. $timetk = strtotime($timetk);
  916. $timetj = strtotime($timetj);
  917. $order_no = $this->input->post('order_no',true);
  918. $type = $this->input->post('type',true);
  919. $where = " ( type = 20) ";
  920. if($order_no){
  921. $where .= " and order_no like '%".$order_no."%' ";
  922. }
  923. if($timetk && $timetj){
  924. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  925. }
  926. if(empty($page))
  927. {
  928. $start = 0;
  929. $perpage = 1;
  930. }
  931. else
  932. {
  933. $start = ($page - 1)*$perpage;
  934. }
  935. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  936. $type_list = $this->zzquque_u9->getType();
  937. $list = [];
  938. foreach($info_list as $k=>$v){
  939. $bzsh_no = $v['bzsh_no'];
  940. if($v['bzsh_status'] == 0){
  941. $bzsh_no = "<span data-action='wxcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  942. }elseif($v['bzsh_status'] == -1){
  943. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);
  944. $tmp_str= "";
  945. if(isset($error[0]['ret_data'])){
  946. $ret_data = json_decode($error[0]['ret_data'],true);
  947. if(isset($ret_data[0]["ResMsg"])){
  948. $tmp_str = $ret_data[0]["ResMsg"];
  949. }elseif(isset($ret_data['msg'])){
  950. $tmp_str = $ret_data['msg'];
  951. }elseif(isset($ret_data['Data'])){
  952. foreach($ret_data['Data'] as $iit){
  953. if(!$iit['m_isSucess']){
  954. $tmp_str .= $iit['m_errorMsg']."<br>";
  955. }
  956. }
  957. }else{
  958. $tmp_str = "系统执行失败,请重试";
  959. }
  960. }else{
  961. $tmp_str = "";
  962. }
  963. $bzsh_no = "<span data-action='wxcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';
  964. }elseif($v['bzsh_status'] == 1){
  965. $bzsh_no = $v['bzsh_no']."<br/><span data-action='wxcprksh' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  966. }
  967. $xs_no = " ";
  968. if($v['xs_status'] == -1){
  969. $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  970. }elseif($v['xs_status'] == 0){
  971. $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  972. }
  973. if(!empty($v['xs_no'])){
  974. $xs_no = $v['xs_no']."<br/>".$xs_no;
  975. }
  976. $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];
  977. $list[] = [
  978. 'id'=>$v['id'],
  979. 'order_no'=>$v['order_no'],
  980. 'type'=>"工厂外销单",
  981. 'bzsh_no'=> $bzsh_no,
  982. 'xs_no'=>$xs_no,
  983. 'bzch_no'=>$bzch_no,
  984. // 'xs_two_no'=>"",
  985. // 'bzch_no'=>"",
  986. //'bzsh_no'=>$bzsh_no,
  987. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  988. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  989. ];
  990. }
  991. $total = $this->zzquque_u9->find_count($where);
  992. $pagenum = ceil($total/$perpage);
  993. $over = $total-($start+$perpage);
  994. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  995. echo json_encode($rows);exit;
  996. }
  997. $this->_Template('zzququeu9wx',$this->data);
  998. }
  999. public function _wxcprk($arg_array){
  1000. $id = $arg_array[0];
  1001. $info = $this->zzquque_u9->read($id);
  1002. if(empty($info)){
  1003. echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));
  1004. exit;
  1005. }
  1006. if($info['bzsh_status'] != 0){
  1007. echo json_encode(array('msg'=>"当前状态不符合创建成品入库单的条件",'success'=>false));
  1008. exit;
  1009. }
  1010. $res = $this->logic_u9action->doRkd($info);
  1011. if($res['code'] == 1){
  1012. echo json_encode(array('msg'=>'创建成品入库单成功','success'=>true));
  1013. exit;
  1014. }else{
  1015. echo json_encode(array('msg'=>$res['msg'],'success'=>false));
  1016. exit;
  1017. }
  1018. }
  1019. public function _wxcprksh($arg_array){
  1020. $id = $arg_array[0];
  1021. $info = $this->zzquque_u9->read($id);
  1022. if(empty($info)){
  1023. echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));
  1024. exit;
  1025. }
  1026. if($info['bzsh_status'] != 0){
  1027. echo json_encode(array('msg'=>"当前状态不符合审核成品入库单的条件",'success'=>false));
  1028. exit;
  1029. }
  1030. $res = $this->logic_u9action->checkRkd($info);
  1031. if($res['code'] == 1){
  1032. echo json_encode(array('msg'=>'审核成品入库单成功','success'=>true));
  1033. exit;
  1034. }else{
  1035. echo json_encode(array('msg'=>$res['msg'],'success'=>false));
  1036. exit;
  1037. }
  1038. }
  1039. public function _wxxs($arg_array){
  1040. $id = $arg_array[0];
  1041. $info = $this->zzquque_u9->read($id);
  1042. if(empty($info)){
  1043. echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));
  1044. exit;
  1045. }
  1046. if($info['xs_status'] != 0){
  1047. echo json_encode(array('msg'=>"当前状态不符合创建销售单的条件",'success'=>false));
  1048. exit;
  1049. }
  1050. $res = $this->logic_u9action->createXsd($info);
  1051. if($res['code'] == 1){
  1052. echo json_encode(array('msg'=>'创建销售单成功','success'=>true));
  1053. exit;
  1054. }else{
  1055. echo json_encode(array('msg'=>$res['msg'],'success'=>false));
  1056. exit;
  1057. }
  1058. }
  1059. public function _gcbh_index(){
  1060. $post = $this->input->post(NULL, TRUE);
  1061. if(isset($post['page']))
  1062. {
  1063. $page = $this->input->post('page',true);
  1064. $perpage = $this->input->post('perpage',true);
  1065. $timetk = $this->input->post('timetk',true);//订单开始时间
  1066. $timetj = $this->input->post('timetj',true);//订单结束时间
  1067. $timetk = strtotime($timetk);
  1068. $timetj = strtotime($timetj);
  1069. $order_no = $this->input->post('order_no',true);
  1070. $type = $this->input->post('type',true);
  1071. $where = " ( type = 21) ";
  1072. if($order_no){
  1073. $where .= " and order_no like '%".$order_no."%' ";
  1074. }
  1075. if($timetk && $timetj){
  1076. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  1077. }
  1078. if(empty($page))
  1079. {
  1080. $start = 0;
  1081. $perpage = 1;
  1082. }
  1083. else
  1084. {
  1085. $start = ($page - 1)*$perpage;
  1086. }
  1087. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  1088. $type_list = $this->zzquque_u9->getType();
  1089. $list = [];
  1090. foreach($info_list as $k=>$v){
  1091. $bzsh_no = $v['bzsh_no'];
  1092. if($v['bzsh_status'] == 0){
  1093. $bzsh_no = "<span data-action='wxcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  1094. }elseif($v['bzsh_status'] == -1){
  1095. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);
  1096. $tmp_str= "";
  1097. if(isset($error[0]['ret_data'])){
  1098. $ret_data = json_decode($error[0]['ret_data'],true);
  1099. if(isset($ret_data[0]["ResMsg"])){
  1100. $tmp_str = $ret_data[0]["ResMsg"];
  1101. }elseif(isset($ret_data['msg'])){
  1102. $tmp_str = $ret_data['msg'];
  1103. }elseif(isset($ret_data['Data'])){
  1104. foreach($ret_data['Data'] as $iit){
  1105. if(!$iit['m_isSucess']){
  1106. $tmp_str .= $iit['m_errorMsg']."<br>";
  1107. }
  1108. }
  1109. }else{
  1110. $tmp_str = "系统执行失败,请重试";
  1111. }
  1112. }else{
  1113. $tmp_str = "";
  1114. }
  1115. $bzsh_no = "<span data-action='wxcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';
  1116. }elseif($v['bzsh_status'] == 1){
  1117. $bzsh_no = $v['bzsh_no']."<br/><span data-action='wxcprksh' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  1118. }
  1119. $xs_no = " ";
  1120. if($v['xs_status'] == -1){
  1121. $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  1122. }elseif($v['xs_status'] == 0){
  1123. $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  1124. }
  1125. if(!empty($v['xs_no'])){
  1126. $xs_no = $v['xs_no']."<br/>".$xs_no;
  1127. }
  1128. $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];
  1129. $list[] = [
  1130. 'id'=>$v['id'],
  1131. 'order_no'=>$v['order_no'],
  1132. 'type'=>"工厂外销单",
  1133. 'bzsh_no'=> $bzsh_no,
  1134. 'xs_no'=>$xs_no,
  1135. 'bzch_no'=>$bzch_no,
  1136. // 'xs_two_no'=>"",
  1137. // 'bzch_no'=>"",
  1138. //'bzsh_no'=>$bzsh_no,
  1139. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  1140. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  1141. ];
  1142. }
  1143. $total = $this->zzquque_u9->find_count($where);
  1144. $pagenum = ceil($total/$perpage);
  1145. $over = $total-($start+$perpage);
  1146. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1147. echo json_encode($rows);exit;
  1148. }
  1149. $this->_Template('zzququeu9gcbh',$this->data);
  1150. }
  1151. }