我有2个视图:1.索引2. PrintPax
“索引”视图是表单过滤数据运行的地方,它可以完美工作,因为它获取了表单的发布数据$ month和$ year。
当我想将此帖子数据传递到视图“ printPax”时,没有数据
这是我的控制器:
public function index()
{
$data['title'] = "Dashboard";
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$data['countuser'] = $this->Admin_model->getCountUser();
$data['onprogress'] = $this->Admin_model->getOnProgressPassanger();
$data['pax'] = $this->Admin_model->getPax();
$data['destination'] = $this->Datamaster_model->getAllDestination();
$month = $this->input->post('month');
$year = $this->input->post('year');
$data['filter'] = $this->Admin_model->getFilterData($month, $year);
if (!empty($this->input->post('month') && $this->input->post('year'))) {
$data['filter'] = $this->Admin_model->getFilterData($month, $year);
}
$this->load->view('templates/header', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('admin/index', $data);
$this->load->view('templates/footer');
$this->load->view('templates/sidebar', $data);
}
public function printFilterData()
{
$month = $this->input->get('month');
$year = $this->input->get('year');
$data['filter'] = $this->Admin_model->getFilterData($month, $year);
if (!empty($this->input->get('month') && $this->input->get('year'))) {
$data['filter'] = $this->Admin_model->getFilterData($month, $year);
}
$this->load->view('view_print/print_filterdata', $data);
}
这是我的模型:
public function getFilterData($month, $year)
{
$query = "SELECT passanger.id, passanger.id_user, destination.destination, count(pax) as pax,user.name, passanger.date_tour
FROM passanger
INNER JOIN destination
ON passanger.destination = destination.id_destination
INNER JOIN user
ON passanger.id_user = user.id_user
WHERE MONTH(passanger.date_tour) = '$month'
AND YEAR(passanger.date_tour) = '$year'
GROUP BY destination, id_user ORDER BY date DESC";
return $this->db->query($query)->result_array();
}
我有一个按钮可以链接printPax视图
<a href="<?= base_url('admin/printfilterdata') ?>" class="btn btn-danger">
Print
</a>
我想要的是当我单击打印按钮时,表单过滤器数据将传递到“ printPax”视图