";
}
$r=str_replace("!!serial_id!!", $serial_id, $r);
$r=str_replace("!!serialcirc_empr_list!!", $aff_empr_list, $r);
$r=str_replace("!!serialcirc_export_list_bt!!", "abt_id."'\"/> ", $r);
return $r;
}
public function show_form() {
global $creation_abonnement_form;
global $serial_header;
global $msg;
global $charset;
global $tpl_del_bouton,$tpl_copy_bouton,$serial_id,$edition_abonnement_form,$pmb_antivol;
global $dbh;
global $pmb_abt_label_perio;
if (!$this->abt_id) {
$r=$serial_header.$creation_abonnement_form;
$r=str_replace('!!page_title!!', $msg[4000].$msg[1003].$msg["abts_abonnements_add_title"], $r);
$r=str_replace('!!libelle_form!!', $msg["abts_abonnements_add_title"], $r);
if($pmb_abt_label_perio){
$serial = new serial($serial_id);
$r=str_replace('!!abt_name!!', htmlentities($serial->tit1, ENT_QUOTES, $charset), $r);
}
// abts_status
$r = str_replace("!!abts_status!!", abts_status::get_form_for(1), $r);
//Checkbox des modèles à associer à l'abonnement
$resultat=pmb_mysql_query("select modele_id,modele_name from abts_modeles where num_notice='$serial_id'");
$liste_modele="
";
//Confection du javascript pour tester au moins une sélection de modèle
$test_liste_modele="if(";
$cpt=0;
while ($rp=pmb_mysql_fetch_object($resultat)) {
if( $cpt++ >0) $test_liste_modele.=" || ";
$liste_modele.="
".pmb_mysql_error());
while ($r_a=pmb_mysql_fetch_object($resultat)) {
$modele_id=$r_a->modele_id;
$num=$r_a->num;
$vol=$r_a->vol;
$tome=$r_a->tome;
$delais=$r_a->delais;
$critique=$r_a->critique;
$modele_name=pmb_sql_value("select modele_name from abts_modeles where modele_id='$modele_id'");
$num_periodicite=pmb_sql_value("select num_periodicite from abts_modeles where modele_id='$modele_id'");
$periodicite=pmb_sql_value("select libelle from abts_periodicites where periodicite_id ='".$num_periodicite."'");
$num_statut=$r_a->num_statut_general;
if($periodicite) $modele_name.=" ($periodicite)";
// if(!$num_statut)$num_statut=$this->statut_id;
$modele_list.=$this->gen_tpl_abt_modele($modele_id,$modele_name,$num,$vol,$tome,$delais,$critique,$num_statut);
$modele_list_dates[] = array($r_a->date_debut,$r_a->date_fin);
}
$r=str_replace("!!modele_list!!",$modele_list,$r);
// calendrier de réception s'il y a des enregistrement présents dans la grille
$r.="
";
if (pmb_sql_value("select sum(nombre) from abts_grille_abt where num_abt='$this->abt_id'"))
{
$calend= <<
function ad_date(obj,e) {
if(!e) e=window.event;
var tgt = e.target || e.srcElement; // IE doesn't use .target
var strid = tgt.id;
var type = tgt.tagName;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
var id_obj=document.getElementById(obj);
var pos=findPos(id_obj);
var url="./catalog/serials/abonnement/abonnement_parution_edition.php?abonnement_id=!!abonnement_id!!&date_parution="+obj+"&type_serie=1&numero=";
var notice_view=document.createElement("iframe");
notice_view.setAttribute('id','frame_abts');
notice_view.setAttribute('name','periodique');
notice_view.src=url;
var att=document.getElementById("att");
notice_view.style.visibility="hidden";
notice_view.style.display="block";
notice_view=att.appendChild(notice_view);
w=notice_view.clientWidth;
h=notice_view.clientHeight;
notice_view.style.left=pos[0]+"px";
notice_view.style.top=pos[1]+"px";
notice_view.style.visibility="visible";
}
ENDOFTEXT;
$calend=str_replace("!!serial_id!!",$serial_id,$calend);
$calend=str_replace("!!abonnement_id!!",$this->abt_id,$calend);
$base_url="./catalog.php?categ=serials&sub=abonnement&serial_id="."$serial_id&abonnement_id=$this->abt_id";
$base_url_mois='';
$calend.= "
\n";
$calend.="";
$r.=$calend;
}
$js= <<
function duplique(obj,e) {
if(!e) e=window.event;
var tgt = e.target || e.srcElement; // IE doesn't use .target
var strid = tgt.id;
var type = tgt.tagName;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
var id_obj=document.getElementById(obj);
var pos=findPos(id_obj);
var url="./catalog/serials/abonnement/abonnement_duplique.php?abonnement_id=!!abonnement_id!!&serial_id=!!serial_id!!";
var notice_view=document.createElement("iframe");
notice_view.setAttribute('id','frame_abts');
notice_view.setAttribute('name','periodique');
notice_view.src=url;
var att=document.getElementById("att");
notice_view.style.visibility="hidden";
notice_view.style.display="block";
notice_view=att.appendChild(notice_view);
w=notice_view.clientWidth;
h=notice_view.clientHeight;
posx=(getWindowWidth()/2-(w/2))<0?0:(getWindowWidth()/2-(w/2))
posy=(getWindowHeight()/2-(h/2))<0?0:(getWindowHeight()/2-(h/2));
notice_view.style.left=posx+"px";
notice_view.style.top=posy+"px";
notice_view.style.visibility="visible";
}
function kill_frame_periodique() {
var notice_view=document.getElementById("frame_abts");
notice_view.parentNode.removeChild(notice_view);
}
ENDOFTEXT;
$js=str_replace("!!serial_id!!",$serial_id,$js);
$js=str_replace("!!abonnement_id!!",$this->abt_id,$js);
$r.=$js;
//Vérifications sur les dates
$test_liste_modele = "
var d = form.date_debut.value.replace(/-/g,'');
var d_abo_debut = new Date(d.substr(0,4),d.substr(4,2),d.substr(6,2));
d = form.date_fin.value.replace(/-/g,'');
var d_abo_fin = new Date(d.substr(0,4),d.substr(4,2),d.substr(6,2));
var dates_modeles = new Array(";
foreach($modele_list_dates as $mdates){
$test_liste_modele .= "new Array('".$mdates[0]."','".$mdates[1]."'),";
}
$test_liste_modele = substr($test_liste_modele,0,strlen($test_liste_modele)-1);
$test_liste_modele .= "
);";
if ($this->date_debut=='0000-00-00' && $this->date_fin=='0000-00-00') {
//On est en création d'abonnement
$test_liste_modele .= "
for(var i= 0; i < dates_modeles.length; i++){
var t = dates_modeles[i][0].split(/[-]/);
var d_mod_debut = new Date(t[0],t[1],t[2]);
var t = dates_modeles[i][1].split(/[-]/);
var d_mod_fin = new Date(t[0],t[1],t[2]);
if ((d_abo_debut < d_mod_debut)||(d_abo_fin > d_mod_fin)) {
alert(\"".$msg['abo_date_incorrecte']."\");
return false;
}
}";
} else {
//on est en modification ou en prolongation
$test_liste_modele .= "
for(var i= 0; i < dates_modeles.length; i++){
var t = dates_modeles[i][0].split(/[-]/);
var d_mod_debut = new Date(t[0],t[1],t[2]);
var t = dates_modeles[i][1].split(/[-]/);
var d_mod_fin = new Date(t[0],t[1],t[2]);
if (document.getElementById('act').value=='prolonge') {
var d_prev = form.date_fin.value.replace(/-/g,'');
var d_abo_prev_fin = new Date(d_prev.substr(0,4),d_prev.substr(4,2),d_prev.substr(6,2));
d_abo_prev_fin.setMonth(d_abo_prev_fin.getMonth() + parseInt(document.getElementById('duree_abonnement').value,10));
if (d_abo_prev_fin > d_mod_fin) {
alert(\"".$msg['abo_date_prolonge_incorrecte']."\");
return false;
}
} else {
if (d_abo_fin > d_mod_fin) {
alert(\"".$msg['abo_date_fin_incorrecte']."\");
return false;
}
}
}";
}
$r=str_replace("!!test_liste_modele!!",$test_liste_modele,$r);
}
$r=str_replace("!!action!!","./catalog.php?categ=serials&sub=abon&serial_id="."$serial_id"."&abt_id="."$this->abt_id",$r);
$r=str_replace('!!bouton_prolonge!!', $bouton_prolonge, $r);
$r=str_replace('!!bouton_raz!!', $bouton_raz, $r);
$r=str_replace("!!serial_id!!",$serial_id,$r);
//Remplacement des valeurs
$r=str_replace("!!abt_id!!",htmlentities($this->abt_id,ENT_QUOTES,$charset),$r);
$r=str_replace("!!abt_name!!",htmlentities($this->abt_name,ENT_QUOTES,$charset),$r);
$r=str_replace("!!abt_name_opac!!",htmlentities($this->abt_name_opac,ENT_QUOTES,$charset),$r);
//Notice mère
$perio=new serial_display($this->num_notice,1);
$r=str_replace("!!num_notice_libelle!!",$perio->header,$r);
$r=str_replace("!!num_notice!!",$this->num_notice,$r);
//Traductions
$translation = new translation($this->abt_id, 'abts_abts');
$r .= $translation->connect('form_abonnement');
return $r;
}
// ----------------------------------------------------------------------------
// fonction do_selector qui génère des combo_box avec tout ce qu'il faut
// ----------------------------------------------------------------------------
public function do_selector() {
global $dbh;
global $charset;
global $deflt_docs_section;
global $deflt_docs_location;
if (!$this->section_id) $this->section_id=$deflt_docs_section ;
if (!$this->location_id) $this->location_id=$deflt_docs_location;
$rqtloc = "SELECT idlocation FROM docs_location order by location_libelle";
$resloc = pmb_mysql_query($rqtloc, $dbh);
$selector = '';
while ($loc=pmb_mysql_fetch_object($resloc)) {
$requete = "SELECT idsection, section_libelle FROM docs_section, docsloc_section where idsection=num_section and num_location='$loc->idlocation' order by section_libelle";
$result = pmb_mysql_query($requete, $dbh);
$nbr_lignes = pmb_mysql_num_rows($result);
if ($nbr_lignes) {
if ($loc->idlocation==$this->location_id) $selector .= "
";
}
break;
default:
print $this->show_form();
break;
}
}
}
class abts_abonnements {
public $abonnements = array(); //Tableau des IDs des modèles
public function __construct($id_perio,$localisation=0) {
$where_localisation = '';
if($localisation > 0) $where_localisation=" and location_id = $localisation ";
$requete="select abt_id from abts_abts where num_notice=$id_perio $where_localisation order by abt_name";
$resultat=pmb_mysql_query($requete);
while ($r=pmb_mysql_fetch_object($resultat)) {
$abonnement=new abts_abonnement($r->abt_id);
if (!$abonnement->error) $this->abonnements[]=$abonnement;
}
}
public function show_list() {
global $abonnement_list,$msg,$serial_id;
$r=$abonnement_list;
$abonnements="";
if (count($this->abonnements)) {
for ($i=0; $iabonnements); $i++) {
$abonnements.=$this->abonnements[$i]->show_abonnement();
}
}
$resultat=pmb_mysql_query("select modele_id,modele_name from abts_modeles where num_notice='$serial_id'");
$cpt=0;
while ($rp=pmb_mysql_fetch_object($resultat)) {
$cpt++;
}
if($cpt)
$r=str_replace("!!abts_abonnements_add_button!!","",$r);
else $r=str_replace("!!abts_abonnements_add_button!!",$msg["abts_modeles_no_modele"],$r);
return str_replace("!!abonnement_list!!",$abonnements,$r);
}
}
function gen_plus_form($id,$titre,$contenu) {
global $msg;
return "