";
echo $deb_ligne ;
/* test de date de retour dépassée */
if ($lvl!="late")
if ($data['retard']) echo "
×
";
else echo "
";
echo "
".$titre."
";
echo "
".$auteur."
";
echo "
".$data["tdoc_libelle"]."
";
echo "
".$data['aff_pret_date']."
";
if ($data['retard']) echo "
".$data['aff_pret_retour']."
";
else echo "
".$data['aff_pret_retour']."
";
// Paramètre de l'opac $opac_pret_prolongation autorisant la gestion des prolongations
if ($opac_pret_prolongation==1 && $allow_prol) {
$prolongation=TRUE;
$expl_id = $data['expl_id'] ;
$query = "select cpt_prolongation, pret_date,pret_retour, expl_location from pret, exemplaires where expl_id=pret_idexpl and pret_idexpl='".$data['expl_id']."'";
$result = mysql_query($query, $dbh);
$data_expl = mysql_fetch_array($result);
$nb_prolongation = $cpt_prolongation = $data_expl['cpt_prolongation'];
$pret_date = $data_expl['pret_date'];
$date_retour= $data_expl['pret_retour'];
$cpt_prolongation++;
$duree_prolongation=$opac_pret_duree_prolongation;
$today=sql_value("SELECT CURRENT_DATE()");
if ($pmb_pret_restriction_prolongation==0) {
// Aucune limitation des prolongations
$prolongation=true;
$duree_prolongation=$opac_pret_duree_prolongation;
} else if ($pmb_pret_restriction_prolongation>0) {
$pret_nombre_prolongation=$pmb_pret_nombre_prolongation;
if(($pmb_pret_restriction_prolongation==1) && ($cpt_prolongation>$pret_nombre_prolongation)) {
// Limitation simple de la prolongation
$prolongation=FALSE;
} else if($pmb_pret_restriction_prolongation==2) {
// Limitation du pret par les quotas
//Initialisation des quotas pour nombre de prolongations
$qt = new quota("PROLONG_NMBR_QUOTA");
//Tableau de passage des paramètres
$struct["READER"] = $id_empr;
$struct["EXPL"] = $expl_id;
$pret_nombre_prolongation=$qt -> get_quota_value($struct);
if($cpt_prolongation>$pret_nombre_prolongation) $prolongation=FALSE;
//Initialisation des quotas la durée de prolongations
$qt = new quota("PROLONG_TIME_QUOTA");
$struct["READER"] = $id_empr;
$struct["EXPL"] = $expl_id;
$duree_prolongation=$qt -> get_quota_value($struct);
} // fin if gestion par quotas
} // fin else if pmb_pret_restriction_prolongation>0
$date_prolongation=sql_value("SELECT DATE_ADD('$date_retour', INTERVAL $duree_prolongation DAY)");
$diff=sql_value("SELECT DATEDIFF('$date_retour','$today')");
if($diff<-$duree_prolongation || $diff>$duree_prolongation) {
$prolongation=FALSE;
}
$req_date_calendrier = "select date_ouverture from ouvertures where ouvert=1 and num_location='".$data_expl['expl_location']."' and DATEDIFF(date_ouverture,'$date_prolongation')>=0 order by date_ouverture asc limit 1";
$res_date_calendrier = mysql_query($req_date_calendrier);
if (mysql_num_rows($res_date_calendrier)) {
$date_prolongation=mysql_result($res_date_calendrier,0,0);
}
// Verif s'il y a des résa et plus d'exemplaire dispo
if ($prolongation==TRUE) {
if($data['num_notice_mono']) $data['bulletin_id']=0;
else $data['num_notice_mono']=0;
// chercher le premier (par ordre de rang, donc de date de début de résa, non validé
$rqt = "SELECT count(1) FROM resa
WHERE resa_idnotice='".$data['num_notice_mono']."' AND resa_idbulletin='".$data['bulletin_id']."'
AND resa_cb='' AND resa_date_fin='0000-00-00' ";
$res= mysql_query($rqt);
$nbresa = mysql_result($res, 0, 0);
if($nbresa){
$rqt="SELECT count(1) FROM exemplaires, docs_statut WHERE expl_statut=idstatut and pret_flag=1 and statut_visible_opac=1 AND expl_notice=".$data['num_notice_mono']." AND expl_bulletin=".$data['bulletin_id']." ";
$res= mysql_query($rqt);
$nbexpl = mysql_result($res, 0, 0);
$rqt="SELECT count(1) FROM pret,exemplaires WHERE pret_idexpl=expl_id AND expl_notice=".$data['num_notice_mono']." AND expl_bulletin=".$data['bulletin_id']." ";
$res= mysql_query($rqt);
$nbexpl_en_pret = mysql_result($res, 0, 0);
if(($nbexpl-$nbexpl_en_pret) < $nbresa){
$prolongation=FALSE;
}
}
}
echo "