Skip to content
Snippets Groups Projects

Hotline 16358 fix update notice cosmogramme

Closed Ghislain Loas requested to merge hotline_16358_fix_update_notice_cosmogramme into hotline_6.52
Compare and
+ 307
122
Preferences
Compare changes
Files
@@ -69,11 +69,9 @@ class notice_integration {
$this->id_bib=$this->id_int_bib=$id_bib;
$this->type_operation=$type_operation;
$this->type_doc_force=$type_doc_force;
$bib=$sql->fetchEnreg("select * from int_bib where id_bib=$id_bib");
$this->qualite_bib=$bib["qualite"];
$this->sigb=$bib["sigb"];
$this->id_profil=$id_profil;
if($id_profil < 0)$format=1; // Paniers d'homogeneisation
else
@@ -141,7 +139,6 @@ class notice_integration {
// Chercher la notice dans la base
$id_notice=$this->chercheNotice();
// Traiter le type d'operation : suppressions
if($this->type_operation == 1)
{
@@ -161,6 +158,7 @@ class notice_integration {
// suppression ou creation des articles si périodique
if($this->notice["type_doc"]==2)
{
// Periodiques Koha et orphee (1 exemplaire pour chaque numéro)
if(($this->id_article_periodique==3 or $this->id_article_periodique==4) and $this->flag_koha==false)
{
@@ -204,7 +202,6 @@ class notice_integration {
}
}
}
// Mise a jour
if(!$id_notice) {
$this->notice["qualite"]=$this->qualite_bib;
@@ -213,11 +210,29 @@ class notice_integration {
else $this->statut=1;
} else {
// Controle des identifiants pour dedoublonnage eventuel
if ($this->identification["statut"] == "code_barres") {
// Lecture identifiants de la notice de la base
$this->updateNoticeWithId($id_notice);
}
$this->ecrireExemplaires($id_notice);
return $this->notice;
}
protected function updateNoticeWithId($id_notice) {
if ($this->identification["statut"] == "code_barres")
return $this->updateNoticeFromCodeBarres($id_notice);
if(($this->identification["statut"] == "clef_alpha") && $this->flag_koha)
return $id_notice;
return $this->updateNotice($id_notice,$this->qualite_bib);
}
protected function updateNoticeFromCodeBarres($id_notice) {
// Lecture identifiants de la notice de la base
$new_id_notice=0;
$enreg = $sql->fetchEnreg("Select isbn,ean,id_commerciale from notices where id_notice=$id_notice");
$enreg = Class_Notice::find($id_notice)->toArray();
if ($this->notice["isbn10"]
and $this->notice["isbn10"] != $enreg["isbn"]
@@ -251,19 +266,17 @@ class notice_integration {
// on supprime les exemplaires de l'ancienne notice
for($i=0; $i<count($this->notice["exemplaires"]); $i++) {
$ex=$this->notice["exemplaires"][$i];
$sql->execute("delete from exemplaires where id_bib=$id_bib and id_notice=$id_notice and code_barres='".$ex["code_barres"]."'");
Class_Exemplaire::deleteBy(['id_bib' => $id_bib,
'id_notice' => $id_notice,
'code_barres' => $ex["code_barres"]]);
}
$id_notice=$new_id_notice;
return $new_id_notice;
}
else $id_notice=$this->updateNotice($id_notice,$this->qualite_bib);
}
else $id_notice=$this->updateNotice($id_notice,$this->qualite_bib);
}
$this->ecrireExemplaires($id_notice);
return $this->notice;
return $this->updateNotice($id_notice,$this->qualite_bib);
}
public function traiteHomogene($id_notice, $isbn, $ean, $id_commerciale, $no_request) {
global $sql;
// Appel du service
@@ -452,8 +465,8 @@ class notice_integration {
private function chercheNotice() {
global $sql;
$id_bib = $this->id_bib;
if(!$this->mode_doublon) {
$isbn10=$this->notice["isbn10"];
$isbn13=$this->notice["isbn13"];
@@ -566,7 +579,7 @@ class notice_integration {
public function noticeToDBEnreg() {
return [
"type_doc" => $this->notice["type_doc"],
"alpha_titre" => $this->notice["alpha_titre"],
"alpha_titre" => $this->notice["alpha_titre"],
"alpha_auteur" => $this->notice["alpha_auteur"],
"titres" => $this->indexation->getfullText(array_merge($this->notice["titres"],
@@ -593,15 +606,14 @@ class notice_integration {
"qualite" => $this->notice["qualite"],
"exportable" => $this->notice["exportable"],
"cote" => $this->notice["cote"],
"unimarc" => $this->notice["unimarc"],
"unimarc" => $this->notice["unimarc"],
"date_maj" => dateDuJour(2) ];
}
private function updateNotice($id_notice, $qualite) {
global $sql;
$notice_enreg = $sql->fetchEnreg("select qualite,unimarc,facettes from notices where id_notice=$id_notice");
$notice_enreg = Class_Notice::find($id_notice)->toArray();
$this->notice["qualite"] = $notice_enreg['qualite'];
$unimarc=$notice_enreg['unimarc'];
$this->notice["facette"] = $notice_enreg['facettes'];
@@ -633,7 +645,6 @@ class notice_integration {
$this->notice_sgbd->ouvrirNotice($this->notice["unimarc"],0);
$this->updateForcedZones($champs_forces, $this->notice["champs_forces"]);
$this->notice = $this->notice_sgbd->getNoticeIntegration();
$this->notice["statut_exemplaires"] = $statut_exemplaires;
$this->notice["exemplaires"] = $exemplaires;
@@ -646,9 +657,7 @@ class notice_integration {
$this->traiteFacettes();
// Qualité égale ou zones forcees : on update
$sql->update("update notices set @SET@ Where id_notice=$id_notice",
$this->noticeToDBEnreg($data));
Class_Notice::find($id_notice)->updateAttributes($this->noticeToDBEnreg())->save();
return $id_notice;
}
@@ -784,6 +793,8 @@ class notice_integration {
public function traiteFacettes() {
global $sql;
$facettes = [];
// Virer les facettes sauf les tags
$controle=explode(" ",$this->notice["facettes"]);
$this->notice["facettes"]="";
@@ -793,6 +804,12 @@ class notice_integration {
if($tp =="Z") $this->notice["facettes"].=" ".$controle[$i];
}
if($type_doc = $this->notice['infos_type_doc']) {
if($code_type_doc = $type_doc['code']){
$facettes[] = 'T'.$code_type_doc;
}
}
// Dewey
if($this->notice["dewey"])
{