diff --git a/panel_manager/includes/formHall.php b/panel_manager/includes/formHall.php index 89e27c9..9733d13 100644 --- a/panel_manager/includes/formHall.php +++ b/panel_manager/includes/formHall.php @@ -7,23 +7,28 @@ class FormHall extends Form { private $option; private $cinema; + private $og_hall; + private $first; //Constructor: - public function __construct($option, $cinema) { + public function __construct($option, $cinema, $hall) { + $this->option = $option; $this->cinema = $cinema; - $options = array("action" => "./?state=".$option); + $this->og_hall = $hall; + + if($option == "edit_hall") + $this->first = true; + + $options = array("action" => "./?state=".$option."&number=".$hall->getNumber().""); parent::__construct('formHall',$options); } protected function generaCamposFormulario($data, $errores = array()){ //Prepare the data - $number = $data['number'] ?? $_POST["number"] ?? ""; - $rows = $data['rows'] ?? $_POST["rows"] ?? "12"; - $cols = $data['cols'] ?? $_POST["cols"] ?? "8"; - $og_number = $data['og_number'] ?? $number; - $og_rows = $data['og_rows'] ?? $rows; - $og_cols = $data['og_cols'] ?? $cols; + $number = $data['number'] ?? $this->og_hall->getNumber() ?? ""; + $rows = $data['rows'] ?? $this->og_hall->getNumRows() ?? "12"; + $cols = $data['cols'] ?? $this->og_hall->getNumCol() ?? "8"; //Seats_map $seats = 0; @@ -35,10 +40,11 @@ class FormHall extends Form { } //Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form - if(isset($data["restart"]) || isset($_POST["edit_hall"]) ){ - $rows = $og_rows; - $cols = $og_cols; - $seat_list = Seat::getSeatsMap($og_number, $this->cinema); + if(isset($data["restart"]) || $this->first){ + $first = false; + $rows = $this->og_hall->getNumRows(); + $cols = $this->og_hall->getNumCol(); + $seat_list = Seat::getSeatsMap($this->og_hall->getNumber(), $this->cinema); if($seat_list){ foreach($seat_list as $seat){ $seats_map[$seat->getNumRows()][$seat->getNumCol()] = $seat->getState(); @@ -76,21 +82,17 @@ class FormHall extends Form { Mapa de Asientos '.$errorSeats.' '.$errorRows.' '.$errorCols.'
-

-

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

+ '.$errorNumber.'
-
- '; if($this->option == "new_hall") $html .=' @@ -103,6 +105,7 @@ class FormHall extends Form { if(!$errorCols && !$errorRows){ $html .='
+

Pantalla

@@ -150,7 +153,6 @@ class FormHall extends Form { $rows = $datos['rows']; $cols = $datos['cols']; - $og_number = $datos["og_number"]; //Prepare the seat_map $seats_map = array(); @@ -193,14 +195,14 @@ class FormHall extends Form { $result = './?state=success'; } if($this->option == "edit_hall"){ - $_SESSION['msg'] = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $og_number); + $_SESSION['msg'] = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber()); $result = './?state=success'; } } if (!isset($result['number']) && isset($datos["delete"]) ) { if($this->option == "edit_hall"){ - $_SESSION['msg'] = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $og_number); + $_SESSION['msg'] = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber()); $result = './?state=success'; } } diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php index 8f1cfe5..7cf26d8 100644 --- a/panel_manager/panel_manager.php +++ b/panel_manager/panel_manager.php @@ -12,14 +12,23 @@ function __construct(){} static function welcome($manager){ + $bd = new Cinema_DAO('complucine'); + if($bd){ + $cinema = ($bd->cinemaData($manager->getIdcinema()))->fetch_assoc(); + $c_name = $cinema["name"]; + $c_dir = $cinema["direction"]; + $c_tel = $cinema["phone"]; + } $name = strtoupper($_SESSION["nombre"]); $cinema = strtoupper( $manager->getIdcinema()); $panel = '

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


-

Usuario: '.$name.'

-

Cine: '.$cinema.'

+

Usuario: '.$name.'


+

Cine: '.$c_name.'

+

Dirección: '.$c_dir.'

+

Telefono: '.$c_tel.'


Espero que estes pasando un buen dia

'; @@ -84,36 +93,20 @@ $panel .= "

No hay ninguna sala en este cine"; }else{ $panel .= ' -

- - - - - - - - - '; +

Salas

Asientos


+ - - - - - - - - - - - - '; +
  • '. $hall->getNumber().'
  • +
  • '.$hall->getTotalSeats().'
  • + Editar + Sessiones + '; } $panel.=' - -
    NumeroFilasColumnasAsientos Disponibles
    '. $hall->getNumber().' '. $hall->getNumRows().' '. $hall->getNumCol().' '.$hall->getTotalSeats().'
    '; + '; } $panel.='
    @@ -133,18 +126,24 @@ return $panel; } - static function edit_hall($manager){ - $formHall = new FormHall("edit_hall",$manager->getIdcinema()); - - $panel = '

    Editar una sala.



    - '.$formHall->gestiona(); - return $panel; + static function edit_hall($manager){ + $hall = Hall::search_hall($_GET["number"], $manager->getIdcinema()); + + if($hall || isset($_POST["restart"]) || isset($_POST["filter"]) || isset($_POST["sumbit"]) ){ + + $formHall = new FormHall("edit_hall",$manager->getIdcinema(), $hall); + $panel = '

    Editar una sala.



    + '.$formHall->gestiona(); + return $panel; + } else{ + return Manager_panel::warning($manager); + } } 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"; + $date = $_POST['date'] ?? $_GET['date'] ?? date("Y-m-d"); + $hall = $_POST['hall'] ?? $_GET['hall'] ?? "1"; //Session filter $panel='
    @@ -254,7 +253,7 @@ //Funcion que se envia cuando hay inconsistencia en el panel manager, principalmente por tocar cosas con la ulr static function warning($manager){ $panel = '
    -

    No deberias poder acceder aqui.

    +

    Ha habido un error.


    >.<

    '."\n";