Add files via upload

This commit is contained in:
Markines16 2021-05-20 12:00:33 +02:00 committed by GitHub
parent 52cc4cb49b
commit 62d0602d70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 16 deletions

View File

@ -18,17 +18,12 @@ class FormHall extends Form {
protected function generaCamposFormulario($data, $errores = array()){ protected function generaCamposFormulario($data, $errores = array()){
//Prepare the data //Prepare the data
if($this->option == "new_hall"){ $number = $data['number'] ?? $_POST["number"] ?? "";
$number = $data['number'] ?? ""; $rows = $data['rows'] ?? $_POST["rows"] ?? "12";
$rows = $data['rows'] ?? '12'; $cols = $data['cols'] ?? $_POST["cols"] ?? "8";
$cols = $data['cols'] ?? '8';
}else {
$number = $data['number'] ?? $_POST["number"];
$rows = $data['rows'] ?? $_POST["rows"];
$cols = $data['cols'] ?? $_POST["cols"];
}
$og_number = $data['og_number'] ?? $number; $og_number = $data['og_number'] ?? $number;
$og_rows = $data['og_rows'] ?? $rows;
$og_cols = $data['og_cols'] ?? $cols;
//Seats_map //Seats_map
$seats = 0; $seats = 0;
@ -41,6 +36,8 @@ class FormHall extends Form {
//Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form //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"]) ){ if(isset($data["restart"]) || isset($_POST["edit_hall"]) ){
$rows = $og_rows;
$cols = $og_cols;
$seat_list = Seat::getSeatsMap($og_number, $this->cinema); $seat_list = Seat::getSeatsMap($og_number, $this->cinema);
if($seat_list){ if($seat_list){
foreach($seat_list as $seat){ foreach($seat_list as $seat){
@ -70,13 +67,18 @@ class FormHall extends Form {
$htmlErroresGlobales = self::generaListaErroresGlobales($errores); $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorNumber = self::createMensajeError($errores, 'number', 'span', array('class' => 'error')); $errorNumber = self::createMensajeError($errores, 'number', 'span', array('class' => 'error'));
$errorSeats = self::createMensajeError($errores, 'seats', '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 = ' $html = '
<div class="column left">'.$htmlErroresGlobales.' '.$errorSeats.' <div class="column left">'.$htmlErroresGlobales.'
<fieldset> <fieldset>
<legend>Mapa de Asientos</legend> <legend>Mapa de Asientos</legend>
'.$errorSeats.' '.$errorRows.' '.$errorCols.'
<label> Filas: </label> <input type="number" name="rows" min="1" id="rows" value="'.$rows.'" required/> <br> <label> Filas: </label> <input type="number" name="rows" min="1" id="rows" value="'.$rows.'" required/> <br>
<input type="Hidden" name="og_rows" value="'.$og_rows.'"/> <br>
<label> Columnas: </label> <input type="number" name="cols" min="1" id="cols" value="'.$cols.'"required/> <br> <label> Columnas: </label> <input type="number" name="cols" min="1" id="cols" value="'.$cols.'"required/> <br>
<input type="Hidden" name="og_cols" value="'.$og_cols.'"/> <br>
<label> Asientos totales:'.$seats.' </label> <input type="hidden" name="seats" id="seats" value="'.$seats.'"readonly/> <br> <label> Asientos totales:'.$seats.' </label> <input type="hidden" name="seats" id="seats" value="'.$seats.'"readonly/> <br>
<input type="submit" name="alltoone" value="Activar todos los asientos" class="button large" />'; <input type="submit" name="alltoone" value="Activar todos los asientos" class="button large" />';
if($this->option == "edit_hall") if($this->option == "edit_hall")
@ -98,6 +100,7 @@ class FormHall extends Form {
<input type="submit" id="submit" name="delete" onclick="return confirm(\'Seguro que quieres borrar esta sala?\')" value="Eliminar Sala" class="black button" /> <input type="submit" id="submit" name="delete" onclick="return confirm(\'Seguro que quieres borrar esta sala?\')" value="Eliminar Sala" class="black button" />
'; ';
} }
if(!$errorCols && !$errorRows){
$html .='</div> $html .='</div>
<div class="column right"> <div class="column right">
<h3 class="table_title"> Pantalla </h3> <h3 class="table_title"> Pantalla </h3>
@ -133,6 +136,8 @@ class FormHall extends Form {
</tbody> </tbody>
</table> </table>
</div>'; </div>';
} else
$html .='</div>';
return $html; return $html;
} }
@ -168,6 +173,14 @@ class FormHall extends Form {
$result['seats'] = "<li> No puede haber 0 asientos disponibles. </li> <br>"; $result['seats'] = "<li> No puede haber 0 asientos disponibles. </li> <br>";
} }
if ($rows <= 0) {
$result['rows'] = "<li> No puede haber 0 o menos filas. </li> <br>";
}
if ($cols <= 0) {
$result['cols'] = "<li> No puede haber 0 o menos columnas. </li> <br>";
}
$number = $datos['number'] ?? null; $number = $datos['number'] ?? null;
if (empty($number) && isset($datos["sumbit"])) { if (empty($number) && isset($datos["sumbit"])) {

View File

@ -56,7 +56,6 @@
"; ";
} }
} }
$panel .= ' <input type="submit" name="change" value="Cambiar" /><br> $panel .= ' <input type="submit" name="change" value="Cambiar" /><br>
</select> </select>
</form> </form>
@ -108,7 +107,7 @@
<input name="rows" type="hidden" value="'. $hall->getNumRows().'"/> <input name="rows" type="hidden" value="'. $hall->getNumRows().'"/>
<input name="cols" type="hidden" value="'. $hall->getNumCol().'"/> <input name="cols" type="hidden" value="'. $hall->getNumCol().'"/>
<input name="seats" type="hidden" value="'.$hall->getTotalSeats().'"/> <input name="seats" type="hidden" value="'.$hall->getTotalSeats().'"/>
<td> <input type="submit" id="submit" name ="edit_hall" formaction="./?state=edit_hall&number='.$hall->getNumber().'" value="Editar" class="primary" /> </td> <td> <input type="submit" id="submit" name ="edit_hall" formaction="./?state=edit_hall" value="Editar" class="primary" /> </td>
</form> </form>
</tr>'; </tr>';
} }