<?php if (isset($_GET['id']) && !empty($_GET['id'])) { $id = htmlentities($_GET['id']); $brands = Brand::getBrandById($id); if (isset($_POST['edit'])) { if (preg_match("#^[a-zA-Z0-9._-]{2,30}#", $_POST['name'])) { PDOConnexion::setParameters('phonedeals', 'root', 'root'); $db = PDOConnexion::getInstance(); $sql = "\n\t\t\t\tUPDATE brand\n\t\t\t\tSET name = :name\n\t\t\t\tWHERE id = :id\n\t\t\t"; $sth = $db->prepare($sql); $sth->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Brand'); $sth->execute(array(':id' => $id, ':name' => $_POST['name'])); if ($sth) { App::success('Cette marque a bien été modifiée'); } } else { App::error("Le nom de cette marque n'est pas valide"); } } if ($brands) { ?> <div class="col-md-8"> <div class="page-header"> <h1>Éditer une marque</h1> </div> <form action="index.php?page=admin/brand-edit&id=<?php echo $id; ?> " method="POST">
<table class="table table-striped"> <thead> <th>Nom</th> <th>Marque</th> <th>Capacité</th> <th>Prix</th> <th>Couleur</th> <th>Description</th> <th></th> <th></th> </thead> <?php foreach (Phone::getPhonesList() as $phone) { echo '<tr data-id="' . $phone->id . '">'; echo '<td><a href="index.php?page=admin/phone-edit&id=' . $phone->id . '">' . $phone->name . '</a></td>'; echo '<td>' . Brand::getBrandById($phone->brand) . '</td>'; echo '<td>' . $phone->capacity . ' Go</td>'; echo '<td>' . $phone->price . ' €</td>'; echo '<td>' . Color::getColorsNames($phone->color, true) . '</td>'; echo '<td style="max-width: 400px;">' . $phone->description . '</td>'; echo '<td><a href="index.php?page=admin/phone-edit&id=' . $phone->id . '"><i class="fa fa-pencil" data-toggle="tooltip" title="Modifier"></i></a></td>'; echo '<td><a href="#" title="Supprimer" data-toggle="tooltip" data-action="delete" title="Supprimer"><i class="fa fa-trash"></i></a></td>'; echo '</tr>'; } ?> </table> <a href="index.php?page=admin/add-phone" class="btn btn-primary">Ajouter un téléphone</a> </div> <script> $('[data-action="delete"]').click(function(e) {
<div class="container"> <div class="row"> <?php if (!isset($_GET['id']) || empty($_GET['id'])) { App::redirect('index.php?page=list'); } else { $id = $_GET['id']; $phone = Phone::getPhoneById($id); $promotion = Promotion::getPromotionByPhoneId($phone->id); $brand = Brand::getBrandById($phone->brand); ?> <div class="col-sm-12" style="margin-bottom: 30px;"> <h1 style="margin-bottom: 0;"><?php echo $phone->name; ?> </h1> <span style="color: #bfbfbf; display: block; font-size: 18px;"><?php echo $brand->name; ?> </span> </div> <div class="col-md-4 col-sm-6 col-xs-12"> <a href="index.php?page=product&id=<?php echo $phone->id; ?> " style="display: inline-block; padding: 15px; border: 1px solid #ededed;"> <img id="phone_img" src="<?php echo Phone::getPhoneThumbnail($phone->id); ?> " alt="<?php echo $phone->name;