diff --git a/panel_manager/eventsProcess.php b/panel_manager/eventsProcess.php deleted file mode 100644 index ff215f6..0000000 --- a/panel_manager/eventsProcess.php +++ /dev/null @@ -1,258 +0,0 @@ -{"price"} ?? ""; - $format = $dictionary->{"format"} ?? ""; - $hall = $dictionary->{"hall"} ?? ""; - $startDate = $dictionary->{"startDate"} ?? ""; - $endDate = $dictionary->{"endDate"} ?? ""; - $startHour = $dictionary->{"startHour"} ?? ""; - $idfilm = $dictionary->{"idFilm"} ?? ""; - - //Check errors in inputs - if (empty($price) || $price <= 0 ) - $errors['price'] = 'El precio no puede ser 0.'; - if (empty($format)) - $errors['format'] = 'El formato no puede estar vacio. Ej: 3D, 2D, voz original'; - if (empty($hall) || $hall<=0 ) - $errors['hall'] = 'La sala no puede ser 0 o menor'; - if (empty($startDate)) - $errors['startDate'] = 'Las sesiones tienen que empezar algun dia.'; - else if (empty($endDate)) - $errors['endDate'] = 'Las sesiones tienen que teminar algun dia.'; - else { - $start = strtotime($startDate); - $end = strtotime($endDate); - $start = date('Y-m-d', $start); - $end = date('Y-m-d', $end); - - if($start > $end) - $errors['date'] = 'La fecha inicial no puede ser antes o el mismo dia que la final.'; - } - if (empty($startHour)) - $errors['startHour'] = 'Es necesario escoger el horario de la sesion.'; - - if (!is_numeric($idfilm) && $idfilm <= 0 ) - $errors['idfilm'] = 'No se ha seleccionado una pelicula.'; - - //Create as many sessions as the diference between start and end date tell us. 1 session per day - while($startDate < $endDate && empty($errors)){ - $msg = Session::create_session($_SESSION["cinema"], $hall, $startHour, $startDate, $idfilm, $price, $format); - - if(strcmp($msg,$correct_response)!== 0) - $errors['global'] = $msg; - else - $data['message'] = $msg; - - $startDate = date('Y-m-d H:i:s', strtotime( $startDate . ' +1 day')); - } - - if (!empty($errors)) { - $data['success'] = false; - $data['errors'] = $errors; - } else { - $data['success'] = true; - } - - echo json_encode($data); - - break; - //Edit session - case 'PUT': - //Correct reply to verify the session has been correctly edited - $correct_response = 'Se ha editado la session con exito'; - - $errors = []; - $data = []; - - //Check if the body is ok - $entityBody = file_get_contents('php://input'); - $dictionary = json_decode($entityBody); - - if (!is_object($dictionary)) - $errors['global'] = 'El cuerpo de la petición no es valido'; - - //Check if the user is droping an event in a new date - if(isset($_GET["drop"]) && $_GET["drop"]){ - - $or_hall = $dictionary->{"idhall"} ?? ""; - $or_date = $dictionary->{"startDate"} ?? ""; - $or_start = $dictionary->{"startHour"} ?? ""; - $price = $dictionary->{"price"} ?? ""; - $idfilm = $dictionary->{"idfilm"} ?? ""; - $format = $dictionary->{"format"} ?? ""; - - $new_date = $dictionary->{"newDate"} ?? ""; - - $msg = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $or_hall, $new_date, $new_date, $idfilm, $price, $format); - - if(strcmp($msg,$correct_response)!== 0) - http_response_code(400); - else - http_response_code(200); - }else{ - //Edit session from a form - $price = $dictionary->{"price"} ?? ""; - $format = $dictionary->{"format"} ?? ""; - $hall = $dictionary->{"hall"} ?? ""; - $startDate = $dictionary->{"startDate"} ?? ""; - - $endDate = $dictionary->{"endDate"} ?? ""; - $startHour = $dictionary->{"startHour"} ?? ""; - - $idfilm = $dictionary->{"idFilm"} ?? ""; - - $or_hall = $dictionary->{"og_hall"} ?? ""; - $or_date = $dictionary->{"og_date"} ?? ""; - $or_start = $dictionary->{"og_start"} ?? ""; - - //Check errors in inputs - if (empty($price) || $price <= 0 ) - $errors['price'] = 'El precio no puede ser 0.'; - if (empty($format)) - $errors['format'] = 'El formato no puede estar vacio. Ej: 3D, 2D, voz original'; - if (empty($hall) || $hall<=0 ) - $errors['hall'] = 'La sala no puede ser 0 o menor'; - if (empty($startDate)) - $errors['startDate'] = 'Las sesiones tienen que empezar algun dia.'; - else if (empty($endDate)) - $errors['endDate'] = 'Las sesiones tienen que teminar algun dia.'; - else { - $start = strtotime($startDate); - $end = strtotime($endDate); - $start = date('Y-m-d', $start); - $end = date('Y-m-d', $end); - if($start > $end) - $errors['date'] = 'La fecha inicial no puede ser antes o el mismo dia que la final.'; - } - if (empty($startHour)) - $errors['startHour'] = 'Es necesario escoger el horario de la sesion.'; - - if (!is_numeric($idfilm) && $idfilm <= 0 ) - $errors['idfilm'] = 'No se ha seleccionado una pelicula.'; - - if(empty($errors)){ - - $msg = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $hall, $startHour, $startDate, $idfilm, $price, $format); - - if(strcmp($msg,$correct_response)!== 0) - $errors['global'] = $msg; - else - $data['message'] = $msg; - } - - if (!empty($errors)) { - $data['success'] = false; - $data['errors'] = $errors; - } else { - $data['success'] = true; - } - } - - echo json_encode($data); - break; - //Delete a session - case 'DELETE': - $errors = []; - $data = []; - - //Correct reply to verify the session has been correctly edited - $correct_response = 'Se ha eliminado la session con exito'; - - //Check if the body is ok - $entityBody = file_get_contents('php://input'); - $dictionary = json_decode($entityBody); - - if (!is_object($dictionary)) - $errors['global'] = 'El cuerpo de la petición no es valido'; - - $or_hall = $dictionary->{"og_hall"} ?? ""; - $or_date = $dictionary->{"og_date"} ?? ""; - $or_start = $dictionary->{"og_start"} ?? ""; - - //Check errors in inputs - if(empty($or_hall)) - $errors['global'] = 'El nº de sala a borrar no existe'; - if(empty($or_date)) - $errors['global'] = 'La fecha de donde borrar no existe'; - if(empty($or_start)) - $errors['global'] = 'La hora de donde borrar no existe'; - - if(empty($errors)){ - $msg = Session::delete_session($_SESSION["cinema"], $or_hall, $or_start, $or_date); - - if(strcmp($msg,$correct_response)!== 0) - $errors['global'] = $msg; - else - $data['message'] = $msg; - } - - if (!empty($errors)) { - $data['success'] = false; - $data['errors'] = $errors; - } else { - $data['success'] = true; - } - - echo json_encode($data); - - break; - default: - break; -} \ No newline at end of file diff --git a/panel_manager/includes/SessionForm.php b/panel_manager/includes/SessionForm.php deleted file mode 100644 index dfdb8dc..0000000 --- a/panel_manager/includes/SessionForm.php +++ /dev/null @@ -1,103 +0,0 @@ -allFilmData(); - - $form=' -
-
- - - - - - -
-
- Datos -
-
-
-
-
-
-
- -
-
-
- Horario -
-
- - - - -
-
-
-
- - -
-
-
- - -
- - -
-
-
-
-

titulo

-
-
-
iron man
-
-
  • Duración: duracion minutos
  • -
  • Lenguaje: idioma
  • -
    -
    -
    - -
    -
    - -
    -
    - '; - - return $form; - } - -} -?> \ No newline at end of file diff --git a/panel_manager/includes/formHall.php b/panel_manager/includes/formHall.php deleted file mode 100644 index c0baea2..0000000 --- a/panel_manager/includes/formHall.php +++ /dev/null @@ -1,226 +0,0 @@ -option = $option; - $this->cinema = $cinema; - if($hall) - $this->og_hall = $hall; - - if($option == "edit_hall" && $hall) - $options = array("action" => "./?state=".$option."&number=".$hall->getNumber()."&editing=true"); - else - $options = array("action" => "./?state=".$option."&editing=false"); - parent::__construct('formHall',$options); - } - - protected function generaCamposFormulario($data, $errores = array()){ - //Prepare the data - $number = $data['number'] ?? $this->og_hall->getNumber() ?? ""; - $rows = $data['rows'] ?? $this->og_hall->getNumRows() ?? "12"; - $cols = $data['cols'] ?? $this->og_hall->getNumCol() ?? "8"; - - //Init Seats_map - $seats = 0; - $seats_map = array(); - for($i = 1;$i <= $rows; $i++){ - for($j = 1; $j <= $cols; $j++){ - $seats_map[$i][$j] = "-1"; - } - } - $alltozero = $_POST["alltozero"] ?? 0; - //Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form - if($this->option == "edit_hall" && !isset($_GET["editing"])){ - $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(); - if($seat->getState()>=0){ - $seats++; - } - } - } - }//Show the checkbox seats_map updated and everything to selected if alltoone was pressed - else if(!$alltozero){ - $alltoone = $_POST["alltoone"] ?? 0; - for($i = 1;$i <= $rows; $i++){ - for($j = 1; $j <= $cols; $j++){ - 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')); - $errorRows = self::createMensajeError($errores, 'rows', 'span', array('class' => 'error')); - $errorCols = self::createMensajeError($errores, 'cols', 'span', array('class' => 'error')); - - $html = ' -
    '.$htmlErroresGlobales.' -
    - Mapa de Asientos - '.$errorSeats.' '.$errorRows.' '.$errorCols.' -
    -
    -
    - - '; - $html .=' -

    - '.$errorNumber.' - -
    - '; - if($this->option == "new_hall") - $html .=' - '; - if($this->option == "edit_hall"){ - $html .=' - - '; - } - if(!$errorCols && !$errorRows){ - $html .='
    -
    - - -

    Pantalla

    - - - - - '; - for($j = 1; $j<=$cols; $j++){ - $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 .= ' - -
    '.$j.'
    '.$i.'
    -
    '; - } else - $html .=''; - - return $html; - } - - //Process form: - protected function procesaFormulario($datos){ - $result = array(); - - $rows = $datos['rows']; - $cols = $datos['cols']; - - //Prepare the seat_map - $seats_map = array(); - $seats = 0; - for($i = 1;$i <= $rows; $i++){ - for($j = 1; $j <= $cols; $j++){ - if(isset($datos["checkbox".$i.$j])){ - $seats_map[$i][$j] = $datos["checkbox".$i.$j]; - $seats++; - if($seats_map[$i][$j] == "-1"){ - $seats_map[$i][$j] = "0"; - } - }else{ - $seats_map[$i][$j] = "-1"; - } - } - } - //Check input errors - if ($seats == 0 && isset($datos["sumbit"]) ) { - $result['seats'] = "
  • No puede haber 0 asientos disponibles.

  • "; - } - if ($rows <= 0) { - $result['rows'] = "
  • No puede haber 0 o menos filas.

  • "; - } - if ($cols <= 0) { - $result['cols'] = "
  • No puede haber 0 o menos columnas.

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

  • "; - } - else if (count($result) === 0 && isset($datos["sumbit"]) ) { - if($this->option == "new_hall"){ - $msg = Hall::create_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map); - FormHall::prepare_message( $msg ); - } - else if($this->option == "edit_hall"){ - if($this->og_hall) - $msg = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber()); - else - $msg = "La sala que intentas editar ya no existe"; - - FormHall::prepare_message( $msg ); - } - } - else if (!isset($result['number']) && isset($datos["delete"]) ) { - if($this->option == "edit_hall"){ - $msg = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber()); - FormHall::prepare_message( $msg ); - } - } - - - return $result; - } - - public static function prepare_message( $msg ){ - $_SESSION['message'] = "
    -
    -
    -
    -

    Operacion Completada


    -

    ".$msg."

    - -
    -
    -
    -
    - "; - } -} - -?> - diff --git a/panel_manager/index.php b/panel_manager/index.php deleted file mode 100644 index f4d1aa3..0000000 --- a/panel_manager/index.php +++ /dev/null @@ -1,159 +0,0 @@ - -
    -
    -
    -

    ¡ATENCIÓN!


    -

    Está viendo la web como un Usuario NO Registrado.

    - -
    -
    -
    - - "; - break; - case "view_ruser": - $_SESSION["rol"] = "user"; - unset($_SESSION["cinema"]); - $panel .= "
    -
    -
    -
    -

    ¡ATENCIÓN!


    -

    Está viendo la web como un Usuario Registrado.

    - -
    -
    -
    -
    - "; - break; - case "manage_halls": - $panel = Manager_panel::manage_halls(); - break; - case "new_hall": - $panel = Manager_panel::new_hall(); - break; - case "edit_hall": - $panel = Manager_panel::edit_hall(); - break; - case "manage_sessions": - $panel = Manager_panel::calendar(); - break; - default: - $panel = Manager_panel::welcomeAdmin($manager); - break; - } - } - else if($_SESSION["login"] && $_SESSION["rol"] === "manager"){ - - if(!isset($_SESSION['cinema'])){ - $bd = new Manager_DAO('complucine'); - if($bd){ - $user = unserialize($_SESSION["user"]); - $manager = $bd->GetManager($user->getId()); - $manager = $manager->fetch_assoc(); - - $_SESSION['cinema'] = $manager["idcinema"]; - } - } - - $state = isset($_GET['state']) ? $_GET['state'] : ''; - - switch($state){ - case "view_user": - $_SESSION["lastRol"] = $_SESSION["rol"]; - $_SESSION["rol"] = null; - unset($_SESSION["cinema"]); - $panel = "
    -
    -
    -
    -

    ¡ATENCIÓN!


    -

    Está viendo la web como un Usuario NO Registrado.

    - -
    -
    -
    -
    - "; - break; - case "view_ruser": - $_SESSION["lastRol"] = $_SESSION["rol"]; - $_SESSION["rol"] = "user"; - unset($_SESSION["cinema"]); - $panel = "
    -
    -
    -
    -

    ¡ATENCIÓN!


    -

    Está viendo la web como un Usuario Registrado.

    - -
    -
    -
    -
    - "; - break; - case "manage_halls": - $panel = Manager_panel::manage_halls(); - break; - case "new_hall": - $panel = Manager_panel::new_hall(); - break; - case "edit_hall": - $panel = Manager_panel::edit_hall(); - break; - case "manage_sessions": - $panel = Manager_panel::calendar(); - break; - default: - $panel = Manager_panel::welcome(); - break; - } - } - else{ - $panel = '
    -
    -
    -

    Debes iniciar sesión para ver el Panel de Manager.


    -

    Inicia Sesión con una cuenta de Gerente.

    - -
    -
    -
    '."\n"; - } - - //Specific page content: - $section = ' - - - -
    - -
    - '.$panel.' -
    -
    '; - - //General page content: - require RAIZ_APP.'/HTMLtemplate.php'; -?> diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php deleted file mode 100644 index d6be5fd..0000000 --- a/panel_manager/panel_manager.php +++ /dev/null @@ -1,223 +0,0 @@ -cinemaData($_SESSION["cinema"]); - $c_name = $cinema->getName(); - $c_dir = $cinema->getDirection(); - } - $name = strtoupper($_SESSION["nombre"]); - $userPic = USER_PICS.strtolower($name).".jpg"; - - $panel= '
    -

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

    -
    - user_profile_picture -

    '.strftime("%A %e de %B de %Y | %H:%M").'

    -

    Usuario: '.$name.'


    -

    Cine: '.$c_name.'

    -

    Dirección: '.$c_dir.'

    -
    '."\n"; - - return $panel; - } - - // Admin welcome panel allows to change the cinema linked to the admin-like-manager - static function welcomeAdmin() { - $cinemaList = new Cinema_DAO('complucine'); - $cinemas = $cinemaList->allCinemaData(); - - $bd = new Cinema_DAO('complucine'); - - $c_name = "Aun no se ha escogido un cine"; - - if($bd && $_SESSION["cinema"] ){ - - $cinema = $bd->cinemaData($_SESSION["cinema"]); - $c_name = $cinema->getName(); - $cinema = $cinema->getId(); - } - - $name = strtoupper($_SESSION["nombre"]); - $userPic = USER_PICS.strtolower($name).".jpg"; - - $panel= '
    -

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

    -
    -
    -
    - user_profile_picture -

    '.strftime("%A %e de %B de %Y | %H:%M").'

    -

    Usuario: '.$name.'


    -

    Como administrador puedes escoger el cine que gestionar

    -

    Cine: '.$c_name.'

    - -
    - - -
    -
    -
    - '; - - return $panel; - } - //Manage the sessions using full calendar js events and a pop up form which is constantly edited with more js - static function calendar(){ - if(isset($_SESSION["cinema"])){ - $hall = $_POST['hall'] ?? $_GET['hall'] ?? "1"; - $halls = Hall::getListHalls($_SESSION["cinema"]); - - if($halls){ - $panel =' -
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    '; - }else{ - $panel ='
    -

    No hay ninguna sala en este cine

    - Añadir Sala -
    '; - } - }else{ - $panel = '
    -

    Aun no se ha seleccionado un cine.

    -
    -

    >.<

    -

    Selecciona un cine en el panel principal

    -
    '."\n"; - } - return $panel; - - } - - static function manage_halls(){ - if(isset($_SESSION["cinema"])){ - $panel = '
    -
    '; - $listhall = Hall::getListHalls($_SESSION["cinema"]); - if(!$listhall){ - $panel .= "

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

    -
    '; - }else{ - $panel = '
    -

    Aun no se ha seleccionado un cine.

    -
    -

    >.<

    -

    Selecciona un cine en el panel principal

    -
    '."\n"; - } - return $panel; - } - - static function new_hall(){ - - $formHall = new FormHall("new_hall",$_SESSION["cinema"],new Hall(null, null, null, null, null, null)); - - $panel = '

    Crear una sala.



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

    Editar una sala.



    - '.$formHall->gestiona(); - return $panel; - } else{ - return Manager_panel::warning(); - } - } - - //this function is used as an answer to wrong url parameters accesing a formhall edit. The formsession version has been replaced by other js error replys - static function warning(){ - $panel = '
    -

    Ha habido un error.

    -
    -

    >.<

    -
    '."\n"; - - return $panel; - } - } -?>