Skip to content
Snippets Groups Projects

Hotline 6.47

Merged Ghislain Loas requested to merge hotline_6.47 into master
Compare and
+ 900
139
Preferences
Compare changes
Files
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Cosmo_EmplacementController extends Zend_Controller_Action {
public function preDispatch() {
$this->cosmoPath = $this->view->cosmoPath = new CosmoPaths();
}
public function indexAction() {
$this->view->models = Class_CodifEmplacement::findAllBy(['order' => 'libelle']);
$this->view->currentId = $this->_getParam('id');
}
public function addAction() {
$this->view->model = Class_CodifEmplacement::newInstance([
'libelle' => '** nouvel emplacement **',
'regles' => '995$k/R',
'ne_pas_afficher' => 0]);
}
public function validateAction() {
if (!$this->_request->isPost()) {
$this->_gotoIndex();
return;
}
if (!$model = Class_CodifEmplacement::find($this->_getParam('id')))
$model = Class_CodifEmplacement::newInstance();
$model
->setLibelle($this->_getParam('libelle'))
->setRegles($this->_getParam('regles'))
->setNePasAfficher($this->_getParam('ne_pas_afficher'));
if (!$model->isValid()) {
$this->view->model = $model;
$this->view->errors = $model->getErrors();
$this->render('add');
return;
}
$model->save();
$this->_gotoIndex($model->getId());
}
public function deleteAction() {
if ($model = Class_CodifEmplacement::find($this->_getParam('id')))
$model->delete();
$this->_gotoIndex();
}
protected function _gotoIndex($id=null) {
$this->_redirect($this->view->url([
'module' => 'cosmo',
'controller' => 'emplacement',
'action' => 'index',
'id' => $id
], null, true),
['prependBase' => false]);
}
}
?>
\ No newline at end of file