='".$yd."-".$md."-".$dd."' and date_ouverture<='".$yf."-".$mf."-".$df."'"; } else { $requete="select count(date_ouverture) from ouvertures where ouvert=1 and num_location=$deflt2docs_location and date_ouverture>'".$yd."-".$md."-".$dd."' and date_ouverture<='".$yf."-".$mf."-".$df."'"; } $resultat=mysql_query($requete); if (mysql_result($resultat,0,0)) { $ndays=mysql_result($resultat,0,0); } else { //on regarde si un jour d'ouverture arrive prochainement.. //si oui cela signifie que l'emprunteur n'est pas en retard et attend la prochaine ouverture $requete="select count(date_ouverture) from ouvertures where ouvert=1 and num_location=$deflt2docs_location and date_ouverture >'".$yf."-".$mf."-".$df."' limit 0,1"; $result=mysql_query($requete); if (mysql_result($result,0,0)) { $ndays = 0; } else { if ($pmb_pret_calcul_retard_date_debut_incluse) $ndays=1+(mktime(0,0,0,$mf,$df,$yf)-mktime(0,0,0,$md,$dd,$yd))/86400; else $ndays=(mktime(0,0,0,$mf,$df,$yf)-mktime(0,0,0,$md,$dd,$yd))/86400; } } } else { if ($pmb_pret_calcul_retard_date_debut_incluse) { $ndays=1+(mktime(0,0,0,$mf,$df,$yf)-mktime(0,0,0,$md,$dd,$yd))/86400; } else { $ndays=(mktime(0,0,0,$mf,$df,$yf)-mktime(0,0,0,$md,$dd,$yd))/86400; } } return $ndays; } static function add_days($dd,$md,$yd,$days) { global $pmb_utiliser_calendrier; global $deflt2docs_location; if ($pmb_utiliser_calendrier) { $requete="select min(date_ouverture) from ouvertures where ouvert=1 and num_location=$deflt2docs_location and date_ouverture>=adddate('".$yd."-".$md."-".$dd."', interval $days day)"; $resultat=mysql_query($requete) or die ($requete." ".mysql_error());; if (!@mysql_num_rows($resultat)) { $requete="select adddate('".$yd."-".$md."-".$dd."', interval $days day)"; $resultat=mysql_query($requete) or die ($requete." ".mysql_error());; } if($date=mysql_result($resultat,0,0)){ return $date; } } $requete="select adddate('".$yd."-".$md."-".$dd."', interval $days day)"; $resultat=mysql_query($requete) or die ($requete." ".mysql_error()); $date=mysql_result($resultat,0,0); return $date; } static function maketime($mysql_date) { $t_date=explode("-",$mysql_date); return mktime(0,0,0,$t_date[1],$t_date[2],$t_date[0]); } } ?>