Zzququeu9.php 66 KB

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