2021-04-10 20:54:56 +02:00
|
|
|
<?php
|
|
|
|
include_once('session_dao.php');
|
|
|
|
include_once('../assets/php/form.php');
|
|
|
|
|
2021-04-15 20:53:01 +02:00
|
|
|
//Receive data from froms and prepare the correct response
|
2021-04-10 20:54:56 +02:00
|
|
|
class FormSession extends Form {
|
2021-04-15 20:53:01 +02:00
|
|
|
//Atributes
|
|
|
|
private $correct;
|
|
|
|
private $reply;
|
2021-04-11 19:55:21 +02:00
|
|
|
private $option;
|
2021-04-13 21:15:28 +02:00
|
|
|
private $sessions;
|
|
|
|
|
2021-04-15 20:53:01 +02:00
|
|
|
//Constructor:
|
2021-04-10 20:54:56 +02:00
|
|
|
public function __construct() {
|
|
|
|
parent::__construct('formSession');
|
|
|
|
$this->reply = array();
|
|
|
|
}
|
2021-04-15 20:53:01 +02:00
|
|
|
|
|
|
|
//Methods:
|
2021-04-10 20:54:56 +02:00
|
|
|
public function getReply() {
|
|
|
|
if($this->correct){
|
2021-04-11 19:55:21 +02:00
|
|
|
if($this->option == "new"){
|
|
|
|
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
2021-04-10 20:54:56 +02:00
|
|
|
<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>";
|
2021-04-11 19:55:21 +02:00
|
|
|
}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>";
|
2021-04-13 21:15:28 +02:00
|
|
|
}else if($this->option == "list"){
|
|
|
|
$this->reply = $this->sessions;
|
2021-04-11 19:55:21 +02:00
|
|
|
}
|
2021-04-14 19:59:52 +02:00
|
|
|
} else if($this->correct == false) {
|
2021-04-10 20:54:56 +02:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2021-04-15 22:34:33 +02:00
|
|
|
public function processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) {
|
2021-04-11 19:55:21 +02:00
|
|
|
$this->option = $option;
|
2021-04-13 21:15:28 +02:00
|
|
|
$this->correct = true;
|
2021-04-15 20:53:01 +02:00
|
|
|
|
2021-04-13 21:15:28 +02:00
|
|
|
$bd = new sessionDAO('complucine');
|
2021-04-15 20:53:01 +02:00
|
|
|
|
2021-04-11 19:55:21 +02:00
|
|
|
if($bd ){
|
2021-04-13 21:15:28 +02:00
|
|
|
if($option == "list"){
|
2021-04-15 20:53:01 +02:00
|
|
|
$this->sessions = $bd->getAllSessionsFromACinemaHallDate($cinema, $hall, $date);
|
2021-04-13 21:15:28 +02:00
|
|
|
|
2021-04-15 20:53:01 +02:00
|
|
|
}else {
|
2021-04-13 21:15:28 +02:00
|
|
|
if($option == "new"){
|
2021-04-15 20:53:01 +02:00
|
|
|
$searchSession = $bd->searchSession($cinema, $hall, $start, $date);
|
|
|
|
if($searchSession) {
|
2021-04-13 21:15:28 +02:00
|
|
|
$this->correct = false;
|
|
|
|
} else{
|
2021-04-15 22:34:33 +02:00
|
|
|
$bd->createSession(null,$film, $hall,$cinema, $date, $start, $price, $format);
|
2021-04-13 21:15:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if ($option == "del"){
|
2021-04-15 22:34:33 +02:00
|
|
|
$bd->deleteSession($hall, $cinema, $date, $start);
|
2021-04-13 21:15:28 +02:00
|
|
|
|
|
|
|
} else if ($option == "edit"){
|
2021-04-15 22:34:33 +02:00
|
|
|
$bd->editSession($film, $hall, $cinema, $date, $start, $price, $format);
|
2021-04-15 20:53:01 +02:00
|
|
|
|
2021-04-11 19:55:21 +02:00
|
|
|
}
|
2021-04-13 21:15:28 +02:00
|
|
|
|
|
|
|
if($repeat > "0"){
|
|
|
|
$repeat--;
|
|
|
|
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
|
2021-04-15 22:34:33 +02:00
|
|
|
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option);
|
2021-04-13 21:15:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {$this->correct = false;}
|
2021-04-10 20:54:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|