diff --git a/VERSIONS_HOTLINE/169415 b/VERSIONS_HOTLINE/169415 new file mode 100644 index 0000000000000000000000000000000000000000..8cf4fe590ac5e90e12d7724dc2f3bcdbc27d6556 --- /dev/null +++ b/VERSIONS_HOTLINE/169415 @@ -0,0 +1 @@ + - correctif #169415 : Cosmogramme : Amélioration du diagnostique de Nanook unique. Vous pouvez maintenant supprimer les intégrations corrompues depuis l'interface. \ No newline at end of file diff --git a/cosmogramme/cosmozend/application/modules/cosmo/controllers/IntegrationController.php b/cosmogramme/cosmozend/application/modules/cosmo/controllers/IntegrationController.php index 22594882ea6c8ebe26fa268ee20a0f38895b4ed7..b8ae462bf380c50e067f5e70b50fbb7eddde08d6 100644 --- a/cosmogramme/cosmozend/application/modules/cosmo/controllers/IntegrationController.php +++ b/cosmogramme/cosmozend/application/modules/cosmo/controllers/IntegrationController.php @@ -145,4 +145,33 @@ class Cosmo_IntegrationController extends ZendAfi_Controller_Action{ $this->_helper->stormFileSystemDownload($file->path(), $file->name()); } + + + public function dashboardAction() { + if ( ! $this->view->int_bib = Class_IntBib::find($this->_getParam('id'))) { + $this->_helper->notify($this->_('Intégration inconnue')); + return $this->_redirectClose($this->_getReferer()); + } + + $this->view->titre = $this->_('Tableau de bord de l\'intégration %s', + $this->view->int_bib->getNomCourt()); + } + + + public function deleteAction() { + if ( ! $int_bib = Class_IntBib::find($this->_getParam('id'))) { + $this->_helper->notify($this->_('Intégration inconnue')); + return $this->_redirectClose($this->_getReferer()); + } + + + if ( $library = $int_bib->getBib()) { + Class_CodifAnnexe::deleteBy(['id_bib' => $library->getId()]); + Class_Exemplaire::deleteBy(['id_bib' => $library->getId()]); + $library->deleteIntBibRelated(); + $library->setVisibilite(Class_Bib::V_NODATA)->save(); + } + + return $this->_redirectClose('/cosmo/index/index'); + } } diff --git a/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/integration/dashboard.phtml b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/integration/dashboard.phtml new file mode 100644 index 0000000000000000000000000000000000000000..3989d11baa6a5f842a4545821f48bf54085e6fc9 --- /dev/null +++ b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/integration/dashboard.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->Cosmo_IntegrationDashboard($this->int_bib); diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IndexTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IndexTest.php index c207f08a2cb371e1b6801cdac48326a570d00f57..535fad224dba1214dd5999d8e7d79e8c6b2a9699 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IndexTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IndexTest.php @@ -363,6 +363,12 @@ class CosmoIndexWithSingleNanookNoTest extends CosmoControllerTestCase { } + /** @test */ + public function linkToETREPAGNYDashboardShouldBeDisplay() { + $this->assertXPath('//p/a[@href="/cosmo/integration/dashboard/id/34"]/i[@class="fa fa-bug"]'); + } + + /** @test */ public function messageBezuIsUsingUrlServerInHttpsShouldBeDisplay() { $this->assertXPathContentContains('//p', 'L\'integration BEZU a pour url_server : https://monsuper-server-nanook.fr/ . Cette url_serveur est utilisée dans 2 autres intégrations'); diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php index 7804d67d56b3f16d03c1d3e7814f011a2833dd74..e36b17c01efad03be71a94df7cc4dd813bc19874 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/IntegrationControllerTest.php @@ -37,19 +37,19 @@ class Cosmo_IntegrationControllerTestActionTest extends CosmoControllerTestCase } - /** @test */ - public function shouldHaveCalledServiceTestMethod() { - $this->dispatch('/cosmo/integration/test?type=7&options[url_serveur]=' . urlencode('http://localhost/ilsdi'), true); - - $this->assertTrue($this->_service->methodHasBeenCalled('test')); - } + /** @test */ + public function shouldHaveCalledServiceTestMethod() { + $this->dispatch('/cosmo/integration/test?type=7&options[url_serveur]=' . urlencode('http://localhost/ilsdi')); + $this->assertTrue($this->_service->methodHasBeenCalled('test')); + } } + abstract class Cosmo_IntegrationControllerControlActionTestCase extends CosmoControllerTestCase { - public function setUp() { - parent::setUp(); + public function setUp() { + parent::setUp(); $this->fixture('Class_CosmoVar', ['id' => 'import_type_operation', 'liste' => "0:Import incrémentiel\r\n1:Suppression d'exemplaires\r\n2:Import total\r\n3:Suppression fichier d'entête Pergame\r\n"]); @@ -58,120 +58,122 @@ abstract class Cosmo_IntegrationControllerControlActionTestCase extends CosmoCon ['id' => 'type_fichier', 'liste' => "0:notices\r\n1:abonnés\r\n2:prêts\r\n3:reservations\r\n4:paniers\r\n"]); - $this->file_system = $this->mock(); - Class_Cosmogramme_Integration::setFileSystem($this->file_system); - } + $this->file_system = $this->mock(); + Class_Cosmogramme_Integration::setFileSystem($this->file_system); + } } + class Cosmo_IntegrationControllerControlActionWithoutBibTest extends Cosmo_IntegrationControllerControlActionTestCase { - public function setUp() { - parent::setUp(); - $this->dispatch('/cosmo/integration/control/id/99', true); - } + public function setUp() { + parent::setUp(); + $this->dispatch('/cosmo/integration/control/id/99'); + } - /** @test */ - public function libraryShouldBeUnknown() { - $this->assertXPathContentContains('//div[@class="message_grand"]', - 'Bibliothèque inconnue'); - } + + /** @test */ + public function libraryShouldBeUnknown() { + $this->assertXPathContentContains('//div[@class="message_grand"]', + 'Bibliothèque inconnue'); + } - /** @test */ - public function shouldNotHavePlanif() { - $this->assertXPathContentContains('//h3', 'Plannification : Aucune'); - } + /** @test */ + public function shouldNotHavePlanif() { + $this->assertXPathContentContains('//h3', 'Plannification : Aucune'); + } - /** @test */ - public function shouldNotHaveFiles() { - $this->assertXPathContentContains('//h3', 'Cette bibliothèque n\'a jamais été intégrée.'); - } + /** @test */ + public function shouldNotHaveFiles() { + $this->assertXPathContentContains('//h3', 'Cette bibliothèque n\'a jamais été intégrée.'); + } } class Cosmo_IntegrationControllerControlActionWithBibTest extends Cosmo_IntegrationControllerControlActionTestCase { - public function setUp() { - parent::setUp(); - $this->file_system - ->whenCalled('file_exists')->answers(true) - ->whenCalled('filesize')->answers(1024) - ; + public function setUp() { + parent::setUp(); + $this->file_system + ->whenCalled('file_exists')->answers(true) + ->whenCalled('filesize')->answers(1024) + ; - $profil = $this->fixture('Class_IntProfilDonnees', - ['id' => 1, - 'type_fichier' => 1]); + $profil = $this->fixture('Class_IntProfilDonnees', + ['id' => 1, + 'type_fichier' => 1]); - $integration = $this->fixture('Class_Cosmogramme_Integration', - ['id' => 29, - 'traite' => 'non', - 'date_transfert' => '2014-11-14', - 'type_operation' => 2, - 'fichier' => 'integre0000.pan', - 'pointeur_reprise' => 0, - 'nb_erreurs' => 0, - 'nb_warnings' => 0, - 'profil_donnees' => $profil]); - $this->fixture('Class_IntBib', - ['id' => 19, - 'nom_court' => 'Testing library', - 'planif_mode' => 'r', - 'planif_jours' => '0010011', - 'integrations' => [$integration]]); + $integration = $this->fixture('Class_Cosmogramme_Integration', + ['id' => 29, + 'traite' => 'non', + 'date_transfert' => '2014-11-14', + 'type_operation' => 2, + 'fichier' => 'integre0000.pan', + 'pointeur_reprise' => 0, + 'nb_erreurs' => 0, + 'nb_warnings' => 0, + 'profil_donnees' => $profil]); + $this->fixture('Class_IntBib', + ['id' => 19, + 'nom_court' => 'Testing library', + 'planif_mode' => 'r', + 'planif_jours' => '0010011', + 'integrations' => [$integration]]); - $this->dispatch('/cosmo/integration/control/id/19', true); - } + $this->dispatch('/cosmo/integration/control/id/19', true); + } - /** @test */ - public function libraryShouldBePresent() { - $this->assertXPathContentContains('//div[@class="message_grand"]', - 'Testing library'); - } + /** @test */ + public function libraryShouldBePresent() { + $this->assertXPathContentContains('//div[@class="message_grand"]', + 'Testing library'); + } - /** @test */ - public function shouldHavePlanif() { - $this->assertXPathContentContains('//h3', 'Plannification : Me, Sa, Di'); - } + /** @test */ + public function shouldHavePlanif() { + $this->assertXPathContentContains('//h3', 'Plannification : Me, Sa, Di'); + } - /** @test */ - public function shouldHaveFiles() { - $this->assertXPath('//table'); - } + /** @test */ + public function shouldHaveFiles() { + $this->assertXPath('//table'); + } - /** @test */ - public function integre0000ShouldBePresent() { - $this->assertXPathContentContains('//td', 'integre0000.pan'); - } + /** @test */ + public function integre0000ShouldBePresent() { + $this->assertXPathContentContains('//td', 'integre0000.pan'); + } - /** @test */ - public function abonneShouldBePresent() { - $this->assertXPathContentContains('//td', 'abonnés'); - } + /** @test */ + public function abonneShouldBePresent() { + $this->assertXPathContentContains('//td', 'abonnés'); + } - /** @test */ - public function importTotalShouldBePresent() { - $this->assertXPathContentContains('//td', 'Import total'); - } + /** @test */ + public function importTotalShouldBePresent() { + $this->assertXPathContentContains('//td', 'Import total'); + } - /** @test */ - public function downloadLinkShouldBePresent() { - $this->assertXPath('//a[contains(@href, "run-log/download/id/29")]'); - } + /** @test */ + public function downloadLinkShouldBePresent() { + $this->assertXPath('//a[contains(@href, "run-log/download/id/29")]'); + } - /** @test */ - public function vendrediShouldBePresent() { - $this->assertXPathContentContains('//td', 'vendredi'); - } + /** @test */ + public function vendrediShouldBePresent() { + $this->assertXPathContentContains('//td', 'vendredi'); + } } @@ -852,9 +854,9 @@ class Cosmo_IntegrationControllerClearActionPostTest extends CosmoControllerTest $this->_file_system = $this->mock() ->whenCalled('glob') ->willDo(function($path) - { - return [substr($path, 0, strlen($path) - 1) . 'one_file.t']; - }) + { + return [substr($path, 0, strlen($path) - 1) . 'one_file.t']; + }) ->whenCalled('is_file')->answers(true) ->whenCalled('unlink')->answers(true); @@ -934,3 +936,176 @@ class Cosmo_IntegrationControllerClearActionPostTest extends CosmoControllerTest $this->assertFlashMessengerContentContains('Exemplaires vidé'); } } + + + + +abstract class Cosmo_IntegrationControllerCorruptedIntBibTest extends CosmoControllerTestCase { + + public function setUp() { + parent::setUp(); + + $library = + $this->fixture(Class_Bib::class, + ['id' => 19, + 'libelle' => 'Bokeh Testing Library']); + + $this->fixture(Class_CodifAnnexe::class, + ['id' => 888834, + 'id_origine' => 'TESTING', + 'code' => 'TESTING', + 'id_bib' => 19, + 'bib' => $library]); + + $profil = $this->fixture(Class_IntProfilDonnees::class, + ['id' => 1, + 'type_fichier' => 1]); + + $integration_2014 = + $this->fixture(Class_Cosmogramme_Integration::class, + ['id' => 29, + 'traite' => 'non', + 'date_transfert' => '2014-11-14', + 'type_operation' => 2, + 'fichier' => 'integre0000.pan', + 'pointeur_reprise' => 0, + 'nb_erreurs' => 0, + 'nb_warnings' => 0, + 'profil_donnees' => $profil]); + + $integration_2023 = + $this->fixture(Class_Cosmogramme_Integration::class, + ['id' => 34, + 'id_bib' => 19, + 'bib' => $library, + 'traite' => 'non', + 'date_transfert' => '2023-04-26', + 'type_operation' => 2, + 'fichier' => 'integre0001.pan', + 'pointeur_reprise' => 0, + 'nb_erreurs' => 0, + 'nb_warnings' => 0, + 'profil_donnees' => $profil]); + + $testing_lib = + $this->fixture(Class_IntBib::class, + ['id' => 19, + 'id_bib' => 19, + 'bib' => $library, + 'nom_court' => 'Testing library', + 'planif_mode' => 'r', + 'planif_jours' => '0010011', + 'integrations' => [$integration_2014, $integration_2023]]); + + $this->fixture(Class_IntMajAuto::class, + ['id' => 4, + 'int_bib' => $testing_lib, + 'libelle' => 'total', + 'profil_donnees' => $profil, + 'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT, + 'nom_fichier' => 'funky/gg/[DATE]_records_no_extension', + 'taille_min_import_total' => 0]); + + $this->fixture(Class_IntMajAuto::class, + ['id' => 5, + 'int_bib' => $testing_lib, + 'libelle' => 'inc', + 'profil_donnees' => $profil, + 'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT, + 'nom_fichier' => 'funky/gg/[DATE]_records_no_extension', + 'taille_min_import_total' => 0]); + } +} + + + + +class Cosmo_IntegrationControllerDashboardActionTest + extends Cosmo_IntegrationControllerCorruptedIntBibTest { + + + public function setUp() { + parent::setUp(); + $this->dispatch('/cosmo/integration/dashboard/id/19'); + } + + + /** @test */ + public function pageShouldContainsDeleteButton() { + $this->assertXPath('//input[@type="button"][@value="Supprimer l\'intégration"][@onclick="if (confirm(\'Êtes-vous sûrs de vouloir supprimer cette intégration et tous les éléments listés ci-dessus ?\')) document.location=\'/cosmo/integration/delete/id/19\'"]'); + } + + + /** @test */ + public function pageShouldContainsBackButton() { + $this->assertXPath('//input[@type="button"][@value="Retour"]'); + } + + + public function tablesContent() : array { + return + [ + ['//table//tr[1]/td[1]', '19'], + ['//table//tr[1]/td[2]', 'Bokeh Testing Library'], + + ['//table//tr[1]/td[1]', '29'], + ['//table//tr[1]/td[2]', 'total'], + ['//table//tr[1]/td[3]', '2014'], + ['//table//tr[2]/td[1]', '5'], + ['//table//tr[2]/td[2]', 'inc'], + ['//table//tr[2]/td[3]', '2023'], + + ['//table//tr[1]/td[3]', 'TESTING'], + + ]; + } + + + /** + * @test + * @dataProvider tablesContent + */ + public function tablesShouldContainsExpectedData($table_xpath, $table_content) { + $this->assertXPathContentContains($table_xpath, $table_content, $this->_response->getBody()); + } +} + + + + +class Cosmo_IntegrationControllerDeleteIntegrationActionTest extends Cosmo_IntegrationControllerCorruptedIntBibTest { + + public function setUp() { + parent::setUp(); + + $this->fixture(Class_Exemplaire::class, + ['id' => 8909, + 'id_bib' => 19]); + + $this->dispatch('/cosmo/integration/delete/id/19'); + } + + + /** @test */ + public function shouldRedirectToCosmoIndex() { + $this->assertRedirectTo('/cosmo/index/index'); + } + + + /** @test */ + public function intBib19ShouldHaveBeenDeleted() { + $this->assertNull(Class_IntBib::find(19)); + } + + + /** @test */ + public function item8909ShouldHaveBeenDeleted() { + $this->assertNull(Class_Exemplaire::find(8909)); + } + + + /** @test */ + public function libraryShouldHaveVisibilitySetToNoData() { + $this->assertEquals(1, Class_Bib::find(19)->getVisibilite()); + } +} diff --git a/cosmogramme/css/main.css b/cosmogramme/css/main.css index 0fc0354550f9d86736d9f03cbf0ae479a6f8c9b3..4bcd4411146d01c84fcce07ea346755f368ac1d1 100644 --- a/cosmogramme/css/main.css +++ b/cosmogramme/css/main.css @@ -292,7 +292,6 @@ a:visited.liste{color:#003687;font-weight:bold;text-decoration:none;font-size:10 a:hover.liste{color:#B73901;font-weight:bold;text-decoration:none;font-size:10pt;} table.tablesorter { - float: left; width: 95%; } diff --git a/library/Class/Bib.php b/library/Class/Bib.php index 780d919ad38227a7d0a5b80690f34222786f7a52..ed60bdb21c6f902046d47b241ee8c61187045918 100644 --- a/library/Class/Bib.php +++ b/library/Class/Bib.php @@ -668,10 +668,6 @@ class Class_Bib extends Storm_Model_Abstract { public function getAllStatus() { return $this->statut_bib; - $status= []; - foreach ($this->statut_bib as $statut) - $status[$statut]=$statut; - return $status; } diff --git a/library/Class/Cosmogramme/Integration.php b/library/Class/Cosmogramme/Integration.php index 932641d4655b01aa0dfcc3a1da48c3c3d1ce3131..3912ccde99e2f62a4d9be3fdf90f3023b1a004f5 100644 --- a/library/Class/Cosmogramme/Integration.php +++ b/library/Class/Cosmogramme/Integration.php @@ -223,4 +223,11 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract { $this->getTypeDoc(), $this->getNomFichier()]; } + + + public function getLibraryLabel() : string { + return ($lib = $this->getBib()) + ? $lib->getLabel() + : ''; + } } diff --git a/library/Class/TableDescription/CodifAnnexe.php b/library/Class/TableDescription/CodifAnnexe.php new file mode 100644 index 0000000000000000000000000000000000000000..d70917c57db566f46d9d7e74ff3355875c7259fd --- /dev/null +++ b/library/Class/TableDescription/CodifAnnexe.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_TableDescription_CodifAnnexe extends Class_TableDescription { + public function init() { + $this->addColumn($this->_('Id'), 'id_annexe') + ->addColumn($this->_('Id origine'), 'id_origine') + ->addColumn($this->_('Code'), 'code') + ->addColumn($this->_('Libelle'), 'libelle') + ->addColumn($this->_('Visible'), fn($codif) => $codif->isVisible() ? $this->_('oui') : $this->_('non')) + ->addColumn($this->_('ID bibliothèque Bokeh'), 'id_bib') + ->addColumn($this->_('Libellé bibliothèque Bokeh'), fn($codif) => $codif->getLibraryLabel()); + } +} diff --git a/library/Class/TableDescription/CosmoIntMajAuto.php b/library/Class/TableDescription/CosmoIntMajAuto.php new file mode 100644 index 0000000000000000000000000000000000000000..3dc3a48649046aec0a7f3da2d7d83c8feb888dbf --- /dev/null +++ b/library/Class/TableDescription/CosmoIntMajAuto.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_TableDescription_CosmoIntMajAuto extends Class_TableDescription { + public function init() { + $this->addColumn($this->_('Id'), 'id_prog') + ->addColumn($this->_('Libelle'), 'libelle') + ->addColumn($this->_('Fichier'), 'nom_fichier') + ->addColumn($this->_('ID bibliothèque Bokeh'), 'id_bib') + ->addColumn($this->_('Libelle bibliothèque Bokeh'), fn($int_maj_auto) => $int_maj_auto->getLibraryLabel()); + } +} diff --git a/library/Class/TableDescription/CosmoIntegration.php b/library/Class/TableDescription/CosmoIntegration.php new file mode 100644 index 0000000000000000000000000000000000000000..8df5417c37bb3a876344871172097dea1c95fda8 --- /dev/null +++ b/library/Class/TableDescription/CosmoIntegration.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_TableDescription_CosmoIntegration extends Class_TableDescription { + public function init() { + $this->addColumn($this->_('Id'), 'id') + ->addColumn($this->_('Fichier'), 'nom_fichier') + ->addColumn($this->_('Date du transfert'), 'date_transfert') + ->addColumn($this->_('Temps de traitement'), 'temps_traitement') + ->addColumn($this->_('ID bibliothèque Bokeh'), 'id_bib') + ->addColumn($this->_('Libellé bibliothèque Bokeh'), fn($integration) => $integration->getLibraryLabel()); + } +} diff --git a/library/Class/TableDescription/IntBib.php b/library/Class/TableDescription/IntBib.php new file mode 100644 index 0000000000000000000000000000000000000000..f24afa21aee6f91e09d141e25a44e89c04dc6f14 --- /dev/null +++ b/library/Class/TableDescription/IntBib.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_TableDescription_IntBib extends Class_TableDescription { + public function init() { + $this->addColumn($this->_('Id'), 'id_bib') + ->addColumn($this->_('Libelle'), 'nom_court') + ->addColumn($this->_('Email'), 'mail') + ->addColumn($this->_('SIGB'), fn($lib) => Class_IntBib::getSigbLabel($lib->getSigb())) + ->addColumn($this->_('Comm Params'), fn($lib) => json_encode($lib->getCommParamsAsArray(), + JSON_PRETTY_PRINT)) + ->addColumn($this->_('ID bibliothèque Bokeh'), 'id_bib') + ->addColumn($this->_('Libellé bibliothèque Bokeh'), fn($lib) => $lib->getLabel()); + } +} diff --git a/library/Class/TableDescription/Library.php b/library/Class/TableDescription/Library.php new file mode 100644 index 0000000000000000000000000000000000000000..0b1d6b62ae4736eccd6fa0b4123edf08fd13362c --- /dev/null +++ b/library/Class/TableDescription/Library.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_TableDescription_Library extends Class_TableDescription { + public function init() { + $this->addColumn($this->_('Id'), 'id_site') + ->addColumn($this->_('Libelle'), 'libelle') + ->addColumn($this->_('Ville'), 'ville') + ->addColumn($this->_('Statut'), fn($lib) => $lib->getAllStatus()[$lib->getVisibilite()]) + ; + } +} diff --git a/library/ZendAfi/View/Helper/Cosmo/Index.php b/library/ZendAfi/View/Helper/Cosmo/Index.php index 0f6ef02542ab77662c066c2d2fedb4720d09c557..26a6a13adb9cf06b1d6387bc93ebea3c7ae7ee02 100644 --- a/library/ZendAfi/View/Helper/Cosmo/Index.php +++ b/library/ZendAfi/View/Helper/Cosmo/Index.php @@ -140,9 +140,15 @@ class ZendAfi_View_Helper_Cosmo_Index extends ZendAfi_View_Helper_BaseHelper { protected function _addNonNanookIntegrations($html) { foreach (Class_IntBib::findAllBy(['sigb not' => Class_IntBib::SIGB_NANOOK]) as $int_bib) - $html [] = $this->view->tagError($this->_('L\'integration %s a pour SIGB : %s .', - $int_bib->getNomCourt(), - Class_IntBib::getSigbLabel($int_bib->getSigb()))); + $html [] = $this->view->tagError($this->_('L\'integration %s a pour SIGB : %s . %s', + $int_bib->getNomCourt(), + Class_IntBib::getSigbLabel($int_bib->getSigb()), + $this->view->tagAnchor($this->view->url(['module' => 'cosmo', + 'controller' => 'integration', + 'action' => 'dashboard', + 'id' => $int_bib->getId()], + null, true), + $this->view->renderIcon('class fa fa-bug')))); $urls_server = []; foreach (Class_IntBib::findAllBy(['sigb' => Class_IntBib::SIGB_NANOOK]) as $int_bib) { diff --git a/library/ZendAfi/View/Helper/Cosmo/IntegrationDashboard.php b/library/ZendAfi/View/Helper/Cosmo/IntegrationDashboard.php new file mode 100644 index 0000000000000000000000000000000000000000..632c6fb2c11323ff42f0b946b32bbc75ab91ce83 --- /dev/null +++ b/library/ZendAfi/View/Helper/Cosmo/IntegrationDashboard.php @@ -0,0 +1,156 @@ +<?php +/** + * Copyright (c) 2012-2022, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_Cosmo_IntegrationDashboard extends ZendAfi_View_Helper_BaseHelper { + + + protected Class_IntBib $_integration_library; + + public function Cosmo_IntegrationDashboard(Class_IntBib $integration_library) : string { + $this->_integration_library = $integration_library; + + $html = [$this->_tag('h1', $this->view->titre)]; + $html = $this->_addData($html); + $html = $this->_addLibraryData($html); + $html = $this->_addCodifAnnexe($html); + $html = $this->_addCosmoIntegrations($html); + $html = $this->_addIntMajAuto($html); + + $html = $this->_addButtons($html); + + return implode(BR, $html); + } + + + protected function _addButtons(array $html) : array { + $html [] = $this->view->cosmoButton($this->_('Supprimer l\'intégration'), + $this->view->url(['module' => 'cosmo', + 'controller' => 'integration', + 'action' => 'delete', + 'id' => $this->_integration_library->getId()], + null, true), + $this->_('Êtes-vous sûrs de vouloir supprimer cette intégration et tous les éléments listés ci-dessus ?')) + + . ' ' . $this->view->cosmoButton($this->_('Retour'), $this->view->url(['module' => 'cosmo', + 'controller' => 'index', + 'action' => 'index'], + null, true)); + + $html [] = BR; + + return $html; + } + + + protected function _addCosmoIntegrations(array $html) : array { + $cosmo_integrations = $this->_integration_library->getIntegrations(); + + $total = count($cosmo_integrations); + $to_show = array_slice($cosmo_integrations, 0, 20); + $count_shown = count($to_show); + + $html [] = $this->_div(['class' => 'analyse'], + $this->_('%d integrations cosmogramme à supprimer (%d affichées):', $total, $count_shown)); + + if ($cosmo_integrations) + $html [] = $this->view->renderTable(new Class_TableDescription_CosmoIntegration('cosmogramme_integrations'), + $to_show); + return $html; + } + + + protected function _addIntMajAuto(array $html) : array { + $int_maj_autos = $this->_integration_library->getIntMajAutos(); + + $total = count($int_maj_autos); + $to_show = array_slice($int_maj_autos, 0, 20); + $count_shown = count($to_show); + + $html [] = $this->_div(['class' => 'analyse'], + $this->_('%d programmations d\'integrations à supprimer (%d affichées) : ', + $total, + $count_shown)); + + if ($int_maj_autos) + $html [] = $this->view->renderTable(new Class_TableDescription_CosmoIntMajAuto('cosmogramme_int_maj_auto'), + $to_show); + return $html; + } + + + protected function _addCodifAnnexe(array $html) : array { + if ( ! $library = $this->_integration_library->getBib()) + return $html; + + $html [] = $this->_div(['class' => 'analyse'], + $this->_('Annexe liée à l\'intégration à supprimer:')); + + if ( ! $annexes = Class_CodifAnnexe::findAllBy(['id_bib' => $library->getId()])) { + $html [] = $this->_tagNotice($this->_('Aucune annexe n\'est rattachée à la bibliothèque')); + return $html; + } + + $html [] = $this->view->renderTable(new Class_TableDescription_CodifAnnexe('codif_annexes'), + $annexes); + + return $html; + } + + + protected function _addData(array $html) : array { + $html [] = $this->_div(['class' => 'analyse'], + $this->_('Détails de l\'intégration à supprimer :')); + + $html [] = $this->view->renderTable(new Class_TableDescription_IntBib('int_bibs'), + [$this->_integration_library]); + + return $html; + } + + + protected function _addLibraryData(array $html) : array { + $html [] = $this->_div(['class' => 'analyse'], + $this->_('Détails de la bibliothèque qui sera mise à jour :')); + + if ( ! $library = $this->_integration_library->getBib()) + return $html; + + $html [] = $this->view->renderTable(new Class_TableDescription_Library('libraries'), + [$library]); + + + $html [] = $this->_tagError($this->_('Le status de la bibliothèque %s sera changé de %s à %s.', + $library->getLibelle(), + $library->getAllStatus()[$library->getVisibilite()], + $library->getAllStatus()[Class_Bib::V_NODATA])); + + $count_items = Class_Exemplaire::countBy(['id_bib' => $library->getId()]); + + $html [] = $count_items > 0 + ? $this->_tagError($this->_('Nombres d\'exemplaires rattachées à la bibliothèque qui seront supprimés: %s', + $count_items)) + : $this->_tagNotice($this->_('Aucun exemplaire n\'est rattaché à la bibliothèque')); + + + return $html; + } +}