Add files via upload
This commit is contained in:
139
panel_manager/edit_sessions.php
Normal file
139
panel_manager/edit_sessions.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
require_once('../assets/php/config.php');
|
||||
|
||||
include_once('./includes/formHall.php');
|
||||
require_once('./includes/hall_dto.php');
|
||||
|
||||
require_once('./includes/session_dto.php');
|
||||
include_once('./includes/session_dao.php');
|
||||
|
||||
require_once('../panel_admin/includes/film_dto.php');
|
||||
include_once('../panel_admin/includes/film_dao.php');
|
||||
|
||||
$formHall = new FormHall();
|
||||
$formHall->processesForm(null, $_SESSION["cinema"], null, null, "list");
|
||||
|
||||
|
||||
|
||||
$filmList = new Film_DAO('complucine');
|
||||
|
||||
if($filmList){
|
||||
$films = $filmList->allFilmData();
|
||||
}else {
|
||||
$films = null;
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['option']) && $_REQUEST['option'] == 'edit') {
|
||||
$_SESSION["hall"] = $_POST['hall'];
|
||||
$_SESSION["date"] = $_POST['date'];
|
||||
$_SESSION["start"] = $_POST['start'];
|
||||
|
||||
echo " <div class = \"column middle\">
|
||||
<h2>Editar/Eliminar Sesion</h2>
|
||||
<form method=\"post\" id=\"edit_ses\" action=\"validateSession.php\">
|
||||
<div class=\"row\">
|
||||
<fieldset id=\"datos\">
|
||||
<legend>Datos</legend>
|
||||
<div class=\"_price\">
|
||||
<input type=\"number\" name=\"price\" id=\"price\" value=\"". $_POST['price'] ."\"min=\"0\" placeholder=\"Precio de la entrada\" required/>
|
||||
</div>
|
||||
<select name=\"hall\" class=\"button large\">";
|
||||
foreach($formHall->getReply() as $r){
|
||||
if($r->getNumber() == $_POST['hall']){
|
||||
echo "<option value=\"". $r->getNumber() ." \"selected> Sala ". $r->getNumber() . "</option>";
|
||||
}else{
|
||||
echo "<option value=\"". $r->getNumber() ." \"> Sala ". $r->getNumber() . "</option>";
|
||||
}
|
||||
}
|
||||
echo "
|
||||
<div class=\"_format\">
|
||||
<input type=\"text\" name=\"format\" id=\"format\" value=\"". $_POST['format'] ."\" placeholder=\"Formato\" required/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id=\"Horario\">
|
||||
<legend>Horario</legend>
|
||||
<div class=\"_start_time\">
|
||||
<input type=\"time\" name=\"start\" id=\"start_time\" value=\"". $_POST['start'] ."\" placeholder=\"Hora de inicio\" required/>
|
||||
</div>
|
||||
<div class=\"_date\">
|
||||
<input type=\"date\" name=\"date\" id=\"date\" value=\"". $_POST['date'] ."\"Fecha de inicio\" required/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class=\"actions\">
|
||||
<input type=\"submit\" name=\"edit\" value=\"Editar\" class=\"button\" />
|
||||
<input type=\"reset\" id=\"reset\" value=\"Limpiar\" />
|
||||
<input type=\"submit\" name=\"del\" value=\"Eliminar\" class=\"button\" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div>
|
||||
<div class=\"column side\">
|
||||
<select name=\"film\" form=\"edit_ses\" class=\"button large\">\n";
|
||||
foreach($films as $f){
|
||||
if($f->getId() == $_POST['idfilm']){
|
||||
echo " <option value=\"". $f->getId() ." \"selected> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>\n";
|
||||
}else{
|
||||
echo " <option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>\n";
|
||||
}
|
||||
}
|
||||
echo " </div>";
|
||||
}
|
||||
|
||||
else{
|
||||
echo " <div class = \"column middle\">
|
||||
<h2>Crear Sesion</h2>
|
||||
<form method=\"post\" id=\"new_ses\" action=\"validateSession.php\">
|
||||
<div class=\"row\">
|
||||
<fieldset id=\"datos\">
|
||||
<legend>Datos</legend>
|
||||
<input type=\"hidden\" name=\"cinema\" value =\"1\" />
|
||||
<div class=\"_price\">
|
||||
<input type=\"number\" name=\"price\" id=\"price\" min=\"0\" placeholder=\"Precio de la entrada\" required/>
|
||||
</div>
|
||||
<select name=\"hall\" class=\"button large\">";
|
||||
foreach($formHall->getReply() as $r){
|
||||
if($r->getNumber() == $_POST['hall']){
|
||||
echo "
|
||||
<option value=\"". $r->getNumber() ." \"selected> Sala ". $r->getNumber() . "</option>";
|
||||
}else{
|
||||
echo "
|
||||
<option value=\"". $r->getNumber() ." \"> Sala ". $r->getNumber() . "</option>";
|
||||
}
|
||||
}
|
||||
echo "
|
||||
<div class=\"_format\">
|
||||
<input type=\"text\" name=\"format\" id=\"format\" value=\"\" placeholder=\"Formato\" required/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id=\"Horario\">
|
||||
<legend>Horario</legend>
|
||||
<div class=\"_start_time\">
|
||||
<input type=\"time\" name=\"start\" id=\"start_time\" value=\"\" placeholder=\"Hora de inicio\" required/>
|
||||
</div>
|
||||
<div class=\"_date\">
|
||||
<input type=\"date\" name=\"date\" id=\"date\" value=\"". $_POST['date'] . "\"Fecha de inicio\" required/>
|
||||
</div>
|
||||
<div class=\"_repeat\">
|
||||
<br> Introducir un numero para añadir esta sesion a los futuros X dias
|
||||
<input type=\"number\" name=\"repeat\" id=\"repeat\" title=\"Repetir esta sesion durante X dias\" min=\"0\" max=\"31\" placeholder=\"Repetir X dias\"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class=\"actions\">
|
||||
<input type=\"submit\" name=\"new\" value=\"Añadir\" class=\"primary\" />
|
||||
<input type=\"reset\" id=\"reset\" value=\"Limpiar\" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div>
|
||||
<div class=\"column side\">
|
||||
<select name=\"film\" form=\"new_ses\" class=\"button large\">\n";
|
||||
foreach($films as $f){
|
||||
echo " <option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>\n";
|
||||
}
|
||||
echo " </div>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
5
panel_manager/hello_panel.php
Normal file
5
panel_manager/hello_panel.php
Normal file
@ -0,0 +1,5 @@
|
||||
<div class="column middle">
|
||||
<h1> Bienvenido al panel de Gerente </h1>
|
||||
<br>
|
||||
<p> Espero que este pasando un buen dia <p>
|
||||
</div>
|
93
panel_manager/includes/formHall.php
Normal file
93
panel_manager/includes/formHall.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
include_once('hall_dao.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class FormHall extends Form {
|
||||
|
||||
//Atributes:
|
||||
private $correct;
|
||||
private $reply;
|
||||
private $option;
|
||||
private $halls;
|
||||
|
||||
//Constructor:
|
||||
public function __construct() {
|
||||
parent::__construct('formSession');
|
||||
$this->reply = array();
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Returns validation response:
|
||||
public function getReply() {
|
||||
|
||||
if($this->correct){
|
||||
if($this->option == "new"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha añadido la sala correctamente en la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}else if($this->option == "edit"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha editado la sala correctamente en la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}else if($this->option == "del"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha eliminado la sala correctamente en la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}else if($this->option == "list"){
|
||||
$this->reply = $this->halls;
|
||||
}
|
||||
} else {
|
||||
$this->reply = "<h1> ERROR </h1><hr />
|
||||
<p> Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}
|
||||
return $this->reply;
|
||||
}
|
||||
|
||||
//Process form:
|
||||
public function processesForm($number, $cinema, $rows, $cols, $option) {
|
||||
$this->option = $option;
|
||||
$this->correct = true;
|
||||
$bd = new HallDAO('complucine');
|
||||
|
||||
|
||||
if($bd ){
|
||||
if($option == "list"){
|
||||
$this->halls = $bd->getAllHalls($cinema);
|
||||
}else {
|
||||
/* TODO
|
||||
$start = date('H:i:s', strtotime( $start ) );
|
||||
|
||||
if($option == "new"){
|
||||
|
||||
$selectSession = $bd->selectSession($cinema, $hall, $start, $date);
|
||||
if($selectSession && $selectSession->num_rows >= 1) {
|
||||
$this->correct = false;
|
||||
} else{
|
||||
$bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
|
||||
}
|
||||
|
||||
mysqli_free_result($selectSession);
|
||||
|
||||
} else if ($option == "del"){
|
||||
$bd->deleteSession($id);
|
||||
|
||||
} else if ($option == "edit"){
|
||||
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format);
|
||||
}
|
||||
|
||||
if($repeat > "0"){
|
||||
$repeat--;
|
||||
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
|
||||
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
} else {$this->correct = false;}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
83
panel_manager/includes/formSession.php
Normal file
83
panel_manager/includes/formSession.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
include_once('session_dao.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
//Receive data from froms and prepare the correct response
|
||||
class FormSession extends Form {
|
||||
//Atributes
|
||||
private $correct;
|
||||
private $reply;
|
||||
private $option;
|
||||
private $sessions;
|
||||
|
||||
//Constructor:
|
||||
public function __construct() {
|
||||
parent::__construct('formSession');
|
||||
$this->reply = array();
|
||||
}
|
||||
|
||||
//Methods:
|
||||
public function getReply() {
|
||||
if($this->correct){
|
||||
if($this->option == "new"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha añadido la sesion correctamente en la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}else if($this->option == "edit"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha editado la sesion correctamente en la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}else if($this->option == "del"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha eliminado la sesion correctamente en la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}else if($this->option == "list"){
|
||||
$this->reply = $this->sessions;
|
||||
}
|
||||
} else if($this->correct == false) {
|
||||
$this->reply = "<h1> ERROR </h1><hr />
|
||||
<p> Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.</p>
|
||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||
}
|
||||
return $this->reply;
|
||||
}
|
||||
|
||||
public function processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) {
|
||||
$this->option = $option;
|
||||
$this->correct = true;
|
||||
|
||||
$bd = new sessionDAO('complucine');
|
||||
|
||||
if($bd ){
|
||||
if($option == "list"){
|
||||
$this->sessions = $bd->getAllSessionsFromACinemaHallDate($cinema, $hall, $date);
|
||||
|
||||
}else {
|
||||
if($option == "new"){
|
||||
$searchSession = $bd->searchSession($cinema, $hall, $start, $date);
|
||||
if($searchSession) {
|
||||
$this->correct = false;
|
||||
} else{
|
||||
$bd->createSession(null,$film, $hall,$cinema, $date, $start, $price, $format);
|
||||
}
|
||||
|
||||
} else if ($option == "del"){
|
||||
$bd->deleteSession($hall, $cinema, $date, $start);
|
||||
|
||||
} else if ($option == "edit"){
|
||||
$bd->editSession($film, $hall, $cinema, $date, $start, $price, $format);
|
||||
|
||||
}
|
||||
|
||||
if($repeat > "0"){
|
||||
$repeat--;
|
||||
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
|
||||
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option);
|
||||
}
|
||||
}
|
||||
} else {$this->correct = false;}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
73
panel_manager/includes/hall_dao.php
Normal file
73
panel_manager/includes/hall_dao.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
38
panel_manager/includes/hall_dto.php
Normal file
38
panel_manager/includes/hall_dto.php
Normal 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; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
12
panel_manager/includes/hall_dto_interface.php
Normal file
12
panel_manager/includes/hall_dto_interface.php
Normal 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();
|
||||
}
|
||||
?>
|
106
panel_manager/includes/session_dao.php
Normal file
106
panel_manager/includes/session_dao.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
56
panel_manager/includes/session_dto.php
Normal file
56
panel_manager/includes/session_dto.php
Normal 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; }
|
||||
|
||||
}
|
||||
?>
|
20
panel_manager/includes/session_dto_interface.php
Normal file
20
panel_manager/includes/session_dto_interface.php
Normal 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();
|
||||
}
|
||||
?>
|
68
panel_manager/index.php
Normal file
68
panel_manager/index.php
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE HTML>
|
||||
<?php
|
||||
//General Config File:
|
||||
require_once('../assets/php/config.php');
|
||||
|
||||
include_once('panel_manager.php');
|
||||
|
||||
$login = false;
|
||||
|
||||
if(isset($_SESSION["login"]) && $_SESSION["rol"] == "manager") $login = true;
|
||||
|
||||
if(isset($_REQUEST['state'])) {
|
||||
$panel = new Panel($_REQUEST['state'],$login);
|
||||
}
|
||||
else {
|
||||
$panel = new Panel('',$login);
|
||||
}
|
||||
?>
|
||||
<!--
|
||||
Práctica 2 - Sistemas Web | Grupo D
|
||||
CompluCine - FDI-cines
|
||||
-->
|
||||
<html lang="es">
|
||||
<!-- Head -->
|
||||
<?php
|
||||
$template->print_head();
|
||||
?>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<?php
|
||||
$template->print_header();
|
||||
?>
|
||||
|
||||
<!-- Main -->
|
||||
<?php
|
||||
$template->print_main();
|
||||
?>
|
||||
|
||||
<!-- Panel -->
|
||||
<div class="row">
|
||||
<!--Left Sidebar -->
|
||||
<div class="sidebar left">
|
||||
<ul>
|
||||
<li>Ver como:</li>
|
||||
<ul>
|
||||
<li><a href='./?state=us_u'>Usuario no registrado</a></li>
|
||||
<li><a href='./?state=us_r'>Usuario registrado</a></li>
|
||||
</ul><br />
|
||||
<li>Añadir/Editar/Eliminar:</li>
|
||||
<ul>
|
||||
<li><a href='./?state=rooms'>Salas</a></li>
|
||||
<li><a href='./?state=sessions'>Sesiones</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
<!--Contents -->
|
||||
<div class="row">
|
||||
<?php $panel->showPanel(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Footer -->
|
||||
<?php
|
||||
$template->print_footer();
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
35
panel_manager/manage_rooms.php
Normal file
35
panel_manager/manage_rooms.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require('./includes/hall_dto.php');
|
||||
|
||||
$r1 = new HallDTO(0,20,20,30);
|
||||
$r2 = new HallDTO(1,10,30,30);
|
||||
$r3 = new HallDTO(2,30,10,30);
|
||||
$r4 = new HallDTO(3,15,15,30);
|
||||
$rooms = array($r1, $r2, $r3, $r4);
|
||||
|
||||
function drawHalls($ros){
|
||||
echo " <p> Esta vista esta en desarrollo <p>
|
||||
<div class=\"column middle\">
|
||||
<table class='alt'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sala</th>
|
||||
<th>Opción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>";
|
||||
foreach($ros as $r){
|
||||
echo "
|
||||
<tr>
|
||||
<td><a href=\"\" class='button'>Sala". $r->getNumber() ."</a></td>
|
||||
<td><a href=\"index.php?state=rooms\" class='button'>Editar</a></td>
|
||||
</tr>";
|
||||
}
|
||||
echo "<tbody>
|
||||
</table>\n";
|
||||
echo "<a href=\"index.php?state=rooms\" class='button large'>Añadir</a>
|
||||
</div>";
|
||||
}
|
||||
drawHalls($rooms);
|
||||
?>
|
||||
|
110
panel_manager/manage_sessions.php
Normal file
110
panel_manager/manage_sessions.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
require_once('../assets/php/config.php');
|
||||
|
||||
include_once('./includes/hall_dto.php');
|
||||
include_once('./includes/formHall.php');
|
||||
|
||||
include_once('./includes/session_dto.php');
|
||||
include_once('./includes/formSession.php');
|
||||
|
||||
include_once('../panel_admin/includes/film_dto.php');
|
||||
include_once('../panel_admin/includes/film_dao.php');
|
||||
|
||||
$formSession = new FormSession();
|
||||
$formHall = new FormHall();
|
||||
|
||||
$placeholder_date = date("Y-m-d");
|
||||
$placeholder_hall = "1";
|
||||
|
||||
$_SESSION["cinema"] = "1";
|
||||
|
||||
if(isset($_POST['filter'])) {
|
||||
$placeholder_date = $_POST["date"];
|
||||
$placeholder_hall = $_POST["hall"];
|
||||
}
|
||||
|
||||
$formHall->processesForm(null, $_SESSION["cinema"], null, null, "list");
|
||||
$formSession->processesForm(null, $placeholder_hall, $_SESSION["cinema"], $placeholder_date, null, null, null, null, "list");
|
||||
|
||||
echo"
|
||||
<!--Session Filter -->
|
||||
<div class = \"column middle\">
|
||||
<form method=\"post\" id=\"addfilter\">
|
||||
<input type=\"date\" name=\"date\" value=\"". $placeholder_date . "\" min=\"2021-01-01\" max=\"2031-12-31\">
|
||||
<select name=\"hall\" class=\"button large\">";
|
||||
|
||||
foreach($formHall->getReply() as $r){
|
||||
if($r->getNumber() == $placeholder_hall){
|
||||
echo "
|
||||
<option value=\"". $r->getNumber() ." \"selected> Sala ". $r->getNumber() . "</option>";
|
||||
}else{
|
||||
echo "
|
||||
<option value=\"". $r->getNumber() ." \"> Sala ". $r->getNumber() . "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "
|
||||
</select>
|
||||
<input type=\"submit\" name=\"filter\" value=\"Filtrar\" class=\"button large\" />
|
||||
</form>
|
||||
</div>";
|
||||
|
||||
function drawSessions($sessions,$bd){
|
||||
echo "
|
||||
<!--Session List -->
|
||||
<div class=\"column side\">
|
||||
<table class='alt'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Hora</th>
|
||||
<th>Pelicula</th>
|
||||
<th>Formato</th>
|
||||
<th>Precio</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>";
|
||||
foreach($sessions as $s){
|
||||
$film = mysqli_fetch_array($bd->FilmData($s->getIdfilm()));
|
||||
echo "
|
||||
<tr>
|
||||
<td> " . date('H:i', strtotime( $s->getStartTime())) . "</a></td>
|
||||
<td> " . str_replace('_', ' ', $film["tittle"]) . "</a></td>
|
||||
<td> " . $s->getFormat() . "</a></td>
|
||||
<td> " . $s->getSeatPrice() . "</a></td>
|
||||
<form method=\"post\" action=\"./?state=edit_session&option=edit\">
|
||||
<input name=\"idfilm\" type=\"hidden\" value=\"".$s->getIdfilm()."\">
|
||||
<input name=\"hall\" type=\"hidden\" value=\"".$s->getIdhall()."\">
|
||||
<input name=\"date\" type=\"hidden\" value=\"".$s->getDate()."\">
|
||||
<input name=\"start\" type=\"hidden\" value=\"".$s->getStartTime()."\">
|
||||
<input name=\"price\" type=\"hidden\" value=\"".$s->getSeatPrice()."\">
|
||||
<input name=\"format\" type=\"hidden\" value=\"".$s->getFormat()."\">
|
||||
<td> <input type=\"submit\" id=\"submit\" value=\"Editar\" class=\"button\" > </td>
|
||||
</form>
|
||||
</tr>";
|
||||
}
|
||||
echo "
|
||||
<tbody>
|
||||
</table>
|
||||
<input type=\"submit\" name=\"submit\" form=\"addfilter\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
|
||||
</div>\n";
|
||||
|
||||
}
|
||||
if($formSession->getReply()){
|
||||
$bd = new Film_DAO('complucine');
|
||||
if($bd){
|
||||
drawSessions($formSession->getReply(), $bd);
|
||||
} else {
|
||||
echo "<div class=\"column side\">
|
||||
<p> Hay un error en la conexion </p>
|
||||
</div>";
|
||||
}
|
||||
} else {
|
||||
echo "
|
||||
|
||||
<div class=\"column side\">
|
||||
<p> No hay ninguna session en la sala ". $placeholder_hall . " el dia ". $placeholder_date . "</p>
|
||||
<input type=\"submit\" name=\"submit\" form=\"addfilter\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
|
||||
</div>\n";
|
||||
}
|
||||
?>
|
28
panel_manager/panel_manager.php
Normal file
28
panel_manager/panel_manager.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
class Panel {
|
||||
public $state;
|
||||
public $login;
|
||||
|
||||
function __construct($panel,$log){
|
||||
$this->state = $panel;
|
||||
$this->login = $log;
|
||||
|
||||
}
|
||||
|
||||
function showPanel() {
|
||||
if($this->login){
|
||||
switch($this->state) {
|
||||
case 'us_u': echo "<p> Esta vista no esta implementada </p>"; break;
|
||||
case 'us_r': echo "<p> Esta vista no esta implementada </p>"; break;
|
||||
case 'rooms': require_once('manage_rooms.php'); break;
|
||||
case 'sessions': require_once('manage_sessions.php'); break;
|
||||
case 'edit_session': require_once('edit_sessions.php'); break;
|
||||
default: require('hello_panel.php'); break;
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo "<h1> Error no tienes los permisos necesarios de gerente</h1>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
77
panel_manager/validateSession.php
Normal file
77
panel_manager/validateSession.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
require_once('../assets/php/config.php');
|
||||
require_once('./includes/formSession.php');
|
||||
$session = new FormSession();
|
||||
$reply = "<p> ERROR DE ACCESO </p>" ;
|
||||
|
||||
if(isset($_POST['new'])){
|
||||
$session->processesForm($_POST["film"], $_POST["hall"], $_SESSION["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],$_POST["repeat"], "new");
|
||||
$reply = $session->getReply();
|
||||
$_SESSION["cinema"] = "";
|
||||
$_SESSION["hall"] = "";
|
||||
$_SESSION["date"] = "";
|
||||
$_SESSION["start"] = "";
|
||||
|
||||
} else if (isset($_POST['edit'])){
|
||||
$session->processesForm($_POST["film"], $_POST["hall"], $_SESSION["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "edit");
|
||||
$reply = $session->getReply();
|
||||
$_SESSION["cinema"] = "";
|
||||
$_SESSION["hall"] = "";
|
||||
$_SESSION["date"] = "";
|
||||
$_SESSION["start"] = "";
|
||||
|
||||
} else if (isset($_POST['del'])){
|
||||
$session->processesForm($_POST["film"], $_POST["hall"], $_SESSION["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "del");
|
||||
$reply = $session->getReply();
|
||||
$_SESSION["cinema"] = "";
|
||||
$_SESSION["hall"] = "";
|
||||
$_SESSION["date"] = "";
|
||||
$_SESSION["start"] = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
Práctica 2 - Sistemas Web | Grupo D
|
||||
CompluCine - FDI-cines
|
||||
-->
|
||||
<html lang="es">
|
||||
<!-- Head -->
|
||||
<?php
|
||||
$template->print_head();
|
||||
?>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<?php
|
||||
$template->print_header();
|
||||
?>
|
||||
|
||||
<!-- Main -->
|
||||
<div class="main">
|
||||
<div class="image"><img src="../img/logo_trasparente.png" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Reply -->
|
||||
<section class="reply">
|
||||
<div class ="row">
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<div class="code info">
|
||||
<?php
|
||||
echo $reply;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Footer -->
|
||||
<?php
|
||||
$template->print_footer();
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user