public function save() { try { $checked = $this->bind($this->collection); $kolizia = $this->collection->existujeKolizna(); if (!is_null($kolizia)) { $this->flash("Zadaná rozvrhová akcia koliduje s inou akciou ({$kolizia}).", "error"); throw new dataValidationException($checked); } if (DateConvert::compareSKTimestamp($this->collection->zaciatok, $this->collection->koniec) >= 0) { $this->flash("Rozvrhová akcia nemôže skončiť skorej ako začala.", "error"); throw new dataValidationException($checked); } $this->collection->save(); $this->notificator->sendStartCollectionNotifyToAllUsers($this->collection); //TODO: mozno zalogovat aj na aky semester (load podla id a get..Info) if (empty($this->collection->id)) { $this->log("Pridanie rozvrhovej akcie"); $this->flash("Rozvrhová akcia bola pridaná.", "info"); } else { $this->log("Zmena rozvrhovej akcie"); $this->flash("Rozvrhová akcia bola zmenená.", "info"); } $this->redirect("ape/collection/index"); } catch (dataValidationException $ex) { $this->set("semestre", $this->periods->getShortAll()); $this->set("akcia", $ex->checked); } }
/** * Ziska zoznam buducich udalosti. Zatial pozera len na rozvrhove akcie. * @return array( * 'title' => nazov_udalosti * 'start' => cas_zaciatku * 'end' => cas_konca * 'allDay'=> false * 'url' => odkaz - momentalne nie je sucastou vystupu * ) */ public function getFutureEvents() { $sql = "SELECT " . DateConvert::DBTimestampToSkDateTime("time_event.start") . " AS start, " . DateConvert::DBTimestampToSkDateTime("time_event.end") . " AS start, " . " semester.year,\n semester.id\n FROM event JOIN semester ON event.id_semester = semester.id\n JOIN event_time_event e2t ON event.id = e2t.id_event\n JOIN time_event ON e2t.id_time_event = time_event.id\n WHERE LOCALTIME < time_event.end + time_event.recur_freq * (time_event.recur_count-1) * INTERVAL '1 day'\n ORDER BY time_event.start DESC"; $this->dbh->query($sql); $retArr = $this->dbh->fetchall_assoc(); $this->__doplnAtributyAkciam($retArr); return $retArr; }
/** * Ziska vsetky alebo $limit poseldnych udalosti * @param int $limit kolko udalosti ziska (0 ak vsetky) * @return array udalosti */ private function __getEvents($limit = 0) { if (!is_int($limit)) { throw new Exception("Limit is not a number"); } $sql = "SELECT id, ip, username, zastupuje, udalost, " . DateConvert::DBTimestampToSkDateTime("cas") . " AS cas\n \t\t FROM log \n \t\t ORDER BY id DESC"; if ($limit > 0) { $sql .= " LIMIT {$limit}"; } $this->dbh->Query($sql); return $this->dbh->fetchall_assoc(); }
public function save() { if (empty($this->id)) { $sql = "INSERT INTO semester(year, semester_order, tuition_start, tuition_end, exam_start, exam_reparat_start, exam_end)\n\t\t\t VALUES (\$1, \$2, "; $sql .= DateConvert::SKtoDB("\$3") . ","; $sql .= DateConvert::SKtoDB("\$4") . ","; $sql .= DateConvert::SKtoDB("\$5") . ","; $sql .= DateConvert::SKtoDB("\$6") . ","; $sql .= DateConvert::SKtoDB("\$7") . ")"; $this->dbh->query($sql, array($this->rok, $this->semester, $this->zac_uc, $this->kon_uc, $this->zac_skus, $this->zac_opr, $this->kon_skus)); } else { $sql = "UPDATE semester\n SET year=\$1, \n semester_order=\$2, \n tuition_start=" . DateConvert::SKtoDB("\$3") . ",\n tuition_end=" . DateConvert::SKtoDB("\$4") . ",\n exam_start=" . DateConvert::SKtoDB("\$5") . ", \n exam_reparat_start=" . DateConvert::SKtoDB("\$6") . ", \n exam_end=" . DateConvert::SKtoDB("\$7") . "\n WHERE id=\$8"; $this->dbh->query($sql, array($this->rok, $this->semester, $this->zac_uc, $this->kon_uc, $this->zac_skus, $this->zac_opr, $this->kon_skus, $this->id)); } }
public function save() { if (empty($this->id)) { $sql = "INSERT INTO semester(rok, semester, zac_uc, kon_uc, zac_skus, zac_opr, kon_skus)\n\t\t\t VALUES (\$1, \$2, "; $sql .= DateConvert::SKtoDB("\$3") . ","; $sql .= DateConvert::SKtoDB("\$4") . ","; $sql .= DateConvert::SKtoDB("\$5") . ","; $sql .= DateConvert::SKtoDB("\$6") . ","; $sql .= DateConvert::SKtoDB("\$7") . ")"; $this->dbh->query($sql, array($this->rok, $this->semester, $this->zac_uc, $this->kon_uc, $this->zac_skus, $this->zac_opr, $this->kon_skus)); } else { $sql = "UPDATE semester\n SET rok=\$1, \n semester=\$2, \n zac_uc=" . DateConvert::SKtoDB("\$3") . ",\n kon_uc=" . DateConvert::SKtoDB("\$4") . ",\n zac_skus=" . DateConvert::SKtoDB("\$5") . ", \n zac_opr=" . DateConvert::SKtoDB("\$6") . ", \n kon_skus=" . DateConvert::SKtoDB("\$7") . "\n WHERE id=\$8"; $this->dbh->query($sql, array($this->rok, $this->semester, $this->zac_uc, $this->kon_uc, $this->zac_skus, $this->zac_opr, $this->kon_skus, $this->id)); } }
public function loadComments($metaPoziadavkaID) { $sql = "SELECT text, zadal, " . DateConvert::DBTimestampToSkDateTime("cas_zadania") . " AS cas_zadania, typ FROM komentar WHERE id_meta_poziadavka=\$1 ORDER BY cas_zadania desc"; $this->dbh->query($sql, array($metaPoziadavkaID)); $comments = $this->dbh->fetchall_assoc(); $komentare = array(); foreach ($comments as $comment) { if ($comment["typ"] == 1) { $komentare["vseobecne"] = $comment["text"]; } elseif ($comment["typ"] == 2) { $komentare["sw"] = $comment["text"]; } elseif ($comment["typ"] == 3) { $komentare["other"][] = $comment; } } return $komentare; }
/** * Zisti ci existuje casova kolizia s existujucou poziadavkou * @return null ak neexistuje, inac string so zaciatkom a koncom koliznej akcie */ public function existujeKolizna() { // hlada nasledovne kolizne pripady: // - existuje zaciatok nejakeho obdobia v nasom // - existuje koniec nejakeho obdobia v nasom // - nejake obdobie kompletne prekryva nase obbodie // pricom vzdy sa ignoruje nase obdobie (kvoli update ktory by bol kolizny so sebou) // a zaroven nie su kolizie ak bezi vaicero akcii na viacero inych semestrov $sql = "SELECT id, " . DateConvert::DBTimestampToSkDateTime("zaciatok") . " AS zaciatok, " . DateConvert::DBTimestampToSkDateTime("koniec") . " AS koniec\n\t\t\tFROM rozvrhova_akcia\n\t\t\t WHERE \n\t\t\t \t((zaciatok>" . DateConvert::SKDateTime2DBTimestamp("\$1") . " AND\n\t\t\t \t zaciatok<" . DateConvert::SKDateTime2DBTimestamp("\$2") . ") OR\t\n\t\t\t \t(koniec>" . DateConvert::SKDateTime2DBTimestamp("\$1") . " AND\n\t\t\t \t koniec<" . DateConvert::SKDateTime2DBTimestamp("\$2") . ") OR\n\t\t\t \t(zaciatok<=" . DateConvert::SKDateTime2DBTimestamp("\$1") . " AND\n\t\t\t \t koniec>=" . DateConvert::SKDateTime2DBTimestamp("\$2") . ")) AND\n\t\t\t \t id_semester=\$3"; $params = array($this->zaciatok, $this->koniec, $this->id_semester); // ak je edit TREBA aj vylucit koliziu so sebou if (!empty($this->id)) { $sql .= " AND id<>\$4"; $params[] = $this->id; } $this->dbh->query($sql, $params); if ($this->dbh->RowCount() > 0) { $kolizia = $this->dbh->fetch_assoc(); return "{$kolizia["zaciatok"]} - {$kolizia["koniec"]}"; } else { return null; } }
public function getAllRequests($predmetID, $typPoziadavky) { $query = "SELECT mp.id, mp.id_predmet, " . DateConvert::DBTimestampToSkDateTime("mp.cas_pridania") . " AS cas_pridania, " . Users::vyskladajMeno("p", "pedagog", false) . "FROM meta_poziadavka mp\n \t JOIN pedagog p ON p.id=mp.id_osoba\n \t WHERE mp.id_predmet=\$1 AND mp.id_poziadavka_typ=\$2\n \t ORDER BY mp.cas_pridania DESC"; $this->dbh->query($query, array($predmetID, $typPoziadavky)); return $this->dbh->fetchall_assoc(); }
public function getAllRequests($predmetID, $typPoziadavky) { $query = "SELECT request.id,\n event.id_course," . DateConvert::DBTimestampToSkDateTime("request.timestamp") . " AS cas_pridania, " . Users::vyskladajMeno("person", "pedagog", false) . "FROM request JOIN event ON request.id_event = event.id\n JOIN person ON request.id_person = person.id\n WHERE event.id_course = \$1 AND event.event_type = \$2\n ORDER BY request.timestamp DESC"; $this->dbh->query($query, array($predmetID, $typPoziadavky)); return $this->dbh->fetchall_assoc(); }