1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777 |
- <?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");
- $this->load->_model("Model_logic_ding","logic_ding");
- }
- //定义方法的调用规则 获取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']));
- $this->logic_ding->sendToDing("备货批量导入出现的错误信息".json_encode($lh,JSON_UNESCAPED_UNICODE));
- 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;
- }
- }
- }
|