'.$msg[103].'
'.$msg[120].'';
if ($pmb_short_loan_management) {
$form.= ''.$msg['short_loan_duration'].'';
}
$form.= ''.$msg['duree_resa'].'';
if (($pmb_gestion_financiere)&&($pmb_gestion_tarif_prets)) {
$form.= ''.$msg['typ_doc_tarif'].'';
}
$form.= ''.$msg['proprio_codage_proprio'].'
'.$msg['import_codage'].'
';
$q = 'SELECT idtyp_doc, tdoc_libelle, duree_pret, duree_resa, tdoc_owner, tdoc_codage_import, lender_libelle, tarif_pret, short_loan_duration FROM docs_type left join lenders on tdoc_owner=idlender ORDER BY tdoc_libelle, idtyp_doc';
$res = mysql_query($q, $dbh);
$nbr = mysql_num_rows($res);
$parity=1;
for($i=0;$i<$nbr;$i++) {
$row=mysql_fetch_object($res);
$pair_impair = (($parity % 2)?'even':'odd');
$parity += 1;
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=docs&sub=typdoc&action=modif&id=$row->idtyp_doc';\" ";
if ($row->tdoc_owner) {
$form.= pmb_bidi("".htmlentities($row->tdoc_libelle,ENT_QUOTES,$charset)."");
} else {
$form.= pmb_bidi("".htmlentities($row->tdoc_libelle,ENT_QUOTES,$charset)."");
}
$form.= ''.((!$pmb_quotas_avances)?(htmlentities($row->duree_pret,ENT_QUOTES,$charset).' '.$msg[121]):($msg['quotas_see_quotas'])).'';
if ($pmb_short_loan_management) {
$form.= ''.((!$pmb_quotas_avances)?(htmlentities($row->short_loan_duration,ENT_QUOTES,$charset).' '.$msg[121]):($msg['quotas_see_quotas'])).'';
}
$form.= ''.((!$pmb_quotas_avances)?(htmlentities($row->duree_resa,ENT_QUOTES,$charset).' '.$msg[121]):($msg['quotas_see_quotas'])).'';
if (($pmb_gestion_financiere)&&($pmb_gestion_tarif_prets)) {
$form.= ''.htmlentities((($pmb_gestion_tarif_prets==1)?($msg['finance_see_finance']):($row->tarif_pret)),ENT_QUOTES,$charset).'';
}
$form.= pmb_bidi(''.htmlentities($row->lender_libelle,ENT_QUOTES,$charset).'');
$form.= pmb_bidi(''.htmlentities($row->tdoc_codage_import,ENT_QUOTES,$charset).'');
$form.='';
}
$form.= "
";
print $form;
}
function show_typdoc_form($libelle='', $pret='31', $short_loan_duration='1', $resa='15', $tdoc_codage_import='', $tdoc_owner=0, $id=0, $tarif='0.00') {
global $dbh,$msg,$charset;
global $admin_typdoc_form;
global $pmb_quotas_avances;
global $pmb_gestion_financiere,$pmb_gestion_tarif_prets;
global $pmb_short_loan_management;
$admin_typdoc_form = str_replace('!!id!!', $id, $admin_typdoc_form);
if(!$id) {
$admin_typdoc_form = str_replace('!!form_title!!', $msg[122], $admin_typdoc_form);
} else {
$admin_typdoc_form = str_replace('!!form_title!!', $msg[124], $admin_typdoc_form);
}
$admin_typdoc_form = str_replace('!!libelle!!', htmlentities($libelle,ENT_QUOTES, $charset), $admin_typdoc_form);
$admin_typdoc_form = str_replace('!!libelle_suppr!!', addslashes($libelle), $admin_typdoc_form);
$form_pret='';
if (!$pmb_quotas_avances) {
$form_pret = "
";
}
$admin_typdoc_form = str_replace('', $form_pret, $admin_typdoc_form);
$form_short_loan_duration='';
if (!$pmb_quotas_avances && $pmb_short_loan_management) {
$form_short_loan_duration = "
";
}
$admin_typdoc_form = str_replace('', $form_short_loan_duration, $admin_typdoc_form);
$form_resa='';
if (!$pmb_quotas_avances) {
$form_resa = "
";
}
$admin_typdoc_form = str_replace('', $form_resa, $admin_typdoc_form);
$admin_typdoc_form = str_replace('!!tdoc_codage_import!!', $tdoc_codage_import, $admin_typdoc_form);
$combo_lender= gen_liste ("select idlender, lender_libelle from lenders order by lender_libelle ", "idlender", "lender_libelle", "form_tdoc_owner", "", $tdoc_owner, 0, $msg[556],0,$msg["proprio_generique_biblio"]) ;
$admin_typdoc_form = str_replace('', $combo_lender, $admin_typdoc_form);
$tarif_pret='';
if (($pmb_gestion_financiere)&&($pmb_gestion_tarif_prets==1)) {
$tarif_pret="
";
}
$admin_typdoc_form = str_replace('', $tarif_pret, $admin_typdoc_form);
print confirmation_delete("./admin.php?categ=docs&sub=typdoc&action=del&id=");
print $admin_typdoc_form;
}
switch($action) {
case 'update':
// v�rification validit� des donn�es fournies.
$id+=0;
$form_pret+=0;
$form_resa+=0;
$form_short_loan_duration+=0;
$form_tarif_pret+=0;
$q = "SELECT count(1) FROM docs_type WHERE (tdoc_libelle='$form_libelle' AND idtyp_doc!='$id' ) LIMIT 1 ";
$res = mysql_query($q, $dbh);
$nbr = mysql_result($res, 0, 0);
if ($nbr > 0) {
error_form_message($form_libelle.$msg['docs_label_already_used']);
} else {
// O.k., now if the id already exist UPDATE else INSERT
$q =(($id)?"update ":"insert into ");
$q.= "docs_type set tdoc_libelle='$form_libelle', ";
$q.= ((!$pmb_quotas_avances)?"duree_pret='$form_pret', duree_resa='$form_resa', ":'');
$q.= ((!$pmb_quotas_avances && $pmb_short_loan_management)?"short_loan_duration='$form_short_loan_duration', ":'');
$q.= (($pmb_gestion_financiere && $pmb_gestion_tarif_prets==1)?"tarif_pret='$form_tarif_pret', ":'');
$q.= "tdoc_codage_import='$form_tdoc_codage_import', tdoc_owner='$form_tdoc_owner' ";
$q.= (($id)?"where idtyp_doc=$id ":'');
$res = mysql_query($q, $dbh);
}
show_typdoc_list();
break;
case 'add':
if(empty($form_libelle) && empty($form_pret) && empty($form_resa)) show_typdoc_form();
else show_typdoc_list();
break;
case 'modif':
$id+=0;
if($id){
$q = "SELECT tdoc_libelle,duree_pret,short_loan_duration,duree_resa,tdoc_codage_import,tdoc_owner,tarif_pret FROM docs_type WHERE idtyp_doc='$id' LIMIT 1 ";
$res = mysql_query($q, $dbh);
if(mysql_num_rows($res)) {
$row=mysql_fetch_object($res);
show_typdoc_form($row->tdoc_libelle, $row->duree_pret, $row->short_loan_duration, $row->duree_resa, $row->tdoc_codage_import, $row->tdoc_owner, $id, $row->tarif_pret);
} else {
show_typdoc_list();
}
} else {
show_typdoc_list();
}
break;
case 'del':
$id+=0;
if($id) {
// requ�te sur 'exemplaires' pour voir si ce typdoc est encore utilis�
$total = 0;
$total = mysql_result(mysql_query("select count(1) from exemplaires where expl_typdoc ='".$id."' ", $dbh), 0, 0);
if ($total==0) {
$q = "DELETE FROM docs_type WHERE idtyp_doc=$id ";
$res = mysql_query($q, $dbh);
show_typdoc_list();
} else {
error_message( $msg[294], $msg[1700], 1, 'admin.php?categ=docs&sub=typdoc&action=');
}
} else {
show_typdoc_list();
}
break;
default:
show_typdoc_list();
break;
}