57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
class ContractController extends mfBaseController {
|
|
|
|
protected function init() {
|
|
$this->needlogin=true;
|
|
$me = new User();
|
|
$me->loadMe();
|
|
$this->me = $me;
|
|
$this->layout()->set("me",$me);
|
|
|
|
if(!$me->is(["Admin"])) {
|
|
$this->redirect("Dashboard");
|
|
}
|
|
}
|
|
|
|
|
|
protected function indexAction() {
|
|
$this->layout()->setTemplate("Contract/Index");
|
|
|
|
$rfilter = $this->request->filter;
|
|
iF(!is_array($rfilter)) {
|
|
$rfilter = [];
|
|
}
|
|
|
|
$this->layout->set("filter", $rfilter);
|
|
|
|
$filter = $this->getPreparedFilter($rfilter);
|
|
|
|
// pagination defaults
|
|
$pagination = [];
|
|
$pagination['start'] = 0;
|
|
$pagination['count'] = 50;
|
|
$pagination['maxItems'] = 0;
|
|
|
|
if(is_numeric($this->request->s)) {
|
|
$pagination['start'] = intval($this->request->s);
|
|
}
|
|
//var_dump($filter);exit;
|
|
$pagination['maxItems'] = ContractModel::count($filter);
|
|
$contracts = ContractModel::search($filter, $pagination);
|
|
|
|
$this->layout()->set("contracts", $contracts);
|
|
}
|
|
|
|
private function getPreparedFilter($filter) {
|
|
$new_filter = [];
|
|
|
|
if(is_array($filter) && count($filter)) {
|
|
foreach($filter as $name => $value) {
|
|
$new_filter[$name] = $value;
|
|
}
|
|
}
|
|
|
|
return $new_filter;
|
|
}
|
|
} |