Пример #1
0
    }
    if ($member) {
        ?>
<div class="col-md-8">
    <div class="page-header">
        <h1>Éditer une promotion</h1>
    </div>

    <form action="index.php?page=admin/promotion-edit&amp;id=<?php 
        echo $id;
        ?>
" method="POST">
        <div class="form-group">
            <label for="phone">Téléphone</label>
            <p><?php 
        echo Phone::getPhoneById($promotion->phone)->name;
        ?>
</p>
        </div>
        <div class="form-group">
            <label for="promotion-percent">Pourcentage</label>
            <input type="text" class="form-control" id="promotion-percent" value="<?php 
        echo $promotion->percent;
        ?>
" name="percent" placeholder="Pourcentage">
        </div>
        
        <button type="submit" class="btn btn-lg btn-primary" name="edit">Éditer</button>
    </form>
</div>
Пример #2
0
<?php

if (isset($_POST['action'])) {
    if ($_POST['action'] == 'add') {
        $phone = Phone::getPhoneById($_POST['id']);
        // Si la session existe, alors on initialise la valeur dans une variable
        if (isset($_SESSION['cart']) && !empty($_SESSION['cart'])) {
            $cart = $_SESSION['cart'];
        } else {
            $cart = array('phones' => array(), 'phone_total' => (int) 0, 'price_total' => (int) 0);
        }
        // Lorsqu'on ajoute un téléphone, on le stocke dans un tableau
        array_push($cart['phones'], array('id' => (int) $phone->id, 'name' => $phone->name, 'price' => (int) $_POST['price'], 'amount' => (int) $_POST['amount'], 'capacity' => (int) $_POST['capacity'], 'color' => (int) $_POST['color']));
        // On précise que les données entrés précédement correspondent à la variable $cart pour les ajouter dans la session
        $_SESSION['cart'] = $cart;
        $_SESSION['cart']['phone_total'] = $_SESSION['cart']['phone_total'] + $_POST['amount'];
        $_SESSION['cart']['price_total'] = $_SESSION['cart']['price_total'] + $phone->price;
        $msg->success('Le téléphone a bien été ajouté au panier.', 'index.php?page=cart');
    } elseif ($_POST['action'] == 'remove') {
        $_SESSION['cart']['phone_total'] = $_SESSION['cart']['phone_total'] - $_SESSION['cart']['phones'][$_POST['id']]['amount'];
        $_SESSION['cart']['price_total'] = $_SESSION['cart']['price_total'] - $_SESSION['cart']['phones'][$_POST['id']]['price'] * $_SESSION['cart']['phones'][$_POST['id']]['amount'];
        unset($_SESSION['cart']['phones'][$_POST['id']]);
        // App::dd($_SESSION['cart']['phones']);
        $msg->success('Le produit a bie été supprimé de votre panier', 'index.php?page=cart');
    } else {
        echo 'Erreur';
    }
} else {
    $empty = true;
    $phonesTotal = 0;
    if (isset($_SESSION['cart']['phones']) && !empty($_SESSION['cart']['phones'])) {
Пример #3
0
 public static function getNewPrice($promotionId)
 {
     $promotion = self::getPromotionByPhoneId($promotionId);
     $phone = Phone::getPhoneById($promotion->phone);
     return $phone->price - $promotion->percent * 0.01 * $phone->price;
 }
Пример #4
0
<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&amp;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;
Пример #5
0
    ?>
		<table class="table table-striped">
			<thead>
				<th>Téléphone</th>
				<th>Pourcentage</th>
				<th>Prix de base</th>
				<th>Prix réduit</th>
				<th></th>
				<th></th>
			</thead>
			<?php 
    foreach (Promotion::getPromotionsList() as $promotion) {
        echo '<tr data-id="' . $promotion->id . '">';
        echo '<td><a href="index.php?page=admin/promotion-edit&amp;id=' . $promotion->id . '">' . Phone::getPhoneById($promotion->phone)->name . '</a></td>';
        echo '<td>' . $promotion->percent . ' %</td>';
        echo '<td>' . Phone::getPhoneById($promotion->phone)->price . ' &euro;</td>';
        echo '<td>' . Promotion::getNewPrice($promotion->phone) . ' &euro;</td>';
        echo '<td><a href="index.php?page=admin/promotion-edit&amp;id=' . $promotion->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-promotion" class="btn btn-primary">Ajouter une promotion</a>
	<?php 
} else {
    echo '<p>Aucune promotion n\'a été ajouté.</p>';
}
?>
</div>
<script>