/** * @return array */ public static function getCommissionsList() { $result = array(); $query = new CQuery(); $query->select("c.*")->from(TABLE_SAB_COMMISSIONS . " as c")->innerJoin(TABLE_YEARS . " as y", "c.year_id = y.id")->order("y.name desc"); foreach ($query->execute()->getItems() as $ar) { $commission = new CSABCommission(new CActiveRecord($ar)); $nv = $commission->title . " (" . $commission->year->getValue() . ")"; $result[$commission->getId()] = $nv; } return $result; }
public function actionGetViewData() { $result = array(); // комиссии по защите дипломов. показываем только комиссии этого года foreach (CActiveRecordProvider::getWithCondition(TABLE_SAB_COMMISSIONS, "year_id=" . CUtils::getCurrentYear()->getId())->getItems() as $ar) { $comm = new CSABCommission($ar); $value = $comm->title; if (!is_null($comm->manager)) { $value .= " " . $comm->manager->getName(); } if (!is_null($comm->secretar)) { $value .= " (" . $comm->secretar->getName() . ")"; } $diplom = CStaffManager::getDiplom(CRequest::getInt("diplom_id")); if (!is_null($diplom)) { $cnt = 0; foreach ($comm->diploms->getItems() as $d) { if (strtotime($diplom->date_act) == strtotime($d->date_act)) { $cnt++; } } $value .= " " . $cnt; } $result[$comm->getId()] = $value; } return $result; }
public function save() { $commission = $this->commission; $members = array(); if (array_key_exists("members", $commission)) { $members = $commission["members"]; unset($commission["members"]); } $commObj = new CSABCommission(); $commObj->setAttributes($commission); $commObj->save(); $this->commission = $commObj; foreach (CActiveRecordProvider::getWithCondition(TABLE_SAB_COMMISSION_MEMBERS, "commission_id=" . $commObj->getId())->getItems() as $ar) { $ar->remove(); } foreach ($members as $m) { if ($m !== 0) { $ar = new CActiveRecord(array("commission_id" => $commObj->getId(), "person_id" => $m, "id" => null)); $ar->setTable(TABLE_SAB_COMMISSION_MEMBERS); $ar->insert(); } } }