Guest User

Untitled

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