<?php
include 'class/utilisateur.class.php';
include 'class/coupon.class.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include 'header.php';?>
</head>
<body>
<?php
$debut = microtime(true);
echo "<style>#dataTables-user {visibility: none;}</style>";
?>
<div id="wrapper">
<?php include 'menu.php'; ?>
<?php if (!(he_can('TTCOUPONS'))) {echo "<script>location.href = '403.php';</script>";}?>
<?php
$managerCou = new CouponManager($db);
$message ='';
$class_msg='';
if (isset($_GET['msg']))
{
switch ($_GET['msg']) {
case 1:$message = "<i class='fas fa-trash' aria-hidden='true'></i> Le coupon à été supprimée!";$class_msg="alert alert-danger";break;
case 2:$message = "<i class='fas fa-envelope-open-text' aria-hidden='true'></i> Le client a été informé sur le coupon par mail";$class_msg="alert alert-success";break;
case 3:$message = "<i class='far fa-envelope' aria-hidden='true'></i> Erreur lors de l'envoi mail";$class_msg="alert alert-danger";break;
case 4:$message = "<i class='fas fa-hand-holding-usd' aria-hidden='true'></i> Le Paiemenet est validée.";$class_msg="alert alert-success";break;
case 5:$message = "<i class='fas fa-thumbs-up' aria-hidden='true'></i> Coupon reçu avec succès.";$class_msg="alert alert-success";break;
}
if (($_GET['msg']== 4)&&(isset($_GET['c'])))
{
$coupon = $managerCou->get((int) $_GET['c']);
$class_msg="alert alert-success";
$message .= "<b>Coupon ajouter. <br> Le numéro de commande est ".$coupon->code_cmd().". </b>";
// $message .="<a type='button' href='".$coupon_dir."coupon-pdf.php?id_coup=".$_GET['c']."'' target='_blanc' class='btn btn-info'><i class='fas fa-print'></i> Imprimer</a>";
$message .="<br><div class='btn-group'>";
$message .="<a type='button' href='".$coupon_dir."coupon-pdf.php?id_coup=".$_GET['c']."'' target='_blanc' class='btn btn-primary btn-sm' title='Imprimer le coupon' data-toggle='tooltip' data-placement='top'><i class='fas fa-print'></i> Imprimer le coupon</a>";
$message .="<a type='button' href='".$coupon_dir."bondecommande.php?id_coup=".$_GET['c']."'' target='_blanc' class='btn btn-info btn-sm' title='Imprimer la bon de commande' data-toggle='tooltip' data-placement='top'><i class='fas fa-file-word'></i> Imprimer la Bon de commande</a>";
$message .= "</div>";
}
}
$managerCou = new CouponManager($db);
$managerCou->nettoyage();
////////////////// traitement des action sur les coupons
if ((isset($_GET['id']))&&(isset($_GET['op'])))
{
if ($_GET['op'] == 'delete')
{$managerCou->delete((int) $_GET['id']);
echo '<script language="javascript">window.location.href = "'.$_SERVER['PHP_SELF'].'?msg=1"</script>';
}
if ($_GET['op'] == 'mail')
{$r = $managerCou->notif_mail((int) $_GET['id']);
if ($r) {
echo '<script language="javascript">window.location.href = "'.$_SERVER['PHP_SELF'].'?msg=2"</script>';
}
else {
echo '<script language="javascript">window.location.href = "'.$_SERVER['PHP_SELF'].'?msg=3"</script>';
}
}
if ($_GET['op'] == 'Payee')
{
$maj = array();
$maj['id']=(int) $_GET['id'];
$maj['date_coupon'] = time();
$maj['id_vendeur'] = $_SESSION['GDEAL']['user']['id'];
$maj['etat']=5;
$managerCou->update($maj);
$managerCou->maj_nb_achteurs($_GET['deal_id'],$_GET['quantite']);
echo '<script language="javascript">window.location.href = "'.$_SERVER['PHP_SELF'].'?msg=4&c='.$maj['id'].'"</script>';
}
if ($_GET['op'] == 'Recu')
{
$maj = array();
$maj['id']=(int) $_GET['id'];
$maj['recu'] = time();
$managerCou->update($maj);
echo '<script language="javascript">window.location.href = "'.$_SERVER['PHP_SELF'].'?msg=5'.'"</script>';
}
}
$get_query = "";
if(isset($_GET['query']))
{
$listeCou = $managerCou->getListTab('QUERY',@$_GET['query']);
$libelle ="<span class='animated infinite flash'><span class='label' style='background-color: red;'><i class='fas fa-exclamation-triangle' title='Recherche Activé'></i></span></span>";
$libelle .= " <font style='color: red;'>Recherche : <b>".@$_GET['query']."</b></font>";
$libelle .= " <a href='".$_SERVER['PHP_SELF']."' type='button' class='btn-info btn-sm' style='text-decoration: none;'><i class='fas fa-refresh fa-spin' aria-hidden='true'></i> Initialiser</a>";
$get_query = "query=".@$_GET['query']."&";
}
else
{
$listeCou = $managerCou->getListTab('ALL','ALL');
$libelle = "Toutes les coupons";
}
/*pagination*/
$nbdelignes= count($listeCou);
$lignesParPage=10;
$nombreDePages=ceil($nbdelignes/$lignesParPage);
if(isset($_GET['page']))
{
$pageActuelle=intval($_GET['page']);
// if($pageActuelle>$nombreDePages) {$pageActuelle=$nombreDePages;}
if ($pageActuelle < 1) { // If it is less than 1
$pageActuelle = 1; // force if to be 1
} else if ($pageActuelle > $nombreDePages) { // if it is greater than $lastpage
$pageActuelle = $nombreDePages; // force it to be $lastpage's value
}
}
else // Sinon
{$pageActuelle=1;}
$premiereEntree=($pageActuelle-1)*$lignesParPage;
$listeCou = array_slice($listeCou, $premiereEntree, $lignesParPage);
?>
<!-- Page Content -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Coupons Rapide</h1>
</div>
<div class="col-lg-12 animated flip">
<a href="vendre.php"><i class="glyphicon glyphicon-plus"></i> Ajouter</a>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<?php echo $libelle;?>
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<?php
if ($message !='')
{echo '<div class="'.$class_msg.' animated flash" role="alert"><i class="fas fa-exclamation-circle"></i> '.$message.'</div>';}
?>
<?php //if(isset($_GET['query'])){ ?>
<table class="table table-striped">
<form name='frm' id='frm' action='' method='get'>
<tbody>
<tr>
<th>
<div class="input-group">
<input type="text" name="query" class="form-control" value="<?php echo @$_GET['query'];?>" placeholder="Recherche de..." pattern="^[a-zA-ZÀ-ÿ0-9_-., ]{3,70}$" title="Mot à rechercher" required>
<span class="input-group-btn">
<button class="btn btn-primary" type="submit" ><i class="fas fa-search"></i> Trouver</button>
</span>
</div>
<span style="font-weight: normal;font-style: italic;font-size: 11px;"> Recherche sur l'id, N°Cmd, nom prénom tél du dealer</span>
</th>
</tr>
</tbody>
</form>
</table>
<?php //} ?>
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover display compact" id="dataTables-user" cellspacing="0" width="100%">
<thead>
<tr>
<th width='14%'>N° Cmd</th>
<th width='22%'>Titre</th>
<th width='11%'>Prix</th>
<th>Dealer</th>
<!-- <th width='9%'>Vend.</th> -->
<th width='13%'>Date</th>
<th width='11%'>Etat</th>
<th width='5%'><i class="fas fa-cogs" aria-hidden="true"></i></th>
</tr>
</thead>
<tbody>
<?php foreach ($listeCou as $cou) {
$icon_etat = "";
if ($cou['vendeur_id']>0) $icon_etat .= "<i class='fad fa-user-headset' data-toggle='tooltip' data-placement='bottom' title='Vendeur : ".$cou['vendeur_id']."/ ".$cou['vendeur_n']."' style='--fa-secondary-opacity: 1.0; --fa-primary-color: saddlebrown; --fa-secondary-color: burlywood;'></i> ";
else $icon_etat .= "<i class='fad fa-mouse' data-toggle='tooltip' data-placement='bottom' title='Vendeur Virtuel' style='--fa-secondary-opacity: 1.0; --fa-primary-color: saddlebrown; --fa-secondary-color: burlywood;'></i> ";
$icon_etat .= $coupon_code_icon[$cou['etat']]." ";
if ($cou['mailing']>0) $icon_etat .= "<i class='fad fa-envelope-open-text' data-toggle='tooltip' data-placement='bottom' title='Notifiée Par Mail' style='--fa-secondary-opacity: 0.5; --fa-primary-color: green; --fa-secondary-color: green;'></i> ";
else $icon_etat .= "<i class='fad fa-envelope' data-toggle='tooltip' data-placement='bottom' title='Non Notifiée Par Mail'></i> ";
if ($cou['recu']>0) $icon_etat .= "<i class='fad fa-thumbs-up' data-toggle='tooltip' data-placement='bottom' title='Reçu' style='--fa-secondary-opacity: 0.5; --fa-primary-color: green; --fa-secondary-color: green;'></i>";
else $icon_etat .= "<i class='fad fa-thumbs-up' data-toggle='tooltip' data-placement='bottom' title='Non Reçu' ></i>";
$icon_usr_gndr ="<i class='fas fa-user' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Client'></i>";
if($cou['dealer_sex'] == "homme")$icon_usr_gndr ="<i class='fad fa-male' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Client' style='color:#2859C9'></i>";
if(($cou['dealer_sex'] == "Female")||($cou['dealer_sex'] == "Femme"))$icon_usr_gndr ="<i class='fad fa-female' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Client' style='color:#B92F77'></i>";
$det_pay ="";
if($cou['pv']) $det_pay ="{<b>".$cou['pv']."<sup>Dt.</sup></b> = ".$cou['av']."<sup>Dt.</sup> + ".$cou['rst']."<sup>Dt.</sup>}";
$resume ="
<i class='fad fa-barcode' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Code Commande'></i> ".$cou['id']." <b>/</b> ".$cou['code_cmd']."<br>
<i class='fad fa-shopping-basket' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Article'></i> ".$cou['deal_id']." <b>/</b> ".$cou['titre']."<br>
<i class='fad fa-file-invoice-dollar' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Prix'></i> <b>".$cou['prix']." <sup>Dt.</sup></b> <small>(x ".$cou['quantite'].")".$det_pay."</small><br>
<details style='background-color: #0000001a;'><summary>".$icon_usr_gndr." <b>".$cou['dealer_nom']." ".$cou['dealer_prenom']."</b></summary>";
$resume .="<table><tr><td width='15%'></td><td></td></tr>";
if ($cou['etat'] == 7){$resume .= "<tr><td><i class='fad fa-shipping-fast' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Adresse de livraison'></i></td><td>".$cou['addr']."</td></tr>";}
$clt= array();
if (strlen($cou['dealer_email']) > 5)
{$clt = $managerCou->getInfoClt($cou['dealer_email']);
$resume .= "<tr><td><i class='fad fa-street-view' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Adresse du client'></i></td><td>".$clt['adr']."</td></tr>";
$resume .= "<tr><td><i class='fad fa-address-card' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Civilité'></i></td><td>".$clt['civilite'].$clt['gender']."</td></tr>";
$resume .= "<tr><td><i class='fad fa-calendar' aria-hidden='true' data-toggle='tooltip' data-placement='left' title=Date de naisssance'></i></td><td>".$clt['date_de_naissance']."</td></tr>";
}
if (count($clt)== 0){
$resume .= "<tr><td></td><td><div class='alert alert-danger'><span class='fa-stack fa-lg'><i class='fas fa-user fa-stack-1x'></i><i class='fad fa-ban fa-stack-2x text-danger'></i></span>Client Non Inscrit </div></td></tr> ";
}
$resume .="
<tr><td><i class='fad fa-phone-alt' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Téléphone'></i></td><td><b>".$cou['dealer_tel']."</b></td></tr>
<tr><td><i class='fad fa-envelope' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Email'></i></td><td><b>".$cou['dealer_email']."</b></td></tr>
<tr><td><i class='fad fa-map-marker-alt' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Gouvernorat'></i></td><td><b>".$cou['dealer_gouv']."</b></td></tr>
<tr><td><i class='fad fa-store-alt' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Vendeur'></i></td><td>".$cou['vendeur_id']." <b>/</b> ".$cou['vendeur_n']."</td></tr>
<tr><td><i class='fad fa-clock' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Date d`achat'></i></td><td>".date("d-m-Y", $cou['date_coupon'])." ".date("\à H:i:s", $cou['date_coupon'])."</td></tr>
<tr><td><i class='fad fa-binoculars' aria-hidden='true' data-toggle='tooltip' data-placement='left' title='Etat du commande'></i></td><td>".$icon_etat."</td></tr>
</table>
<form action='tel:".$cou['dealer_tel']."'><button class='btn btn-success btn-block' type='submit'><i class='fas fa-phone-square' aria-hidden='true'></i> Appeler</button></form>
";
if (strlen($cou['dealer_email']) > 5){ $resume .="<a target='_blanc' href='https://www.facebook.com/search/people/?q=".$cou['dealer_email']."'><i class='fab fa-facebook-square fa-2x'></i></a>";}
if (strlen($cou['dealer_tel']) > 5){ $resume .="<a target='_blanc' href='https://www.facebook.com/search/people/?q=".$cou['dealer_tel']."'><i class='fab fa-facebook-square fa-2x' style='color: #fdbd32;'></i></a>";}
// if ($cou['etat'] == 7) $resume .="<i class='fas fa-map-marker' aria-hidden='true'></i> ".$cou['addr']."<br> ";
$resume_tab[$cou['id']]= $resume."</details>";
?>
<?php if(isset($_GET['query'])){foreach ($cou as $c => $i) {if (in_array($c, array("id","code_cmd","dealer_nom","dealer_prenom","dealer_tel","dealer_email","dealer_gouv"))){$cou[$c] = str_ireplace(@$_GET['query'],"<font color=red>".@$_GET['query']."</font>", $cou[$c]);}}} ?>
<tr class="odd gradeX ">
<td class="center <?php echo $etat_class[$cou['etat']];?>">
<i class="fas fa-info-circle" data-toggle="tooltip" data-placement="bottom" title="<?php echo "Id : ".$cou['id'];?>">
<?php echo $cou['code_cmd'];?>
</i>
<div class="visible-xs visible-sm"><?php echo $coupon_code_icon[$cou['etat']];?><div>
</td>
<td>
<?php echo "<a href='".$home."/?p=".$cou['deal_id']."' data-toggle='tooltip' data-placement='bottom' title='ID : ".$cou['deal_id']."<br>".$cou['titre']."' target='_blanc'>".mb_substr($cou['titre'],0, 18,'UTF-8')."...</a>";?>
</td>
<?php
$det_pay ="";
if($cou['pv']) $det_pay ="<b>Prix de vente : ".$cou['pv']."<sup>Dt.</sup></b><br> Avance : ".$cou['av']."<sup>Dt.</sup> <br> Reste : ".$cou['rst']."<sup>Dt.</sup>";
?>
<td data-order="<?php echo $cou['prix'];?>">
<span class="" data-toggle="tooltip" data-placement="bottom" title="<?php echo $det_pay;?>">
<?php echo "<b>".$cou['prix']." <sup>Dt.</sup></b><sub>(x".$cou['quantite'].")</sub>";?>
</span>
</td>
<?php $dealer_txt = $cou['dealer_nom']." ".$cou['dealer_prenom']."<br>".$cou['dealer_email']."<br>".$cou['dealer_tel']; ?>
<td>
<i class="" data-toggle="tooltip" data-placement="bottom" title="<?php echo $dealer_txt;?>" >
<?php echo $cou['dealer_nom']." ".$cou['dealer_prenom']; ?>
</i>
</td>
<td data-order="<?php echo $cou['date_coupon'];?>">
<i class="fas fa-info-circle" data-toggle="tooltip" data-placement="bottom" title="<?php echo date("\à H:i:s", $cou['date_coupon']);?>" >
<?php echo date("d-m-Y", $cou['date_coupon']);?>
</i>
</td>
<td >
<?php echo $icon_etat; ?> </td>
<td class="center">
<?php
$abprint = $abmailing = $abpaiement= $abrecu = $abdelete = $abedit = 'disabled';
if ((he_can('CPPRINT'))&&(in_array($cou['etat'], $etat_cp_canprint))) {$abprint = '';}
if ((he_can('CPMAILING'))&&(in_array($cou['etat'], $etat_cp_paied))) {$abmailing = '';}
if (he_can('CPPAIEMENT')) {$abpaiement = '';}
if ((he_can('CPRECU'))&&(in_array($cou['etat'], $etat_cp_paied))) {$abrecu = '';}
if (he_can('CPDELETE')) {$abdelete = '';}
if (he_can('CPEDIT')) {$abedit = '';}
?>
<span class='hidden-xs'>
<a class="" href="#" data-toggle="modal" data-target="#rsm<?php echo $cou['id'];?>" title="Résumé & Option">
<i class="fad fa-cog" data-toggle="tooltip" data-placement="bottom" title="Résumé & Option" ></i>
</a>
</span>
<span class='visible-xs'>
<button class="btn btn-primary col-xs-5" data-toggle="modal" data-target="#rsm<?php echo $cou['id'];?>" title="Résumé & Option"><i class="fas fa-cog" data-toggle="tooltip" data-placement="bottom" title="Résumé & Option"></i></button>
</span>
<div class="modal fade modal-primary" id="rsm<?php echo $cou['id'];?>" data-easein="flipXIn" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog <?php echo $animated_open_effect[array_rand($animated_open_effect, 1)]; ?> animated modal-sm" 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">×</span></button>
<h1 class="modal-title text-center" id="myModalLabel">
<i class="fas fa-eye" aria-hidden="true"></i> Résumé
</h1>
</div>
<div class="modal-body row-fluid">
<?php echo $resume_tab[$cou['id']]; ?>
<div class="clearfix"></div>
<?php
$cou['ex_art']=$cou['ex_cod']=$cou['ex_pp']=$cou['ex_gd']="";
if(!($cou['pv']))$cou['pv']=$cou['prix'];
if($cou['deal_id']==1373 ){$cou['ex_art']="MARGOUM";$cou['ex_cod']="MA2";$cou['ex_pp'] = floor($cou['pv'] * 0.85);}
if($cou['deal_id']==1617 ){$cou['ex_art']="Lit2019";$cou['ex_cod']="LI19";$cou['ex_pp'] = floor($cou['pv'] * 0.8);}
if($cou['deal_id']==1438 ){$cou['ex_art']="Convertible2019";$cou['ex_cod']="CV19";$cou['ex_pp'] = floor($cou['pv'] * 0.85);}
if($cou['deal_id']==1437 ){$cou['ex_art']="Salon2018";$cou['ex_cod']="SA18";$cou['ex_pp'] = floor($cou['pv'] * 0.85);}
if($cou['deal_id']==1616 ){$cou['ex_art']="Salon2019";$cou['ex_cod']="SA19";$cou['ex_pp'] = floor($cou['pv'] * 0.85);}
if($cou['deal_id']==985 ){$cou['ex_art']="SALLE A MANGER";$cou['ex_cod']="SAM";$cou['ex_pp'] = floor($cou['pv'] * 0.85);}
?>
<span id="excel_format<?php echo $cou['id'];?>" >
<table style="font-size: 1px;width: 100%;background-color: #fff !important;color: #fff;">
<thead>
<tr style="background-color: #fff !important;color: #fff;">
<td><?php echo date("d/m/Y", $cou['date_coupon']);?></td>
<td><?php echo $cou['code_cmd'];?></td>
<td><?php echo $cou['ex_art'];?></td>
<td><?php echo $cou['ex_cod'];?></td>
<td><?php echo $cou['quantite'];?></td>
<td></td>
<td><?php echo $cou['pv'];?></td>
<td><?php echo $cou['ex_pp'];?></td>
<td><?php echo $cou['ex_gd'];?></td>
<td><?php echo $cou['av'];?></td>
<td><?php echo $cou['rst'];?></td>
<td>non</td>
<td>en cours</td>
<td><?php echo $cou['dealer_nom']." ".$cou['dealer_prenom']." a compte".$cou['av']."dt. reste ".$cou['rst']."dt";?></td>
</tr>
</thead>
</table>
</span>
<!-- The button used to copy the text -->
<div class="clearfix"></div>
<form></form>
<a class="btn btn-primary col-md-3 col-sm-6 col-xs-12 <?php echo $abprint;?>" closemodal='ok' href="<?php echo $coupon_dir."coupon-pdf.php?id_coup=".$cou['id'];?>" target='_blanc' data-toggle="tooltip" data-placement="top" title="Imprimer Coupon"> <i class="fad fa-print"></i></a>
<a class="btn btn-info col-md-3 col-sm-6 col-xs-12 <?php echo $abprint;?>" closemodal='ok' href="<?php echo $coupon_dir."bondecommande.php?id_coup=".$cou['id'];?>" target='_blanc' data-toggle="tooltip" data-placement="top" title="Imprimer Bon de commande"><i class="fad fa-file-word"></i> </a>
<form name='frmmail<?php echo $cou['id'];?>' id='frmmail<?php echo $cou['id'];?>' action='' method='get'>
<?php
echo "<input type='hidden' name='id' value = '".$cou['id']."'>";
echo "<input type='hidden' name='op' value = 'mail'>";
?>
</form>
<a class="btn btn-warning col-md-3 col-sm-6 col-xs-12 <?php echo $abmailing;?>" closemodal='ok' onclick="if (confirm('Voulez vous vraiment Informer le client par mail sur ce coupon?')) {document.forms['frmmail<?php echo $cou['id'];?>'].submit(); return false;}" data-toggle="tooltip" data-placement="top" title="Mailing"><i class="fad fa-envelope-open-text"></i></a>
<a class="btn btn-success col-md-3 col-sm-6 col-xs-12 <?php echo $abmailing;?>" closemodal='ok' onclick="copier_ligne_cmd_to_excel(<?php echo $cou['id'];?>)" data-toggle="modal" data-target="#copiedok" title="Copier format Excel"><i class="fad fa-file-excel" title="Copier format Excel" data-toggle="tooltip" data-placement="top" ></i></a>
<form name='frmpay<?php echo $cou['id'];?>' id='frmpay<?php echo $cou['id'];?>' action='' method='get'>
<?php
echo "<input type='hidden' name='id' value = '".$cou['id']."'>";
echo "<input type='hidden' name='quantite' value = '".$cou['quantite']."'>";
echo "<input type='hidden' name='op' value = 'Payee'>";
echo "<input type='hidden' name='deal_id' value = '".$cou['deal_id']."'>";
?>
</form>
<a class="btn btn-success col-md-3 col-sm-6 col-xs-12 <?php echo $abpaiement;?>" closemodal='ok' onclick="if (confirm('Voulez vous vraiment valider le payement (quantite = <?php echo $cou['quantite'];?>) ?')) {document.forms['frmpay<?php echo $cou['id'];?>'].submit(); return false;}" data-toggle="tooltip" data-placement="top" title="Paiement?"><i class="fad fa-shopping-cart"></i></a>
<form name='frmrecu<?php echo $cou['id'];?>' id='frmrecu<?php echo $cou['id'];?>' action='' method='get'>
<?php
echo "<input type='hidden' name='id' value = '".$cou['id']."'>";
echo "<input type='hidden' name='op' value = 'Recu'>";
?>
</form>
<a class="btn btn-info col-md-3 col-sm-6 col-xs-12 <?php echo $abrecu;?>" closemodal='ok' onclick="if (confirm('Avez vous recu ce coupon ?')) {document.forms['frmrecu<?php echo $cou['id'];?>'].submit(); return false;}" data-toggle="tooltip" data-placement="top" title="Reçu?"><i class="fad fa-thumbs-up"></i> </a>
<a class="btn btn-warning col-md-3 col-sm-6 col-xs-12 <?php echo $abedit;?>" href="<?php echo "editcoupon.php?id_coup=".$cou['id'];?>" data-toggle="tooltip" data-placement="top" title="Modifier" ><i class="fad fa-edit"></i></a>
<form name='frmdel<?php echo $cou['id'];?>' id='frmdel<?php echo $cou['id'];?>' action='' method='get'>
<?php
echo "<input type='hidden' name='id' value = '".$cou['id']."'>";
echo "<input type='hidden' name='op' value = 'delete'>";
?>
</form>
<a class="btn btn-danger col-md-3 col-sm-6 col-xs-12 <?php echo $abdelete;?>" onclick="if (confirm('Voulez vous vraiment supprimer ce coupon ( ID = <?php echo $cou['id'];?>)?')) {document.forms['frmdel<?php echo $cou['id'];?>'].submit(); return false;}" data-toggle="tooltip" data-placement="top" title="Supprimer"><i class="fad fa-trash-alt"></i> </a>
<div class="clearfix"></div>
<label for="search-select" class="col-md-12 col-sm-12 col-xs-12" >Chercher:</label>
<select id="search-select" class="col-md-12 col-sm-12 col-xs-12">
<option value="">--Merci de choisir un option--</option>
<option value="<?php echo $cou['dealer_nom']." ".$cou['dealer_prenom'];?>" ><?php echo $cou['dealer_nom']." ".$cou['dealer_prenom'];?> ?</option>
<option value="<?php echo $cou['titre'];?>" ><?php echo $cou['titre'];?> ?</option>
<option value="<?php echo date("d-m-Y", $cou['date_coupon']);?>" ><?php echo date("d-m-Y", $cou['date_coupon']);?> ?</option>
<option value="<?php echo $cou['vendeur_n'];?>"><?php echo $cou['vendeur_n'];?> ?</option>
</select>
</div>
<div class="modal-footer center">
<div class="container-fluid text-center"><button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button></div>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php }?>
</tbody>
</table>
<!-- pagination -->
<?php
$centerPages = "";
$sub1 = $pageActuelle - 1;
$sub2 = $pageActuelle - 2;
$sub3 = $pageActuelle - 3;
$sub4 = $pageActuelle - 4;
$add1 = $pageActuelle + 1;
$add2 = $pageActuelle + 2;
$add3 = $pageActuelle + 3;
$add4 = $pageActuelle + 4;
function can_link($num,$np)
{
if(($num>1)&&($num< $np))
return true;
return false;
}
if ($pageActuelle == 1) {
$centerPages .= ' <span class="pagNumActive">' . $pageActuelle . '</span> ';
if(can_link($add1,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $add1 . '">' . $add1 . '</a> ';
if(can_link($add2,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $add2 . '">' . $add2 . '</a> ';
if(can_link($add3,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $add3 . '">' . $add3 . '</a> ';
if(can_link($add4,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $add4 . '">' . $add4 . '</a> ';
} else if ($pageActuelle == $nombreDePages) {
if(can_link($sub4,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $sub4 . '">' . $sub4 . '</a> ';
if(can_link($sub3,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $sub3 . '">' . $sub3 . '</a> ';
if(can_link($sub2,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $sub2 . '">' . $sub2 . '</a> ';
if(can_link($sub1,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $sub1 . '">' . $sub1 . '</a> ';
$centerPages .= ' <span class="pagNumActive">' . $pageActuelle . '</span> ';
} else if ($pageActuelle > 2 && $pageActuelle < ($nombreDePages - 1)) {
if(can_link($sub2,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $sub2 . '">' . $sub2 . '</a> ';
if(can_link($sub1,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $sub1 . '">' . $sub1 . '</a> ';
$centerPages .= ' <span class="pagNumActive">' . $pageActuelle . '</span> ';
if(can_link($add1,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $add1 . '">' . $add1 . '</a> ';
if(can_link($add2,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $add2 . '">' . $add2 . '</a> ';
} else if ($pageActuelle > 1 && $pageActuelle < $nombreDePages) {
if(can_link($sub1,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $sub1 . '">' . $sub1 . '</a> ';
$centerPages .= ' <span class="pagNumActive">' . $pageActuelle . '</span> ';
if(can_link($add1,$nombreDePages))$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $add1 . '">' . $add1 . '</a> ';
}
//premiére / dernier
if ($pageActuelle > 1) {$centerPages = ' <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page=1">1</a> ..'.$centerPages;}
if ($pageActuelle < $nombreDePages) {$centerPages .= '.. <a href="' . $_SERVER['PHP_SELF'] . '?'.$get_query.'page='.$nombreDePages.'">'.$nombreDePages.'</a> ';}
///select pagination
$select_pagination ="<form style='display: inline;'><select name='select_pagination' onChange='top.location.href = this.form.select_pagination.options[this.form.select_pagination.selectedIndex].value;return false;'>";
for ($i = 1; $i <= $nombreDePages; $i++)
if($pageActuelle == $i)
{$select_pagination .="<option value='".$i."' selected>".$i."</option>";}
else
{$select_pagination .="<option value='".$_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $i."'>".$i."</option>";}
$select_pagination .="</select></form>";
// location.href=\'".$_SERVER['PHP_SELF'] . '?'.$get_query.'page=' . $i."\'
//////////////////////////////// END Pagination Logic ////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Pagination Display Setup /////////////////////////////////////////////////////////////////////
$paginationDisplay = ""; // Initialize the pagination output variable
// This code runs only if the last page variable is ot equal to 1, if it is only 1 page we require no paginated links to display
if ($nombreDePages != "1"){
// This shows the user what page they are on, and the total number of pages
$paginationDisplay .= 'Page <strong>'. $select_pagination . '</strong> sur ' . $nombreDePages. ' ';
// If we are not on page 1 we can place the Back button
if ($pageActuelle != 1) {
$previous = $pageActuelle - 1;
$paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?page=' . $previous . '"> Précédent</a> ';
}
// Lay in the clickable numbers display here between the Back and Next links
$paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>';
// If we are not on the very last page we can place the Next button
if ($pageActuelle != $nombreDePages) {
$nextPage = $pageActuelle + 1;
$paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?page=' . $nextPage . '"> Suivant</a> ';
}
}
?>
<div class="row">
<div class="col-lg-12 text-center" style="padding:10px;"><?php echo $paginationDisplay; ?></div>
</div>
<div class="modal fade modal-primary" id="copiedok" data-easein="flipXIn" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog fadeInDown animated modal-sm modal-dialog-centered" role="document">
<div class="modal-content" style="background-color: #dff0d8;border-color : #d6e9c6;">
<div class="modal-body row-fluid">
<center><h4 style="color: #3c763d;">Ligne Copiée</h4></center>
</div>
</div>
</div>
</div>
</div>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="../bower_components/metisMenu/dist/metisMenu.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="../dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->
<!--link href="../datatable/jquery.dataTables.css" rel="stylesheet"-->
<link href="../datatable/responsive.dataTables.css" rel="stylesheet">
<link href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap.min.css" rel="stylesheet">
<!--script src="../datatable/jquery.dataTables.js"></script-->
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="../datatable/dataTables.responsive.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/dataTables.foundation.min.js"></script>
<script>
function copier_ligne_cmd_to_excel(id) {
var copyText = document.getElementById('excel_format'+id);
var range, select;
if (document.createRange) {
range = document.createRange();
range.selectNode(copyText)
select = window.getSelection();
select.removeAllRanges();
select.addRange(range);
document.execCommand('copy');
select.removeAllRanges();
} else {
range = document.body.createTextRange();
range.moveToElementText(copyText);
range.select();
document.execCommand('copy');
}
////
/* Alert the copied text */
// alert("Ligne Copiée " + copyText.innerHTML );
// alert("Ligne Copiée");
// if (confirm("Ligne Copiée \n Voulez-vous ouvrir KADECO CMD ?")) {
// Clic sur OK
// window.open('https://www.dropbox.com/scl/fi/67xtagulolqey2w2jf4o3/kadeco-cmd.xlsx?cloud_editor=excel&dl=0&activeCell=%27kadeco%27!F486&wdInitialSession=7ad6a266-d67d-4d28-b690-b4634c85821f&wdRldC=1','_blank');
// }
}
</script>
<script>
$('a[closemodal="ok"]').click( function () {$('.modal').modal('hide');});
$('button[closemodal="ok"]').click( function () {$('.modal').modal('hide');});
$('select.option[closemodal="ok"]').click( function () {$('.modal').modal('hide');});
$(function () {
$('[data-toggle="tooltip"]').tooltip({html: true});
$('[data-toggle="popover"]').popover({html: true});
$('body').on('click', function (e) {
$('[data-toggle="popover"]').each(function () {
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {$(this).popover('hide');}
});
});
});
$.extend( $.fn.dataTable.defaults, {
responsive: true
} );
$(document).ready(function() {
$('#dataTables-user').DataTable( {
"initComplete": function () {
var api = this.api();
// api.$('i').click( function () {
// api.search( this.abbr ).draw();
$('i').click( function () {
api.search( $(this).attr('search') ).draw();
// $('.modal').modal('hide');
} );
$('select').on('change', function() {
api.search( this.value ).draw();
$('.modal').modal('hide');
});
},
"processing": true,
"stateSave": false,
"order": [[ 4, "desc" ]],
"language": {
"sProcessing": "Traitement en cours...",
"sSearch": false,
"sLengthMenu": "Afficher _MENU_ éléments",
"sInfo": "Affichage de l'élément _START_ à _END_ sur _TOTAL_ éléments",
"sInfoEmpty": "Affichage de l'élément 0 à 0 sur 0 élément",
"sInfoFiltered": "(filtré de _MAX_ éléments au total)",
"sInfoPostFix": "",
"sLoadingRecords": "Chargement en cours...",
"sZeroRecords": "Aucun élément à afficher",
"sEmptyTable": "Aucune donnée disponible dans le tableau",
"oPaginate": false,
"oAria": {
"sSortAscending": ": activer pour trier la colonne par ordre croissant",
"sSortDescending": ": activer pour trier la colonne par ordre décroissant"
}
}
} );
} );
</script>
<?php
$fin = microtime(true);
$delai = $fin - $debut;
echo '<center>Le temps écoulé est de '.$delai.' millisecondes.</center>';
echo "<style>#dataTables-user {visibility: visible;}</style>";
?>
</body>
</html>