Skip to content
Snippets Groups Projects

Dev#16866 hide session

Merged Ghislain Loas requested to merge dev#16866_hide_session into WIP
Compare and
+ 307
38
Preferences
Compare changes
Files
@@ -21,6 +21,7 @@
class Admin_FormationController extends ZendAfi_Controller_Action {
use Trait_Translator;
public function getRessourceDefinitions() {
return [
'model' => [
@@ -41,6 +42,19 @@ class Admin_FormationController extends ZendAfi_Controller_Action {
'after_add' => function($formation) { $this->_redirect('/admin/session-formation/add/formation_id/' . $formation->getId());} ];
}
protected function setYearsForCombo() {
$years = Class_SessionFormation::getYears();
$current_year = Class_SessionFormation::getCurrentYear();
if (empty($years))
$years[$current_year]=$current_year;
$this->view->years = $years;
return $this->view->selected_year = $this->_getParam('year',
in_array($current_year, $this->view->years) ?
$current_year:reset($years));
}
public function indexAction() {
if ($this->_request->isPost()) {
@@ -50,17 +64,12 @@ class Admin_FormationController extends ZendAfi_Controller_Action {
$this->view->titre = 'Mise à jour des formations';
$formations_by_year = Class_Formation::indexByYear(Class_Formation::findAllBy(['order' => 'id desc']), true);
$years = array_keys($formations_by_year);
$this->view->years = array_combine($years, $years);
$this->view->selected_year = $this->_getParam('year', end($years));
$this->view->formations = array_filter($formations_by_year[$this->view->selected_year],
$this->view->formations = array_filter(Class_Formation::findAllBy(['order' => 'id desc']),
function($f) {return !$f->hasSessions();});
$sessions = Class_SessionFormation::findAllBy(['where' => 'left(date_debut, 4)="'.$this->view->selected_year.'"',
'order' => 'date_debut']);
$this->view->sessions = $sessions;
$this->setYearsForCombo();
$this->view->sessions = Class_SessionFormation::getAllSessionsForYear($this->view->selected_year);
$this->_setParam('year', $this->view->selected_year);
}
@@ -68,7 +77,6 @@ class Admin_FormationController extends ZendAfi_Controller_Action {
public function getAction() {
$this->_helper->viewRenderer->setNoRender();
$this->getResponse()->setHeader('Content-Type', 'application/json; charset=utf-8');
$formations_years = Class_Formation::indexByYear(
Class_Formation::findAllBy(['order' => 'libelle']),
true);