load->library('session');
$this->load->_model('Model_taxzhengzhou','taxzhengzhou');
$this->load->_model('Model_taxzhengzhousk','taxzhengzhousk');
$this->load->_model('Model_taxzhengzhoush','taxzhengzhoush');
$this->load->_model('Model_fullorder','fullorder');
$this->load->_model('Model_fullordertt','fullordertt');
$this->load->_model('Model_fullordersmt','fullordersmt');
}
//定义方法的调用规则 获取URI第二段值
public function _remap($arg,$arg_array)
{
if($arg == 'add')//添加
{
$this->_add();
}
else if($arg == 'edit')//修改
{
$this->_edit($arg_array);
}
else if($arg == 'skadd')//添加
{
$this->_skadd();
}
else if($arg == 'skedit')//修改
{
$this->_skedit($arg_array);
}
else if($arg == 'sk')//修改
{
$this->_sk($arg_array);
}
else if($arg == 'addsh')//添加
{
$this->_addsh($arg_array);
}
else if($arg == 'sh')//添加
{
$this->_sh($arg_array);
}
else if($arg == 'shlist')//添加
{
$this->_shlist($arg_array);
}
else if($arg == 'wc')//添加
{
$this->_wc($arg_array);
}
else if($arg == 'drexcel')//添加
{
$this->_drexcel($arg_array);
}
else if($arg == 'ding')//添加
{
$this->_ding($arg_array);
}
else
{
$this->_index();
}
}
//管理
public function _index()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$continent = $this->input->post('continent',true);
$express = $this->input->post('express',true);
$ename = $this->input->post('ename',true);
$zname = $this->input->post('zname',true);
$where = "1=1 ";
if($continent)
{
$where .= " and continent = '$continent'";
}
if($express)
{
$where .= " and express = '$express'";
}
if($ename)
{
$where .= " and ename = '$ename'";
}
if($zname)
{
$where .= " and zname = '$zname'";
}
//数据排序
$order_str = "id asc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->taxzhengzhou->find_all($where,'id,orderno,apptype,batchnumber,packno,goodsvalue,insuredFee,ht,itemno,iedate,createtime,accountingdate,sh',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
if($value['apptype'] == '1')
{
$info_list[$key]['apptype'] = '新增';
}
else if($value['apptype'] == '2')
{
$info_list[$key]['apptype'] = '变更';
}
else if($value['apptype'] == '3')
{
$info_list[$key]['apptype'] = '删除';
}
if($value['sh'] == '0')
{
$info_list[$key]['sh'] = '待审核';
}
else if($value['sh'] == '1')
{
$info_list[$key]['sh'] = '不通过';
}
else if($value['sh'] == '2')
{
$info_list[$key]['sh'] = '通过';
}
if($value['sh'] != 2)
{
$info_list[$key]['orderno'] = "".$value['orderno']."
";
}
else
{
$info_list[$key]['orderno'] = "".$value['orderno']."
";
}
$info_list[$key]['iedate'] = date('Y-m-d',$value['iedate']);
$info_list[$key]['createtime'] = date('Y-m-d h:i:s',$value['createtime']);
$info_list[$key]['accountingdate'] = date('Y-m-d h:i:s',$value['accountingdate']);
}
$total = $this->taxzhengzhou->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('tax_zhengzhou',$this->data);
}
//添加
public function _add()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['apptype']))
{
$createtime = $this->input->post('createtime',true);
$post['createtime'] = strtotime($createtime);
$iedate = $this->input->post('iedate',true);
$post['iedate'] = strtotime($iedate);
$accountingdate = $this->input->post('accountingdate',true);
$post['accountingdate'] = strtotime($accountingdate);
if($this->taxzhengzhou->insert($post))
{
echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
}
else
{
echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
}
}
$this->_Template('tax_zhengzhou_add',$this->data);
}
//修改
public function _edit($arg_array)
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['id']))
{
$id = $this->input->post('id',true);
$post['sh'] = 0;
$createtime = $this->input->post('createtime',true);
$post['createtime'] = strtotime($createtime);
$iedate = $this->input->post('iedate',true);
$post['iedate'] = strtotime($iedate);
$accountingdate = $this->input->post('accountingdate',true);
$post['accountingdate'] = strtotime($accountingdate);
if($this->taxzhengzhou->save($post,$id))
{
echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
}
else
{
echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
}
}
$arg_array = $arg_array[0];
$taxzhengzhou = $this->taxzhengzhou->read($arg_array);
$this->data['taxzhengzhou'] = $taxzhengzhou;
$this->_Template('tax_zhengzhou_edit',$this->data);
}
public function _sk()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$continent = $this->input->post('continent',true);
$express = $this->input->post('express',true);
$ename = $this->input->post('ename',true);
$zname = $this->input->post('zname',true);
$where = "1=1 ";
if($continent)
{
$where .= " and continent = '$continent'";
}
if($express)
{
$where .= " and express = '$express'";
}
if($ename)
{
$where .= " and ename = '$ename'";
}
if($zname)
{
$where .= " and zname = '$zname'";
}
//数据排序
$order_str = "id asc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->taxzhengzhousk->find_all($where,'id,orderno,charge,accountingdate',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
$info_list[$key]['accountingdate'] = date('Y-m-d h:i:s',$value['accountingdate']);
}
$total = $this->taxzhengzhousk->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('tax_zhengzhou_sk',$this->data);
}
//添加
public function _skadd()
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['apptype']))
{
$createtime = $this->input->post('createtime',true);
$post['createtime'] = strtotime($createtime);
$accountingdate = $this->input->post('accountingdate',true);
$post['accountingdate'] = strtotime($accountingdate);
if($this->taxzhengzhousk->insert($post))
{
echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
}
else
{
echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
}
}
$this->_Template('tax_zhengzhou_sk_add',$this->data);
}
//修改
public function _skedit($arg_array)
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['id']))
{
$id = $this->input->post('id',true);
$createtime = $this->input->post('createtime',true);
$post['createtime'] = strtotime($createtime);
$accountingdate = $this->input->post('accountingdate',true);
$post['accountingdate'] = strtotime($accountingdate);
if($this->taxzhengzhousk->save($post,$id))
{
echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
}
else
{
echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
}
}
$arg_array = $arg_array[0];
$taxzhengzhousk = $this->taxzhengzhousk->read($arg_array);
$this->data['taxzhengzhousk'] = $taxzhengzhousk;
$this->_Template('tax_zhengzhou_sk_edit',$this->data);
}
public function _addsh($arg_array)
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['uid']))
{
$this->db->trans_begin();
$id = $this->input->post('uid',true);
$this->taxzhengzhou->save(array('sh'=>$post['sh']),$id);
$post['time'] = time();
$this->taxzhengzhoush->insert($post);
if ($this->db->trans_status() === TRUE)
{
$this->db->trans_commit();
echo json_encode(array('msg'=>'提交成功','success'=>true));exit;
}
else
{
$this->db->trans_rollback();
echo json_encode(array('msg'=>'提交失败,请重试','success'=>false));exit;
}
}
$arg_array = $arg_array[0];
$taxzhengzhou = $this->taxzhengzhou->read($arg_array);
$this->data['taxzhengzhou'] = $taxzhengzhou;
$this->_Template('tax_zhengzhou_addsh',$this->data);
}
public function _wc($arg_array)
{
$post = $this->input->post(NULL, TRUE);
$arg_array = $arg_array[0];
$taxzhengzhou = $this->taxzhengzhou->read($arg_array);
$this->data['taxzhengzhou'] = $taxzhengzhou;
$this->_Template('tax_zhengzhou_wc',$this->data);
}
public function _sh($arg_array)
{
$post = $this->input->post(NULL, TRUE);
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$continent = $this->input->post('continent',true);
$express = $this->input->post('express',true);
$ename = $this->input->post('ename',true);
$zname = $this->input->post('zname',true);
$where = "sh=0 ";
if($continent)
{
$where .= " and continent = '$continent'";
}
if($express)
{
$where .= " and express = '$express'";
}
if($ename)
{
$where .= " and ename = '$ename'";
}
if($zname)
{
$where .= " and zname = '$zname'";
}
//数据排序
$order_str = "id asc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
//取得信息列表
$info_list = $this->taxzhengzhou->find_all($where,'id,orderno,apptype,batchnumber,packno,goodsvalue,insuredFee,payno,itemno,iedate,createtime,accountingdate',$order_str,$start,$perpage);
foreach ($info_list as $key=>$value)
{
if($value['apptype'] == '1')
{
$info_list[$key]['apptype'] = '新增';
}
else if($value['apptype'] == '2')
{
$info_list[$key]['apptype'] = '变更';
}
else if($value['apptype'] == '3')
{
$info_list[$key]['apptype'] = '删除';
}
$info_list[$key]['iedate'] = date('Y-m-d',$value['iedate']);
$info_list[$key]['createtime'] = date('Y-m-d h:i:s',$value['createtime']);
$info_list[$key]['accountingdate'] = date('Y-m-d h:i:s',$value['accountingdate']);
}
$total = $this->taxzhengzhou->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('tax_zhengzhou_sh',$this->data);
}
public function _shlist($arg_array)
{
$where = "uid = '".$arg_array[0]."'";
$info_list = $this->taxzhengzhoush->find_all($where,'title,shname,time,sh','id desc');
foreach ($info_list as $key=>$value)
{
if($value['sh'] == 2)
{
$info_list[$key]['title'] = '审核通过';
}
$info_list[$key]['time'] = date('Y-m-d h:i',$value['time']);
}
$this->data['data'] = $info_list;
$this->_Template('tax_zhengzhou_shlist',$this->data);
}
public function _drexcel($arg_array)
{
$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();$dn = '';$ds = 'get_number';
foreach ($list as $key=>$value)
{
if($value[0] == '')
{
continue;
}
if($value[0] == '订单号')
{
$dn = 0;
$ds = 'get_orderinfo';
continue;
}
else if ($value[0] == '序号')
{
$dn = 19;
continue;
}
else
{
$dlz = $this->fullorder->$ds($value[0]);
$smt = $this->fullordersmt->$ds($value[0]);
$dlz2 = $this->fullorder->$ds($value[9]);
$smt2 = $this->fullordersmt->$ds($value[9]);
if($dlz || $smt)
{
$dn = 0;
}
if($dlz2 || $smt2)
{
$dn = 9;
}
}
$dgs = 'fullorder';
$dd = $this->fullorder->$ds($value[$dn]);
if(!$dd)
{
$dd = $this->fullordersmt->$ds($value[$dn]);
$dgs = 'fullordersmt';
}
if(!$dd)
{
$ed[] = $value[$dn];
$j++;
}
else
{
$this->$dgs->save(array('gw'=>$arg_array[0]),$dd['id']);
$i++;
}
}
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'=>'导入成功!共导入'.$i.'条','error'=>1,'success'=>true));exit;
}
}
}
public function _ding()
{
$post = $this->input->post(NULL, TRUE);
if(isset($_SESSION['api']))
{
$user = $this->user->get_api($_SESSION['api']);
$usp = $user;
$fgshop = "";$sid = "";$wid="";$wtype="";
$usersp = explode('|',trim($user['shop'],'|'));
$userwh = explode('|',trim($user['warehouse'],'|'));
foreach ($usersp as $value)
{
$fgshop .= " shop = ".$value." or";
$sid .= " id = ".$value." or";
}
foreach ($userwh as $value)
{
$wid .= " id = ".$value." or";
$wtype .= " type = ".$value." or";
}
}
if(isset($post['page']))
{
$page = $this->input->post('page',true);
$perpage = $this->input->post('perpage',true);
$ht = $this->input->post('ht',true);
$orderno = $this->input->post('orderno',true);
$timetk = $this->input->post('timetk',true);
$timetj = $this->input->post('timetj',true);
$timetk = strtotime($timetk);
$timetj = strtotime($timetj);
$where = "gw != 0 and dtime > '$timetk' and dtime < '$timetj'";;
if($ht)
{
$tax = $this->taxzhengzhou->get_ht($ht);
$where .= " and gw = '".$tax['id']."'";
}
if($orderno)
{
$tax = $this->taxzhengzhou->get_orderno($orderno);
$where .= " and gw = '".$tax['id']."'";
}
//数据排序
$order_str = "dtime desc";
if(empty($page))
{
$start = 0;
$perpage = 1;
}
else
{
$start = ($page - 1)*$perpage;
}
$info_list = array();
$info_listsmt = array();
$dlz = 0; $smt = 0;
//取得信息列表
$info_list = $this->fullorder->find_all($where,'id,orderinfo,number,name,dtime,waybill',$order_str,$start,$perpage);
//格式化数据
foreach ($info_list as $key=>$value)
{
$info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
$info_list[$key]['orderinfo'] = "".$value['orderinfo']."
";
}
$dlz += $this->fullorder->find_count($where);
$info_listsmt = $this->fullordersmt->find_all($where,'id,orderinfo,number,name,dtime,waybill',$order_str,$start,$perpage);
//格式化数据
foreach ($info_listsmt as $key=>$value)
{
$info_listsmt[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
$info_listsmt[$key]['orderinfo'] = "".$value['orderinfo']."
";
}
$smt += $this->fullordersmt->find_count($where);
//$total += $this->fullorder_smt->find_count($where);
$total = $dlz+$smt;
$rows = array_merge($info_list,$info_listsmt);
//$rows = array_slice($rows,$start,$perpage);
$pagenum = ceil($total/$perpage);
$over = $total-($start+$perpage);
$tmp = array();
foreach ($rows as $key => $val)
{
$tmp[$key] = $val['dtime'];
}
array_multisort($tmp,SORT_DESC,$rows);
$rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
echo json_encode($rows);exit;
}
$this->_Template('tax_zhengzhou_ding',$this->data);
}
public function _ck()
{
}
}