";
- if($film["tittle"]){
- $htmlform .= "
-
-
-
".str_replace('_', ' ',$film["tittle"])."
-
-
-
".$film["description"]."
-
-
Duración: ".$film["duration"]." minutos
-
-
-";
+
+
-';
- return $htmlform;
+
+ return $html;
}
//Methods:
//Process form:
- public static function processesForm($data){
- if($data["option"] == "new_session"){
- $_SESSION['msg'] = Session::create_session($data);
- header( "Location: ../?state=success" );
- }else if($data["option"] == "edit_session"){
- $_SESSION['msg'] = Session::edit_session($data);
- header( "Location: ../?state=success" );
+ protected function procesaFormulario($data){
+ $result = array();
+
+ $film = $data['film'] ;
+ $hall = $data['hall'] ;
+ $date = $data['date'] ;
+ $start = $data['start'];
+ $price = $data['price'] ;
+ $format = $data['format'] ?? null ;
+ $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 (empty($format) && isset($data["sumbit"])) {
+ $result['format'] = "
El formato no puede estar vacio. ";
+ }
+
+ 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);
+ $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);
+ $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);
+ $result = './?state=success';
}
- else if($data["option"] == "delete_session") {
- $_SESSION['msg'] = Session::delete_session($data);
- header( "Location: ../?state=success" );
- }
+
+ return $result;
}
}