".$msg[abonnements_periodicite_libelle]." ".$msg[abonnements_periodicite_duree]." ".$msg[abonnements_periodicite_unite]." ".$msg['seuil_periodicite']." ".$msg['retard_periodicite']." ".$msg['serialcirc_consultation_duration']." "; // affichage du tableau des périodicités $requete = "SELECT periodicite_id, libelle, duree, unite, seuil_periodicite, retard_periodicite,consultation_duration "; $requete .= "FROM abts_periodicites ORDER BY libelle "; $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=abonnements&sub=periodicite&action=modif&id=$row->periodicite_id';\" "; print pmb_bidi(""); print pmb_bidi("$row->libelle"); print "$row->duree"; print ""; switch($row->unite) { case '0':print "$msg[abonnements_periodicite_unite_jour]";break; case '1':print "$msg[abonnements_periodicite_unite_mois]";break; case '2':print "$msg[abonnements_periodicite_unite_annee]";break; } print ""; print "$row->seuil_periodicite"; print "$row->retard_periodicite"; print "$row->consultation_duration"; print ""; } print " "; } function statut_form($id=0, $libelle="", $duree=0, $unite=0, $seuil_periodicite=0, $retard_periodicite=0,$consultation_duration=0) { global $msg; global $admin_abonnements_periodicite_form; global $charset; if (!$id) { $admin_abonnements_periodicite_form = str_replace('!!form_title!!', $msg[abonnements_ajouter_une_periodicite], $admin_abonnements_periodicite_form); $admin_abonnements_periodicite_form = str_replace("!!bouton_supprimer!!","",$admin_abonnements_periodicite_form) ; } else { $admin_abonnements_periodicite_form = str_replace("!!bouton_supprimer!!","",$admin_abonnements_periodicite_form) ; $admin_abonnements_periodicite_form = str_replace('!!form_title!!', $msg[118], $admin_abonnements_periodicite_form); } $admin_abonnements_periodicite_form = str_replace('!!id!!', $id, $admin_abonnements_periodicite_form); $admin_abonnements_periodicite_form = str_replace('!!libelle!!', htmlentities($libelle,ENT_QUOTES, $charset), $admin_abonnements_periodicite_form); $admin_abonnements_periodicite_form = str_replace('!!libelle_suppr!!', addslashes($libelle), $admin_abonnements_periodicite_form); $admin_abonnements_periodicite_form = str_replace('!!duree!!', htmlentities($duree,ENT_QUOTES, $charset), $admin_abonnements_periodicite_form); $selected[$unite]= "selected='selected'"; $str_unite=" "; $admin_abonnements_periodicite_form = str_replace('!!unite!!', $str_unite, $admin_abonnements_periodicite_form); $admin_abonnements_periodicite_form = str_replace('!!seuil_periodicite!!', htmlentities($seuil_periodicite,ENT_QUOTES, $charset), $admin_abonnements_periodicite_form); $admin_abonnements_periodicite_form = str_replace('!!retard_periodicite!!', htmlentities($retard_periodicite,ENT_QUOTES, $charset), $admin_abonnements_periodicite_form); $admin_abonnements_periodicite_form = str_replace('!!consultation_duration!!', htmlentities($consultation_duration,ENT_QUOTES, $charset), $admin_abonnements_periodicite_form); print confirmation_delete("./admin.php?categ=abonnements&sub=periodicite&action=del&id="); print $admin_abonnements_periodicite_form; } switch($action) { case 'update': if (($retard_periodicite>=$seuil_periodicite)||($retard_periodicite==0)) { if ($id) { $requete = "UPDATE abts_periodicites SET libelle='$libelle',duree='$duree',unite='$unite', seuil_periodicite='$seuil_periodicite', retard_periodicite='$retard_periodicite', retard_periodicite='$retard_periodicite' , consultation_duration='$consultation_duration' WHERE periodicite_id='$id' "; $res = mysql_query($requete, $dbh); show_statut($dbh); } else { $requete1=mysql_query("SELECT count(*) FROM abts_periodicites WHERE libelle='$libelle'"); if ($requete1) { $result1=mysql_fetch_array($requete1); if ($result1[0]==0) { $requete = "INSERT INTO abts_periodicites SET libelle='$libelle',duree='$duree',unite='$unite', seuil_periodicite='$seuil_periodicite', retard_periodicite='$retard_periodicite' , consultation_duration='$consultation_duration' "; $res = mysql_query($requete, $dbh); show_statut($dbh); } else { error_message_history( $msg[periodicite_existante], $msg[periodicite_existante], 1); } mysql_free_result($requete1); } else { print $msg['err_sql']."\n"; print mysql_error(); } } } else { error_message( $msg[retard_rapport_seuil], $msg[retard_rapport_seuil], 1, 'admin.php?categ=abonnements&sub=periodicite&action='); } break; case 'add': if (empty($libelle)) statut_form(); else show_statut($dbh); break; case 'modif': if ($id) { $requete = "SELECT libelle, duree, unite, retard_periodicite, seuil_periodicite,consultation_duration FROM abts_periodicites WHERE periodicite_id='$id'"; $res = mysql_query($requete, $dbh); if(mysql_num_rows($res)) { $row=mysql_fetch_object($res); statut_form($id, $row->libelle, $row->duree, $row->unite, $row->seuil_periodicite, $row->retard_periodicite, $row->consultation_duration); } }else { show_statut($dbh); } break; case 'del': if ($id) { $total = 0; $total = mysql_result(mysql_query("select count(1) from abts_modeles where num_periodicite ='".$id."' ", $dbh), 0, 0); if ($total==0) { $requete = "DELETE FROM abts_periodicites WHERE periodicite_id='$id' "; $res = mysql_query($requete, $dbh); $requete = "OPTIMIZE TABLE abts_periodicites "; $res = mysql_query($requete, $dbh); show_statut($dbh); } else { error_message( $msg[noti_statut_noti], $msg[noti_statut_used], 1, 'admin.php?categ=abonnements&sub=periodicite&action='); } } else show_statut($dbh); break; default: show_statut($dbh); break; }