12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Whlabel_bh extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_whlabel_bh','whlabel_bh');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_purchase','purchase');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullorder_smt','fullorder_smt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_kdniao','kdniao');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_dhl','dhl');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_fullorderexcel','fullorderexcel');
- $this->load->_model('Model_ljg','ljg');
- $this->load->_model('Model_usps','usps');
- $this->load->_model('Model_specialstock','specialstock');
- $this->load->_model('Model_whlabellabel','whlabellabel');
- $this->load->_model('Model_whlabelwz','whlabelwz');
- $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
- $this->load->_model('Model_whlabeltransport','whlabeltransport');
- $this->load->_model('Model_orderurl','orderurl');
- $this->load->_model('Model_brand','brand');
- $this->load->_model('Model_classid','classid');
- $this->load->_model('Model_apiyy','apiyy');
- $this->load->_model('Model_whlabel_bh_list','whlabel_bh_list');
- $this->load->_model('Model_whlabel','whlabel');
- $this->load->_model('Model_whlabel_bh_transfer','whlabel_bh_transfer');
- $this->load->_model('Model_transfer','transfer');
- $this->load->_model("Model_logic_u9tools","logic_u9tools");
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'add')
- {
- $this->_add();
- }
- else if($arg == 'edit')
- {
- $this->_edit($arg_array);
- }
- else if($arg == 'del')//删除
- {
- $this->_del();
- }
- else if($arg == 'deltransfer')//删除
- {
- $this->_deltransfer();
- }
- else if($arg == 'cz')//删除
- {
- $this->_cz();
- }
- else if($arg == 'db')//删除
- {
- $this->_db();
- }
- else if($arg == 'kc')//删除
- {
- $this->_kc();
- }
- else if($arg == 'excel')//删除
- {
- $this->_excel();
- }
- else if($arg == 'xxpl')//删除
- {
- $this->_xxpl();
- }
- else if($arg == 'bbprint')//删除
- {
- $this->_bbprint();
- }
- else if($arg == 'operate')
- {
- $this->_operate();
- }
- else if($arg == 'out')
- {
- $this->_out();
- }
- else if($arg == 'bdbb')
- {
- $this->_bdbb();
- }
- else
- {
- $this->_index();
- }
- }
- //管理
- public function _index()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $jm = $this->input->post('jm',true);
- $title = $this->input->post('title',true);
- $pm = $this->input->post('pm',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $type = $this->input->post('type',true);
- $shipremarks = $this->input->post('shipremarks',true);
- $type = $this->input->post('type',true);
- $state = $this->input->post('state',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1 ";
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo like '%$orderinfo%'";
- }
- if($type != '')
- {
- $where .= " and type = '$type'";
- }
- if($jm)
- {
- $where .= " and jm like '%$jm%'";
- }
- if($title)
- {
- $where .= " and title like '%$title%'";
- }
- if($pm)
- {
- $where .= " and pm like '%$pm%'";
- }
- if($category)
- {
- $where .= " and shipremarks like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and shipremarks like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and shipremarks like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and shipremarks like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and shipremarks like '%-$lowe-%'";
- }
- if($type)
- {
- $where .= " and type = '$type'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shipremarks)
- {
- $where .= " and shipremarks like '%$shipremarks%'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $warehouse = $this->warehouse->find_all();
- $ck = array();
- foreach ($warehouse as $v)
- {
- $ck[$v['id']] = $v['title'];
- }
- //取得信息列表
- $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,time,cscg',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $d = $this->whlabel_bh->read($value['id']);
- $info_list[$key]['title'] = "<font data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>".$d['jm'].'</font><br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
- $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
- $printnum = array_sum(array_column($printnum,'ts'));
- $info_list[$key]['printnum'] = $printnum;
- $info_list[$key]['num'] = $value['bhnum']-$printnum;
- $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
- $info_list[$key]['cscg'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
- }
- $total = $this->whlabel_bh->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
-
- /**
- $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,kcnum,num,rknum,dbnum,state,time,scapi,dbapi',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $d = $this->whlabel_bh->read($value['id']);
- if($d['print'] == 0)
- {
- $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #2ca8a1;'>未打印</span></p>";
- }
- else
- {
- $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #999;'>已打印</span></p>";
- }
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "<p>待生产/外购</p><p><span data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>传输料号</span></p>";//开 始
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "<p>生产/外购中</p><p><span data-id='".$value['id']."' data-cz='1' class='whlabel_bh_ks'>完成入库</span></p>".$print;
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "<p>已完成</p><p>已全部入库</p>";
- }
- $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
- $info_list[$key]['title'] = $d['jm'].'<br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
- $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
- $zc = '';
- foreach ($zd as $v)
- {
- $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
- }
- $info_list[$key]['scapi'] = $zc;
- $info_list[$key]['dbapi'] = "<span data-id='".$value['id']."' class='whlabel_bh_db'>调拨出库</span>";
- $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num'));
- }
- **/
- }
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- }
- else
- {
- header('Location: /');exit;
- }
- $w = $this->shop->find_all("yyid != ''");
- $this->data['yyck'] = $w;
- if($user['userid'] == 'ch')
- {
- $user['vip'] = 1;
- }
- $this->data['vip'] = $user['vip'];
- $this->_Template('whlabel_bh',$this->data);
- }
-
- //入库操作
- public function _add()
- {
- $tc = $this->typeclass->find_all();
- $typeclass = array();
- foreach ($tc as $v)
- {
- $tcjm[$v['id']] = array($v['jm'],$v['classid']);
- $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['num']))
- {
- $list = array();
- $sku = $this->input->post('sku',true);
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $xzsku = $this->input->post('xzsku',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- $classid = $this->classid->sku();
- $pm = $classid;
- $jm = $classid;
- $sku = $sku;
- $title = '';$features = '';$cs = array();
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- foreach($list as $k=>$v)
- {
- if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['bm'] != '')
- {
- $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
- }
- }
- if($v != 0)
- {
- if($k != 'size')
- {
- $title .= $typeclass[$v]['title']." ";
- }
- $features .=$v.'-';
- $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['title'] == '9A')
- {
- $pm[$typeclass[$v]['classid']] = '9A';
- }
- else if($typeclass[$v]['title'] == '10A')
- {
- $pm[$typeclass[$v]['classid']] = '10A';
- }
- else
- {
- $clzh = $typeclass[$v]['zh'];
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
- $clzh = $clzh[0];
- }
- $pm[$typeclass[$v]['classid']] = $clzh;
- }
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['jm'])
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
- }
- }
- }
- }
- $jm = array_filter($jm);//去除空值
- $jm = implode("-",$jm);
- $sku = array_filter($sku);//去除空值
- $sku = implode("-",$sku);
- $pm = array_filter($pm);//去除空值
- $pm = implode(" ",$pm);
- $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
- if($list['size'])
- {
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- }
- $title = trim($title,' ');
-
- $post['num'] = $this->input->post('num',true);
- $ztime = $this->input->post('ztime',true);
- $post['ztime'] = strtotime($ztime);
- $post['bm'] = '03'.implode("",$bmpx);
- $post['jm'] = $jm;
- $post['sku'] = $sku;
- $post['pm'] = $pm;
- $post['title'] = $title;
- $post['features'] = '-'.$features;
- $post['number'] = date('YmdHis',time()).rand(100,999);
- if(!$post['num'])
- {
- $post['number'] = date("YmdHis").rand(100,999);
- }
- $time = time();
- $post['time'] = $time;//操作时间
- $post['printnum'] = $time;
- $post['type'] = 0;
-
- //传输料号开始
- $lc = 0;
- $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
- if(isset($lh['Data'][0]))
- {
- if($lh['Data'][0]['m_isSucess'] != 1)
- {
- if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
- {
- echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
- }
- }
- }
- else
- {
- echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit;
-
- }
-
- if($this->whlabel_bh->insert($post))
- {
- echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
- }
- }
- $w = $this->shop->find_all("yyid != ''");
- $this->data['yyck'] = $w;
- $purchase = $this->purchase->find_all("yyid != ''");
- $this->data['purchase'] = $purchase;
- $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
- $this->_Template('whlabel_bh_add',$this->data);
- }
-
-
- public function get_cjlp($data)//创建料品
- {
- $list["0"]["Code"] = $data['jm'];//料号,SKU
- $list["0"]["Code1"] = '';
- $list["0"]["Name"] = $data['zh'];//产品名称
- $list["0"]["MainItemCategory"]["Code"] = $data['bm'];
- $list["0"]["Org"]["Code"] = 001;
- $list["0"]["OtherID"] = 1;
- $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1;
- $list["0"]["PurchaseInfo"]["PriceSource"] = 2;
- $list["0"]["PurchaseInfo"]["InquireRule"] = -1;
- $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0;
- $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1;
- $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true;
- $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true;
- $list["0"]["InventoryUOM"]["Code"] = '条';
- $list["0"]["InventorySecondUOM"]["Code"] = '';
- $list["0"]["IsDualUOM"] = false;
- $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4;
- $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1;
- $list["0"]["InventoryInfo"]["TurnOverRate"] = 1;
- $list["0"]["InventoryInfo"]["ReserveMode"] = -1;
- $list["0"]["InventoryInfo"]["SupplyMethod"] = -1;
- $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01;
- $list["0"]["DescFlexField"]["PubDescSeg5"] = 01;
- $list["0"]["Description"] = $data['title'];
- $list["0"]["ItemForm"] = 2001;
- $list["0"]["ItemFormAttribute"] = 10;
- $list["0"]["IsInventoryEnable"] = true;
- $list["0"]["IsPurchaseEnable"] = true;
- $list["0"]["IsSalesEnable"] = true;
- $list["0"]["IsBuildEnable"] = true;
- $list["0"]["IsOutsideOperationEnable"] = true;
- $list["0"]["IsMRPEnable"] = true;
- $list["0"]["IsBOMEnable"] = true;
- $list["0"]["IsCostCalByGrade"] = false;
- $list["0"]["IsCostCalByPotency"] = false;
- $list["0"]["IsGradeControl"] = false;
- $list["0"]["StandardGrade"] = -1;
- $list["0"]["StartGrade"] = -1;
- $list["0"]["EndGrade"] = -1;
- $list["0"]["IsPotencyControl"] = false;
- $list["0"]["StandardPotency"] = -1;
- $list["0"]["StartPotency"] = -1;
- $list["0"]["EndPotency"] = -1;
- $asd = $list;
- $list = json_encode($list);
- $token = $this->setting->get_yytoken_130();
- $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create';
- $header[] = "Content-Type: application/json";
- $header[] = "Token: ".$token;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- $res = curl_exec($ch);
- $res = json_decode($res,true);
- return $asd;
- }
-
-
- //修改产品
- public function _edit($arg_array)
- {
- $tc = $this->typeclass->find_all();
- $typeclass = array();
- foreach ($tc as $v)
- {
- $tcjm[$v['id']] = array($v['jm'],$v['classid']);
- $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $list = array();
- $sku = $this->input->post('sku',true);
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $xzsku = $this->input->post('xzsku',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- $classid = $this->classid->sku();
- $pm = $classid;
- $jm = $classid;
- $sku = $sku;
- $title = '';$features = '';$cs = array();
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- foreach($list as $k=>$v)
- {
- if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['bm'] != '')
- {
- $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
- }
- }
- if($v != 0)
- {
- if($k != 'size')
- {
- $title .= $typeclass[$v]['title']." ";
- }
- $features .=$v.'-';
- $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['title'] == '9A')
- {
- $pm[$typeclass[$v]['classid']] = '9A';
- }
- else if($typeclass[$v]['title'] == '10A')
- {
- $pm[$typeclass[$v]['classid']] = '10A';
- }
- else
- {
- $clzh = $typeclass[$v]['zh'];
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
- $clzh = $clzh[0];
- }
- $pm[$typeclass[$v]['classid']] = $clzh;
- }
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['jm'])
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
- }
- }
- }
- }
- $jm = array_filter($jm);//去除空值
- $jm = implode("-",$jm);
- $sku = array_filter($sku);//去除空值
- $sku = implode("-",$sku);
- $pm = array_filter($pm);//去除空值
- $pm = implode(" ",$pm);
- $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
- if($list['size'])
- {
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- }
- $title = trim($title,' ');
-
- $post['num'] = $this->input->post('num',true);
- $ztime = $this->input->post('ztime',true);
- $post['ztime'] = strtotime($ztime);
- $post['bm'] = '03'.implode("",$bmpx);
- $post['jm'] = $jm;
- $post['sku'] = $sku;
- $post['pm'] = $pm;
- $post['title'] = $title;
- $post['features'] = '-'.$features;
-
- $ztime = $this->input->post('ztime',true);
- if($ztime)
- {
- $post['ztime'] = strtotime($ztime);
- }
-
- if($this->whlabel_bh->save($post,$id))
- {
- echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
- }
- }
- $w = $this->shop->find_all("yyid != ''");
- $this->data['yyck'] = $w;
- $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
- $this->data['whlabel_bh'] = $whlabel_bh ;
- $purchase = $this->purchase->find_all("yyid != ''");
- $this->data['purchase'] = $purchase;
- $this->_Template('whlabel_bh_edit',$this->data);
- }
-
- public function _cz()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $cz = $this->input->post('cz',true);
- $num = $this->input->post('num',true);
- $cz = $cz+1;
- $w = $this->whlabel_bh->read($id);
- if(!$w)
- {
- echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
- }
-
- //传输料号开始
- $lc = 0;
- $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
- if(isset($lh['Data'][0]))
- {
- if($lh['Data'][0]['m_isSucess'] != 1)
- {
- if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
- {
- echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
- }
- }
- }
- else
- {
- echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
-
- }
- echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true));
- /** 投产
-
-
- if($w['scapi'] != 99)
- {
- if($w['state'] == $cz)
- {
- echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
- }
- if($w['type'] == '0')
- {
- $type = '生产';
- $bhlx = 0;
- }
- else
- {
- $type = '外购';
- $bhlx = 1;
- }
- $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
- if($yy['c'] == 0)
- {
- if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
- {
- echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
- }
- else
- {
- echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
- }
- }
- else
- {
- echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
- }
- }
- else if($w['dbapi'] != 99 && $w['type'] == '0')
- {
- $cz = 1;
- if(!is_numeric($num))
- {
- echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
- }
- if($num > $w['num']-$w['rknum'])
- {
- echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
- }
- if($w['rknum']+$num == $w['num'])
- {
- $dbapi = 99;
- $cz = 2;
- }
- else
- {
- $dbapi = 0;
- }
- $w['ts'] = $num;
- $rk = $this->apiyy->_newrk($w);
- if($rk['c'] == 0)
- {
- if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
- {
- if($dbapi == 99)
- {
- echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
- }
- else
- {
- echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
- }
- }
- else
- {
- echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
- }
- }
- else
- {
- $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
- echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
- }
- }
- else if($w['dbapi'] != 99 && $w['type'] == '1')
- {
- $cz = 1;
- if(!is_numeric($num))
- {
- echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
- }
- if($num > $w['num']-$w['rknum'])
- {
- echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
- }
- if($w['rknum']+$num == $w['num'])
- {
- $dbapi = 99;
- $cz = 2;
- }
- else
- {
- $dbapi = 0;
- }
- $scid = explode('~',$w['scid']);
- $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
- if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
- {
- if($dbapi == 99)
- {
- echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
- }
- else
- {
- echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
- }
- }
- else
- {
- echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
- }
- }
- **/
-
-
- }
- }
-
-
- public function _db()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $num = $this->input->post('num',true);
- $warehouse = $this->input->post('warehouse',true);
- $w = $this->warehouse->read($warehouse);
- $data = $this->whlabel_bh->read($id);
- if(!$data)
- {
- echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
- }
- $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
- $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
- if($num > $data['rknum']-$ydbnum)
- {
- echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
- }
- $data['dccbm'] = 13001;//默认从许昌仓调出
- $data['ts'] = $num;
- $data['drcbm'] = $w['yybm'];
- $dc = $this->apiyy->get_cpdc($data);
- if(isset($dc['Data'][0]))
- {
- if($dc['Data'][0]['IsSucess'] != 1)
- {
- echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
- }
- else
- {
- $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
- if(isset($sh['Data'][0]))
- {
- $code = $sh['Data'][0]['Code'];
- echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
- }
- else
- {
- $code = '';
- echo json_encode(array('msg'=>'调出成功!','success'=>true));
- }
- $p['uid'] = $id;
- $p['bm'] = $data['bm'];
- $p['sku'] = $data['jm'];
- $p['shipremarks'] = $data['shipremarks'];
- $p['title'] = $data['title'];
- $p['zh'] = $data['pm'];
- $p['fpdata'] = $data['features'];
- $p['num'] = $num;
- $p['warehouse'] = 13;//默认从许昌仓调出
- $p['rwarehouse'] = $warehouse;
- $p['time'] = time();//操作时间
- $p['code'] = $code;
- $this->whlabel_bh_list->insert($p);
- }
- }
- else
- {
- echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
- }
- }
- }
-
-
-
- public function _del()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',trim($id_arr,','));
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $w = $this->whlabel_bh->read($v);
- if($w['state'] > 0)
- {
- // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
- }
- }
- foreach ($id_arr as $v)
- {
- $this->whlabel_bh->remove($v);
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
- }
- }
-
- public function _deltransfer()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',trim($id_arr,','));
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- if(count($id_arr) > 1)
- {
- echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
- }
- foreach ($id_arr as $v)
- {
- $this->whlabel_bh_transfer->remove($v);
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
- }
- }
-
- public function _kc()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['category']))
- {
- $list = array();
- $sku = $this->input->post('sku',true);
- $features = $this->input->post('features',true);
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $xzsku = $this->input->post('xzsku',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- $shipremarks = '';
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $shipremarks .=$v.'-';
- }
- }
- $shipremarks = '-'.$shipremarks;
- if($features)
- {
- $shipremarks = $features;
- }
- $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
- if($w > 0)
- {
- echo json_encode(array('msg'=>$w,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
- }
- }
- }
-
-
-
- public function _excel()
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = $v;
- }
- $prc = array();
- $purchase = $this->purchase->find_all();
- foreach($purchase as $k=>$v)
- {
- $prc[$v['id']] = $v['title'];
- }
- if(isset($_GET['excel']))
- {
- $number = $this->input->post('number',true);
- $sku = $this->input->post('sku',true);
- $title = $this->input->post('title',true);
- $pm = $this->input->post('pm',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $shipremarks = $this->input->post('shipremarks',true);
- $type = $this->input->post('type',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($number)
- {
- $where .= " and number like '%$number%'";
- }
- if($type != '')
- {
- $where .= " and type = '$type'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($title)
- {
- $where .= " and title like '%$title%'";
- }
- if($pm)
- {
- $where .= " and pm like '%$pm%'";
- }
- if($category)
- {
- $where .= " and shipremarks like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and shipremarks like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and shipremarks like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and shipremarks like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and shipremarks like '%-$lowe-%'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shipremarks)
- {
- $where .= " and shipremarks like '%$shipremarks%'";
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere = " and (".rtrim($sd,'or').")";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
-
- /**
- $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
- }
- **/
- $warehouse = $this->warehouse->find_all();
- $ck = array();
- foreach ($warehouse as $v)
- {
- $ck[$v['id']] = $v['title'];
- }
- $list = array();
- $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
- foreach ($rows as $key=>$value)
- {
- if($value['state'] == 0)
- {
- $rows[$key]['state'] = "待生产/外购";
- }
- else if($value['state'] == 1)
- {
- $rows[$key]['state'] = "生产/外购中";
- }
- else if($value['state'] == 2)
- {
- $rows[$key]['state'] = "已完成";
- }
- $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
- $zc = '';
- foreach ($zd as $v)
- {
- $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
- }
- $rows[$key]['id'] = $zc;
- $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
- $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
- $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
- }
- $title = '备货详情';
- $titlename = "<table border=1>
- <tr align='center'>
- <td>状态</td>
- <td>标题</td>
- <td>流水码</td>
- <td>简码</td>
- <td>英文</td>
- <td>中文</td>
- <td>备注</td>
- <td>备货数量</td>
- <td>库存数量</td>
- <td>生产/外购数量</td>
- <td>入库数量</td>
- <td>调拨数量</td>
- <td>调拨详情</td>>
- <td>生产时间</td>>
- <td>操作时间</td>>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
-
- }
-
-
- public function _xxpl()
- {
- /* 订单加入键值-j */
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- require_once "./data/excel/PHPExcel/IOFactory.php";
- @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $tc = $this->typeclass->find_all();
- $typeclass = array();
- foreach ($tc as $v)
- {
- $typeclass[$v['jm']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
- }
- $i = 0;$j = 0;$ed = array();
- $classid = $this->classid->sku();
- $typeclassid = [];
- foreach($tc as $v){
- $typeclassid[$v['id']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
- }
- $i = 0;$j = 0;$ed = [];
- $ck = [
- "成品仓"=>'99001',
- "美国仓"=>'02031',
- "AP"=>'0103001',
- "WK"=>'0103002',
- "QV"=>'0103003',
- "AS"=>'0103004',
- "H"=>"0103005",
- "AP英"=>"0103006",
- "YMS"=>"0103007",
- "AP新"=>"0103008",
- "WK新"=>"0103009",
- "H新"=>"0103010",
- "Bilisar"=>"0103011",
- "Estilar"=>"0103012",
- "QM"=>"0103013",
- "Afola"=>"0103014",
- "拼多多-Finsa"=>"0106002",
- "拼多多-艾彩"=>"0105001",
- "拼多多-Estilar"=>"0106001",
- "拼多多-QM"=>"0106003",
- ];
- foreach($list as $k=>$v){
- $res = $this->logic_u9tools->getGoodInfoByErpSku($v[0],$v[1],$typeclass,$typeclassid,$classid);
-
- if($res['code']==1){
- //传输料号开始
- $post = $res['data'];
- $post['orderinfo'] = $v[2];
- $post['num'] = $v[5];
- $post['state'] = ($v[3] == '生产')?0:1;
- $post['purchase'] = "";//供货商
- $post['shipremarks'] = empty($v[6])?" ":$v[6];//
- $post['rknum'] = 0;
- $post['scapi'] = 0;
- $post['dbapi'] = 0;
- $post['bhnum'] = $v[5];
- if(isset($ck[$v[4]])){
- $post['kh'] = $ck[$v[4]];
- }else{
- $j++;
- $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
- continue;
- }
-
- $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
- if(isset($lh['Data'][0]))
- {
- if($lh['Data'][0]['m_isSucess'] != 1)
- {
- if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
- {
- $j++;
- $ed[] = array($lh['Data'][0]['m_errorMsg'],$post['jm'],$post['bm']);
- }
- }
- }
- else
- {
- $j++;
- $ed[] = array('料号错误',$post['jm'],$post['bm']);
- }
- if($this->whlabel_bh->insert($post))
- {
- $i++;
- }
- else
- {
- $j++;
- $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
- }
- }else{
- $j++;
- $ed[] = array($res['msg'],$v[1],"");
- }
- }
- if($j > 0)
- {
- $time = date('Ymd',time());
- $title = '错误信息-'.$time;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
- }
- }
- else
- {
- echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
- }
- }
-
-
- public function _cslh($jm,$title,$pm,$bm)
- {
- $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
- if(isset($lh['Data'][0]))
- {
- if($lh['Data'][0]['m_isSucess'] != 1)
- {
- if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
- {
- return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
- }
- }
- }
- else
- {
- return array('msg'=>'料号错误','x'=>1);exit;
-
- }
- return array('x'=>2);exit;
-
- }
-
-
- public function _bbprint()
- {
- $time = time();
- $post = $this->input->post(NULL);
- if(isset($post['d']))
- {
- $order = 0;$time = time();
- $d = $this->input->post('d',true);
- $n = $this->input->post('n',true);//打印数量
- $data = $this->whlabel_bh->read($d);
- if(!$data)
- {
- echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
- }
- $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
- $printnum = array_sum(array_column($printnum,'ts'));
- if(($data['bhnum'] + 1)-$printnum-$n < 0)
- {
- echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
- }
- $post['number'] = $data['number'];
- $post['orderinfo'] = $data['orderinfo'];
- $post['type'] = 0;//0生产 1外购
- $post['features'] = $data['features'];
- $post['jm'] = $data['jm'];
- $post['bm'] = $data['bm'];
- $post['pm'] = $data['pm'];
- $post['sku'] = $data['sku'];
- $post['features'] = $data['features'];
- $post['number'] = $data['number'];
- $post['title'] = $data['title'];
- $post['printtime'] = $time;
- $post['ts'] = $n;
- $post['rk'] = "|15|";//默认订单中心 打印后直接入库
- $post['rktime'] = "|".$time."|";
- $post['ctime15'] = $time;
- $post['time'] = $time;
- $post['gtime'] = date('Yms',$time);
- $rows = array();
- $label = substr($time,1).rand(10,99);
- $post['label'] = $label;
- $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>$n);
- if($this->whlabel_bh_transfer->insert($post))
- {
- echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
- }
- else
- {
- $this->db->trans_rollback();
- echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
- }
- }
- }
-
- public function _operate()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $api = $this->input->post('api',true);
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $orderinfo = $this->input->post('number',true);
- $color = $this->input->post('color',true);
- $pm = $this->input->post('pm',true);
- $purchase = $this->input->post('purchase',true);
- $transfer = $this->input->post('transfer',true);
- $lx = $this->input->post('lx',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1";
- if($transfer)
- {
- $ctime = 'ctime'.$transfer;
- $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
- }
- else
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo like '%$orderinfo%'";
- }
- if($transfer)
- {
- $where .= " and rk like '%|".$transfer."|%'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($pm)
- {
- $where .= " and pm like '%$pm%'";
- }
- if($color)
- {
- $where .= " and fpdata like '%-".$color."-%'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
- $transfer = $this->transfer->find_all();
- $t = array();$ot = array();
- foreach ($transfer as $v)
- {
- $t[$v['id']] = $v['title'];
- $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
- }
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $dd = $this->whlabel_bh_transfer->read($value['id']);
- $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
- $rk = explode('|',trim($dd['rk'],'|'));
- $rktime = explode('|',trim($dd['rktime'],'|'));
- $ck = explode('|',trim($dd['ck'],'|'));
- $cktime = explode('|',trim($dd['cktime'],'|'));
- $info_list[$key]['time'] = '';
- for($i=0;$i<count($rk);$i++)
- {
- if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
- {
- $d = '<em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br>';
- }
- else
- {
- $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
- }
- $info_list[$key]['time'] .= $d;
- if(isset($ck[$i]) && $ck[$i] != '')
- {
- $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
- }
- }
- $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
- }
- $total = $this->whlabel_bh_transfer->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $pid = "";$tid="";$sid="";$wid="";
- $purchase = explode('|',trim($user['purchase'],'|'));
- $transfer = explode('|',trim($user['transfer'],'|'));
- $warehouse = explode('|',trim($user['warehouse'],'|'));
- foreach ($purchase as $value)
- {
- $pid .= " id = ".$value." or";
- }
- foreach ($transfer as $value)
- {
- $tid .= " id = ".$value." or";
- }
- foreach ($warehouse as $value)
- {
- $wid .= " id = ".$value." or";
- }
- }
- else
- {
- header('Location: /');exit;
- }
- $kx = '';$zjtab = '';
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['warehouse'] = $warehouse;
- $purchase = $this->purchase->find_all("yyid != ''");
- $this->data['purchase'] = $purchase;
- $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
- $this->data['transfer'] = $transfer;
- $this->data['vip'] = $user['vip'];
- $this->_Template('whlabel_bh_operate',$this->data);
- }
-
- public function _out()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['label']))
- {
- $time = time();
- $label = $this->input->post('label',true);
- $cz = $this->input->post('cz',true);
- $transfer = $this->input->post('transfer',true);
- if(!$label)
- {
- echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
- }
- if(!$transfer)
- {
- echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
- }
- $lb = $this->whlabel_bh_transfer->get_label($label);
- if(!$lb)
- {
- echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
- }
- $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
- $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
- if($cz == 1)
- {
- $lb['rk'] .= $transfer.'|';
- $lb['rktime'] .= $time.'|';
- if($lbrk[0] == $transfer)
- {
- echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
- }
- }
- else if($cz == 2)
- {
- $lb['ck'] .= $transfer.'|';
- $lb['cktime'] .= $time.'|';
- if($lbck[0] == $transfer)
- {
- echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
- }
- }
- $cztime = 'ctime'.$transfer;
- //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
- if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
- {
- echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
- }
- if($this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id']))
- {
- echo json_encode(array('music'=>'1','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
- }
- }
- }
-
- public function _bdbb()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',trim($id_arr,','));
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $t = $this->whlabel_bh_transfer->read($v);
- if(!isset($t['number']))
- {
- echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
- }
- $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>$t['ts']);
- }
- echo json_encode(array('rows'=>($rows),'success'=>true));exit;
- }
- }
- }
|