1 | <?php |
---|
2 | // +-------------------------------------------------+ |
---|
3 | // | 2002-2007 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) |
---|
4 | // +-------------------------------------------------+ |
---|
5 | // $Id: nomenclature_family_admin.class.php,v 1.8 2015-04-03 11:16:19 jpermanne Exp $ |
---|
6 | |
---|
7 | if (stristr($_SERVER['REQUEST_URI'], ".class.php")) die("no access"); |
---|
8 | |
---|
9 | require_once($include_path."/templates/nomenclature_family_admin.tpl.php"); |
---|
10 | |
---|
11 | class nomenclature_family_admin { |
---|
12 | protected $id=0; |
---|
13 | public $info=array(); |
---|
14 | |
---|
15 | |
---|
16 | public function __construct($id=0) { |
---|
17 | $this->id=$id+0; |
---|
18 | $this->fetch_data(); |
---|
19 | } |
---|
20 | |
---|
21 | protected function fetch_data() { |
---|
22 | global $dbh; |
---|
23 | |
---|
24 | $this->info=array(); |
---|
25 | $this->info['musicstands']=array(); |
---|
26 | if(!$this->id) return; |
---|
27 | $req="select * from nomenclature_families where id_family=". $this->id; |
---|
28 | $resultat=pmb_mysql_query($req,$dbh); |
---|
29 | if (pmb_mysql_num_rows($resultat)) { |
---|
30 | $r=pmb_mysql_fetch_object($resultat); |
---|
31 | $this->info['id']= $r->id_family; |
---|
32 | $this->info['name']= $r->family_name; |
---|
33 | $this->info['display']= "<a href='./admin.php?categ=family&sub=family&action=form&id=".$r->id_family."'>".$r->family_name."</a>";$r->family_name; |
---|
34 | $j=0; |
---|
35 | $req="select * from nomenclature_families,nomenclature_musicstands where musicstand_famille_num=id_family and id_family=".$this->id." order by musicstand_order"; |
---|
36 | $res_musicstands=pmb_mysql_query($req,$dbh); |
---|
37 | if (pmb_mysql_num_rows($res_musicstands)) { |
---|
38 | while($r_musicstand=pmb_mysql_fetch_object($res_musicstands)){ |
---|
39 | $this->info['musicstands'][$r_musicstand->id_musicstand]['id']=$r_musicstand->id_musicstand; |
---|
40 | $this->info['musicstands'][$r_musicstand->id_musicstand]['name']=$r_musicstand->musicstand_name; |
---|
41 | $this->info['musicstands'][$r_musicstand->id_musicstand]['division']=$r_musicstand->musicstand_division; |
---|
42 | $this->info['musicstands'][$r_musicstand->id_musicstand]['workshop']=$r_musicstand->musicstand_workshop; |
---|
43 | $this->info['musicstands'][$r_musicstand->id_musicstand]['instruments']=array(); |
---|
44 | |
---|
45 | if($this->info['musicstands_display'])$this->info['musicstands_display'].="<br>"; |
---|
46 | $this->info['musicstands_display'].="<a href='./admin.php?categ=family&sub=family&action=musicstand_form&id=".$this->id."&id_musicstand=".$r_musicstand->id_musicstand."'>".$r_musicstand->musicstand_name."</a>"; |
---|
47 | |
---|
48 | $req="select * from nomenclature_instruments where instrument_musicstand_num=". $r_musicstand->id_musicstand." order by instrument_code"; |
---|
49 | $res_instruments=pmb_mysql_query($req,$dbh); |
---|
50 | $count_instrument=0; |
---|
51 | if (pmb_mysql_num_rows($res_instruments)) { |
---|
52 | while($r_instrument=pmb_mysql_fetch_object($res_instruments)){ |
---|
53 | $this->info['musicstands'][$r_musicstand->id_musicstand]['instruments'][$count_instrument]['id']= $r_instrument->id_instrument; |
---|
54 | $this->info['musicstands'][$r_musicstand->id_musicstand]['instruments'][$count_instrument]['code']= $r_instrument->instrument_code; |
---|
55 | $this->info['musicstands'][$r_musicstand->id_musicstand]['instruments'][$count_instrument]['name']= $r_instrument->instrument_name; |
---|
56 | $this->info['musicstands'][$r_musicstand->id_musicstand]['instruments'][$count_instrument]['standard']= $r_instrument->instrument_standard; |
---|
57 | |
---|
58 | if($r_instrument->instrument_standard)$standard="*";else $standard=""; |
---|
59 | if($this->info['musicstands'][$r_musicstand->id_musicstand]['instruments_display'])$this->info['musicstands'][$r_musicstand->id_musicstand]['instruments_display'].="<br>"; |
---|
60 | $this->info['musicstands'][$r_musicstand->id_musicstand]['instruments_display'].="<a href='./admin.php?categ=instrument&sub=instrument&action=form&id=".$r_instrument->id_instrument."'>".$r_instrument->instrument_code." ( ".$r_instrument->instrument_name." )</a> $standard"; |
---|
61 | |
---|
62 | $count_instrument++; |
---|
63 | } |
---|
64 | } |
---|
65 | $j++; |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | public function get_form() { |
---|
72 | global $nomenclature_family_form_tpl,$msg,$charset; |
---|
73 | |
---|
74 | $tpl=$nomenclature_family_form_tpl; |
---|
75 | if($this->id){ |
---|
76 | $tpl=str_replace('!!msg_title!!',$msg['admin_nomenclature_family_form_edit'],$tpl); |
---|
77 | $tpl=str_replace('!!delete!!',"<input type='button' class='bouton' value='".$msg['admin_nomenclature_family_form_del']."' onclick=\"document.getElementById('action').value='delete';this.form.submit();\" />", $tpl); |
---|
78 | $name=$this->info['name']; |
---|
79 | }else{ |
---|
80 | $tpl=str_replace('!!msg_title!!',$msg['admin_nomenclature_family_form_add'],$tpl); |
---|
81 | $tpl_objet=""; |
---|
82 | $tpl=str_replace('!!delete!!',"",$tpl); |
---|
83 | $name=""; |
---|
84 | } |
---|
85 | $tpl=str_replace('!!name!!',htmlentities($name, ENT_QUOTES, $charset),$tpl); |
---|
86 | $tpl=str_replace('!!id!!',$this->id,$tpl); |
---|
87 | |
---|
88 | $tpl_musicstands=" |
---|
89 | <script type='text/javascript' src='./javascript/sorttable.js'></script> |
---|
90 | <table class='sortable'> |
---|
91 | <tr> |
---|
92 | <th>".$msg["admin_nomenclature_family_musicstand_form_name"]." |
---|
93 | </th> |
---|
94 | <th>".$msg["admin_nomenclature_family_musicstand_form_instruments"]." |
---|
95 | </th> |
---|
96 | </tr> |
---|
97 | "; |
---|
98 | $flag_checked=0; |
---|
99 | foreach($this->info['musicstands'] as $musicstand){ |
---|
100 | $tpl_musicstand=" |
---|
101 | <tr> |
---|
102 | <td style=\"cursor: pointer\" onmousedown=\"document.location='./admin.php?categ=family&sub=family&action=musicstand_form&id=".$this->id."&id_musicstand=".$musicstand['id']."';\"> |
---|
103 | <a href='./admin.php?categ=family&sub=family&action=musicstand_form&id=".$this->id."&id_musicstand=".$musicstand['id']."'>".$musicstand['name']."</a> |
---|
104 | </td> |
---|
105 | <td style=\"cursor: pointer\" onmousedown=\"document.location='./admin.php?categ=family&sub=family&action=musicstand_form&id=".$this->id."&id_musicstand=".$musicstand['id']."';\"> |
---|
106 | ".$musicstand['instruments_display']." |
---|
107 | </td> |
---|
108 | </tr> |
---|
109 | "; |
---|
110 | $tpl_musicstands.=$tpl_musicstand; |
---|
111 | } |
---|
112 | $tpl_musicstands.=" |
---|
113 | </table>"; |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | $tpl=str_replace('!!musicstands!!',$tpl_musicstands,$tpl); |
---|
118 | |
---|
119 | return $tpl; |
---|
120 | } |
---|
121 | |
---|
122 | public function save() { |
---|
123 | global $dbh; |
---|
124 | global $name; |
---|
125 | |
---|
126 | $notice_onglet+=0; |
---|
127 | $fields=" |
---|
128 | family_name='".$name."' |
---|
129 | "; |
---|
130 | if(!$this->id){ // Ajout |
---|
131 | $requete="select max(family_order) as ordre from nomenclature_families"; |
---|
132 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
133 | $ordre_max=@pmb_mysql_result($resultat,0,0); |
---|
134 | $req="INSERT INTO nomenclature_families SET $fields, family_order=".($ordre_max+1); |
---|
135 | pmb_mysql_query($req, $dbh); |
---|
136 | $this->id = pmb_mysql_insert_id($dbh); |
---|
137 | } else { |
---|
138 | $req="UPDATE nomenclature_families SET $fields where id_family=".$this->id; |
---|
139 | pmb_mysql_query($req, $dbh); |
---|
140 | } |
---|
141 | $this->fetch_data(); |
---|
142 | } |
---|
143 | |
---|
144 | public function delete() { |
---|
145 | global $dbh; |
---|
146 | $req="DELETE from nomenclature_musicstands WHERE musicstand_famille_num=".$this->id; |
---|
147 | pmb_mysql_query($req, $dbh); |
---|
148 | $req="DELETE from nomenclature_families WHERE id_family=".$this->id; |
---|
149 | pmb_mysql_query($req, $dbh); |
---|
150 | $this->id=0; |
---|
151 | $this->fetch_data(); |
---|
152 | } |
---|
153 | |
---|
154 | public function get_musicstand_form($id_musicstand) { |
---|
155 | global $nomenclature_family_musicstand_form_tpl,$msg,$charset; |
---|
156 | |
---|
157 | $tpl=$nomenclature_family_musicstand_form_tpl; |
---|
158 | if($id_musicstand){ |
---|
159 | $tpl=str_replace('!!msg_title!!',str_replace('!!famille_name!!',$this->info['display'],$msg['admin_nomenclature_family_musicstand_form_edit']),$tpl); |
---|
160 | $tpl=str_replace('!!delete!!',"<input type='button' class='bouton' value='".$msg['admin_nomenclature_family_musicstand_form_del']."' onclick=\"document.getElementById('action').value='musicstand_delete';this.form.submit();\" />", $tpl); |
---|
161 | $name=$this->info['musicstands'][$id_musicstand]['name']; |
---|
162 | |
---|
163 | if($this->info['musicstands'][$id_musicstand]['division'])$checked="checked"; else $checked=""; |
---|
164 | if($this->info['musicstands'][$id_musicstand]['workshop'])$workshop_checked="checked"; else $workshop_checked=""; |
---|
165 | $tpl=str_replace('!!checked!!',$checked, $tpl); |
---|
166 | $tpl=str_replace('!!workshop_checked!!',$workshop_checked, $tpl); |
---|
167 | }else{ |
---|
168 | $tpl=str_replace('!!msg_title!!',str_replace('!!famille_name!!',$this->info['display'],$msg['admin_nomenclature_family_musicstand_form_add']),$tpl); |
---|
169 | $tpl_objet=""; |
---|
170 | $tpl=str_replace('!!delete!!',"",$tpl); |
---|
171 | $tpl=str_replace('!!checked!!',"", $tpl); |
---|
172 | $tpl=str_replace('!!workshop_checked!!',"", $tpl); |
---|
173 | $name=""; |
---|
174 | } |
---|
175 | $tpl=str_replace('!!name!!',htmlentities($name, ENT_QUOTES, $charset),$tpl); |
---|
176 | $tpl=str_replace('!!id!!',$this->id,$tpl); |
---|
177 | $tpl=str_replace('!!id_musicstand!!',$id_musicstand,$tpl); |
---|
178 | |
---|
179 | $tpl_instruments=""; |
---|
180 | if($id_musicstand){ |
---|
181 | $tpl_instruments=" |
---|
182 | <script type='text/javascript' src='./javascript/sorttable.js'></script> |
---|
183 | <table class='sortable'> |
---|
184 | <tr> |
---|
185 | <th>".$msg["admin_nomenclature_instrument_code"]." |
---|
186 | </th> |
---|
187 | <th>".$msg["admin_nomenclature_instrument_name"]." |
---|
188 | </th> |
---|
189 | <th>".$msg["admin_nomenclature_instrument_standard"]." |
---|
190 | (<input type='radio' name='standard' value='0' !!checked!! /> ".$msg["admin_nomenclature_instrument_standard_no"]." ) |
---|
191 | </th> |
---|
192 | </tr> |
---|
193 | "; |
---|
194 | $flag_checked=0; |
---|
195 | foreach($this->info['musicstands'][$id_musicstand]['instruments'] as $instrument){ |
---|
196 | if($instrument['standard']){ |
---|
197 | $checked="checked"; |
---|
198 | $flag_checked=1; |
---|
199 | }else $checked=""; |
---|
200 | |
---|
201 | $standard="<input type='radio' name='standard' value='".$instrument['id']."' $checked />"; |
---|
202 | $tpl_instrument=" |
---|
203 | <tr> |
---|
204 | <td style=\"cursor: pointer\" onmousedown=\"document.location='./admin.php?categ=instrument&sub=instrument&action=form&id=".$instrument['id']."';\"> |
---|
205 | ".$instrument['code']." |
---|
206 | </td> |
---|
207 | <td style=\"cursor: pointer\" onmousedown=\"document.location='./admin.php?categ=instrument&sub=instrument&action=form&id=".$instrument['id']."';\"> |
---|
208 | ".$instrument['name']." |
---|
209 | </td> |
---|
210 | <td> |
---|
211 | ".$standard." |
---|
212 | </td> |
---|
213 | </tr> |
---|
214 | "; |
---|
215 | $tpl_instruments.=$tpl_instrument; |
---|
216 | } |
---|
217 | $tpl_instruments.=" |
---|
218 | </table>"; |
---|
219 | if(!$flag_checked) $checked="checked";else $checked=""; |
---|
220 | $tpl_instruments=str_replace('!!checked!!',$checked,$tpl_instruments); |
---|
221 | } |
---|
222 | $tpl=str_replace('!!instruments!!',$tpl_instruments,$tpl); |
---|
223 | |
---|
224 | return $tpl; |
---|
225 | } |
---|
226 | |
---|
227 | public function musicstand_save($id_musicstand) { |
---|
228 | global $dbh; |
---|
229 | global $name; |
---|
230 | global $division; |
---|
231 | global $workshop; |
---|
232 | global $standard; |
---|
233 | |
---|
234 | $fields=" |
---|
235 | musicstand_famille_num='".$this->id."', |
---|
236 | musicstand_name='".$name."', |
---|
237 | musicstand_division='".$division."', |
---|
238 | musicstand_workshop='".$workshop."' |
---|
239 | "; |
---|
240 | if(!$id_musicstand){ // Ajout |
---|
241 | |
---|
242 | $requete="select max(musicstand_order) as ordre from nomenclature_musicstands where musicstand_famille_num=".$this->id; |
---|
243 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
244 | $ordre_max=@pmb_mysql_result($resultat,0,0); |
---|
245 | $req="INSERT INTO nomenclature_musicstands SET $fields, musicstand_order=".($ordre_max+1); |
---|
246 | pmb_mysql_query($req, $dbh); |
---|
247 | $id_musicstand = pmb_mysql_insert_id($dbh); |
---|
248 | } else { |
---|
249 | $req="UPDATE nomenclature_musicstands SET $fields where id_musicstand=".$id_musicstand; |
---|
250 | pmb_mysql_query($req, $dbh); |
---|
251 | } |
---|
252 | |
---|
253 | $standard+=0; // id de l'instrument standard |
---|
254 | $req="UPDATE nomenclature_instruments SET instrument_standard=0 where instrument_musicstand_num=".$id_musicstand; |
---|
255 | pmb_mysql_query($req, $dbh); |
---|
256 | if($standard){ |
---|
257 | $req="UPDATE nomenclature_instruments SET instrument_standard=1 where id_instrument=".$standard; |
---|
258 | pmb_mysql_query($req, $dbh); |
---|
259 | } |
---|
260 | |
---|
261 | $this->fetch_data(); |
---|
262 | } |
---|
263 | |
---|
264 | public function musicstand_delete($id_musicstand) { |
---|
265 | global $dbh; |
---|
266 | |
---|
267 | $req="UPDATE nomenclature_instruments SET instrument_musicstand_num=0 where instrument_musicstand_num=".$id_musicstand; |
---|
268 | pmb_mysql_query($req, $dbh); |
---|
269 | |
---|
270 | $req="DELETE from nomenclature_musicstands WHERE id_musicstand=".$id_musicstand; |
---|
271 | pmb_mysql_query($req, $dbh); |
---|
272 | $this->fetch_data(); |
---|
273 | } |
---|
274 | |
---|
275 | |
---|
276 | } //nomenclature_family_musicstand class end |
---|
277 | |
---|
278 | |
---|
279 | |
---|
280 | class nomenclature_family_admins { |
---|
281 | public $info=array(); |
---|
282 | |
---|
283 | public function __construct() { |
---|
284 | $this->fetch_data(); |
---|
285 | } |
---|
286 | |
---|
287 | protected function fetch_data() { |
---|
288 | global $dbh; |
---|
289 | $this->info=array(); |
---|
290 | $i=0; |
---|
291 | $req="select * from nomenclature_families order by family_order"; |
---|
292 | $resultat=pmb_mysql_query($req,$dbh); |
---|
293 | if (pmb_mysql_num_rows($resultat)) { |
---|
294 | while($r=pmb_mysql_fetch_object($resultat)){ |
---|
295 | $this->info[$i]= $family=new nomenclature_family_admin($r->id_family); |
---|
296 | $i++; |
---|
297 | } |
---|
298 | } |
---|
299 | } |
---|
300 | |
---|
301 | public function get_list() { |
---|
302 | global $nomenclature_family_list_tpl,$nomenclature_family_list_line_tpl,$msg; |
---|
303 | |
---|
304 | $tpl=$nomenclature_family_list_tpl; |
---|
305 | $tpl_list=""; |
---|
306 | $odd_even="odd"; |
---|
307 | foreach($this->info as $elt){ |
---|
308 | $tpl_elt=$nomenclature_family_list_line_tpl; |
---|
309 | if($odd_even=='odd')$odd_even="even"; else $odd_even="odd"; |
---|
310 | |
---|
311 | $tpl_elt=str_replace('!!odd_even!!',$odd_even, $tpl_elt); |
---|
312 | $tpl_elt=str_replace('!!name!!',$elt->info['name'], $tpl_elt); |
---|
313 | $tpl_elt=str_replace('!!musicstands_display!!',$elt->info['musicstands_display'], $tpl_elt); |
---|
314 | $tpl_elt=str_replace('!!id!!',$elt->info['id'], $tpl_elt); |
---|
315 | $tpl_list.=$tpl_elt; |
---|
316 | } |
---|
317 | $tpl=str_replace('!!list!!',$tpl_list, $tpl); |
---|
318 | return $tpl; |
---|
319 | } |
---|
320 | |
---|
321 | function order_up($id){ |
---|
322 | global $dbh; |
---|
323 | |
---|
324 | $requete="select family_order from nomenclature_families where id_family=$id"; |
---|
325 | $resultat=pmb_mysql_query($requete,$dbh); |
---|
326 | $ordre=pmb_mysql_result($resultat,0,0); |
---|
327 | $requete="select max(family_order) as ordre from nomenclature_families where family_order<$ordre"; |
---|
328 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
329 | $ordre_max=@pmb_mysql_result($resultat,0,0); |
---|
330 | if ($ordre_max != '') { |
---|
331 | $requete="select id_family from nomenclature_families where family_order=$ordre_max limit 1"; |
---|
332 | $resultat=pmb_mysql_query($requete); |
---|
333 | $id_max=pmb_mysql_result($resultat,0,0); |
---|
334 | $requete="update nomenclature_families set family_order='".$ordre_max."' where id_family=$id"; |
---|
335 | pmb_mysql_query($requete,$dbh); |
---|
336 | $requete="update nomenclature_families set family_order='".$ordre."' where id_family=".$id_max; |
---|
337 | pmb_mysql_query($requete,$dbh); |
---|
338 | $this->fetch_data(); |
---|
339 | } |
---|
340 | } |
---|
341 | |
---|
342 | function order_down($id){ |
---|
343 | global $dbh; |
---|
344 | $requete="select family_order from nomenclature_families where id_family=$id"; |
---|
345 | $resultat=pmb_mysql_query($requete); |
---|
346 | $ordre=pmb_mysql_result($resultat,0,0); |
---|
347 | $requete="select min(family_order) as ordre from nomenclature_families where family_order>$ordre"; |
---|
348 | $resultat=pmb_mysql_query($requete); |
---|
349 | $ordre_min=@pmb_mysql_result($resultat,0,0); |
---|
350 | if ($ordre_min) { |
---|
351 | $requete="select id_family from nomenclature_families where family_order=$ordre_min limit 1"; |
---|
352 | $resultat=pmb_mysql_query($requete); |
---|
353 | $id_min=pmb_mysql_result($resultat,0,0); |
---|
354 | $requete="update nomenclature_families set family_order='".$ordre_min."' where id_family=$id"; |
---|
355 | pmb_mysql_query($requete); |
---|
356 | $requete="update nomenclature_families set family_order='".$ordre."' where id_family=".$id_min; |
---|
357 | pmb_mysql_query($requete); |
---|
358 | $this->fetch_data(); |
---|
359 | } |
---|
360 | } |
---|
361 | |
---|
362 | } // nomenclature_family_admins class end |
---|
363 | |
---|
364 | |
---|
365 | |
---|
366 | class nomenclature_family_musicstand_admins { |
---|
367 | protected $id=0; // id de la famille ou est rataché les pupitres |
---|
368 | public $info=array(); |
---|
369 | |
---|
370 | public function __construct($id) { |
---|
371 | $this->id=$id+0; |
---|
372 | $this->fetch_data(); |
---|
373 | } |
---|
374 | |
---|
375 | protected function fetch_data() { |
---|
376 | global $dbh; |
---|
377 | $this->info=array(); |
---|
378 | $this->info[0]=new nomenclature_family_admin($this->id); |
---|
379 | } |
---|
380 | |
---|
381 | public function get_list() { |
---|
382 | global $nomenclature_family_musicstand_list_tpl,$nomenclature_family_musicstand_list_line_tpl,$msg; |
---|
383 | |
---|
384 | $tpl=$nomenclature_family_musicstand_list_tpl; |
---|
385 | $tpl_list=""; |
---|
386 | $odd_even="odd"; |
---|
387 | foreach($this->info[0]->info['musicstands'] as $elt){ |
---|
388 | $tpl_elt=$nomenclature_family_musicstand_list_line_tpl; |
---|
389 | if($odd_even=='odd')$odd_even="even"; else $odd_even="odd"; |
---|
390 | |
---|
391 | $tpl_elt=str_replace('!!odd_even!!',$odd_even, $tpl_elt); |
---|
392 | $tpl_elt=str_replace('!!name!!',$elt['name'], $tpl_elt); |
---|
393 | if($elt['division'])$division="x"; else $division=""; |
---|
394 | if($elt['workshop'])$workshop="x"; else $workshop=""; |
---|
395 | $tpl_elt=str_replace('!!division!!',$division, $tpl_elt); |
---|
396 | $tpl_elt=str_replace('!!workshop!!',$workshop, $tpl_elt); |
---|
397 | $tpl_elt=str_replace('!!instruments!!',$elt['instruments_display'], $tpl_elt); |
---|
398 | $tpl_elt=str_replace('!!id_musicstand!!',$elt['id'], $tpl_elt); |
---|
399 | $tpl_list.=$tpl_elt; |
---|
400 | } |
---|
401 | $tpl=str_replace('!!list!!',$tpl_list, $tpl); |
---|
402 | $tpl=str_replace('!!id!!',$this->id, $tpl); // id family |
---|
403 | $tpl=str_replace('!!famille_name!!',$this->info[0]->info['name'], $tpl); // id family |
---|
404 | return $tpl; |
---|
405 | } |
---|
406 | |
---|
407 | function order_up($id){ |
---|
408 | global $dbh; |
---|
409 | |
---|
410 | $requete="select musicstand_order from nomenclature_musicstands where id_musicstand=$id"; |
---|
411 | $resultat=pmb_mysql_query($requete,$dbh); |
---|
412 | $ordre=pmb_mysql_result($resultat,0,0); |
---|
413 | $requete="select max(musicstand_order) as ordre from nomenclature_musicstands where musicstand_order<$ordre and musicstand_famille_num=".$this->id; |
---|
414 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
415 | $ordre_max=@pmb_mysql_result($resultat,0,0); |
---|
416 | if ($ordre_max != '') { |
---|
417 | $requete="select id_musicstand from nomenclature_musicstands where musicstand_order=$ordre_max and musicstand_famille_num=".$this->id." limit 1"; |
---|
418 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
419 | $id_max=pmb_mysql_result($resultat,0,0); |
---|
420 | $requete="update nomenclature_musicstands set musicstand_order='".$ordre_max."' where id_musicstand=$id"; |
---|
421 | pmb_mysql_query($requete,$dbh); |
---|
422 | $requete="update nomenclature_musicstands set musicstand_order='".$ordre."' where id_musicstand=".$id_max; |
---|
423 | pmb_mysql_query($requete,$dbh); |
---|
424 | $this->fetch_data(); |
---|
425 | } |
---|
426 | } |
---|
427 | |
---|
428 | function order_down($id){ |
---|
429 | global $dbh; |
---|
430 | $requete="select musicstand_order from nomenclature_musicstands where id_musicstand=$id"; |
---|
431 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
432 | $ordre=pmb_mysql_result($resultat,0,0); |
---|
433 | $requete="select min(musicstand_order) as ordre from nomenclature_musicstands where musicstand_order>$ordre and musicstand_famille_num=".$this->id; |
---|
434 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
435 | $ordre_min=@pmb_mysql_result($resultat,0,0); |
---|
436 | if ($ordre_min) { |
---|
437 | $requete="select id_musicstand from nomenclature_musicstands where musicstand_order=$ordre_min and musicstand_famille_num=".$this->id." limit 1"; |
---|
438 | $resultat=pmb_mysql_query($requete, $dbh); |
---|
439 | $id_min=pmb_mysql_result($resultat,0,0); |
---|
440 | $requete="update nomenclature_musicstands set musicstand_order='".$ordre_min."' where id_musicstand=$id"; |
---|
441 | pmb_mysql_query($requete, $dbh); |
---|
442 | $requete="update nomenclature_musicstands set musicstand_order='".$ordre."' where id_musicstand=".$id_min; |
---|
443 | pmb_mysql_query($requete, $dbh); |
---|
444 | $this->fetch_data(); |
---|
445 | } |
---|
446 | } |
---|
447 | |
---|
448 | |
---|
449 | } // nomenclature_family_musicstand_admins class end |
---|