public function actionBuergerInnenversammlungen() { if (!$this->binContentAdmin()) { $this->errorMessageAndDie(403, ""); } $this->top_menu = "admin"; if (AntiXSS::isTokenSet("delete")) { /** @var Termin $termin */ $termin = Termin::model()->findByPk(AntiXSS::getTokenVal("delete")); $termin->delete(); $this->msg_ok = "Gelöscht."; } if (AntiXSS::isTokenSet("save")) { if (isset($_REQUEST["neu"]) && $_REQUEST["neu"]["datum"] != "" && $_REQUEST["neu"]["ba_nr"] > 0) { $result = Yii::app()->db->createCommand("SELECT MIN(id) minid FROM termine")->queryAll(); $id = $result[0]["minid"]; if ($id >= 0) { $id = 0; } $id--; $termin = new Termin(); $termin->id = $id; $termin->ba_nr = IntVal($_REQUEST["neu"]["ba_nr"]); $termin->typ = Termin::$TYP_BUERGERVERSAMMLUNG; $termin->sitzungsort = $_REQUEST["neu"]["ort"]; $termin->termin = $_REQUEST["neu"]["datum"]; $termin->datum_letzte_aenderung = new CDbExpression('NOW()'); if (!$termin->save()) { $this->msg_err = print_r($termin->getErrors(), true); } } if (isset($_REQUEST["termin"])) { foreach ($_REQUEST["termin"] as $id => $save) { /** @var Termin $termin */ $termin = Termin::model()->findByPk($id); $termin->sitzungsort = $save["ort"]; $termin->termin = $save["datum"]; $termin->save(); } } $this->msg_ok = "Gespeichert"; } $termine = Termin::model()->findAllByAttributes(["typ" => Termin::$TYP_BUERGERVERSAMMLUNG], ["order" => "termin DESC"]); $this->render("buergerInnenversammlungen", ["termine" => $termine]); }