<!-- START CSS STYLE FILE CALL -->
<link rel="stylesheet" type="text/css" href="../files/customer_mail_alert_stock/css/customer_mail_alert_stock.css" rel="stylesheet">
<!-- END CSS STYLE FILE CALL -->
<!-- START CSS DATATABLES FILE CALL -->
<link rel="stylesheet" type="text/css" src="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" src="https://cdn.datatables.net/buttons/2.1.0/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css" src="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
<!-- END CSS DATATABLES FILE CALL -->
<!-- START JQUERY CALL -->
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
<!-- END JQUERY CALL -->
<!-- START DATATABLES CALL -->
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.flash.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.6.2/js/buttons.print.min.js"></script>
<!-- END DATATABLES CALL -->
<!-- START JAVASCRIPT FUNCTIONS FILE CALL -->
<script type="text/javascript" language="javascript" src="../files/customer_mail_alert_stock/js/customer_mail_alert_stock.js"></script>
<!-- END JAVASCRIPT FUNCTIONS FILE CALL -->
<!-- START MAIN CONTENT -->
<div class="right_col" role="main">
<div>
<!-- START HEADER PAGE CONTENT -->
<div class="page-title">
<div class="title_left">
<h3>Requalification demandes d'alertes</h3>
</div>
</div>
<div class="clearfix"></div>
<div>
<p class="alert alert-success" style="text-align:center;">
</p>
</div>
<!-- END HEADER PAGE CONTENT -->
<!-- START MAIN PAGE CONTENT -->
<div id="update_customers_alert_success" class="alert alert-success alert-dismissible" role="alert" style="text-align:center; display:none"></div>
<div id="update_customers_alert_failed" class="alert alert-danger alert-dismissible" role="alert" style="text-align:center; display:none;"></div>
<div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_content">
<div class="row">
<div class="col-sm-12">
<div class="card-box table-responsive" id="customer_mail_alert_stock_table">
</div>
</div>
</div>
</div>
<div class="x_content">
<select id="bulk_option_select" class="form-control" style="display: inline !important;" >
<option value="" disabled selected>Actions groupées</option>
<option value="delete_checked">Supprimer</option>
<option value="export_checked">Exporter</option>
</select>
<button onclick="bulkAction()" id="btn_ok" class="btn btn-success">OK</button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_content">
<div class="row">
<div class="col-sm-12">
<p style="text-align: center;" id="cron_command"></p>
<button style="margin:0 auto; display:block;" onclick="updateCustomers()" class="btn btn-success">Exécuter</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END MAIN PAGE CONTENT -->
</div>
</div>
<!-- END MAIN CONTENT -->
<!-- MODAL LOADING -->
<div class="modalChanged" id="divModalLoading">
</div>
.dataTables_length {
float: right;
}
.dataTables_filter {
float: left;
text-align: left;
}
#bulk_option_select{
width:200px;
margin-left: 16px;
}
.btn.btn-default.buttons-csv.buttons-html5 {
background-color: #eeeeee;
border-color: #ffffff;
border-width: initial;
border-radius: 6px;
margin-left: 20px;
}
var documentRoot;
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const product = (urlParams.get('product')) ? urlParams.get('product') : '';
let path_admin = '';
function loadDocumentRoot() {
var datas = {
path : "utils",
page : "get_document_root",
bJSON : 1
}
$.ajax({
type: "POST",
url: "route.php",
async: true,
data: datas,
dataType: "json",
cache: false
})
.done(function(result) {
console.log(result);
documentRoot = result;
var cron_command_div = document.getElementById("cron_command");
cron_command_div.innerHTML = "Pour lancer le cron, utilisez la commande suivante : /usr/local/bin/php " + documentRoot + "/modules/boiteaoutils/files/customer_mail_alert_stock/cron/cron_customer_mail_alert_stock.php";
})
.fail(function(err) {
console.log("error");
// error
});
}
var aOfCustomers = [];
// variable contenant la datatable
var tablesCustomers;
var tokenAdminProducts;
function loadTokenAdminProducts() {
var datas = {
path : "token",
page : "get_token_admin_products",
bJSON : 1
}
$.ajax({
type: "POST",
url: "route.php",
async: true,
data: datas,
dataType: "json",
cache: false
})
.done(function(result) {
console.log(result);
var linkAdminProducts = result;
var AdminProductsParts = linkAdminProducts.split('token=', 2);
tokenAdminProducts = AdminProductsParts[1];
})
.fail(function(err) {
console.log("error");
// error
});
}
// charge la liste des stocks en Ajax et construit le tableau JS
function loadCustomers() {
var datas = {
path : "customer_mail_alert_stock",
page : "customer_mail_alert_stock_list",
bJSON : 1
}
$.ajax({
type: "POST",
url: "route.php",
async: true,
data: datas,
dataType: "json",
cache: false
})
.done(function(result) {
var iCustomer = 0;
aOfCustomers = [];
path_admin = result.path_admin
for (var ligne in result) {
if (ligne != 'path_admin') {
aOfCustomers[iCustomer] = [];
aOfCustomers[iCustomer]["id_customer"] = result[ligne]["id_customer"];
aOfCustomers[iCustomer]["email"] = result[ligne]["email"];
aOfCustomers[iCustomer]["id_product"] = result[ligne]["id_product"];
aOfCustomers[iCustomer]["name"] = result[ligne]["name"];
aOfCustomers[iCustomer]["lastname"] = result[ligne]["lastname"];
aOfCustomers[iCustomer]["firstname"] = result[ligne]["firstname"];
aOfCustomers[iCustomer]["id_product_attribute"] = result[ligne]["id_product_attribute"];
aOfCustomers[iCustomer]["date_creation"] = result[ligne]["date_creation"];
aOfCustomers[iCustomer]["product_name"] = result[ligne]["product_name"];
iCustomer++;
}
}
// INIT DATATABLE
constructTableCustomers();
// reload datatable configuration
tablesCustomers = $('#datatable').DataTable(configuration);
$('#divModalLoading').hide();
/*var datatable_filter = $('#datatable_filter').parent();
var datatable_length = $('#datatable_length').parent();
var datatable_filter_clone = datatable_filter.clone();
var datatable_length_clone = datatable_length.clone();
datatable_filter.replaceWith(datatable_length_clone);
datatable_length.replaceWith(datatable_filter_clone);
//$('#datatable_filter').css({'float':'left'});
//$('#datatable_length').css({'float':'right'});*/
})
.fail(function(err) {
// error
alert('error : ' + err.status);
});
}
function updateCustomers() {
var div_update_customers_alert_success = document.getElementById("update_customers_alert_success");
var div_update_customers_alert_failed = document.getElementById("update_customers_alert_failed");
var datas = {
path : "customer_mail_alert_stock",
page: "customer_mail_alert_stock_update",
bJSON: 1
}
$.ajax({
type: "POST",
url: "route.php",
async: true,
data: datas,
dataType: "json",
cache: false
})
.done(function (result) {
console.log(result);
create_toast('Les demandes d\'alertes ont bien été requalifiées', 'success')
// div_update_customers_alert_success.innerHTML += "<strong>Les demandes d'alertes ont bien été requalifiées</strong><br/>";
// div_update_customers_alert_success.style.display = "block";
})
.fail(function (err) {
alert('error : ' + err.status);
});
}
function deleteCustomers() {
for(i = 0; i < aOfCustomers.length; i++) {
if ($('#checkbox_' + i).is(":checked")) {
//console.log("checked " + i);
//console.log(aOfCustomers[i]["id_product"]);
var datas = {
path : "customer_mail_alert_stock",
page: "customer_mail_alert_stock_delete",
bJSON: 1,
'email': aOfCustomers[i]["email"],
'id_product': aOfCustomers[i]["id_product"],
'id_product_attribute': aOfCustomers[i]["id_product_attribute"],
}
$.ajax({
type: "POST",
url: "route.php",
async: true,
data: datas,
dataType: "json",
cache: false
})
.done(function (result) {
console.log(result);
console.log("deleted");
loadCustomers();
})
.fail(function (err) {
alert('error : ' + err.status);
});
}
else {
//console.log("not checked " + i);
}
}
}
function bulkAction() {
//alert($("#bulk_option_select").val());
if ($("#bulk_option_select").val() === 'delete_checked') {
deleteCustomers();
}
else if ($("#bulk_option_select").val() === 'export_checked') {
}
}
function selectAllCustomers() {
if ($('#bulk_action_select_all').not(":checked")) {
for(i = 0; i < aOfCustomers.length; i++) {
if ($('#checkbox_' + i).is(":checked")) {
console.log("checked " + i);
$('#checkbox_' + i).prop('checked', false);
}
}
}
if ($('#bulk_action_select_all').is(":checked")) {
for(i = 0; i < aOfCustomers.length; i++) {
if ($('#checkbox_' + i).not(":checked")) {
console.log("not checked " + i);
$('#checkbox_' + i).prop('checked', true);
}
}
}
}
// construit la table avec les données
function constructTableCustomers() {
var i;
// tableau datatable
var sHTML = "";
sHTML += '<table id="datatable" class="table table-striped table-bordered" style="width:100%">';
sHTML += "<thead>";
sHTML += "<tr>";
sHTML += '<th></th>';
sHTML += "<th>ID CLIENT </th>";
sHTML += "<th style='padding-right: 15px !important;'>EMAIL CLIENT</th>";
sHTML += "<th>ID PRODUIT</th>";
sHTML += "<th>NOM PRODUIT</th>";
sHTML += "<th>ATTRIBUT</th>";
sHTML += "<th>ID ATTRIBUT</th>";
sHTML += "<th>NOM</th>";
sHTML += "<th>PRENOM</th>";
sHTML += "<th>DATE DE CREATION</th>";
sHTML += "</tr>";
sHTML += "</thead>";
sHTML += "<tbody>";
// pour chaque ligne de résultat, construire la ligne dans datatable
for(i = 0; i < aOfCustomers.length; i++) {
sHTML += '<tr style="text-align:center;">';
sHTML += '<td></td>';
sHTML += `<td><a href='/${path_admin}/index.php/sell/customers/${aOfCustomers[i]["id_customer"]}/view?_token=${tokenAdminProducts}' target="_blank">${aOfCustomers[i]["id_customer"]}</a></td>`;
sHTML += `<td><a href='/${path_admin}/index.php/sell/customers/${aOfCustomers[i]["id_customer"]}/view?_token=${tokenAdminProducts}' target="_blank">${aOfCustomers[i]["email"]}</a></td>`;
sHTML += `<td><a href='/${path_admin}/index.php/sell/catalog/products/${aOfCustomers[i]["id_product"]}?_token=${tokenAdminProducts}' target='_blank'>${aOfCustomers[i]["id_product"]}</a></td>`;
sHTML += "<td>" + aOfCustomers[i]["product_name"] + "</td>";
sHTML += "<td>" + aOfCustomers[i]["name"] + "</td>";
sHTML += "<td>" + aOfCustomers[i]["id_product_attribute"] + "</td>";
sHTML += "<td>" + aOfCustomers[i]["lastname"] + "</td>";
sHTML += "<td>" + aOfCustomers[i]["firstname"] + "</td>";
sHTML += "<td>" + aOfCustomers[i]["date_creation"] + "</td>";
sHTML += '</tr>';
}
sHTML += "</tbody>";
sHTML += "</table>";
$('#customer_mail_alert_stock_table').html(sHTML);
}
/**
* clear HTML table
* clear and destroy datatable
* build table and call database
*/
function rebuildDatatableStocks() {
tablesCustomers.clear();
tablesCustomers.destroy();
constructTableCustomers();
tablesCustomers = $('#datatable').DataTable(configuration);
}
// datatable configuration
// order : tri selon une colonne (0 = 1ère colonne) par ordre croissant (asc) ou décroissant (desc)
// pageLength : nombre de résultats affichés par défaut
// lenghtMenu : choix du nombre de résultats à afficher
// language : traduction
// columns :
// orderable : triable (true ou false)
// visible : colonne affichée ou non (ID par exemple, ou date (si on veut trier par la date par exemple)) (true ou false)
// searchable : filtrable par le champ de recherche
const configuration = {
"stateSave": false,
"order": [[9, "desc"], [3, "asc"], [1, "asc"]],
"pageLength": 25,
"pagingType": "simple_numbers",
"searching": true,
"search" : {
'search': product
},
"lengthMenu": [[10, 25, 50, 100, 250, -1], [10, 25, 50, 100, 250, "Tous"]],
"language" : {
"info": "Affichage des lignes _START_ à _END_ sur _TOTAL_ résultats au total",
"emptyTable": "Aucun résultat disponible",
"lengthMenu": "Affichage de _MENU_ résultats",
"search" : "Rechercher : ",
"zeroRecords" : "Aucun résultat trouvé",
"paginate" : {
"previous": "Précédent",
"next": "Suivant"
},
"sInfoFiltered": "(filtrés à partir de _MAX_ résultats au total)",
"sInfoEmpty": "Aucun résultat disponible"
},
dom: 'Bflrtip',
select: true,
buttons: [{
extend: 'csv',
text: 'CSV selected',
exportOptions: {
columns: [1, 2, 3, 4, 5, 6, 7, 8, 9],
modifier: {
selected: true
}
}
}],
columnDefs: [ {
targets: 0,
data: null,
defaultContent: '',
orderable: false,
className: 'select-checkbox'
} ],
select: {
style: 'os',
selector: 'td:first-child'
},
"retrieve": true,
"responsive": true,
"autoWidth": false
};
/**
* Init start
*
*/
// une fois la page chargée, charger les stocks
$(document).ready(function() {
loadTokenAdminProducts();
loadCustomers();
loadDocumentRoot();
});
You can jump to the latest bin by adding /latest
to your URL
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + [ | Indents selected lines |
ctrl + ] | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Clone Bin |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |