";
if (SESSrights & ADMINISTRATION_AUTH) {
$link = "!!name!!";
} else {
$link = "!!name!!";
}
break;
default : // On ne doit pas passer par là
$links_form = "";
//break 2; // On sort aussi du foreach
$end = true;
break;
}
if($end) break;
foreach ( $values as $infos ) {
$links_form .= "
";
}
}
return $links_form;
}
public function set_properties_from_form() {
global $cart_type;
global $classementGen_caddie;
parent::set_properties_from_form();
if(!$this->idcaddie || ($this->idcaddie && !$this->nb_item && $cart_type)) {
$this->type = $cart_type;
}
$this->classementGen = stripslashes($classementGen_caddie);
}
protected static function get_order_cart_list() {
return " order by type, name, comment ";
}
static public function get_cart_data($temp) {
global $dbh;
$nb_item = 0 ;
$nb_item_pointe = 0 ;
$nb_item_base = 0 ;
$nb_item_base_pointe = 0 ;
$nb_item_blob = 0 ;
$nb_item_blob_pointe = 0 ;
$rqt_nb_item="select count(1) from caddie_content where caddie_id='".$temp->idcaddie."' ";
$nb_item = pmb_mysql_result(pmb_mysql_query($rqt_nb_item, $dbh), 0, 0);
$rqt_nb_item_pointe = "select count(1) from caddie_content where caddie_id='".$temp->idcaddie."' and (flag is not null and flag!='') ";
$nb_item_pointe = pmb_mysql_result(pmb_mysql_query($rqt_nb_item_pointe, $dbh), 0, 0);
$rqt_nb_item_base="select count(1) from caddie_content where caddie_id='".$temp->idcaddie."' and (content is null or content='') ";
$nb_item_base = pmb_mysql_result(pmb_mysql_query($rqt_nb_item_base, $dbh), 0, 0);
$rqt_nb_item_base_pointe="select count(1) from caddie_content where caddie_id='".$temp->idcaddie."' and (content is null or content='') and (flag is not null and flag!='') ";
$nb_item_base_pointe = pmb_mysql_result(pmb_mysql_query($rqt_nb_item_base_pointe, $dbh), 0, 0);
$nb_item_blob = $nb_item - $nb_item_base ;
$nb_item_blob_pointe = $nb_item_pointe - $nb_item_base_pointe ;
return array(
'idcaddie' => $temp->idcaddie,
'name' => $temp->name,
'type' => $temp->type,
'comment' => $temp->comment,
'autorisations' => $temp->autorisations,
'autorisations_all' => $temp->autorisations_all,
'caddie_classement' => $temp->caddie_classement,
'acces_rapide' => $temp->acces_rapide,
'favorite_color' => $temp->favorite_color,
'nb_item' => $nb_item,
'nb_item_pointe' => $nb_item_pointe,
'nb_item_base' => $nb_item_base,
'nb_item_base_pointe' => $nb_item_base_pointe,
'nb_item_blob' => $nb_item_blob,
'nb_item_blob_pointe' => $nb_item_blob_pointe
);
}
// liste des paniers disponibles
static public function get_cart_list($restriction_panier="",$acces_rapide = 0) {
return parent::get_cart_list($restriction_panier, $acces_rapide);
}
// création d'un panier vide
public function create_cart() {
$requete = "insert into caddie set name='".addslashes($this->name)."', type='".$this->type."', comment='".addslashes($this->comment)."', autorisations='".$this->autorisations."', autorisations_all='".$this->autorisations_all."', caddie_classement='".addslashes($this->classementGen)."', acces_rapide='".$this->acces_rapide."', favorite_color='".addslashes($this->favorite_color)."' ";
$user = $this->get_info_user();
if(is_object($user)) {
$requete .= ", creation_user_name='".addslashes($user->name)."', creation_date='".date("Y-m-d H:i:s")."'";
}
pmb_mysql_query($requete);
$this->idcaddie = pmb_mysql_insert_id();
$this->compte_items();
return $this->idcaddie;
}
// sauvegarde du panier
public function save_cart() {
$query = "update caddie set name='".addslashes($this->name)."', type='".$this->type."', comment='".addslashes($this->comment)."', autorisations='".$this->autorisations."', autorisations_all='".$this->autorisations_all."', caddie_classement='".addslashes($this->classementGen)."', acces_rapide='".$this->acces_rapide."', favorite_color='".addslashes($this->favorite_color)."' where ".static::get_field_name()."='".$this->get_idcaddie()."'";
$result = pmb_mysql_query($query);
return true;
}
// ajout d'un item
public function add_item($item=0, $object_type="NOTI", $bul_or_dep="") {
// $bul_or_dep permet de choisir entre notice de dépouillement (DEP)
// ou notice de bulletin (par défaut) lors de l'ajout d'un bulletin à un panier de notices
global $dbh;
if (!$item) return CADDIE_ITEM_NULL ;
// les objets sont identiques
if ($object_type==$this->type) {
// rêgle : les caddies sont homogènes, on y stocke des objets de même type en fonction du type du caddie
$requete_compte = "select count(1) from caddie_content where caddie_id='".$this->idcaddie."' AND object_id='".$item."' ";
$result_compte = @pmb_mysql_query($requete_compte, $dbh);
$deja_item=pmb_mysql_result($result_compte, 0, 0);
if (!$deja_item) {
$requete= "insert into caddie_content set caddie_id='".$this->idcaddie."', object_id='".$item."', content='' ";
$result = @pmb_mysql_query($requete, $dbh);
}
} else {
// Traitement des cas particuliers
// panier d'exemplaires :
// Notice reçue :
// on stocke tous les exemplaires associés à la notice
// voir le pb de notice de dépouillement
if ($this->type=="EXPL" && $object_type=="NOTI") {
$rqt_mono_serial_bull_analysis = "select niveau_biblio, niveau_hierar from notices where notice_id = '$item' ";
$res_mono_serial_bull_analysis = pmb_mysql_query($rqt_mono_serial_bull_analysis, $dbh);
$row_mono_serial_bull_analysis = pmb_mysql_fetch_object($res_mono_serial_bull_analysis);
// monographie
if ($row_mono_serial_bull_analysis->niveau_biblio=="m" && $row_mono_serial_bull_analysis->niveau_hierar=="0")
$rqt_expl = "select expl_id from exemplaires where expl_notice='$item' ";
// périodique : notice mère
if ($row_mono_serial_bull_analysis->niveau_biblio=="s" && $row_mono_serial_bull_analysis->niveau_hierar=="1")
$rqt_expl = "select expl_id from exemplaires, bulletins where bulletin_notice='$item' and expl_bulletin=bulletin_id ";
// périodique : notice de dépouillement (analytique)
if ($row_mono_serial_bull_analysis->niveau_biblio=="a" && $row_mono_serial_bull_analysis->niveau_hierar=="2")
$rqt_expl = "select expl_id from exemplaires, analysis where analysis_notice='$item' and analysis_bulletin=expl_bulletin ";
// bulletin : notice de bulletin
if ($row_mono_serial_bull_analysis->niveau_biblio=="b" && $row_mono_serial_bull_analysis->niveau_hierar=="2")
$rqt_expl = "select expl_id from exemplaires, bulletins where num_notice='$item' and bulletin_id=expl_bulletin ";
}
// Bulletin reçu :
// on stocke tous les exemplaires associés au bulletin
if ($this->type=="EXPL" && $object_type=="BULL") {
$rqt_expl = "select expl_id from exemplaires where expl_bulletin='$item' ";
}
// panier de notices :
// EXPL reçu :
// on stocke la notice de l'exemplaire
// voir le pb d'expl de bulletin
if ($this->type=="NOTI" && $object_type=="EXPL") {
$rqt_mono_bull = "select expl_notice, expl_bulletin from exemplaires where expl_id='$item' ";
$res_mono_bull = pmb_mysql_query($rqt_mono_bull, $dbh);
$row_mono_bull = pmb_mysql_fetch_object($res_mono_bull);
// expl de monographie
if ($row_mono_bull->expl_notice && !$row_mono_bull->expl_bulletin)
$rqt_expl = "select expl_notice from exemplaires where expl_id='$item' ";
// expl de bulletin
if (!$row_mono_bull->expl_notice && $row_mono_bull->expl_bulletin)
$rqt_expl = "select bulletin_notice from exemplaires, bulletins where expl_id='$item' and expl_bulletin=bulletin_id ";
}
// BULL reçu :
// on stocke la notice du bulletin si existante
// ATTENTION: modif version 3.1.12: ajout de la notice de bulletin et non plus les notices de dépouillement
if ($this->type=="NOTI" && $object_type=="BULL") {
if ($bul_or_dep=="DEP") $rqt_expl = "select analysis_notice from analysis where analysis_bulletin='$item' ";
else $rqt_expl = "select num_notice from bulletins where bulletin_id='$item' and num_notice!=0";
} // fin if NOTI / BULL
// panier de bulletins :
// EXPL reçu :
// on stocke le bulletin de l'exemplaire
if ($this->type=="BULL" && $object_type=="EXPL") {
$rqt_mono_bull = "select expl_notice, expl_bulletin from exemplaires where expl_id='$item' ";
$res_mono_bull = pmb_mysql_query($rqt_mono_bull, $dbh);
$row_mono_bull = pmb_mysql_fetch_object($res_mono_bull);
// expl de monographie
if ($row_mono_bull->expl_notice && !$row_mono_bull->expl_bulletin)
return CADDIE_ITEM_IMPOSSIBLE_BULLETIN;
// expl de bulletin
if (!$row_mono_bull->expl_notice && $row_mono_bull->expl_bulletin)
$rqt_expl = "select expl_bulletin from exemplaires where expl_id='$item' ";
}
// NOTI reçue :
// on stocke le bulletin associé à la notice chapeau reçue
// ou bien le bulletin contenant la notice de dépouillement reçue
if ($this->type=="BULL" && $object_type=="NOTI") {
$rqt_mono_serial_bull_analysis = "select niveau_biblio, niveau_hierar from notices where notice_id = '$item' ";
$res_mono_serial_bull_analysis = pmb_mysql_query($rqt_mono_serial_bull_analysis, $dbh);
$row_mono_serial_bull_analysis = pmb_mysql_fetch_object($res_mono_serial_bull_analysis);
// monographie
if ($row_mono_serial_bull_analysis->niveau_biblio=="m" && $row_mono_serial_bull_analysis->niveau_hierar=="0")
return CADDIE_ITEM_IMPOSSIBLE_BULLETIN;
// périodique : notice mère
if ($row_mono_serial_bull_analysis->niveau_biblio=="s" && $row_mono_serial_bull_analysis->niveau_hierar=="1")
$rqt_expl = "select bulletin_id from bulletins where bulletin_notice='$item' ";
// périodique : notice de dépouillement (analytique)
if ($row_mono_serial_bull_analysis->niveau_biblio=="a" && $row_mono_serial_bull_analysis->niveau_hierar=="2")
$rqt_expl = "select analysis_bulletin from analysis where analysis_notice='$item' ";
// bulletin : notice de bulletin
if ($row_mono_serial_bull_analysis->niveau_biblio=="b" && $row_mono_serial_bull_analysis->niveau_hierar=="2")
$rqt_expl = "select bulletin_id from bulletins where num_notice='$item' ";
}
if ($this->type=="EXPL" && $object_type=="EXPL") {
$rqt_expl = "select expl_id from exemplaires where expl_id='$item' ";
} // fin if NOTI / BULL
if ($rqt_expl) {
$res_expl = pmb_mysql_query($rqt_expl, $dbh);
for($i=0;$icompte_items();
}
public function del_item_base($item=0,$forcage=array()) {
global $dbh;
if (!$item) return CADDIE_ITEM_NULL ;
switch ($this->type) {
case "EXPL" :
if (!$this->verif_expl_item($item)) {
if ($forcage['source_id']) {
exemplaire::save_to_agnostic_warehouse(array(0=>$item),$forcage['source_id']);
}
if (exemplaire::del_expl($item)) {
return CADDIE_ITEM_SUPPR_BASE_OK ;
} else {
return 0 ;
}
} else return CADDIE_ITEM_EXPL_PRET ;
break ;
case "BULL" :
if (!$this->verif_bull_item($item,$forcage)) {
// aucun prêt d'exemplaire de ce bulletin en cours, on supprime :
$myBulletinage = new bulletinage($item);
$myBulletinage->delete();
return CADDIE_ITEM_SUPPR_BASE_OK ;
} else return CADDIE_ITEM_BULL_USED ;
break ;
case "NOTI" :
if (!$this->verif_noti_item($item,$forcage)) {
if ($forcage['source_id']) {
notice::save_to_agnostic_warehouse(array(0=>$item),$forcage['source_id']);
}
$requete="SELECT niveau_biblio, niveau_hierar FROM notices WHERE notice_id='".$item."'";
$res=pmb_mysql_query($requete, $dbh);
if(pmb_mysql_num_rows($res) && (pmb_mysql_result($res,0,0) == "s") && (pmb_mysql_result($res,0,1) == "1")){
$myBulletinage = new serial($item);
$myBulletinage->serial_delete();
}else{
notice::del_notice($item);
}
return CADDIE_ITEM_SUPPR_BASE_OK ;
} else return CADDIE_ITEM_NOTI_USED ;
break ;
}
return CADDIE_ITEM_OK ;
}
// suppression d'un item de tous les caddies du même type le contenant
public function del_item_all_caddies($item, $type) {
global $dbh;
$requete = "select idcaddie FROM caddie where type='".$type."' ";
$result = pmb_mysql_query($requete, $dbh);
for($i=0;$icompte_items();
}
public function del_item_no_flag($inconnu_aussi=1) {
global $dbh;
$requete = "delete FROM caddie_content where caddie_id='".$this->idcaddie."' and (flag is null or flag='') ";
if (!$inconnu_aussi) $requete .= " and (content is null or content='') ";
$result = @pmb_mysql_query($requete, $dbh);
$this->compte_items();
}
// Export des documents numérique d'un item
public function export_doc_num($item=0,$chemin) {
global $dbh, $charset, $msg;
$pattern_nom_fichier_doc_num="!!explnumid!!_!!idnotice!!_!!idbulletin!!_!!indicedocnum!!_!!nomdoc!!";
if ($this->type=="NOTI") {
$requete = "select explnum_id, explnum_notice as numnotice, explnum_bulletin, explnum_data, explnum_extfichier, explnum_nomfichier, length(explnum_data) as taille ";
$requete .= " FROM explnum WHERE ";
$requete .= " explnum_notice=$item ";
} elseif ($this->type=="BULL") {
$requete = "select explnum_id, bulletin_notice as numnotice, explnum_bulletin, explnum_data, explnum_extfichier, explnum_nomfichier, length(explnum_data) as taille ";
$requete .= " FROM explnum JOIN bulletins on bulletin_id=explnum_bulletin WHERE ";
$requete .= " explnum_bulletin=$item ";
} else return; // pas encore de document numérique attaché à un exemplaire
$requete .= " and ((explnum_data is not null and explnum_data!='') OR (explnum_nomfichier is not null and explnum_nomfichier!=''))";
$result = pmb_mysql_query($requete, $dbh) or die(pmb_mysql_error()." $requete");
for($i=0;$iexplnum_id = str_pad ($t->explnum_id, 6, "0", STR_PAD_LEFT) ;
$t->numnotice = str_pad ($t->numnotice, 6, "0", STR_PAD_LEFT) ;
$t->explnum_bulletin = str_pad ($t->explnum_bulletin, 6, "0", STR_PAD_LEFT) ;
$nomfic= $pattern_nom_fichier_doc_num;
$nomfic = str_replace("!!explnumid!!", str_pad ($t->explnum_id, 6, "0", STR_PAD_LEFT), $nomfic) ;
$nomfic = str_replace("!!idnotice!!", str_pad ($t->numnotice, 6, "0", STR_PAD_LEFT), $nomfic) ;
$nomfic = str_replace("!!idbulletin!!", str_pad ($t->explnum_bulletin, 6, "0", STR_PAD_LEFT), $nomfic) ;
$nomfic = str_replace("!!indicedocnum!!", str_pad ($i, 3, "0", STR_PAD_LEFT), $nomfic) ;
$nomfic = str_replace("!!nomdoc!!", $t->explnum_nomfichier, $nomfic) ;
$hf = fopen($chemin.$nomfic, "w");
if ($hf) {
$explnum = new explnum($t->explnum_id);
fwrite($hf, $explnum->get_file_content());
fclose($hf);
$ret = "
";
print $cb_display;
}
} // fin de liste
print $end_result_liste;
} // fin si BULL
}
print " ".$nav_bar ;
return;
}
public function aff_cart_titre() {
global $msg;
$link = "./catalog.php?categ=search&mode=3&object_type=".$this->type."&idcaddie=".$this->get_idcaddie()."&item=";
return "
",$form);
return $form;
}
public function reindex_object($object) {
if ($this->type=='NOTI'){
// Mise à jour de tous les index de la notice
notice::majNoticesTotal($object);
}elseif($this->type=='BULL'){
$requete="SELECT bulletin_titre, num_notice FROM bulletins WHERE bulletin_id='".$object."'";
$res=pmb_mysql_query($requete);
if(pmb_mysql_num_rows($res)){
$element=pmb_mysql_fetch_object($res);
if(trim($element->bulletin_titre)){
$requete="UPDATE bulletins SET index_titre=' ".addslashes(strip_empty_words($element->bulletin_titre))." ' WHERE bulletin_id='".$object."'";
pmb_mysql_query($requete);
}
if($element->num_notice){
notice::majNoticesTotal($element->num_notice);
}
}
}elseif($this->type=='EXPL'){
$requete="SELECT expl_notice, expl_bulletin FROM exemplaires WHERE expl_id='".$object."' ";
$res=pmb_mysql_query($requete);
if(pmb_mysql_num_rows($res)){
$row=pmb_mysql_fetch_object($res);
if($row->expl_notice){
notice::majNoticesTotal($row->expl_notice);
}else{
$requete="SELECT bulletin_titre, num_notice FROM bulletins WHERE bulletin_id='".$row->expl_bulletin."'";
$res2=pmb_mysql_query($requete);
if(pmb_mysql_num_rows($res2)){
$element=pmb_mysql_fetch_object($res2);
if(trim($element->bulletin_titre)){
$requete="UPDATE bulletins SET index_titre=' ".addslashes(strip_empty_words($element->bulletin_titre))." ' WHERE bulletin_id='".$row->expl_bulletin."'";
pmb_mysql_query($requete);
}
if($element->num_notice){
notice::majNoticesTotal($element->num_notice);
}
}
}
}
}
}
public function del_items_base_from_list($liste=array()) {
global $supp_notice_linked;
global $supp_notice_linked_expl_num;
global $source_id;
global $supp_notice_perio_abo;
global $supp_notice_perio_collstat;
global $supp_notice_perio_modele;
global $supp_bulletin_linked_expl_num;
global $supp_notice_linked_cascade;
global $url_base;
// le formulaire demande de supprimer les notices meme avec liens
$forcage = array();
if($supp_notice_linked) $forcage['notice_linked']=1; else $forcage['notice_linked']=0;
if($supp_notice_linked_expl_num) $forcage['notice_linked_expl_num']=1; else $forcage['notice_linked_expl_num']=0;
if($source_id) $forcage['source_id']=$source_id; else $forcage['source_id']=0;
if($supp_notice_perio_abo) $forcage['notice_perio_abo']=1; else $forcage['notice_perio_abo']=0;
if($supp_notice_perio_collstat) $forcage['notice_perio_collstat']=1; else $forcage['notice_perio_collstat']=0;
if($supp_notice_perio_modele) $forcage['notice_perio_modele']=1; else $forcage['notice_perio_modele']=0;
if($supp_bulletin_linked_expl_num) $forcage['bulletin_linked_expl_num']=1; else $forcage['bulletin_linked_expl_num']=0;
$res_aff_suppr_base = '';
foreach ($liste as $cle => $object) {
// le formulaire demande de suprimmer toutes les notices liées à celle-ci
if($supp_notice_linked_cascade) {
$forcage['notice_linked']=1;
$liste_linked=notice::get_list_child($object);
foreach($liste_linked as $object) {
if ($this->del_item_base($object,$forcage)==CADDIE_ITEM_SUPPR_BASE_OK)
$this->del_item_all_caddies ($object, $this->type) ;
else {
$res_aff_suppr_base .= aff_cart_unique_object ($object, $this->type, $url_base="./catalog.php?categ=caddie&sub=gestion&quoi=panier&idcaddie=".$this->idcaddie) ;
}
}
} else {
if ($this->del_item_base($object,$forcage)==CADDIE_ITEM_SUPPR_BASE_OK) $this->del_item_all_caddies ($object, $this->type) ;
else {
$res_aff_suppr_base .= aff_cart_unique_object ($object, $this->type, $url_base="./catalog.php?categ=caddie&sub=gestion&quoi=panier&idcaddie=".$this->idcaddie) ;
}
}
}
return $res_aff_suppr_base;
}
protected function write_content_tableau() {
global $elt_flag, $elt_no_flag, $notice_tpl;
afftab_cart_objects ($this->idcaddie, $elt_flag , $elt_no_flag, $notice_tpl );
}
protected function get_display_content_tableauhtml() {
global $elt_flag, $elt_no_flag, $notice_tpl;
afftab_cart_objects ($this->idcaddie, $elt_flag , $elt_no_flag, $notice_tpl ) ;
}
public function get_export_iframe($param_exp='') {
export_param::init_session();
$param_exp=new export_param(EXP_SESSION_CONTEXT);
return parent::get_export_iframe($param_exp);
}
public function get_idcaddie() {
return $this->idcaddie;
}
public function get_id() {
return $this->idcaddie;
}
public function set_idcaddie($idcaddie) {
$this->idcaddie = intval($idcaddie);
}
} // fin de déclaration de la classe caddie