Commit b135dc7b by Julien Jorry

BIG UPDATE ON ADMIN LIST : add export on top + add createdAt and updatedAt…

BIG UPDATE ON ADMIN LIST : add export on top + add createdAt and updatedAt filter on different views with datepicker + add cotisation end of validity date instead of 'yes' in list + add free cotisation to manager in admin presta list view
parent e933d503
......@@ -19,7 +19,7 @@ sonata_admin:
layout: '@kohinos/bundles/SonataAdminBundle/standard_layout.html.twig'
#outer_list_rows_mosaic: '@kohinos/bundles/SonataAdminBundle/list_outer_rows_mosaic.html.twig'
# ajax: '@kohinos/bundles/SonataAdminBundle/ajax_layout.html.twig'
# list: '@kohinos/bundles/SonataAdminBundle/CRUD/list.html.twig'
list: '@kohinos/bundles/SonataAdminBundle/CRUD/list.html.twig'
# show: '@kohinos/bundles/SonataAdminBundle/CRUD/show.html.twig'
# show_compare: '@kohinos/bundles/SonataAdminBundle/CRUD/show_compare.html.twig'
# edit: '@kohinos/bundles/SonataAdminBundle/CRUD/edit.html.twig'
......
......@@ -6,6 +6,7 @@ twig:
- 'bootstrap_4_layout.html.twig'
- '@SonataFormatter/Form/formatter.html.twig'
- '@kohinos/rubrique/media_widgets.html.twig'
- '@kohinos/common/form/widget/datepicker.html.twig'
paths:
'%kernel.project_dir%/templates/themes/custom': kohinos
'%kernel.project_dir%/templates/themes/kohinos': kohinos
\ No newline at end of file
......@@ -9,6 +9,7 @@ use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\DoctrineORMAdminBundle\Filter\BooleanFilter;
use Sonata\Form\Type\BooleanType;
use Sonata\Form\Type\DateTimeRangePickerType;
use Sonata\Form\Type\EqualType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Security\Core\Security;
......@@ -66,6 +67,10 @@ class AchatMonnaieAConfirmerAdmin extends AbstractAdmin
'advanced_filter' => false,
'show_filter' => true,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
])
;
}
......
......@@ -23,6 +23,7 @@ use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter;
use Sonata\Form\Type\DateTimeRangePickerType;
use Sonata\UserBundle\Model\UserManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
......@@ -251,6 +252,14 @@ class AdherentAdmin extends AbstractAdmin
'show_filter' => true,
'advanced_filter' => false,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de création'
])
->add('updatedAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de mise à jour'
])
;
}
......@@ -367,7 +376,17 @@ class AdherentAdmin extends AbstractAdmin
'label' => 'Activé',
'editable' => true,
])
->addIdentifier('user.updatedAt', null, ['label' => 'Mis à jour'])
->add('user.createdAt', 'date', [
'pattern' => 'dd/MM/YYYY HH:mm',
'label' => 'Crée le',
])
->add('user.updatedAt', 'date', [
'pattern' => 'dd/MM/YYYY HH:mm',
'label' => 'Mis à jour le',
])
->add('_action', null, [
'actions' => ['edit' => []],
])
;
}
......
......@@ -7,6 +7,7 @@ use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\Form\Type\DateTimeRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType as SChoiceType;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatorInterface;
......@@ -139,6 +140,10 @@ class FluxAdmin extends AbstractAdmin
'advanced_filter' => false,
'show_filter' => true,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
])
;
}
......
......@@ -8,6 +8,7 @@ use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter;
use Sonata\Form\Type\DateTimeRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatorInterface;
......@@ -123,6 +124,10 @@ class OperationAdmin extends AbstractAdmin
return true;
},
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
])
;
}
......
......@@ -31,6 +31,7 @@ use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Object\Metadata;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\Form\Type\DateTimeRangePickerType;
use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter;
use Sonata\MediaBundle\Form\Type\MediaType;
use Sonata\MediaBundle\Provider\MediaProviderInterface;
......@@ -500,6 +501,14 @@ class PrestataireAdmin extends AbstractAdmin
'label' => 'Accepte e-mlc',
'advanced_filter' => false,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de création'
])
->add('updatedAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de mise à jour'
])
->add('typeprestataire', null, [
'label' => 'Type',
'advanced_filter' => false,
......@@ -518,31 +527,31 @@ class PrestataireAdmin extends AbstractAdmin
$expr = $em->getExpressionBuilder();
$a = $em->getRepository(CotisationAdherent::class)
->createQueryBuilder('c')
->select('a.id')
->leftJoin('c.expediteur', 'a')
->leftJoin('c.cotisationInfos', 'i')
->where('i.fin > :now')
->createQueryBuilder('ca')
->select('aa.id')
->leftJoin('ca.expediteur', 'aa')
->leftJoin('ca.cotisationInfos', 'ii')
->where('ii.fin > :now')
->getQuery()
->getDQL();
if (true === $value['value']) {
$queryBuilder
->leftJoin($alias . '.users', 'u')
->leftJoin('u.adherent', 'd')
->leftJoin($alias . '.users', 'uu')
->leftJoin('uu.adherent', 'dd')
->andWhere(
$expr->in(
'd.id',
'dd.id',
$a
)
);
} else {
$queryBuilder
->leftJoin($alias . '.users', 'u')
->leftJoin('u.adherent', 'd')
->leftJoin($alias . '.users', 'uu')
->leftJoin('uu.adherent', 'dd')
->andWhere(
$expr->notIn(
'd.id',
'dd.id',
$a
)
);
......@@ -655,6 +664,9 @@ class PrestataireAdmin extends AbstractAdmin
$actions['addfreecotisationpresta'] = [
'template' => '@kohinos/bundles/SonataAdminBundle/CRUD/list__action_addfreecotisationpresta.html.twig',
];
$actions['addfreecotisationadh'] = [
'template' => '@kohinos/bundles/SonataAdminBundle/CRUD/list__action_addfreecotisationadh.html.twig',
];
}
} else {
$actions = [
......@@ -669,6 +681,9 @@ class PrestataireAdmin extends AbstractAdmin
$actions['addfreecotisationpresta'] = [
'template' => '@kohinos/bundles/SonataAdminBundle/CRUD/list__action_addfreecotisationpresta.html.twig',
];
$actions['addfreecotisationadh'] = [
'template' => '@kohinos/bundles/SonataAdminBundle/CRUD/list__action_addfreecotisationadh.html.twig',
];
}
}
$listMapper
......@@ -699,7 +714,7 @@ class PrestataireAdmin extends AbstractAdmin
]
)
->add('users', null, [
'label' => 'Gestionnaires (Cotis. à jour ?)',
'label' => 'Gestionnaires [Cotisation à jour]',
'template' => '@kohinos/bundles/SonataAdminBundle/CRUD/list_presta_gestionnaires.html.twig',
])
->add('enabled', null, [
......@@ -708,9 +723,15 @@ class PrestataireAdmin extends AbstractAdmin
])
->add('acceptemlc', null, [
'label' => 'Accepte e-mlc',
'editable' => true,
])
->add('createdAt', 'date', [
'pattern' => 'dd/MM/YYYY HH:mm',
'label' => 'Crée le',
])
->add('updatedAt', null, [
'label' => 'Mis à jour',
->add('updatedAt', 'date', [
'pattern' => 'dd/MM/YYYY HH:mm',
'label' => 'Mis à jour le',
])
// You may also specify the actions you want to be displayed in the list
->add('_action', null, [
......@@ -723,7 +744,9 @@ class PrestataireAdmin extends AbstractAdmin
{
$collection->remove('delete');
$collection
->add('addfreecotisationpresta', $this->getRouterIdParameter() . '/addfreecotisationpresta');
->add('addfreecotisationpresta', $this->getRouterIdParameter() . '/addfreecotisationpresta')
->add('addfreecotisationadh', $this->getRouterIdParameter() . '/addfreecotisationadh')
;
}
public function getObjectMetadata($object)
......
......@@ -8,6 +8,7 @@ use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\DoctrineORMAdminBundle\Filter\StringFilter;
use Sonata\Form\Type\DateTimeRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
......@@ -103,6 +104,10 @@ class TransactionAdmin extends FluxAdmin
'advanced_filter' => false,
'show_filter' => true,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date'
])
;
}
......
......@@ -25,6 +25,7 @@ use Sonata\AdminBundle\Form\Type\ModelType;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\CoreBundle\Form\Type\DatePickerType;
use Sonata\Form\Type\DateTimeRangePickerType;
use Sonata\UserBundle\Admin\Model\UserAdmin as BaseUserAdmin;
use Sonata\UserBundle\Form\Type\SecurityRolesType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
......@@ -73,6 +74,7 @@ class UserAdmin extends BaseUserAdmin
'editable' => true,
])
->add('createdAt')
->add('lastLogin')
->add('_action', null, [
'label' => 'Actions',
'actions' => [
......@@ -98,6 +100,14 @@ class UserAdmin extends BaseUserAdmin
->add('username')
->add('email')
->add('groups')
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de création'
])
->add('lastLogin', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de dernière connexion'
])
;
}
......
......@@ -8,6 +8,55 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
class CRUDController extends Controller
{
// /**
// * @inheritdoc
// */
// public function exportAction(Request $request)
// {
// $this->admin->checkAccess('export');
// $format = $request->get('format');
// // // NEXT_MAJOR: remove the check
// // if (!$this->has('sonata.admin.admin_exporter')) {
// // @trigger_error(
// // 'Not registering the exporter bundle is deprecated since version 3.14. You must register it to be able to use the export action in 4.0.',
// // \E_USER_DEPRECATED
// // );
// // $allowedExportFormats = (array) $this->admin->getExportFormats();
// // $class = (string) $this->admin->getClass();
// // $filename = sprintf(
// // 'export_%s_%s.%s',
// // strtolower((string) substr($class, strripos($class, '\\') + 1)),
// // date('Y_m_d_H_i_s', strtotime('now')),
// // $format
// // );
// // $exporter = $this->get('sonata.admin.exporter');
// // } else {
// $adminExporter = $this->get('sonata.admin.admin_exporter');
// $allowedExportFormats = $adminExporter->getAvailableFormats($this->admin);
// $filename = $adminExporter->getExportFilename($this->admin, $format);
// $exporter = $this->get('sonata.exporter.exporter');
// // }
// if (!\in_array($format, $allowedExportFormats, true)) {
// throw new \RuntimeException(sprintf(
// 'Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`',
// $format,
// $this->admin->getClass(),
// implode(', ', $allowedExportFormats)
// ));
// }
// return $exporter->getResponse(
// $format,
// $filename,
// $this->admin->getDataSourceIterator()
// );
// }
public function deleteAction($id)
{
$request = $this->getRequest();
......
......@@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\CotisationAdherent;
use App\Entity\CotisationPrestataire;
use App\Entity\Prestataire;
use App\Enum\MoyenEnum;
......@@ -25,7 +26,57 @@ class PrestataireAdminController extends CRUDController
}
/**
* @param $id
* Ajouter une cotisation gratuite à l'adhérent
* @param Uuid $id Id du prestataire
* @return Response
*/
public function addfreecotisationadhAction($id): Response
{
$prestataire = $this->admin->getSubject();
if (!$prestataire) {
throw new NotFoundHttpException(sprintf('Impossible de trouver le prestataire avec l\'id: %s', $id));
}
$managers = $prestataire->getUsers();
if (count($managers) == 1) {
$manager = $managers[0];
if (null != $manager->getAdherent()) {
$cotisation = new CotisationAdherent();
$cotisation->setExpediteur($manager->getAdherent());
$now = new DateTime();
$cotisation->setRecu(true);
$cotisation->setReference('Cotisation gratuite');
// $cotisation->setOperateur(null);
$cotisation->setRole($this->getUser()->getGroups()[0]->__toString());
$mlcPrestataire = $this->em->getRepository(Prestataire::class)->findOneBy(['mlc' => true]);
$cotisation->setDestinataire($mlcPrestataire);
$cotisation->setMoyen(MoyenEnum::MOYEN_AUTRE);
$cotisation->setMontant(0);
$cotisation->getCotisationInfos()->setAnnee(date('Y'));
$cotisation->getCotisationInfos()->setDebut($now);
$cotisation->getCotisationInfos()->setFin(new DateTime('+ 1 year'));
$this->em->persist($cotisation);
$this->em->flush();
$this->addFlash('sonata_flash_success', sprintf('Cotisation gratuite ajouté au gestionnaire %s du prestataire %s', $manager->__toString(), $prestataire->__toString()));
} else {
$this->addFlash('sonata_flash_error', sprintf('Impossible d\ajouter une cotisation gratuite au gestionnaire %s du prestataire %s car il n\'a pas de compte adhérent !', $manager->getEmail(), $prestataire->__toString()));
}
} else {
$this->addFlash('sonata_flash_error', sprintf('Impossible d\ajouter une cotisation gratuite à tous les gestionnaires du prestataire %s !', $prestataire->__toString()));
}
return new RedirectResponse(
$this->admin->generateUrl('list', ['filter' => $this->admin->getFilterParameters()])
);
}
/**
* Ajouter une cotisation gratuite au prestataire
* @param Uuid $id Id du prestataire
* @return Response
*/
public function addfreecotisationprestaAction($id): Response
{
......
......@@ -40,7 +40,7 @@ class RequestListener
($user->isGranted('ROLE_PRESTATAIRE') &&
null != $this->session->get('_prestagere'))
) &&
!$this->cotisationUtils->isCotisationValid($user) &&
false === $this->cotisationUtils->isCotisationValid($user) &&
'cotisation_invalid' != $route
) {
$event->setResponse(new RedirectResponse($this->router->generate('cotisation_invalid')));
......
......@@ -210,17 +210,32 @@ class AppExtension extends AbstractExtension
return $this->em->getRepository(Prestataire::class)->findOneById($this->session->get('_prestagere')->getId());
}
public function isCotisationValid(?UserInterface $user = null): bool
/**
* isCotisationValid
* @param UserInterface|null $user
* @return boolean|date
*/
public function isCotisationValid(?UserInterface $user = null)
{
return $this->cotisationUtils->isCotisationValid($user);
}
public function isCotisationValidForPresta(?Prestataire $presta = null): bool
/**
* [isCotisationValidForPresta
* @param Prestataire|null $presta
* @return boolean|date
*/
public function isCotisationValidForPresta(?Prestataire $presta = null)
{
return $this->cotisationUtils->isCotisationValidForPresta($presta);
}
public function isCotisationValidForAdherent(?Adherent $adherent = null): bool
/**
* [isCotisationValidForAdherent
* @param Adherent|null $adherent
* @return boolean|date
*/
public function isCotisationValidForAdherent(?Adherent $adherent = null)
{
return $this->cotisationUtils->isCotisationValidForAdherent($adherent);
}
......
......@@ -63,7 +63,12 @@ class CotisationUtils
return $hasCotisationValidForPeriod;
}
public function isCotisationValidForPresta(?Prestataire $presta): bool
/**
* Is the Cotisation Valid For Presta ?
* @param Prestataire $presta
* @return boolean|date
*/
public function isCotisationValidForPresta(?Prestataire $presta)
{
$query = null;
if (null !== $presta) {
......@@ -73,7 +78,7 @@ class CotisationUtils
$cotisations = $query->getResult();
foreach ($cotisations as $cotisation) {
if ($cotisation->isRecu() && $cotisation->getCotisationInfos()->getFin() > new \DateTime('now')) {
return true;
return $cotisation->getCotisationInfos()->getFin();
}
}
}
......@@ -81,7 +86,12 @@ class CotisationUtils
return false;
}
public function isCotisationValidForAdherent(?Adherent $adherent): bool
/**
* Is the Cotisation Valid For Adherent
* @param Adherent $adherent
* @return boolean|date
*/
public function isCotisationValidForAdherent(?Adherent $adherent)
{
$query = null;
if (null !== $adherent) {
......@@ -91,7 +101,7 @@ class CotisationUtils
$cotisations = $query->getResult();
foreach ($cotisations as $cotisation) {
if ($cotisation->isRecu() && $cotisation->getCotisationInfos()->getFin() > new \DateTime('now')) {
return true;
return $cotisation->getCotisationInfos()->getFin();
}
}
}
......@@ -99,7 +109,12 @@ class CotisationUtils
return false;
}
public function isCotisationValid(?UserInterface $user): bool
/**
* Is Cotisation Valid
* @param UserInterface $user
* @return boolean|date
*/
public function isCotisationValid(?UserInterface $user)
{
$query = null;
if (null === $user && null != $this->security->getUser()) {
......@@ -119,7 +134,7 @@ class CotisationUtils
$cotisations = $query->getResult();
foreach ($cotisations as $cotisation) {
if ($cotisation->isRecu() && $cotisation->getCotisationInfos()->getFin() > new \DateTime('now')) {
return true;
return $cotisation->getCotisationInfos()->getFin();
}
}
}
......
......@@ -6,7 +6,7 @@
{% block blockcontent %}
{# @TODO : ajouter un KOH_BLOCK_ON_INVALID_COTISATION #}
{# Il est possible d'empêcher l'utilisation du compte s'il n'y a pas de cotisation valide! #}
{# {% if not isCotisationValid(app.user) %}
{# {% if false == isCotisationValid(app.user) %}
<div class='text-danger mb-3'>{{ 'Si vous souhaitez utiliser les fonctionnalités de votre compte, vous devez avoir une cotisation à jour !'|trans }}</div>
{% else %} #}
{% set form = getAchatMonnaieAdherentForm(app.user) %}
......
{% if not isCotisationValid(app.user) %}
{% if false == isCotisationValid(app.user) %}
<div class='text-danger mb-3'>{{ 'Si vous souhaitez utiliser les fonctionnalités de votre compte, vous devez avoir une cotisation valide !'|trans }}</div>
{% endif %}
......
......@@ -9,7 +9,7 @@
{% block blocksubtitle %}
{% endblock blocksubtitle %}
{% block blockcontent %}
{% if not isCotisationValid(app.user) %}
{% if false == isCotisationValid(app.user) %}
{% if cotisations|length > 0 %}
<div class='text-danger mb-3'>{{ 'Votre dernière cotisation est arrivée à expiration, veuillez cotiser de nouveau pour accéder aux fonctionnalités de votre compte !'|trans }}</div>
{% else %}
......@@ -27,7 +27,7 @@
</ul>
{% if ((app.user and is_granted('ROLE_ADHERENT') and app.user.adherent) or (app.user and is_granted('ROLE_PRESTATAIRE') and app.session.has('_prestagere'))) %}
{% if isCotisationValid(app.user) %}
{% if false != isCotisationValid(app.user) %}
<span class='btn btn-secondary disabled mt-2' disabled='disabled'>
{{ 'Votre cotisation est à jour'|trans }}
</span>
......
{% extends '@SonataAdmin/CRUD/base_list.html.twig' %}
{% block list_header %}
{% if admin.datagrid.results|length > 0 %}
<div class="box-footer">
<div class="form-inline clearfix">
{% if not app.request.isXmlHttpRequest %}
{# NEXT_MAJOR : remove this assignment #}
{% set export_formats = export_formats|default(admin.exportFormats) %}
<div class="pull-left">
{% if admin.hasRoute('export') and admin.hasAccess('export') and export_formats|length %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-share-square-o" aria-hidden="true"></i>
{{ "label_export_download"|trans({}, "SonataAdminBundle") }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{% for format in export_formats %}
<li>
{# NEXT_MAJOR: Remove completely next "<a>" element and uncomment the other one #}
<a href="{{ admin.generateUrl('export', sonata_pagination_parameters(admin, 0) + {'format' : format}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
{{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
</a>
{#
<a href="{{ admin.generateUrl('export', admin.datagrid.paginationparameters(0) + {'format' : format}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
{{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
</a>
#}
</li>
{% endfor %}
</ul>
</div>
</div>
{#
{% if block('pager_results') is not empty %}
&nbsp;-&nbsp;
{% endif %} #}
{% endif %}
<div class="pull-right">
{% include get_admin_template('pager_results', admin.code) %}
</div>
{% endif %}
</div>
</div>
{% endif %}
{% endblock %}
{% block list_footer %}
{% if admin.datagrid.results|length > 0 %}
<div class="box-footer">
<div class="form-inline clearfix">
{% if not app.request.isXmlHttpRequest %}
<div class="pull-left">
{% if admin.hasRoute('batch') and batchactions|length > 0 %}
{% block batch %}
<script>
{% block batch_javascript %}
jQuery(document).ready(function ($) {
// Toggle individual checkboxes when the batch checkbox is changed
$('#list_batch_checkbox').on('ifChanged change', function () {
var checkboxes = $(this)
.closest('table')
.find('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
;
if (Admin.get_config('USE_ICHECK')) {
checkboxes.iCheck($(this).is(':checked') ? 'check' : 'uncheck');
} else {
checkboxes.prop('checked', this.checked);
}
});
// Add a CSS class to rows when they are selected
$('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
.on('ifChanged change', function () {
$(this)
.closest('tr, div.sonata-ba-list-field-batch')
.toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'))
;
})
.trigger('ifChanged')
;
});
{% endblock %}
</script>
{% block batch_actions %}
<label class="checkbox" for="{{ admin.uniqid }}_all_elements">
<input type="checkbox" name="all_elements" id="{{ admin.uniqid }}_all_elements">
{{ 'all_elements'|trans({}, 'SonataAdminBundle') }}
{# NEXT_MAJOR: remove the attribute check and just use .countResults() #}
({{ attribute(admin.datagrid.pager, 'countResults') is defined ? admin.datagrid.pager.countResults() : admin.datagrid.pager.getNbResults() }})
</label>
<select name="action" style="width: auto; height: auto" class="form-control">
{% for action, options in batchactions %}
<option value="{{ action }}">{{ options.label|trans({}, options.translation_domain|default(admin.translationDomain)) }}</option>
{% endfor %}
</select>
{% endblock %}
<input type="submit" class="btn btn-small btn-primary" value="{{ 'btn_batch'|trans({}, 'SonataAdminBundle') }}">
{% endblock %}
{% endif %}
</div>
{# NEXT_MAJOR : remove this assignment #}
{% set export_formats = export_formats|default(admin.exportFormats) %}
<div class="pull-left ml-2">
{% if admin.hasRoute('export') and admin.hasAccess('export') and export_formats|length %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-share-square-o" aria-hidden="true"></i>
{{ "label_export_download"|trans({}, "SonataAdminBundle") }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{% for format in export_formats %}
<li>
{# NEXT_MAJOR: Remove completely next "<a>" element and uncomment the other one #}
<a href="{{ admin.generateUrl('export', sonata_pagination_parameters(admin, 0) + {'format' : format}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
{{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
</a>
{#
<a href="{{ admin.generateUrl('export', admin.datagrid.paginationparameters(0) + {'format' : format}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
{{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
</a>
#}
</li>
{% endfor %}
</ul>
</div>
{# {% if block('pager_results') is not empty %}
&nbsp;-&nbsp;
{% endif %} #}
{% endif %}
</div>
<div class="pull-right">
{% block pager_results %}
{% include get_admin_template('pager_results', admin.code) %}
{% endblock %}
</div>
{% endif %}
</div>
{% block pager_links %}
{% if admin.datagrid.pager.haveToPaginate() %}
<hr/>
{% include get_admin_template('pager_links', admin.code) %}
{% endif %}
{% endblock %}
</div>
{% endif %}
{% endblock %}
\ No newline at end of file
{% if false != isCotisationValidForPresta(object) and object.users|length == 1 and object.users[0].adherent is not null and false == isCotisationValidForAdherent(object.users[0].adherent) %}
<a class="btn btn-sm btn-default view_link" onclick="return confirm('Êtes-vous sûr de vouloir ajouter une cotisation gratuite au manager de ce prestataire ?')" href="{{ admin.generateObjectUrl('addfreecotisationadh', object) }}"><i class="fa fa-plus" aria-hidden="true"></i> Ajouter cotisation gratuite à l'adh.</a>
{% endif %}
\ No newline at end of file
{% if not isCotisationValidForPresta(object) %}
<a class="btn btn-sm btn-default view_link" onclick="return confirm('Êtes-vous sûr de vouloir ajouter une cotisation gratuite à ce prestataire ?')" href="{{ admin.generateObjectUrl('addfreecotisationpresta', object) }}"><i class="fa fa-plus" aria-hidden="true"></i> Free cotis.</a>
{% if false == isCotisationValidForPresta(object) %}
<a class="btn btn-sm btn-default view_link" onclick="return confirm('Êtes-vous sûr de vouloir ajouter une cotisation gratuite à ce prestataire ?')" href="{{ admin.generateObjectUrl('addfreecotisationpresta', object) }}"><i class="fa fa-plus" aria-hidden="true"></i> Ajouter cotisation gratuite au presta</a>
{% endif %}
\ No newline at end of file
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{%- spaceless %}
{% if isCotisationValidForPresta(object) %}
{% set text = 'label_type_yes'|trans({}, 'SonataAdminBundle') %}
{% set cotisEnd = isCotisationValidForPresta(object) %}
{% if false != cotisEnd %}
{% set text = cotisEnd|date('d/m/Y') %}
{% set class = 'label-success' %}
{% else %}
{% set text = 'label_type_no'|trans({}, 'SonataAdminBundle') %}
......
......@@ -7,8 +7,9 @@
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, element, field_description.options.route.parameters) }}">
{{- element|render_relation_element(field_description) -}}
</a>
{% if isCotisationValidForAdherent(element.adherent) %}
<span class="label label-success">oui</span>
{% set cotisEnd = isCotisationValidForAdherent(element.adherent) %}
{% if false != cotisEnd %}
<span class="label label-success">{{ cotisEnd|date('d/m/Y') }}</span>
{% else %}
<span class="label label-danger">non</span>
{% endif %}
......
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{%- spaceless %}
{% if isCotisationValid(object.user) %}
{% set text = 'label_type_yes'|trans({}, 'SonataAdminBundle') %}
{% set cotisEnd = isCotisationValid(object.user) %}
{% if false != cotisEnd %}
{% set text = cotisEnd|date('d/m/Y') %}
{% set class = 'label-success' %}
{% else %}
{% set text = 'label_type_no'|trans({}, 'SonataAdminBundle') %}
......
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% block sonata_type_date_picker_widget_html %}
{% if datepicker_use_button %}
<div class='input-group date' id='dp_{{ id }}'>
{% endif %}
{% set attr = attr|merge({'data-date-format': moment_format}) %}
{{ block('date_widget') }}
{% if datepicker_use_button %}
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
</div>
{% endif %}
{% endblock sonata_type_date_picker_widget_html %}
{% block sonata_type_date_picker_widget %}
{% apply spaceless %}
{% if wrap_fields_with_addons %}
<div class="input-group">
{{ block('sonata_type_date_picker_widget_html') }}
</div>
{% else %}
{{ block('sonata_type_date_picker_widget_html') }}
{% endif %}
<script type="text/javascript">
jQuery(function ($) {
$('#{{ datepicker_use_button ? 'dp_' : '' }}{{ id }}').datetimepicker({{ dp_options|json_encode|raw }});
});
</script>
{% endapply %}
{% endblock sonata_type_date_picker_widget %}
{% block sonata_type_datetime_picker_widget_html %}
{% if datepicker_use_button %}
<div class='input-group date {% if not dp_options['pickDate'] %}timepicker{% endif %}' id='dtp_{{ id }}'>
{% endif %}
{% set attr = attr|merge({'data-date-format': moment_format}) %}
{{ block('datetime_widget') }}
{% if datepicker_use_button %}
<span class="input-group-addon">
<span class="fa {% if dp_options['pickDate'] %}fa-calendar{% else %}fa-clock{% endif %}"></span>
</span>
</div>
{% endif %}
{% endblock sonata_type_datetime_picker_widget_html %}
{% block sonata_type_datetime_picker_widget %}
{% apply spaceless %}
{% if wrap_fields_with_addons %}
<div class="input-group">
{{ block('sonata_type_datetime_picker_widget_html') }}
</div>
{% else %}
{{ block('sonata_type_datetime_picker_widget_html') }}
{% endif %}
<script type="text/javascript">
jQuery(function ($) {
$('#{{ datepicker_use_button ? 'dtp_' : '' }}{{ id }}').datetimepicker({{ dp_options|json_encode|raw }});
});
</script>
{% endapply %}
{% endblock sonata_type_datetime_picker_widget %}
{% block sonata_type_datetime_range_script_block %}
{% apply spaceless %}
{{ block('form_widget') }}
<script type="text/javascript">
jQuery(function ($) {
var $startDateTimePicker = $('#{{ startId }}');
var $endDateTimePicker = $('#{{ endId }}');
$startDateTimePicker.on("dp.change", function (e) {
$endDateTimePicker.data("DateTimePicker").setMinDate(e.date);
});
$endDateTimePicker.on("dp.change", function (e) {
$startDateTimePicker.data("DateTimePicker").setMaxDate(e.date);
});
});
</script>
{% endapply %}
{% endblock sonata_type_datetime_range_script_block %}
{% block sonata_type_datetime_range_picker_widget %}
{% set startId = (form.children.start.vars.datepicker_use_button ? 'dtp_' : '') ~ form.children.start.vars.id %}
{% set endId = (form.children.end.vars.datepicker_use_button ? 'dtp_' : '') ~ form.children.end.vars.id %}
{{ block('sonata_type_datetime_range_script_block') }}
{% endblock sonata_type_datetime_range_picker_widget %}
{% block sonata_type_date_range_picker_widget %}
{% set startId = (form.children.start.vars.datepicker_use_button ? 'dp_' : '') ~ form.children.start.vars.id %}
{% set endId = (form.children.end.vars.datepicker_use_button ? 'dp_' : '') ~ form.children.end.vars.id %}
{{ block('sonata_type_datetime_range_script_block') }}
{% endblock sonata_type_date_range_picker_widget %}
......@@ -6,7 +6,7 @@
{% block blockcontent %}
{# @TODO : ajouter un KOH_BLOCK_ON_INVALID_COTISATION #}
{# Il est possible d'empêcher l'utilisation du compte s'il n'y a pas de cotisation valide! #}
{# {% if not isCotisationValid(app.user) %}
{# {% if false == isCotisationValid(app.user) %}
<div class='text-danger mb-3'>{{ 'Si vous souhaitez utiliser les fonctionnalités de votre compte, vous devez avoir une cotisation à jour !'|trans }}</div>
{% else %} #}
{% set form = getAchatMonnaiePrestataireForm(app.user) %}
......
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