public function action_stats() { $data = array(); $errors = array(); $filter = Session::instance()->get('statFilter', array()); if ($this->isPressed('btnFilter')) { $filter['FIO'] = Arr::get($_POST, 'FIO'); $filter['dateFrom'] = Arr::get($_POST, 'dateFrom'); $filter['dateTo'] = Arr::get($_POST, 'dateTo'); Session::instance()->set('statFilter', $filter); if ($filter['dateFrom'] != '' && !Valid::mydate($filter['dateFrom'])) { $errors['dateFrom'] = 'Дата должна быть в формате dd.mm.yyyy'; } if ($filter['dateTo'] != '' && !Valid::mydate($filter['dateTo'])) { $errors['dateTo'] = 'Дата должна быть в формате dd.mm.yyyy'; } } $material_id = $this->request->param('id', NULL); $material = ORM::factory('material', $material_id); $data['materialName'] = $material->materialName; $data['stats'] = $material->getStats($material_id, $filter); $data['count'] = count($data['stats']); $data['filter'] = $filter; $data['errors'] = $errors; $this->tpl->content = View::factory('materials/stats', $data); }