";
*/
if ($parity++ % 2) $pair_impair = "even"; else $pair_impair = "odd";
// Si modifiable, ajout du lien vers le formulaire
if($my_collstate->explr_acces_autorise=="MODIF") {
$tr_javascript=" onmousedown=\"document.location='./catalog.php?categ=serials&sub=collstate_form&id=".$coll->collstate_id."&serial_id=".$this->serial_id."';\" ";
} else {
$tr_javascript="";
}
$tr_surbrillance = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='".$pair_impair."'\" ";
$line = str_replace('!!tr_javascript!!',$tr_javascript , $tpl_collstate_liste_line[$type]);
$line = str_replace('!!tr_surbrillance!!',$tr_surbrillance , $line);
$line = str_replace('!!pair_impair!!',$pair_impair , $line);
if ($pmb_sur_location_activate) {
$line = str_replace('!!surloc!!', $my_collstate->surloc_libelle, $line);
}
$line = str_replace('!!localisation!!', $my_collstate->location_libelle, $line);
$line = str_replace('!!cote!!', $my_collstate->cote, $line);
$line = str_replace('!!type_libelle!!', $my_collstate->type_libelle, $line);
$line = str_replace('!!emplacement_libelle!!', $my_collstate->emplacement_libelle, $line);
$line = str_replace('!!statut_libelle!!', "".$my_collstate->statut_gestion_libelle, $line);
$line = str_replace('!!origine!!', $my_collstate->origine, $line);
$line = str_replace('!!state_collections!!',str_replace("\n"," ",$my_collstate->state_collections), $line);
$line = str_replace('!!lacune!!', str_replace("\n"," ",$my_collstate->lacune), $line);
$liste.=$line;
}
$liste = str_replace('!!collstate_liste!!',$liste , $tpl_collstate_liste[$type]);
} else {
$liste= $msg["collstate_no_collstate"];
}
if($form)$liste = str_replace('!!collstate_table!!',$liste , $tpl_collstate_liste_form);
$liste = str_replace('!!base_url!!', $base_url, $liste);
$liste = str_replace('!!location!!', $location, $liste);
$this->liste=$liste;
$this->nbr=$nbr_lignes;
// barre de navigation par page
$this->pagination = aff_pagination ($base_url."&location=$location", $nbr_lignes, $nb_per_page_a_search, $page, 10, false, true) ;
}
// fonction de mise à jour ou de création d'état de collection
function update($value) {
global $dbh,$msg;
$fields="";
foreach($value as $key => $val) {
if($fields) $fields.=",";
$fields.=" $key='".addslashes($val)."' ";
}
if($this->id) {
// modif
$no_erreur=mysql_query("UPDATE collections_state SET $fields WHERE collstate_id=".$this->id, $dbh);
if(!$no_erreur) {
error_message($msg["collstate_add_collstate"], $msg["collstate_add_error"],1);
exit;
}
} else {
// create
$no_erreur=mysql_query("INSERT INTO collections_state SET $fields ", $dbh);
$this->id = mysql_insert_id($dbh);
if(!$no_erreur) {
error_message($msg["collstate_edit_collstate"], $msg["collstate_add_error"],1);
exit;
}
}
return $this->id;
}
function update_from_form() {
global $state_collections,$origine,$archive,$cote,$note,$lacune,$serial_id,$archstatut_id,$archtype_id,$location_id,$archempla_id;
global $deflt_docs_location;
$value->id_serial=stripslashes($serial_id);
if(!$location_id) $location_id=$deflt_docs_location;
$value->location_id=stripslashes($location_id);
$value->state_collections=stripslashes($state_collections);
$value->collstate_emplacement=stripslashes($archempla_id);
$value->collstate_type=stripslashes($archtype_id);
$value->collstate_origine=stripslashes($origine);
$value->collstate_note=stripslashes($note);
$value->collstate_cote=stripslashes($cote);
$value->collstate_archive=stripslashes($archive);
$value->collstate_lacune=stripslashes($lacune);
if(!$archstatut_id)$archstatut_id=1;
$value->collstate_statut=stripslashes($archstatut_id);
$this->update($value);
//Traitement des champs perso
$p_perso=new parametres_perso("collstate");
$p_perso->check_submited_fields();
$p_perso->rec_fields_perso($this->id);
}
// fonction générant le form de saisie de notice chapeau
function do_form() {
global $msg;
global $collstate_form,$statut_field,$emplacement_field, $location_field, $support_field;
global $deflt_docs_location;
global $deflt_arch_statut,$deflt_arch_emplacement,$deflt_arch_type;
global $charset;
global $pmb_etat_collections_localise;
// titre formulaire
if($this->id) {
$libelle=$libelle=$msg["collstate_edit_collstate"];
$link_delete="";
} else {
$libelle=$msg["collstate_add_collstate"];
$link_delete="";
}
$collstate_form = str_replace('!!id!!', htmlentities($this->id,ENT_QUOTES,$charset), $collstate_form);
$collstate_form = str_replace('!!location_id!!', htmlentities($this->location_id,ENT_QUOTES,$charset), $collstate_form);
$collstate_form = str_replace('!!serial_id!!', htmlentities($this->serial_id,ENT_QUOTES,$charset), $collstate_form);
$action="./catalog.php?categ=serials&sub=collstate_update&serial_id=".rawurlencode($this->serial_id)."&id=".rawurlencode($this->id);
$collstate_form = str_replace('!!action!!', $action, $collstate_form);
$collstate_form = str_replace('!!delete!!', $link_delete, $collstate_form);
$collstate_form = str_replace('!!libelle!!',$libelle , $collstate_form);
$collstate_form = str_replace('!!origine!!',htmlentities($this->origine,ENT_QUOTES,$charset) , $collstate_form);
$collstate_form = str_replace('!!archive!!',htmlentities($this->archive,ENT_QUOTES,$charset) , $collstate_form);
$collstate_form = str_replace('!!cote!!',htmlentities($this->cote,ENT_QUOTES,$charset) , $collstate_form);
$collstate_form = str_replace('!!note!!',htmlentities($this->note,ENT_QUOTES,$charset) , $collstate_form);
$collstate_form = str_replace('!!lacune!!',htmlentities($this->lacune,ENT_QUOTES,$charset) , $collstate_form);
$collstate_form = str_replace('!!state_collections!!',htmlentities($this->state_collections,ENT_QUOTES,$charset) , $collstate_form);
// champs des localisations
if($pmb_etat_collections_localise) {
if(!$this->location_id) $this->location_id=$deflt_docs_location;
$select = gen_liste("select distinct idlocation, location_libelle from docs_location order by 2 ", "idlocation", "location_libelle", 'location_id', "", $this->location_id, "", "","","",0);
$field="";
if($select) $field = str_replace('!!location!!',$select, $location_field);
$collstate_form = str_replace('!!location_field!!',$field, $collstate_form);
}else{
$field=" ";
$collstate_form = str_replace('!!location_field!!',$field, $collstate_form);
}
// champs des emplacements
if(!$this->emplacement) $this->emplacement=$deflt_arch_emplacement;
$select = gen_liste("select archempla_id, archempla_libelle from arch_emplacement order by 2", "archempla_id", "archempla_libelle", "archempla_id", "",$this->emplacement, "", "", "","","",0) ;
$field="";
if($select) $field = str_replace('!!emplacement!!',$select, $emplacement_field);
$collstate_form = str_replace('!!emplacement_field!!',$field, $collstate_form);
// champs des supports
if(!$this->type) $this->type=$deflt_arch_type;
$select = gen_liste("select archtype_id, archtype_libelle from arch_type order by 2", "archtype_id", "archtype_libelle", "archtype_id", "", $this->type, "", "","","",0) ;
$field="";
if($select) $field = str_replace('!!support!!',$select, $support_field);
$collstate_form = str_replace('!!support_field!!',$field, $collstate_form);
// champs des statuts
if(!$this->statut) $this->statut=$deflt_arch_statut;
$select = gen_liste("select archstatut_id, archstatut_gestion_libelle from arch_statut order by 2", "archstatut_id", "archstatut_gestion_libelle", "archstatut_id", "", $this->statut, "", "","","",0) ;
$field="";
if($select) $field = str_replace('!!statut!!',$select, $statut_field);
$collstate_form = str_replace('!!statut_field!!',$field, $collstate_form);
// Champs perso
$p_perso=new parametres_perso("collstate");
$parametres_perso="";
if (!$p_perso->no_special_fields) {
$perso_=$p_perso->show_editable_fields($this->id);
$perso="";
for ($i=0; $i
".$p["AFF"]."
";
}
$perso.=$perso_["CHECK_SCRIPTS"];
$parametres_perso.=$perso;
}
$collstate_form = str_replace('!!parametres_perso!!',$parametres_perso , $collstate_form);
$link_annul = "onClick=\"unload_off();history.go(-1);\"";
$collstate_form = str_replace('!!annul!!', $link_annul, $collstate_form);
//vérification de la présence de champs perso
//si non, on confirme la soumission du formulaire
if($p_perso->no_special_fields)
$return_form = "return true";
//sinon, on vérifie leurs valeurs
else $return_form = "return check_form()";
$collstate_form = str_replace('!!return_form!!',$return_form, $collstate_form);
return $collstate_form;
}
// suppression d'une collection ou de toute les collections d'un périodique
function delete() {
global $dbh;
if($this->id) {
//elimination des champs persos
$p_perso=new parametres_perso("collstate");
$p_perso->delete_values($this->id);
mysql_query("DELETE from collections_state WHERE collstate_id='".$this->id."' ", $dbh);
} else if($this->serial_id) {
$myQuery = mysql_query("SELECT collstate_id FROM collections_state WHERE id_serial='".$this->serial_id."' ", $dbh);
if((mysql_num_rows($myQuery))) {
while(($coll = mysql_fetch_object($myQuery))) {
$my_collstate=new collstate($coll->collstate_id);
$my_collstate->delete();
}
}
}
}
} // fin définition classe