<div class="content-wrapper">
    <section class="content-header">
        <h1>
            Gérer les
            <small>Commandes</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Accueil</a></li>
            <li class="active">Commandes</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12 col-xs-12">
                <?php if (session()->getFlashdata('success')): ?>
                    <div class="alert alert-success alert-dismissible" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <?php echo session()->getFlashdata('success'); ?>
                    </div>
                <?php elseif (session()->getFlashdata('error')): ?>
                    <div class="alert alert-error alert-dismissible" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <?php echo session()->getFlashdata('error'); ?>
                    </div>
                <?php endif; ?>
                <?php if (in_array('createOrder', $user_permission)): ?>
                    <button class="btn btn-primary" data-toggle="modal" data-target="#addModal">Ajouter un Reservation</button>
                    <br /> <br />
                <?php endif; ?>

                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">Gérer les Commandes</h3>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table id="manageTable" class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>Nom du client</th>
                                    <th>Téléphone du client</th>
                                    <th>Jour de reservation</th>
                                    <th>Produits totaux</th>
                                    <th>Montant total</th>
                                    <?php if (in_array('updateOrder', $user_permission) || in_array('viewOrder', $user_permission) || in_array('deleteOrder', $user_permission)): ?>
                                        <th>Action</th>
                                    <?php endif; ?>
                                </tr>
                            </thead>

                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>
        </div>
        <!-- create brand modal -->
        <div class="modal fade" tabindex="-1" role="dialog" id="addModal">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">Ajouter un magasin</h4>
                    </div>

                    <form role="form" action="<?php echo base_url('stores/create') ?>" method="post" id="createForm">

                        <div class="modal-body">

                            <div class="form-group">
                                <label for="client_name">Nom du client</label>
                                <input type="text" class="form-control" id="client_name" name="nom_client" placeholder="Nom du client" autocomplete="off">
                            </div>

                            <div class="form-group">
                                <label for="telclient">Télephone du client</label>
                                <input type="text" class="form-control" id="telclient" name="telephone_client" placeholder="Tel client" autocomplete="off">
                            </div>

                            <div class="form-group">
                                <label for="date_fin">Date d'expiration du reservation</label>
                                <input type="date" class="form-control" id="date_fin" name="date_fin" placeholder="Nom du magasin" autocomplete="off">
                            </div>

                            <div class="form-group">
                                <label for="product">Produit à reserver</label>
                                <select name="product" class="form-control" multiple="multiple" id="product">
                                    <option value=""></option>
                                    <?php foreach ($product as $k => $v): ?>
                                        <?php if ($v['qty'] > 0): ?>
                                            <option value="<?php echo $v['id'] ?>"><?= $v['sku'] . ' | ' . $v['name'] . ' | ' . $v['numero_de_moteur'] . ' | ' . $v['puissance'] ?></option>
                                        <?php endif; ?>
                                    <?php endforeach ?>
                                </select>
                            </div>

                            <div class="form-group">
                                <label for="montatnt">Montant</label>
                                <input type="text" class="form-control" id="montant" name="montant" placeholder="Nom du magasin" autocomplete="off" disabled>
                                <input type="hidden" class="form-control" id="montant2" name="montant2" placeholder="Montant" autocomplete="off">
                            </div>
                        </div>


                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
                            <button type="submit" class="btn btn-primary">Enregistrer</button>
                        </div>

                    </form>


                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
    </section>
</div>