63 lines
2.1 KiB
PHP
63 lines
2.1 KiB
PHP
<?php
|
|
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Booking extends Admin_Controller {
|
|
|
|
private $params = null;
|
|
private $itemPerPage = 10;
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
// Load model
|
|
$this->load->model('booking_model');
|
|
}
|
|
|
|
public function index() {
|
|
$this->summary();
|
|
}
|
|
|
|
public function summary() {
|
|
$data['page_title'] = 'Booking';
|
|
$this->renderBookingPage('view_booking_summary', $data);
|
|
}
|
|
|
|
public function getReports() {
|
|
$postData = $this->input->post();
|
|
$this->validate($postData);
|
|
|
|
$params = !empty($postData['params']) ? $postData['params'] : $this->params;
|
|
$pageNo = !empty($postData['pageNo']) ? $postData['pageNo'] - 1 : 0;
|
|
$pageSize = !empty($postData['pageSize']) ? $postData['pageSize'] : $this->itemPerPage;
|
|
|
|
$data = $this->booking_model->getReports($params, $pageNo, $pageSize);
|
|
echo json_encode($data);
|
|
}
|
|
|
|
protected function validate($data, $type = 'filter') {
|
|
$this->load->library('form_validation');
|
|
$this->form_validation->set_data($data);
|
|
$this->setFormRuleForBooking($type);
|
|
|
|
if ($this->form_validation->run() === FALSE) {
|
|
$errors = $this->form_validation->error_array();
|
|
header('HTTP/1.1 400 Bad Request');
|
|
echo json_encode(['errors' => $errors]);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
protected function setFormRuleForBooking($type) {
|
|
$this->form_validation->set_rules('params[id]', 'ID', 'integer');
|
|
$this->form_validation->set_rules('params[quote_id]', 'Quote ID', 'integer');
|
|
$this->form_validation->set_rules('params[member_id]', 'Member ID', 'integer');
|
|
$this->form_validation->set_rules('params[cost]', 'Cost', 'integer');
|
|
}
|
|
|
|
protected function renderBookingPage($page_name, $data) {
|
|
$this->load->view('admin/view_admin_header', $data);
|
|
$this->load->view('booking/' . $page_name, $data);
|
|
$this->load->view('admin/view_admin_footer', $data);
|
|
}
|
|
}
|