106 lines
2.9 KiB
PHP
106 lines
2.9 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Notes:开票相关
|
|
* Created on: 2021/9/28 14:11
|
|
* Created by: dengbw
|
|
*/
|
|
class Bill extends HD_Controller
|
|
{
|
|
private $status_pid = 3;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->library('OrdersList');
|
|
$this->load->model('items/items_model');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->lists();
|
|
}
|
|
|
|
public function lists()
|
|
{
|
|
$params = $this->input->get();
|
|
!strlen($params['status']) && $params['status'] = 1;
|
|
$result = $this->orderslist->lists($this->status_pid, $params);
|
|
$params['status']==2 && $result['params']['show_bill_time'] = true;
|
|
$this->data = $result;
|
|
return $this->show_view($result['view'], true);
|
|
}
|
|
|
|
public function get()
|
|
{
|
|
}
|
|
|
|
//添加单条数据
|
|
public function add()
|
|
{
|
|
}
|
|
|
|
//编辑单条数据
|
|
public function edit()
|
|
{
|
|
}
|
|
|
|
//删除单条数据
|
|
public function del()
|
|
{
|
|
|
|
}
|
|
|
|
//批量操作(默认修改状态)
|
|
public function batch()
|
|
{
|
|
|
|
}
|
|
|
|
//导出数据列表
|
|
public function export()
|
|
{
|
|
$params = $this->input->get();
|
|
$params['page'] = 1;
|
|
$params['size'] = 10000;
|
|
$indexs = [];
|
|
if($params['export_type']){
|
|
$result = $this->orderslist->export_data($this->status_pid, $params);
|
|
$fileName = '保险明细';
|
|
$data = $result['data'];
|
|
$indexs = $result['indexs'];
|
|
}else{
|
|
$fieldAry = $this->orderslist->get_fields($this->status_pid, 1);
|
|
$fieldAry['bill_time']['title'] = '开票时间';
|
|
$fieldAry['vin']['title'] = '车架号';
|
|
$fieldAry['admin_name'] = ['title'=>'销售顾问'];
|
|
foreach ($fieldAry as $key => $value) {
|
|
$indexs[$key] = $value['title'];
|
|
}
|
|
$result = $this->orderslist->lists($this->status_pid, $params);
|
|
$item_arr_ids = array_unique(array_column($result['lists'],'item_id'));
|
|
$item_map = [];
|
|
if($item_arr_ids){
|
|
$str_ids = implode(',',$item_arr_ids);
|
|
$where = [
|
|
"id in ({$str_ids})" => null
|
|
];
|
|
$item_map = $this->items_model->map('id','vin',$where,'','','','id,vin');
|
|
}
|
|
$fileName = $result['_title'];
|
|
foreach ($result['lists'] as $key => $value) {
|
|
$value['vin'] = $item_map[$value['item_id']];
|
|
$temp = array();
|
|
foreach ($fieldAry as $key2 => $value2) {
|
|
$temp[$key2] = $value[$key2];
|
|
}
|
|
$data[] = $temp;
|
|
}
|
|
array_unshift($data, $indexs);
|
|
}
|
|
$this->load->library('excel');
|
|
return $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
|
|
}
|
|
|
|
}
|