Пример #1
0
 /**
  * Vrati vsechny masaze dane kategorie
  * @param $categoryId - id kategorie
  * @return mixed
  */
 public static function getMassagesByCategory($categoryId)
 {
     $pdo = Db_Data::getPDO();
     $sql = "SELECT * FROM masaze WHERE id_kategorie = :id order by razeni";
     $q = $pdo->prepare($sql);
     $q->execute(array(":id" => $categoryId));
     return $q->fetchall();
 }
Пример #2
0
 /**
  * Vrati vsechny oleje dane kategorie
  * @param $categoryId - id kategorie
  * @return mixed
  */
 public static function getOilsByCategory($categoryId)
 {
     $pdo = Db_Data::getPDO();
     $sql = "SELECT * FROM oleje WHERE id_kategorie = :id";
     $q = $pdo->prepare($sql);
     $q->execute(array(":id" => $categoryId));
     return $q->fetchall();
 }
Пример #3
0
 public static function getGalerie()
 {
     $pdo = Db_Data::getPDO();
     $sql = "SELECT * FROM fotky WHERE zobrazit = 1 ORDER BY razeni";
     $q = $pdo->prepare($sql);
     $q->execute();
     return $q->fetchAll();
 }
Пример #4
0
 public static function getLast3()
 {
     $pdo = Db_Data::getPDO();
     $sql = "SELECT * FROM aktuality WHERE aktivni= 1 ORDER BY id DESC LIMIT 3";
     $q = $pdo->prepare($sql);
     $q->execute();
     return $q->fetchAll();
     //posledni tri aktivni aktuality
 }
Пример #5
0
 public static function getPDO()
 {
     try {
         if (!isset(self::$db)) {
             self::$db = new PDO("mysql:host=127.0.0.1;dbname=detinsky_db", "root", "", self::$nastaveniDB);
         }
     } catch (PDOException $e) {
         die('Připojení k databázi selhalo: ' . $e->getMessage());
     }
     return self::$db;
 }
Пример #6
0
 /**
  * vrati url k masazi
  */
 public static function returnURL($id)
 {
     $pdo = Db_Data::getPDO();
     $sqlMasaz = "SELECT * FROM masaze WHERE id_masaze = " . $id;
     $q = $pdo->prepare($sqlMasaz);
     $q->execute();
     $masaz = $q->fetchAll();
     $sqlKategorie = "SELECT * FROM kategorie_masazi WHERE id_kategorie = " . $masaz[0]['id_kategorie'];
     $r = $pdo->prepare($sqlKategorie);
     $r->execute();
     $kategorie = $r->fetchAll();
     return MassagesModel::title2pagename($kategorie[0]['nazev']) . '#idMasaze' . $masaz[0]['id_kategorie'];
 }
Пример #7
0
 /**
  * Vraci akce
  * @return array
  */
 public static function getAkce()
 {
     $pdo = Db_Data::getPDO();
     $sql = "SELECT k.id_akce, k.* FROM akce k ";
     $q = $pdo->prepare($sql);
     $q->execute();
     $kategorie = $q->fetchAll();
     foreach ($kategorie as $key => $kat) {
         $kategorie[$key]['nazev'] = $kat['nazev'];
         $kategorie[$key]['popis'] = $kat['popis'];
         $kategorie[$key]['plati'] = $kat['plati'];
     }
     return $kategorie;
 }
Пример #8
0
 /**
  * Vrácí číselné pole obsazených dnů v daném měsíci
  * @param $month - číslo
  * @param $year - rok ve tvaru YYYY
  */
 public static function getBusyDay($month, $year, $typPokoje)
 {
     //pripravim si dotaz do databaze
     if ($month == 12) {
         $nextMonth = "01";
         $yearD1 = $year + 1;
     } else {
         $yearD1 = $year;
         $nextMonth = $month < 9 ? "0" . ($month + 1) : $month + 1;
     }
     $d1 = $yearD1 . "-" . $nextMonth . "-01";
     $d2 = $year . "-" . ($month < 10 ? "0" : "") . $month . "-01";
     $pdo = Db_Data::getPDO();
     //vyberu jen ty zaznamy, ktere se tykaji daneho mesice
     $sql = $typPokoje == 1 ? "SELECT * from rezervace WHERE odDatum <:d1 AND doDatum >= :d2 AND zaloha = 1 AND typPokoje = 1" : "SELECT * from rezervace WHERE odDatum <:d1 AND doDatum >= :d2 AND zaloha = 1 AND typPokoje = 2";
     $q = $pdo->prepare($sql);
     $q->execute(array(":d1" => $d1, ":d2" => $d2));
     $rezervace = $q->fetchAll();
     //rezervace pro dany mesic
     //print_r($rezervace);
     //hraniční datumy daneho měsíce
     $firstDay = date($year . "-" . ($month < 10 ? "0" : "") . $month . "-01");
     $lastDay = date($year . "-" . ($month < 10 ? "0" : "") . $month . "-" . self::getNumberOfDays($month));
     //sestavim pole obsazených dnu
     $busyDays = array();
     foreach ($rezervace as $r) {
         $fromDate = date($r['odDatum']);
         $toDate = date($r['doDatum']);
         $begin = (int) explode('-', $fromDate)[2];
         //zacatek rezervace (cislo dne)
         $end = (int) explode('-', $toDate)[2];
         // konec rezervace
         //1. - uvnitr daneho mesice
         if ($fromDate >= $firstDay && $fromDate <= $lastDay && ($toDate <= $lastDay && $toDate >= $firstDay)) {
             for ($i = $begin; $i <= $end; $i++) {
                 $busyDays[$i] = $i;
             }
         } else {
             //2. - cast mesice ze zacatku (zacatek mimo)
             if ($fromDate < $firstDay && ($toDate >= $firstDay && $toDate <= $lastDay)) {
                 for ($i = 1; $i <= $end; $i++) {
                     $busyDays[$i] = $i;
                 }
             } else {
                 //3. - cast mesice - konec (konec mimo)
                 if ($fromDate >= $firstDay && $fromDate <= $lastDay && $toDate > $lastDay) {
                     for ($i = $begin; $i <= self::getNumberOfDays($month); $i++) {
                         $busyDays[$i] = $i;
                     }
                 } else {
                     //4. cely mesic (zacatek a konec mimo)
                     if ($fromDate < $firstDay && $toDate > $lastDay) {
                         for ($i = 1; $i <= self::getNumberOfDays($month); $i++) {
                             $busyDays[$i] = $i;
                         }
                     }
                 }
             }
         }
     }
     //print_r($busyDays);
     return $busyDays;
 }