diff --git a/VERSIONS_HOTLINE/183239 b/VERSIONS_HOTLINE/183239 new file mode 100644 index 0000000000000000000000000000000000000000..5e9dcde1592d615d18532de3a874097ae83dde6b --- /dev/null +++ b/VERSIONS_HOTLINE/183239 @@ -0,0 +1 @@ + - correctif #183239 : Cosmogramme : L'import de notices avec des champs Date de Nouveauté multiples contenant parfois des chaines de caractères est maintenant correctement géré. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/183241 b/VERSIONS_HOTLINE/183241 new file mode 100644 index 0000000000000000000000000000000000000000..0dda6626ac87b6edaddd157d421c51a594efa4cd --- /dev/null +++ b/VERSIONS_HOTLINE/183241 @@ -0,0 +1 @@ + - correctif #183241 : Cosmogramme : La date de nouveauté calculée pour le format AAAAMMJJ prend maintenant en compte aussi le format AAMMJJ en ajoutant '20' en prefixe de l'année \ No newline at end of file diff --git a/cosmogramme/php/_accueil.php b/cosmogramme/php/_accueil.php index c899c8bc9a8c98207eec4046f3035ba26db20e7b..bf42d8885e251887b3612f8b129c141931bbe0d3 100644 --- a/cosmogramme/php/_accueil.php +++ b/cosmogramme/php/_accueil.php @@ -66,12 +66,10 @@ if($statut=="1") //--------------------------------------------------------------------------------- // Ecart entre traitements //--------------------------------------------------------------------------------- -$ecart=ecartDates(dateDuJour(0),$date_integration); +$ecart = Class_TimeSource::daysBetween(date('Y-m-d'),$date_integration); $frequence = (int)getVariable("integration_frequence"); -if($ecart > $frequence And $frequence > 0) -{ - afficherLigne(true,"Les traitements d'intégration n'ont pas été effectués depuis ".$ecart." jours</h3>"); -} +if($ecart && ($ecart > $frequence) && ($frequence > 0)) + afficherLigne(true,"Les traitements d'intégration n'ont pas été effectués depuis ".$ecart." jours</h3>"); //--------------------------------------------------------------------------------- // Nombre de fichiers en attente @@ -157,4 +155,4 @@ function afficherLigne($erreur, $texte) print('<h3' .$class.' style="margin-left:20px">» '.$texte.'</h3>'); } -?> \ No newline at end of file +?> diff --git a/cosmogramme/php/classes/classe_bib.php b/cosmogramme/php/classes/classe_bib.php index 538178c7c24d9f2617c5baee295a1e8daba87cec..44216d788f333b86bbb798d5e22787648a318450 100644 --- a/cosmogramme/php/classes/classe_bib.php +++ b/cosmogramme/php/classes/classe_bib.php @@ -49,34 +49,34 @@ class bibliotheque //--------------------------------------------------------------------------------- // Renvoie la liste des bibs qui ont un mail //--------------------------------------------------------------------------------- - public function getListeRetardIntegration() - { - global $sql; - $bibs=$sql->fetchAll("select * from int_bib where mail > '' and ecart_ajouts > 0 order by nom_court"); - foreach($bibs as $bib) - { - $ecart=ecartDates(dateDuJour(0),$bib["dernier_ajout"]); - if($ecart > $bib["ecart_ajouts"]) - { - if($bib["dernier_ajout"] == "0000-00-00") - { - $bib["dernier_ajout"]="aucune"; - $ecart="jamais intégré"; - } - else - { - $bib["dernier_ajout"]=rendDate($bib["dernier_ajout"],1); - if($ecart == 1) $ecart="1 jour"; - else $ecart.=" jours"; - } - $lig=$bib; - if(!$lig["date_mail"]) $lig["date_mail"]="jamais"; - $lig["retard"]=$ecart; - $ret[]=$lig; - } - } - return $ret; - } + public function getListeRetardIntegration() + { + global $sql; + $bibs=$sql->fetchAll("select * from int_bib where mail > '' and ecart_ajouts > 0 order by nom_court"); + foreach($bibs as $bib) + { + $ecart = Class_TimeSource::daysBetween(dateDuJour(0),$bib["dernier_ajout"]); + if($ecart && ($ecart > $bib["ecart_ajouts"])) + { + if($bib["dernier_ajout"] == "0000-00-00") + { + $bib["dernier_ajout"]="aucune"; + $ecart="jamais intégré"; + } + else + { + $bib["dernier_ajout"]=rendDate($bib["dernier_ajout"],1); + if($ecart == 1) $ecart="1 jour"; + else $ecart.=" jours"; + } + $lig=$bib; + if(!$lig["date_mail"]) $lig["date_mail"]="jamais"; + $lig["retard"]=$ecart; + $ret[]=$lig; + } + } + return $ret; + } //--------------------------------------------------------------------------------- // Rend une combo avec les noms courts diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index 234a4161a0a2dada9050f4c31b327ffe7f7bb895..d4ed6440060fb0bd0eb64f6cc8c6c9081df7e225 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -568,9 +568,16 @@ class notice_unimarc extends iso2709_record { if (isset($champs_nouveaute['zone']) && $champs_nouveaute['zone'] != '995' && $champs_nouveaute['zone'] > '000') { - $data = $this->get_subfield($champs_nouveaute['zone'], $champs_nouveaute['champ']); - if ($data[0] > '') - $date_nouveaute = $this->calculDateNouveaute($data[0]); + $data = array_filter($this->get_subfield($champs_nouveaute['zone'], $champs_nouveaute['champ']), + fn($value) => ($champs_nouveaute['valeurs'] + || in_array($champs_nouveaute['format'], + [Class_IntProfilDonnees::NOVELTY_DATE_FORMAT_NONE, + Class_IntProfilDonnees::NOVELTY_DATE_FORMAT_VALUES]) + || preg_match('/^[0-9\/-]+$/',trim($value))) + ); + $date_nouveaute = is_array($data) + ? $this->calculDateNouveaute(reset($data)) + : ''; } $ret = ['warnings' => []]; @@ -620,18 +627,16 @@ class notice_unimarc extends iso2709_record { if (isset($champs_nouveaute['zone']) && isset($champs_nouveaute['champ']) && $champs_nouveaute['zone'] == $item_zone - && $champ['code'] == $champs_nouveaute['champ']) { + && $champ['code'] == $champs_nouveaute['champ']) $ex['date_nouveaute'] = $this->calculDateNouveaute($champ['valeur']); - } - if ($champ_availability and $champ['code'] == $champ_availability) { + if ($champ_availability && ($champ['code'] == $champ_availability)) $ex['is_available'] = ('1' === $champ['valeur']); - } }); if (isset($ex['code_barres']) && ($ex['code_barres'] > '')) { $nb_ex++; - if ($date_nouveaute > '' && (!$ex['date_nouveaute'])) + if ($date_nouveaute > '' && (!isset($ex['date_nouveaute']))) $ex['date_nouveaute'] = $date_nouveaute; if(isset($ex['ignore_exemplaire']) @@ -1208,35 +1213,33 @@ class notice_unimarc extends iso2709_record { } - public function calculDateNouveaute($valeur) { + public function calculDateNouveaute( string $valeur) :string { $valeur = trim($valeur); if (!$valeur) - return '2000-01-01'; + return ''; - $params = $this->profil['attributs'][4]; + $params = $this->profil['attributs'][Class_IntProfilDonnees::FIELD_RECORDISNEW]; if (!$date = $this->_getDateWithFormat($params['format'], $valeur)) return '2000-01-01'; - return ajouterJours($date, $params['jours']); + return Class_TimeSource::addDays($date, (int) $params['jours']); } protected function _getDateWithFormat($format, $value) { - $format = $this->profil['attributs'][4]['format']; - $valeurs = $this->profil['attributs'][4]['valeurs']; + $format = $this->profil['attributs'][Class_IntProfilDonnees::FIELD_RECORDISNEW]['format']; + $valeurs = $this->profil['attributs'][Class_IntProfilDonnees::FIELD_RECORDISNEW]['valeurs']; $mappings = [ - '1' => function($value) {return substr($value, 0, 10);}, - '2' => function($value) {return substr($value, 0, 4) . '-' - . substr($value, 4, 2) . '-' - . substr($value, 6, 2);}, - '4' => function($value) {return rendDate($value, 0);}, - '5' => function($value) {return rendDate($value, 0);}, - '3' => function($value) use ($valeurs) { - $compare = ';' . $valeurs . ';'; - if(strpos($compare, ';' . $value . ';') !== false) - return '2030-12-31'; - },]; + '1' => fn($value) => Class_TimeSource::tryFormatDate($value), + '2' => fn($value) => Class_TimeSource::tryFormatDate($value), + '4' => fn($value) => Class_TimeSource::tryFormatDate($value), + '5' => fn($value) => Class_TimeSource::tryFormatDate($value), + '3' => function($value) use ($valeurs) { + $compare = ';' . $valeurs . ';'; + if(strpos($compare, ';' . $value . ';') !== false) + return '2030-12-31'; + },]; if (array_key_exists($format, $mappings)) return $mappings[$format]($value); diff --git a/cosmogramme/php/fonctions/date_heure.php b/cosmogramme/php/fonctions/date_heure.php index eea5123893a446ee1e3d05f06072b0167c3335e8..9cc404f97a72265dc80e048bab742be6c8f255cb 100644 --- a/cosmogramme/php/fonctions/date_heure.php +++ b/cosmogramme/php/fonctions/date_heure.php @@ -51,7 +51,7 @@ function rendDate($date, $format) if(strlen($jour)==1) $jour2="0".$jour; else $jour2=$jour; if(strlen($mois)==1) $mois2="0".$mois; else $mois2=$mois; $dateUs=$an . "-" . $mois2. "-" . $jour2; - + // Formatter switch( $format) { @@ -99,41 +99,3 @@ function dateTimeDuJour() $new = $date["year"]."-".$date["mon"]."-".$date["mday"]." ".$date["hours"].":".$date["minutes"].":".$date["seconds"]; return $new; } - -// Soustrait date1 par date2 et rend le nombre de jours -function ecartDates( $date1, $date2 ) -{ - $date1 = rendTimeStamp($date1); - $date2 = rendTimeStamp($date2); - $sec = $date1-$date2; - $heures = (int)($sec/3600); - $jours = (int)($heures/24); - return $jours; -} - -// Ajoute ou soustrait des jours à une date et renvoie une date (format sql) -function ajouterJours( $date, $jours) -{ - if(!$date) return false; - if(!$jours) return $date; - $date=RendTimeStamp($date); - $jours=$jours*3600*24; - $new = $date+$jours; - $dt=getdate($new); - if( $dt["mon"] < 10 ) $dt["mon"] ="0".$dt["mon"]; - if( $dt["mday"] < 10 ) $dt["mday"] ="0".$dt["mday"]; - $new = $dt["year"]."-".$dt["mon"]."-".$dt["mday"]; - return $new; -} - -// Rend un timestamp à partir d'une date (francais ou US) -function rendTimeStamp( $date ) -{ - if(! $date or substr($date,0,10) == "0000-00-00") return false; - $elem = explode( "-", $date ); - if(strlen($elem[0]) == 4) $new = mkTime(0,0,0,$elem[1],$elem[2],$elem[0]); - else $new = mkTime(0,0,0,$elem[1], $elem[0], $elem[2]); - return $new; -} - -?> \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php index 1032955e4647b376ebc7e53d72d3d3cfbe0497c4..ccdfc746c68af0544f59dba669ec59b76c4d9877 100644 --- a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php +++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php @@ -1200,3 +1200,38 @@ class NoticeIntegrationZonesTest extends KohaRecordIntegrationTestCase { Class_Exemplaire::find(51)->getZone995()); } } + + + + +/* @see hotline : https://forge.afi-sa.net/issues/183241 */ +class NoticeIntegrationDateNouveauteGAMTest extends KohaRecordIntegrationTestCase { + + public function getProfilDonnees() { + $int_profildonnees = Class_IntProfilDonnees::forKoha() + ->setIdProfil(45); + $attributs = $int_profildonnees->getAttributsAsArray(); + $attributs[4]['format'] = Class_IntProfilDonnees::NOVELTY_DATE_FORMAT_AAAAMMJJ; + $int_profildonnees->setAttributs($attributs); + return $int_profildonnees->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + + $this->loadRecordsFromFile('unimarc_koha_gam'); + } + + + /** @test */ + public function exemplaireCodeBarreShouldBe() { + $this->assertEquals('3262550090', Class_Exemplaire::findFirstBy([])->getCodeBarres()); + } + + + /** @test */ + public function exmplaireDateNouveauteShouldBe() { + $this->assertEquals('2004-08-03', Class_Exemplaire::findFirstBy([])->getDateNouveaute()); + } +} diff --git a/cosmogramme/tests/php/classes/NoticeUnimarcTest.php b/cosmogramme/tests/php/classes/NoticeUnimarcTest.php index dbc34804b53a4e76fe00513b6322ed4004075f03..4d26d26bf6e6cfacc78d2bc2bb20826928658609 100644 --- a/cosmogramme/tests/php/classes/NoticeUnimarcTest.php +++ b/cosmogramme/tests/php/classes/NoticeUnimarcTest.php @@ -80,16 +80,16 @@ class NoticeUnimarcMultipleIsbnTest extends NoticeIntegrationTestCase { public function setUp() { parent::setUp(); - $this->fixture('Class_CosmoVar', + $this->fixture(Class_CosmoVar::class, ['id' => 'types_docs', 'liste' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium"]); - $codif_type_doc = $this->fixture('Class_CodifTypeDoc', + $codif_type_doc = $this->fixture(Class_CodifTypeDoc::class, ['id' => 31, 'label' => 'Romans gros caractères', 'famille_id' => Class_CodifTypeDoc::LIVRE]); - $this->fixture('Class_TypeDoc', + $this->fixture(Class_TypeDoc::class, ['id' => 31, 'label' => 'Romans gros caractères', 'codif_type_doc' => $codif_type_doc]); diff --git a/cosmogramme/tests/php/classes/PMBIntegrationTest.php b/cosmogramme/tests/php/classes/PMBIntegrationTest.php index 7a8e43af42a2b564dfcfa2ed7f04666a67ebd13a..1d25bc72b33cc4412c97b4fcb20032a7cf705779 100644 --- a/cosmogramme/tests/php/classes/PMBIntegrationTest.php +++ b/cosmogramme/tests/php/classes/PMBIntegrationTest.php @@ -480,3 +480,38 @@ class PMBIntegrationRecordLePecheurDoubleSearchIdsThenAlphaTest Class_Notice::findFirstBy(['clef_alpha' => 'LEPECHEURETLAPENITENCEDANSLEGLISEANCIENNE--VOGELC--CERF-1966-1'])->numberOfExemplaires()); } } + + + + +class PMBIntegrationRecordAchatTest extends PMBIntegrationRecordsTestCase { + + protected $_record; + protected $_profil_donnees = + ['id_profil' => 133, + 'libelle' => 'Unimarc PMB auto', + 'accents' => 0, + 'rejet_periodiques' => '1', + 'id_article_periodique' => 0, + 'type_fichier' => 0, + 'format' => 0, + 'attributs' => 'a:10:{i:0;a:14:{s:8:"type_doc";a:55:{i:0;a:3:{s:4:"code";s:1:"0";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:1;a:3:{s:4:"code";s:1:"1";s:5:"label";s:5:"am;na";s:8:"zone_995";s:1:";";}i:2;a:3:{s:4:"code";s:1:"2";s:5:"label";s:5:"as;aa";s:8:"zone_995";s:1:";";}i:3;a:3:{s:4:"code";s:1:"3";s:5:"label";s:3:"i;j";s:8:"zone_995";s:1:";";}i:4;a:3:{s:4:"code";s:1:"4";s:5:"label";s:1:"g";s:8:"zone_995";s:0:"";}i:5;a:3:{s:4:"code";s:1:"5";s:5:"label";s:3:"l;m";s:8:"zone_995";s:1:";";}i:6;a:3:{s:4:"code";s:1:"6";s:5:"label";s:1:"c";s:8:"zone_995";s:0:"";}i:7;a:3:{s:4:"code";s:1:"7";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:8;a:3:{s:4:"code";s:1:"8";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:9;a:3:{s:4:"code";s:1:"9";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:10;a:3:{s:4:"code";s:2:"10";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:11;a:3:{s:4:"code";s:2:"11";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:12;a:3:{s:4:"code";s:2:"12";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:13;a:3:{s:4:"code";s:2:"13";s:5:"label";s:1:"r";s:8:"zone_995";s:0:"";}i:14;a:3:{s:4:"code";s:3:"100";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:15;a:3:{s:4:"code";s:3:"101";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:16;a:3:{s:4:"code";s:3:"102";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:17;a:3:{s:4:"code";s:3:"103";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:18;a:3:{s:4:"code";s:3:"105";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:19;a:3:{s:4:"code";s:3:"107";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:20;a:3:{s:4:"code";s:3:"109";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:21;a:3:{s:4:"code";s:3:"110";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:22;a:3:{s:4:"code";s:3:"112";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:23;a:3:{s:4:"code";s:3:"113";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:24;a:3:{s:4:"code";s:3:"115";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:25;a:3:{s:4:"code";s:3:"116";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:26;a:3:{s:4:"code";s:3:"117";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:27;a:3:{s:4:"code";s:3:"119";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:28;a:3:{s:4:"code";s:7:"Assimil";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:29;a:3:{s:4:"code";s:3:"Cvs";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:30;a:3:{s:4:"code";s:18:"LaSourisQuiRaconte";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:31;a:3:{s:4:"code";s:7:"Lekiosk";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:32;a:3:{s:4:"code";s:10:"LesYeuxDoc";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:33;a:3:{s:4:"code";s:7:"Musicme";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:34;a:3:{s:4:"code";s:5:"Omeka";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:35;a:3:{s:4:"code";s:8:"Skilleos";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:36;a:3:{s:4:"code";s:10:"StoryPlayR";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:37;a:3:{s:4:"code";s:13:"ToutApprendre";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:38;a:3:{s:4:"code";s:7:"DiMusic";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:39;a:3:{s:4:"code";s:5:"Numel";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:40;a:3:{s:4:"code";s:9:"per_title";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:41;a:3:{s:4:"code";s:7:"per_art";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:42;a:3:{s:4:"code";s:5:"Bacon";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:43;a:3:{s:4:"code";s:19:"MaPetiteMediatheque";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:44;a:3:{s:4:"code";s:10:"Whisperies";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:45;a:3:{s:4:"code";s:7:"Numilog";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:46;a:3:{s:4:"code";s:11:"Cyberlibris";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:47;a:3:{s:4:"code";s:7:"ArteVod";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:48;a:3:{s:4:"code";s:10:"bokeh_page";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:49;a:3:{s:4:"code";i:111;s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:50;a:3:{s:4:"code";s:8:"Arkhenum";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:51;a:3:{s:4:"code";s:10:"ArteCampus";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:52;a:3:{s:4:"code";s:6:"Artips";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:53;a:3:{s:4:"code";s:11:"Kidilangues";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}i:54;a:3:{s:4:"code";s:7:"Mobidys";s:5:"label";s:0:"";s:8:"zone_995";s:0:"";}}s:9:"item_zone";s:3:"995";s:17:"champ_code_barres";s:1:"f";s:10:"champ_cote";s:1:"k";s:14:"champ_type_doc";s:0:"";s:13:"champ_section";s:1:"q";s:11:"champ_genre";s:0:"";s:17:"champ_emplacement";s:0:"";s:12:"champ_annexe";s:1:"b";s:18:"champ_availability";s:0:"";s:15:"champ_bundle_id";s:0:"";s:17:"champ_itemid_sigb";s:0:"";s:16:"champ_id_origine";a:2:{s:4:"zone";s:3:"001";s:5:"champ";s:0:"";}s:9:"champ_url";a:2:{s:4:"zone";s:0:"";s:5:"champ";s:0:"";}}i:1;a:0:{}i:2;a:0:{}i:3;a:0:{}i:4;a:5:{s:5:"jours";s:2:"60";s:4:"zone";s:3:"999";s:5:"champ";s:1:"a";s:6:"format";s:1:"5";s:7:"valeurs";s:0:"";}i:5;a:0:{}i:6;a:2:{s:4:"zone";s:3:"932";s:5:"champ";s:1:"a";}i:7;a:3:{s:15:"index_file_zone";a:1:{i:0;s:0:"";}s:16:"index_file_field";a:1:{i:0;s:0:"";}s:20:"index_file_uri_regex";a:1:{i:0;s:37:"/userfiles/files/[a-zA-Z0-9_\-]+\.pdf";}}i:8;a:2:{s:11:"thumbs_zone";a:0:{}s:12:"thumbs_field";a:0:{}}s:11:"identifiers";a:3:{s:16:"identifiers_type";a:1:{i:0;s:0:"";}s:16:"identifiers_zone";a:1:{i:0;s:0:"";}s:17:"identifiers_field";a:1:{i:0;s:0:"";}}}']; + + + public function getProfilDonnees(){ + return $this->_profil_donnees; + } + + public function setUp() { + parent::setUp(); + + $this->loadRecordsFromFile('unimarc_pmb_achat'); + $this->_exemplaire = Class_Exemplaire::find(1); + } + + + /** @test */ + public function dateNouveauteShouldBe20Sept2023() { + $this->assertContains('2023-09-20', $this->_exemplaire->getDateNouveaute()); + } +} diff --git a/cosmogramme/tests/php/classes/unimarc_koha_gam.txt b/cosmogramme/tests/php/classes/unimarc_koha_gam.txt new file mode 100644 index 0000000000000000000000000000000000000000..db1e92789a3671b4f8387e7227fa854fe27704bf --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_koha_gam.txt @@ -0,0 +1 @@ +02060 jm 2200637 4500001000700000010001800007035001200025071003100037073001800068090001100086100004100097101000800138126002000146127001100166200010500177210002700282215001900309225002200328345004800350410002800398464002500426464002600451464002500477464003200502464002000534464002300554464001600577464001200593464002500605464002000630464001200650464002700662464001800689464002200707464003200729464002000761464001600781464001500797464002500812464002100837464001800858464001800876464002100894464002300915464002100938464002000959464003300979686001401012700004901026702003101075702004301106801002001149902001901169995011601188995011801304123044 a2-7427-4346-4 a0286228 aLIV 4972bActes sud junior a9782742743464 a123044 a20040505d2003 a||y0frey50 ba afre aagbxzzx||||||cd a001200 aComptines à croquer à belles dentsfJean-Hugues MalineaugLouis Dunoyer de SegonzacgJocelyne Sand cActes Sud juniord2003 a1 C-De1 livre aUn livre-une voix aGAMb9782742743469cdisque compactd23,92 E 97675tUn livre-une voix tUn Appétit d'oiseau tUn Appétit de jaguar tQuand je serai grand tDe soleil et d'eau fraîche tBidon-saucisson tPotage de cétacé tGargouillis tA table tTon thé et ton thon tQuelle salade ! tRecette tAu menu ou à la carte tTrois sorbets tQuestion de goût tJ'aime pas les choux-fleurs tQuel appétit ! tLa Dînette tBien pondu tRepas préhistorique tCasser la graine tUn deux trois tAm stram gram tAmour champêtre tMarché aux fleurs tPoule de Pâques tFesses en l'air tMa grand-mère va au marché a723dDVDP 945796aMalineaubJean-Huguesf1945-....4070 973784aSandbJocelyne4550 935282aDunoyer de SegonzacbLouis4230 aFRbGAMc040505 9266acomptines 10203052011-06-2762021-04-169145925bBDMcBDMf3262550090hENFAigamjJk723 MALm2019-09-10o0rC-Dx0z10 10203052011-10-0662023-07-249156651bBDMcBDMdJf3976420090hENFAicvsjJk723 MALm2018-08-21o0rC-Dx0z9 \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_pmb_achat.txt b/cosmogramme/tests/php/classes/unimarc_pmb_achat.txt new file mode 100644 index 0000000000000000000000000000000000000000..2c010e8b024ef9effd88d5dcab9c3f9127008cc4 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_pmb_achat.txt @@ -0,0 +1 @@ +01940nam0 22002531i 450 00100060000010000350000600900150004120000260005601000300008210100130011221500320012533003740015770000470053121000460057821400460062489601700067099500680084099605550090899900420146399900710150560600410157660600430161780100260166066690 a20230111u u u0frey0103 a2023-01-011 aL'alphabet du silence a978-2-37880-351-3d20 EUR1 afrecfre a1 vol. (303 p.)d19 x 14 cm aProfesseur Áa l'universitÂe du Bosphore, GÉoktay s'engage en faveur des opprimÂes du rÂegime turc, notamment la minoritÂe kurde, et dÂenonce les dÂerives autoritaires du prÂesident Erdogan. Cependant, son Âepouse, Aula, enseignante de franÐcais, ne partage pas son militantisme et n'aspire qu'Áa profiter de la douceur d'Istanbul avec leur petite fille. Premier roman. 1aMinouibDelphine4070f1974-....9id:36251 aParisbPariscl'Iconoclasted20239id:413 aParisbPariscl'Iconoclasted20239id:413 ahttps://haubourdin.bibli.fr/getimage.php?url_image=http%3A%2F%2Fimages-eu.amazon.com%2Fimages%2FP%2F%21%21isbn%21%21.08.MZZZZZZZ.jpg¬icecode=9782378803513&vigurl= aFonds proprecFonds propref079844kR MINqurabHaubourdin-Bib f079844kR MINm00000000n00000000aFonds propreb1vBibliothÁeque d'HaubourdinwBibliothÁeque principalexRoman AdulteseLivreraz1Empruntable319expl_id:675259create_date:2023-07-22 15:51:549expl_cb:0798449expl_cote:R MIN9expl_statut:19statut_libelle:Empruntable9expl_typdoc:19tdoc_libelle:Livre9tdoc_codage_import:az9expl_section:189section_libelle:Roman Adultes9expl_owner:19lender_libelle:Fonds propre9codestat_libelle:Adultes9pret_flag:19location_libelle:BibliothÁeque d'Haubourdin9locdoc_codage_import:BibliothÁeque principale aAchatlOriginenoriginetlistf079844 a22/07/2023lDate d'acquisitionndate_acquisitiontdate_boxf079844 19id:28229lang:fr_FR9idthes:1aRoman 19id:19589lang:fr_FR9idthes:1aTurquie aElectrebFRc20230729 \ No newline at end of file diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index 4163e1eae4486a25fcb82fd6fd52263822ea6e0a..4a3835387ca69087bada70cdcda4da4c5b0241ca 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -493,7 +493,7 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ $this->_notice->setUrlVignette($url_vignette); $this->_notice->setUrlImage($url_vignette); if ($release_date = $this->_model->getReleaseDate()) - $this->_notice->setDateCreation($this->tryFormatDate($release_date, 'Y-m-d H:i:s')); + $this->_notice->setDateCreation(Class_TimeSource::tryFormatDate($release_date, 'Y-m-d H:i:s')); parent::_index(); } diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php index 636e8809c978c4648051b1f5d506e62ef4dff246..edc18dbf6aab623a5db36346d1575d9ef79cd9d6 100644 --- a/library/Class/IntProfilDonnees.php +++ b/library/Class/IntProfilDonnees.php @@ -406,6 +406,7 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { FIELD_ITEM_BASE_URL = 'item_base_url', FIELD_ITEM_SITE_SLUG = 'item_site_slug', FIELD_ITEM_CAS_SSO = 'item_cas_sso', + FIELD_RECORDISNEW = 4, PROFILE_FIELDS = 'champs', PROFILE_DOC_TYPES = 'type_doc', @@ -454,32 +455,34 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { ->newInstance(['libelle' => 'Unimarc standard', 'rejet_periodiques' => 1, 'attributs' => - [['type_doc' => - [['code' => '0', 'label' => '', 'zone_995' => ''], - ['code' => '1', 'label' => 'am;na', 'zone_995' => ''], - ['code' => '2', 'label' => 'as', 'zone_995' => ''], - ['code' => '3', 'label' => 'i;j', 'zone_995' => ''], - ['code' => '4', 'label' => 'g', 'zone_995' => ''], - ['code' => '5', 'label' => 'l;m', 'zone_995' => ''], - ['code' => '8', 'label' => '', 'zone_995' => ''], - ['code' => '9', 'label' => '', 'zone_995' => ''], - ['code' => '10', 'label' => '', 'zone_995' => ''], - ['code' => '100', 'label' => '', 'zone_995' => ''], + [ self::FT_RECORDS => + ['type_doc' => + [['code' => '0', 'label' => '', 'zone_995' => ''], + ['code' => '1', 'label' => 'am;na', 'zone_995' => ''], + ['code' => '2', 'label' => 'as', 'zone_995' => ''], + ['code' => '3', 'label' => 'i;j', 'zone_995' => ''], + ['code' => '4', 'label' => 'g', 'zone_995' => ''], + ['code' => '5', 'label' => 'l;m', 'zone_995' => ''], + ['code' => '8', 'label' => '', 'zone_995' => ''], + ['code' => '9', 'label' => '', 'zone_995' => ''], + ['code' => '10', 'label' => '', 'zone_995' => ''], + ['code' => '100', 'label' => '', 'zone_995' => ''], + ], + static::FIELD_ITEM_BARCODE => 'f', + static::FIELD_ITEM_COTE => 'k', + static::FIELD_ITEM_GENRE => '', + static::FIELD_ITEM_SECTION => 'q', + static::FIELD_ITEM_EMPLACEMENT => 'u', + static::FIELD_ITEM_ANNEXE => 'a', ], - static::FIELD_ITEM_BARCODE => 'f', - static::FIELD_ITEM_COTE => 'k', - static::FIELD_ITEM_GENRE => '', - static::FIELD_ITEM_SECTION => 'q', - static::FIELD_ITEM_EMPLACEMENT => 'u', - static::FIELD_ITEM_ANNEXE => 'a', + self::FIELD_RECORDISNEW => + [ + 'zone' => '', + 'champ' => '', + 'format' => '', + 'jours' => '', + 'valeurs' => '', ], - [ - 'zone' => '', - 'champ' => '', - 'format' => '', - 'jours' => '', - 'valeurs' => '', - ], ]]); } @@ -493,37 +496,37 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_UNIMARC, 'attributs' => - [0 => ['type_doc' => - [[ 'code' => '0', 'label' => '', 'zone_995' => '' ], - [ 'code' => '1', 'label' => 'am', 'zone_995' => '' ], - [ 'code' => '2', 'label' => 'as', 'zone_995' => ''], - [ 'code' => '3', 'label' => 'j;jm', 'zone_995' => ''], - [ 'code' => '4', 'label' => '','zone_995' => 'gf'], - [ 'code' => '5', 'label' => '', 'zone_995' => 'gz'], - [ 'code' => '6', 'label' => 'm;m', 'zone_995' => '' ], - [ 'code' => '7', 'label' => '', 'zone_995' => 'iz' ], - [ 'code' => '8', 'label' => '', 'zone_995' => 'mz'], - [ 'code' => '9', 'label' => '', 'zone_995' => ''], - [ 'code' => '10', 'label' => '', 'zone_995' => ''], - [ 'code' => '11', 'label' => '', 'zone_995' => ''], - [ 'code' => '12', 'label' => '', 'zone_995' => 'jd'] - ], - self::FIELD_ITEM_BARCODE => 'f', - self::FIELD_ITEM_COTE => 'k', - self::FIELD_ITEM_TYPE_DOC => '', - self::FIELD_ITEM_GENRE => '7', - self::FIELD_ITEM_SECTION => '9', - self::FIELD_ITEM_EMPLACEMENT => '6', - self::FIELD_ITEM_ANNEXE => '8' + [self::FT_RECORDS => ['type_doc' => + [[ 'code' => '0', 'label' => '', 'zone_995' => '' ], + [ 'code' => '1', 'label' => 'am', 'zone_995' => '' ], + [ 'code' => '2', 'label' => 'as', 'zone_995' => ''], + [ 'code' => '3', 'label' => 'j;jm', 'zone_995' => ''], + [ 'code' => '4', 'label' => '','zone_995' => 'gf'], + [ 'code' => '5', 'label' => '', 'zone_995' => 'gz'], + [ 'code' => '6', 'label' => 'm;m', 'zone_995' => '' ], + [ 'code' => '7', 'label' => '', 'zone_995' => 'iz' ], + [ 'code' => '8', 'label' => '', 'zone_995' => 'mz'], + [ 'code' => '9', 'label' => '', 'zone_995' => ''], + [ 'code' => '10', 'label' => '', 'zone_995' => ''], + [ 'code' => '11', 'label' => '', 'zone_995' => ''], + [ 'code' => '12', 'label' => '', 'zone_995' => 'jd'] + ], + self::FIELD_ITEM_BARCODE => 'f', + self::FIELD_ITEM_COTE => 'k', + self::FIELD_ITEM_TYPE_DOC => '', + self::FIELD_ITEM_GENRE => '7', + self::FIELD_ITEM_SECTION => '9', + self::FIELD_ITEM_EMPLACEMENT => '6', + self::FIELD_ITEM_ANNEXE => '8' ], 1 => ['champs' => ''], 2 => ['champs' => ''], 3 => ['champs' => ''], - 4 => ['zone' => '995', - 'champ' => '4', - 'format' => self::NOVELTY_DATE_FORMAT_VALUES, - 'jours' => '', - 'valeurs' => ''] + self::FIELD_RECORDISNEW => ['zone' => '995', + 'champ' => '4', + 'format' => self::NOVELTY_DATE_FORMAT_VALUES, + 'jours' => '', + 'valeurs' => ''] ] ] ); @@ -539,38 +542,38 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_UNIMARC, 'attributs' => - [0 => ['type_doc' => - [[ 'code' => '0', 'label' => '', 'zone_995' => '' ], - [ 'code' => '1', 'label' => 'am', 'zone_995' => '' ], - [ 'code' => '2', 'label' => 'as', 'zone_995' => ''], - [ 'code' => '3', 'label' => 'j;jm', 'zone_995' => ''], - [ 'code' => '4', 'label' => '','zone_995' => 'gf'], - [ 'code' => '5', 'label' => '', 'zone_995' => 'gz'], - [ 'code' => '6', 'label' => 'm;m', 'zone_995' => '' ], - [ 'code' => '7', 'label' => '', 'zone_995' => 'iz' ], - [ 'code' => '8', 'label' => '', 'zone_995' => 'mz'], - [ 'code' => '9', 'label' => '', 'zone_995' => ''], - [ 'code' => '10', 'label' => '', 'zone_995' => ''], - [ 'code' => '11', 'label' => '', 'zone_995' => ''], - [ 'code' => '12', 'label' => '', 'zone_995' => 'jd'] - ], - self::FIELD_ITEM_BARCODE => 'f', - self::FIELD_ITEM_COTE => 'k', - self::FIELD_ITEM_TYPE_DOC => '2', - self::FIELD_ITEM_GENRE => '', - self::FIELD_ITEM_SECTION => 'q', - self::FIELD_ITEM_EMPLACEMENT => 'u', - self::FIELD_ITEM_ANNEXE => 'a', - self::FIELD_ITEM_AVAILABILITY => '1' + [ self::FT_RECORDS => ['type_doc' => + [[ 'code' => '0', 'label' => '', 'zone_995' => '' ], + [ 'code' => '1', 'label' => 'am', 'zone_995' => '' ], + [ 'code' => '2', 'label' => 'as', 'zone_995' => ''], + [ 'code' => '3', 'label' => 'j;jm', 'zone_995' => ''], + [ 'code' => '4', 'label' => '','zone_995' => 'gf'], + [ 'code' => '5', 'label' => '', 'zone_995' => 'gz'], + [ 'code' => '6', 'label' => 'm;m', 'zone_995' => '' ], + [ 'code' => '7', 'label' => '', 'zone_995' => 'iz' ], + [ 'code' => '8', 'label' => '', 'zone_995' => 'mz'], + [ 'code' => '9', 'label' => '', 'zone_995' => ''], + [ 'code' => '10', 'label' => '', 'zone_995' => ''], + [ 'code' => '11', 'label' => '', 'zone_995' => ''], + [ 'code' => '12', 'label' => '', 'zone_995' => 'jd'] + ], + self::FIELD_ITEM_BARCODE => 'f', + self::FIELD_ITEM_COTE => 'k', + self::FIELD_ITEM_TYPE_DOC => '2', + self::FIELD_ITEM_GENRE => '', + self::FIELD_ITEM_SECTION => 'q', + self::FIELD_ITEM_EMPLACEMENT => 'u', + self::FIELD_ITEM_ANNEXE => 'a', + self::FIELD_ITEM_AVAILABILITY => '1' ], - 1 => ['champs' => ''], - 2 => ['champs' => ''], - 3 => ['champs' => ''], - 4 => ['zone' => '995', - 'champ' => '4', - 'format' => self::NOVELTY_DATE_FORMAT_VALUES, - 'jours' => '', - 'valeurs' => ''] + 1 => ['champs' => ''], + 2 => ['champs' => ''], + 3 => ['champs' => ''], + self::FIELD_RECORDISNEW => ['zone' => '995', + 'champ' => '4', + 'format' => self::NOVELTY_DATE_FORMAT_VALUES, + 'jours' => '', + 'valeurs' => ''] ] ] ); @@ -586,30 +589,32 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_UNIMARC, 'attributs' => - [['type_doc' => - [[ 'code' => '0', 'label' => '', 'zone_995' => '' ], - [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'au;uu;iu;LIV;MS' ], - [ 'code' => '2', 'label' => 'as', 'zone_995' => 'PER'], - [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'jz;CD;LIVCD;LIVK7;K7'], - [ 'code' => '4', 'label' => 'g', 'zone_995' => 'gz;DIAPO;DVD;VHS;VHD;VD'], - [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'lu;CDR'], - [ 'code' => '6', 'label' => '', 'zone_995' => 'DOS' ], - [ 'code' => '7', 'label' => '', 'zone_995' => '' ], - [ 'code' => '8', 'label' => '', 'zone_995' => 'WEB;MF'] + [ self::FT_RECORDS => + ['type_doc' => + [[ 'code' => '0', 'label' => '', 'zone_995' => '' ], + [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'au;uu;iu;LIV;MS' ], + [ 'code' => '2', 'label' => 'as', 'zone_995' => 'PER'], + [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'jz;CD;LIVCD;LIVK7;K7'], + [ 'code' => '4', 'label' => 'g', 'zone_995' => 'gz;DIAPO;DVD;VHS;VHD;VD'], + [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'lu;CDR'], + [ 'code' => '6', 'label' => '', 'zone_995' => 'DOS' ], + [ 'code' => '7', 'label' => '', 'zone_995' => '' ], + [ 'code' => '8', 'label' => '', 'zone_995' => 'WEB;MF'] + ], + self::FIELD_ITEM_BARCODE => 'a', + self::FIELD_ITEM_COTE => 'f', + self::FIELD_ITEM_TYPE_DOC => 'c', + self::FIELD_ITEM_GENRE => '', + self::FIELD_ITEM_SECTION => 'w', + self::FIELD_ITEM_EMPLACEMENT => 'x', + self::FIELD_ITEM_ANNEXE => 'g' ], - self::FIELD_ITEM_BARCODE => 'a', - self::FIELD_ITEM_COTE => 'f', - self::FIELD_ITEM_TYPE_DOC => 'c', - self::FIELD_ITEM_GENRE => '', - self::FIELD_ITEM_SECTION => 'w', - self::FIELD_ITEM_EMPLACEMENT => 'x', - self::FIELD_ITEM_ANNEXE => 'g' - ], - ['zone' => '995', - 'champ' => '5', - 'format' => self::NOVELTY_DATE_FORMAT_VALUES, - 'jours' => '', - 'valeurs' => '1'] + self::FIELD_RECORDISNEW => + ['zone' => '995', + 'champ' => '5', + 'format' => self::NOVELTY_DATE_FORMAT_VALUES, + 'jours' => '', + 'valeurs' => '1'] ] ] ); @@ -636,20 +641,21 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'id_article_periodique' => self::SERIAL_FORMAT_ALOES_INDEXPRESS, 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_UNIMARC, - 'attributs' => [ - ['type_doc' => $type_doc, - self::FIELD_ITEM_BARCODE => 'f', - self::FIELD_ITEM_COTE => 'k', - self::FIELD_ITEM_TYPE_DOC => '', - self::FIELD_ITEM_GENRE => '', - self::FIELD_ITEM_SECTION => 'q', - self::FIELD_ITEM_EMPLACEMENT => 'l', - self::FIELD_ITEM_ANNEXE => 'b'], - ['zone' => '995', - 'champ' => 'v', - 'format' => self::NOVELTY_DATE_FORMAT_VALUES, - 'jours' => '', - 'valeurs' => 'nouveaute']]]); + 'attributs' => + [ + self::FT_RECORDS =>['type_doc' => $type_doc, + self::FIELD_ITEM_BARCODE => 'f', + self::FIELD_ITEM_COTE => 'k', + self::FIELD_ITEM_TYPE_DOC => '', + self::FIELD_ITEM_GENRE => '', + self::FIELD_ITEM_SECTION => 'q', + self::FIELD_ITEM_EMPLACEMENT => 'l', + self::FIELD_ITEM_ANNEXE => 'b'], + self::FIELD_RECORDISNEW => ['zone' => '995', + 'champ' => 'v', + 'format' => self::NOVELTY_DATE_FORMAT_VALUES, + 'jours' => '', + 'valeurs' => 'nouveaute']]]); } @@ -673,20 +679,21 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'id_article_periodique' => self::SERIAL_FORMAT_ALOES_INDEXPRESS, 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_UNIMARC, - 'attributs' => [ - ['type_doc' => $type_doc, - self::FIELD_ITEM_BARCODE => 'f', - self::FIELD_ITEM_COTE => 'k', - self::FIELD_ITEM_TYPE_DOC => 'r', - self::FIELD_ITEM_GENRE => '', - self::FIELD_ITEM_SECTION => 'q', - self::FIELD_ITEM_EMPLACEMENT => 'u', - self::FIELD_ITEM_ANNEXE => 'a'], - ['zone' => '922', - 'champ' => 'c', - 'format' => self::NOVELTY_DATE_FORMAT_SLASHED_JMAAAA, - 'jours' => '', - 'valeurs' => '']]]); + 'attributs' => + [ + self::FT_RECORDS => ['type_doc' => $type_doc, + self::FIELD_ITEM_BARCODE => 'f', + self::FIELD_ITEM_COTE => 'k', + self::FIELD_ITEM_TYPE_DOC => 'r', + self::FIELD_ITEM_GENRE => '', + self::FIELD_ITEM_SECTION => 'q', + self::FIELD_ITEM_EMPLACEMENT => 'u', + self::FIELD_ITEM_ANNEXE => 'a'], + self::FIELD_RECORDISNEW => ['zone' => '922', + 'champ' => 'c', + 'format' => self::NOVELTY_DATE_FORMAT_SLASHED_JMAAAA, + 'jours' => '', + 'valeurs' => '']]]); } @@ -718,20 +725,20 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_UNIMARC, 'attributs' => [ - [self::PROFILE_DOC_TYPES => $type_doc, - self::FIELD_ITEM_BARCODE => 'f', - self::FIELD_ITEM_COTE => 'k', - self::FIELD_ITEM_TYPE_DOC => 'r', - self::FIELD_ITEM_GENRE => '', - self::FIELD_ITEM_SECTION => 'q', - self::FIELD_ITEM_EMPLACEMENT => 'e', - self::FIELD_ITEM_ANNEXE => 'b', - self::FIELD_ITEM_UNIQ_SUBFIELD => '9'], - ['zone' => '801', - 'champ' => 'c', - 'format' => self::NOVELTY_DATE_FORMAT_AAAA_MM_JJ, - 'jours' => '90', - 'valeurs' => '']]]); + self::FT_RECORDS => [self::PROFILE_DOC_TYPES => $type_doc, + self::FIELD_ITEM_BARCODE => 'f', + self::FIELD_ITEM_COTE => 'k', + self::FIELD_ITEM_TYPE_DOC => 'r', + self::FIELD_ITEM_GENRE => '', + self::FIELD_ITEM_SECTION => 'q', + self::FIELD_ITEM_EMPLACEMENT => 'e', + self::FIELD_ITEM_ANNEXE => 'b', + self::FIELD_ITEM_UNIQ_SUBFIELD => '9'], + self::FIELD_RECORDISNEW => ['zone' => '801', + 'champ' => 'c', + 'format' => self::NOVELTY_DATE_FORMAT_AAAA_MM_JJ, + 'jours' => '90', + 'valeurs' => '']]]); } @@ -765,19 +772,20 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'id_article_periodique' => 0, 'type_fichier' => self::FT_RECORDS, 'format' => self::FORMAT_MARC21, - 'attributs' => [['type_doc' => $type_doc, - self::FIELD_ITEM_BARCODE => '999', - self::FIELD_ITEM_COTE => 'k', - self::FIELD_ITEM_TYPE_DOC => 'x', - self::FIELD_ITEM_GENRE => '', - self::FIELD_ITEM_SECTION => 'z', - self::FIELD_ITEM_EMPLACEMENT => 'l', - self::FIELD_ITEM_ANNEXE => 'm'], - ['zone' => '996', - 'champ' => 'u', - 'format' => self::NOVELTY_DATE_FORMAT_AAAA_MM_JJ, - 'jours' => '90', - 'valeurs' => '']]]); + 'attributs' => + [ self::FT_RECORDS => ['type_doc' => $type_doc, + self::FIELD_ITEM_BARCODE => '999', + self::FIELD_ITEM_COTE => 'k', + self::FIELD_ITEM_TYPE_DOC => 'x', + self::FIELD_ITEM_GENRE => '', + self::FIELD_ITEM_SECTION => 'z', + self::FIELD_ITEM_EMPLACEMENT => 'l', + self::FIELD_ITEM_ANNEXE => 'm'], + self::FIELD_RECORDISNEW => ['zone' => '996', + 'champ' => 'u', + 'format' => self::NOVELTY_DATE_FORMAT_AAAA_MM_JJ, + 'jours' => '90', + 'valeurs' => '']]]); } diff --git a/library/Class/Systeme/PergameService.php b/library/Class/Systeme/PergameService.php index bfcefe5aba04064f05db5bde5439860dd2143db7..a347312dd2a8ebd1e722bfe48c855377e2bf2fef 100644 --- a/library/Class/Systeme/PergameService.php +++ b/library/Class/Systeme/PergameService.php @@ -266,7 +266,7 @@ class Class_Systeme_PergameService { $anteriorite_max = (int)$regles['Anteriorite_max_en_jours']; if ($anteriorite_max) { $ecart = ecartDates($dateJour, $dateRetour); - if ($ecart>$anteriorite_max) + if ($ecart && ($ecart > $anteriorite_max)) return ['statut' => 0, 'erreur' => 'Le prêt n\'a pas pu être prolongé car il a un retard trop important.' . $complement_msg]; } @@ -280,9 +280,9 @@ class Class_Systeme_PergameService { } // On prolonge - $newDate = ajouterJours($pret["DATE_RETOUR"], $regles['Duree_en_jours']); + $newDate = Class_TimeSource::addDays($pret["DATE_RETOUR"], $regles['Duree_en_jours']); while($newDate<=$dateJour) - $newDate = ajouterJours($newDate,$regles['Duree_en_jours']); + $newDate = Class_TimeSource::addDays($newDate,$regles['Duree_en_jours']); $tempsProlong=(int)$regles['Duree_en_jours']; // Ecrire le prêt diff --git a/library/Class/TimeSource.php b/library/Class/TimeSource.php index 8d39e30299c04e1a95a17dbcac4b0b6ed9a576d9..8f5dce7589882047280c1fc863cf304289227a33 100644 --- a/library/Class/TimeSource.php +++ b/library/Class/TimeSource.php @@ -168,6 +168,23 @@ class Class_TimeSource { } + public static function tryFormatDate( string $date_str, string $return_format= 'Y-m-d'): string { + $date_str = str_replace( '.0Z', '', $date_str); + + $formats=['Y','Y-m-d', 'Y/m/d', 'Ymd', 'YmdHis','Y-m-d*H:i:s', 'd-m-Y', 'd/m/Y','ymd']; + + foreach ($formats as $format) { + if ($date = DateTime::createFromFormat($format, $date_str)) + return $date->format($return_format); + } + return ''; + } + + + public static function daysBetween(string $date_from, string $date_to) : int{ + return (new DateTime($date_from))->diff(new DateTime($date_to))->d; + } + /** * @see https://www.php.net/manual/en/function.uniqid.php * php uniqid is time dependent therefore it is entitled to be provided by time source @@ -175,4 +192,8 @@ class Class_TimeSource { public function uniqid(string $prefix='', bool $more_entropy=false) : string { return uniqid($prefix, $more_entropy); } + + public static function addDays(string $date, int $days, string $format = 'Y-m-d') :string{ + return date($format, strtotime( $days.' day' , strtotime($date))); + } } diff --git a/library/Class/WebService/Cas3.php b/library/Class/WebService/Cas3.php index b464bb3c90844dadbbd3f36d9702977a21a4bf96..00e6637006737e69392e15e454b0604d30f92434 100644 --- a/library/Class/WebService/Cas3.php +++ b/library/Class/WebService/Cas3.php @@ -71,6 +71,6 @@ class Class_WebService_Cas3 extends Class_WebService_Cas2 { if (strlen($value) <= 4) return sprintf('%04d-01-01',$value); - return self::tryFormatDate($value); + return Class_TimeSource::tryFormatDate($value); } } diff --git a/library/Trait/TimeSource.php b/library/Trait/TimeSource.php index a675547667f706ae377ac7a586f840b57294abea..03da053e5c87de65e8561d6edc38a8de1a2d1700 100644 --- a/library/Trait/TimeSource.php +++ b/library/Trait/TimeSource.php @@ -77,19 +77,6 @@ trait Trait_TimeSource { } - public static function tryFormatDate( string $date_str, string $return_format= 'Y-m-d'): string { - $date_str = str_replace( '.0Z', '', $date_str); - - $formats=['Y','Y-m-d', 'Y/m/d', 'Ymd', 'YmdHis','Y-m-d*H:i:s', 'd-m-Y', 'd/m/Y']; - - foreach ($formats as $format) { - if ($date = DateTime::createFromFormat($format, $date_str)) - return $date->format($return_format); - } - return ''; - } - - public static function addIntervalToDate($interval, $date){ $date= $date ? strtotime($date)