/** * * @param \PDO $pdo * @param String $code * @return \model\database\views\GameBoxExtended */ public static function retire($pdo, $code) { $box = \model\database\views\GameBoxExtended::fetchByCode($pdo, $code); if (!$box) { return null; } $statement = $pdo->prepare("UPDATE `web_logickehry_db`.`game_box` SET " . "`retired` = 1 " . "WHERE `game_box`.`tracking_code` = :tracking_code"); if (!$statement->execute(['tracking_code' => $code])) { DB_Service::logError($statement->errorInfo(), __CLASS__ . "::" . __FUNCTION__, $statement->queryString); return null; } return $box; }
/** * * @param \PDO $pdo * @param int $game_type_id * @param Date $date * @param Time $time_from * @param Time $time_to * @return GameBoxExtended[] */ public static function getAvailableGameBox($pdo, $game_type_id, $date, $time_from, $time_to) { $boxes = GameBoxExtended::fetchAllByGameType($pdo, $game_type_id); $statement = $pdo->prepare('SELECT game_box_id FROM reservation_extended ' . 'WHERE game_type_id = :game_type_id AND ' . 'reservation_date = :date AND ( ' . ' ( time_from <= :time_from1 AND :time_from2 <= time_to ) OR' . ' ( time_from <= :time_to1 AND :time_to2 <= time_to )' . ')'); $pars = ['game_type_id' => $game_type_id, 'date' => $date, 'time_from1' => $time_from, 'time_from2' => $time_from, 'time_to1' => $time_to, 'time_to2' => $time_to]; if (!$statement->execute($pars)) { DB_Service::logError($statement->errorInfo(), __CLASS__ . "::" . __FUNCTION__, $statement->queryString, $pars); return false; } $boxesInUse = $statement->fetchAll(\PDO::FETCH_COLUMN); foreach ($boxesInUse as $boi) { unset($boxes[$boi]); } return $boxes; }
private function checkBoxBeforeInsert($code, $game_id) { if (!$this->user->isSupervisor()) { return "Nedostatečná uživatelská oprávnění"; } if (strlen($code) < Tables\GameBox::MIN_CODE_LENGTH) { return sprintf("Evidenční kód musí být alespoň %d znaků dlouhý.", Tables\GameBox::MIN_CODE_LENGTH); } $gameBox = Views\GameBoxExtended::fetchByCode($this->pdo, $code); if ($gameBox) { $response = "Kód {$code} je v databázi již veden, "; $response .= $gameBox->retired ? "je však vyřazený z oběhu" : "náleží hře " . $gameBox->game_name; return $response; } $gameType = $this->gameTypes->fetchById($game_id); if (!$gameType) { return $this->template['response'] = sprintf("Nebyla nalezena hra %03d", $game_id); } return false; }
public function renderInventory() { $this->template["game_type"] = Views\GameTypeExtended::fetchAll($this->pdo); $this->template["game_box"] = Views\GameBoxExtended::fetchAll($this->pdo, false); }
public function renderInventar() { $retired = $this->getParam("retired"); $this->addCss("hra.css"); $this->template['pageTitle'] = "Správa evidovaných herních krabic"; $this->template['col_game'] = 4; $this->template['col_code'] = 12; $boxes = Views\GameBoxExtended::fetchAll($this->pdo); $games = Views\GameTypeExtended::fetchAll($this->pdo); $gamesSrt = []; foreach ($games as $g) { $g->tracking_codes = []; $gamesSrt[$g->game_type_id] = $g; } foreach ($boxes as $b) { if ($b->tracking_code && (!$b->retired || $retired)) { $game = $gamesSrt[$b->game_type_id]; $game->addTrackingCode($b); } } $this->template['retireAction'] = 'retireBox'; $this->template['insertAction'] = 'insertBox'; $this->template['games'] = $gamesSrt; }