diff --git a/VERSIONS_HOTLINE/37288 b/VERSIONS_HOTLINE/37288 new file mode 100644 index 0000000000000000000000000000000000000000..54f149ec3de32e0fc0a31e79ca1a074116394392 --- /dev/null +++ b/VERSIONS_HOTLINE/37288 @@ -0,0 +1 @@ + - ticket #37288 : Correction de la localisation des exemplaires \ No newline at end of file diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index 618854ad9b72a58672fe5373b44d6e7bb08edb72..1486ef51fe4ac1c33ee7322542019af8292f6137 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -80,9 +80,9 @@ class Class_Exemplaire extends Storm_Model_Abstract { public function getBestCote() { - if($this->_sigb_exemplaire && - ($sigb_cote = $this->_sigb_exemplaire->getCote()) && - (strlen($sigb_cote) > strlen($this->getCote()))) + if ($this->getSigbExemplaire() && + ($sigb_cote = $this->getSigbExemplaire()->getCote()) && + (strlen($sigb_cote) > strlen($this->getCote()))) return $sigb_cote; return $this->getCote(); diff --git a/library/Class/Localisation.php b/library/Class/Localisation.php index e6ef278ee1ece6f1d67815d466503dd3e4e875e8..7afe7020da660c1e22ad770f5355d5035c8ae756 100644 --- a/library/Class/Localisation.php +++ b/library/Class/Localisation.php @@ -232,12 +232,15 @@ class Class_Localisation extends Storm_Model_Abstract { $quality = count(array_intersect_assoc($matching_datas, $exemplaire_datas)); + if ($quality < count($matching_datas) && $quality < (count($exemplaire_datas))) + return null; + if( 0 > ($cote_quality = $this->coteMatchingQuality($exemplaire))) return null; $quality += $cote_quality; - return [$quality => $this]; + return ($quality > 0) ? [$quality => $this] : null; } diff --git a/tests/library/Class/LocalisationTest.php b/tests/library/Class/LocalisationTest.php index 261a037d12322a44e90be943fa87458183065585..ef9eabc9c23d3672d8d6cc66763464da9b81cbb6 100644 --- a/tests/library/Class/LocalisationTest.php +++ b/tests/library/Class/LocalisationTest.php @@ -87,6 +87,17 @@ class LocalisationTest extends Storm_Test_ModelTestCase { 'libelle' => 'CD Jazz', 'cote_debut' => 'CDJazz A', 'cote_fin' => 'CDJazz Z']); + + $this->fixture('Class_Localisation', + ['id' => 22, + 'id_bib' => 1, + 'annexe' => 1, + 'section' => 'J', + 'genre' => 'B', + 'libelle' => 'CD Jazz Broken', + 'cote_debut' => 'CDJazz A', + 'cote_fin' => 'CDJazz Z', + 'type_doc' => 2]); }