Bonjour tout le monde,
Je reprends le code de quelqu'un pour résoudre plusieurs bugs.
Je n'arrive pas à trouver la solution pour le dernier bug, l'id de la cotisation du membre est toujours égal à 13 :
Dans la BD j'ai :
Au retour de PHP (ajax), j'ai ceci :
Le problème est le suivant, il y a création de bouton avec id, mais l'id de la cotisation est toujours 13 :[{"idCotisation":"13","montant":"10.00"},{"idCotisation":"58","montant":"10.00",{"idCotisation":"85","montant":"5.00"},{"idCotisation":"86","montant":"5.00"},{"idCotisation":"115","montant":"10.00"},{"idCotisation":"142","montant":"10.00"}
etc...
]
C'est la variable data-whatever="13" qui nous intéresse dans ce cas.
Voici le code, j'ai pas débugué, mais je n'y arrive pas (voir ligne 176 à 178 :
Je vous remercie d'avance pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 $.ajax( { type: 'POST', url: 'php/gestionCotisations.php', data: { to_send:to_send }, dataType:'text', success:function(retour_php) { //alert(retour_php); try { var retour = JSON.parse(retour_php); //console.log('ici 3-> '+retour); } catch(error) { $('#nombre_resultat2').text('Aucun résultat trouvé!').css("color","red"); $("ul.listetotale div").remove(); return false; } //console.warn(retour); if(retour == "" || retour == false) { console.warn("NO DATA BACK!"); $('#nombre_resultat2').text('Aucun résultat trouvé!').css("color","red"); $("ul.listetotale div").remove(); return false; } //suppression totale des résultats $("ul.listetotale div").remove(); //var lastval={}; //var rejoin; var alldata=""; var lastId=""; var doublons=0; var pass=0; var tempval=""; var total = 0; var totalDon = 0; var totalMembre = 0; var nextline=0; var montant=0; var num_versement=0; var communication=0; var type=0; //alert(retour.length); for(var i = 0; i < retour.length; i++) { var obj = retour[i]; //alert(obj[i]); //console.log('llllllaaaaa --->'+obj[i]); if (nextline > 1) { nextline-=1; doublons+=1; continue; } total = 0; totalDon = 0; totalMembre = 0; $.each(obj, function(index, value) { if (value == null || value == undefined) { obj[index] = ""; } }); if ((!($("#noNames").is(":checked")) && obj.nom=="" && obj.prenom=="")) { continue; } //Trop gourmand , essai pour le gif non concluant voire pire avec d'autre animation en js. //timestamp=Date(); //while (new Date() < timestamp +1) {}; alldata+= '<div><li><div class="panel panel-default"><div class="panel-heading">\ <h4 class="panel-title">'; //console.log('iciiiiiiiiiii -->'+ value); if (obj.nom == "" && obj.prenom == "") { alldata+='<a data-toggle="collapse" href="#' + obj.idMembre + '" class="membreNomPrenom">Sans nom et prénom, institution: '+ obj.institution + '</a>'; } else { alldata+='<a data-toggle="collapse" href="#' + obj.idMembre + '" class="membreNomPrenom">'+ obj.nom+ ' ' + obj.prenom+ '</a>'; } alldata+='</h4>\ </div>\ <div id="' + obj.idMembre + '" class="panel-collapse collapse" >\ <div class="panel-body">\ <div class="container-fluid">\ <div class="row" style="margin-bottom: 10px">'; //création d'une cotisation if (create_cot) { alldata+='<div class="col-md-1">\ <button type="button" class="btn btn-default btn-sm" aria-label="Left Align" data-target="#modalAjoutCotisation" data-whatever="' + obj.idMembre + '" data-toggle="modal" >\ <span class="glyphicon glyphicon-plus"></span>\ Ajouter une cotisation\ </button>\ </div>'; } alldata+='</div>\ <div class="table-responsive">\ <table class="table">\ <thead>\ <tr>\ <th>Extrait</th>\ <th>Date</th>\ <th>Montant</th>\ <th>Communication</th>\ <th>Type</th>'; alldata+='</tr>\ </thead>\ <tbody id="'+obj.idMembre+'">'; nextline=0; do { if (nextline>=1) { montant=retour[i+nextline].montant; num_versement=retour[i+nextline].num_versement; date_paiement=retour[i+nextline].date_paiement; communication=retour[i+nextline].communication; type=retour[i+nextline].type; idcot = [i+nextline].idCotisation; //alert(idcot); } else { montant = obj.montant; num_versement = obj.num_versement; date_paiement = obj.date_paiement; communication = obj.communication; type = obj.type; idcot = obj.idCotisation; //alert(idcot); } if (montant !=0) { total += parseFloat(montant); } //alert(obj.idCotisation); alldata+='<tr id="'+ obj.idCotisation + '">'; alldata+='<td class="numVersement">ici ->' + num_versement + '</td>'; alldata+='<td class="datePaiement">' + date_paiement + '</td>'; alldata+='<td class="montantCotisation">' + montant + '</td>'; alldata+='<td class="communication">' + communication + '</td>'; alldata+='<td class="type">' + type + '</td>'; if (total>0) { if (up_cot) { alldata+='<th><button type="button" class="btn btn-default" aria-label="Left Align" data-target="#modalModificationPaiement" data-whatever="' + obj.idCotisation + '" data-toggle="modal" >\ <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>\ </button></th>'; } //suppressionCotisation if (del_cot) { alldata+='<th><button type="button" class="btn btn-default" aria-label="Left Align" data-whatever="' + obj.idCotisation + '">\ <span id="suppressionCotisation" class="glyphicon glyphicon-trash" aria-hidden="true"></span>\ </button></th>'; } }
bee
Partager