diff --git a/panel_manager/includes/formHall.php b/panel_manager/includes/formHall.php index 6f113cd..5100e1c 100644 --- a/panel_manager/includes/formHall.php +++ b/panel_manager/includes/formHall.php @@ -6,10 +6,12 @@ include_once($prefix.'assets/php/form.php'); class FormHall extends Form { private $option; + private $cinema; //Constructor: - public function __construct($option) { + public function __construct($option, $cinema) { $this->option = $option; + $this->cinema = $cinema; $options = array("action" => "./?state=".$option); parent::__construct('formHall',$options); } @@ -25,15 +27,16 @@ class FormHall extends Form { $rows = $data['rows'] ?? $_POST["rows"]; $cols = $data['cols'] ?? $_POST["cols"]; } - $og_number = $data['og_number'] ?? $number; + $og_number = $data['og_number'] ?? $number; + //Seats_map $seats = 0; $seats_map = array(); //Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form if($data["restart"] || $_POST["edit_hall"] ){ - foreach(Seat::getSeatsMap($og_number, $_SESSION["cinema"]) as $seat){ + foreach(Seat::getSeatsMap($og_number, $this->cinema) as $seat){ $seats_map[$seat->getNumRows()][$seat->getNumCol()] = $seat->getState(); if($seat->getState()>=0){ $seats++; @@ -44,85 +47,84 @@ class FormHall extends Form { $alltoone = $_POST["alltoone"] ?? 0; for($i = 1;$i <= $rows; $i++){ for($j = 1; $j <= $cols; $j++){ - echo "El valor de la data: ".$data["checkbox".$i.$j]; - if($alltoone || ( $data["checkbox".$i.$j] >= "0")){ + if($alltoone || isset($data["checkbox".$i.$j])) { $seats_map[$i][$j] = $data["checkbox".$i.$j] ?? "0"; $seats++; + if($seats_map[$i][$j] == "-1"){ + $seats_map[$i][$j] = "0"; + } }else $seats_map[$i][$j] = "-1"; } - } - - - + } } $htmlErroresGlobales = self::generaListaErroresGlobales($errores); $errorNumber = self::createMensajeError($errores, 'number', 'span', array('class' => 'error')); $errorSeats = self::createMensajeError($errores, 'seats', 'span', array('class' => 'error')); - - $html = '
- '.$htmlErroresGlobales.' - '.$errorSeats.' + + $html = ' +
'.$htmlErroresGlobales.' '.$errorSeats.' '. $errorManager.'
- Configuracion + Mapa de Asientos


- '; + '; if($this->option == "edit_hall") - $html .= ' '; - $html .='
- - '.$errorNumber.' + $html .= ' '; + $html .=' + + '.$errorNumber.'

-
+
'; if($this->option == "new_hall") - $html .=''; + $html .=' + '; if($this->option == "edit_hall"){ $html .=' - + '; } - $html .='
+ $html .='

Pantalla

- - - '; + + + + '; for($j = 1; $j<=$cols; $j++){ - $html .= ''; + $html .= ' + '; } - $html .= ' - - '; + $html .= ' + + '; for($i = 1;$i<=$rows;$i++){ $html .= ' - - - '; + + + '; for($j=1; $j<=$cols; $j++){ if($seats_map[$i][$j]>=0){ $html .= ' - ';} + ';} else { $html .= ' - ';} + ';} } - $html .=' - '; + $html .=''; } $html .= ' - +
'.$j.''.$j.'
'.$i.'
'.$i.'
-
- '; + '; return $html; } @@ -158,25 +160,26 @@ class FormHall extends Form { $result['seats'] = "
  • No puede haber 0 asientos disponibles.

  • "; } + $number = $datos['number'] ?? null; if (empty($number) && isset($datos["sumbit"])) { $result['number'] = "
  • El numero de sala tiene que ser mayor que 0.

  • "; } if (count($result) === 0 && isset($datos["sumbit"]) ) { - if($this->option == "new_hall"){ - $_SESSION['msg'] = Hall::create_hall($number, $_SESSION["cinema"], $rows, $cols, $seats, $seats_map); - $result = './?state=success'; - } - if($this->option == "edit_hall"){ - $_SESSION['msg'] = Hall::edit_hall($number, $_SESSION["cinema"], $rows, $cols, $seats, $seats_map, $og_number); - $result = './?state=success'; - } + if($this->option == "new_hall"){ + $_SESSION['msg'] = Hall::create_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map); + $result = './?state=success'; + } + if($this->option == "edit_hall"){ + $_SESSION['msg'] = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $og_number); + $result = './?state=success'; + } } if (!isset($result['number']) && isset($datos["delete"]) ) { if($this->option == "edit_hall"){ - $_SESSION['msg'] = Hall::delete_hall($number, $_SESSION["cinema"], $rows, $cols, $seats, $seats_map, $og_number); + $_SESSION['msg'] = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $og_number); $result = './?state=success'; } } diff --git a/panel_manager/includes/formSession.php b/panel_manager/includes/formSession.php index 052d2fe..c40ecf2 100644 --- a/panel_manager/includes/formSession.php +++ b/panel_manager/includes/formSession.php @@ -8,10 +8,12 @@ require_once($prefix.'assets/php/form.php'); class FormSession extends Form { private $option; - + private $cinema; + //Constructor: - public function __construct($option) { + public function __construct($option, $cinema) { $this->option = $option; + $this->cinema = $cinema; $options = array("action" => "./?state=".$option); parent::__construct('formSession',$options); } @@ -23,16 +25,14 @@ class FormSession extends Form { $films = $filmList->allFilmData(); if($this->option == "new_session") { - $cinema = $data['cinema'] ?? $_SESSION["cinema"]; $film = $data['film'] ?? 1; - $hall = $data['hall'] ?? ''; - $date = $data['date'] ?? ''; + $hall = $data['hall'] ?? $_POST["hall"]; + $date = $data['date'] ?? $_POST["date"]; $start = $data['start'] ?? ''; $price = $data['price'] ?? ''; $format = $data['format'] ?? ''; } else { - $cinema = $data['cinema'] ?? $_SESSION["cinema"]; $film = $data['film'] ?? $_POST["film"]; $hall = $data['hall'] ?? $_POST["hall"]; $date = $data['date'] ?? $_POST["date"]; @@ -47,17 +47,15 @@ class FormSession extends Form { $htmlErroresGlobales = self::generaListaErroresGlobales($errores); $errorPrice = self::createMensajeError($errores, 'price', 'span', array('class' => 'error')); - $html .= '
    - '.$htmlErroresGlobales.' - '.$errorPrice.' + $html .= ' +
    '.$htmlErroresGlobales.' '.$errorPrice.'
    Datos -
    - '.$errorFormat.' +
    '.$errorFormat.'

    - '; + '; if($film){ if($this->option == "new_session") $html .= '
    -
    '; +
    '; if($this->option == "edit_session"){ - $html .= ' -
    -
    '; + $html .= '
    +
    '; } } $html .= ' - +
    -
    - + '; foreach($films as $f){ if($f->getId() == $film){ - $html .= ""; + $html .= " + "; }else{ - $html .= ""; + $html .= " + "; } } - + $html .= ''; return $html; } //Methods: @@ -128,17 +128,17 @@ class FormSession extends Form { if (count($result) === 0 && isset($data["sumbit"]) ) { if($this->option == "new_session"){ - $_SESSION['msg'] = Session::create_session($_SESSION["cinema"], $hall, $start, $date, $film, $price, $format,$repeat); + $_SESSION['msg'] = Session::create_session($this->cinema, $hall, $start, $date, $film, $price, $format,$repeat); $result = './?state=success'; } if($this->option == "edit_session"){ - $_SESSION['msg'] = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $hall, $start, $date, $film, $price, $format); + $_SESSION['msg'] = Session::edit_session($this->cinema, $or_hall, $or_date, $or_start, $hall, $start, $date, $film, $price, $format); $result = './?state=success'; } } if(!isset($result['hall']) && !isset($result['start']) && !isset($result['date']) && isset($data["delete"])) { - $_SESSION['msg'] = Session::delete_session($_SESSION["cinema"], $or_hall, $or_start, $or_date); + $_SESSION['msg'] = Session::delete_session($this->cinema, $or_hall, $or_start, $or_date); $result = './?state=success'; } diff --git a/panel_manager/index.php b/panel_manager/index.php index 8218392..292a46e 100644 --- a/panel_manager/index.php +++ b/panel_manager/index.php @@ -1,15 +1,28 @@ GetManager($user->getId()); + + if($manager){ + if($manager->num_rows == 1){ + $fila = $manager->fetch_assoc(); + $manager = new Manager($fila["id"], $fila["idcinema"], $fila["username"], $fila["email"], $fila["rol"]); + } + } + } + switch($_GET["state"]){ case "view_ruser": case "view_user": @@ -22,31 +35,31 @@
    '."\n"; break; case "manage_halls": - $panel = Manager_panel::manage_halls(); + $panel = Manager_panel::manage_halls($manager); break; case "new_hall": - $panel = Manager_panel::new_hall(); + $panel = Manager_panel::new_hall($manager); break; case "edit_hall": - $panel = Manager_panel::edit_hall(); + $panel = Manager_panel::edit_hall($manager); break; case "manage_sessions": - $panel = Manager_panel::manage_sessions(); + $panel = Manager_panel::manage_sessions($manager); break; case "new_session": - $panel = Manager_panel::new_session(); + $panel = Manager_panel::new_session($manager); break; case "edit_session": - $panel = Manager_panel::edit_session(); + $panel = Manager_panel::edit_session($manager); break; case "select_film": - $panel = Manager_panel::select_film($template); + $panel = Manager_panel::select_film($template,$manager); break; case "success": $panel = Manager_panel::success(); break; default: - $panel = Manager_panel::welcome(); + $panel = Manager_panel::welcome($manager); break; } } @@ -64,13 +77,12 @@ //Specific page content: $section = ' +
    -
    - -
    - '.$panel.' -
    -
    + +
    + '.$panel.' +
    '; //General page content: diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php index a0e0426..4abb337 100644 --- a/panel_manager/panel_manager.php +++ b/panel_manager/panel_manager.php @@ -1,6 +1,7 @@ getIdcinema()); $panel = '
    -

    Bienvenido '.$name.' a tu Panel de Manager.

    -
    -

    Usuario: '.$name.'

    -

    Cine: '.$cinema.'

    -

    Espero que estes pasando un buen dia

    -
    '."\n"; +

    Bienvenido '.$name.' a tu Panel de Manager.

    +
    +

    Usuario: '.$name.'

    +

    Cine: '.$cinema.'

    +

    Espero que estes pasando un buen dia

    +
    '; return $panel; } @@ -35,170 +36,167 @@ return $panel; } - static function manage_halls(){ + static function manage_halls($manager){ $panel = '
    -
    '; - $listhall = Hall::getListHalls($_SESSION["cinema"]); +
    '; + $listhall = Hall::getListHalls($manager->getIdcinema()); if(!$listhall){ $panel .= "

    No hay ninguna sala en este cine"; }else{ $panel .= ' - - - - - - - - - - - '; +
    NumeroFilasColumnasAsientos Disponibles
    + + + + + + + + + '; foreach($listhall as $hall){ $panel .=' - - - - - - - - - - - - - - '; + + + + + + + + + + + + + '; } $panel.=' - -
    NumeroFilasColumnasAsientos Disponibles
    '. $hall->getNumber().' '. $hall->getNumRows().' '. $hall->getNumCol().' '.$hall->getTotalSeats().'
    '. $hall->getNumber().' '. $hall->getNumRows().' '. $hall->getNumCol().' '.$hall->getTotalSeats().'
    - '; + + '; } - $panel.='
    - + $panel.=' + +
    -

    -
    - '; +
    +
    '; return $panel; } - static function new_hall(){ + static function new_hall($manager){ - $formHall = new FormHall("new_hall"); + $formHall = new FormHall("new_hall",$manager->getIdcinema()); - $panel = '

    Crear una sala.



    ' - .$formHall->gestiona(); + $panel = '

    Crear una sala.



    + '.$formHall->gestiona(); return $panel; } - static function edit_hall(){ - $formHall = new FormHall("edit_hall"); + static function edit_hall($manager){ + $formHall = new FormHall("edit_hall",$manager->getIdcinema()); - $panel = '

    Editar una sala.



    ' - .$formHall->gestiona(); + $panel = '

    Editar una sala.



    + '.$formHall->gestiona(); return $panel; } - static function manage_sessions(){ + static function manage_sessions($manager){ //Base filtering values $date = isset($_POST['date']) ? $_POST['date'] : date("Y-m-d"); $hall = isset($_POST['hall']) ? $_POST['hall'] : "1"; //Session filter $panel='
    -
    - - + - -
    -
    + + + +
    '; //Session list - $panel .='
    '; - $sessions = Session::getListSessions($hall,$_SESSION["cinema"],$date); + $panel .='
    '; + $sessions = Session::getListSessions($hall,$manager->getIdcinema(),$date); if($sessions) { $panel .=' -
    - - - - - - - - - - '; + +
    HoraPeliculaFormatoPrecio
    + + + + + + + + + '; foreach($sessions as $session){ $panel .=' - - - - - - - - - - - - - - - '; + + + + + + + + + + + + + + + '; } $panel.=' - -
    HoraPeliculaFormatoPrecio
    '.date("H:i", strtotime( $session->getStartTime())).' '. str_replace('_', ' ', Session::getThisSessionFilm($session->getIdfilm())["tittle"]) .' '.$session->getFormat().' '.$session->getSeatPrice().'
    '.date("H:i", strtotime( $session->getStartTime())).' '. str_replace('_', ' ', Session::getThisSessionFilm($session->getIdfilm())["tittle"]) .' '.$session->getFormat().' '.$session->getSeatPrice().'
    - '; + + + '; } else { $panel.='

    No hay ninguna sesion

    '; } $panel.=' - -
    -'; + +
    '; return $panel; } - static function new_session(){ - $formSession = new FormSession("new_session"); - - $panel = '

    Crear una sesion.



    ' - .$formSession->gestiona(); + static function new_session($manager){ + $formSession = new FormSession("new_session", $manager->getIdcinema() ); + + $panel = '

    Crear una sesion.



    + '.$formSession->gestiona(); return $panel; } - static function edit_session(){ - $formSession = new FormSession("edit_session"); + static function edit_session($manager){ + $formSession = new FormSession("edit_session", $manager->getIdcinema() ); - $panel = '

    Editar una sesion.



    ' - .$formSession->gestiona(); + $panel = '

    Editar una sesion.



    + '.$formSession->gestiona(); return $panel; } - static function select_film($template){ + //TODO: estado al modificar sesiones para la seleccion de peliculas usando el template->print films + static function select_film($template,$manager){ if(isset($_GET["option"])){ $_SESSION["option"] = $_GET["option"]; $panel = '

    Seleccionar Pelicula.



    '; @@ -210,7 +208,7 @@ } //Funcion que se envia cuando hay inconsistencia en el panel manager, principalmente por tocar cosas con la ulr - static function warning(){ + static function warning($manager){ $panel = '

    No deberias poder acceder aqui.