|
|
@@ -193,7 +193,10 @@ class Whlabel extends Start_Controller
|
|
|
}else if ($arg == 'exceljxcjs') //进销存信息导出
|
|
|
{
|
|
|
$this->_exceljxcjs();
|
|
|
- } else if($arg == "w_t_cs"){
|
|
|
+ } else if ($arg == 'summaryjs') //汇总导出
|
|
|
+ {
|
|
|
+ $this->_summaryjs($arg_array);
|
|
|
+ }else if($arg == "w_t_cs"){
|
|
|
$this->_w_t_cs(); //首页
|
|
|
}else {
|
|
|
$this->_index();
|
|
|
@@ -8432,4 +8435,96 @@ class Whlabel extends Start_Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function _summaryjs($arg_array)
|
|
|
+ {
|
|
|
+ $prc = array();
|
|
|
+ $purchase = $this->purchase->find_all();
|
|
|
+ foreach ($purchase as $k => $v) {
|
|
|
+ $prc[$v['id']] = $v['title'];
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ //取得信息列表
|
|
|
+ $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
|
|
|
+ foreach ($info_list as $key => $value) {
|
|
|
+ $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
|
|
|
+ $warehouse = $this->warehouse->read($value['warehouse']);
|
|
|
+ $info_list[$key]['warehouse'] = $warehouse['title'];
|
|
|
+ $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
|
|
|
+ $details = array();
|
|
|
+ $cpid = array();
|
|
|
+ foreach ($x as $k => $v) {
|
|
|
+ if ($v['details'] != '') {
|
|
|
+ $details[$v['details']] = $v['details'];
|
|
|
+ }
|
|
|
+ if ($v['cpid'] != 0) {
|
|
|
+ $cpid[$v['cpid']] = $v['cpid'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
|
|
|
+ $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
|
|
|
+ $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
|
|
|
+ $info_list[$key]['s'] = $s;
|
|
|
+ $info_list[$key]['x'] = count($x);
|
|
|
+ }
|
|
|
+ if(empty($info_list)){
|
|
|
+ exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
|
|
|
+ }
|
|
|
+ $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
|
|
|
+ $merges = [
|
|
|
+ [
|
|
|
+ "s"=>["r"=>0,"c"=>0],
|
|
|
+ "e"=>["r"=>0,"c"=>7]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ $cols = [
|
|
|
+ ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
|
|
|
+ ];
|
|
|
+ $final_list = [];
|
|
|
+ foreach($info_list as $k => $v){
|
|
|
+ $final_list[] = array_values($v);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
|
|
|
+ $titlename = "<table border=1>
|
|
|
+ <tr align='center'>
|
|
|
+ <td>仓库</td>
|
|
|
+ <td>供应商</td>
|
|
|
+ <td>出库位置</td>
|
|
|
+ <td>出库编码</td>
|
|
|
+ <td>SKU</td>
|
|
|
+ <td>产品名</td>
|
|
|
+ <td>总剩余库存</td>
|
|
|
+ <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
|
|
|
+ </tr>
|
|
|
+ </table>";
|
|
|
+ $filename = $title . ".xls";
|
|
|
+ $tail = "";
|
|
|
+ $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|