liste_sugg = $tableau_sugg;
}
/**
* Formulaire de saisie des suggestions multiples
*/
public function display_form(){
global $dbh, $multi_sug_form,$charset, $msg, $sug_src;
$ligne = '';
//On charge la liste des sources
$req = "select * from suggestions_source order by libelle_source";
$res= pmb_mysql_query($req,$dbh);
$option = "";
while(($src=pmb_mysql_fetch_object($res))){
$option .= "";
}
if(!$this->liste_sugg){
$nb_lignes=1;
$multi_sug_form = str_replace('!!max_ligne!!',$nb_lignes,$multi_sug_form);
$ligne = "
|
|
|
|
|
|
|
|
|
|
|
";
} else {
$liste = $this->liste_sugg;
$this->ori_unimarc = microtime()."_unimulti";
for($i=0;$i $row["loc_libelle"], "visible" => $row["loc_visible"]);
}
//Traitement de la notice uni
$uni = new suggestions_unimarc();
$uni->entrepot_to_unimarc($id_noti);
$uni->sugg_uni_num_notice = $id_noti;
$uni->sugg_uni_origine = $this->ori_unimarc;
$uni->save();
$aff = new notice_affichage_unimarc($id_noti,'', 0,0, $entrepots_localisations);
$aff->fetch_data();
$titre = $aff->notice->tit1;
$auteur = ($aff->auteurs_principaux ? $aff->auteurs_principaux : $aff->auteurs_tous);
$editeur =$aff->publishers[0]["name"];
$code = $aff->code;
$prix =$aff->prix;
$date=$aff->year;
$url=($aff->notice->lien ? $aff->notice->lien : ($aff->notice->eformat ? $aff->notice->eformat :($aff->notice->lien_texte ? $aff->notice->lien_texte : '')));
$ext=true;
} else{
$requete = "SELECT tit1 as titre, ed_name as editeur, CONCAT(author_name,' ',author_rejete) as auteur, prix, code, lien, year
FROM notices LEFT JOIN responsability ON responsability_notice=notice_id
LEFT JOIN authors ON responsability_author=author_id LEFT JOIN publishers ON ed1_id=ed_id
WHERE notice_id=".$liste[$i];
$result = pmb_mysql_query($requete,$dbh);
$sug = pmb_mysql_fetch_object($result);
$titre = $sug->titre;
$auteur = $sug->auteur;
$editeur =$sug->editeur;
$code = $sug->code;
$prix =$sug->prix;
$date =$sug->year;
$url = $sug->lien;
$notice_id = $liste[$i];
}
$ligne .= "
|
|
|
|
|
|
|
|
|
| ";
if($i==count($liste)-1){
$ligne .= " | ";
} else {
$ligne .= " | ";
}
if($ext) $ligne .= " ";
if($notice_id) $ligne .= " ";
$ligne .= "
";
}
$multi_sug_form = str_replace('!!max_ligne!!',$i,$multi_sug_form);
}
$multi_sug_form = str_replace('!!ligne!!',$ligne,$multi_sug_form);
$multi_sug_form = str_replace('!!from_cart!!',$this->from_cart,$multi_sug_form);
$multi_sug_form.= "";
return $multi_sug_form;
}
/*
* Enregistrement d'une suggestion multiple
*/
public function save(){
global $dbh, $max_nblignes, $msg, $id_empr, $empr_location, $num_categ;
for($i=0;$i<$max_nblignes;$i++){
$tit = "sugg_tit_".$i; $aut = "sugg_aut_".$i; $edi = "sugg_edi_".$i;
$code = "sugg_code_".$i; $prix = "sugg_prix_".$i; $com = "sugg_com_".$i;
$url = "sugg_url_".$i; $qte = "sugg_qte_".$i; $src = "sugg_src_".$i;
$date = "sugg_date_".$i; $unimarc = "id_unimarc_".$i; $notice = "id_notice_".$i;
global $sug_tr, ${$tit}, ${$aut}, ${$edi}, ${$code}, ${$com}, ${$prix}, ${$url}, ${$qte}, ${$src}, ${$date}, ${$unimarc}, ${$notice};
if(isset(${$tit})){
if(!is_numeric(${$qte})){
print "".$msg['empr_sugg_qte_error']."";
return;
} else if(!${$tit} || (!${$edi} && !${$aut} && !${$code})) {
print "".str_replace('\n','
',$msg['empr_sugg_ko'])."";
return;
} else if(!suggestions::exists($id_empr,${$tit},${$aut},${$edi},${$code})) {
${$prix} = str_replace(',','.',${$prix});
$req="insert into suggestions set
titre='".${$tit}."',
auteur='".${$aut}."',
editeur='".${$edi}."',
code='".${$code}."',
prix='".${$prix}."',
commentaires='".${$com}."',
url_suggestion='".${$url}."',
nb='".${$qte}."',
sugg_source='".${$src}."',
statut=1,
date_publication='".${$date}."',
date_creation='".date("Y-m-d")."',
sugg_location='".$empr_location."',
num_categ='".$num_categ."'
";
if(${$unimarc}){
$uni = new suggestions_unimarc(${$unimarc});
$req .= ", notice_unimarc ='".addslashes($uni->sugg_uni_notice)."'";
}
if(${$notice}){
$req .= ", num_notice ='".${$notice}."'";
}
pmb_mysql_query($req,$dbh);
$idSugg = pmb_mysql_insert_id();
if (isset($uni) && is_object($uni)) $uni->delete();
$sug_orig = new suggestions_origine($id_empr, $idSugg);
$sug_orig->type_origine = 1;
$sug_orig->save();
//Envoi mail
$su = new suggestions($idSugg);
suggestions::alert_mail_sugg_users_pmb(1, $id_empr, $su->get_table(), $su->sugg_location) ;
//On retire la notice du panier ?
$this->delete_cart_record(${$notice});
print $msg['empr_sugg_ok'] . ' : ' . stripslashes(${$tit}) . '
';
} else {
print $msg['empr_sugg_already_exist'] . ' : ' . stripslashes(${$tit}) . '
';
}
}
}
}
public function delete_cart_record($notice_id) {
global $opac_cart_records_remove, $from_cart;
if(!$this->from_cart && !empty($from_cart)) {
$this->from_cart = $from_cart;
}
if($opac_cart_records_remove && $this->from_cart) {
$as=array_search($notice_id,$_SESSION["cart"]);
if (($as!==null)&&($as!==false)) {
unset($_SESSION["cart"][$as]);
}
}
}
}
?>