diff --git a/panel_manager/edit_sessions.php b/panel_manager/edit_sessions.php index 0322ca6..d290be7 100644 --- a/panel_manager/edit_sessions.php +++ b/panel_manager/edit_sessions.php @@ -1,8 +1,40 @@ -

Este es el panel de editar/añadir o eliminar sesiones

- - + + if(isset($_REQUEST['option']) && $_REQUEST['option'] == 'edit') { + echo "

Este es el panel de editar o eliminar una sesion. Deberia tener el formulario de crear una sesion nueva pero con los datos ya situados y quizas que solo aqui aparezca el boton de eliminar

"; + } + else{ + echo "

Crear Session

+
+
+
+ Datos +
+ +
+
+ +
+
+ +
+
+
+ Horario +
+ +
+
+
+ + +
+
+
"; + } + echo "" + ?> + diff --git a/panel_manager/includes/formSession.php b/panel_manager/includes/formSession.php new file mode 100644 index 0000000..e1b65f0 --- /dev/null +++ b/panel_manager/includes/formSession.php @@ -0,0 +1,66 @@ +reply = array(); + } + + //Methods: + + //Returns validation response: + public function getReply() { + + //Habria que comprobar si realmente se ha validado la respuesta antes de escribir una respuesta correcta + if($this->correct){ + $this->reply = "

Operacion realizada con exito


+

Se ha añadido la sesion correctamente en la base de datos.

+ "; + } else { + $this->reply = "

ERROR


+

Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.

+ "; + + } + return $this->reply; + } + + //Process form: + public function processesForm($price, $film, $format, $start) { + $this->correct = true; + $hall = 2; + $cinema = 1; + $date = "2021-04-10"; + //Habria que validar todo para que encaje en la base de datos + + $start = date('H:i:s', strtotime( $start ) ); + $date = date('Y-m-d', strtotime( $date ) ); + + $bd = new sessionDAO('complucine'); + if($bd){ + $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); + } + } + +} + +?> + diff --git a/panel_manager/includes/listSessions.php b/panel_manager/includes/listSessions.php new file mode 100644 index 0000000..4decf4d --- /dev/null +++ b/panel_manager/includes/listSessions.php @@ -0,0 +1,67 @@ +array = array(); + + $this->cinema = $cinema; + $this->hall = $hall; + $this->date = $date; + } + //Methods: + + //Returns the whole session array + public function getArray() { + return $this->array; + } + + //Returns the value i from the array + public function getiArray($i) { + if($i < $size){ + return $this->array($i); + } else { + return null; + } + + } + //Change the patterns of the filter + public function setCinema($cinema){$this->cinema = $cinema;} + public function setHall($hall){$this->hall = $hall;} + public function setDate($date){$this->date = $date;} + + //Update the array with current filter values + public function filterList() { + + $this->date = date('Y-m-d', strtotime( $this->date ) ); + + $bd = new sessionDAO('complucine'); + + if($bd){ + $selectSession = $bd->selectSession($this->cinema, $this->hall, null, $this->date); + $selectSession->data_seek(0); + $this->size = 0; + while ($fila = $selectSession->fetch_assoc()) { + $this->array[]= new SessionDTO($fila['id'], $fila['idfilm'], $fila['idhall'], $fila['idcinema'], $fila['date'], date('h:i', strtotime( $fila['start_time'])) , $fila['seat_price'], $fila['format']); + $this->size++; + } + mysqli_free_result($selectSession); + } + } + +} + +?> + diff --git a/panel_manager/includes/session_dao.php b/panel_manager/includes/session_dao.php index 945cac0..a30a04e 100644 --- a/panel_manager/includes/session_dao.php +++ b/panel_manager/includes/session_dao.php @@ -12,12 +12,14 @@ //Methods: //Create a new Session. - public function createSession($id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format){ - - $sql = sprintf( "INSERT INTO sessions( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format) - VALUES ( '%s', '%s', '%s', '%date', '%time', '%d', '%s')", - $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format ); - + public function createSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){ + + $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; } @@ -28,7 +30,25 @@ return $resul; } - + + //Returns a query to check if the session in this cinema, hall and scheudle exists. + public function selectSession($cinema, $hall, $start, $date){ + if($start == null){ + $sql = sprintf( "SELECT * FROM session WHERE + idcinema = '%s' AND idhall = '%s' AND date = '%s'", + $cinema, $hall, $date); + }else{ + $sql = sprintf( "SELECT * FROM session WHERE + idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'", + $cinema, $hall, $date, $start); + } + $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, $date, $startTime, $seatPrice, $format){ return new SessionDTO( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format); @@ -36,4 +56,4 @@ } -?> \ No newline at end of file +?> diff --git a/panel_manager/includes/session_dto.php b/panel_manager/includes/session_dto.php index 10c8a28..24f1d04 100644 --- a/panel_manager/includes/session_dto.php +++ b/panel_manager/includes/session_dto.php @@ -5,18 +5,20 @@ //Attributes: private $_id; //Session Id. - private $_idfilm; //Film Id - private $_idhall //Hall id + private $_idfilm; //Film Id -> deberia ser un objeto tipo pelicula? para poder sacar el nombre de la pelicula en cuestion + private $_idhall; //Hall id -> deberia ser un objeto tipo room/hall/sala de cine por lo mismo + private $_idcinema; private $_date; //Session date. private $_startTime; //Session start time. private $_seatPrice; //Seat price. private $_format; //Type of film: 3D | 4D | normal | subtitle | mute. //Constructor: - function __construct($id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format){ + 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; @@ -32,8 +34,11 @@ public function setIdfilm($idfilm){ $this->_idfilm = $idfilm; } public function getIdfilm(){ return $this->_idfilm; } - public function setIdhall($film){ $this->_idhall = $idhall; } + 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; } diff --git a/panel_manager/index.php b/panel_manager/index.php index 2110079..1bdf911 100644 --- a/panel_manager/index.php +++ b/panel_manager/index.php @@ -6,12 +6,15 @@ require_once('./panel_manager.php'); $template = new Template(); + $login = false; + + if(isset($_SESSION["login"]) && $_SESSION["nombre"] == "manager") $login = true; if(isset($_REQUEST['state'])) { - $panel = new Panel($_REQUEST['state']); + $panel = new Panel($_REQUEST['state'],$login); } - else { - $panel = new Panel(''); + else { + $panel = new Panel('',$login); } // IMPORTANTE: // VERIFICAR QUE ES MANAGER(GERENTE), SI NO, MOSTRAR MENSAJE DE "ERROR" @@ -38,28 +41,31 @@
- + + - +
- showPanel(); ?> +
+
print_footer(); diff --git a/panel_manager/manage_rooms.php b/panel_manager/manage_rooms.php index fcefd6b..4d9ff68 100644 --- a/panel_manager/manage_rooms.php +++ b/panel_manager/manage_rooms.php @@ -1,10 +1,10 @@ - +
- filterList(); + $sessions = $sessionList->getArray(); + function drawSessions($ses){ echo " @@ -41,28 +41,28 @@ Hora - Película - Tipo + idPelícula + Formato Precio - - "; foreach($ses as $s){ echo " - - " . $s->getStartTime() . " - " . $s->getFilm() . " - " . $s->getFormat() . " - ". $s->getSeatPrice() . " - - - "; + + + + " . $s->getStartTime() . " + " . $s->getIdfilm() . " + " . $s->getFormat() . " + ". $s->getSeatPrice() . " + + " + ; } echo " \n"; - echo "Añadir"; + echo "Añadir"; } drawSessions($sessions); ?> diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php index cadc7c1..3c4a62b 100644 --- a/panel_manager/panel_manager.php +++ b/panel_manager/panel_manager.php @@ -1,22 +1,32 @@ state = $panel; + $this->login = $log; } function showPanel() { - switch($this->state) { - case 'us_u': require('user_unregistered_view.php'); break; - case 'us_r': require('user_registered_view.php'); break; - case 'rooms': require('manage_rooms.php'); break; - case 'sessions': require('manage_sessions.php'); break; - case 'edit_session': require('edit_sessions.php'); break; - default: echo "

BIENVENIDO AL PANEL DE GERENTE

-
-

Espero que este pasando un buen dia

-
"; break; + if($this->login){ + switch($this->state) { + case 'us_u': require('user_unregistered_view.php'); break; + case 'us_r': require('user_registered_view.php'); break; + case 'rooms': require('manage_rooms.php'); break; + case 'sessions': require('manage_sessions.php'); break; + case 'edit_session': require('edit_sessions.php'); break; + default: echo "

BIENVENIDO AL PANEL DE GERENTE

+
+

Espero que este pasando un buen dia

+ "; break; + } + } + else{ + echo "

ERROR

+
+

No tiene permiso en esta sección de la pagina web

+ "; } } } diff --git a/panel_manager/validate.php b/panel_manager/validate.php new file mode 100644 index 0000000..c9b508e --- /dev/null +++ b/panel_manager/validate.php @@ -0,0 +1,63 @@ +processesForm($_POST["price"], $_POST["film"], $_POST["format"],$_POST["start"]); + $reply = $session->getReply(); + +?> + + + + + print_head(); + ?> + + + print_header(); + ?> + + +
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+ + + print_footer(); + ?> + + + + \ No newline at end of file