Skip to content

Commit

Permalink
Bulding crud
Browse files Browse the repository at this point in the history
  • Loading branch information
aloundoye committed Sep 24, 2020
1 parent c60b13c commit 9d1d1c0
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ fabric.properties

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

public/mampinstaller
public/mampinstaller/*
4 changes: 3 additions & 1 deletion .idea/LocalFoot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 43 additions & 8 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions private/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ function redirect_to($location){
header("Location: " . $location);
exit();
}

function is_post_request(){
return $_SERVER['REQUEST_METHOD'] == 'POST';
}
function is_get_request(){
return $_SERVER['REQUEST_METHOD'] == 'GET';
}
?>
14 changes: 7 additions & 7 deletions private/shared/admin_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@
</div>

<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="../vendor/jquery/jquery.min.js"></script>
<script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="../vendor/jquery-easing/jquery.easing.min.js"></script>

<!-- Custom scripts for all pages-->
<script src="js/sb-admin-2.min.js"></script>
<script src="../js/sb-admin-2.min.js"></script>

<!-- Page level plugins -->
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
<script src="../vendor/datatables/jquery.dataTables.min.js"></script>
<script src="../vendor/datatables/dataTables.bootstrap4.min.js"></script>

<!-- Page level custom scripts -->
<script src="js/demo/datatables-demo.js"></script>
<script src="../js/demo/datatables-demo.js"></script>

</body>

Expand Down
8 changes: 4 additions & 4 deletions private/shared/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<title>Local Foot - <?php echo htmlspecialchars($page_title); ?></title>

<!-- Custom fonts for this template-->
<link href="<?php echo url_for('vendor/fontawesome-free/css/all.min.css'); ?>" rel="stylesheet" type="text/css">
<link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

<!-- Custom styles for this template-->
<link href="<?php echo url_for('stylesheets/sb-admin-2.min.css');?>" rel="stylesheet">
<link href="../stylesheets/sb-admin-2.min.css" rel="stylesheet">

</head>

Expand Down Expand Up @@ -63,12 +63,12 @@

<!-- Nav Items -->
<li class="nav-item">
<a class="nav-link" href="<?php echo url_for('admin/terrains.php')?>">
<a class="nav-link" href="terrains.php">
<i class="fas fa-fw fa-table"></i>
<span>Terrains</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo url_for('admin/reservations.php')?>">
<a class="nav-link" href="reservations.php">
<i class="fas fa-fw fa-table"></i>
<span>Reservations</span></a>
</li>
Expand Down
38 changes: 38 additions & 0 deletions public/admin/create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

require_once('../../private/initialize.php');
$page_title = 'Ajouter Terrain';

if (is_post_request()){
$taille = $_POST['taille'] ?? '';
}else{
}
?>
<?php include(SHARED_PATH . '/admin_header.php') ?>


<!-- Page Heading -->
<h1 class="h3 mb-2 text-gray-800">Ajouter Terrain</h1>
<div class="container">
<form action="create.php" method="post">
<div class="form-group">
<label for="taille">Taille</label>
<input type="text" class="form-control form-control-sm" id="taille" name="taille" placeholder="Entrer la taille du terrain">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea name="description" class="form-control form-control-sm" id="description" cols="30" rows="10" placeholder="Entrer la description du terrain"></textarea>
</div>
<div class="form-group">
<label for="prix">Prix</label>
<input type="text" class="form-control form-control-sm" id="prix" name="prix" placeholder="Entrer le prix pour une reservation du terrain">
</div>
<div class="form-group">
<label for="photo">Photo du terrain</label>
<input type="file" class="form-control-file" name="photo" id="photo">
</div>
<button type="submit" class="btn btn-primary">Ajouter</button>
<a href="terrains.php" class="btn btn-danger">Annuler</a>
</form>
</div>
<?php include(SHARED_PATH . '/admin_footer.php') ?>
Empty file added public/admin/delete.php
Empty file.
47 changes: 47 additions & 0 deletions public/admin/edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
require_once('../../private/initialize.php');
$page_title = 'Modifier Terrain';
if (!isset($_GET['id'])){
redirect_to(url_for('/admin/index.php'));
}
$id = $_GET['id'];

if (is_post_request()){
$taille = $_POST['taille'];
}
?>

<?php include(SHARED_PATH . '/admin_header.php'); ?>
<!-- Page Heading -->
<h1 class="h3 mb-2 text-gray-800">Modifier Terrain</h1>
<div class="container">
<form action="" method="post">
<div class="form-group">
<label for="taille">Taille</label>
<input type="text" class="form-control form-control-sm" id="taille" name="taille" placeholder="Entrer la taille du terrain">
</div>
<div class="form-group">
<label for="taille">Taille</label>
<input type="text" class="form-control form-control-sm" id="taille" name="taille" placeholder="Entrer la taille du terrain">
</div>
<div class="form-group">
<label for="taille">Taille</label>
<input type="text" class="form-control form-control-sm" id="taille" name="taille" placeholder="Entrer la taille du terrain">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea name="description" class="form-control form-control-sm" id="description" cols="30" rows="10" placeholder="Entrer la description du terrain"></textarea>
</div>
<div class="form-group">
<label for="prix">Prix</label>
<input type="text" class="form-control form-control-sm" id="prix" name="prix" placeholder="Entrer le prix pour une reservation du terrain">
</div>
<div class="form-group">
<label for="photo">Photo du terrain</label>
<input type="file" class="form-control-file" id="photo" name="photo">
</div>
<button type="submit" class="btn btn-primary">Modifier</button>
<a href="terrains.php" class="btn btn-danger">Annuler</a>
</form>
</div>
<?php include(SHARED_PATH . '/admin_footer.php') ?>
29 changes: 26 additions & 3 deletions public/admin/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,30 @@

<!-- Page Heading -->
<h1 class="h3 mb-2 text-gray-800">Ajouter Terrain</h1>



<div class="container">
<form action="create.php" method="post">
<div class="form-group">
<label for="nom_terrain">Nom du terrain</label>
<input type="text" class="form-control form-control-sm" id="nom_terrain" name="nom_terrain" placeholder="Entrer le nom du terrain">
</div>
<div class="form-group">
<label for="taille">Taille</label>
<input type="text" class="form-control form-control-sm" id="taille" name="taille" placeholder="Entrer la taille du terrain">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea name="description" class="form-control form-control-sm" id="description" cols="30" rows="10" placeholder="Entrer la description du terrain"></textarea>
</div>
<div class="form-group">
<label for="prix">Prix</label>
<input type="text" class="form-control form-control-sm" id="prix" name="prix" placeholder="Entrer le prix pour une reservation du terrain">
</div>
<div class="form-group">
<label for="photo">Photo du terrain</label>
<input type="file" class="form-control-file" name="photo" id="photo">
</div>
<button type="submit" class="btn btn-primary">Ajouter</button>
<a href="terrains.php" class="btn btn-danger">Annuler</a>
</form>
</div>
<?php include(SHARED_PATH . '/admin_footer.php') ?>
6 changes: 5 additions & 1 deletion public/admin/terrains.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<a href="" class="m-0 btn btn-info fa-pull-right"><i class="fas fa-plus"></i> Ajouter une nouvelle produit</a>
<a href="<?php echo url_for('/admin/new.php') ?>" class="m-0 btn btn-info fa-pull-right"><i class="fas fa-plus"></i> Ajouter une nouvelle produit</a>
<h6 class="m-0 font-weight-bold text-primary">Détails Terrains</h6>
</div>
<div class="card-body">
Expand All @@ -20,20 +20,24 @@
<th>Nom</th>
<th>Prix</th>
<th>Taille</th>
<th>&nbsp;</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Nom</th>
<th>Prix</th>
<th>Taille</th>
<th>&nbsp;</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>$320,800</td>
<td>61</td>
<td><a class="btn btn-outline-primary" href="<?php echo url_for('/admin/edit.php?id=' . h(u()));?>">Modifier</a>
<a class="btn btn-outline-danger" href="<?php echo url_for('/admin/delete.php?id=' . h(u()));?>">Supprimer</a></td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 9d1d1c0

Please sign in to comment.