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 134 135 136 137 138 139
|
$(document).ready(function () {
$("#select_client").selectmenu({
width: 337,
change:function () {
var client = $('#select_client').val();
if (client === '-1') {
$('#table_tarif_ajout_projet_mots tr').remove();
var row_entete = $("<tr />");
$("#table_tarif_ajout_projet_mots").append(row_entete);
row_entete.append($("<th class='th_ajouter_projet_numero'>" + "N°" + "</th><th class='th_ajouter_projet'>" + "Match" + "</th><th class='th_ajouter_projet'>" + "Nb mots" + "</th><th class='th_ajouter_projet'>" + "Tarif" + "</th>"));
}
$.ajax({
type: "POST",
data: {"nom_select_client": client},
url: "traitement.php",
dataType: "json",
success: function (data) {
rows = data.length;
$('#table_tarif_ajout_projet_mots tr').remove();
var row_entete = $("<tr />");
$("#table_tarif_ajout_projet_mots").append(row_entete);
row_entete.append($("<th class='th_ajouter_projet_numero'>" + "N°" + "</th><th class='th_ajouter_projet'>" + "Match" + "</th><th class='th_ajouter_projet'>" + "Nb mots" + "</th><th class='th_ajouter_projet'>" + "Tarif" + "</th>"));
$.each(data, function (index, valeur) {
num = index + 1;
var input_match = $('<input>', {
type: 'text',
class: 'input_tarif_projet',
value: valeur.match_def,
name: 'match['+index+']'
});
input_match.attr('size', '11');
input_match.attr('maxlength', '15');
input_match.attr('onblur','verifText(this);');
var input_nbmots = $('<input>', {
type: 'text',
class: 'input_tarif_projet',
name: 'nbmots['+index+']'
});
input_nbmots.attr('size', '6');
input_nbmots.attr('onblur','verifInteger(this);');
var input_val = $('<input>', {
type: 'text',
class: 'input_tarif_projet',
value: (valeur.tarif_mot_def).replace(".",","),
name: 'tarif_mot['+index+']'
});
input_val.attr('size', '6');
input_val.attr('onblur','verifPrix_mot(this);');
var row = $("<tr />");
$("#table_tarif_ajout_projet_mots").append(row);
row.append($("<td class='td_ajouter_projet_numero'>" + num + "</td>"));
row.append($("<td class='td_ajouter_projet'>").append($(input_match)).append($("</td>")));
row.append($("<td class='td_ajouter_projet'>").append($(input_nbmots)).append($("</td>")));
row.append($("<td class='td_ajouter_projet'>").append($(input_val)).append($("</td>")));
$('#img_tab_plus_projet').css({ "display": 'block'});
$('#img_tab_moins_projet').css({ "display": 'block'});
});
}
});
}
});
});
var compteur = 0;
function addMatch(idChamp) {
if (compteur < 5) {
var conteneur = document.getElementById(idChamp);
var tr1 = document.createElement('tr');
var td1 = document.createElement('td');
var td2 = document.createElement('td');
var td3 = document.createElement('td');
var td4 = document.createElement('td');
var num = document.createElement('p');
var match_supp = document.createElement('input');
var nbmots_supp = document.createElement('input');
var tarif_mot_supp = document.createElement('input');
num.setAttribute("id","num["+compteur+"]");
match_supp.setAttribute("type","text");
match_supp.setAttribute("size","11");
match_supp.setAttribute("class","input_tarif_projet");
match_supp.setAttribute("name","match_supp["+compteur+"]");
match_supp.setAttribute("onblur","verifText(this);");
match_supp.setAttribute('maxlength', 15);
nbmots_supp.setAttribute("type","text");
nbmots_supp.setAttribute("size","6");
nbmots_supp.setAttribute("class","input_tarif_projet");
nbmots_supp.setAttribute("name","nbmots_supp["+compteur+"]");
nbmots_supp.setAttribute("onblur","verifInteger(this);");
nbmots_supp.setAttribute('maxlength', 10);
tarif_mot_supp.setAttribute("type","text");
tarif_mot_supp.setAttribute("size","6");
tarif_mot_supp.setAttribute("class","input_tarif_projet");
tarif_mot_supp.setAttribute("name","tarif_mot_supp["+compteur+"]");
tarif_mot_supp.setAttribute("onblur","verifPrix_mot(this);");
tarif_mot_supp.setAttribute('maxlength', 6);
td1.appendChild(num);
td1.setAttribute("class","td_ajouter_projet_numero");
td2.appendChild(match_supp);
td2.setAttribute("class","td_ajouter_projet");
td3.appendChild(nbmots_supp);
td3.setAttribute("class","td_ajouter_projet");
td4.appendChild(tarif_mot_supp);
td4.setAttribute("class","td_ajouter_projet");
tr1.appendChild(td1);
tr1.appendChild(td2);
tr1.appendChild(td3);
tr1.appendChild(td4);
conteneur.appendChild(tr1);
document.getElementById("num["+compteur+"]").innerHTML = compteur+1;
compteur++;
}
else
{
alert('Nombre maximum de match/tarif atteint (total : 5)');
}
}
function supprimerMatch(){
var oTable = document.getElementById('table_tarif_ajout_projet_mots');
if( oTable.rows.length > 2){
oTable.deleteRow(-1);
compteur--;
} else {
alert('Suppression impossible (minimum 1)');
}
}
function afficherMatch(){
if (document.getElementById('affMatch').style.display === 'none'){
document.getElementById('affMatch').style.display = 'block';
}
}
function masquerMatch(){
var oTable = document.getElementById('table_tarif_ajout_projet_mots');
if( oTable.rows.length === 1){
if (document.getElementById('affMatch').style.display === 'block'){
document.getElementById('affMatch').style.display = 'none';
}
}
} |
Partager