Skip to content
Snippets Groups Projects
Commit f9af2f1e authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #16358 : RT small code formatting

parent 82a74e13
Branches
Tags
4 merge requests!529Hotline 6.56,!425Dev#16320 loire forez skin,!421Hotline 6.52,!416Hotline 16358 fix update notice cosmogramme
......@@ -26,6 +26,9 @@ require_once("classe_codif_matiere.php");
require_once("classe_codif_langue.php");
class notice_integration {
const RECORD_RENEW = 5;
const RECORD_UPDATE = 4;
private $id_profil; // Id du profil de données initialisé
private $format; // Format de fichier 0=unimarc
private $id_article_periodique; // Mode d'indentification des articles de periodiques
......@@ -231,48 +234,46 @@ class notice_integration {
protected function updateNoticeFromCodeBarres($id_notice) {
// Lecture identifiants de la notice de la base
$new_id_notice=0;
$enreg = Class_Notice::find($id_notice)->toArray();
if ($this->notice["isbn10"]
and $this->notice["isbn10"] != $enreg["isbn"]
and $this->notice["isbn13"] != $enreg["isbn"]) {
$new_id_notice=$this->identification["isbn"];
if(!$new_id_notice) $new_id_notice="creation";
}
$new_id_notice = 0;
$enreg = Class_Notice::find($id_notice)->toArray();
if ($this->notice["isbn10"]
and $this->notice["isbn10"] != $enreg["isbn"]
and $this->notice["isbn13"] != $enreg["isbn"]) {
$new_id_notice = $this->identification["isbn"];
if (!$new_id_notice)
$new_id_notice = 'creation';
}
if(!$new_id_notice
and $this->notice["ean"]
and $this->notice["ean"] != $enreg["ean"]) {
$new_id_notice=$this->identification["ean"];
if(!$new_id_notice) $new_id_notice="creation";
}
if(!$new_id_notice
and $this->notice["ean"]
and $this->notice["ean"] != $enreg["ean"]) {
$new_id_notice = $this->identification["ean"];
if (!$new_id_notice)
$new_id_notice = 'creation';
}
// if(!$new_id_notice and !$ean and $this->notice["id_commerciale"] != $enreg["id_commerciale"])
// {
// $new_id_notice=$this->identification["id_commerciale"];
// if(!$new_id_notice) $new_id_notice="creation";
// }
if ($new_id_notice) {
if ($new_id_notice == "creation") {
$this->notice["qualite"]=$this->qualite_bib;
$new_id_notice = $this->insertNotice();
if (!$new_id_notice) return;
} else {
$this->updateNotice($new_id_notice,$this->qualite_bib);
}
if ($new_id_notice) {
if ($new_id_notice == "creation") {
$this->notice["qualite"]=$this->qualite_bib;
$new_id_notice = $this->insertNotice();
if (!$new_id_notice)
return;
} else {
$this->updateNotice($new_id_notice, $this->qualite_bib);
}
// on supprime les exemplaires de l'ancienne notice
for($i=0; $i<count($this->notice["exemplaires"]); $i++) {
$ex=$this->notice["exemplaires"][$i];
Class_Exemplaire::deleteBy(['id_bib' => $id_bib,
'id_notice' => $id_notice,
'code_barres' => $ex["code_barres"]]);
}
return $new_id_notice;
}
return $this->updateNotice($id_notice,$this->qualite_bib);
// on supprime les exemplaires de l'ancienne notice
for($i=0; $i<count($this->notice["exemplaires"]); $i++) {
$ex = $this->notice["exemplaires"][$i];
Class_Exemplaire::deleteBy(['id_bib' => $id_bib,
'id_notice' => $id_notice,
'code_barres' => $ex["code_barres"]]);
}
return $new_id_notice;
}
return $this->updateNotice($id_notice, $this->qualite_bib);
}
......@@ -612,7 +613,6 @@ class notice_integration {
private function updateNotice($id_notice, $qualite) {
global $sql;
$notice_enreg = Class_Notice::find($id_notice)->toArray();
$this->notice["qualite"] = $notice_enreg['qualite'];
$unimarc=$notice_enreg['unimarc'];
......@@ -621,14 +621,14 @@ class notice_integration {
// Test qualite
if ($qualite >= $this->notice["qualite"]) {
$this->notice["qualite"] = $qualite;
$this->statut = 5;
$this->statut = static::RECORD_RENEW;
} else {
$this->statut=4;
$this->statut = static::RECORD_UPDATE;
}
// Si la notice n'a pas de titre on substitue par celle de la base en forcant a une qualite inferieure
if( !$this->notice["titre_princ"])
$this->statut=4;
if (!$this->notice['titre_princ'])
$this->statut = static::RECORD_UPDATE;
// Zones forcees
$this->notice_sgbd->ouvrirNotice($unimarc, 0);
......@@ -641,7 +641,7 @@ class notice_integration {
$warnings = $this->notice["warnings"];
// Si la notice de la base est de meilleure qualite on la prend
if ($this->statut==5)
if ($this->statut == static::RECORD_RENEW)
$this->notice_sgbd->ouvrirNotice($this->notice["unimarc"],0);
$this->updateForcedZones($champs_forces, $this->notice["champs_forces"]);
......@@ -652,12 +652,14 @@ class notice_integration {
$this->notice["qualite"] = $qualite;
$this->notice["id_origine"] = $id_origine;
if($this->statut == 4)
if ($this->statut == static::RECORD_UPDATE)
return $id_notice;
$this->traiteFacettes();
Class_Notice::find($id_notice)->updateAttributes($this->noticeToDBEnreg())->save();
Class_Notice::find($id_notice)
->updateAttributes($this->noticeToDBEnreg())
->save();
return $id_notice;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment