option = $option; $this->cinema = $cinema; $options = array("action" => "./?state=".$option); 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; //Seats_map $seats = 0; $seats_map = array(); for($i = 1;$i <= $rows; $i++){ for($j = 1; $j <= $cols; $j++){ $seats_map[$i][$j] = "-1"; } } //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($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{ $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 = '
'; for($j = 1; $j<=$cols; $j++){ $html .= ' | '.$j.' | '; } $html .= '|
---|---|---|
'.$i.' | '; for($j=1; $j<=$cols; $j++){ if($seats_map[$i][$j]>=0){ $html .= '';} else { $html .= ' | ';} } $html .=' |