".$msg[103]." ".$msg["type_abts_prepay"]." ".$msg["type_abts_prepay_dflt"]." ".$msg["type_abts_tarif"]." ".$msg["type_abts_caution"]." "; // affichage du tableau des utilisateurs $requete = "SELECT id_type_abt, type_abt_libelle, prepay, prepay_deflt_mnt,tarif,caution FROM type_abts ORDER BY type_abt_libelle,id_type_abt"; $res = mysql_query($requete, $dbh); $nbr = mysql_num_rows($res); $parity=1; for($i=0;$i<$nbr;$i++) { $row=mysql_fetch_row($res); if ($row[2]) $prepay="x"; 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=finance&sub=abts&action=modif&id=$row[0]';\" "; print pmb_bidi("".htmlentities($row[1],ENT_QUOTES,$charset)." $prepay".$row[3]."".$row[4]."".$row[5]." "); } print " "; } function abts_form($libelle="", $id=0, $prepay=0, $prepay_mnt_deflt=0, $tarif=0, $commentaire="", $caution=0, $localisations="") { global $msg; global $finance_abts_form ; global $charset; $finance_abts_form = str_replace('!!id!!', $id, $finance_abts_form); if(!$id) $finance_abts_form = str_replace('!!form_title!!', $msg["type_abts_add"], $finance_abts_form); else $finance_abts_form = str_replace('!!form_title!!', $msg["type_abts_update"], $finance_abts_form); if ($prepay) $prepay_checked="checked"; $finance_abts_form = str_replace('!!libelle!!', htmlentities($libelle,ENT_QUOTES, $charset), $finance_abts_form); $finance_abts_form = str_replace('!!libelle_suppr!!', htmlentities($libelle,ENT_QUOTES, $charset), $finance_abts_form); $finance_abts_form = str_replace('!!commentaire!!', htmlentities($commentaire,ENT_QUOTES, $charset), $finance_abts_form); $finance_abts_form = str_replace('!!prepay_checked!!', $prepay_checked, $finance_abts_form); $finance_abts_form = str_replace('!!prepay_deflt_mnt!!', htmlentities($prepay_mnt_deflt,ENT_QUOTES, $charset), $finance_abts_form); $finance_abts_form = str_replace('!!tarif!!', htmlentities($tarif,ENT_QUOTES, $charset), $finance_abts_form); $finance_abts_form = str_replace('!!caution!!', htmlentities($caution,ENT_QUOTES, $charset), $finance_abts_form); //Localisations $loc_checkbox=""; $loc=explode(",",$localisations); $requete="select idlocation, location_libelle from docs_location"; $resultat=mysql_query($requete); $n=0; $c=0; if ($resultat) { while ($l=mysql_fetch_object($resultat)) { if ($c==0) $loc_checkbox.="
"; $loc_checkbox.="
"; $loc_checkbox.="idlocation,$loc); if (($as!==false)&&($as!==null)) $loc_checkbox.="checked"; $loc_checkbox.=">"; $loc_checkbox.=" "; $loc_checkbox.="
"; $n++; $c++; if ($c==3) { $c=0; $loc_checkbox.="
"; } } if ($c!=0) $loc_checkbox.="
 
"; $loc_checkbox.="
"; } $finance_abts_form = str_replace('!!localisations!!', $loc_checkbox, $finance_abts_form); print confirmation_delete("./admin.php?categ=finance&sub=abts&action=del&id="); print $finance_abts_form; } switch($action) { case 'update': // O.k., now if the id already exist UPDATE else INSERT if(!empty($typ_abt_libelle)) { if($id) { if (count($localisation)) $localisations=implode(",",$localisation); else $localisations=""; $requete = "UPDATE type_abts SET type_abt_libelle='".$typ_abt_libelle."', prepay='$prepay', prepay_deflt_mnt='$prepay_deflt_mnt', tarif='$tarif', commentaire='$commentaire', caution='$caution', localisations='".$localisations."' WHERE id_type_abt=$id "; $res = mysql_query($requete, $dbh); } else { if (count($localisation)) $localisations=implode(",",$localisation); else $localisations=""; $requete = "INSERT INTO type_abts (id_type_abt,type_abt_libelle, prepay, prepay_deflt_mnt, tarif, commentaire, caution, localisations) VALUES ('', '$typ_abt_libelle','$prepay', '$prepay_deflt_mnt', '$tarif', '$commentaire', '$caution','$localisations') "; $res = mysql_query($requete, $dbh); } } show_abts($dbh); break; case 'add': abts_form(); break; case 'modif': if($id){ $requete = "SELECT id_type_abt, type_abt_libelle, prepay, prepay_deflt_mnt,tarif,commentaire, caution, localisations FROM type_abts WHERE id_type_abt=$id LIMIT 1"; $res = mysql_query($requete, $dbh); if(mysql_num_rows($res)) { $row=mysql_fetch_row($res); abts_form($row[1], $id,$row[2],$row[3],$row[4],$row[5],$row[6],$row[7]); } else { show_abts($dbh); } } else { show_abts($dbh); } break; case 'del': if($id) { $total = 0; $total = mysql_result(mysql_query("select count(1) from empr where type_abt ='".$id."' ", $dbh), 0, 0); if ($total==0) { $requete = "DELETE FROM type_abts WHERE id_type_abt=$id ;"; $res = mysql_query($requete, $dbh); $requete = "OPTIMIZE TABLE type_abts "; $res = mysql_query($requete, $dbh); show_abts($dbh); } else { error_message( $msg["type_abts_type"], $msg["type_abts_del_error"], 1, 'admin.php?categ=finance&sub=abts&action='); } } else show_abts($dbh); break; default: show_abts($dbh); break; } ?>