File: /var/www/vhosts/creativefellows.nl/jhtaxatie.creativefellows.nl/classes/SearchController.php
<?php
class SearchController extends BaseController
{
function __construct($db_connection,$router,$user_id,$view=null,$user_role=null,$settings=null)
{
$this->db = $db_connection;
$this->router = $router;
$this->view = $view;
$this->user_role = $user_role;
$this->user_id = $user_id;
$this->settings = $settings;
$this->siteUrl = $this->settings['siteUrl'];
}
/*
* Search DB for taxations
*/
public function showSearch($request, $response, $args)
{
$params = $request->getQueryParams();
$q = $params["q"];
$view_page = isset($params["p"]) ? $params["p"] : 1;
// taxations
$taxationController = new TaxationController($this->db, $this->router, $this->user_id , null, $this->user_role, $this->settings);
$taxationController->setPageMax(50);
$taxations = $taxationController->searchTaxations($q,$view_page);
// enquiries
$enquiryController = new EnquiryController($this->db, $this->router, $this->user_id , null, $this->user_role, $this->settings);
$enquiryController->setPageMax(50);
$enquiries = $enquiryController->search($q,$view_page);
// inspections
$inspectionController = new InspectionController($this->db, $this->router, $this->user_id , null, $this->user_role, $this->settings);
$inspectionController->setPageMax(50);
$inspections = $inspectionController->search($q,$view_page);
return $this->view->render($response, 'search.php',[
"router" => $this->router,
"data" => [
"Taxaties" => $taxations,
"Aanvragen" => $enquiries,
"Keuringen" => $inspections
],
"paths" =>
[
"Taxaties" => "taxation.view",
"Aanvragen" => "enquiry.view",
"Keuringen" => "inspection.view"
],
"header_lbl" => "Zoekresultaten",
"pagination" => $this->pagination,
"active_page" => $view_page,
"q" => $q
]);
}
}
?>