Add files via upload

This commit is contained in:
Fernando Méndez 2021-04-30 22:23:26 +02:00 committed by GitHub
parent 779f11d8d0
commit d5dbb1ddcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 864 additions and 35 deletions

View File

@ -192,15 +192,15 @@ table a{
/* Main */ /* Main */
.main { main {
padding: 30px; padding: 30px;
text-align: center; text-align: center;
font-size: 35px; font-size: 35px;
} }
.main h1, h2, h3, h4 { main h1, h2, h3, h4 {
color: #363636; color: #363636;
} }
.main img { main img {
width: 50%; width: 50%;
} }

371
assets/mysql/complucine.sql Normal file
View File

@ -0,0 +1,371 @@
-- phpMyAdmin SQL Dump
-- version 4.6.6deb5
-- https://www.phpmyadmin.net/
--
-- Servidor: localhost:3306
-- Tiempo de generación: 30-04-2021 a las 21:59:24
-- Versión del servidor: 10.0.28-MariaDB-2+b1
-- Versión de PHP: 7.3.27-1~deb10u1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de datos: `complucine`
--
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `admin`
--
CREATE TABLE `admin` (
`id` int(15) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `cinema`
--
CREATE TABLE `cinema` (
`id` int(15) UNSIGNED NOT NULL,
`name` varchar(10) NOT NULL,
`direction` varchar(120) NOT NULL,
`phone` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcado de datos para la tabla `cinema`
--
INSERT INTO `cinema` (`id`, `name`, `direction`, `phone`) VALUES
(1, 'Cinema 1st', 'no tiene direccion', '666666666');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `film`
--
CREATE TABLE `film` (
`id` int(15) UNSIGNED NOT NULL,
`tittle` varchar(60) NOT NULL,
`duration` int(3) UNSIGNED NOT NULL,
`language` varchar(30) NOT NULL,
`description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcado de datos para la tabla `film`
--
INSERT INTO `film` (`id`, `tittle`, `duration`, `language`, `description`) VALUES
(1, 'iron_man', 120, 'spanish', 'Un empresario millonario construye un traje blindado y lo usa para combatir el crimen y el terrorismo.'),
(2, 'iron_man_2', 120, 'spanish', 'Con el mundo ahora consciente de que él es Iron Man, el millonario inventor Tony Stark debe forjar nuevas alianzas y confrontar a un enemigo nuevo y poderoso.'),
(3, 'iron_man_3', 120, 'spanish', 'El descarado y brillante Tony Stark, tras ver destruido todo su universo personal, debe encontrar y enfrentarse a un enemigo cuyo poder no conoce límites. Este viaje pondrá a prueba su entereza una y otra vez, y le obligará a confiar en su ingenio.'),
(4, 'capitan_america_el_primer_vengador', 120, 'spanish', 'Tras tres meses de someterse a un programa de entrenamiento físico y táctico, encomiendan a Steve Rogers su primera misión como Capitán América. Armado con un escudo indestructible, emprende la guerra contra la perversa organización HYDRA.'),
(5, 'capitan_america_el_soldado_de_invierno', 120, 'spanish', 'Capitán América, Viuda Negra y un nuevo aliado, Falcon, se enfrentan a un enemigo inesperado mientras intentan exponer una conspiración que pone en riesgo al mundo.'),
(6, 'capitan_america_civil_war', 180, 'spanish', 'Después de que otro incidente internacional, en el que se ven envueltos los Vengadores, produzca daños colaterales, la presión política obliga a poner en marcha un sistema para depurar responsabilidades.'),
(7, 'marvel_avengers', 120, 'spanish', 'El director de la Agencia SHIELD decide reclutar a un equipo para salvar al mundo de un desastre casi seguro cuando un enemigo inesperado surge como una gran amenaza para la seguridad mundial.'),
(8, 'avengers_age_of_ultron', 120, 'spanish', 'Los Vengadores se reúnen de nuevo y juntan sus fuerzas con las de los recién llegados Quicksilver y Bruja Escarlata para luchar contra un robot maquiavélico llamado Ultrón, el cual Tony Stark creó con el fin de defender la paz, pero resultó defectuoso y ahora pretende exterminar a toda la humanidad.'),
(9, 'avengers_inifinity_war', 180, 'spanish', 'Los superhéroes se alían para vencer al poderoso Thanos, el peor enemigo al que se han enfrentado. Si Thanos logra reunir las seis gemas del infinito: poder, tiempo, alma, realidad, mente y espacio, nadie podrá detenerlo.'),
(10, 'avengers_end_game', 180, 'spanish', 'Los Vengadores restantes deben encontrar una manera de recuperar a sus aliados para un enfrentamiento épico con Thanos, el malvado que diezmó el planeta y el universo.');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `hall`
--
CREATE TABLE `hall` (
`number` int(15) UNSIGNED NOT NULL,
`idcinema` int(15) UNSIGNED NOT NULL,
`numrows` int(3) NOT NULL,
`numcolumns` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcado de datos para la tabla `hall`
--
INSERT INTO `hall` (`number`, `idcinema`, `numrows`, `numcolumns`) VALUES
(1, 1, 20, 20),
(2, 1, 20, 20),
(3, 1, 20, 20);
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `manager`
--
CREATE TABLE `manager` (
`id` int(15) UNSIGNED NOT NULL,
`idcinema` int(15) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `promotion`
--
CREATE TABLE `promotion` (
`id` int(15) UNSIGNED NOT NULL,
`tittle` varchar(30) NOT NULL,
`description` text NOT NULL,
`code` varchar(15) NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `purchase`
--
CREATE TABLE `purchase` (
`iduser` int(15) UNSIGNED NOT NULL,
`idsession` int(15) UNSIGNED NOT NULL,
`idhall` int(15) UNSIGNED NOT NULL,
`idcinema` int(15) UNSIGNED NOT NULL,
`numrow` int(3) UNSIGNED NOT NULL,
`numcolum` int(3) UNSIGNED NOT NULL,
`time_purchase` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `seat`
--
CREATE TABLE `seat` (
`idhall` int(15) UNSIGNED NOT NULL,
`idcinema` int(15) UNSIGNED NOT NULL,
`numrow` int(3) UNSIGNED NOT NULL,
`numcolum` int(3) UNSIGNED NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `session`
--
CREATE TABLE `session` (
`id` int(15) UNSIGNED NOT NULL,
`idfilm` int(15) UNSIGNED NOT NULL,
`idhall` int(15) UNSIGNED NOT NULL,
`idcinema` int(15) UNSIGNED NOT NULL,
`date` date NOT NULL,
`start_time` time NOT NULL,
`seat_price` float NOT NULL,
`format` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Volcado de datos para la tabla `session`
--
INSERT INTO `session` (`id`, `idfilm`, `idhall`, `idcinema`, `date`, `start_time`, `seat_price`, `format`) VALUES
(3, 4, 2, 1, '2021-04-16', '14:20:00', 5, 'Estandar'),
(4, 4, 2, 1, '2021-04-17', '14:20:00', 5, 'Estandar'),
(5, 4, 2, 1, '2021-04-18', '14:20:00', 5, 'Estandar'),
(6, 9, 2, 1, '2021-04-15', '18:00:00', 7, '3D'),
(7, 9, 1, 1, '2021-04-16', '18:00:00', 7, '3D'),
(8, 9, 1, 1, '2021-04-17', '18:00:00', 7, '3D'),
(9, 9, 1, 1, '2021-04-18', '18:00:00', 7, '3D'),
(10, 9, 1, 1, '2021-04-19', '18:00:00', 7, '3D'),
(11, 9, 1, 1, '2021-04-20', '18:00:00', 7, '3D'),
(12, 9, 1, 1, '2021-04-21', '18:00:00', 7, '3D'),
(13, 9, 1, 1, '2021-04-22', '18:00:00', 7, '3D'),
(14, 10, 1, 1, '2021-04-15', '18:00:00', 10, 'normal'),
(15, 1, 1, 1, '2021-04-30', '14:00:00', 5, '3d');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `users`
--
CREATE TABLE `users` (
`id` int(15) UNSIGNED NOT NULL,
`username` varchar(10) NOT NULL,
`email` varchar(30) NOT NULL,
`passwd` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`rol` varchar(7) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Usuarios';
--
-- Volcado de datos para la tabla `users`
--
INSERT INTO `users` (`id`, `username`, `email`, `passwd`, `rol`) VALUES
(0, 'admin', 'admin@complucine.sytes.net', 'shDBCKnEbWZFc', 'admin'),
(1, 'manager', 'manager@complucine.sytes.net', 'shTS9RK/eJPoQ', 'manager'),
(2, 'user', 'user@complucine.sytes.net', 'shO5etd.DYKWg', 'user'),
(7, 'fernando', 'fer@complucine.sytes.net', '$2y$10$k/R4m.uN1IfZ0rdc5wwc2uaO9b0e5qK9WtOBloxlfkUuBjWPMC3PG', 'user');
--
-- Índices para tablas volcadas
--
--
-- Indices de la tabla `admin`
--
ALTER TABLE `admin`
ADD KEY `PK_A_USER` (`id`);
--
-- Indices de la tabla `cinema`
--
ALTER TABLE `cinema`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `film`
--
ALTER TABLE `film`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `U_TITTLE_LANGUAGE` (`tittle`,`language`);
--
-- Indices de la tabla `hall`
--
ALTER TABLE `hall`
ADD PRIMARY KEY (`number`,`idcinema`),
ADD KEY `FK_CINEMA` (`idcinema`);
--
-- Indices de la tabla `manager`
--
ALTER TABLE `manager`
ADD KEY `PK_M_USER` (`id`),
ADD KEY `PK_M_CINEMA` (`idcinema`);
--
-- Indices de la tabla `promotion`
--
ALTER TABLE `promotion`
ADD PRIMARY KEY (`id`);
--
-- Indices de la tabla `purchase`
--
ALTER TABLE `purchase`
ADD KEY `PK_P_SEAT` (`idhall`,`numrow`,`numcolum`),
ADD KEY `FK_P_SESSION` (`idsession`),
ADD KEY `FK_P_USER` (`iduser`),
ADD KEY `FK_P_SEAT` (`idhall`,`idcinema`,`numrow`,`numcolum`);
--
-- Indices de la tabla `seat`
--
ALTER TABLE `seat`
ADD PRIMARY KEY (`idhall`,`numrow`,`numcolum`),
ADD KEY `FK_HALL` (`idhall`,`idcinema`);
--
-- Indices de la tabla `session`
--
ALTER TABLE `session`
ADD PRIMARY KEY (`id`),
ADD KEY `FK_FILM` (`idfilm`),
ADD KEY `FK_HALL_` (`idhall`,`idcinema`);
--
-- Indices de la tabla `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`),
ADD UNIQUE KEY `username_2` (`username`),
ADD KEY `username` (`username`);
--
-- AUTO_INCREMENT de las tablas volcadas
--
--
-- AUTO_INCREMENT de la tabla `cinema`
--
ALTER TABLE `cinema`
MODIFY `id` int(15) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT de la tabla `film`
--
ALTER TABLE `film`
MODIFY `id` int(15) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT de la tabla `hall`
--
ALTER TABLE `hall`
MODIFY `number` int(15) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT de la tabla `session`
--
ALTER TABLE `session`
MODIFY `id` int(15) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
--
-- AUTO_INCREMENT de la tabla `users`
--
ALTER TABLE `users`
MODIFY `id` int(15) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- Restricciones para tablas volcadas
--
--
-- Filtros para la tabla `admin`
--
ALTER TABLE `admin`
ADD CONSTRAINT `PK_A_USER` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Filtros para la tabla `hall`
--
ALTER TABLE `hall`
ADD CONSTRAINT `FK_CINEMA` FOREIGN KEY (`idcinema`) REFERENCES `cinema` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Filtros para la tabla `manager`
--
ALTER TABLE `manager`
ADD CONSTRAINT `PK_M_CINEMA` FOREIGN KEY (`idcinema`) REFERENCES `cinema` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `PK_M_USER` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Filtros para la tabla `purchase`
--
ALTER TABLE `purchase`
ADD CONSTRAINT `FK_P_SEAT` FOREIGN KEY (`idhall`,`idcinema`,`numrow`,`numcolum`) REFERENCES `seat` (`idhall`, `idcinema`, `numrow`, `numcolum`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_P_SESSION` FOREIGN KEY (`idsession`) REFERENCES `session` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_P_USER` FOREIGN KEY (`iduser`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Filtros para la tabla `seat`
--
ALTER TABLE `seat`
ADD CONSTRAINT `FK_HALL` FOREIGN KEY (`idhall`,`idcinema`) REFERENCES `hall` (`number`, `idcinema`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Filtros para la tabla `session`
--
ALTER TABLE `session`
ADD CONSTRAINT `FK_FILM` FOREIGN KEY (`idfilm`) REFERENCES `film` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `FK_HALL_` FOREIGN KEY (`idhall`,`idcinema`) REFERENCES `hall` (`number`, `idcinema`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View File

@ -149,12 +149,12 @@
} }
/* MAIN */ /* MAIN */
echo"<div class='main'> echo"<main>
<div class='image'><a href='{$prefix}'><img src='{$prefix}img/logo_trasparente.png' alt='logo_FDI-Cines' /></a></div> <div class='image'><a href='{$prefix}'><img src='{$prefix}img/logo_trasparente.png' alt='logo_FDI-Cines' /></a></div>
{$sub_header} {$sub_header}
<h1>{$page}</h1> <h1>{$page}</h1>
<hr /> <hr />
</div>\n"; </main>\n";
} }
//Print panel menu: //Print panel menu:

View File

@ -19,13 +19,9 @@
?> ?>
<!-- Main --> <!-- Main -->
<div class="main">
<div class="image"><a href='../../'><img src="../../img/logo_trasparente.png" alt="logo_FDI-Cines" /></a></div>
<!-- Sub Header -->
<?php <?php
$template->print_subheader(); $template->print_main();
?> ?>
</div>
<!-- Description --> <!-- Description -->
<section id="description"> <section id="description">

View File

@ -19,13 +19,9 @@
?> ?>
<!-- Main --> <!-- Main -->
<div class="main">
<div class="image"><a href='../../'><img src="../../img/logo_trasparente.png" alt="logo_FDI-Cines" /></a></div>
<!-- Sub Header -->
<?php <?php
$template->print_subheader(); $template->print_main();
?> ?>
</div>
<!-- Details --> <!-- Details -->
<section id="details"> <section id="details">

View File

@ -19,7 +19,7 @@
?> ?>
<!-- Main --> <!-- Main -->
<div class="main"> <main>
<div class="image"><img src="../../img/logo_trasparente.png" /></div> <div class="image"><img src="../../img/logo_trasparente.png" /></div>
<!-- Sub Header --> <!-- Sub Header -->
<?php <?php
@ -63,7 +63,7 @@
</tbody> </tbody>
</table> </table>
</section> </section>
</div> </main>
<!-- Members --> <!-- Members -->
<section id="members"> <section id="members">

View File

@ -28,7 +28,7 @@
?> ?>
<!-- Main --> <!-- Main -->
<div class="main"> <main>
<div class="image"><a href='./'><img src="./img/logo_trasparente.png" alt="logo_FDI-Cines" /></a></div> <div class="image"><a href='./'><img src="./img/logo_trasparente.png" alt="logo_FDI-Cines" /></a></div>
<?php <?php
if(isset($_SESSION["nombre"])){ if(isset($_SESSION["nombre"])){
@ -39,7 +39,7 @@
} }
?> ?>
<hr /> <hr />
</div> </main>
<!-- Undercard --> <!-- Undercard -->
<section id="cartelera"> <section id="cartelera">

View File

@ -1,5 +1,14 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<?php <?php
/**
* USUARIOS DE PRUEBAS:
* user | userpass
* fernando | ferpass
* manager | managerpass
* admin | adminpass
*/
//General Config File: //General Config File:
require_once('../assets/php/config.php'); require_once('../assets/php/config.php');
@ -26,11 +35,9 @@
?> ?>
<!-- Main --> <!-- Main -->
<div class="main"> <?php
<div class="image"><img src="../img/logo_trasparente.png" /></div> $template->print_main();
<h1>Acceso</h1> ?>
<hr />
</div>
<!-- Login / Register --> <!-- Login / Register -->
<section id="login_register"> <section id="login_register">

View File

@ -26,9 +26,9 @@
?> ?>
<!-- Main --> <!-- Main -->
<div class="main"> <?php
<div class="image"><img src="../img/logo_trasparente.png" /></div> $template->print_main();
</div> ?>
<!-- Reply --> <!-- Reply -->
<section class="reply"> <section class="reply">

View File

@ -38,9 +38,9 @@
?> ?>
<!-- Main --> <!-- Main -->
<div class="main"> <?php
<div class="image"><img src="../img/logo_trasparente.png" /></div> $template->print_main();
</div> ?>
<!-- Reply --> <!-- Reply -->
<section class="reply"> <section class="reply">

View File

@ -0,0 +1,103 @@
<?php
include_once('film_dto.php');
$template = new Template();
$prefix = $template->get_prefix();
include_once($prefix.'assets/php/dao.php');
class Film_DAO extends DAO {
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
//Create a new Session.
public function createFilm($id, $tittle, $duration, $language,$description){
$sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`)
VALUES ( '%d', '%s', '%d', '%s','%s')",
$id, $tittle, $duration, $language,$description);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Returns a film data .
public function GetFilm($tittle,$language){
$sql = sprintf( "SELECT * FROM film WHERE film.tittle = '%s'AND film.language='%s'", $tittle,$language );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Returns a query to get the film's data.
public function FilmData($id){
$sql = sprintf( "SELECT * FROM film WHERE id = '%d'", $id );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Returns a query to get All the films.
public function allFilmData(){
$sql = sprintf( "SELECT * FROM film ");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
while($fila=$resul->fetch_assoc()){
$films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]);
}
$resul->free();
return $films;
}
//Returns a query to get all films tittles.
public function tittleFilmData(){
$sql = sprintf( "SELECT DISTINCT tittle FROM film ");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Returns a query to get all films descriptions.
public function descriptionFilmData(){
$sql = sprintf( "SELECT description FROM film ");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
/*
public function addFilm($films) {
$resul = mysqli_query($this->mysqli, $this->createFilm($film.getId(), $film.getTittle(), $film.getDuration(), $film.getLanguage(), $film.getDescription())) or die ('Error into query database');
return $resul;
}
*/
//Deleted film by "id".
public function deleteFilm($id){
$sql = sprintf( "DELETE FROM film WHERE film.id = '%d' ;",$id);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Edit a film.
public function editFilm($id, $tittle, $duration, $language,$description){
$sql = sprintf( "UPDATE film SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s'
WHERE film.id = '%d';",
$tittle, $duration, $language, $description, $id);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Create a new film Data Transfer Object.
public function loadFilm($id, $tittle, $duration, $language,$description){
return new Film_DTO( $id, $tittle, $duration, $language,$description);
}
}
?>

View File

@ -0,0 +1,37 @@
<?php
include_once('film_dto_interface.php');
class Film_DTO implements FilmDTO {
//Attributes:
private $_id; //Film ID.
private $_tittle; //Film tittle.
private $_duration; //Film duration.
private $_language; //Film language.
private $_description; //Film description.
//Constructor:
function __construct($id, $tittle, $duration, $language, $description){
$this->_id = $id;
$this->_tittle = $tittle;
$this->_duration = $duration;
$this->_language = $language;
$this->_description = $description;
}
//Methods:
//Getters && Setters:
public function setId($id){ $this->_id = $id; }
public function getId(){ return $this->_id; }
public function setTittle($tittle) {$this->_tittle = $tittle; }
public function getTittle(){return $this->_tittle;}
public function setDuration($duration){$this->_duration = $duration; }
public function getDuration() {return $this->_duration;}
public function setLanguage($language) {$this->_language = $language; }
public function getLanguage(){return $this->_language;}
public function setDescription($description){ $this->_description = $description;}
public function getDescription(){return $this->_description;}
}
?>

View File

@ -0,0 +1,14 @@
<?php
interface FilmDTO {
public function setId($id);
public function getId();
public function setTittle($tittle);
public function getTittle();
public function setDuration($duration);
public function getDuration();
public function setLanguage($language);
public function getLanguage();
public function setDescription($description);
public function getDescription();
}
?>

View File

@ -0,0 +1,73 @@
<?php
require_once('../assets/php/dao.php');
include_once('hall_dto.php');
class HallDAO extends DAO {
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
//Create a new Hall.
public function createHall($number, $idcinema, $numCol, $numRows){
$sql = sprintf( "INSERT INTO `hall`( `number`, `idcinema`, `numrows`, `numcolumns`)
VALUES ( '%d', '%d', '%i', '%i')",
$number, $idcinema, $numRows, $numCol );
return $sql;
}
//Returns a query to get the halls data.
public function getAllHalls($cinema){
$sql = sprintf( "SELECT * FROM hall WHERE
idcinema = '%s'",
$cinema);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
$hall = null;
while($fila=mysqli_fetch_array($resul)){
$hall[] = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"]);
}
mysqli_free_result($resul);
return $hall;
}
//Create a new Hall Data Transfer Object.
public function loadHall($number, $idcinema, $numrows, $numcolumns){
return new HallDTO($number, $idcinema, $numrows, $numcolumns);
}
//Edit Hall.
public function editHall($id, $idcinema, $numCol, $numRows){
$sql = sprintf( "UPDATE `hall`
SET `numrows` = '%i' , `numcolumns` = '%i'
WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",
$numRows,$numCol,$id, $idcinema );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Delete Hall.
public function deleteHall($id, $idcinema){
$sql = sprintf( "DELETE FROM `hall` WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",$id,$idcinema);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
}
?>

View File

@ -0,0 +1,38 @@
<?php
include_once('hall_dto_interface.php');
class HallDTO implements HallsDTO {
//Attributes:
private $_number; //Room number.
private $_idcinema; //Cinema Id
private $_numRows; //Num rows.
private $_numCol; //Num columns.
//Constructor:
function __construct($number, $idcinema, $numRows, $numCol){
$this->_number = $number;
$this->_idcinema = $idcinema;
$this->_numRows = $numRows;
$this->_numCol = $numCol;
}
//Methods:
//Getters && Setters:
public function setNumber($number){ $this->_number = $number; }
public function getNumber(){ return $this->_number; }
public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; }
public function getIdcinema(){ return $this->_idcinema; }
public function setNumRows($numRows){ $this->_numRows = $numRows; }
public function getNumRows(){ return $this->_numRows; }
public function setNumCol($numCol){ $this->_numCol = $numCol; }
public function getNumCol(){ return $this->_numCol; }
}
?>

View File

@ -0,0 +1,12 @@
<?php
interface HallsDTO {
public function setNumber($number);
public function getNumber();
public function setIdcinema($idcinema);
public function getIdcinema();
public function setNumCol($numCol);
public function getNumCol();
public function setNumRows($numRows);
public function getNumRows();
}
?>

View File

@ -0,0 +1,106 @@
<?php
require_once('../assets/php/dao.php');
include_once('session_dto.php');
class SessionDAO extends DAO {
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
public function createSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
$format = $this->mysqli->real_escape_string($format);
$date = date('Y-m-d', strtotime( $date ) );
$startTime = date('H:i:s', strtotime( $startTime ) );
$sql = sprintf( "INSERT INTO `session` (`id`, `idfilm`, `idhall`, `idcinema`, `date`, `start_time`, `seat_price`, `format`)
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s')",
$id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $sql;
}
//Returns a query to get the session's data.
public function sessionData($id){
$sql = sprintf( "SELECT * FROM `session` WHERE id = '%d'", $id );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en sessionData con la id '. $id);
return $resul;
}
//Returns the count of the session searched
public function searchSession($cinema, $hall, $startTime, $date){
$date = date('Y-m-d', strtotime( $date ) );
$startTime = date('H:i:s', strtotime( $startTime ) );
$sql = sprintf( "SELECT COUNT(*) FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$cinema, $hall, $date, $startTime);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
$session = null;
$session = mysqli_fetch_array($resul);
mysqli_free_result($resul);
return $session[0];
}
//Returns a query to get all the session's data.
public function getAllSessionsFromACinemaHallDate($cinema, $hall, $date){
$date = date('Y-m-d', strtotime( $date ) );
$sql = sprintf( "SELECT * FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s'",
$cinema, $hall, $date);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
$sessions = null;
while($fila=mysqli_fetch_array($resul)){
$sessions[] = $this->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"]);
}
mysqli_free_result($resul);
return $sessions;
}
public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
$format = $this->mysqli->real_escape_string($format);
$date = date('Y-m-d', strtotime( $date ) );
$startTime = date('H:i:s', strtotime( $startTime ) );
$sql = sprintf( "UPDATE `session`
SET `idfilm` = '%d' , `idhall` = '%d', `idcinema` = '%d', `date` = '%s',
`start_time` = '%s', `seat_price` = '%d', `format` = '%s'
WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $_SESSION["cinema"],$_SESSION["hall"],$_SESSION["date"],$_SESSION["start"]);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
public function deleteSession($hall, $cinema, $date, $startTime){
$sql = sprintf( "DELETE FROM `session` WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$cinema, $hall, $date, $startTime);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Create a new Session Data Transfer Object.
public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
return new SessionDTO( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
}
}
?>

View File

@ -0,0 +1,56 @@
<?php
include_once('session_dto_interface.php');
class SessionDTO implements SessionsDTO {
//Attributes:
private $_id;
private $_idfilm;
private $_idhall;
private $_idcinema;
private $_date;
private $_startTime;
private $_seatPrice;
private $_format;
//Constructor:
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
$this->_id = $id;
$this->_idfilm = $idfilm;
$this->_idhall = $idhall;
$this->_idcinema = $idcinema;
$this->_date = $date;
$this->_startTime = $startTime;
$this->_seatPrice = $seatPrice;
$this->_format = $format;
}
//Methods:
//Getters && Setters:
public function setId($id){ $this->_id = $id; }
public function getId(){ return $this->_id; }
public function setIdfilm($idfilm){ $this->_idfilm = $idfilm; }
public function getIdfilm(){ return $this->_idfilm; }
public function setIdhall($idhall){ $this->_idhall = $idhall; }
public function getIdhall(){ return $this->_idhall; }
public function setIdcinema($cinema){ $this->_idcinema = $idcinema; }
public function getIdcinema(){ return $this->_idcinema; }
public function setDate($date){ $this->_date = $date; }
public function getDate(){ return $this->_date; }
public function setStartTime($startTime){ $this->_startTime = $startTime; }
public function getStartTime(){ return $this->_startTime; }
public function setSeatPrice($seatPrice){ $this->_seatPrice = $seatPrice; }
public function getSeatPrice(){ return $this->_seatPrice; }
public function setFormat($format){ $this->_format = $format; }
public function getFormat(){ return $this->_format; }
}
?>

View File

@ -0,0 +1,20 @@
<?php
interface SessionsDTO {
public function setId($id);
public function getId();
public function setIdfilm($idfilm);
public function getIdfilm();
public function setIdhall($film);
public function getIdhall();
public function setIdcinema($cinema);
public function getIdcinema();
public function setDate($date);
public function getDate();
public function setStartTime($startTime);
public function getStartTime();
public function setSeatPrice($seatPrice);
public function getSeatPrice();
public function setFormat($format);
public function getFormat();
}
?>