diff --git a/purchase/confirm.php b/purchase/confirm.php deleted file mode 100644 index 9ec899c..0000000 --- a/purchase/confirm.php +++ /dev/null @@ -1,19 +0,0 @@ -gestiona(); - - //Page-specific content: - $section = '
-

Completar la Compra


- - '.$formHTML.' -
'; - - //General page content: - require RAIZ_APP.'/HTMLtemplate.php'; -?> \ No newline at end of file diff --git a/purchase/includes/formPurchase.php b/purchase/includes/formPurchase.php deleted file mode 100644 index 86a6e79..0000000 --- a/purchase/includes/formPurchase.php +++ /dev/null @@ -1,232 +0,0 @@ -session = $sessionDAO->sessionData($_POST["sessions"]); - - $filmDAO = new Film_DAO("complucine"); - $this->film = $filmDAO->FilmData($this->session->getIdfilm()); - - $cinemaDAO = new Cinema_DAO("complucine"); - $this->cinema = $cinemaDAO->cinemaData($this->session->getIdcinema()); - - $hallDAO = new HallDAO("complucine"); - $this->hall = $hallDAO->HallData($this->session->getIdhall()); - - $this->seat = array(); - $this->row = array(); - $this->col = array(); - $rows = $this->hall->getNumRows(); - $cols = $this->hall->getNumCol(); - for($i = 0; $i <= $rows; $i++){ - for($j = 0; $j <= $cols; $j++){ - $seat = $i.$j; - if(isset($_POST["checkbox".$seat])){ - array_push($this->seat, $i."-".$j); - array_push($this->row, $i); - array_push($this->col, $j); - } - } - } - - $promoDAO = new Promotion_DAO("complucine"); - $this->code = intval(0); - if(isset($_POST["code"]) && $_POST["code"] !== ""){ - if($promoDAO->GetPromotion($_POST["code"])->data_seek(0)){ - $this->code = intval(2); - } - } - - $TODAY = getdate(); - $year = "$TODAY[year]"; - - $this->_TODAY = "$TODAY[year]-$TODAY[month]-$TODAY[mday] $TODAY[hours]:$TODAY[minutes]:$TODAY[seconds]"; - - $this->years = array(); - for($i = $year; $i < $year+10; $i++) array_push($this->years, $i); - - $this->months = array(); - for($i = 1; $i <= 12; $i++) array_push($this->months, $i); - } - - protected function generaCamposFormulario($datos, $errores = array()){ - - // Se generan los mensajes de error si existen. - $htmlErroresGlobales = self::generaListaErroresGlobales($errores); - $errorNombre = self::createMensajeError($errores, 'card-holder', 'span', array('class' => 'error')); - $errorCardNumber = self::createMensajeError($errores, 'card-number-0', 'span', array('class' => 'error')); - $errorCVV = self::createMensajeError($errores, 'card-cvv', 'span', array('class' => 'error')); - $errorCardExpirationMonth = self::createMensajeError($errores, 'card-expiration-month', 'span', array('class' => 'error')); - $errorCardExpirationYear = self::createMensajeError($errores, 'card-expiration-year', 'span', array('class' => 'error')); - - $monthsHTML = ""; - foreach($this->months as $value){ - $monthsHTML .= ""; - } - - $yearsHTML = ""; - foreach($this->years as $value){ - $yearsHTML .= ""; - } - - if($this->session->getSeatsFull()){ - $html = "
-

La sesión está llena, no quedan asientos disponibles.


-

Vuelva atrás para selecionar otra sesión.

-
"; - } else { - if(!empty($this->seat)){ - $seats = ""; - foreach($this->seat as $value){ - $seats .= $value.", "; - } - - $promo = ""; - if($this->code > 0) $promo = "
(Se ha aplicado un descuento por código promocional).
"; - - $html = "
-
- Resumen de la Compra - ".$this->film->getTittle()." -

Película: ".str_replace('_', ' ', strtoupper($this->film->getTittle()))."

-

Cine: ".$this->cinema->getName()."

-

Sala: ".$this->session->getIdhall()."

-

Asiento(s):".$seats."

-

Fecha: ".date_format(date_create($this->session->getDate()), 'd-m-Y')."

-

Hora: ".$this->session->getStartTime()."

-

Precio Total: ".intval($this->session->getSeatPrice()*count($this->seat)-$this->code)."€ (Precio por asiento: ".$this->session->getSeatPrice()." €)

-

".$promo."

-
-
".$htmlErroresGlobales."
- Datos Bancarios -
".$errorNombre."

- -
-
".$errorCardNumber."

- - - - - -
".$errorCVV."
-
-
".$errorCardExpirationMonth.$errorCardExpirationYear."

- - -
-
- - - - - -
-
"; - } else { - $html = "
-

No se ha seleccionado asiento(s).

-

Vuelva atrás para selecionar una butaca.

- -
"; - } - } - return $html; - } - - protected function procesaFormulario($datos){ - $result = array(); - - $nombre = $this->test_input($datos['card-holder']) ?? null; - $nombre = strtolower($nombre); - if ( empty($nombre) ) { - $result['card-holder'] = "El nombre no puede estar vacío."; - } - - for($i = 0; $i < 4; $i++){ - $card_numer = $this->test_input($datos['card-number-'.$i]) ?? null; - if ( empty($card_numer) || mb_strlen($card_numer) < 4 ) { - $result['card-number-0'] = "La tarjeta debe tener 16 dígitos."; - } - } - - $cvv = $this->test_input($datos['card-cvv']) ?? null; - if ( empty($cvv) || mb_strlen($cvv) < 3 ) { - $result['card-cvv'] = "El CVV debe tener 3 números."; - } - - $month = $this->test_input($datos['card-expiration-month']) ?? null; - //$TODAY = getdate(); - //$actualMonth = "$TODAY[month]"; - if ( empty($month) /*|| $month < $actualMonth*/) { - $result['card-expiration-month'] = "El mes de expiración no es correcto."; - } - - $year = $this->test_input($datos['card-expiration-year']) ?? null; - if ( empty($year) ) { - $result['card-expiration-year'] = "El año de expiración no es correcto."; - } - - if (count($result) === 0) { - if(isset($_SESSION["login"]) && $_SESSION["login"] == true){ - $purchaseDAO = new PurchaseDAO("complucine"); - $count = count(unserialize($datos["row"])); - $rows = unserialize($datos["row"]); $cols = unserialize($datos["col"]); - for($i = 0; $i < $count; $i++){ - if($purchaseDAO->createPurchase(unserialize($_SESSION["user"])->getId(), $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), $rows[$i], $cols[$i], date("Y-m-d H:i:s"))){ - $purchase = new Purchase(unserialize($_SESSION["user"])->getId(), $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), $datos["row"], $datos["col"], strftime("%A %e de %B de %Y a las %H:%M")); - - $_SESSION["purchase"] = serialize($purchase); - $_SESSION["film_purchase"] = serialize($this->film); - $result = "resume.php"; - } else { - $result[] = "Error al realizar la compra."; - } - } - } else { - $purchase = new Purchase("null", $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), $datos["row"], $datos["col"], strftime("%A %e de %B de %Y a las %H:%M")); - $_SESSION["purchase"] = serialize($purchase); - $_SESSION["film_purchase"] = serialize($this->film); - $result = "resume.php"; - } - } - - return $result; - } -} -?> \ No newline at end of file diff --git a/purchase/includes/formSelectCinemaSession.php b/purchase/includes/formSelectCinemaSession.php deleted file mode 100644 index a96f0fd..0000000 --- a/purchase/includes/formSelectCinemaSession.php +++ /dev/null @@ -1,272 +0,0 @@ - "selectSeat.php"); - parent::__construct('formSelectCinemaSession', $options); - - $TODAY = getdate(); - $this->_TODAY = "$TODAY[mday]"."-"."$TODAY[mon]"."-"."$TODAY[year]"; - - } - - protected function generaCamposFormulario($datos, $errores = array()){ - $cinemas = []; - $sessions = []; - - // Se generan los mensajes de error, si existen. - $htmlErroresGlobales = self::generaListaErroresGlobales($errores); - $errorCinema = self::createMensajeError($errores, 'cinemas', 'span', array('class' => 'error')); - $errorFilm = self::createMensajeError($errores, 'films', 'span', array('class' => 'error')); - $errorSession = self::createMensajeError($errores, 'sessions', 'span', array('class' => 'error')); - $errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error')); - - $pay = true; - if(isset($_GET["film"])){ - $filmDAO = new Film_DAO("complucine"); - $film = $filmDAO->FilmData($_GET["film"]); - if($film){ - $tittle = $film->getTittle(); - $image = $film->getImg(); - - $cinemas = $filmDAO->getCinemas($_GET["film"]); - $cinema_id = $_GET["cinema"]; - if(!empty($cinemas)){ - $cinemasNames = new ArrayIterator(array()); - $cinemasIDs = new ArrayIterator(array()); - foreach($cinemas as $key=>$value){ - $cinemasIDs[$key] = $value->getId(); - $cinemasNames[$key] = $value->getName(); - } - $cinemasIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); - $cinemasIT->attachIterator($cinemasIDs, "cID"); - $cinemasIT->attachIterator($cinemasNames, "NAME"); - - $cinemasListHTML = '
'.$htmlErroresGlobales.'
- -
'; - } else { - $cinemasListHTML = ''; - } - - $fiml_id = $film->getId(); - - if(isset($cinema_id)){ - $sessionsDAO = new SessionDAO("complucine"); - $sessions = $sessionsDAO->getSessions_Film_Cinema($fiml_id, $cinema_id); - if(!empty($sessions)){ - $sessionsDates = new ArrayIterator(array()); - $sessionsStarts = new ArrayIterator(array()); - $sessionsHalls = new ArrayIterator(array()); - $sessionsIDs = new ArrayIterator(array()); - foreach($sessions as $key=>$value){ - $sessionsIDs[$key] = $value->getId(); - $sessionsDates[$key] = date_format(date_create($value->getDate()), 'j-n-Y'); - $sessionsHalls[$key] = $value->getIdhall(); - $sessionsStarts[$key] = $value->getStartTime(); - } - $sessionsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); - $sessionsIT->attachIterator($sessionsIDs, "sID"); - $sessionsIT->attachIterator($sessionsDates, "DATE"); - $sessionsIT->attachIterator($sessionsHalls, "HALL"); - $sessionsIT->attachIterator($sessionsStarts, "HOUR"); - - $count = 0; - $sessionsListHTML = ''; - - if($count == 0) { - $sessionsListHTML = ''; - $pay = false; - } - } else { - $sessionsListHTML = ''; - $pay = false; - } - } else { - $sessionsListHTML = ''; - $pay = false; - } - - //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema. - $html = '
-

Película seleccionada: '.str_replace('_', ' ', $tittle).'


-
'.$tittle.'
-

Duración: '.$film->getDuration().' minutos

-

Idioma: '.$film->getLanguage().'

-
-
-

Seleccione un Cine y una Sesión


-

Cines

- '.$cinemasListHTML.' -

Sesiones

- '.$sessionsListHTML.' -

Aplicar código promocional

-
'.$errorCode.'
-
'; - } else { - $html = '

No existe la película.

'; - $pay = false; - } - } else if(isset($_GET["cinema"])) { - $pay = false; - $cinemaDAO = new Cinema_DAO("complucine"); - $cinema = $cinemaDAO->cinemaData($_GET["cinema"]); - if($cinema){ - $cinema_name = $cinema->getName(); - $cinema_address = $cinema->getDirection(); - $cinema_tlf = $cinema->getPhone(); - - $films = $cinemaDAO->getFilms($_GET["cinema"]); - $film_id = $_GET["film"]; - if(!empty($films)){ - $filmsNames = new ArrayIterator(array()); - $filmsIDs = new ArrayIterator(array()); - foreach($films as $key=>$value){ - $filmsIDs[$key] = $value->getId(); - $filmsNames[$key] = str_replace('_', ' ', $value->getTittle()); - } - $filmsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); - $filmsIT->attachIterator($filmsIDs, "fID"); - $filmsIT->attachIterator($filmsNames, "NAME"); - - $filmsListHTML = '
'.$htmlErroresGlobales.'
- -
'; - - } else { - $filmsListHTML = ''; - } - - //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema. - $html = '
-

Cine seleccionado: '.$cinema_name.'


-
'.$cinema_name.'
-

Dirección: '.$cinema_address.'

-

Teléfono: '.$cinema_tlf.'

-
-
-

Seleccione una Película y una Sesión


-

Películas

- '.$filmsListHTML.' -

Sesiones

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

No existe el cine.

'; - $pay = false; - } - } else { - $html = '

No se ha encontrado película ni cine.

- '; - $pay = false; - } - - //Select seat button: - if($pay){ - $pay = ''; - } else { - $pay = ''; - } - - return ' -
- '.$html.' -
-
- '.$pay.' -
'; - } - - protected function procesaFormulario($datos){ - $result = array(); - - $cinema = $this->test_input($datos['cinemas']) ?? null; - if ( empty($cinema) ) { - $result['cinemas'] = "Selecciona un cine."; - } - - $films = $this->test_input($datos['films']) ?? null; - if ( empty($films) ) { - $result['films'] = "Selecciona una película."; - } - - $session = $this->test_input($datos['sessions']) ?? null; - if ( empty($session) ) { - $result['sessions'] = "Selecciona una sesión."; - } - - $code = $this->test_input($datos['code']) ?? null; - $avaliable = "../assets/php/common/checkPromo.php?code=".$code; - if ( !empty($code) && mb_strlen($code) != 8 && $avaliable === "avaliable") { - $result['code'] = "El código promocional no es válido."; - } - - if (count($result) === 0) { - $result = "selectSeat.php"; - } - - return $result; - } -} -?> \ No newline at end of file diff --git a/purchase/includes/formSelectSeat.php b/purchase/includes/formSelectSeat.php deleted file mode 100644 index 6eb4e99..0000000 --- a/purchase/includes/formSelectSeat.php +++ /dev/null @@ -1,108 +0,0 @@ - "confirm.php"); - parent::__construct('formSelectSeat', $options); - - } - - protected function generaCamposFormulario($datos, $errores = array()){ - - // Se generan los mensajes de error, si existen. - $htmlErroresGlobales = self::generaListaErroresGlobales($errores); - $errorSeat = self::createMensajeError($errores, 'seats', 'span', array('class' => 'error')); - - $sessionDAO = new SessionDAO("complucine"); - $session = $sessionDAO->sessionData($_POST["sessions"]); - - $hallDAO = new HallDAO("complucine"); - $hall = $hallDAO->HallData($session->getIdhall()); - - $seatDAO = new SeatDAO("complucine"); - $seats = $seatDAO->getAllSeats($session->getIdhall(), $session->getIdcinema()); - - $rows = $hall->getNumRows(); - $cols = $hall->getNumCol(); - - //$seats = $hall->getTotalSeats(); - $seats_map = array(); - - for($i = 1; $i <= $rows; $i++){ - for($j = 1; $j <= $cols; $j++){ - $seats_map[$i][$j] = $seats[$i]->getState(); - } - } - $html ='

Seleccionar un Asiento


-

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.'
'; - - //Pay button: - $pay = ' - - '; - - return ' -
- '.$html.' -
-
- '.$pay.' -
'; - } - - protected function procesaFormulario($datos){ - $result = array(); - - if (count($result) === 0) { - $result = "confirm.php"; - } - - return $result; - } -} -?> \ No newline at end of file diff --git a/purchase/index copy.php b/purchase/index copy.php deleted file mode 100644 index 4ff77de..0000000 --- a/purchase/index copy.php +++ /dev/null @@ -1,153 +0,0 @@ -FilmData($_GET["film"]); - if($film){ - $tittle = $film->getTittle(); - - $cinemas = $filmDAO->getCinemas($_GET["film"]); - if(!empty($cinemas)){ - $cinemasNames = new ArrayIterator(array()); - $cinemasIDs = new ArrayIterator(array()); - foreach($cinemas as $key=>$value){ - $cinemasIDs[$key] = $value->getId(); - $cinemasNames[$key] = $value->getName(); - } - $cinemasIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); - $cinemasIT->attachIterator($cinemasIDs, "cID"); - $cinemasIT->attachIterator($cinemasNames, "NAME"); - - $cinemasListHTML = '
- '; - } else { - $cinemasListHTML = '
'; - } - - $fiml_id = $film->getId(); - $cinema_id = $value["cID"]; - - $sessionsDAO = new SessionDAO("complucine"); - $sessions = $sessionsDAO->getSessions_Film_Cinema($fiml_id, $cinema_id); - if(!empty($sessions)){ - $sessionsDates = new ArrayIterator(array()); - $sessionsStarts = new ArrayIterator(array()); - $sessionsHalls = new ArrayIterator(array()); - $sessionsIDs = new ArrayIterator(array()); - foreach($sessions as $key=>$value){ - $sessionsIDs[$key] = $value->getId(); - $sessionsDates[$key] = date_format(date_create($value->getDate()), 'j-n-Y'); - $sessionsHalls[$key] = $value->getIdhall(); - $sessionsStarts[$key] = $value->getStartTime(); - } - $sessionsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); - $sessionsIT->attachIterator($sessionsIDs, "sID"); - $sessionsIT->attachIterator($sessionsDates, "DATE"); - $sessionsIT->attachIterator($sessionsHalls, "HALL"); - $sessionsIT->attachIterator($sessionsStarts, "HOUR"); - - $count = 0; - $sessionsListHTML = ''; - - if($count == 0) { - $sessionsListHTML = ''; - $pay = false; - } - } else { - $sessionsListHTML = ''; - $pay = false; - } - - //$session_id = $value["sID"]; - //$hall_id = $value["HALL"]; - //$date_ = $value["DATE"]; - //$hour_ = $value["HOUR"]; - - //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema. - $reply = '
-

Película seleccionada: '.str_replace('_', ' ', $tittle).'


-
'.$tittle.'
-

Duración: '.$film->getDuration().' minutos

-

Idioma: '.$film->getLanguage().'

-
-
-

Seleccione un Cine y una Sesión


-

Cines

- '.$cinemasListHTML.' -

Sesiones

- '.$sessionsListHTML.' -
- '; - } else { - $reply = '

No existe la película.

'; - $pay = false; - } - } else if(isset($_GET["cinema"])) { - $reply = '

ESTAMOS TRABAJANDO EN ELLO

'; - $pay = false; - } else { - $reply = '

No se ha encontrado película ni cine.

'; - $pay = false; - } - - - //Pay button: - if($pay){ - $pay = ' - '; - } else { - $pay = ''; - } - //Page-specific content: - $section = ' -
-
-
- '.$reply.' -
-
- '.$pay.' -
-
-
- '; - - //General page content: - require RAIZ_APP.'/HTMLtemplate.php'; -?> diff --git a/purchase/index.php b/purchase/index.php deleted file mode 100644 index dfc52ab..0000000 --- a/purchase/index.php +++ /dev/null @@ -1,23 +0,0 @@ -gestiona(); - - //Page-specific content: - $section = ' -
-
- '.$formHTML.' -
-
- '; - - //General page content: - require RAIZ_APP.'/HTMLtemplate.php'; - - //TO-DO: añadir selección de butaca y elegir promociones y enviar con el POST. -?> diff --git a/purchase/resume.php b/purchase/resume.php deleted file mode 100644 index f29c2b9..0000000 --- a/purchase/resume.php +++ /dev/null @@ -1,81 +0,0 @@ -sessionData($purchase->getSessionId()); - $cinemaDAO = new Cinema_DAO("complucine"); - $cinema = $cinemaDAO->cinemaData($purchase->getCinemaId()); - - $seatsArray = array_combine(unserialize($purchase->getRow()), unserialize($purchase->getColumn())); - $seats = ""; - for($i=0; $i < count(unserialize($purchase->getRow())); $i++){ - $seats .= unserialize($purchase->getRow())[$i]."-".unserialize($purchase->getColumn())[$i].", "; - } - - unset($_SESSION["purchase"]); - unset($_SESSION["film_purchase"]); - - $reply = "

Se ha realizado su compra con éxito, a continuación puede ver el resumen:


-
- ".$film_purchase->getTittle()." -

Película: ".str_replace('_', ' ', strtoupper($film_purchase->getTittle()))."

-

Duración: ".$film_purchase->getDuration()." minutos

-

Idioma: ".$film_purchase->getLanguage()."

-

Precio: ".$session->getSeatPrice()*count(unserialize($purchase->getRow()))." €

-
-
-

Sesión (Fecha): ".$session->getDate()."

-

Sesión (Hora): ".$session->getStartTime()."

-

Cine: ".$cinema->getName()."

-

Sala: ".$purchase->getHallId()."

-

Asiento(s): ".$seats."

-

Fecha de la Compra: ".$purchase->getTime()."

-
- "; - - if(isset($_SESSION["login"]) && $_SESSION["login"] == true){ - $actions = '

Guarde esta información y enséñela para entrar al cine.


-

Se ha guardado la información de la compra en su panel de usuario.

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

Guarde esta información y enséñela para entrar al cine.


-