mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
aside activities query added to filter by current user
This commit is contained in:
parent
6680ba19ce
commit
eca00d155f
@ -1,14 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\AsideActivityBundle\Controller;
|
namespace Chill\AsideActivityBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
use Doctrine\Common\Collections\Criteria;
|
||||||
|
|
||||||
|
final class AsideActivityController extends CRUDController
|
||||||
/**
|
|
||||||
* Class AsideActivityBundle
|
|
||||||
*/
|
|
||||||
class AsideActivityController extends CRUDController
|
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param QueryBuilder $query
|
||||||
|
*/
|
||||||
|
protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $query) {
|
||||||
|
|
||||||
|
$usr = $this->getUser();
|
||||||
|
$id = $usr->getId();
|
||||||
|
$criteria = Criteria::create()->andWhere(Criteria::expr()->eq('agent', $id));
|
||||||
|
|
||||||
|
$query
|
||||||
|
->addCriteria($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -200,10 +200,4 @@ class AsideActivity implements TrackUpdateInterface, TrackCreationInterface
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function __toString()
|
|
||||||
// {
|
|
||||||
// // dump($this->type->getTitle());
|
|
||||||
// return $this->type->getTitle();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
dump($options);
|
||||||
$timeChoices = [];
|
$timeChoices = [];
|
||||||
|
|
||||||
foreach ($this->timeChoices as $e) {
|
foreach ($this->timeChoices as $e) {
|
||||||
@ -108,7 +109,6 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
$seconds = $data->getTimezone()->getOffset($data);
|
$seconds = $data->getTimezone()->getOffset($data);
|
||||||
$data->setTimeZone($timezoneUTC);
|
$data->setTimeZone($timezoneUTC);
|
||||||
$data->add(new \DateInterval('PT'.$seconds.'S'));
|
$data->add(new \DateInterval('PT'.$seconds.'S'));
|
||||||
dump($data);
|
|
||||||
|
|
||||||
// test if the timestamp is in the choices.
|
// test if the timestamp is in the choices.
|
||||||
// If not, recreate the field with the new timestamp
|
// If not, recreate the field with the new timestamp
|
||||||
|
@ -1,37 +1,28 @@
|
|||||||
<div class="{% block crud_content_main_div_class %}col-10 centered{% endblock %}">
|
<div class="{% block crud_content_main_div_class %}col-10 centered{% endblock %}">
|
||||||
{% block crud_content_header %}
|
{% block crud_content_header %}
|
||||||
<h1>{{ ('crud.'~crud_name~'.title_delete')|trans({ '%as_string%': 'Aside Activity' }) }}</h1>
|
<h1>{{ ('crud.'~crud_name~'.title_delete')|trans({ '%as_string%': 'Aside Activity' }) }}</h1>
|
||||||
{% endblock crud_content_header %}
|
{% endblock crud_content_header %}
|
||||||
|
|
||||||
<p class="message-confirm">{{ ('crud.'~crud_name~'.confirm_message_delete')|trans({ '%as_string%': 'Aside Activity' }) }}</p>
|
<p class="message-confirm">{{ ('crud.'~crud_name~'.confirm_message_delete')|trans({ '%as_string%': 'Aside Activity' }) }}</p>
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
{% block content_form_actions_back %}
|
{% block content_form_actions_back %}
|
||||||
<li class="cancel">
|
<li class="cancel">
|
||||||
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_crud_'~crud_name~'_index') }}">
|
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_crud_'~crud_name~'_index') }}">
|
||||||
{{ 'Cancel'|trans }}
|
{{ 'Cancel'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content_form_actions_before %}{% endblock %}
|
{% block content_form_actions_before %}{% endblock %}
|
||||||
{% block content_form_actions_view %}
|
{% block content_form_actions_confirm_delete %}
|
||||||
{% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %}
|
<li>
|
||||||
<li class="">
|
<button type="submit" class="btn btn-delete" value="delete-and-close">{{ ('crud.'~crud_name~'.button_delete')|trans }}</button>
|
||||||
<a class="btn btn-show" href="{{ chill_return_path_or('chill_crud_'~crud_name~'_view', { 'id': entity.id }) }}">
|
</li>
|
||||||
{{ 'crud.edit.back_to_view'|trans }}
|
{% endblock content_form_actions_confirm_delete %}
|
||||||
</a>
|
{% block content_form_actions_after %}{% endblock %}
|
||||||
</li>
|
</ul>
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
{% block content_form_actions_confirm_delete %}
|
|
||||||
<li>
|
|
||||||
<button type="submit" class="btn btn-delete" value="delete-and-close">{{ ('crud.'~crud_name~'.button_delete')|trans }}</button>
|
|
||||||
</li>
|
|
||||||
{% endblock content_form_actions_confirm_delete %}
|
|
||||||
{% block content_form_actions_after %}{% endblock %}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,107 +1,106 @@
|
|||||||
{% extends "@ChillMain/layout.html.twig" %}
|
{% extends "@ChillMain/layout.html.twig" %}
|
||||||
|
|
||||||
{% block title %}{{ 'Aside activity list' |trans }}{% endblock title %}
|
{% block title %}
|
||||||
|
{{ 'Aside activity list' |trans }}
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col-md-10 col-xxl asideactivity-list">
|
<div class="col-md-10 col-xxl asideactivity-list">
|
||||||
<h2>{{ 'My aside activities' |trans }}</h2>
|
<h2>{{ 'My aside activities' |trans }}</h2>
|
||||||
|
|
||||||
{% if entities|length == 0 %}
|
{% if entities|length == 0 %}
|
||||||
<p class="chill-no-data-statement">
|
<p class="chill-no-data-statement">
|
||||||
{{ "There aren't any aside activities."|trans }}
|
{{ "There aren't any aside activities."|trans }}
|
||||||
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create button-small"></a>
|
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create button-small"></a>
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<div class="flex-table my-4 list-records">
|
<div
|
||||||
{# Sort activities according to date in descending order #}
|
class="flex-table my-4 list-records">
|
||||||
{% for entity in entities|sort ((a, b) => b.date <=> a.date) %}
|
{# Sort activities according to date in descending order #}
|
||||||
{% set t = entity.type %}
|
{% for entity in entities|sort ((a, b) => b.date <=> a.date) %}
|
||||||
|
{% set t = entity.type %}
|
||||||
|
|
||||||
{# only load aside activities of current user. #}
|
<div class="item-bloc">
|
||||||
{% if entity.agent == app.user %}
|
<div class="item-row main">
|
||||||
|
<div class="item-col">
|
||||||
|
|
||||||
<div class="item-bloc">
|
<h3>
|
||||||
<div class="item-row main">
|
<b>{{ entity.type.title | localize_translatable_string }}</b>
|
||||||
<div class="item-col">
|
</h3>
|
||||||
|
|
||||||
<h3>
|
{% if entity.date %}
|
||||||
<b>{{ entity.type.title | localize_translatable_string }}</b>
|
<p>{{ entity.date|format_date('long') }}</p>
|
||||||
</h3>
|
{% endif %}
|
||||||
|
|
||||||
{% if entity.date %}
|
<div class="duration">
|
||||||
<p>{{ entity.date|format_date('long') }}</p>
|
<p>
|
||||||
{% endif %}
|
<i class="fa fa-fw fa-hourglass-end"></i>
|
||||||
|
{{ entity.duration|date('H:i') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="duration">
|
</div>
|
||||||
<p>
|
<div class="item-col">
|
||||||
<i class="fa fa-fw fa-hourglass-end"></i>
|
<ul class="list-content">
|
||||||
{{ entity.duration|date('H:i') }}
|
{% if entity.createdBy %}
|
||||||
</p>
|
<li>
|
||||||
</div>
|
<b>{{ 'Created by: '|trans }}{{ entity.createdBy.usernameCanonical }}</b>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
{# {%
|
||||||
<div class="item-col">
|
if entity.note is not empty
|
||||||
<ul class="list-content">
|
or entity.createdBy|length > 0
|
||||||
{% if entity.createdBy %}
|
%}
|
||||||
<li>
|
<div class="item-row details">
|
||||||
<b>{{ 'Created by: '|trans }}{{ entity.createdBy.usernameCanonical }}</b>
|
{% if entity.note is not empty %}
|
||||||
</li>
|
<div class="item-col comment">
|
||||||
{% endif %}
|
{{ entity.note|chill_markdown_to_html }}
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
</div>
|
|
||||||
|
</div>
|
||||||
|
{% endif %} #}
|
||||||
|
<div class="item-col">
|
||||||
|
<ul class="list-content">
|
||||||
|
<ul class="record_actions">
|
||||||
|
{# <li>
|
||||||
|
<a href="{{ path('chill_crud_aside_activity_view', { 'id': entity.id} ) }}" class="btn btn-show "></a>
|
||||||
|
</li> #}
|
||||||
|
{# TOOD
|
||||||
|
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
||||||
|
#}
|
||||||
|
<li><a href="{{ path('chill_crud_aside_activity_edit', { 'id': entity.id }) }}" class="btn btn-update "> </a>
|
||||||
|
</li>
|
||||||
|
{# TOOD
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('CHILL_ACTIVITY_DELETE', activity) %}
|
||||||
|
#}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_crud_aside_activity_delete', { 'id': entity.id } ) }}" class="btn btn-delete "></a>
|
||||||
|
</li>
|
||||||
|
{#
|
||||||
|
{% endif %}
|
||||||
|
#}
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{# {%
|
{% endfor %}
|
||||||
if entity.note is not empty
|
</div>
|
||||||
or entity.createdBy|length > 0
|
<ul class="record_actions">
|
||||||
%}
|
<li>
|
||||||
<div class="item-row details">
|
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create">
|
||||||
{% if entity.note is not empty %}
|
{{ 'Add a new aside activity' | trans }}
|
||||||
<div class="item-col comment">
|
</a>
|
||||||
{{ entity.note|chill_markdown_to_html }}
|
</li>
|
||||||
</div>
|
</ul>
|
||||||
{% endif %}
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
|
||||||
{% endif %} #}
|
|
||||||
<div class="item-col">
|
|
||||||
<ul class="list-content">
|
|
||||||
<ul class="record_actions">
|
|
||||||
{# <li>
|
|
||||||
<a href="{{ path('chill_crud_aside_activity_view', { 'id': entity.id} ) }}" class="btn btn-show "></a>
|
|
||||||
</li> #}
|
|
||||||
{# TOOD
|
|
||||||
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
|
||||||
#}
|
|
||||||
<li>
|
|
||||||
<a href="{{ path('chill_crud_aside_activity_edit', { 'id': entity.id }) }}" class="btn btn-update "></a>
|
|
||||||
</li>
|
|
||||||
{# TOOD
|
|
||||||
{% endif %}
|
|
||||||
{% if is_granted('CHILL_ACTIVITY_DELETE', activity) %}
|
|
||||||
#}
|
|
||||||
<li>
|
|
||||||
<a href="{{ path('chill_crud_aside_activity_delete', { 'id': entity.id } ) }}" class="btn btn-delete "></a>
|
|
||||||
</li>
|
|
||||||
{#
|
|
||||||
{% endif %}
|
|
||||||
#}
|
|
||||||
</ul>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
<ul class="record_actions">
|
|
||||||
<li>
|
|
||||||
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create">
|
|
||||||
{{ 'Add a new aside activity' | trans }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#general
|
#general
|
||||||
Show the aside activity: Voir l'activité annexe
|
Show the aside activity: Voir l'activité annexe
|
||||||
Edit the aside activity: Modifier l'activité annexe
|
Edit the aside activity: Modifier l'activité annexe
|
||||||
|
Remove aside activity: Supprimer l'activité annexe
|
||||||
Aside activity: Activité annexe
|
Aside activity: Activité annexe
|
||||||
Duration time: Durée
|
Duration time: Durée
|
||||||
durationTime: durée
|
durationTime: durée
|
||||||
user_username: nom de l'utilisateur
|
user_username: nom de l'utilisateur
|
||||||
Remark: Commentaire
|
Remark: Commentaire
|
||||||
No comments: Aucun commentaire
|
No comments: Aucun commentaire
|
||||||
@ -25,7 +26,7 @@ Required: Obligatoire
|
|||||||
Persons: Personnes
|
Persons: Personnes
|
||||||
Users: Utilisateurs
|
Users: Utilisateurs
|
||||||
Emergency: Urgent
|
Emergency: Urgent
|
||||||
by: 'Par '
|
by: "Par "
|
||||||
location: Lieu
|
location: Lieu
|
||||||
|
|
||||||
# Crud
|
# Crud
|
||||||
@ -75,8 +76,10 @@ My aside activities: Mes activités annexes
|
|||||||
Date: Date
|
Date: Date
|
||||||
Created by: Creér par
|
Created by: Creér par
|
||||||
|
|
||||||
|
|
||||||
#Aside activity delete
|
#Aside activity delete
|
||||||
Delete aside activity: Supprimer une activité annexe
|
Delete aside activity: Supprimer une activité annexe
|
||||||
Are you sure you want to remove the aside activity concerning "%name%" ?: Êtes-vous sûr de vouloir supprimer une activité annexe qui concerne "%name%" ?
|
Are you sure you want to remove the aside activity concerning "%name%" ?: Êtes-vous sûr de vouloir supprimer une activité annexe qui concerne "%name%" ?
|
||||||
The activity has been successfully removed.: L'activité a été supprimée.
|
The activity has been successfully removed.: L'activité a été supprimée.
|
||||||
|
|
||||||
|
#Menu
|
||||||
|
Create an aside activity: "Creér une activité annexe"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user