Mini Shell

Direktori : /home/emypro/www/admin/
Upload File :
Current File : /home/emypro/www/admin/obras_edit.php

<?php include('header.php') ?>
<?php
$obra = new Obra();

$flash = array();
// UPDATE
if(isset($_POST['action']) && $_POST['action'] == 'update'):
	unset($_POST['action']);

	$obra_edit = $obra->find($_GET['id']);

	if(strlen($_POST['title']) > 1 && strlen($_POST['local']) > 1 && strlen($_POST['client']) > 1 && strlen($_POST['description']) > 7):

		if($obra->update($_GET['id'], $_POST)):
			$flash = Helper::flash('success');
		else:
			$flash = Helper::flash('error');
		endif;

	else:
		$flash = Helper::flash('error');
	endif;
endif;

$obra = $obra->find($_GET['id']);
?>
<div id="page">
	<div class="row">
		<div class="col lg-12">
			<h2>Obras / editar</h2>
		</div>
	</div>
	<div class="row">
		<?php if($flash): ?>
		<div class="col-lg-12">
			<div class="alert alert-<?= $flash['class'] ?> alert-dismissible">
				<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<?= $flash['message'] ?>
			</div>
		</div>
		<?php endif ?>
		<div class="col-lg-12">
			<a href="obras.php" class="btn btn-primary">Voltar</a>
			<hr>
			<small>* todos os campos são obrigatórios</small>
			<form action="" method="post" enctype="multipart/form-data">
				<div class="form-group">
					<label for="title">Título:</label>
					<input type="text" name="title" class="form-control" value="<?= $obra->title ?>">
				</div>
				<div class="form-group">
					<label for="local">Local:</label>
					<input type="text" name="local" class="form-control" value="<?= $obra->local ?>">
				</div>
				<div class="form-group">
					<label for="client">Cliente:</label>
					<input type="text" name="client" class="form-control" value="<?= $obra->client ?>">
				</div>
				<div class="form-group">
					<label for="description">Descrição:</label>
					<textarea name="description" class="form-control" cols="30" rows="10"><?= $obra->description ?></textarea>
				</div>
				<div class="form-group">
					<input type="hidden" name="action" value="update">
					<button type="submit" class="btn btn-primary">Atualizar</button>
				</div>
			</form>
		</div>
		<div class="col-lg-6">
			<a href="attachments.php?model=obras&id=<?= $obra->id ?>" class="btn btn-warning"><i class="glyphicon glyphicon-picture"></i> Galeria de fotos</a>
		</div>
	</div>
</div>

<?php include('footer.php') ?>

Zerion Mini Shell 1.0