Skip to content
Snippets Groups Projects

Hotline #22519

Closed Laurent requested to merge hotline_#22519 into master
Compare and
+ 232
72
Preferences
Compare changes
Files
@@ -30,6 +30,10 @@ class notice_integration {
const RECORD_RENEW = 5;
const RECORD_UPDATE = 4;
const STATUS_NOTFOUND = 'non trouvée';
const SEARCH_MODE_ALPHAKEY = 1;
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
@@ -236,6 +240,7 @@ class notice_integration {
public function traiteHomogene($id_notice, $isbn, $ean, $id_commerciale, $no_request) {
global $sql;
// Appel du service
$args["isbn"]=$isbn;
$args["ean"]= $ean;
@@ -247,13 +252,20 @@ class notice_integration {
$ret["timeout"]=10;
// Statut not found : Mise a jour nombre de retries
if($ret["statut_z3950"] == "1") $sql->execute("Update notices set z3950_retry = z3950_retry +1 Where id_notice=$id_notice");
if ($ret["statut_z3950"] == '1') {
$notice = Class_Notice::find($id_notice);
$retry = $notice->getZ3950Retry() + 1;
$notice->setZ3950Retry($retry)->save();
}
// Statut ok : on remplace la notice
if(!$this->analyseur) $this->analyseur=new notice_unimarc();
if($ret["statut_z3950"] > "1")
{
$this->analyseur->ouvrirNotice($ret["unimarc"],1);
$this->analyseur->ouvrirNotice($ret["unimarc"],
$args['isbn']
? profil_donnees::HOMOGENIZATION_ISBN
: profil_donnees::HOMOGENIZATION_EAN);
$this->notice=$this->analyseur->getNoticeIntegration();
$qualite=getVariable("homogene_code_qualite");
$this->updateNotice($id_notice,$qualite);
@@ -421,81 +433,70 @@ class notice_integration {
private function chercheNotice() {
global $sql;
$id_bib = $this->id_bib;
$attributes = [];
if(!$this->mode_doublon)
$attributes = [//'isbn10' => $this->notice['isbn10'],
//'isbn13' => $this->notice['isbn13'],
'isbn' => [$this->notice['isbn13'], $this->notice['isbn10']],
'ean' => $this->notice['ean'],
'id_commerciale' => $this->notice['id_commerciale']];
if(!$this->mode_doublon) {
$isbn10=$this->notice["isbn10"];
$isbn13=$this->notice["isbn13"];
$ean=$this->notice["ean"];
$id_commerciale=$this->notice["id_commerciale"];
}
$clef_alpha=$this->notice["clef_alpha"];
if ($this->mode_doublon == static::SEARCH_MODE_ALPHAKEY)
$attributes = ['clef_alpha' => $this->notice['clef_alpha']];
$this->identification=array("statut"=>"non trouvée");
if($this->notice["statut_exemplaires"]["nb_ex"]>0)
{
$unicite_codes_barres=getVariable("unicite_code_barres");
if($unicite_codes_barres=="1") $condition="";
else $condition='id_int_bib='.$this->id_int_bib.' and ';
foreach($this->notice["exemplaires"] as $ex)
{
$code_barres=$ex["code_barres"];
if($code_barres >"")$id_notice=$sql->fetchOne("select id_notice from exemplaires where ".$condition." code_barres='$code_barres'");
if($id_notice)
{
$this->identification["statut"]="code_barres";
$this->identification["code_barres"]=$id_notice;
break;
}
}
}
if($isbn10)
{
$this->identification["isbn"]=$sql->fetchOne("select id_notice from notices where isbn='$isbn10'");
if(!$id_notice and $this->identification["isbn"])
{
$this->identification["statut"]="isbn";
$id_notice=$this->identification["isbn"];
}
}
if($isbn13 and !$this->identification["isbn"])
{
$this->identification["isbn"]=$sql->fetchOne("select id_notice from notices where isbn='$isbn13'");
if(!$id_notice and $this->identification["isbn"])
{
$this->identification["statut"]="isbn";
$id_notice=$this->identification["isbn"];
}
}
if($ean)
{
$this->identification["ean"]=$sql->fetchOne("select id_notice from notices where ean='$ean'");
if(!$id_notice and $this->identification["ean"])
{
$this->identification["statut"]="ean";
$id_notice=$this->identification["ean"];
}
$this->identification = ['statut' => static::STATUS_NOTFOUND];
if ($id_notice = $this->searchRecordByItemsBarcodes()) {
$this->identification['statut'] = 'code_barres';
$this->identification['code_barres'] = $id_notice;
return $id_notice;
}
if($id_commerciale and !$ean)
{
$this->identification["id_commerciale"]=$sql->fetchOne("select id_notice from notices where id_commerciale='$id_commerciale'");
if(!$id_notice and $this->identification["id_commerciale"])
{
$this->identification["statut"]="id_commerciale";
$id_notice=$this->identification["id_commerciale"];
foreach ($attributes as $key => $value) {
if ($id_notice = $this->searchRecordBy($key, $value)) {
$this->identification['statut'] = $key;
$this->identification[$key] = $id_notice;
return $id_notice;
}
}
if($this->mode_doublon==1)
{
if (!$id_notice && $matching_notice = Class_Notice::findFirstBy(['clef_alpha' => $clef_alpha])) {
$this->identification["clef_alpha"] = $id_notice = $matching_notice->getId();
$this->identification["statut"]="clef_alpha";
}
return '';
}
private function searchRecordByItemsBarcodes() {
if ($this->notice['statut_exemplaires']['nb_ex'] <= 0)
return '';
$unicite_codes_barres = getVariable('unicite_code_barres');
$condition = [];
if ($unicite_codes_barres == '1')
$condition['id_int_bib'] = $this->id_int_bib;
foreach ($this->notice['exemplaires'] as $ex) {
if (!$ex['code_barres'] > '')
continue;
$condition['code_barres'] = $ex['code_barres'];
if ($exemplaire = Class_Exemplaire::findFirstBy($condition))
return $exemplaire->getIdNotice();
}
if(!$id_notice)$this->identification["statut"]="non trouvée";
return $id_notice;
return '';
}
private function searchRecordBy($key, $value) {
if (!$value)
return '';
if (!$notice = Class_Notice::findFirstBy([$key => $value]))
return '';
return $notice->getId();
}