load->library('session');
$this->load->_model('Model_specialstock','specialstock');
$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_whlabelwz','whlabelwz');
$this->load->_model('Model_classid','classid');
$this->load->_model("Model_logic_u9tools","logic_u9tools");
}
//定义方法的调用规则 获取URI第二段值
public function _remap($arg,$arg_array)
{
if($arg == 'existence')//在库标签
{
$this->_existence();
}
else if($arg == 'cpbqdc')//在库标签
{
$this->_cpbqdc();
}
else if($arg == 'type')//进销存浏览
{
$this->_type($arg_array);
}
else if($arg == 'xhctype')//现货仓进销存浏览
{
$this->_xhctype($arg_array);
}
else if($arg == 'typedy')//进销存浏览店员浏览
{
$this->_typedy();
}
else if($arg == 'xhctypedy')//现货仓进销存浏览店员浏览
{
$this->_xhctypedy();
}
else if($arg == 'usatype')//美仓进销存浏览
{
$this->_usatype();
}
else if($arg == 'usatypeapp')//美仓APP进销存浏览
{
$this->_usatypeapp();
}
else if($arg == 'enteradd')//入库操作
{
$this->_enteradd();
}
else if($arg == 'enteredit')//修改
{
$this->_enteredit($arg_array);
}
else if($arg == 'enter')//入库浏览
{
$this->_enter();
}
else if($arg == 'xhcenter')//入库浏览
{
$this->_xhcenter();
}
else if($arg == 'out')//出库浏览
{
$this->_out();
}
else if($arg == 'label')//出库标签浏览
{
$this->_label();
}
else if($arg == 'outorder')//独立站出库订单
{
$this->_outorder();
}
else if($arg == 'soutorder')//速卖通出库订单
{
$this->_soutorder();
}
else if($arg == 'retreat')//退库订单
{
$this->_retreat();
}
else if($arg == 'retreatlk')//退库订单
{
$this->_retreatlk();
}
else if($arg == 'change')//更换标签
{
$this->_change();
}
else if($arg == 'del')//删除
{
$this->_del($arg_array);
}
else if($arg == 'exceljxc')//进销存信息导出
{
$this->_exceljxc();
}
else if($arg == 'excelr')//入库信息导出
{
$this->_excelr();
}
else if($arg == 'excelct')//出库、退库信息导出
{
$this->_excelct();
}
else if($arg == 'kcyz')//库存验证
{
$this->_kcyz();
}
else if($arg == 'kj')//库存扣减
{
$this->_kj($arg_array);
}
else if($arg == 'presetout')//预设库存导入
{
$this->_presetout($arg_array);
}
else if($arg == 'presetedit')//预设库存导入
{
$this->_presetedit($arg_array);
}
else if($arg == 'summary')//汇总导出
{
$this->_summary($arg_array);
}
else if($arg == 'manifest')//usps发货清单
{
$this->_manifest();
}
else if($arg == 'abnormal')//占单异常
{
$this->_abnormal();
}
else if($arg == 'error')
{
$this->_error();
}
else if($arg == 'ppkc')
{
$this->_ppkc();
}
else if($arg == 'list')
{
$this->_list($arg_array);
}
else if($arg == 'hwwz')
{
$this->_hwwz();
}
else if($arg == 'order')
{
$this->_order();
}
else if($arg == 'placeorder')
{
$this->_placeorder();
}
else
{
$this->_index();
}
}
public function _del($id_arr)
{
if($id_arr)
{
$id_arr = explode(',',$id_arr);
//循环删除记录
foreach ($id_arr as $value)
{
$data = $this->specialstock->read($value);
$z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and number = "'.$data['number'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
foreach ($z as $v)
{
$this->specialstock->remove($v['id']);
}
}
return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
}
else
{
echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
}
}
public function _list($arg_array)
{
$ppid = array();
$number = (isset($arg_array[1]))?$arg_array[1]:'no';
if(!isset($arg_array[2]))
{
echo "特殊产品信息错误!清除浏览器缓存后再试";exit;
}
$hz = '';
$bdck = $this->warehouse->get_bdck('specialstock');
if($bdck)
{
if($bdck['hz'] != '' && stripos($arg_array[2],$bdck['hz']) !== false)
{
$hz = $bdck['hz'];
}
}
if(stripos($arg_array[2],'-') !== false)
{
$dcp = explode('-',$arg_array[2]);
foreach ($dcp as $v)
{
if($hz != '')
{
$ppid[] = trim($v,$hz);
}
else
{
$ppid[] = 0;
}
}
if($hz != '')
{
$xzid = trim($dcp[0],$hz);
}
else
{
$xzid = 0;
}
}
else
{
if($arg_array[2] != 0 && $hz != '')
{
$xzid = trim($arg_array[2],$hz);//已选择产品用
$ppid[] = $xzid;
}
else
{
$xzid = $arg_array[0];//未选择产品用
$ppid[] = 0;
}
}
$thisdata = $this->specialstock->read($xzid);
$data = array();$dataw = array();
//本单已占用的,无论是否已出库
if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
{
$tjd = explode('-',$thisdata['featurespp']);
$dataally = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '".$number."'");
}
else
{
$dataally = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '".$number."'");
}
foreach ($dataally as $v)
{
$sm = '';
$zd = ($number == $v['zd'])?1:0;
$cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
$cpbz = ($v['cpbz']!='')?'
货物说明:'.$v['cpbz'].'
':'';
$features = '-';$c = '';
$td = explode('-',trim($v['features'],'-'));
foreach ($td as $va)
{
$s = $this->typeclass->read($va);
if($s['classid'] == '14')
{
$c = $va;
}
else
{
$features .= $va.'-';
}
}
foreach ($ppid as $va)
{
if($va == $v['id'])
{
$sm = '当前选择的产品
';
}
else if(stripos($sm,'当前选择的产品') === false)
{
$sm = '本单已占用
';
}
}
$tp = $this->typeclass->read($c);
$data[] = array('id'=>$v['id'],'z'=>$zd,'title'=>$v['title'].$sm,'features'=>$c.','.$features,'cc'=>$tp['spare'],'num'=>1,'details'=>'位置:'.$v['details'].$cpid.$cpbz,'sm'=>$sm);
}
//未占用的库存
if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
{
$tjd = explode('-',$thisdata['featurespp']);
$dataallw = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '' and state = '0'");
}
else
{
$dataallw = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '' and state = '0'");
}
foreach ($dataallw as $v)
{
$zd = ($number == $v['zd'])?1:0;
$cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
$cpbz = ($v['cpbz']!='')?'货物说明:'.$v['cpbz'].'
':'';
$features = '-';$c = '';
$td = explode('-',trim($v['features'],'-'));
foreach ($td as $va)
{
$sm = '';
$s = $this->typeclass->read($va);
if($s['classid'] == '14')
{
$c = $va;
}
else
{
$features .= $va.'-';
}
foreach ($ppid as $va)
{
if($va == $v['id'])
{
$sm = '当前选择的产品,需提交后占单
';
}
}
}
$tp = $this->typeclass->read($c);
$dataw[] = array('id'=>$v['id'],'z'=>$zd,'title'=>$v['title'].$sm,'ct'=>$v['title'],'features'=>$c.','.$features,'cc'=>$tp['spare'],'num'=>1,'details'=>'位置:'.$v['details'].$cpid.$cpbz);
}
$this->data['data'] = $data;
$this->data['dataw'] = $dataw;
$this->data['id'] = $arg_array[0];
$this->data['ppid'] = $ppid;
$this->_Template('specialstock_list',$this->data);
}
//检查是否匹配特殊库存
public function _ppkc()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['data']))
{
$data = $this->input->post('data',true);
$number = $this->input->post('number',true);
$whlabel = $this->input->post('whlabel',true);
$data = explode('|',rtrim($data,'|'));
$whlabel = explode('|',trim($whlabel,'|'));
$i = 0;$list = array();$a=array();
//更具要求特殊仓库存不在有限匹配
// foreach ($data as $v)
// {
// $v = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
// $vfl = explode('-',trim($v,'-'));
// $num = explode('-',trim($whlabel[$i],'-'));
// if(isset($vfl[4]))
// {
// if($vfl[4] == 149)//如果是360头套 那么也可以匹配370头套
// {
// $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
// if(!$pp)
// {
// $pp = $this->specialstock->find_all("(featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' or featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3]."-329') and zd = '' and state = '0'");
// }
// }
// else
// {
// $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
// }
// $yzd='';
// if(isset($num[2]))
// {
// preg_match_all('/\d+/',$num[2],$n);
// $n = join('',$n[0]);
// $yzd = $this->specialstock->find_all("id = '$n' and zd = '$number'");
// }
// if(count($pp) >= $num[1] && !$yzd)
// {
// $w = '特殊';//有现货仓的设置后面特殊更改为现货
// $list[] = array($i,$pp[0]['id'],$w);
// }
// else if($yzd)
// {
// foreach ($yzd as $val)
// {
// if($num[2] == $val['id'].'z')
// {
// $w = '特殊';//有现货仓的设置后面特殊更改为现货
// $list[] = array($i,$yzd[0]['id'],$w);
// }
// }
// }
// }
// $i++;
// }
if($list)
{
echo json_encode(array('list'=>$list,'success'=>true));exit;
}
}
}
//管理
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);
$sku = $this->input->post('sku',true);
$number = $this->input->post('number',true);
$warehouse = $this->input->post('warehouse',true);
$purchase = $this->input->post('purchase',true);
$orderinfo = $this->input->post('orderinfo',true);
$waybill = $this->input->post('waybill',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);
$label = $this->input->post('label',true);
$timetk = $this->input->post('timetkk',true);
$timetj = $this->input->post('timetjj',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
$where = "1=1 ";
if($timetk && $timetj)
{
$where .= " and time > '$timetk' and time < '$timetj'";
}
if($sku)
{
$where .= " and sku = '$sku'";
}
if($number)
{
$where .= " and number = '$number'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($orderinfo)
{
$where .= " and orderinfo = '$orderinfo'";
}
if($waybill)
{
$where .= " and waybill = '$waybill'";
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($label)
{
$where .= " and label = '$label'";
}
if($state || $state == 0)
{
$where .= " and state = '$state'";
}
//数据排序
$order_str = "time desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$info_list[$key]['warehouse'] = $warehouse['title'];
$purchase = $this->purchase->read($value['purchase']);
$info_list[$key]['purchase'] = $purchase['title'];
if($value['enter'] != 0)
{
$info_list[$key]['enter'] = ''.date('Y-m-d',$value['enter']).'
'.date('H:i:s',$value['enter']).'
';
}
else
{
$info_list[$key]['enter'] = "";
}
if($value['outk'] != 0)
{
$info_list[$key]['outk'] = ''.date('Y-m-d',$value['outk']).'
'.date('H:i:s',$value['outk']).'
';
}
else
{
$info_list[$key]['outk'] = "";
}
if($value['printing'] != 0)
{
$info_list[$key]['printing'] = ''.date('Y-m-d',$value['printing']).'
'.date('H:i:s',$value['printing']).'
';
}
else
{
$info_list[$key]['printing'] = "";
}
if($value['orderinfo'] == 0)
{
$info_list[$key]['orderinfo'] = "";
}
if($value['waybill'] == 0)
{
$info_list[$key]['waybill'] = "";
}
if($value['state'] == 0)
{
$info_list[$key]['state'] = "在库";
}
else if($value['state'] == 1)
{
$info_list[$key]['state'] = "出库";
}
else if($value['state'] == 2)
{
$info_list[$key]['state'] = "退库";
}
else if($value['state'] == 3)
{
$info_list[$key]['state'] = "调拨中";
}
else if($value['state'] == 4)
{
$info_list[$key]['state'] = "再加工";
}
else if($value['state'] == 5)
{
$info_list[$key]['state'] = "维修中";
}
else if($value['state'] == 6)
{
$info_list[$key]['state'] = "盘亏";
}
else if($value['state'] == 7)
{
$info_list[$key]['state'] = "更换标签";
}
else if($value['state'] == 8)
{
$info_list[$key]['state'] = "其它";
}
else if($value['state'] == 9)
{
$info_list[$key]['state'] = "预设";
}
if($value['text'] == "")
{
$info_list[$key]['text'] = "";
}
$info_list[$key]['time'] = ''.date('Y-m-d',$value['time']).'
'.date('H:i:s',$value['time']).'
';
}
$total = $this->specialstock->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($post['outsku']))
{
$cz = $this->input->post('cz',true);
if($cz == '1')
{
$sku = $this->input->post('outsku',true);
if($sku)
{
$data = $this->specialstock->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
if(count($data) < 1)
{
echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
}
$this->specialstock->save(array('state'=>10,'outk'=>time(),'time'=>time()),$data[0]['id']);
echo json_encode(array('success'=>true));exit;
}
}
else
{
$sku = $this->input->post('outsku',true);
if($sku)
{
$data = $this->specialstock->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
if(count($data) < 1)
{
echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
}
$this->specialstock->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
echo json_encode(array('success'=>true));exit;
}
}
}
$this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
$this->_Template('specialstock',$this->data);
}
//在库标签
public function _existence()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['s']))
{
$id_arr = $this->input->post('s');
$id_arr = explode(',',$id_arr);
if(!$id_arr)
{
echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
}
//循环删除记录
foreach ($id_arr as $v)
{
$this->specialstock->remove($v);
}
echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
}
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$warehouse = $this->input->post('warehouse',true);
$label = $this->input->post('label',true);
$where = "1=1 and state = 0";
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($label)
{
$where .= " and label = '$label'";
}
//数据排序
$order_str = "time asc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
if($value['enter'] != 0)
{
$info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
}
else
{
$info_list[$key]['enter'] = "";
}
if($value['printing'] != 0)
{
$info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
}
else
{
$info_list[$key]['printing'] = "";
}
}
$total = $this->specialstock->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;
}
$this->_Template('specialstock_existence',$this->data);
}
public function _typedy()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$sku = $this->input->post('sku');
$title = $this->input->post('title');
$warehouse = $this->input->post('warehouse',true);
$usa = $this->input->post('usa',true);
$purchase = $this->input->post('purchase',true);
$lacetype = $this->input->post('lacetype',true);
$haircap = $this->input->post('haircap',true);
$density = $this->input->post('density',true);
$details = $this->input->post('details',true);
$state = $this->input->post('state',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "1=1";$gj = "";$ck = "";
if($lacetype)
{
$where .= " and features like '%-$lacetype-%'";
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($haircap)
{
$where .= " and features like '%-$haircap-%'";
}
if($density)
{
$where .= " and features like '%-$density-%'";
}
if($usa)
{
if(!$warehouse)
{
$where .= " and (warehouse = '5' or warehouse = '8')";
}
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($details)
{
$where .= " and details = '$details'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($ktime && $jtime)
{
$gj = " and enter > '$ktime' and enter < '$jtime'";
$ck = " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
if($sku)
{
$sku = trim($sku,' ');
$sku = trim($sku,' ');
$where .= " and sku like '%$sku%'";
$info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
}
else if($title)
{
$title = trim($title,' ');
$title = trim($title,' ');
$where .= " and title like '%$title%'";
$info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
}
else
{
//$where .= " and time > '$ktime' and time < '$jtime'";
$info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
}
//取得信息列表
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$wid = $this->specialstock->read($value['id']);
$c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
$z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
$number = $value['number'];$ftime = time()-15*24*3600;
$z = count($z);//查看订单号
$info_list[$key]['features'] = count($c);
$info_list[$key]['number'] = $z;
$details = array();
$cpid = array();
foreach ($c as $k=>$v)
{
$details[$v['details']] = $v['details'];
if($v['cpid'] != 0)
{
$cpid[$v['cpid']] = $v['cpid'];
}
}
$info_list[$key]['details'] = ($cpid)?implode(" ",$details).''.implode(" ",$cpid).'
':implode(" ",$details);
}
$total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
echo json_encode($rows);exit;
}
$this->_Template('specialstock_typedy',$this->data);
}
//进销存浏览
public function _type($arg_array)
{
$vip = 0;
if(isset($_SESSION['api']))
{
$user = $this->user->get_api($_SESSION['api']);
if($user['vip'] == 1)
{
$vip = 1;
}
}
else
{
header('Location: /');exit;
}
if(isset($arg_array[0]))
{
if($arg_array[0] == 'del')
{
$s = $this->input->post('s',true);
$del = $this->_0kcdel($s);
echo $del;exit;
}
}
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$sku = $this->input->post('sku');
$title = $this->input->post('title');
$warehouse = $this->input->post('warehouse',true);
$usa = $this->input->post('usa',true);
$purchase = $this->input->post('purchase',true);
$lacetype = $this->input->post('lacetype',true);
$haircap = $this->input->post('haircap',true);
$density = $this->input->post('density',true);
$details = $this->input->post('details',true);
$state = $this->input->post('state',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$hairnumber = $this->input->post('hairnumber',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "1=1";$gj = "";$ck = "";
if($lacetype)
{
$where .= " and features like '%-$lacetype-%'";
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($haircap)
{
$where .= " and features like '%-$haircap-%'";
}
if (!empty($hairnumber)) {
$where .= " and features like '%-128-%' ";
if ($hairnumber < 0) {
$class_list = $this->typeclass->find_all('classid = 43');
foreach ($class_list as $v) {
$where .= " and features not like '%-" . $v['id'] . "-%'";
}
} else {
$where .= " and features like '%-$hairnumber-%'";
}
}
if($density)
{
$where .= " and features like '%-$density-%'";
}
if($usa)
{
if(!$warehouse)
{
$where .= " and (warehouse = '5' or warehouse = '8')";
}
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($details)
{
$where .= " and details = '$details'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($state)
{
if($state >-1){
$where .= " and state = '$state'";
}
}
if($ktime && $jtime)
{
$gj = " and enter > '$ktime' and enter < '$jtime'";
$ck = " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
if($sku)
{
$sku = trim($sku,' ');
$sku = trim($sku,' ');
$where .= " and sku like '%$sku%'";
$info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
}
else if($title)
{
$title = trim($title,' ');
$title = trim($title,' ');
$where .= " and title like '%$title%'";
$info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
}
else
{
//$where .= " and time > '$ktime' and time < '$jtime'";
$info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
}
//取得信息列表
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$wid = $this->specialstock->read($value['id']);
$c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
$g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
$x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
$t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$wid['warehouse'].'"');
$z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
$od = array();$odid = '';
foreach ($z as $v)
{
if(!isset($od[$v['zd']]))
{
$od[$v['zd']] = 1;//所有数据sku
}
else
{
$od[$v['zd']] = $od[$v['zd']]+1;
}
}
foreach ($od as $k=>$vv)
{
$odid .= $k.'数量'.$vv;
}
$ftime = time()-15*24*3600;
$z = count($z).'('.$odid.')';//查看订单号
$info_list[$key]['features'] = count($c);
$info_list[$key]['g'] = $g;
$info_list[$key]['x'] = $x;
$info_list[$key]['t'] = $t;
$info_list[$key]['z'] = $z;
$details = array();
$cpid = array();
foreach ($c as $k=>$v)
{
$details[$v['details']] = $v['details'];
if($v['cpid'] != 0)
{
$cpid[$v['cpid']] = $v['cpid'];
}
}
$info_list[$key]['details'] = ($cpid)?implode(" ",$details).''.implode(" ",$cpid).'
':implode(" ",$details);
}
$total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features'));
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
echo json_encode($rows);exit;
}
$this->data['vip'] = $vip;
$this->_Template('specialstock_type',$this->data);
}
public function _xhctypedy()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$sku = $this->input->post('sku',true);
$details = $this->input->post('details',true);
$warehouse = $this->input->post('warehouse',true);
$purchase = $this->input->post('purchase',true);
$lacetype = $this->input->post('lacetype',true);
$state = $this->input->post('state',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "warehouse != '12'";$gj = "";$ck = "";
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($lacetype)
{
$where .= " and features like '%-$lacetype-%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($sku)
{
$where .= " and sku like '%$sku%'";
}
if($details)
{
$where .= " and details like '%$details%'";
}
if($ktime && $jtime)
{
$gj = " and enter > '$ktime' and enter < '$jtime'";
$ck = " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
}
foreach ($rows as $k=>$value)
{
$c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
if($c < 1)
{
unset($rows[$k]);
}
}
$rowsdq = array_slice($rows,$start,$perpage);
foreach ($rowsdq as $value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
$z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
$number = $value['number'];$ftime = time()-15*24*3600;
$z = count($z);//查看订单号
//$z = $od;
$list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'wz'=>$value['details'],'bz'=>$value['cpbz'],'c'=>$c,'z'=>$z);
}
$total = count($rows);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
echo json_encode($rows);exit;
}
$this->_Template('specialstock_xhctypedy',$this->data);
}
//进销存浏览
public function _xhctype($arg_array)
{
$post = $this->input->post(NULL, TRUE);
if(isset($arg_array[0]))
{
if($arg_array[0] == 'del')
{
$s = $this->input->post('s',true);
$del = $this->_del($s);
echo $del;exit;
}
}
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$sku = $this->input->post('sku',true);
$details = $this->input->post('details',true);
$warehouse = $this->input->post('warehouse',true);
$purchase = $this->input->post('purchase',true);
$lacetype = $this->input->post('lacetype',true);
$state = $this->input->post('state',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "warehouse != '12'";$gj = "";$ck = "";
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($lacetype)
{
$where .= " and features like '%-$lacetype-%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($sku)
{
$where .= " and sku like '%$sku%'";
}
if($details)
{
$where .= " and details like '%$details%'";
}
if($ktime && $jtime)
{
$gj = " and enter > '$ktime' and enter < '$jtime'";
$ck = " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
}
$rowsdq = array_slice($rows,$start,$perpage);
foreach ($rowsdq as $k=>$value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
$g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
$x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
$t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
$z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
$od = array();$odid = '';
foreach ($z as $v)
{
if(!isset($od[$v['zd']]))
{
$od[$v['zd']] = 1;//所有数据sku
}
else
{
$od[$v['zd']] = $od[$v['zd']]+1;
}
}
foreach ($od as $k=>$vv)
{
$odid .= $k.'数量'.$vv;
}
$number = $value['number'];$ftime = time()-15*24*3600;
/**
if($value['shop'] != '')
{
$shop = $value['shop'];
$orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$order = array_merge($orderdlz,$ordersmt);
$od = 0;$a = '';$orid = '';
foreach ($order as $v)
{
$or = explode('|',ltrim($v['specialstock'],'|'));
for($i=0;$ifullorder->find_all("time > '$ftime' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$order = array_merge($orderdlz,$ordersmt);
$od = 0;$a = '';$orid = '';$qt = array();
foreach ($order as $v)
{
$or = explode('|',ltrim($v['specialstock'],'|'));
for($i=0;$ispecialstock->find_count("number = '$number' and warehouse = '".$value['warehouse']."' and shop = '".$v['shop']."' and state = 0");
if($czzs > 0)
{
if(isset($qt[$v['shop']]))
{
if($qt[$v['shop']] < $orod[1])
{
$od += $orod[1];//专属小于单量不计算剩余直接归入通用
$orid .= $v['number'].'+数量'.$orod[1].'-';
}
else
{
$qt[$v['shop']] -= $orod[1];
}
}
else
{
$qt[$v['shop']] = $czzs;
}
}
else
{
$od += $orod[1];
$orid .= $v['number'].'+数量'.$orod[1].'-';
}
}
}
}
}
**/
$z = count($z).'('.$odid.')';//查看订单号
//$z = $od;
$wz = ($value['cpid'] > 0)?$value['details'].'-'.$value['cpid']:$value['details'];
$list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'wz'=>$wz,'bz'=>$value['cpbz'],'c'=>$c,'g'=>$g,'x'=>$x,'t'=>$t,'z'=>$z);
}
$total = count($rows);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
echo json_encode($rows);exit;
}
$this->_Template('specialstock_xhctype',$this->data);
}
//美仓进销存浏览
public function _usatype()
{
$this->_Template('specialstock_typeusa',$this->data);
}
//美仓进销存浏览
public function _usatypeapp()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$sku = $this->input->post('sku',true);
$warehouse = '5';
$title = $this->input->post('title',true);
$state = $this->input->post('state',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "1=1";$gj = "";$ck = "";
if($title)
{
$st = explode(' ',trim($title,' '));
foreach ($st as $v)
{
$where .= " and title like '%$v%'";
}
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($sku)
{
$where .= " and sku like '%$sku%'";
}
if($ktime && $jtime)
{
$gj = " and enter > '$ktime' and enter < '$jtime'";
$ck = " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['sku'].'warehouse'.$value['warehouse']] = $value;//所有数据sku
}
$rowsdq = array_slice($rows,$start,$perpage);
foreach ($rowsdq as $value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
$x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
$t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
$od = array();$odid = '';
$list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
}
$total = count($rows);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
echo json_encode($rows);exit;
}
$this->_Template('phone/p_usatypeapp',$this->data);
}
//入库操作
public function _enteradd()
{
$dt = 0;
if(isset($_SESSION['api']))
{
$user = $this->user->get_api($_SESSION['api']);
$usp = $user;
$fgshop = "";$sid = "";
$user = explode('|',trim($user['shop'],'|'));
foreach ($user as $value)
{
$fgshop .= " shop = ".$value." or";
$sid .= " id = ".$value." or";
}
}
$post = $this->input->post(NULL, TRUE);
if(isset($post['details']))
{
$list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
$order = $this->input->post('order',true);
$post['details'] = $this->input->post('details',true);
$post['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);
$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);
$post['warehouse'] = $this->input->post('warehouse',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['wigother1'] = $this->input->post('wigother1',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);
}
else if($category == 1702)
{
$list['syhairther'] = $this->input->post('syhairther',true);
}
foreach($list as $k=>$v)
{
if($v != 0)
{
$num .=$v;
$features .=$v.'-';
$post[$k] = $v;
$typeclass = $this->typeclass->read($v);
if($k != 'size')
{
$title .= $typeclass['title']." ";
}
}
}
$typeclass = $this->typeclass->read($list['size']);
$title .= $typeclass['title'];
$time = time();
$post['title'] = rtrim($title,' ');
$post['number'] = $num;
$post['features'] = '-'.$features;
$featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
$featurespp = explode('-',trim($featurespp,'-'));
$post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
$post['enter'] = $time;
$post['time'] = $time;//操作时间
for($i=0;$i<$order;$i++)
{
$post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
$this->specialstock->insert($post);
}
echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
}
$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
$this->data['wlshop'] = $wlshop;
$this->_Template('specialstock_enteradd',$this->data);
}
//修改产品
public function _enteredit($arg_array)
{
$dt = 0;
if(isset($_SESSION['api']))
{
$user = $this->user->get_api($_SESSION['api']);
$usp = $user;
$fgshop = "";$sid = "";
$user = explode('|',trim($user['shop'],'|'));
foreach ($user as $value)
{
$fgshop .= " shop = ".$value." or";
$sid .= " id = ".$value." or";
}
}
$post = $this->input->post(NULL, TRUE);
if(isset($post['details']))
{
$list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
$id = $this->input->post('id',true);
$order = $this->input->post('order',true);
$post['details'] = $this->input->post('details',true);
$post['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);
$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);
$post['warehouse'] = $this->input->post('warehouse',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['wigother1'] = $this->input->post('wigother1',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);
}
else if($category == 1702)
{
$list['syhairther'] = $this->input->post('syhairther',true);
}
foreach($list as $k=>$v)
{
if($v != 0)
{
$num .=$v;
$features .=$v.'-';
$typeclass = $this->typeclass->read($v);
if($k != 'size')
{
$title .= $typeclass['title']." ";
}
}
}
$typeclass = $this->typeclass->read($list['size']);
$title .= $typeclass['title'];
$time = time();
$post['title'] = rtrim($title,' ');
$post['number'] = $num;
$post['features'] = '-'.$features;
$featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
$featurespp = explode('-',trim($featurespp,'-'));
$post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
$post['time'] = $time;//操作时间
$uid = $this->specialstock->read($id);
$datanum = $this->specialstock->find_count("state = 0 and number = '".$uid['number']."' and zd != ''");
if($datanum > 0)
{
echo json_encode(array('msg'=>'此库存有占单,请解除占单后再修改!','success'=>false));exit;
}
$data = $this->specialstock->find_all("number = '".$uid['number']."' and enter = '".$uid['enter']."'");// and enter = '".$uid['enter']."'
foreach ($data as $v)
{
$post['id'] = $v['id'];
$this->specialstock->save($post,$v['id']);
}
echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
}
$uid = $this->specialstock->read($arg_array[0]);
$uid['order'] = $this->specialstock->find_count('enter = '.$uid['enter']);
$this->data['enter'] = $uid ;
$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
$this->data['wlshop'] = $wlshop;
$whlabelwz = $this->whlabelwz->find_all();
$this->data['whlabelwz'] = $whlabelwz;
$this->_Template('specialstock_enteredit',$this->data);
}
//入库浏览
public function _enter()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['s']))
{
$id_arr = $this->input->post('s');
$id_arr = explode(',',$id_arr);
if(!$id_arr)
{
echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
}
//循环删除记录
foreach ($id_arr as $v)
{
$sid = $this->specialstock->read($v);
$info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
foreach ($info_list as $va)
{
$this->specialstock->remove($va['id']);
}
}
echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
}
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$details = $this->input->post('details',true);
$sku = $this->input->post('sku',true);
$warehouse = '';//12
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "1=1";$gj = "";$ck = "";
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($details)
{
$where .= " and details like '%$details%'";
}
if($sku)
{
$where .= " and sku like '%$sku%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($ktime && $jtime)
{
$where .= " and enter > '$ktime' and enter < '$jtime'";
}
//数据排序
$order_str = "enter desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*',$order_str);
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['enter'].$value['number']] = $value;//所有数据sku
}
foreach ($rows as $value)
{
$g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
$list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'details'=>$value['details'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
}
$total = count($list);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list),'abc'=>($where));
echo json_encode($rows);exit;
}
$this->_Template('specialstock_enter',$this->data);
}
//入库浏览
public function _xhcenter()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['s']))
{
$id_arr = $this->input->post('s');
$id_arr = explode(',',$id_arr);
if(!$id_arr)
{
echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
}
//循环删除记录
foreach ($id_arr as $v)
{
$sid = $this->specialstock->read($v);
$info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
foreach ($info_list as $va)
{
$this->specialstock->remove($va['id']);
}
}
echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
}
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$details = $this->input->post('details',true);
$sku = $this->input->post('sku',true);
$warehouse = $this->input->post('warehouse',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "warehouse != '12'";$gj = "";$ck = "";
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($details)
{
$where .= " and details like '%$details%'";
}
if($sku)
{
$where .= " and sku like '%$sku%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($ktime && $jtime)
{
$where .= " and enter > '$ktime' and enter < '$jtime'";
}
//数据排序
$order_str = "enter desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*',$order_str);
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['enter'].$value['number']] = $value;//所有数据sku
}
foreach ($rows as $value)
{
$g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
$list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'details'=>$value['details'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
}
$total = count($list);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
echo json_encode($rows);exit;
}
$this->_Template('specialstock_xhcenter',$this->data);
}
//出库浏览
public function _out()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$sku = $this->input->post('sku',true);
$warehouse = $this->input->post('warehouse',true);
$purchase = $this->input->post('purchase',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "state=3";$gj = "";$ck = "";
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($sku)
{
$where .= " and sku = '$sku'";
}
if($ktime && $jtime)
{
$where .= " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'sku');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
}
$rows = array_unique($rows);//删除重复记录
foreach ($rows as $key=>$value)
{
$data = $this->specialstock->get_sku($value);//获取目前sku的所有数据
$ck = $this->warehouse->read($data['warehouse']);
$warehouse = $ck['title'];
$gy = $this->purchase->read($data['purchase']);
$purchase = $gy['purchase'];
$g = $this->specialstock->find_count($where.' and sku = "'.$value.'" and state = 3');
$list[] = array('id'=>$data['id'],'warehouse'=>$warehouse,'purchase'=>$purchase,'sku'=>$data['sku'],'title'=>$data['title'],'time'=>date('Y-m-d H:i:s',$data['enter']),'number'=>$g);
}
$total = count($list);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
echo json_encode($rows);exit;
}
$this->_Template('specialstock_out',$this->data);
}
//出库标签浏览
public function _label()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$sku = $this->input->post('sku',true);
$warehouse = $this->input->post('warehouse',true);
$purchase = $this->input->post('purchase',true);
$orderinfo = $this->input->post('orderinfo',true);
$waybill = $this->input->post('waybill',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);
$where = "state=1";
if($sku)
{
$where .= " and sku = '$sku'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($orderinfo)
{
$where .= " and orderinfo = '$orderinfo'";
}
if($waybill)
{
$where .= " and waybill = '$waybill'";
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
//数据排序
$order_str = "outk desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$info_list[$key]['warehouse'] = $warehouse['title'];
$purchase = $this->purchase->read($value['purchase']);
$info_list[$key]['purchase'] = $purchase['title'];
if($value['outk'] != 0)
{
$info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
}
else
{
$info_list[$key]['outk'] = "";
}
if($value['orderinfo'] == 0)
{
$info_list[$key]['orderinfo'] = "";
}
if($value['waybill'] == 0)
{
$info_list[$key]['waybill'] = "";
}
}
$total = $this->specialstock->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;
}
$this->_Template('specialstock_label',$this->data);
}
//独立站出库订单
public function _outorder()
{
if(isset($_SESSION['api']))
{
$user = $this->user->get_api($_SESSION['api']);
$usp = $user;
$fgshop = "";$sid = "";
$user = explode('|',trim($user['shop'],'|'));
foreach ($user as $value)
{
$sid .= " id = ".$value." or";
}
}
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$warehouse = $this->input->post('warehouse',true);
$xztime = $this->input->post('xztime',true);
$timetk = $this->input->post('timetkk',true);
$timetj = $this->input->post('timetjj',true);
$shop = $this->input->post('shop',true);
$source = $this->input->post('source',true);
$orderinfo = $this->input->post('orderinfo',true);
$number = $this->input->post('number',true);
$express = $this->input->post('express',true);
$waybill = $this->input->post('waybill',true);
$library = $this->input->post('library',true);
$country = $this->input->post('country',true);
$so = $this->input->post('so',true);
$libraryconfirm = $this->input->post('libraryconfirm',true);
$print = $this->input->post('print',true);
$state = $this->input->post('state',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
/**
$sj = $this->input->post('sj',true);
if($sj)
{
$sj = $this->input->post('sj',true);
}
else
{
$sj = "fullorder";
}
**/
$sj = "fullorder";
$where = "mergeid = 0";
if($warehouse)
{
$where .= " and type = '$warehouse'";
}
if($timetk && $timetj)
{
$where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
}
if($orderinfo)
{
$where .= " and orderinfo = '$orderinfo'";
}
if($number)
{
$where .= " and number = '$number'";
}
if($express)
{
$where .= " and express = '$express'";
}
if($waybill)
{
$where .= " and waybill = '$waybill'";
}
if($library)
{
$where .= " and library = '$library'";
}
if($print)
{
$where .= " and print = '$print'";
}
if($libraryconfirm)
{
$where .= " and libraryconfirm = '$libraryconfirm'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($shop)
{
$where .= " and shop = '$shop'";
}
if($country)
{
$where .= " and country = '$country'";
}
if($so)
{
$where .= " and shipremarks like '%$so%'";
}
if($source)
{
$where .= " and source = '$source'";
}
else
{
if(isset($_SESSION['api']))
{
foreach ($user as $value)
{
$fgshop .= " shop = ".$value." or";
}
$where .= " and (".rtrim($fgshop,'or').")";
}
}
//数据排序
$order_str = "librarytime desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
//格式化数据
foreach ($info_list as $key=>$value)
{
$shop = $this->shop->read($value['shop']);
$info_list[$key]['shop'] = $shop['shopname'];
$express = $this->express->read($value['express']);
$info_list[$key]['express'] = $express['servicename'];
$warehouse = $this->warehouse->read($value['type']);
$info_list[$key]['type'] = $warehouse['title'];
if($value['librarytime'] == '0')
{
$info_list[$key]['librarytime'] = '';
}
else
{
$info_list[$key]['librarytime'] = ''.date('Y-m-d H:i:s',$value['librarytime']).'';
}
}
$total = $this->$sj->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;
}
$this->data['express'] = $this->express->find_all();
$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
$this->data['wlshop'] = $wlshop;
$this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=2','*','idorder desc');//导出模板
$this->_Template('specialstock_outorder',$this->data);
}
//速卖通出库订单
public function _soutorder()
{
if(isset($_SESSION['api']))
{
$user = $this->user->get_api($_SESSION['api']);
$usp = $user;
$fgshop = "";$sid = "";
$user = explode('|',trim($user['shop'],'|'));
foreach ($user as $value)
{
$sid .= " id = ".$value." or";
}
}
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$warehouse = $this->input->post('warehouse',true);
$xztime = $this->input->post('xztime',true);
$timetk = $this->input->post('timetkk',true);
$timetj = $this->input->post('timetjj',true);
$shop = $this->input->post('shop',true);
$source = $this->input->post('source',true);
$orderinfo = $this->input->post('orderinfo',true);
$number = $this->input->post('number',true);
$express = $this->input->post('express',true);
$waybill = $this->input->post('waybill',true);
$library = $this->input->post('library',true);
$country = $this->input->post('country',true);
$libraryconfirm = $this->input->post('libraryconfirm',true);
$print = $this->input->post('print',true);
$state = $this->input->post('state',true);
$so = $this->input->post('so',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
/**
$sj = $this->input->post('sj',true);
if($sj)
{
$sj = $this->input->post('sj',true);
}
else
{
$sj = "fullorder";
}
**/
$sj = "fullordersmt";
$where = "mergeid = 0";
if($warehouse)
{
$where .= " and type = '$warehouse'";
}
if($timetk && $timetj)
{
$where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
}
if($orderinfo)
{
$where .= " and orderinfo = '$orderinfo'";
}
if($number)
{
$where .= " and number = '$number'";
}
if($express)
{
$where .= " and express = '$express'";
}
if($waybill)
{
$where .= " and waybill = '$waybill'";
}
if($library)
{
$where .= " and library = '$library'";
}
if($print)
{
$where .= " and print = '$print'";
}
if($libraryconfirm)
{
$where .= " and libraryconfirm = '$libraryconfirm'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($shop)
{
$where .= " and shop = '$shop'";
}
if($so)
{
$where .= " and shipremarks like '%$so%'";
}
if($source)
{
$where .= " and source = '$source'";
}
if($country)
{
$where .= " and country = '$country'";
}
else
{
if(isset($_SESSION['api']))
{
foreach ($user as $value)
{
$fgshop .= " shop = ".$value." or";
}
$where .= " and (".rtrim($fgshop,'or').")";
}
}
//数据排序
$order_str = "librarytime desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
//格式化数据
foreach ($info_list as $key=>$value)
{
$shop = $this->shop->read($value['shop']);
$info_list[$key]['shop'] = $shop['shopname'];
$express = $this->express->read($value['express']);
$info_list[$key]['express'] = $express['servicename'];
$warehouse = $this->warehouse->read($value['type']);
$info_list[$key]['type'] = $warehouse['title'];
if($value['librarytime'] == '0')
{
$info_list[$key]['librarytime'] = '';
}
else
{
$info_list[$key]['librarytime'] = ''.date('Y-m-d H:i:s',$value['librarytime']).'';
}
}
$total = $this->$sj->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;
}
$this->data['express'] = $this->express->find_all();
$wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
$this->data['wlshop'] = $wlshop;
$this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=5','*','idorder desc');//导出模板
$this->_Template('specialstock_soutorder',$this->data);
}
//订单退库
public function _retreat()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$warehouse = $this->input->post('warehouse',true);
$timetk = $this->input->post('timetk',true);
$timetj = $this->input->post('timetj',true);
$shop = $this->input->post('shop',true);
$source = $this->input->post('source',true);
$state = $this->input->post('state',true);
$review = $this->input->post('review',true);
$state = $this->input->post('state',true);
$express = $this->input->post('express',true);
$orderinfo = $this->input->post('orderinfo',true);
$user = $this->input->post('user',true);
$name = $this->input->post('name',true);
$waybill = $this->input->post('waybill',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
$where = "(state=206 or state=210) and mergeid = 0";
if($warehouse)
{
$where .= " and state = '$warehouse'";
}
if($timetk && $timetj)
{
$where .= " and buytime > '$timetk' and buytime < '$timetj'";
}
if($shop)
{
$where .= " and shop = '$shop'";
}
if($source)
{
$where .= " and source = '$source'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($review)
{
$where .= " and review = '$review'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($express)
{
$where .= " and express = '$express'";
}
if($orderinfo)
{
$where .= " and orderinfo = '$orderinfo'";
}
if($user)
{
$where .= " and user = '$user'";
}
if($name)
{
$where .= " and name = '$name'";
}
if($waybill)
{
$where .= " and waybill = '$waybill'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
//格式化数据
foreach ($info_list as $key=>$value)
{
$shop = $this->shop->read($value['shop']);
$info_list[$key]['shop'] = $shop['shopname'];
$warehouse = $this->warehouse->read($value['warehouse']);
$info_list[$key]['warehouse'] = $warehouse['title'];
$info_list[$key]['orderinfo'] = "".$value['orderinfo']."";
$info_list[$key]['buytime'] = ''.date('Y-m-d',$value['buytime']).'
'.date('H:i:s',$value['buytime']).'
';
if($value['waybill'] == 0)
{
$info_list[$key]['waybill'] = "";
}
$express = $this->express->read($value['express']);
$info_list[$key]['express'] = $express['title'];
$typeclass = $this->typeclass->read($value['state']);
$info_list[$key]['state'] = $typeclass['title'];
}
$total = $this->fullorder->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;
}
$this->data['express'] = $this->express->find_all();
$this->_Template('specialstock_retreat',$this->data);
}
//退库标签浏览
public function _retreatlk()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$timetk = $this->input->post('timetk',true);
$timetj = $this->input->post('timetj',true);
$sku = $this->input->post('sku',true);
$warehouse = $this->input->post('warehouse',true);
$purchase = $this->input->post('purchase',true);
$orderinfo = $this->input->post('orderinfo',true);
$waybill = $this->input->post('waybill',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);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
$where = "state=2";
if($timetk && $timetj)
{
$where .= " and retreat > '$timetk' and retreat < '$timetj'";
}
if($sku)
{
$where .= " and sku = '$sku'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($orderinfo)
{
$where .= " and orderinfo = '$orderinfo'";
}
if($waybill)
{
$where .= " and waybill = '$waybill'";
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
//数据排序
$order_str = "time desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$info_list[$key]['warehouse'] = $warehouse['title'];
$retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
$info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
$purchase = $this->purchase->read($value['purchase']);
$info_list[$key]['purchase'] = $purchase['title'];
if($value['outk'] != 0)
{
$info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
}
else
{
$info_list[$key]['outk'] = "";
}
if($value['retreat'] != 0)
{
$info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
}
else
{
$info_list[$key]['retreat'] = "";
}
if($value['orderinfo'] == 0)
{
$info_list[$key]['orderinfo'] = "";
}
if($value['waybill'] == 0)
{
$info_list[$key]['waybill'] = "";
}
}
$total = $this->specialstock->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;
}
$this->_Template('specialstock_retreatlk',$this->data);
}
//更换标签及浏览
public function _change()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$timetk = $this->input->post('timetk',true);
$timetj = $this->input->post('timetj',true);
$label = $this->input->post('label',true);
$oldlabel = $this->input->post('oldlabel',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
$where = "state=10 ";
if($timetk && $timetj)
{
$where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
}
if($label)
{
$where .= " and label = '$label'";
}
if($oldlabel)
{
$where .= " and oldlabel = '$oldlabel'";
}
//数据排序
$order_str = "time asc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
$info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
}
$total = $this->specialstock->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;
}
$this->_Template('specialstock_change',$this->data);
}
//产品标签
public function _cpbqdc()
{
if(isset($_GET['excel']))
{
$where = "1=1";
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
$warehouse = $this->input->get('warehouse',true);
$state = $this->input->get('state',true);
$timetk = $this->input->get('timetkk',true);
$timetj = $this->input->get('timetjj',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($state || $state == 0)
{
$where .= " and state = '$state'";
}
if($timetk && $timetj)
{
$where .= " and time > '$timetk' and time < '$timetj'";
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['time']] = $value;//所有数据sku
}
foreach ($rows as $value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$s = $this->specialstock->find_count($where.' and time = "'.$value['time'].'"');
$list[] = array($warehouse['title'],$value['sku'],$value['title'],date('Y-m-d H:i:s',$value['enter']),date('Y-m-d H:i:s',$value['time']),$value['details'],$s);
}
$title = "产品标签统计表";
$titlename = "
".$title." |
仓库 |
SKU |
产品 |
入库时间 |
操作时间 |
备注 |
数量 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($list,$titlename,$filename,$tail);
}
}
//进销存导出
public function _exceljxc()
{
if(isset($_GET['excel']))
{
$where = "1=1";
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
$category = $this->input->get('category',true);
$warehouse = $this->input->get('warehouse',true);
$pc = $this->input->get('pc',true);
if($pc)
{
$pc = trim($pc,'x');
$pc = explode('x',$pc);
foreach ($pc as $v)
{
$where .= " and warehouse != '".$v."'";
}
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
//取得信息列表
$info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,features,sku,details,warehouse,number,title,cpbz');
$list = array();
// foreach ($info_list as $value)
// {
// $classid = $this->classid->sku();
// $pm = $classid;
// //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
// $features = explode('-',trim($value['features'],'-'));
// foreach ($features as $v)
// {
// $typeclass = $this->typeclass->read($v);
// $pm[$typeclass['classid']] = $typeclass['zh'];
// //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
// }
// $typeclass = $this->typeclass->read($v);
// //$scsku = implode("-",$scsku);
// $zh = implode(" ",$pm);
// $zh = str_replace('自然色 ','',rtrim($zh,' '));
// //$scsku = str_replace('- ','-',trim($scsku,'-'));
// //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
// $cpid = '';
// $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
// foreach ($c as $v)
// {
// if($v['cpid'] != 0)
// {
// $cpid .= $v['cpid'].' ';
// }
// }
// $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
// $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
// $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
// $number = $value['number'];$ftime = time()-15*24*3600;
// $warehouse = $this->warehouse->read($value['warehouse']);
// $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
// }
$classid = $this->classid->sku();
$tcall = $this->typeclass->find_all();
foreach ($tcall 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']);
}
foreach ($info_list as $value)
{
$tmp_r = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
$zh = $tmp_r['zh'];
$zh = str_replace('自然色 ','',rtrim($zh,' '));
$u9_code = $tmp_r['jm'];
$cpid = '';
$c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
foreach ($c as $v)
{
if($v['cpid'] != 0)
{
$cpid .= $v['cpid'].' ';
}
}
$g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
$x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
$t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
$number = $value['number'];$ftime = time()-15*24*3600;
$warehouse = $this->warehouse->read($value['warehouse']);
$list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
}
$title = "总进销存统计表";
$titlename = "
".$title." |
位置 |
库存编码 |
产品 |
SKU |
中文 |
u9料号 |
入库总量 |
库存数量 |
销售数量 |
退货数量 |
备注 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($list,$titlename,$filename,$tail);
}
}
//入库导出
public function _excelr()
{
if(isset($_GET['excel']))
{
$category = $this->input->get('category',true);
$size = $this->input->get('size',true);
$grade = $this->input->get('grade',true);
$color = $this->input->get('color',true);
$lowe = $this->input->get('lowe',true);
$sku = $this->input->get('sku',true);
$warehouse = $this->input->get('warehouse',true);
$purchase = $this->input->get('purchase',true);
$ktime = $this->input->get('ktime',true);
$jtime = $this->input->get('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "1=1";$gj = "";$ck = "";
$pc = $this->input->get('pc',true);
if($pc)
{
$pc = trim($pc,'x');
$pc = explode('x',$pc);
foreach ($pc as $v)
{
$where .= " and warehouse != '".$v."'";
}
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($sku)
{
$where .= " and sku = '$sku'";
}
if($ktime && $jtime)
{
$where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_pc($where,'enter','*',$order_str);
$list = array();
foreach ($info_list as $value)
{
$ck = $this->warehouse->read($value['warehouse']);
$warehouse = $ck['title'];
$tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
$retreatwarehouse = $tkck['title'];
$gy = $this->purchase->read($value['purchase']);
$purchase = $gy['title'];
$cpid = '';
$g = $this->specialstock->find_all($where.' and enter = "'.$value['enter'].'"','cpid');
foreach ($g as $v)
{
if($v['cpid'] != 0)
{
$cpid .= $v['cpid'].' ';
}
}
$list[] = array('details'=>$value['details'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>count($g),'cpid'=>$cpid);
}
$title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
$titlename = "
".$title." |
备注 |
产品 |
时间 |
数量 |
编码 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($list,$titlename,$filename,$tail);
}
}
//出库、退库导出
public function _excelct()
{
if(isset($_GET['excel']))
{
$type = $this->input->get('excel',true);
$category = $this->input->get('category',true);
$size = $this->input->get('size',true);
$grade = $this->input->get('grade',true);
$color = $this->input->get('color',true);
$lowe = $this->input->get('lowe',true);
$lacetype = $this->input->get('lacetype',true);
$details = $this->input->get('details',true);
$sku = $this->input->get('sku',true);
$warehouse = $this->input->get('warehouse',true);
$purchase = $this->input->get('purchase',true);
$state = $this->input->get('state',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 = "";
$pc = $this->input->get('pc',true);
if($pc)
{
$pc = trim($pc,'x');
$pc = explode('x',$pc);
foreach ($pc as $v)
{
$where .= " and warehouse != '".$v."'";
}
}
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($sku)
{
$where .= " and sku like '%$sku%'";
}
if($lacetype)
{
$where .= " and features like '%-$lacetype-%'";
}
if($details)
{
$where .= " and details like '%$details%'";
}
if($ktime && $jtime)
{
if($type == 1)
{
$tl = '出库';
$where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
}
else if($type == 2)
{
$tl = '退库';
$where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
}
else if($type == 3)
{
$gj = " and enter > '$ktime' and enter < '$jtime'";
$ck = " and outk > '$ktime' and outk < '$jtime'";
}
else if($type == 4)
{
$tl = '出库+零售';
$where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
}
else if($type == 5)
{
$tl = '零售';
$where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
}
}
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;
}
//取得信息列表
if($type != 3 && $type != 5)
{
if($type == 1 || $type == 4)
{
$info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,outk,cpbz',$order_str);
foreach ($info_list as $key=>$value)
{
$info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
}
}
else
{
$info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,retreat,cpbz',$order_str);
foreach ($info_list as $key=>$value)
{
$info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
}
}
$title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
$titlename = "
".$title." |
位置 |
产品编码 |
产品 |
标签 |
订单号 |
运单号 |
".$tl."时间(中国时间) |
备注 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($info_list,$titlename,$filename,$tail);
}
else if($type == 5)
{
$info_list = $this->specialstock->find_all($where,'details,cpid,title,label,outk,cpbz',$order_str);
foreach ($info_list as $key=>$value)
{
$info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
$warehouse = $this->warehouse->read($value['warehouse']);
$info_list[$key]['warehouse'] = $warehouse['title'];
}
$title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
$titlename = "
".$title." |
位置 |
产品编码 |
产品 |
标签 |
".$tl."时间(中国时间) |
备注 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($info_list,$titlename,$filename,$tail);
}
else
{
$info_list = $this->specialstock->find_pc($where.$sidwhere,'sku,warehouse,features','*');
$list = array();
foreach ($info_list as $value)
{
$classid = $this->classid->sku();
$pm = $classid;
//$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
$features = explode('-',trim($value['features'],'-'));
foreach ($features as $v)
{
$typeclass = $this->typeclass->read($v);
$pm[$typeclass['classid']] = $typeclass['zh'];
//$scsku[$typeclass['classid']] = $typeclass['bqsku'];
}
$typeclass = $this->typeclass->read($v);
//$scsku = implode("-",$scsku);
$zh = implode(" ",$pm);
$zh = str_replace('自然色 ','',rtrim($zh,' '));
//$scsku = str_replace('- ','-',trim($scsku,'-'));
//$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
$cpid = '';
$c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"','cpid');
foreach ($c as $v)
{
if($v['cpid'] != 0)
{
$cpid .= $v['cpid'].' ';
}
}
$g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state != "9"');
$x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "1"');
$t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "2"');
$number = $value['number'];$ftime = time()-15*24*3600;
$warehouse = $this->warehouse->read($value['warehouse']);
$list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$g,count($c),$x,$t,$value['cpbz']);
}
$title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
$titlename = "
".$title." |
位置 |
库存编码 |
产品 |
SKU |
中文 |
入库总量 |
库存数量 |
销售数量 |
退货数量 |
备注 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($list,$titlename,$filename,$tail);
}
}
}
//数量调整模板导出
public function _presetout()
{
if(isset($_GET['excel']))
{
$where = "1=1";
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
$pc = $this->input->get('pc',true);
if($pc)
{
$pc = trim($pc,'x');
$pc = explode('x',$pc);
foreach ($pc as $v)
{
$where .= " and warehouse != '".$v."'";
}
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['number']] = $value;//所有数据sku
}
foreach ($rows as $value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$number = $value['number'];$ftime = time()-15*24*3600;
$list[] = array($value['features'],$value['sku'],'0','','0',$warehouse['title']);
}
$title = "库存模板";
$titlename = "
编码号 |
SKU |
增减数量(正数或负数) |
扣减备注 |
扣减方式:0减少库存1删除库存 |
所属仓库 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($list,$titlename,$filename,$tail);
}
}
//数量调整模板导入
public function _presetedit()
{
$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
{
libxml_use_internal_errors(true);
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;
}
}
$i = 0;$j = 0;$ed = array();
foreach ($list as $key=>$value)
{
$time = time();
if($value['0'] == "")
{
continue;
}
$features = $value['0'];
$num = $value['2'];//调整数量
$text = $value['3'];//扣减说明
$type = $value['4'];//调整方式0扣减1删除
$d = $this->specialstock->get_features($features);
if(!$d)//如果没有这个SKU
{
$ed[] = array($title.'-库存中不存在此编码');
$j++;
continue;
}
if($num < 0)//扣减库存
{
$data = $this->specialstock->find_all('warehouse = "'.$warehouse['id'].'" and features = "'.$features.'" and zd = "" and state = 0');
if(count($data) < abs($num))
{
$ed[] = array($title.'-扣减数量大于库存剩余数量!');
$j++;
continue;
}
if($type == 0)//如果扣减方式为 扣减库存
{
for($i=0;$ispecialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$data[$i]['id']);
}
}
else
{
for($i=0;$ispecialstock->remove($data[$i]['id']);
}
}
}
else if($num > 0)//增加库存
{
$post['shop'] = $d['shop'];
$post['purchase'] = $d['purchase'];
$post['retreatwarehouse'] = $d['retreatwarehouse'];
$post['state'] = 0;
$post['title'] = $d['title'];
$post['number'] = $d['number'];
$post['features'] = $d['features'];
$post['enter'] = $time;
$post['time'] = $time;//操作时间
for($i=0;$i<$num;$i++)
{
$post['label'] = time().rand(100,999).$i;
$this->specialstock->insert($post);
}
}
sleep(1);//防止入库时间一样,需要延迟1秒
}
if($j > 0)
{
$tt = date('Ymd',time());
$title = '库存导入错误信息-'.$tt;
$titlename = "";
$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'=>'导入成功!','error'=>1,'success'=>true));exit;
}
}
}
//笛卡儿积
function cp($ps,$sets,$list)
{
$result = array();$j=0;
for($i=0,$count=count($sets); $i<$count-1; $i++)
{
if($i==0)
{
$result = $sets[$i];
}
$tmp = array();
foreach($result as $res)
{
foreach($sets[$i+1] as $set)
{
$tmp[] = $res.','.$set;
}
}
$result = $tmp;
}
$this->db->trans_begin();
foreach ($result as $v)
{
$post = array();$title = "";$num="";
$data = explode(',',$v);
for($i=0;$itypeclass->read($data[$i]);
$title = $title.$typeclass['title']." ";
if($data[$i] != 0)
{
$num .=$data[$i];//所有数据ID拼接
}
}
foreach ($ps as $kp=>$vp)
{
$post[$kp] = $vp;
}
$post['number'] = $num;
$info_list = $this->specialstock->get_number($num);//查询specialstock是否存在此拼接的数据ID
if($info_list)
{
$j++;
}
else
{
$skunum = $this->specialstock->find_count();
$post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
$post['title'] = rtrim($title,' ');
$this->specialstock->insert($post);
}
}
if ($this->db->trans_status() === FALSE)
{
$this->db->trans_commit();
return NULL;
}
else
{
$this->db->trans_commit();
return $j;
}
}
public function _kj($arg_array)
{
if(isset($_POST['number']))
{
$time = time();
$number = $this->input->post('number',true);
$num = $this->input->post('num',true);
$text = $this->input->post('text',true);
$order = $this->specialstock->find_all("number = '$number' and zd = '' and state = 0");
if($num > count($order))
{
echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
}
else
{
for($i=0;$i<$num;$i++)
{
$this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$order[$i]['id']);
}
}
echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
}
$uid = $this->specialstock->read($arg_array[0]);
$uid['num'] = $this->specialstock->find_count('number = "'.$uid['number']. '" and zd = "" and state = 0');
$this->data['data'] = $uid ;
$this->_Template('specialstock_kj',$this->data);
}
public function _summary($arg_array)
{
if(isset($_GET['excel']))
{
$ktime = $this->input->get('ktime',true);
$jtime = $this->input->get('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "1=1";
if($ktime && $jtime)
{
$where .= " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "time desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
$pc = $this->input->get('pc',true);
if($pc)
{
$pc = trim($pc,'x');
$pc = explode('x',$pc);
foreach ($pc as $v)
{
$where .= " and warehouse != '".$v."'";
}
}
//取得信息列表
$info_list = $this->specialstock->find_pc($where,'number','*');
foreach ($info_list as $value)
{
$xcpid = '';$scpid = '';
$x = $this->specialstock->find_all($where.' and number = "'.$value['number'].'"');
foreach ($x as $v)
{
if($v['cpid'] != 0)
{
$xcpid .= $v['cpid'].' ';
}
}
$s = $this->specialstock->find_all('state = 0 and number = "'.$value['number'].'"');
foreach ($s as $v)
{
if($v['cpid'] != 0)
{
$scpid .= $v['cpid'].' ';
}
}
$list[] = array('details'=>$value['details'],'title'=>$value['title'],'s'=>count($s),'x'=>count($x),'scpid'=>$scpid,'xcpid'=>$xcpid,'outk'=>date('Y-m-d H:i:s',$value['outk']));
}
$title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
$titlename = "
仓库备注 |
产品名 |
总剩余库存 |
".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量 |
剩余产品编码 |
销售产品编码 |
出库时间 |
";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($list,$titlename,$filename,$tail);
}
}
//usps发货清单
public function _manifest()
{
if(isset($_POST['manifest']))
{
$wltext = $this->input->post('wltext',true);
$time = time()-16*3600;
$ptime = strtotime(date('Y-m-d',$time));
$waybill = array();
$fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
foreach ($fullorder as $v)
{
$waybill[$v['waybill']] = $v['waybill'];
}
$fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
foreach ($fullordersmt as $v)
{
$waybill[$v['waybill']] = $v['waybill'];
}
$wltext = explode(';',$wltext);
foreach ($wltext as $v)
{
if(isset($waybill[$v]))
{
unset($waybill[$v]);
}
}
$data = $this->usps->get_manifest($waybill);
if(isset($data['Description']))
{
echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
}
else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
{
$bctime = date('Ymd',time());
$pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
}
else
{
echo json_encode(array('msg'=>$data,'success'=>false));exit;
}
}
}
public function _pdf($pdf,$title,$bctime)
{
$pdf_path = './data/pdf/'.$bctime.'/';
$file_base64 = $pdf;
$file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
$file_base64 = base64_decode($file_base64);
if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
file_put_contents($pdf_path.$title.'.pdf',$file_base64);
return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
}
/**
*
*
*
进销存占单异常索引
*
*
*
**/
public function _abnormal()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$sku = $this->input->post('sku',true);
$where = "1=1";
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['sku']] = $value;//所有数据sku
}
foreach ($rows as $value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
$number = $value['number'];$ftime = time()-15*24*3600;
if($value['shop'] != '')
{
$shop = $value['shop'];
$orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$order = array_merge($orderdlz,$ordersmt);
$od = 0;$a = '';$orid = '';
foreach ($order as $v)
{
$or = explode('|',ltrim($v['specialstock'],'|'));
for($i=0;$ifullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
$order = array_merge($orderdlz,$ordersmt);
$od = 0;$a = '';$orid = '';$qt = array();
foreach ($order as $v)
{
$or = explode('|',ltrim($v['specialstock'],'|'));
for($i=0;$ispecialstock->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
if($czzs > 0)
{
if(isset($qt[$v['shop']]))
{
if($qt[$v['shop']] < $orod[1])
{
$od += $orod[1];//专属小于单量不计算剩余直接归入通用
$orid .= $v['number'].'+数量'.$orod[1].'-';
}
else
{
$qt[$v['shop']] -= $orod[1];
}
}
else
{
$qt[$v['shop']] = $czzs;
}
}
else
{
$od += $orod[1];
$orid .= $v['number'].'+数量'.$orod[1].'-';
}
}
}
}
}
$z = $od.'('.$orid.')';//查看订单号
//$z = $od;
if($od > $c)
{
$list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
}
}
$listdata = array_slice($list,$start,$perpage);
$total = count($list);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
echo json_encode($rows);exit;
}
$this->_Template('specialstock_abnormal',$this->data);
}
/**
*
*
*
进销存占单异常索引
*
*
*
**/
public function _error()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$sku = $this->input->post('sku',true);
$warehouse = $this->input->post('warehouse',true);
$where = "1=1";
if($sku)
{
$where .= " and sku = '$sku'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
if($value['sku'] != '')
{
$rows[$value['sku']] = $value;//所有数据sku
}
}
foreach ($rows as $value)
{
$warehouse = $this->warehouse->read($value['warehouse']);
$c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
$number = $value['number'];$ftime = time()-15*24*3600;
if($c < 1)
{
$list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
}
}
$listdata = array_slice($list,$start,$perpage);
$total = count($list);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
echo json_encode($rows);exit;
}
if(isset($post['s']))
{
$id_arr = $this->input->post('s');
$id_arr = explode(',',$id_arr);
if(!$id_arr)
{
echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
}
//循环删除记录
foreach ($id_arr as $v)
{
$dd = $this->specialstock->read($v);
$deldd = $this->specialstock->find_all("sku = '".$dd['sku']."'");
foreach ($deldd as $vv)
{
$this->specialstock->remove($vv['id']);
}
}
echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
}
$this->_Template('specialstock_error',$this->data);
}
/**
*
*
* 占单
*
*
**/
public function _kcyz()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['warehouse']))
{
$warehouse = $this->input->post('warehouse',true);
$specialstock = $this->input->post('specialstock',true);
$id = $this->input->post('id',true);
$shop = $this->input->post('shop',true);
$number = $this->input->post('number',true);
if(!$specialstock || $specialstock == '|')
{
return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
}
$pp = explode('|',trim($specialstock,'|'));
$x = 0;$save = array();
foreach ($pp as $va)
{
$num = explode('-',$va);
if($number)
{
$specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')");//通用
$shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
}
else
{
$specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
$shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
}
$x++;
if(count($specialstock)+count($shopspecialstock) < $num[1])
{
$save[] = $x-1;continue;//提前先加X不然出错,所以要减1
}
}
if(isset($save[0]))
{
echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
}
else
{
echo json_encode(array('success'=>true));exit;
}
}
}
public function _hwwz()//货物位置
{
if(isset($_GET['id']))
{
$id = $this->input->get('id',true);
$sku = $this->input->get('sku',true);
$bs = $this->input->get('bs',true);
$number = $this->input->get('number',true);
$warehouse = $this->input->get('warehouse',true);
$purchase = $this->input->get('purchase',true);
$orderinfo = $this->input->get('orderinfo',true);
$waybill = $this->input->get('waybill',true);
$category = $this->input->get('category',true);
$size = $this->input->get('size',true);
$grade = $this->input->get('grade',true);
$color = $this->input->get('color',true);
$lowe = $this->input->get('lowe',true);
$state = $this->input->get('state',true);
$label = $this->input->get('label',true);
$px = $this->input->get('px',true);
$details = $this->input->get('details',true);
$timetk = $this->input->get('timetkk',true);
$timetj = $this->input->get('timetjj',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
$where = "state='0'";
//数据排序
$order_str = $px." desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
$category = $this->input->get('category',true);
$warehouse = $this->input->get('warehouse',true);
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($details)
{
$where .= " and details = '$details'";
}
if($id != '')
{
$sid = "";
$usersp = explode(',',trim($id,','));
foreach ($usersp as $value)
{
$sid .= " id = ".$value." or";
}
$info_list = $this->specialstock->find_all($where." and (".rtrim($sid,'or').")",'*','details desc');
}
else
{
$info_list = $this->specialstock->find_all($where,'*','details desc');
}
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['sku'].$value['warehouse'].$value['details']] = $value;//所有数据sku
}
foreach ($rows as $value)
{
$classid = $this->classid->sku();
$pm = $classid;
//$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
$features = explode('-',trim($value['features'],'-'));
foreach ($features as $v)
{
$typeclass = $this->typeclass->read($v);
$pm[$typeclass['classid']] = $typeclass['zh'];
//$scsku[$typeclass['classid']] = $typeclass['bqsku'];
}
$typeclass = $this->typeclass->read($v);
//$scsku = implode("-",$scsku);
$zh = implode(" ",$pm);
$zh = str_replace('自然色 ','',rtrim($zh,' '));
//$scsku = str_replace('- ','-',trim($scsku,'-'));
//$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
$c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"');
$number = $value['number'];$ftime = time()-15*24*3600;
$warehouse = $this->warehouse->read($value['warehouse']);
$list[] = array($value['id'],$value['details'],$zh,$c);
}
$title = "库存表";
$titlename = "";
$filename = $title.".xls";
$tail = "";
$this->excel->get_fz2($list,$titlename,$filename,$tail);
}
}
public function _order()
{
$post = $this->input->post(NULL, TRUE);
if(isset($arg_array[0]))
{
if($arg_array[0] == 'del')
{
$s = $this->input->post('s',true);
$del = $this->_del($s);
echo $del;exit;
}
}
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',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);
$sku = $this->input->post('sku',true);
$details = $this->input->post('details',true);
$warehouse = $this->input->post('warehouse',true);
$purchase = $this->input->post('purchase',true);
$lacetype = $this->input->post('lacetype',true);
$state = $this->input->post('state',true);
$ktime = $this->input->post('ktime',true);
$jtime = $this->input->post('jtime',true);
$ktime = strtotime($ktime);
$jtime = strtotime($jtime);
$where = "zd =''";$gj = "";$ck = "";
if($category)
{
$where .= " and features like '%-$category-%'";
}
if($size)
{
$where .= " and features like '%-$size-%'";
}
if($grade)
{
$where .= " and features like '%-$grade-%'";
}
if($color)
{
$where .= " and features like '%-$color-%'";
}
if($lowe)
{
$where .= " and features like '%-$lowe-%'";
}
if($lacetype)
{
$where .= " and features like '%-$lacetype-%'";
}
if($warehouse)
{
$where .= " and warehouse = '$warehouse'";
}
if($purchase)
{
$where .= " and purchase = '$purchase'";
}
if($state)
{
$where .= " and state = '$state'";
}
if($sku)
{
$where .= " and sku like '%$sku%'";
}
if($details)
{
$where .= " and details like '%$details%'";
}
if($ktime && $jtime)
{
$gj = " and enter > '$ktime' and enter < '$jtime'";
$ck = " and outk > '$ktime' and outk < '$jtime'";
}
//数据排序
$order_str = "id desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->specialstock->find_all($where,'*');
$rows = array();$list = array();
foreach ($info_list as $key=>$value)
{
$rows[$value['number'].$value['warehouse']] = $value;//所有数据sku
}
$rowsdq = array_slice($rows,$start,$perpage);
$inch = '';$zh = '';
$classid = $this->classid->sku();
$pm = $classid;
foreach ($rowsdq as $value)
{
$features = '-';
$td = explode('-',trim($value['features'],'-'));
foreach ($td as $va)
{
$s = $this->typeclass->read($va);
if($s['classid'] == '14')
{
$c = $va;
$inch = $s['spare'];
if(isset($pm[$s['classid']]))
{
$pm[$s['classid']] = $s['zh'];
}
}
else
{
$features .= $va.'-';
if(isset($pm[$s['classid']]))
{
$pm[$s['classid']] = $s['zh'];
}
}
}
$features = $c.','.$features;
$warehouse = $this->warehouse->read($value['warehouse']);
$cpid = ($value['cpid']>0)?' - 编码:'.$value['cpid']:'';
$nr = implode(" ",$pm);
$nr = preg_replace(array('/(\s+)/','/分\s/u'),array(' ','分'),$nr);
$c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
$list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'tj'=>"添加");
}
$total = count($rows);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
echo json_encode($rows);exit;
}
$this->_Template('specialstock_order',$this->data);
}
public function _0kcdel($id_arr)
{
if($id_arr)
{
$id_arr = explode(',',$id_arr);
$j = count($id_arr);
$i = 0;
//循环删除记录
foreach ($id_arr as $value)
{
$data = $this->specialstock->read($value);
$z = $this->specialstock->find_count('sku = "'.$data['sku'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
if($z < 1)
{
$z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
foreach ($z as $v)
{
$this->specialstock->remove($v['id']);
}
$i++;
}
}
if($i != $j && $i != 0)
{
return json_encode(array('del'=>$id_arr,'msg'=>'有非0库存数据,0库存删除成功!','success'=>true));
}
else if($i != $j && $i == 0)
{
return json_encode(array('del'=>$id_arr,'msg'=>'库存非0不允许删除!','success'=>false));
}
else
{
return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
}
}
else
{
echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
}
}
}