Skip to content
Snippets Groups Projects
Commit 79b5cab8 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

#26993 refacto

parent bf9001c2
Branches
Tags
2 merge requests!1058Stable,!1051Hotline #26993 records nanook serials
......@@ -27,10 +27,16 @@ require_once("classe_codif_langue.php");
require_once("classe_profil_donnees.php");
class notice_integration {
const RECORD_RENEW = 5;
const RECORD_UPDATE = 4;
const STATUS_NOTFOUND = 'non trouvée';
const
RECORD_REJECT = 0,
RECORD_INSERT = 1,
RECORD_DELETE = 2,
RECORD_FULLUPDATE = 3,
RECORD_UPDATE = 4,
RECORD_RENEW = 5,
RECORD_UPGRADE = 6,
RECORD_SUCCINCT = 7,
STATUS_NOTFOUND = 'non trouvée';
private $id_profil; // Id du profil de données initialisé
private $format; // Format de fichier 0=unimarc
......@@ -45,7 +51,16 @@ class notice_integration {
private $qualite_bib; // Code qualite de la bib
private $sigb; // Sigb de la bib
private $statut; // Statut de la notice traitee
public $libStatut=array("Rejetées","Créée","Supprimée","Mise à jour notice et exemplaires","Mise à jour exemplaires","Remplacées","Homogénéisées","Mises en notices succintes");
public $libStatut = [self::RECORD_REJECT => "Rejetées",
self::RECORD_INSERT => "Créée",
self::RECORD_DELETE => "Supprimée",
self::RECORD_FULLUPDATE => "Mise à jour notice et exemplaires",
self::RECORD_UPDATE => "Mise à jour exemplaires",
self::RECORD_RENEW => "Remplacées",
self::RECORD_UPGRADE => "Homogénéisées",
self::RECORD_SUCCINCT =>"Mises en notices succintes"];
private $erreur; // Message d'erreur notice traitee
private $filtrer_fulltext; // Vient de la variable filtrer_fulltext.
private $identification; // Mode d'identification de la notice
......@@ -922,52 +937,34 @@ class notice_integration {
// --------------------------------------------------------------------------------
// Ecrit une notice : article de périodique
// --------------------------------------------------------------------------------
private function ecrireArticlePeriodique()
{
private function ecrireArticlePeriodique() {
global $sql;
// identifiants
$clef_chapeau=$this->notice["clef_chapeau"];
$clef_numero=$this->notice["clef_numero"];
$clef_article=$this->notice["clef_article"];
$clef_unimarc=$this->notice["clef_unimarc"];
if( 1 == $this->notice["statut"])
return $this->deleteRecordArticles();
// suppression
if($this->notice["statut"]==1)
{
$this->statut=2;
if($clef_unimarc)
$controle=$sql->execute("delete from notices_articles where clef_unimarc='$clef_unimarc'");
else
$controle=$sql->execute("delete from notices_articles where clef_chapeau='$clef_chapeau' and clef_numero='$clef_numero' and clef_article='$clef_article'" );
if(!$controle)
{
$this->statut=0;
$this->erreur="notice à supprimer non reconnue";
}
return;
}
$clef_chapeau = $this->notice["clef_chapeau"];
$clef_numero = $this->notice["clef_numero"];
$clef_article = $this->notice["clef_article"];
$clef_unimarc = $this->notice["clef_unimarc"];
$titre_principal = $this->notice['titre_princ'];
$clef_titre = hash('crc32b', $titre_principal);
// constitution enregistrement
$enreg["clef_chapeau"]=$clef_chapeau;
$enreg["clef_numero"]=$clef_numero;
$enreg["clef_chapeau"] = $clef_chapeau;
$enreg["clef_numero"] = $clef_numero;
$enreg["clef_unimarc"] = $clef_unimarc ? $clef_unimarc : $clef_titre;
$enreg["unimarc"]=$this->notice["unimarc"];
$enreg["date_maj"]=dateDuJour(0);
$enreg["qualite"]=$this->qualite_bib;
$enreg["unimarc"] = $this->notice["unimarc"];
$enreg["date_maj"] = dateDuJour(0);
$enreg["qualite"] = $this->qualite_bib;
$enreg["clef_article"] = $clef_article;
// cherche la notice
if($clef_unimarc) {
if ($article = Class_Notice_SerialArticles::findFirstBy(['clef_unimarc' => $clef_unimarc])) {
$enreg["clef_chapeau"] = $article->getClefChapeau();
$enreg["clef_numero"] = $article->getClefNumero();
}
}
else {
} else {
if(!$article = Class_Notice_SerialArticles::findFirstBy(['clef_chapeau' => $clef_chapeau,
'clef_numero' => $clef_numero,
'clef_unimarc' => $clef_titre]))
......@@ -977,23 +974,35 @@ class notice_integration {
'clef_unimarc' => '']);
}
// ecrire
if($article)
{
if($article) {
// remplacer si qualite superieure ou egale
if($enreg["qualite"] >= $article->getQualite()) {
$article->updateAttributes($enreg)->save();
$this->statut=5;
}
}
else
{
} else {
Class_Notice_SerialArticles::newInstance($enreg)->save();
Class_Notice_SerialArticles::clearCache();
$this->statut=1;
}
}
protected function deleteRecordArticles() {
$this->statut = self::RECORD_DELETE;
if($this->notice["clef_unimarc"])
$controle = $sql->execute("delete from notices_articles where clef_unimarc='$clef_unimarc'");
else
$controle = $sql->execute("delete from notices_articles where clef_chapeau='$clef_chapeau' and clef_numero='$clef_numero' and clef_article='$clef_article'" );
if(!$controle) {
$this->statut = 0;
$this->erreur = "notice à supprimer non reconnue";
}
}
// --------------------------------------------------------------------------------
// Recupere titre, auteurs, matieres pour 1 article de périodique
// --------------------------------------------------------------------------------
......
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