option = $option; $this->cinema = $cinema; $options = array("action" => "./?state=".$option); parent::__construct('formSession',$options); } //TODO Edit session no funciona correctamente con el seleccionar una pelicula distinta, hay que guardar la id de la sesion de alguna forma y usarla o guardar en la sesion protected function generaCamposFormulario($data, $errores = array()){ $filmList = new Film_DAO('complucine'); $films = $filmList->allFilmData(); if($this->option == "new_session") { $film = $data['film'] ?? 1; $hall = $data['hall'] ?? $_POST["hall"]; $date = $data['date'] ?? $_POST["date"]; $start = $data['start'] ?? ''; $price = $data['price'] ?? ''; $format = $data['format'] ?? ''; } else { $film = $data['film'] ?? $_POST["film"]; $hall = $data['hall'] ?? $_POST["hall"]; $date = $data['date'] ?? $_POST["date"]; $start = $data['start'] ?? $_POST["start"]; $price = $data['price'] ?? $_POST["price"]; $format = $data['format'] ?? $_POST["format"]; } $or_hall = $data["or_hall"] ?? $hall; $or_date = $data["or_date"] ?? $date; $or_start = $data["or_start"] ?? $start; $htmlErroresGlobales = self::generaListaErroresGlobales($errores); $errorPrice = self::createMensajeError($errores, 'price', 'span', array('class' => 'error')); $errorFormat = self::createMensajeError($errores, 'format', 'span', array('class' => 'error')); $html = '
'.$htmlErroresGlobales.' '.$errorPrice.'
Datos
'.$errorFormat.'
Horario

'; if($film){ if($this->option == "new_session") $html .= '

'; if($this->option == "edit_session"){ $html .= '

'; } } $html .= '
'; return $html; } //Methods: //Process form: protected function procesaFormulario($data){ $result = array(); $film = $data['film'] ; $hall = $data['hall'] ; $date = $data['date'] ; $start = $data['start']; $price = $data['price'] ; $format = $data['format'] ; $repeat = $data['repeat'] ?? 0; $or_hall = $data["or_hall"] ; $or_date = $data["or_date"] ; $or_start = $data["or_start"] ; if (($price == 0 || empty($price))&& isset($data["sumbit"]) ) { $result['price'] = "
  • No puede haber 0 euros.

  • "; } if (count($result) === 0 && isset($data["sumbit"]) ) { if($this->option == "new_session"){ $_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($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($this->cinema, $or_hall, $or_start, $or_date); $result = './?state=success'; } return $result; } } ?>