Zzququeu9.php 61 KB

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