$msg[orinot_nom] $msg[orinot_pays] $msg[orinot_diffusable] "; // affichage du tableau des statuts $requete = "SELECT orinot_id, orinot_nom, orinot_pays, orinot_diffusion FROM origine_notice ORDER BY orinot_nom "; $res = mysql_query($requete, $dbh); $nbr = mysql_num_rows($res); $parity=1; for($i=0;$i<$nbr;$i++) { $row=mysql_fetch_object($res); if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=notices&sub=orinot&action=modif&id=$row->orinot_id';\" "; print pmb_bidi("".htmlentities($row->orinot_nom,ENT_QUOTES, $charset)."".htmlentities($row->orinot_pays,ENT_QUOTES, $charset).""); if ($row->orinot_diffusion) print "$msg[orinot_diffusable_oui]"; else print "$msg[orinot_diffusable_non]"; print ""; } print " "; } function orinot_form($nom="", $pays="FR", $diffusion=1, $id=0) { global $msg; global $admin_orinot_form; global $charset; $admin_orinot_form = str_replace('!!id!!', $id, $admin_orinot_form); if(!$id) $admin_orinot_form = str_replace('!!form_title!!', $msg[orinot_ajout], $admin_orinot_form); else $admin_orinot_form = str_replace('!!form_title!!', $msg[orinot_modification], $admin_orinot_form); $admin_orinot_form = str_replace('!!nom!!', htmlentities($nom,ENT_QUOTES, $charset), $admin_orinot_form); $admin_orinot_form = str_replace('!!nom_suppr!!', addslashes($nom), $admin_orinot_form); $admin_orinot_form = str_replace('!!pays!!', htmlentities($pays,ENT_QUOTES, $charset), $admin_orinot_form); if($diffusion) $checkbox="checked"; else $checkbox=""; $admin_orinot_form = str_replace('!!checkbox!!', $checkbox, $admin_orinot_form); $admin_orinot_form = str_replace('!!diffusion!!', $diffusion, $admin_orinot_form); print confirmation_delete("./admin.php?categ=notices&sub=orinot&action=del&id="); print $admin_orinot_form; } switch($action) { case 'update': if(!empty($form_nom)) { if($id) { $requete = "UPDATE origine_notice SET orinot_nom='$form_nom',orinot_pays='$form_pays',orinot_diffusion='$form_diffusion' WHERE orinot_id='$id' "; $res = mysql_query($requete, $dbh); } else { $requete = "SELECT count(1) FROM origine_notice WHERE orinot_nom='$form_nom' LIMIT 1 "; $res = mysql_query($requete, $dbh); $nbr = mysql_result($res, 0, 0); if($nbr == 0){ $requete = "INSERT INTO origine_notice (orinot_nom,orinot_pays,orinot_diffusion) VALUES ('$form_nom','$form_pays','$form_diffusion') "; $res = mysql_query($requete, $dbh); } } } show_orinot($dbh); break; case 'add': if(empty($form_nom) && empty($form_pays)) orinot_form(); else show_orinot($dbh); break; case 'modif': if($id){ $requete = "SELECT orinot_nom, orinot_pays, orinot_diffusion FROM origine_notice WHERE orinot_id='$id' "; $res = mysql_query($requete, $dbh); if(mysql_num_rows($res)) { $row=mysql_fetch_object($res); orinot_form($row->orinot_nom, $row->orinot_pays, $row->orinot_diffusion, $id); } else { show_orinot($dbh); } } else { show_orinot($dbh); } break; case 'del': if (($id) && ($id!=1)) { $total = 0; $total = mysql_num_rows (mysql_query("select origine_catalogage from notices where origine_catalogage ='".$id."' ", $dbh)); if ($total==0) { $requete = "DELETE FROM origine_notice WHERE orinot_id='$id' "; $res = mysql_query($requete, $dbh); $requete = "OPTIMIZE TABLE origine_notice "; $res = mysql_query($requete, $dbh); show_orinot($dbh); } else { error_message( "", $msg[orinot_used], 1, 'admin.php?categ=notices&sub=orinot&action='); } } else show_orinot($dbh); break; default: show_orinot($dbh); break; }