abt_id = $abt_id+0; $this->getData(); } public function getData() { $this->abt_name = ''; $this->abt_name_opac = ''; $this->num_notice = ''; $this->base_modele_name = ''; $this->base_modele_id = ''; $this->num_notice = ''; //numéro de la notice liée $this->duree_abonnement = ''; //Durée de l'abonnement $this->date_debut = ''; //Date de début de validité du modèle $this->date_fin = ''; //Date de fin de validité du modèle $this->fournisseur = '';// id du fournisseur $this->destinataire = ''; $this->cote = ''; $this->typdoc_id = ''; $this->exemp_auto = ''; $this->location_id = ''; $this->section_id = ''; $this->lender_id = ''; $this->statut_id = ''; $this->codestat_id = ''; $this->type_antivol = ''; $this->abt_numeric = ''; $this->prix = ''; $this->abt_status = ''; if ($this->abt_id) { $requete="select * from abts_abts where abt_id=".$this->abt_id; $resultat=pmb_mysql_query($requete); if (pmb_mysql_num_rows($resultat)) { $r=pmb_mysql_fetch_object($resultat); $this->abt_id = $r->abt_id; $this->abt_name = $r->abt_name; $this->abt_name_opac = $r->abt_name_opac; $this->num_notice = $r->num_notice; $this->base_modele_name = $r->base_modele_name; $this->base_modele_id = $r->base_modele_id; $this->num_notice = $r->num_notice; //numéro de la notice liée $this->duree_abonnement = $r->duree_abonnement; //Durée de l'abonnement $this->date_debut = $r->date_debut; //Date de début de validité du modèle $this->date_fin = $r->date_fin; //Date de fin de validité du modèle $this->fournisseur = $r->fournisseur;// id du fournisseur $this->destinataire = $r->destinataire; $this->cote = $r->cote; $this->typdoc_id = $r->typdoc_id; $this->exemp_auto = $r->exemp_auto; $this->location_id = $r->location_id; $this->section_id = $r->section_id; $this->lender_id = $r->lender_id; $this->statut_id = $r->statut_id; $this->codestat_id = $r->codestat_id; $this->type_antivol = $r->type_antivol; $this->abt_numeric = $r->abt_numeric; $this->prix = $r->prix; $this->abt_status = $r->abt_status; } else { $this->error = true; $this->error_message = "Le modèle demandé n'existe pas"; } } } public function set_perio($num_notice) { $this->num_notice = 0; $requete = "select niveau_biblio from notices where notice_id=".$num_notice; $resultat = pmb_mysql_query($requete); if (pmb_mysql_num_rows($resultat)) { if (pmb_mysql_result($resultat,0,0)=="s") $this->num_notice = $num_notice; } else { $this->error = true; $this->error_message = "La notice liée n'existe pas ou n'est pas un périodique"; } } public function show_abonnement() { global $abonnement_view,$serial_id; global $dbh,$msg; global $abonnement_serialcirc_empr_list_empr, $abonnement_serialcirc_empr_list_group, $abonnement_serialcirc_empr_list_group_elt; global $pmb_gestion_devise; $perio=new serial_display($this->num_notice,1); $r=$abonnement_view; $r=str_replace("!!view_id_abonnement!!","catalog.php?categ=serials&sub=abon&serial_id=$serial_id&abt_id=$this->abt_id",$r); $r=str_replace("!!id_abonnement!!",$this->abt_id,$r); $r=str_replace("!!abonnement_header!!",$this->abt_name,$r); $r=str_replace("!!statut!!",abts_status::get_display($this->abt_status),$r); $modele=0; $modele_list=""; $requete="select modele_id from abts_abts_modeles where abt_id='$this->abt_id'"; $resultat=pmb_mysql_query($requete, $dbh); while ($r_a=pmb_mysql_fetch_object($resultat)) { $modele_id=$r_a->modele_id; $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."'"); if ($modele_list) $modele_list.=","; $modele_list.=" $modele_name"; if($periodicite) $modele_list.=" ($periodicite)"; } $r=str_replace("!!modele_lie!!",$modele_list,$r); $r=str_replace("!!duree_abonnement!!",$this->duree_abonnement,$r); $r=str_replace("!!date_debut!!",format_date($this->date_debut),$r); $r=str_replace("!!date_fin!!",format_date($this->date_fin),$r); $r=str_replace("!!nombre_de_series!!",pmb_sql_value("select sum(nombre) from abts_grille_abt where num_abt='$this->abt_id' and type ='1'"),$r); $r=str_replace("!!nombre_de_horsseries!!",pmb_sql_value("select sum(nombre) from abts_grille_abt where num_abt='$this->abt_id' and type ='2'"),$r); $prix=''; $prix=$this->prix.' '.$pmb_gestion_devise; $r=str_replace("!!prix!!",$prix,$r); $fournisseur_name = ''; if($this->fournisseur) $fournisseur_name=$msg["abonnements_fournisseur"].": ".pmb_sql_value("SELECT raison_sociale from entites where id_entite = '".$this->fournisseur."' "); $r=str_replace("!!fournisseur!!",$fournisseur_name,$r); $aff_destinataire=""; if($this->destinataire){ $aff_destinataire=" ".$this->destinataire." "; } $r=str_replace("!!commentaire!!",$aff_destinataire,$r); //Liste des destinataires $serialcirc_diff=new serialcirc_diff(0,$this->abt_id); $tpl_empr_list = ""; foreach($serialcirc_diff->diffusion as $diff){ if($diff['empr_type']==SERIALCIRC_EMPR_TYPE_empr){ $tpl_empr=$abonnement_serialcirc_empr_list_empr; $name_elt=$serialcirc_diff->empr_info[ $diff['empr']['id_empr']]['empr_libelle']; }else{ $name_elt=$diff['empr_name']; $group_list_list=""; if(count($diff['group'])){ $tpl_empr=$abonnement_serialcirc_empr_list_group; foreach($diff['group'] as $empr){ $group_list=$abonnement_serialcirc_empr_list_group_elt; $resp=""; if($empr['responsable']){ $resp=$msg["serialcirc_group_responsable"]; } $group_list=str_replace('!!empr_libelle!!',$empr['empr']['empr_libelle'].$resp, $group_list); $group_list_list.=$group_list; } $tpl_empr=str_replace('!!empr_list!!', $group_list_list, $tpl_empr); }else { $tpl_empr=$abonnement_serialcirc_empr_list_empr; } } $tpl_empr=str_replace('!!id_diff!!', $diff['id'], $tpl_empr); if (isset($diff['empr']['view_link'])) { $tpl_empr=str_replace('!!empr_view_link!!', $diff['empr']['view_link'], $tpl_empr); } else { // un groupe $tpl_empr=str_replace('!!empr_view_link!!', '', $tpl_empr); } $tpl_empr=str_replace('!!empr_name!!', $name_elt, $tpl_empr); $tpl_empr_list.=$tpl_empr; } $aff_empr_list=""; if($tpl_empr_list){ $aff_empr_list="

".$msg["serialcirc_diff_empr_list_title"]."

$tpl_empr_list "; } $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.=""; $test_liste_modele.=" (document.getElementById('modele[".$rp->modele_id."]').checked==true) "; } $test_liste_modele.=") { return true; }else { alert(\"$msg[abonnements_err_msg_select_model]\"); return false; }"; $liste_modele.="
$rp->modele_name
"; $r=str_replace("!!liste_modele!!",$liste_modele,$r); $r=str_replace("!!test_liste_modele!!",$test_liste_modele,$r); $copy_bouton=$del_bouton=""; $r=str_replace("!!abonnement_form1!!","",$r); $bouton_prolonge=''; $bouton_raz=''; } else { $this->getData(); $r=$serial_header.$edition_abonnement_form; $r=str_replace('!!page_title!!', $msg[4000].$msg[1003].$msg["abts_abonnements_modify_title"], $r); $r=str_replace('!!libelle_form!!', $msg["abts_abonnements_modify_title"], $r); $bouton_prolonge=""; $bouton_raz=""; // abts_status $r = str_replace("!!abts_status!!", abts_status::get_form_for($this->abt_status), $r); //Durée d'abonnement if (!$this->duree_abonnement) $this->duree_abonnement=12; $r=str_replace("!!duree_abonnement!!",$this->duree_abonnement,$r); //Date de début if (!$this->date_debut || $this->date_debut == "0000-00-00") $date_debut=date("Ymd",time()); else $date_debut=$this->date_debut; $r=str_replace("!!date_debut!!",str_replace("-","",$date_debut),$r); $r=str_replace("!!date_debut_lib!!",formatdate($date_debut),$r); //Date de fin if (!$this->date_fin || $this->date_fin == "0000-00-00") $date_fin=pmb_sql_value("SELECT DATE_ADD('$date_debut', INTERVAL 1 YEAR)"); else $date_fin=$this->date_fin; $r=str_replace("!!date_fin!!",str_replace("-","",$date_fin),$r); $r=str_replace("!!date_fin_lib!!",format_date($date_fin),$r); //Fournisseur $r=str_replace('!!lib_fou!!', htmlentities(pmb_sql_value("SELECT raison_sociale from entites where id_entite = '".$this->fournisseur."' "),ENT_QUOTES,$charset), $r); $r=str_replace('!!id_fou!!', $this->fournisseur, $r); //Destinataire: $r=str_replace('!!destinataire!!', $this->destinataire, $r); //Cote: $r=str_replace('!!cote!!', htmlentities($this->cote,ENT_QUOTES,$charset), $r); // select "type document" $r = str_replace('!!type_doc!!', do_selector('docs_type', 'typdoc_id', $this->typdoc_id), $r); $r = str_replace('!!exemplarisation_automatique!!', "exemp_auto ?"checked":"yes")." name='exemp_auto' id='exemp_auto'/>", $r); $r = str_replace('!!abt_numeric_checked!!', ($this->abt_numeric ?"checked":"yes"), $r); // select "localisation" $r = str_replace('!!localisation!!', gen_liste ("select distinct idlocation, location_libelle from docs_location, docsloc_section where num_location=idlocation order by 2 ", "idlocation", "location_libelle", 'location_id', "calcule_section(this);", $this->location_id, "", "","","",0), $r); // select "section" $r = str_replace('!!section!!', $this->do_selector(), $r); // select "owner" $r = str_replace('!!owner!!', do_selector('lenders', 'lender_id', $this->lender_id), $r); // select "statut" $r = str_replace('!!statut!!', do_selector('docs_statut', 'statut_id', $this->statut_id), $r); // select "code statistique" $r = str_replace('!!codestat!!', do_selector('docs_codestat', 'codestat_id', $this->codestat_id), $r); //Prix $r=str_replace('!!prix!!', htmlentities($this->prix,ENT_QUOTES,$charset), $r); $selector=""; if($pmb_antivol>0) {// select "type_antivol" $selector = "'; } $r = str_replace('!!type_antivol!!', $selector, $r); //Liste des formulaire de modèles (dépliables +,-) $modele_list=""; $modele_list_dates = array(); $requete="select a.modele_id,num,vol,tome,delais,critique, num_statut_general, date_debut, date_fin from abts_abts_modeles a join abts_modeles m on m.modele_id=a.modele_id where abt_id='$this->abt_id'"; $resultat=pmb_mysql_query($requete, $dbh); if (!$resultat) die($requete."

".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.= "
" ; $date = $this->date_debut; $calend.= ""; $year=pmb_sql_value("SELECT YEAR('$date')"); $cur_year=$year; //debut expand $calend.="
 
$year
"; $i=pmb_sql_value("SELECT MONTH('$date')"); if($i==2 || $i==5 || $i==8 || $i==11) { $calend.= "
 "; $calend.= "
\n"; } if($i==3 || $i==6 || $i==9 || $i==12) { $calend.= "
 "; $calend.= "
\n"; $calend.= "
 "; $calend.= "
\n"; } do{ $year=pmb_sql_value("SELECT YEAR('$date')"); if($year!=$cur_year){ $calend.= "
"; $calend.="
$year
\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 .= "
idlocation."\" style=\"display:block\">\r\n"; else $selector .= "
idlocation."\" style=\"display:none\">\r\n"; $selector .= "
'; } } return $selector; } public function gen_tpl_abt_modele($id,$titre,$num,$vol,$tome,$delais,$delais_critique,$change_statut_id){ global $dbh; global $msg; $requete="select * from abts_modeles where modele_id='$id'"; $resultat=pmb_mysql_query($requete, $dbh); if ($r_a=pmb_mysql_fetch_object($resultat)) { $tom_actif=$r_a->tom_actif; $vol_actif=$r_a->vol_actif; $num_depart=$r_a->num_depart; $vol_depart=$r_a->vol_depart; $tom_depart=$r_a->tom_depart; } if(!$num) $num=$num_depart; if(!$vol) $vol=$vol_depart; if(!$tome) $tome=$tom_depart; $contenu= "
"; if($vol_actif)$contenu.= "
"; if($tom_actif)$contenu.= "
"; $contenu.= "
"; // select !!change_statut!! $statut_form=str_replace('!!statut_check!!', "", $msg['catalog_change_statut_form']); $statut_form=str_replace('!!statut_list!!', do_selector('docs_statut', "change_statut[".$id."]", $change_statut_id), $statut_form); $contenu.= "
 
$statut_form
"; return gen_plus_form($id,$titre,$contenu); } public function gen_date($garder=0){ global $dbh; global $msg; global $include_path; if($this->abt_id) { if (!$garder) { $dummy = "delete FROM abts_grille_abt WHERE num_abt='$this->abt_id' and state='0'"; pmb_mysql_query($dummy, $dbh); } $date=$date_debut = construitdateheuremysql($this->date_debut); $date_fin = construitdateheuremysql($this->date_fin); //Pour tous les modèles utilisé dans l'abonnement, on recopie les grilles modèles dans la grille abonnement $requete="select modele_id from abts_abts_modeles where abt_id='$this->abt_id'"; $resultat_a=pmb_mysql_query($requete, $dbh); while ($r_a=pmb_mysql_fetch_object($resultat_a)) { $modele_id=$r_a->modele_id; $requete="select * from abts_grille_modele where num_modele='$modele_id'"; $resultat=pmb_mysql_query($requete); while ($r_g=pmb_mysql_fetch_object($resultat)) { //Ne garder les bulletins compris entre les dates de début et fin d'abonnement if( ( pmb_sql_value("SELECT DATEDIFF('$date_fin','$r_g->date_parution')")>= 0 ) && ( pmb_sql_value("SELECT DATEDIFF('$date_debut','$r_g->date_parution')")<= 0 ) ) { for($i=1;$i<=$r_g->nombre_recu;$i++){ $requete = "INSERT INTO abts_grille_abt SET num_abt='$this->abt_id', date_parution ='$r_g->date_parution', modele_id='$modele_id', type = '$r_g->type_serie', numero='$r_g->numero', nombre='1', ordre='$i' "; pmb_mysql_query($requete, $dbh); } } } } } } public function update() { global $dbh; global $msg; global $include_path; global $act,$modele,$num,$vol,$tome,$delais,$delais_critique,$change_statut,$change_statut_check; if(!$this->abt_name) return false; // nettoyage des valeurs en entrée $this->abt_name = clean_string($this->abt_name); $this->abt_name_opac = clean_string($this->abt_name_opac); // construction de la requête $requete = "SET abt_name='".addslashes($this->abt_name)."', "; $requete .= "abt_name_opac='".addslashes($this->abt_name_opac)."', "; $requete .= "num_notice='$this->num_notice', "; $requete .= "duree_abonnement='$this->duree_abonnement', "; $requete .= "date_debut='$this->date_debut', "; $requete .= "date_fin='$this->date_fin', "; $requete .= "fournisseur='$this->fournisseur', "; $requete .= "destinataire='".addslashes($this->destinataire)."', "; $requete .= "cote='".addslashes($this->cote)."', "; $requete .= "typdoc_id='$this->typdoc_id', "; $requete .= "exemp_auto='$this->exemp_auto', "; $requete .= "location_id='$this->location_id', "; $requete .= "section_id='$this->section_id', "; $requete .= "lender_id='$this->lender_id', "; $requete .= "statut_id='$this->statut_id', "; $requete .= "codestat_id='$this->codestat_id', "; $requete .= "prix='$this->prix', "; $requete .= "type_antivol='$this->type_antivol', "; $requete .= "abt_numeric='$this->abt_numeric', "; $requete .= "abt_status='$this->abt_status' "; if($this->abt_id) { // Update: s'assurer que le nom d'abonnement n'existe pas déjà $dummy = "SELECT * FROM abts_abts WHERE abt_name='".addslashes($this->abt_name)."' and num_notice='$this->num_notice' and abt_id!=$this->abt_id"; $check = pmb_mysql_query($dummy, $dbh); if(pmb_mysql_num_rows($check)) { require_once("$include_path/user_error.inc.php"); warning($msg["abonnements_titre_creation_edition_abonnement"], $msg["abonnements_erreur_creation_doublon_abonnement"]." ($this->abt_name)."); return FALSE; } // update $requete = 'UPDATE abts_abts '.$requete; $requete .= ' WHERE abt_id='.$this->abt_id.' LIMIT 1;'; if(pmb_mysql_query($requete, $dbh) ) { if($act=="gen") $this->gen_date(); $requete="select modele_id from abts_modeles where num_notice='$this->num_notice'"; $resultat=pmb_mysql_query($requete, $dbh); while ($r=pmb_mysql_fetch_object($resultat)) { $modele_id=$r->modele_id; if($change_statut_check[$modele_id])$num_statut=$change_statut[$modele_id]; else $num_statut=0; $requete = "UPDATE abts_abts_modeles SET num='$num[$modele_id]', vol='$vol[$modele_id]', tome='$tome[$modele_id]', delais='$delais[$modele_id]', critique='$delais_critique[$modele_id]' , num_statut_general='$num_statut' WHERE modele_id='$modele_id'and abt_id='$this->abt_id'"; pmb_mysql_query($requete, $dbh); } //Traductions $translation = new translation($this->abt_id, 'abts_abts'); $translation->update_small_text('abt_name_opac'); return TRUE; } else { echo pmb_mysql_error(); require_once("$include_path/user_error.inc.php"); warning($msg["abonnements_titre_creation_edition_abonnement"], $msg["abonnements_titre_creation_edition_modele_impossible"]); return FALSE; } } else { // Création: s'assurer que le modèle n'existe pas déjà $dummy = "SELECT * FROM abts_abts WHERE abt_name='".addslashes($this->abt_name)."' and num_notice='$this->num_notice'"; $check = pmb_mysql_query($dummy, $dbh); if(pmb_mysql_num_rows($check)) { require_once("$include_path/user_error.inc.php"); warning($msg["abonnements_titre_creation_edition_abonnement"], $msg["abonnements_erreur_creation_doublon_abonnement"]." ($this->abt_name)."); return FALSE; } $requete = 'INSERT INTO abts_abts '.$requete.';'; if(pmb_mysql_query($requete, $dbh)) { $this->abt_id=pmb_mysql_insert_id(); $requete="select modele_id,num_periodicite from abts_modeles where num_notice='$this->num_notice'"; $resultat=pmb_mysql_query($requete, $dbh); while ($r=pmb_mysql_fetch_object($resultat)) { $modele_id=$r->modele_id; $num_periodicite=$r->num_periodicite; if(isset($modele[$modele_id])){ $requete="select libelle, retard_periodicite,seuil_periodicite from abts_periodicites where periodicite_id ='".$num_periodicite."'"; $r_delais=pmb_mysql_query($requete, $dbh); if ($r_d=pmb_mysql_fetch_object($r_delais)) { $periodicite=$r_d->libelle; $delais=$r_d->seuil_periodicite; $critique=$r_d->retard_periodicite; } if(!isset($critique)) $critique = 0; //retard_periodicite est a NULL par défaut if($change_statut_check[$modele_id])$num_statut=$change_statut[$modele_id]; else $num_statut=0; $requete = "INSERT INTO abts_abts_modeles SET modele_id='$modele_id', abt_id='$this->abt_id', delais='$delais', critique='$critique', num_statut_general='$num_statut' "; pmb_mysql_query($requete, $dbh); } } //Traductions $translation = new translation($this->abt_id, 'abts_abts'); $translation->update_small_text('abt_name_opac'); if($act=="gen") $this->gen_date(); return TRUE; } else { echo pmb_mysql_error(); require_once("$include_path/user_error.inc.php"); warning($msg["abonnements_titre_creation_edition_abonnement"], $msg["abonnements_titre_creation_edition_modele_impossible"]); return FALSE; } } } public function delete(){ global $dbh; global $msg; global $include_path; // l'abonnement a encore au moins un expl en circulation if(serialcirc_diff::expl_in_circ($this->abt_id)){ return $msg['serialcirc_error_delete_abt']; } $dummy = "delete FROM abts_abts WHERE abt_id='$this->abt_id' "; $check = pmb_mysql_query($dummy, $dbh); $dummy = "delete FROM abts_grille_abt WHERE num_abt='$this->abt_id' "; $check = pmb_mysql_query($dummy, $dbh); $dummy = "delete FROM abts_abts_modeles WHERE abt_id='$this->abt_id' "; $check = pmb_mysql_query($dummy, $dbh); abts_pointage::delete_retard($this->abt_id); serialcirc_diff::delete($this->abt_id); translation::delete($this->abt_id, 'abts_abts'); return ""; } public function proceed() { global $act; global $serial_id,$msg,$num_notice,$num_periodicite,$duree_abonnement,$date_debut,$date_fin,$days,$day_month,$week_month,$week_year,$month_year,$date_parution; global $abt_name,$abt_name_opac,$duree_abonnement,$date_debut,$date_fin,$id_fou,$destinataire; global $dbh,$abt_id; global $cote,$typdoc_id,$exemp_auto,$location_id,$lender_id,$statut_id,$codestat_id, $prix,$type_antivol,$abt_numeric, $abts_status; global $deflt_docs_section; global $deflt_docs_location,$nb_duplication; $formlocid="f_ex_section".$location_id ; global ${$formlocid}; $section_id=${$formlocid} ; if (!$section_id) $section_id=$deflt_docs_section ; if (!$location_id) $location_id=$deflt_docs_location; if(!$abts_status) $abts_status = 1; switch ($act) { case 'update': // mise à jour modèle $this->abt_name= stripslashes($abt_name); $this->abt_name_opac= stripslashes($abt_name_opac); $this->num_notice= $num_notice; $this->duree_abonnement = $duree_abonnement; $this->date_debut= $date_debut; $this->date_fin= $date_fin; $this->fournisseur = $id_fou; $this->destinataire = stripslashes($destinataire); $this->cote=stripslashes($cote); $this->typdoc_id=$typdoc_id; $this->exemp_auto=$exemp_auto; $this->location_id=$location_id; $this->section_id=$section_id; $this->lender_id=$lender_id; $this->statut_id=$statut_id; $this->codestat_id=$codestat_id; $this->prix=stripslashes($prix); $this->type_antivol=$type_antivol; $this->abt_numeric=$abt_numeric; $this->abt_status=$abts_status; $this->update(); print $this->show_form(); break; case 'gen': // mise à jour modèle $this->abt_name= stripslashes($abt_name); $this->abt_name_opac= stripslashes($abt_name_opac); $this->num_notice= $num_notice; $this->duree_abonnement = $duree_abonnement; $this->date_debut= $date_debut; $this->date_fin= $date_fin; $this->fournisseur = $id_fou; $this->destinataire = stripslashes($destinataire); $this->cote=stripslashes($cote); $this->typdoc_id=$typdoc_id; $this->exemp_auto=$exemp_auto; $this->location_id=$location_id; $this->section_id=$section_id; $this->lender_id=$lender_id; $this->statut_id=$statut_id; $this->codestat_id=$codestat_id; $this->prix=stripslashes($prix); $this->type_antivol=$type_antivol; $this->abt_numeric=$abt_numeric; $this->abt_status=$abts_status; $this->update(); print $this->show_form(); break; case 'prolonge': // mise à jour modèle $this->abt_name= stripslashes($abt_name); $this->abt_name_opac= stripslashes($abt_name_opac); $this->num_notice= $num_notice; $this->duree_abonnement = $duree_abonnement; $this->date_debut= $date_fin; //Ce n'est pas une erreur mais cela sert pour $this->gen_date(1); qui suit... Date début est bien re-valorisé juste après $this->date_fin= pmb_sql_value("SELECT DATE_ADD('$date_fin',INTERVAL $duree_abonnement month)"); $this->fournisseur = $id_fou; $this->destinataire = stripslashes($destinataire); $this->cote=stripslashes($cote); $this->typdoc_id=$typdoc_id; $this->exemp_auto=$exemp_auto; $this->location_id=$location_id; $this->section_id=$section_id; $this->lender_id=$lender_id; $this->statut_id=$statut_id; $this->codestat_id=$codestat_id; $this->prix=stripslashes($prix); $this->type_antivol=$type_antivol; $this->abt_numeric=$abt_numeric; $this->abt_status=$abts_status; $this->gen_date(1); $this->date_debut= $date_debut; $this->update(); print $this->show_form(); break; case 'copy': $this->getData(); $abt_id=$this->abt_id; $this->abt_name.="_1"; for($i=0;$i<$nb_duplication;$i++){ //Création nouvel abonnement $this->abt_id=''; do { $this->abt_name++; $requete = "SELECT abt_name FROM abts_abts WHERE abt_name='".addslashes($this->abt_name)."' and num_notice='$this->num_notice'"; $resultat=pmb_mysql_query($requete, $dbh); } while (pmb_mysql_fetch_object($resultat)); $this->update(); //recopie des modeles associés $requete = "select * from abts_abts_modeles where abt_id='$abt_id'"; $resultat=pmb_mysql_query($requete); while ($r_m=pmb_mysql_fetch_object($resultat)) { $requete = "INSERT INTO abts_abts_modeles SET modele_id='$r_m->modele_id', abt_id='$this->abt_id',num='$r_m->num' ,vol='$r_m->vol',tome='$r_m->tome',delais='$r_m->delais', critique='$r_m->critique',num_statut_general='$r_m->num_statut_general'"; pmb_mysql_query($requete, $dbh); } //recopie des infos du calendrier $requete = "select * from abts_grille_abt where num_abt='$abt_id'"; $resultat=pmb_mysql_query($requete); while ($r_g=pmb_mysql_fetch_object($resultat)) { $requete = "INSERT INTO abts_grille_abt SET num_abt='$this->abt_id', date_parution ='$r_g->date_parution', modele_id='$r_g->modele_id', type = '$r_g->type', numero='$r_g->numero', nombre='$r_g->nombre', ordre='$r_g->ordre' "; pmb_mysql_query($requete, $dbh); } } print "
".$msg['maj_encours']."
"; $id_form = md5(microtime()); $retour = "./catalog.php?categ=serials&sub=view&serial_id=$serial_id&view=abon"; print "
"; break; case 'raz': if($this->abt_id) { $dummy = "delete FROM abts_grille_abt WHERE num_abt='".$this->abt_id."'"; pmb_mysql_query($dummy, $dbh); } print $this->show_form(); break; case 'del': if($msg_error=$this->delete()) { $retour = "./circ.php?categ=serialcirc"; error_message('', $msg_error, 1, $retour); }else{ print "
".$msg['maj_encours']."
"; $id_form = md5(microtime()); $retour = "./catalog.php?categ=serials&sub=view&serial_id=$serial_id&view=abon"; print "
"; } 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 "
$titre
"; } ?>