Bonsoir à tous,

Suite à des problèmes de lenteur (connue) du dataTables
lors de l'emploi de "bVisible":false,
j'ai dû me résigner à repenser à mes codes...

Je n'y arrive pas.
A nouveau dataTables fait des caprices !
Enfin, j'ai sûrement mal programmé...
Mais je n'arrive pas à mettre le doigt sur mon erreur.

Pouvez-vous tenter de m'aider ?
D'avance, je vous remercie pour votre aide !

Voici la page en question !

Voici mes soucis :
1. Lorsque dans le slider-control "taille" (1er slider de la 2e ligne), je bouge le curseur de droite sur "Excellent", le javascript plante dans "newRecherche()".
2. Lorsque dans le slider-control "sertissure" (3e slider de la 2e ligne), je clique sur l'autre choix, le javascript plante dans "newRecherche()".
3. Lorsque je clique dans la partie de droite sur un ou plusieurs critères avancés, le javascript plante dans "newRecherche()".
En conclusion, cela "foire" dans la fonction "newRecherche()"


Pouvez-vous m'aider à boucler ce dataTables ?
Je n'en peux plus !!!

Pour vous aider à y voir plus clair,
J'y ai mis des alert...

Aussi, je vous joins aussi "chargementdata00.php"
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
 
 <?php
	session_start();
 
	$nbcomparer = 0;
	if (isset($_SESSION['recherche'])) {
		if ($_SESSION['recherche']['stringcomparer'] != "") {
			unset($refcomparer);
			$refcomparer = explode(":", $_SESSION['recherche']['stringcomparer']);
			$nbcomparer = count($refcomparer);
		}
	}
 
	$swCriteres = array();
	if ( isset( $_GET['crit'] )) {
		$criteres = $_GET['crit'];
	} else {
		$criteres = "000000000";
	}
 
	for ($i = 0; $i < 9; $i++) {
		$swCriteres[11+$i] = substr($criteres,$i, 1);
	}
 
	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * libell&eacute;s types
	 */
	$indColumn = 5;
	$libelle = array();
	$libelle[1] = array ("", "Rond", "Princesse", "Emeraude", "Radiant", "Ovale", "Poire", "Marquise", "Coeur", "Asscher CS");
	$libelle[4] = array ("D", "E", "F", "G", "H", "I", "J", "K");
	$libelle[3] = array ("Faible", "Bon", "Très bon", "Excellent", "Idéal");
	$libelle[5] = array ("IF", "VVS1", "VVS2", "VS1", "VS2", "SI1", "SI2", "SI3", "I1");
	if ($swCriteres[11] == "1") {
		$indColumn++;
		$libelle[$indColumn] = array ("Faible", "Bon", "Très bon", "Excellent", "Idéal");
	}
	if ($swCriteres[12] == "1") {
		$indColumn++;
		$libelle[$indColumn] = array ("Faible", "Bon", "Très bon", "Excellent", "Idéal");
	}
	if ($swCriteres[15] == "1") {
		$indColumn++;
		$libelle[$indColumn] = array ("Sans", "Très légère", "Légère", "Faible", "Moyenne", "Forte", "Très forte");
	}
	if ($swCriteres[17] == "1") {
		$indColumn++;
		$libelle[$indColumn] = array ("Pointue", "Très petite", "Petite", "Moyenne", "Large");
	}
	$indColumn++;
	$libelle[$indColumn]  = array ("", "GIA", "HRD", "IGI", "EGL", "AGS");
 
	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * Easy set variables
	 */
 
	/* Array of database columns which should be read and sent back to DataTables. Use a space where
	 * you want to insert a non-database field (for example a counter or static image)
	 */
	$aColumns = array();
	$aColumns [] = 'item_id';										/* 00					*/
	$aColumns [] = 'cut';											/* 01					*/
	$aColumns [] = 'carat';											/* 02					*/
	$aColumns [] = 'cut_grade';										/* 03					*/
	$aColumns [] = 'color';											/* 04					*/
	$aColumns [] = 'clarity';										/* 05					*/
	if ($swCriteres[11] == "1") {
		$aColumns [] = 'polish';				/* 06	option11		*/
	}
	if ($swCriteres[12] == "1") {
		$aColumns [] = 'symmetry';				/* 07	option12		*/
	}
	if ($swCriteres[13] == "1") {
		$aColumns [] = 'depth';					/* 08	option13		*/
	}
	if ($swCriteres[14] == "1") {
		$aColumns [] = 'table'; 				/* 09	option14		*/
	}
	if ($swCriteres[15] == "1") {
		$aColumns [] = 'fluo_intensity';		/* 10	option15		*/
	}
	if ($swCriteres[16] == "1") {
		$aColumns [] = 'price_per_carat_ht';	/* 11	option16		*/
	}
	if ($swCriteres[17] == "1") {
		$aColumns [] = 'culet_size';			/* 12	option17		*/
	}
	if ($swCriteres[18] == "1") {
		$aColumns [] = 'length_width';			/* 13	option18		*/
	}
	$aColumns [] = 'delay';											/* 14					*/
	$aColumns [] = 'certificat';									/* 15					*/
	$aColumns [] = 'total_price_ht';								/* 16					*/
	$aColumns [] = 'item_id';										/* 17					*/
 
	/* Indexed column (used for fast and accurate table cardinality) */
	$sIndexColumn = "item_id";
 
	/* DB table to use */
	$sTable = "diamant_data";
 
	/* Database connection information */
	$gaSql['user']       = "***";
	$gaSql['password']   = "***";
	$gaSql['db']         = "***";
	$gaSql['server']     = "***";
 
 
	/* 
	 * MySQL connection
	 */
	$gaSql['link'] =  mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password']  ) or
		die( 'Could not open connection to server' );
 
	mysql_select_db( $gaSql['db'], $gaSql['link'] ) or 
		die( 'Could not select database '. $gaSql['db'] );
 
	mysql_set_charset( 'utf8' ); 	
 
 
	/* 
	 * Paging
	 */
	$sLimit = "";
	if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
	{
		$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
			intval( $_GET['iDisplayLength'] );
	}
 
 
	/*
	 * Ordering
	 */
	$sOrder = "";
	if ( isset( $_GET['iSortCol_0'] ) )
	{
		$sOrder = "ORDER BY  ";
		for ( $i=0 ; $i<intval( $_GET['iSortingCols'] ) ; $i++ )
		{
			if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
			{
				$sOrder .= "`".$aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."` ".
					($_GET['sSortDir_'.$i]==='asc' ? 'asc' : 'desc') .", ";
			}
		}
 
		$sOrder = substr_replace( $sOrder, "", -2 );
		if ( $sOrder == "ORDER BY" )
		{
			$sOrder = "";
		}
	}
 
	$sWhere = "";
 
	/* Individual column filtering */
	$sColumnWhere = "";
	for ( $i=0 ; $i<count($aColumns) ; $i++ )
	{	
		if ( $_GET['sSearch_'.$i] != "" )
		{
			$aWords = preg_split('/\s+/', $_GET['sSearch_'.$i]);
			$sColumnWhere .= "(";
			for ( $j=0 ; $j<count($aWords) ; $j++ )
			{
				if ( $aWords[$j] != "" )
				{
					$sColumnWhere .= "`".$aColumns[$i]."` = '".mysql_real_escape_string( $libelle[ $i ][ $aWords[$j] ] )."' OR ";
				}
			}
			$sColumnWhere = substr_replace( $sColumnWhere, "", -3 );
			$sColumnWhere .= ") AND ";
		}
		if ( $_GET['sStart_'.$i] != "" AND $_GET['sEnd_'.$i] != "" )
		{
			$sColumnWhere .= "(";
			$sColumnWhere .= "`".$aColumns[$i]."` >= '".mysql_real_escape_string( $_GET['sStart_'.$i] )."' AND `".$aColumns[$i]."` <= '".mysql_real_escape_string( $_GET['sEnd_'.$i] )."' ";
			$sColumnWhere .= ") AND ";
		}
	}
 
	if ( $sColumnWhere != "" ) {
		$sColumnWhere = substr_replace( $sColumnWhere, "", -5 );
		if ( $sWhere == "" ) {
			$sWhere = $sColumnWhere;
		} else {
			$sWhere .= " AND ".$sColumnWhere;
		}
	}
 
	if ( $sWhere != "" )
	{
		$sWhere = "WHERE ".$sWhere;
	}
 
 
	/*
	 * SQL queries
	 * Get data to display
	 */
	$sQuery = "
	 SELECT SQL_CALC_FOUND_ROWS `".str_replace(" , ", " ", implode("`, `", $aColumns))."` 
		FROM   $sTable
		$sWhere
		$sOrder
		$sLimit
		";
	$rResult = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
 
	/* Data set length after filtering */
	$sQuery = "
		SELECT FOUND_ROWS()
	";
	$rResultFilterTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
	$aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
	$iFilteredTotal = $aResultFilterTotal[0];
 
	/* Total data set length */
	$sQuery = "
		SELECT COUNT(`".$sIndexColumn."`)
		FROM   $sTable
	";
	$rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
	$aResultTotal = mysql_fetch_array($rResultTotal);
	$iTotal = $aResultTotal[0];
 
 
	/*
	 * Output
	 */
	$output = array(
		"sEcho" => intval($_GET['sEcho']),
		"iTotalRecords" => $iTotal,
		"iTotalDisplayRecords" => $iFilteredTotal,
		"aaData" => array()
	);
 
	while ( $aRow = mysql_fetch_array( $rResult ) )
	{
				$on=0;
				$comparer = trim($aRow[ 'item_id' ]);
				if ($nbcomparer > 0) {
					for ($krow=0; $krow<$nbcomparer; $krow++) {
						if ($refcomparer[$krow] == $comparer) {
							array_splice($refcomparer,$krow,1);
							$nbcomparer--;
							$on=1;
							break;
						}
					}
				}
				$row = array();
				$row[] = "<div id='tag".$comparer."'><input id='comparer[".$comparer."]' type='checkbox' class='curseur' onclick='acomparer(".$comparer.");'"
				.($on==1?' CHECKED':'')."></div>";
				$row[] = trim($aRow[ 'cut' ]);
				$inter = trim($aRow[ 'carat' ]);
				$row[] = number_format($inter, 2, ',', ' ');
				$row[] = trim($aRow[ 'cut_grade' ]);
				$row[] = trim($aRow[ 'color' ]);
				$row[] = trim($aRow[ 'clarity' ]);
				if ($swCriteres[11] == "1") {
					$row[] = trim($aRow[ 'polish' ]);
				}
				if ($swCriteres[12] == "1") {
					$row[] = trim($aRow[ 'symmetry' ]);
				}
				if ($swCriteres[13] == "1") {
					$inter = trim($aRow[ 'depth' ]);
					if (floatval($inter)>0) {
						$row[] = number_format($inter, 2, ',', ' ');
					} else {
						$row[] = "";
					}
				}
				if ($swCriteres[14] == "1") {
					$inter = trim($aRow[ 'table' ]);
					if (floatval($inter)>0) {
						$row[] = number_format($inter, 2, ',', ' ');
					} else {
						$row[] = "";
					}
				}
				if ($swCriteres[15] == "1") {
					$row[] = trim($aRow[ 'fluo_intensity' ]);
				}
				if ($swCriteres[16] == "1") {
					$inter = trim($aRow[ 'price_per_carat_ht' ]);
					$row[] = number_format($inter, 0, ',', ' ');
				}
				if ($swCriteres[17] == "1") {
					$row[] = trim($aRow[ 'culet_size' ]);
				}
				if ($swCriteres[18] == "1") {
					$inter = trim($aRow[ 'length_width' ]);
					if (floatval($inter)>0) {
						$row[] = number_format($inter, 2, ',', ' ');
					} else {
						$row[] = "";
					}
				}
				$inter = trim($aRow[ 'delay' ]);
				if (floatval($inter) == 0) {
					$row[] = "nc";
				}
				if (floatval($inter) == 1) {
					$row[] = $inter." jour";
				}
				if (floatval($inter) > 1) {
					$row[] = $inter." jours";
				}
				$row[] = trim($aRow[ 'certificat' ]);
				$inter = trim($aRow[ 'total_price_ht' ]);
				$row[] = number_format($inter, 0, ',', ' ');
				$row[] = "<a href='#' onClick='envoiDetails(".trim($aRow[ 'item_id' ]).",\"".trim($aRow[ 'cut' ])."\",".trim($aRow[ 'carat' ]).");'><span class='voir'>D&eacute;tails</span></a>";
				$output['aaData'][] = $row;
	}
 
	echo json_encode( $output );
?>