Commit 242057ab authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge branch...

Merge branch 'dev#77660_525_commande_bdp_yonne_module_d_aide_a_la_planification_des_echanges_v1_admin_menu_admin_var_vue_avec_filtresrecherche_formulaire_entree_mon_compte_usager' into 'master'

dev #77660 : rendez-vous management

See merge request !3080
parents 99bd4faf 3f8811e0
Pipeline #6701 passed with stage
in 33 minutes and 36 seconds
- ticket #77660 : Administration : ajout d'un module de gestion des rendez-vous
\ No newline at end of file
<?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 Admin_RendezVousController extends ZendAfi_Controller_Action {
public function getPlugins() {
return ['ZendAfi_Controller_Plugin_ResourceDefinition_RendezVous',
'ZendAfi_Controller_Plugin_Manager_RendezVous'];
}
public function indexAction() {
if (!Class_UserGroup::find($this->_request->getParam('group_id', 0))) {
$this->_helper->notify($this->_('Liste des rendez-vous impossible : Agenda inconnu'));
return $this->_redirect($this->view->url(['module' => 'admin',
'controller' => 'usergroup-agenda',
'action' => 'index'], null, true));
}
parent::indexAction();
}
}
<?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 Admin_UsergroupAgendaController extends ZendAfi_Controller_Action {
public function getPlugins() {
return ['ZendAfi_Controller_Plugin_ResourceDefinition_UsergroupAgenda',
'ZendAfi_Controller_Plugin_Manager_UsergroupAgenda'];
}
}
<?php
echo $this->renderForm($this->form);
<?php
echo $this->button_New((new Class_Entity())
->setText($this->_('Ajouter un rendez-vous')));
echo $this->button_Back((new Class_Entity())
->setText($this->_('Retour aux agendas'))
->setUrl($this->url(['module' => 'admin',
'controller' => 'usergroup-agenda'], null, true)));
$description = (new Class_TableDescription('rendez-vous'))
->addColumn($this->_('Date'), 'date')
->addColumn($this->_('Heure de début'), 'formatted_begin_time')
->addColumn($this->_('Heure de fin'), 'formatted_end_time')
->addColumn($this->_('Lieu'), 'location_label')
->addRowAction(function($model) { return $this->renderPluginsActions($model); });
echo $this->renderTable($description, $this->rendezvous);
<?php
echo $this->searchRendezVous($this->search, $this->rendezvous);
<?php
echo $this->button_New((new Class_Entity())
->setText($this->_('Créer un agenda')));
echo $this->button((new Class_Entity())
->setText($this->_('Tous les rendez-vous'))
->setUrl($this->url(['module' => 'admin',
'controller' => 'usergroup-agenda',
'action' => 'all'], null, true))
->setImage($this->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons',
'test'))));
$description = (new Class_TableDescription('agendas'))
->addColumn($this->_('Libellé'), 'libelle')
->addRowAction(function($model) { return $this->renderPluginsActions($model); });
echo $this->renderTable($description, $this->groups);
<?php
$actions = function($model) {
return $this->renderModelActions($model,
[['url' => '#',
'icon' => 'add_user',
'label' => $this->_('Ajouter "%s" comme destinataire',
$model->getNomComplet()),
'anchorOptions' => ['class' => 'user_add_action',
'data-userid' => $model->getId(),
'data-username' => $model->getNomComplet()]]
]);
};
echo $this->tag('div', $this->Admin_SearchUsers($this->users, $this->total, $this->form,
$this->page, $this->params, $actions),
['class' => 'modules']);
......@@ -1395,4 +1395,13 @@ class AbonneController extends ZendAfi_Controller_Action {
return $this->_redirectToReferer();
}
public function rendezVousAction() {
if (!Class_AdminVar::isRendezVousEnabled())
return $this->_redirect('/abonne/fiche');
$this->view->titre = $this->_('Mes Rendez-vous');
$this->view->user_rendez_vous = new Class_User_RendezVous($this->_user);
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ echo $this->abonne_Multimedia($this->user);
echo $this->abonne_SuggestionAchat($this->user);
echo $this->abonne_Settings($this->user);
echo $this->abonne_Cards($this->user);
echo $this->abonne_RendezVous($this->user);
echo $this->abonne_Deconnexion($this->user);
if ($this->error)
......
<?php
echo $this->openBoiteContent($this->titre)
. $this->abonne_RendezVousIndex($this->user_rendez_vous)
. $this->closeBoiteContent()
. $this->abonne_RetourFiche()
;
\ No newline at end of file
<?php
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
try {
$adapter->query(
'create table `rendez_vous` ('
. '`id` int(11) unsigned not null auto_increment,'
. '`group_id` int(11) not null,'
. '`location_id` int(11) null default null,'
. '`date` date not null,'
. '`begin_time` varchar(255) not null,'
. '`end_time` varchar(255) not null,'
. '`comment` varchar(255),'
. 'primary key (id),'
. 'key `group_id` (`group_id`),'
. 'key `location_id` (`location_id`),'
. 'key `date` (`date`),'
. 'key `comment` (`comment`)'
. ') engine=MyISAM default charset=utf8'
);
} catch(Exception $e) {}
......@@ -134,7 +134,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'lesocial' => $this->_getLeSocialVars(),
'static_map' => $this->_getStaticMapVars(),
'search' => $this->_getSearchVars(),
'file-manager' => $this->_getFileManagerVars()
'file-manager' => $this->_getFileManagerVars(),
'usergroup-agenda' => $this->_getRendezVousVars(),
];
}
......@@ -469,6 +470,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
}
protected function _getRendezVousVars() {
return ['ENABLE_RENDEZ_VOUS' => Class_AdminVar_Meta::newOnOff($this->_('Activer la gestion des rendez-vous'))];
}
public function allVarsValues() {
if (null !== $this->_all_vars_values)
return $this->_all_vars_values;
......@@ -1019,6 +1025,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
public function shouldKeepLastSigbRecord() {
return Class_AdminVar::isModuleEnabled('KEEP_LAST_SIGB_RECORD');
}
public function isRendezVousEnabled() {
return Class_AdminVar::isModuleEnabled('ENABLE_RENDEZ_VOUS');
}
}
......
<?php
/**
* Copyright (c) 2012, 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 RendezVousLoader extends Storm_Model_Loader {
use Trait_TimeSource;
public function findAllFutureByGroup($group) {
return $group
? Class_RendezVous::findAllBy(['group_id' => (int)$group->getId(),
'where' => 'date >= "' . $this->getTimeSource()->dateYmd() . '"'])
: [];
}
}
class Class_RendezVous extends Storm_Model_Abstract {
use Trait_Translator, Trait_TimeSource;
protected $_table_name = 'rendez_vous';
protected $_loader_class = 'RendezVousLoader';
protected $_belongs_to = ['agenda' => ['model' => 'Class_UserGroup',
'referenced_in' => 'group_id'],
'location' => ['model' => 'Class_Lieu',
'referenced_in' => 'location_id']];
protected $_default_attribute_values = ['group_id'=> null,
'location_id' => null,
'date' => null,
'begin_time' => null,
'end_time' => null,
'comment' => ''];
public function getLibelle() {
return $this->_('Le %s de %s à %s',
$this->getFormattedDate(),
$this->getFormattedBeginTime(),
$this->getFormattedEndTime());
}
public function getFormattedDate() {
return strftime('%A %d %B', strtotime($this->getDate()));
}
public function getFormattedBeginTime() {
return $this->getFormattedTime($this->getBeginTime());
}
public function getFormattedEndTime() {
return $this->getFormattedTime($this->getEndTime());
}
public function getFormattedTime($value) {
return str_replace(':', 'h', $value);
}
public function getLocationLabel() {
return $this->hasLocation()
? $this->getLocation()->getLibelle()
: '';
}
public function getAgendaLabel() {
return $this->hasAgenda()
? $this->getAgenda()->getLibelle()
: '';
}
public function validate() {
$this->check($this->hasAgenda(), $this->_('L\'agenda est obligatoire'));
$this->checkAttribute('date',
$this->hasDate()
&& (new ZendAfi_Validate_DateFormat())->isValid($this->getDate()),
$this->_('La date doit être au forma JJ/MM/AAAA'));
$this->_validateTime('begin_time', $this->_('L\'heure de début est obligatoire'));
$this->_validateTime('end_time', $this->_('L\'heure de fin est obligatoire'));
$this->checkAttribute('end_time', $this->getBeginTime() < $this->getEndTime(),
$this->_('L\'heure de fin doit être après l\'heure de début'));
}
protected function _validateTime($field, $message) {
$this->checkAttribute('begin_time', $this->_has($field), $message);
$this->checkAttribute($field,
$this->getTimeSource()->isValidHourMinutes($this->_get($field)),
$this->_('L\'heure doit être au format HH:mm'));
}
public function setDate($value) {
$this->_set('date', $this->_ensureDateFormat($value));
}
protected function _ensureDateFormat($value) {
if (!$value)
return null;
if (false === strpos($value, '/'))
return $value;
return implode('-', array_reverse(explode('/', $value)));
}
public function copy() {
$attributes = $this->_attributes;
unset($attributes['id']);
return (new static())->updateAttributes($attributes);
}
/**
* @param $other Class_RendezVous
* @return int -1 less, 0 equal, 1 greater
*/
public function compare($other) {
if (!$other)
return 0;
if (0 !== $date_comp = strnatcmp($this->getDate(), $other->getDate()))
return $date_comp;
if (0 !== $begin_comp = strnatcmp($this->getBeginTime(), $other->getBeginTime()))
return $begin_comp;
return strnatcmp($this->getEndTime(), $other->getEndTime());
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2014, 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_RendezVous_SearchCriteria extends Class_SearchCriteria {
protected $_model_class = 'Class_RendezVous';
public function __construct($params) {
$this->_criteria = [
new Class_RendezVous_SearchCriteria_User($params),
new Class_RendezVous_SearchCriteria_Comment($params),
new Class_RendezVous_SearchCriteria_Date($params),
new Class_RendezVous_SearchCriteria_Location($params),
new Class_RendezVous_SearchCriteria_Order($params),
];
}
}
<?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_RendezVous_SearchCriteria_Comment extends Class_SearchCriteria_Abstract {
protected
$_name = 'comment',
$_value = '';
public function __construct($params) {
parent::__construct($params);
$previous = $this->_value;
$this->_value = trim((new Zend_Filter_Alnum(true))->filter($this->_value));
$this->_element->setValue($this->_value);
if ($previous != $this->_value)
$this->_element->addError($this->_('Seuls les caractères alphanumériques sont autorisés'));
}
protected function buildElement() {
return new Zend_Form_Element_Text($this->getName(),
['label' => $this->_('Commentaire contient')]);
}
public function acceptSearchVisitor($visitor) {
if (!$this->_value)
return;
$visitor->addWhereParam('comment like "%' . $this->_value . '%"');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment