diff --git a/application/modules/opac/controllers/FormationsController.php b/application/modules/opac/controllers/FormationsController.php index 1dc3e46be8a05ace56538d301507c892ab7a8bb9..a2e0e04dff8185efb677ebdb65902e25dbf90156 100644 --- a/application/modules/opac/controllers/FormationsController.php +++ b/application/modules/opac/controllers/FormationsController.php @@ -53,4 +53,10 @@ class FormationsController extends ZendAfi_Controller_Action { $this->view->titre = $this->_('Mes inscriptions en cours'); $this->view->sessions = Class_SessionFormation::findAllRegistered($this->_user); } + + + public function doneAction() { + $this->view->titre = $this->_('Mes formations suivies'); + $this->view->sessions = Class_SessionFormation::findAllDone($this->_user); + } } \ No newline at end of file diff --git a/application/modules/opac/views/scripts/formations/done.phtml b/application/modules/opac/views/scripts/formations/done.phtml new file mode 100644 index 0000000000000000000000000000000000000000..5792b31b0066ddf54134fc5f79d2fc1e73a481ce --- /dev/null +++ b/application/modules/opac/views/scripts/formations/done.phtml @@ -0,0 +1,29 @@ +<?php +$this->openBoite($this->titre); + +$details_link = $this->url(['action' => 'detail-session', + 'id' => null]); + +$current_link = $this->url(); + +echo $this->tagModelTable( + $this->sessions, + [$this->_('Formation'), + $this->_('Date'), + $this->_('Lieu')], + ['libelle_formation', + 'date_debut_texte', + 'libelle_lieu'], + [function($model) use($details_link, $current_link) { + return $this->modelActions($model, + [['url' => $details_link . '/id/%s?retour=' . $current_link, + 'icon' => 'view', + 'label' => $this->_('Details de la session %s', + $model->getLabel())]]); + }], + 'done_sessions' +); + +$this->closeBoite(); + +echo $this->abonne_RetourFiche(); diff --git a/library/Class/SessionFormation.php b/library/Class/SessionFormation.php index 9d3c020902f1340a2608ff8775db0adb3a56002b..77aae35fd79e2e094d77bd59a0b2f63ad99ae800 100644 --- a/library/Class/SessionFormation.php +++ b/library/Class/SessionFormation.php @@ -25,15 +25,27 @@ class SessionFormationLoader extends Storm_Model_Loader { return []; return (new Storm_Model_Collection($user->getSessionFormations())) - ->reject(function($session) { return $session->alreadyStarted(); }) + ->reject('alreadyStarted') ->getArrayCopy(); } + public function findAllDone($user) { + if(!$user) + return []; + + return (new Storm_Model_Collection($user->getSessionFormations())) + ->select('alreadyStarted') + ->getArrayCopy(); + } + + public function getAllSessionsForYear($year) { return Class_SessionFormation::findAllBy(['where' => 'left(date_debut, 4)="'.$year.'"', 'order' => 'date_debut']); } + + public function getYears() { $sessions = Class_SessionFormation::findAllBy(['order' => 'id desc']); $years = []; @@ -44,10 +56,10 @@ class SessionFormationLoader extends Storm_Model_Loader { return $years; } + public function getCurrentYear() { return self::getCurrentYear(); } - } diff --git a/scripts/emacs/phafi-mode.el b/scripts/emacs/phafi-mode.el index 155f20cff467bbc49690b67616948e692985ef32..4a34da8c36cee1618b8d81aee470071fdbfa0441 100644 --- a/scripts/emacs/phafi-mode.el +++ b/scripts/emacs/phafi-mode.el @@ -50,7 +50,6 @@ (require 'phpunit) (require 'auto-complete-autoloads) (require 'auto-complete) - (require 'org-link-minor-mode) (require 'gtags) (add-hook 'gtags-mode-hook @@ -73,7 +72,6 @@ ) (auto-complete-mode t) (subword-mode t) - (org-link-minor-mode t) (gtags-mode t) (setq ag-highlight-search t) (setq ag-arguments (list "--smart-case" diff --git a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php index 1481c1e72350dc6290a22847e57ccd7749c9b856..bd92428b315a7cd628a915f86f590dbeb19b89b8 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php @@ -177,7 +177,7 @@ abstract class AbstractAbonneControllerFormationsTestCase 'nom' => 'Cerisier', 'prenom' => 'Christophe', 'mail' => 'cc@bokeh.fr']) - ]]); + ]]); $this->_learn_python = $this->fixture('Class_Formation', ['id' => 12, @@ -204,13 +204,13 @@ class AbonneControllerFormationsListWithLearnJavaNotVisibleTest extends Abstract } - /** @test */ + /** @test */ function noH2ShouldContainsLearnJava() { $this->assertNotXPathContentContains('//h2', 'Learn Java'); } - /** @test */ + /** @test */ function sessionMarsShouldNotBeVisible() { $this->assertNotXPathContentContains('//tbody//tr//td', '1 mars 2014'); } @@ -230,7 +230,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte $this->dispatch('/opac/formations', true); $this->assertXPathContentContains('//h2', 'Learn Java',$this->response->getBody()); } - /** @test */ + /** @test */ function noH2ShouldContainsLearnSmalltalk() { $this->_learn_smalltalk->hide()->save(); $this->dispatch('/opac/formations', true); @@ -238,7 +238,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte } - /** @test */ + /** @test */ function sessionJuilletShouldNotBeVisibleIfParentTrainingIsHidden() { $this->_learn_smalltalk->hide()->save(); $this->dispatch('/opac/formations', true); @@ -246,7 +246,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte } - /** @test */ + /** @test */ function sessionJuilletShouldNotBeVisibleIfHidden() { $this->_learn_smalltalk->show()->save(); $this->_session_smalltalk_juillet->hide()->save(); @@ -254,7 +254,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte $this->assertNotXPathContentContains('//tbody//tr//td', '11 juillet 2014'); } - /** @test */ + /** @test */ function sessionJuilletShouldBeVisibleIfShow() { $this->_learn_smalltalk->show()->save(); $this->_session_smalltalk_juillet->show()->save(); @@ -275,8 +275,8 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati ->setBarreNavOn(true) ->setLibelle('Mon compte') ->setParentProfil( - Class_Profil::newInstanceWithId(42, - ['cfg_modules' => ['abonne' => ['formations' => ['barre_nav' => 'Les formations']]]])); + Class_Profil::newInstanceWithId(42, + ['cfg_modules' => ['abonne' => ['formations' => ['barre_nav' => 'Les formations']]]])); $this->dispatch('/opac/formations', true); } @@ -336,7 +336,7 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati } - /** @test */ + /** @test */ function sessionSeptemberShouldBeSecond() { $this->assertXPathContentContains('//tbody//tr[2]//td', ' septembre 2014'); } @@ -349,85 +349,85 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ - function session10Juillet2014ShouldBeFirst() { - $this->assertXPathContentContains('//tbody//tr[1]//td', '10 juillet 2014'); - } + function session10Juillet2014ShouldBeFirst() { + $this->assertXPathContentContains('//tbody//tr[1]//td', '10 juillet 2014'); + } - /** @test */ - function session11Juillet2014ShouldSecond() { - $this->assertXPathContentContains('//tbody//tr[2]//td', '11 juillet 2014'); - } + /** @test */ + function session11Juillet2014ShouldSecond() { + $this->assertXPathContentContains('//tbody//tr[2]//td', '11 juillet 2014'); + } - /** @test */ - function session_fevrier_17_lieuBonlieuShouldBeDisplayed() { - $this->assertXPathContentContains('//tbody//tr//td', 'Bonlieu'); - } + /** @test */ + function session_fevrier_17_lieuBonlieuShouldBeDisplayed() { + $this->assertXPathContentContains('//tbody//tr//td', 'Bonlieu'); + } - /** @test */ - function session_fevrier_17_ShouldHaveLinkForInscrire() { - $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/inscrire-session/id/31")]', - "S'inscrire"); - } + /** @test */ + function session_fevrier_17_ShouldHaveLinkForInscrire() { + $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/inscrire-session/id/31")]', + "S'inscrire"); + } - /** @test */ - function session_fevrier_17_ShouldDisplayDateLimite15Fevrier() { - $this->assertXPathContentContains('//tbody//tr/td', - '20 janvier 2015'); - } + /** @test */ + function session_fevrier_17_ShouldDisplayDateLimite15Fevrier() { + $this->assertXPathContentContains('//tbody//tr/td', + '20 janvier 2015'); + } - /** @test */ - function session_fevrier_17_ShouldHaveLinkForDetailSessionFormation() { - $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "formations/detail-session/id/31")]', - 'Détails de la session'); - } + /** @test */ + function session_fevrier_17_ShouldHaveLinkForDetailSessionFormation() { + $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "formations/detail-session/id/31")]', + 'Détails de la session'); + } - /** @test */ - function session_mars_27_ShouldBeDisplayedUnderLearnJavaInFirstPosition() { - $this->assertXPathContentContains('//tbody//tr[1]', '1 mars 2014'); - } + /** @test */ + function session_mars_27_ShouldBeDisplayedUnderLearnJavaInFirstPosition() { + $this->assertXPathContentContains('//tbody//tr[1]', '1 mars 2014'); + } - /** @test */ - function session_septembre_java_ShouldBeAnnule() { - $this->assertXPathContentContains('//tr/td/span[@class="error"]', 'Annul'); - } + /** @test */ + function session_septembre_java_ShouldBeAnnule() { + $this->assertXPathContentContains('//tr/td/span[@class="error"]', 'Annul'); + } - /** @test */ - function session_python_juillet_ShouldHaveLinkForDesinscrire() { - $this->assertXPathContentContains('//tr//a[contains(@href, "abonne/desinscrire-session/id/121")]', - "Se désinscrire"); - } + /** @test */ + function session_python_juillet_ShouldHaveLinkForDesinscrire() { + $this->assertXPathContentContains('//tr//a[contains(@href, "abonne/desinscrire-session/id/121")]', + "Se désinscrire"); + } - /** @test */ - function boiteTitleShouldBeFormations() { - $this->assertXPathContentContains('//h1', 'Formations'); - } + /** @test */ + function boiteTitleShouldBeFormations() { + $this->assertXPathContentContains('//h1', 'Formations'); + } - /** - * @test - * @group pagetitles - */ - public function barreNavShouldContainsMonCompte() { - $this->assertXPathContentContains('//div[@class="barre_nav"]//span//a[contains(@href, "index/index/id_profil/2")]', - 'Mon compte'); - } + /** + * @test + * @group pagetitles + */ + public function barreNavShouldContainsMonCompte() { + $this->assertXPathContentContains('//div[@class="barre_nav"]//span//a[contains(@href, "index/index/id_profil/2")]', + 'Mon compte'); + } - /** @test */ - public function barreNavShouldContainsAccueilThatLinksToProfilOne() { - $this->assertXPathContentContains('//div[@class="barre_nav"]//a[contains(@href, "index/index/id_profil/1")]', - 'Accueil'); - } - } + /** @test */ + public function barreNavShouldContainsAccueilThatLinksToProfilOne() { + $this->assertXPathContentContains('//div[@class="barre_nav"]//a[contains(@href, "index/index/id_profil/1")]', + 'Accueil'); + } +} @@ -523,22 +523,66 @@ class AbonneControllerFormationsRegisteredActionTest - Class AbonneControllerFormationsFicheAbonneWithoutSufficientRigthsTest extends AbstractAbonneControllerFormationsTestCase { - /** @test */ - public function whenFormationsDisabledPageShouldNotContainsLinkToFormations() { - Class_AdminVar::getLoader() - ->newInstanceWithId('FORMATIONS') - ->setValeur('0'); - $this->dispatch('/opac/abonne/fiche'); - $this->assertNotXPath('//a[contains(@href, "formations")]'); - } +class AbonneControllerFormationsDoneActionTest + extends AbstractAbonneControllerFormationsTestCase { + public function setUp() { - /** @test */ - public function whenUserNotStagiairePageShouldNotContainsLinkToFormations() { - $this->_amadou->setUserGroups(array()); - $this->dispatch('/opac/abonne/fiche'); - $this->assertNotXPath('//a[contains(@href, "formations")]'); + parent::setUp(); + $this->_session_python_juillet->setDateDebut('2006-09-09')->assertSave(); + $this->dispatch('/formations/done', true); + } + + + /** @test */ + public function titleShouldBeMesInscriptionsEnCours() { + $this->assertXPathContentContains('//h1', 'Mes formations suivies'); + } + + + /** @test */ + public function learnPythonShouldBePresent() { + $this->assertXPathContentContains('//td', 'Learn Python'); + } + + + /** @test */ + public function dateShouldBePresent() { + $this->assertXPathContentContains('//td', '9 septembre 2006'); + } + + + /** @test */ + public function locationShouldBePresent() { + $this->assertXPathContentContains('//td', 'Bibliothèque des romains'); + } + + + /** @test */ + public function detailLinkShouldBePresent() { + $this->assertXPath('//a[contains(@href, "formations/detail-session/id/121")]'); + } +} + + + + +Class AbonneControllerFormationsFicheAbonneWithoutSufficientRigthsTest extends AbstractAbonneControllerFormationsTestCase { + /** @test */ + public function whenFormationsDisabledPageShouldNotContainsLinkToFormations() { + Class_AdminVar::getLoader() + ->newInstanceWithId('FORMATIONS') + ->setValeur('0'); + $this->dispatch('/opac/abonne/fiche'); + $this->assertNotXPath('//a[contains(@href, "formations")]'); + } + + + /** @test */ + public function whenUserNotStagiairePageShouldNotContainsLinkToFormations() { + $this->_amadou->setUserGroups(array()); + $this->dispatch('/opac/abonne/fiche'); + $this->assertNotXPath('//a[contains(@href, "formations")]'); } } @@ -1129,25 +1173,25 @@ Class AbonneControllerFormationsInformationsTest extends AbstractControllerTestC $current_user = $this->fixture('Class_Users', [ - 'id' => 1, - 'login' => 'log', - 'password' => 'pwd', - 'id_site' => 1, - 'idabon' => '00044958', - 'role_level' => 2, - 'user_groups' => [$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()] - ]); + 'id' => 1, + 'login' => 'log', + 'password' => 'pwd', + 'id_site' => 1, + 'idabon' => '00044958', + 'role_level' => 2, + 'user_groups' => [$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()] + ]); ZendAfi_Auth::getInstance()->logUser($current_user); $session_full = $this->fixture('Class_SessionFormation', - ['id' => 1, - 'formation_id' => 1, - 'date_debut' => '2014-07-10', - 'date_limite_inscription' => '2014-07-01', - 'effectif_min' => 1, - 'effectif_max' => 1, - 'stagiaires' => [$current_user]]); + ['id' => 1, + 'formation_id' => 1, + 'date_debut' => '2014-07-10', + 'date_limite_inscription' => '2014-07-01', + 'effectif_min' => 1, + 'effectif_max' => 1, + 'stagiaires' => [$current_user]]); $session_canceled = $this->fixture('Class_SessionFormation', ['id' => 1, @@ -1168,17 +1212,17 @@ Class AbonneControllerFormationsInformationsTest extends AbstractControllerTestC 'stagiaires' => []]); $formation = $this->fixture('Class_Formation', - ['id' => 1, - 'libelle' => 'Farming cerths', - 'sessions' => [$session_full, - $session_canceled, - $session_subscription_exhausted]]); + ['id' => 1, + 'libelle' => 'Farming cerths', + 'sessions' => [$session_full, + $session_canceled, + $session_subscription_exhausted]]); $current_user->setSessionFormationInscriptions([$this->fixture('Class_SessionFormationInscription', - ['id' => 1, - 'stagiaire' => $current_user, - 'session_formation' => $formation])]); + ['id' => 1, + 'stagiaire' => $current_user, + 'session_formation' => $formation])]); $this->dispatch('/opac/formations', true); } @@ -1209,5 +1253,4 @@ Class AbonneControllerFormationsInformationsTest extends AbstractControllerTestC $this->assertXPathContentContains('//tbody//tr/td/span', 'Date de limite d\'inscription:'); } -} -?> \ No newline at end of file +} \ No newline at end of file