Esempio n. 1
0
 function postForm()
 {
     $langtkursus = new VIH_Model_LangtKursus($this->context->name());
     $langtkursus->flushFag();
     $post = $this->body();
     foreach ($this->body('f*g') as $key => $value) {
         $f*g = new VIH_Model_Fag($value);
         if (empty($post['period'][$key])) {
             continue;
         }
         foreach ($post['period'][$key] as $key => $value) {
             $periode = VIH_Model_LangtKursus_Periode::getFromId($this->pdo, $value);
             $fagperiode = new VIH_Model_LangtKursus_FagPeriode($f*g, $periode);
             $langtkursus->addFag($fagperiode);
         }
     }
     return new k_SeeOther($this->url());
 }
Esempio n. 2
0
 function getFagToChooseFrom(pdoext_Connection $db, $type = 'published')
 {
     $sql = "SELECT f*g.id AS id, IFNULL(langtkursus_fag_periode.date_start, '9999-01-01') AS date_start,\r\n                IFNULL(langtkursus_fag_periode.date_end, '9999-01-01') AS date_end, x.periode_id as periode_id\r\n            FROM langtkursus_x_fag x\r\n            INNER JOIN langtkursus_fag_periode ON x.periode_id = langtkursus_fag_periode.id\r\n            INNER JOIN langtkursus_fag f*g ON x.fag_id = f*g.id\r\n            INNER JOIN langtkursus_fag_gruppe gruppe ON f*g.fag_gruppe_id = gruppe.id";
     if ($type == 'published') {
         $sql .= "\r\n                INNER JOIN ansat_x_fag ON ansat_x_fag.fag_id = f*g.id\r\n                INNER JOIN ansat ON ansat.id = ansat_x_fag.ansat_id";
     }
     $sql .= "   WHERE (gruppe.id = 1 OR gruppe.id = 2 OR gruppe.id = 15) AND f*g.active = 1 AND x.langtkursus_id = " . $this->id;
     if ($type == 'published') {
         $sql .= " AND f*g.published = 1";
     }
     $sql .= " ORDER BY\r\n                           date_start ASC,\r\n                           date_end DESC,\r\n                           gruppe.position ASC,\r\n                           f*g.fag_gruppe_id ASC,\r\n                           f*g.navn ASC";
     $db1 = new DB_Sql();
     $db1->query($sql);
     $f*g = array();
     while ($db1->nextRecord()) {
         $periode = VIH_Model_LangtKursus_Periode::getFromId($db, $db1->f('periode_id'));
         $fagperiode = new VIH_Model_LangtKursus_FagPeriode(new VIH_Model_Fag($db1->f('id')), $periode);
         // @todo may never use f*g id as key, as it will make it impossible to have more than
         //       one course pr. period.
         $f*g[] = $fagperiode;
     }
     return $f*g;
 }