1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| $(window).ready(function(){
var site_url= $('section.content-section').attr('data-id');
$('.pagination li').click(function(){
cl = $(this).hasClass('active');
if(!cl){
$('.pagination').find('li.active').removeClass('active');
$(this).addClass('active');
p = $(this).attr('id');
id = $('.table').attr('user-id')
$.ajax({
url : site_url+'scripts/admin.php',
type : "POST",
data : {
action : "pagination",
p : p,
id : id,
},
dataType : "json",
success : function(data){
if(data.status == 1){
$('.table .vide').remove();
j = (data.data).length+(10*p);
for(i=0;i<(data.data).length;i++){
date = data.data[i]['DateDiff'] == null ? 'Non activé' : data.data[i]['DateDiff'];
$('tr.titre').after("<tr class='vide'>"+
"<td>"+(j--)+"</td>"+
"<td>"+data.data[i]['Software_name']+"</td>"+
"<td>"+data.data[i]['Licence']+"</td>"+
"<td>"+date+"</td>"+
"</tr>");
}
}
else{
alertbox('error', data.msg, 4000);
}
}
});
}
});
$('.soft').on('change',function(){
id_soft = $(this).val();
$.ajax({
url : site_url+'scripts/info.php',
type : "POST",
data : {
action : "dispo",
id : id_soft,
},
dataType : "json",
success : function(data){
if(data.status == 1){
$('.TypeL').empty();
for(i=0;i<(data.data).length;i++){
$('.TypeL').append('<option value='+data.data[i]['TypeLicence_id']+'>'+data.data[i]['TypeLicence_libelle']+'</option>');
}
}
else{
alertbox('error', data.msg, 4000);
}
}
})
});
$('.export').click(function(){
id = $('.table').attr('user-id');
$.ajax({
url : site_url+'scripts/admin.php',
type : "POST",
data : {
action : "CSVlicenceU",
id : id,
},
dataType : "json",
success : function(data){
if(data.status == 1){
alertbox('success', data.msg, 4000);
location.href= site_url+'csv/ExportLicenceClient.csv';
}
else{
alertbox('error', data.msg, 4000);
}
}
})
});
$('#addLicence').click(function(){
soft = $('.soft option:selected').val();
licence = $('.TypeL option:selected').val();
qt = $('input[name=qt]').val();
$.ajax({
url : site_url+'scripts/info.php',
type : "POST",
data : {
action : "info-prix",
soft : soft,
licence : licence,
qt : qt,
},
dataType : "json",
success : function(data){
if(data.status == 1){
id = parseInt($(".ListeLicence table tbody tr").last().attr('id'));
$(".ListeLicence table tbody").append("<tr id="+data.data['Dispo_id']+" qt='"+qt+"' ><td>"+data.data['software_name']+"</td>"+
"<td>"+data.data['TypeLicence_libelle']+"</td>"+
"<td>"+qt+'</td><td>'+data.data['prix']+"</td>"+
"<td> <i id="+data.data['Dispo_id']+" class='glyphicon glyphicon-trash deleteSoft'></i></td></tr>");
}
else{
alertbox('error', data.msg, 4000);
}
}
})
$('.ListeLicence table').on('click',".deleteSoft", function(){
id = $(this).attr('id');
$('.ListeLicence tbody tr').each(function() {
if($(this).attr('id') == id){
$(this).remove();
}
});
});
$('.btn-add-li').click(function(){
var dispo = new Array();
var qt = new Array();
f = 0;
id = $('.table').attr('user-id');
$(this).prev(".table-striped").find('tr').each(function() {
if($(this).attr('id') != 0){
dispo.push($(this).attr('id'));
}
});
console.log(dispo);
console.log('ici');
});
});
}); |