public function actionSave() { $year = new CTimeIntervals(); $year->setAttributes(CRequest::getArray($year::getClassName())); if ($year->validate()) { $year->save(); if ($this->continueEdit()) { $this->redirect("?action=edit&id=" . $year->getId()); } else { $this->redirect("index.php?action=index"); } return true; } $this->setData("year", $year); $this->renderView("_time_intervals/edit.tpl"); }
public function actionIndex() { $selectedYear = null; $set = new CRecordSet(); $query = new CQuery(); $set->setQuery($query); $query->select("p.*")->from(TABLE_PERSON . " as p")->order("p.fio asc"); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY) { if (is_null(CSession::getCurrentPerson())) { $query->condition("p.id = 0"); } else { $query->condition("p.id = " . CSession::getCurrentPerson()->getId()); } } // фильтр по году if (!is_null(CRequest::getFilter("year.id"))) { $query->innerJoin(TABLE_IND_PLAN_LOADS . " as l", "l.person_id = p.id"); $query->innerJoin(TABLE_YEARS . " as year", "l.year_id = year.id"); $selectedYear = CRequest::getFilter("year.id"); } $yearsQuery = new CQuery(); $yearsQuery->select("year.*")->from(TABLE_YEARS . " as year")->order("year.name asc"); $years = array(); foreach ($yearsQuery->execute()->getItems() as $ar) { $year = new CTimeIntervals(new CActiveRecord($ar)); $years[$year->getId()] = $year->name; } $persons = new CArrayList(); foreach ($set->getPaginated()->getItems() as $ar) { $person = new CPerson($ar); $persons->add($person->getId(), $person); } $this->addActionsMenuItem(array(array("title" => "Назад", "link" => "index.php", "icon" => "actions/edit-undo.png"), array("title" => "Печать по шаблону", "link" => "#", "icon" => "devices/printer.png", "template" => "formset_ind_plan_view"))); $this->setData("paginator", $set->getPaginator()); $this->setData("persons", $persons); $this->setData("years", $years); $this->setData("selectedYear", $selectedYear); $this->renderView("_individual_plan/load/index.tpl"); }