text: $(document).on("click", "#rechercher_certificat", function(){
  
  	var parent = $("#parent").val();
      var eleve = $("#eleve").val();
      var langue = $("#langue").val();
      var date_certificat = $("#date_certificat").val();
  
      var locale = $("#locale").val();
  
      $.ajax({
          type: 'GET',
          datatype: 'json',
          url: "/fr/certificats/search?parent=" + parent + "&eleve=" + eleve + "&langue=" + langue + "&date_certificat=" + date_certificat,
          cache: false,
          success: function (data) {
          	var certificats = JSON.parse(data);
          	var _html = "";
  
          	$("#dataTables-example").find("tbody").html("");
  
          	if(certificats!=null)
          	{
          		for(var k=0; k<certificats.length; k++)
              	{
          			if(locale == "ar"){
          				_html += "<tr><td>" + certificats[k]["parent_nom_ar"] + " " + certificats[k]["parent_prenom_ar"] + "</td><td>" + certificats[k]["eleve_nom_ar"] + " " + certificats[k]["eleve_prenom_ar"] + "</td><td>" + certificats[k]["date_certificat"] + "</td><td>" + certificats[k]["en_francais"] + "</td><td>" + certificats[k]["en_arabe"] + "</td><td>" + (certificats[k]["realisation"] == '1' ? 'Oui' : 'Non') + "</td>";
          				_html += "<td><a class='supprimer' title='Supprimer' data-id='" + certificats[k]["id"] + "'><li class='fa fa-trash'></li> </a>";
  
          				if(certificats[k]["realisation"] == '1')
          				{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='1'><li class='fa fa-check'></li> </a></td>";
          				}else{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='0'><li class='fa fa-minus-circle'></li> </a></td>";
          				}
  
          				_html += "</tr>";
          			}else{
          				_html += "<tr><td>" + certificats[k]["parent_nom"] + " " + certificats[k]["parent_prenom"] + "</td><td>" + certificats[k]["eleve_nom"] + " " + certificats[k]["eleve_prenom"] + "</td><td>" + certificats[k]["date_certificat"] + "</td><td>" + certificats[k]["en_francais"] + "</td><td>" + certificats[k]["en_arabe"] + "</td><td>" + (certificats[k]["realisation"] == '1' ? 'Oui' : 'Non') + "</td>";
  	        			_html += "<td><a class='supprimer' title='Supprimer' data-id='" + certificats[k]["id"] + "'><li class='fa fa-trash'></li> </a>";
  
  	        			if(certificats[k]["realisation"] == '1')
          				{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='1'><li class='fa fa-check'></li> </a></td>";
          				}else{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='0'><li class='fa fa-minus-circle'></li> </a></td>";
          				}
  
  	        			_html += "</tr>";
          			}
              	}
          	}
  
          	$("#dataTables-example").find("tbody").html(_html);
          	$(".notes-resultats").find(".panel-body").removeClass("hidden");
  
              return false;
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              console.log('erreur');
          }
      });
  });
  
  $(document).on("click", ".supprimer", function(){
  
  	var id = $(this).data("id");
      var locale = $("#locale").val();
  
      $.ajax({
          type: 'GET',
          datatype: 'json',
          url:  "/fr/certificats/supprimer?id=" + id,
          cache: false,
          success: function (data) {
          	var certificats = JSON.parse(data);
          	var _html = "";
  
          	$("#dataTables-example").find("tbody").html("");
  
          	if(certificats!=null)
          	{
          		for(var k=0; k<certificats.length; k++)
              	{
          			if(locale == "ar"){
          				_html += "<tr><td>" + certificats[k]["parent_nom_ar"] + " " + certificats[k]["parent_prenom_ar"] + "</td><td>" + certificats[k]["eleve_nom_ar"] + " " + certificats[k]["eleve_prenom_ar"] + "</td><td>" + certificats[k]["date_certificat"] + "</td><td>" + certificats[k]["en_francais"] + "</td><td>" + certificats[k]["en_arabe"] + "</td><td>" + (certificats[k]["realisation"] == '1' ? 'Oui' : 'Non') + "</td>";
          				_html += "<td><a class='supprimer' title='Supprimer' data-id='" + certificats[k]["id"] + "'><li class='fa fa-trash'></li> </a>";
  
          				if(certificats[k]["realisation"] == '1')
          				{
          					_html += " | <a class='realiser' title='Annuler la réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='1'><li class='fa fa-minus-circle'></li> </a></td>";
          				}else{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='0'><li class='fa fa-check'></li> </a></td>";
          				}
  
          				_html += "</tr>";
          			}else{
          				_html += "<tr><td>" + certificats[k]["parent_nom"] + " " + certificats[k]["parent_prenom"] + "</td><td>" + certificats[k]["eleve_nom"] + " " + certificats[k]["eleve_prenom"] + "</td><td>" + certificats[k]["date_certificat"] + "</td><td>" + certificats[k]["en_francais"] + "</td><td>" + certificats[k]["en_arabe"] + "</td><td>" + (certificats[k]["realisation"] == '1' ? 'Oui' : 'Non') + "</td>";
  	        			_html += "<td><a class='supprimer' title='Supprimer' data-id='" + certificats[k]["id"] + "'><li class='fa fa-trash'></li> </a>";
  
  	        			if(certificats[k]["realisation"] == '1')
          				{
          					_html += " | <a class='realiser' title='Annuler la réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='1'><li class='fa fa-minus-circle'></li> </a></td>";
          				}else{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='0'><li class='fa fa-check'></li> </a></td>";
          				}
  
  	        			_html += "</tr>";
          			}
              	}
          	}
  
          	$("#dataTables-example").find("tbody").html(_html);
          	$(".notes-resultats").find(".panel-body").removeClass("hidden");
  
              return false;
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              console.log('erreur');
          }
      });
  });
  
  $(document).on("click", ".realiser", function(){
  
  	var id = $(this).data("id");
  	var val = $(this).data("realisation");
      var locale = $("#locale").val();
  
      $.ajax({
          type: 'POST',
          datatype: 'json',
          url:  "/fr/certificats/realiser",
          cache: false,
          data: {id: id, val: val},
          success: function (data) {
          	var certificats = JSON.parse(data);
          	var _html = "";
  
          	$("#dataTables-example").find("tbody").html("");
  
          	if(certificats!=null)
          	{
          		for(var k=0; k<certificats.length; k++)
              	{
          			if(locale == "ar"){
          				_html += "<tr><td>" + certificats[k]["parent_nom_ar"] + " " + certificats[k]["parent_prenom_ar"] + "</td><td>" + certificats[k]["eleve_nom_ar"] + " " + certificats[k]["eleve_prenom_ar"] + "</td><td>" + certificats[k]["date_certificat"] + "</td><td>" + certificats[k]["en_francais"] + "</td><td>" + certificats[k]["en_arabe"] + "</td><td>" + (certificats[k]["realisation"] == '1' ? 'Oui' : 'Non') + "</td>";
          				_html += "<td><a class='supprimer' title='Supprimer' data-id='" + certificats[k]["id"] + "'><li class='fa fa-trash'></li> </a>";
  
          				if(certificats[k]["realisation"] == '1')
          				{
          					_html += " | <a class='realiser' title='Annuler la réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='" + certificats[k]["realisation"] + "'><li class='fa fa-minus-circle'></li> </a></td>";
          				}else{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='" + certificats[k]["realisation"] + "'><li class='fa fa-check'></li> </a></td>";
          				}
  
          				_html += "</tr>";
          			}else{
          				_html += "<tr><td>" + certificats[k]["parent_nom"] + " " + certificats[k]["parent_prenom"] + "</td><td>" + certificats[k]["eleve_nom"] + " " + certificats[k]["eleve_prenom"] + "</td><td>" + certificats[k]["date_certificat"] + "</td><td>" + certificats[k]["en_francais"] + "</td><td>" + certificats[k]["en_arabe"] + "</td><td>" + (certificats[k]["realisation"] == '1' ? 'Oui' : 'Non') + "</td>";
  	        			_html += "<td><a class='supprimer' title='Supprimer' data-id='" + certificats[k]["id"] + "'><li class='fa fa-trash'></li> </a>";
  
  	        			if(certificats[k]["realisation"] == '1')
          				{
          					_html += " | <a class='realiser' title='Annuler la réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='" + certificats[k]["realisation"] + "'><li class='fa fa-minus-circle'></li> </a></td>";
          				}else{
          					_html += " | <a class='realiser' title='Réaliser' data-id='" + certificats[k]["id"] + "' data-realisation='" + certificats[k]["realisation"] + "'><li class='fa fa-check'></li> </a></td>";
          				}
  
  	        			_html += "</tr>";
          			}
              	}
          	}
  
          	$("#dataTables-example").find("tbody").html(_html);
          	$(".notes-resultats").find(".panel-body").removeClass("hidden");
  
              return false;
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
              console.log('erreur');
          }
      });
  });
  