Add files via upload
This commit is contained in:
parent
993f70a373
commit
89669ce53e
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/common/hall_dao.php');
|
||||
include_once('../assets/php/common/hall_dao.php');
|
||||
|
||||
class Hall{
|
||||
|
||||
@ -25,18 +25,6 @@
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function create_hall($hall){
|
||||
$bd = new HallDAO('complucine');
|
||||
if($bd ){
|
||||
if(!$bd->searchHall($hall['cinema'], $hall['number'])){
|
||||
$bd->createHall($hall['number'], $hall['cinema'], $hall['cols'], $hall['rows']);
|
||||
return "Se ha creado la sala con exito";
|
||||
} else {
|
||||
return "Esta sala ya existe";
|
||||
}
|
||||
} else { return "Error al conectarse a la base de datos"; }
|
||||
}
|
||||
|
||||
//Getters && Setters:
|
||||
public function setNumber($number){ $this->_number = $number; }
|
||||
public function getNumber(){ return $this->_number; }
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/common/session_dao.php');
|
||||
include_once($prefix.'panel_admin/includes/film.php');
|
||||
include_once($prefix.'assets/php/common/film_dao.php');
|
||||
include_once('session_dao.php');
|
||||
include_once('film.php');
|
||||
include_once('film_dao.php');
|
||||
|
||||
class Session{
|
||||
|
||||
@ -55,34 +55,6 @@
|
||||
|
||||
} else return "Error al conectarse a la base de datos";
|
||||
}
|
||||
|
||||
public static function edit_session($session){
|
||||
$bd = new SessionDAO('complucine');
|
||||
if($bd ){
|
||||
if($bd->searchSession($session['cinema'], $session['origin_hall'],$session['origin_start'],$session['origin_date'])){
|
||||
$origin = array("cinema" => $session['cinema'],"hall" => $session['origin_hall'],"start" => $session['origin_start'],"date" => $session['origin_date']);
|
||||
$bd->editSession($session['film'], $session['hall'], $session['cinema'], $session['date'],
|
||||
$session['start'], $session['price'], $session['format'],$origin);
|
||||
return "Se ha editado la session con exito";
|
||||
} else
|
||||
return "Esta session no existe";
|
||||
|
||||
} else return "Error al conectarse a la base de datos";
|
||||
}
|
||||
|
||||
public static function delete_session($session){
|
||||
$bd = new SessionDAO('complucine');
|
||||
if($bd ){
|
||||
if($bd->searchSession($session['cinema'], $session['hall'],$session['start'],$session['date'])){
|
||||
$bd->deleteSession($session['hall'], $session['cinema'], $session['date'], $session['start']);
|
||||
return "Se ha eliminado la session con exito";
|
||||
} else
|
||||
return "Esta session no existe";
|
||||
|
||||
} else return "Error al conectarse a la base de datos";
|
||||
}
|
||||
|
||||
|
||||
//Esto deberia estar en film.php? seguramente
|
||||
public static function getFilmTitle($idfilm){
|
||||
$bd = new Film_DAO('complucine');
|
||||
|
@ -67,7 +67,7 @@
|
||||
return $sessions;
|
||||
}
|
||||
|
||||
public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin){
|
||||
public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
||||
$format = $this->mysqli->real_escape_string($format);
|
||||
$date = date('Y-m-d', strtotime( $date ) );
|
||||
$startTime = date('H:i:s', strtotime( $startTime ) );
|
||||
@ -77,7 +77,7 @@
|
||||
`start_time` = '%s', `seat_price` = '%d', `format` = '%s'
|
||||
WHERE
|
||||
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
|
||||
$idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin["cinema"],$origin["hall"],$origin["date"],$origin["start"]);
|
||||
$idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $_SESSION["cinema"],$_SESSION["hall"],$_SESSION["date"],$_SESSION["start"]);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
|
@ -7,10 +7,15 @@
|
||||
define('BD_USER', 'sw');
|
||||
define('BD_PASS', '_admin_');
|
||||
|
||||
/**
|
||||
* Temprarl files directory.
|
||||
/*
|
||||
* Configuration parameters used to generate URLs and file paths in the application
|
||||
*/
|
||||
define('TMP_DIR', __DIR__.'/img/');
|
||||
define('ROUTE_APP', '/'); //Change if it´s necessary.
|
||||
|
||||
/**
|
||||
* Image files directory.
|
||||
*/
|
||||
define('IMG_DIR', ROUTE_APP.'img/');
|
||||
|
||||
/**
|
||||
* Utf-8 support settings, location (language and country) and time zone.
|
||||
|
@ -186,14 +186,14 @@
|
||||
|
||||
case "manager": array_push($menus, "<li>Ver como...
|
||||
<ul>
|
||||
<a href='./?state=view_user'><li>Usuario</li></a>
|
||||
<a href='./?state=view_ruser'><li>Usuario registrado</li></a>
|
||||
<a href='./?state=us_u'><li>Usuario</li></a>
|
||||
<a href='./?state=us_r'><li>Usuario registrado</li></a>
|
||||
</ul>
|
||||
</li>");
|
||||
array_push($menus, "<li>Modificar
|
||||
<ul>
|
||||
<a href='./?state=manage_halls'><li>Salas</li></a>
|
||||
<a href='./?state=manage_sessions'><li>Sesiones</li></a>
|
||||
<a href='./?state=rooms'><li>Salas</li></a>
|
||||
<a href='./?state=sessions'><li>Sesiones</li></a>
|
||||
</ul>
|
||||
</li>");
|
||||
break;
|
||||
|
@ -91,16 +91,17 @@ class FormFilm extends Form {
|
||||
|
||||
//Validate promotional film image.
|
||||
$file_name = $_FILES['file']['name'];
|
||||
$file_type = $_FILES['file']['type'];
|
||||
//$file_type = $_FILES['file']['type'];
|
||||
$file_size = $_FILES['file']['size'];
|
||||
if (strpos($file_type, "jpg") && $file_size < 100000) {
|
||||
$uploadFile = TMP_DIR . basename($_FILES['file'][$_tittle]);
|
||||
if(isset($file_name) && $file_name != ""
|
||||
&& strpos($file_name, "jpg") && $file_size < 100000){
|
||||
$uploadFile = IMG_DIR . basename($_FILES['file'][$_tittle]);
|
||||
if (!move_uploaded_file($file_name, $uploadFile)){
|
||||
print_r($_FILES);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$this->correct =false;
|
||||
$this->correct = false;
|
||||
}
|
||||
|
||||
//Habria que validar todo para que encaje en la base de datos
|
||||
|
@ -19,7 +19,7 @@
|
||||
<input type="number" name="duration" id="duration" placeholder="Duración" />
|
||||
<input type="text" name="language" id="language" placeholder="Idioma" />
|
||||
<input type="text" name="description" id="description" placeholder="Descripción" />
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" placeholder="Imagen promocional" /></div>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir pelicula" name="add_film" class="primary" />
|
||||
@ -61,7 +61,7 @@
|
||||
echo'<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h2>Editar pelicula</h2>
|
||||
<form method="post" action="index.php?state=mf">
|
||||
<form method="post" enctype="multipart/form-data" action="index.php?state=mf">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>Datos de pelicula</legend>
|
||||
@ -70,7 +70,7 @@
|
||||
<input type="number" name="duration" id="duration" value='.$_POST['duration'].' />
|
||||
<input type="text" name="language" id="language" value="'.$_POST['language'].'" />
|
||||
<input type="text" name="description" id="description" value="'.$_POST['description'].'"/>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" placeholder="Imagen promocional" /></div>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Editar" name="confirm_edit_film" class="primary" />
|
||||
|
@ -34,9 +34,6 @@
|
||||
};
|
||||
break;
|
||||
case 'mf': require_once('manage_films.php');
|
||||
//echo $_SERVER['DOCUMENT_ROOT']."/../img";
|
||||
echo TMP_DIR;
|
||||
//echo $_SERVER['PHP_SELF'];
|
||||
if(isset($_POST['edit_film'])) {
|
||||
editFilm();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ require_once($prefix.'assets/php/common/session_dao.php');
|
||||
require_once($prefix.'assets/php/common/session.php');
|
||||
require_once($prefix.'assets/php/form.php');
|
||||
|
||||
require_once($prefix.'panel_admin/includes/film.php');
|
||||
require_once($prefix.'assets/php/common/film.php');
|
||||
require_once($prefix.'assets/php/common/film_dao.php');
|
||||
|
||||
//Receive data from froms and prepare the correct response
|
||||
@ -31,7 +31,7 @@ class FormSession extends Form {
|
||||
<form method="post" id="'.$data['option'].'" action="./includes/processForm.php"\>
|
||||
<fieldset>
|
||||
<legend>Datos</legend>
|
||||
<input type="number" name="price" value="'.$price.'" min="0" placeholder="Precio de la entrada" required/> <br>
|
||||
<input type="number" name="price" value="'.$number.'" min="0" placeholder="Precio de la entrada" required/> <br>
|
||||
<input type="text" name="format" value="'.$format.'" placeholder="Formato de pelicula" required/> <br>
|
||||
<select name="hall" class="button large">';
|
||||
foreach(Hall::getListHalls($cinema) as $hll){
|
||||
@ -56,11 +56,7 @@ class FormSession extends Form {
|
||||
$htmlform .= '<input type="number" name="repeat" value="" min="0" title="Añadir esta sesion durante los proximos X dias" min="0" max="31" placeholder="Añadir X dias"/> <br>
|
||||
<button type="submit" name="new_session" class="button large">Crear</button><br>';
|
||||
if($data['option'] == "edit_session")
|
||||
$htmlform .= '
|
||||
<input name="origin_hall" type="hidden" value="'.$hall.'">
|
||||
<input name="origin_date" type="hidden" value="'.$date.'">
|
||||
<input name="origin_start" type="hidden" value="'.$start.'">
|
||||
<button type="submit" name="edit_session" class="button large">Editar</button><br>
|
||||
$htmlform .= '<button type="submit" name="edit_session" class="button large">Editar</button><br>
|
||||
<button type="submit" name="delete_session" class="primary">Borrar</button><br>';
|
||||
$htmlform .= '
|
||||
<input type="reset" value="Limpiar Campos" >
|
||||
@ -90,13 +86,8 @@ class FormSession extends Form {
|
||||
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" );
|
||||
}
|
||||
else if($data["option"] == "delete_session") {
|
||||
$_SESSION['msg'] = Session::delete_session($data);
|
||||
header( "Location: ../?state=success" );
|
||||
}else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,4 @@
|
||||
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]);
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_session'])){
|
||||
$data = array("option" => "edit_session","film" => $_POST["film"],"hall" => $_POST["hall"],"date" => $_POST["date"],"start" => $_POST["start"]
|
||||
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]
|
||||
, "origin_hall"=> $_POST["origin_hall"],"origin_date"=> $_POST["origin_date"],"origin_start"=> $_POST["origin_start"]);
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
|
||||
if(isset($_POST['delete_session'])){
|
||||
$data = array("option" => "delete_session","cinema" => $_SESSION["cinema"], "hall"=> $_POST["origin_hall"]
|
||||
,"date"=> $_POST["origin_date"],"start"=> $_POST["origin_start"]);
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
?>
|
@ -141,16 +141,7 @@
|
||||
<td> '. str_replace('_', ' ', Session::getFilmTitle($session->getIdfilm())) .' </td>
|
||||
<td> '.$session->getFormat().' </td>
|
||||
<td> '.$session->getSeatPrice().' </td>
|
||||
<td> <input type="date" name="date" value="'.$date.'">
|
||||
<form method="post" action="./?state=edit_session">
|
||||
<input name="film" type="hidden" value="'.$session->getIdfilm().'">
|
||||
<input name="hall" type="hidden" value="'.$session->getIdhall().'">
|
||||
<input name="date" type="hidden" value="'.$session->getDate().'">
|
||||
<input name="start" type="hidden" value="'.$session->getStartTime().'">
|
||||
<input name="price" type="hidden" value="'.$session->getSeatPrice().'">
|
||||
<input name="format" type="hidden" value="'.$session->getFormat().'">
|
||||
<td> <input type="submit" name="edit" value="Editar" class="button" ></td>
|
||||
</form>
|
||||
</tr>';
|
||||
}
|
||||
$panel.='
|
||||
@ -178,9 +169,12 @@
|
||||
}
|
||||
|
||||
static function edit_session(){
|
||||
$data = array("option" => "edit_session","hall" => $_POST["hall"],"cinema" => $_SESSION["cinema"],"date" => $_POST['date'],"film" => $_POST['film'],"start" => $_POST['start'],"price" => $_POST['price'],"format" => $_POST['format']);
|
||||
$panel = '<h1>Editar una sesión.</h1><hr /></br>
|
||||
'.FormSession::generaCampoFormulario($data, null);
|
||||
$panel = '<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h1>Editar una session.</h1><hr /></br>
|
||||
<p> En desarrollo... </p>
|
||||
</div>
|
||||
<div class="column side"></div>'."\n";
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user