mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 01:08:26 +00:00 
			
		
		
		
	Compare commits
	
		
			10 Commits
		
	
	
		
			280-add-mi
			...
			102_activi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d248d7e8af | |||
| d58c0efae9 | |||
| 1283ea4010 | |||
| 3f01986234 | |||
| f751d6abca | |||
| f4962f86a0 | |||
| 1db69cdfe9 | |||
| f41e27d75a | |||
| 158effe232 | |||
| 8b30652b6b | 
| @@ -0,0 +1,20 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Chill\AsideActivityBundle\Controller; | ||||
|  | ||||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
|  | ||||
| /** | ||||
|  * Controller for activity configuration | ||||
|  * | ||||
|  * @author Julien Fastré <julien.fastre@champs-libres.coop> | ||||
|  * @author Champs Libres <info@champs-libres.coop> | ||||
|  */ | ||||
| class AdminController extends AbstractController | ||||
| { | ||||
|      | ||||
|     public function redirectToAdminIndexAction() | ||||
|     { | ||||
|         return $this->redirectToRoute('chill_main_admin_central'); | ||||
|     } | ||||
| } | ||||
| @@ -1,14 +1,29 @@ | ||||
| <?php | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| namespace Chill\AsideActivityBundle\Controller; | ||||
|  | ||||
| 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; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Class AsideActivityBundle | ||||
|  */ | ||||
| class AsideActivityController extends CRUDController | ||||
| final 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); | ||||
|     } | ||||
|  | ||||
|      | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,91 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Chill\ActivityBundle\DataFixtures\ORM; | ||||
|  | ||||
| use Doctrine\Common\DataFixtures\AbstractFixture; | ||||
| use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | ||||
| use Doctrine\Persistence\ObjectManager; | ||||
| use Faker\Factory as FakerFactory; | ||||
| use Chill\MainBundle\DataFixtures\ORM\LoadUsers; | ||||
| use Chill\AsideActivityBundle\DataFixtures\LoadAsideActivityCategory; | ||||
| use Chill\AsideActivityBundle\Entity\AsideActivity; | ||||
| use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||||
|  | ||||
| /** | ||||
|  * Load reports into DB | ||||
|  * | ||||
|  * @author Champs-Libres Coop | ||||
|  */ | ||||
| class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface | ||||
| { | ||||
|     use \Symfony\Component\DependencyInjection\ContainerAwareTrait; | ||||
|  | ||||
|     /** | ||||
|      * @var \Faker\Generator | ||||
|      */ | ||||
|     private $faker; | ||||
|  | ||||
|     public function __construct() | ||||
|     { | ||||
|         $this->faker = FakerFactory::create('fr_FR'); | ||||
|     } | ||||
|  | ||||
|     public function getOrder() | ||||
|     { | ||||
|         return 16400; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Return a random asideActivityCategory | ||||
|      * | ||||
|      * @return \Chill\AsideActivityBundle\Entity\AsideActivityCategory | ||||
|      */ | ||||
|     private function getRandomAsideActivityCategory() | ||||
|     { | ||||
|         $catRef = LoadAsideActivityCategory::$references[array_rand(LoadAsideActivityCategory::$references)]; | ||||
|         return $this->getReference($catRef); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Return a random user | ||||
|      * | ||||
|      * @return \Chill\MainBundle\Entity\User | ||||
|      */ | ||||
|     private function getRandomUser() | ||||
|     { | ||||
|         $userRef = array_rand(LoadUsers::$refs); | ||||
|         return $this->getReference($userRef); | ||||
|     } | ||||
|  | ||||
|     public function newRandomActivity() | ||||
|     { | ||||
|         $asideactivity = (new AsideActivity()) | ||||
|             ->setAgent($this->getRandomUser()) | ||||
|             ->setDate($this->faker->dateTimeThisYear()) | ||||
|             ->setDuration($this->faker->dateTime(36000)) | ||||
|             ->setType($this->getRandomAsideActivityCategory()); | ||||
|  | ||||
|         return $asideactivity; | ||||
|     } | ||||
|  | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         $users = $this->container->get('doctrine.orm.entity_manager') | ||||
|             ->getRepository('ChillMainBundle:User') | ||||
|             ->findAll(); | ||||
|  | ||||
|         foreach($users as $user) { | ||||
|             $activityNbr = rand(0,3); | ||||
|             $ref = 'activity_'.$user->getUsernameCanonical(); | ||||
|  | ||||
|             for($i = 0; $i < $activityNbr; $i ++) { | ||||
|                 print "Creating an aside activity for  : ".$user." (ref: ".$ref.")  \n"; | ||||
|                 $asideactivity = $this->newRandomActivity($user); | ||||
|                 $manager->persist($asideactivity); | ||||
|             } | ||||
|  | ||||
|             $this->setReference($ref, $asideactivity); | ||||
|         } | ||||
|         $manager->flush(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,53 @@ | ||||
| <?php | ||||
|  | ||||
| Namespace Chill\AsideActivityBundle\DataFixtures; | ||||
|  | ||||
| use Doctrine\Bundle\FixturesBundle\Fixture; | ||||
| use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | ||||
| use Doctrine\Persistence\ObjectManager; | ||||
| use Chill\ActivityBundle\Entity\ActivityTypeCategory; | ||||
| use Chill\AsideActivityBundle\Entity\AsideActivityCategory; | ||||
|  | ||||
| /** | ||||
|  * Fixtures for AsideActivityCategory | ||||
|  * | ||||
|  * @author Champs-Libres Coop | ||||
|  */ | ||||
| class LoadAsideActivityCategory extends Fixture implements OrderedFixtureInterface | ||||
| { | ||||
|     public static $references = array(); | ||||
|  | ||||
|     public function getOrder() | ||||
|     { | ||||
|         return 16050; | ||||
|     } | ||||
|  | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         $categories = [ | ||||
|             [ | ||||
|                 'title' => ['fr' => 'Formation', 'en' => 'Training'], | ||||
|                 'ref' => 'training', | ||||
|             ], | ||||
|             [ | ||||
|                 'title' => ['fr' => 'Team building', 'en' => 'Team building'], | ||||
|                 'ref' => 'teambuilding', | ||||
|             ], | ||||
|         ]; | ||||
|  | ||||
|         foreach ($categories as $cat) { | ||||
|             print "Creating aside activity type category : " . $cat['ref'] . "\n"; | ||||
|  | ||||
|             $newCat = (new AsideActivityCategory()) | ||||
|                 ->setTitle(($cat['title'])); | ||||
|  | ||||
|             $manager->persist($newCat); | ||||
|             $reference = 'activity_type_cat_'.$cat['ref']; | ||||
|  | ||||
|             $this->addReference($reference, $newCat); | ||||
|             static::$references[] = $reference; | ||||
|         } | ||||
|  | ||||
|         $manager->flush(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,102 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Chill\AsideActivityBundle\DataFixtures\ORM; | ||||
|  | ||||
| use Doctrine\Common\DataFixtures\AbstractFixture; | ||||
| use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | ||||
| use Doctrine\Persistence\ObjectManager; | ||||
| use Faker\Factory as FakerFactory; | ||||
| use Chill\MainBundle\DataFixtures\ORM\LoadUsers; | ||||
| use Chill\AsideActivityBundle\DataFixtures\ORM\LoadAsideActivityCategory; | ||||
| use Chill\AsideActivityBundle\Entity\AsideActivity; | ||||
| use Chill\AsideActivityBundle\Entity\AsideActivityCategory; | ||||
| use Chill\MainBundle\Entity\User; | ||||
| use Chill\MainBundle\Repository\UserRepository; | ||||
| use DateTime; | ||||
| use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface; | ||||
| use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||||
| use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||||
|  | ||||
| /** | ||||
|  * Load reports into DB | ||||
|  * | ||||
|  * @author Champs-Libres Coop | ||||
|  */ | ||||
| class LoadAsideActivity extends AbstractFixture implements DependentFixtureInterface, ContainerAwareInterface | ||||
| { | ||||
|     use \Symfony\Component\DependencyInjection\ContainerAwareTrait; | ||||
|  | ||||
|     /** | ||||
|      * @var \Faker\Generator | ||||
|      */ | ||||
|     private $faker; | ||||
|  | ||||
|     private array $cacheUsers = []; | ||||
|  | ||||
|     private UserRepository $userRepository; | ||||
|  | ||||
|     public function __construct(UserRepository $userRepository) | ||||
|     { | ||||
|         $this->faker = FakerFactory::create('fr_FR'); | ||||
|         $this->userRepository = $userRepository; | ||||
|     } | ||||
|  | ||||
|     public function getDependencies() | ||||
|     { | ||||
|         return [ | ||||
|             LoadAsideActivityCategory::class, | ||||
|             LoadUsers::class, | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Return a random asideActivityCategory | ||||
|      * | ||||
|      * @return \Chill\AsideActivityBundle\Entity\AsideActivityCategory | ||||
|      */ | ||||
|     private function getRandomAsideActivityCategory(): AsideActivityCategory | ||||
|     { | ||||
|         $catRef = LoadAsideActivityCategory::$references[array_rand(LoadAsideActivityCategory::$references)]; | ||||
|  | ||||
|         return $this->getReference($catRef); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Return a random user | ||||
|      * | ||||
|      * @return \Chill\MainBundle\Entity\User | ||||
|      */ | ||||
|     private function getRandomUser(): User | ||||
|     { | ||||
|         if (0 === count($this->cacheUsers)){ | ||||
|             $this->cacheUsers = $this->container->get('doctrine.orm.entity_manager') | ||||
|                 ->getRepository('ChillMainBundle:User') | ||||
|                 ->findAll(); | ||||
|         } | ||||
|  | ||||
|         return $this->cacheUsers[array_rand($this->cacheUsers)]; | ||||
|     } | ||||
|  | ||||
|     public function newRandomActivity() | ||||
|     { | ||||
|         $asideactivity = ($activity = new AsideActivity()) | ||||
|             ->setAgent($this->getRandomUser()) | ||||
|             ->setDate($this->faker->dateTimeThisYear()) | ||||
|             ->setCreatedAt(new DateTime()) | ||||
|             ->setCreatedBy($activity->getAgent()) | ||||
|             //->setDuration(3600) | ||||
|             ->setType($this->getRandomAsideActivityCategory()); | ||||
|  | ||||
|         return $asideactivity; | ||||
|     } | ||||
|  | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         for($i = 0; $i < 100; $i ++) { | ||||
|             $asideactivity = $this->newRandomActivity(); | ||||
|             $manager->persist($asideactivity); | ||||
|         } | ||||
|  | ||||
|         $manager->flush(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,50 @@ | ||||
| <?php | ||||
|  | ||||
| Namespace Chill\AsideActivityBundle\DataFixtures\ORM; | ||||
|  | ||||
| use Doctrine\Bundle\FixturesBundle\Fixture; | ||||
| use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | ||||
| use Doctrine\Persistence\ObjectManager; | ||||
| use Chill\ActivityBundle\Entity\ActivityTypeCategory; | ||||
| use Chill\AsideActivityBundle\Entity\AsideActivityCategory; | ||||
| use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface; | ||||
| use Doctrine\Common\DataFixtures\DependentFixtureInterface; | ||||
|  | ||||
| /** | ||||
|  * Fixtures for AsideActivityCategory | ||||
|  * | ||||
|  * @author Champs-Libres Coop | ||||
|  */ | ||||
| class LoadAsideActivityCategory extends Fixture | ||||
| { | ||||
|     public static $references = array(); | ||||
|  | ||||
|     public function load(ObjectManager $manager) | ||||
|     { | ||||
|         $categories = [ | ||||
|             [ | ||||
|                 'title' => ['fr' => 'Formation', 'en' => 'Training'], | ||||
|                 'ref' => 'training', | ||||
|             ], | ||||
|             [ | ||||
|                 'title' => ['fr' => 'Team building', 'en' => 'Team building'], | ||||
|                 'ref' => 'teambuilding', | ||||
|             ], | ||||
|         ]; | ||||
|  | ||||
|         foreach ($categories as $cat) { | ||||
|             print "Creating aside activity type category : " . $cat['ref'] . "\n"; | ||||
|  | ||||
|             $newCat = (new AsideActivityCategory()) | ||||
|                 ->setTitle(($cat['title'])); | ||||
|  | ||||
|             $manager->persist($newCat); | ||||
|             $reference = 'activity_type_cat_'.$cat['ref']; | ||||
|  | ||||
|             $this->addReference($reference, $newCat); | ||||
|             static::$references[] = $reference; | ||||
|         } | ||||
|  | ||||
|         $manager->flush(); | ||||
|     } | ||||
| } | ||||
| @@ -25,8 +25,9 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte | ||||
|     public function load(array $configs, ContainerBuilder $container): void | ||||
|     { | ||||
|         $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config')); | ||||
|         // $loader->load('services.yaml'); | ||||
|         $loader->load('services.yaml'); | ||||
|         $loader->load('services/form.yaml'); | ||||
|         $loader->load('services/menu.yaml'); | ||||
|     } | ||||
|  | ||||
|     public function prepend(ContainerBuilder $container) | ||||
|   | ||||
| @@ -13,7 +13,7 @@ use Symfony\Component\Validator\Constraints as Assert; | ||||
|  * @ORM\Entity | ||||
|  * @ORM\Table(schema="chill_asideactivity") | ||||
|  */ | ||||
| final class AsideActivity implements TrackUpdateInterface, TrackCreationInterface | ||||
| class AsideActivity implements TrackUpdateInterface, TrackCreationInterface | ||||
| { | ||||
|     /** | ||||
|      * @ORM\Id | ||||
| @@ -200,10 +200,4 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac | ||||
|  | ||||
|         return $this; | ||||
|     } | ||||
|  | ||||
|     // public function __toString() | ||||
|     // { | ||||
|     //     // dump($this->type->getTitle()); | ||||
|     //     return $this->type->getTitle(); | ||||
|     // } | ||||
| } | ||||
|   | ||||
| @@ -8,6 +8,7 @@ use Chill\MainBundle\Entity\User; | ||||
| use Chill\MainBundle\Form\Type\ChillDateType; | ||||
| use Chill\MainBundle\Form\Type\ChillTextareaType; | ||||
| use Chill\MainBundle\Templating\TranslatableStringHelper; | ||||
| use Doctrine\ORM\EntityRepository; | ||||
| use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
| use Symfony\Component\Form\AbstractType; | ||||
| use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; | ||||
| @@ -34,6 +35,7 @@ final class AsideActivityFormType extends AbstractType | ||||
|  | ||||
|     public function buildForm(FormBuilderInterface $builder, array $options) | ||||
|     { | ||||
|         dump($options); | ||||
|         $timeChoices = []; | ||||
|  | ||||
|         foreach ($this->timeChoices as $e) { | ||||
| @@ -53,6 +55,9 @@ final class AsideActivityFormType extends AbstractType | ||||
|                 'required' => true, | ||||
|                 'class' => User::class, | ||||
|                 'data' => $this->storage->getToken()->getUser(), | ||||
|                 'query_builder' => function(EntityRepository $er){ | ||||
|                     return $er->createQueryBuilder('u')->where('u.enabled = true'); | ||||
|                 }, | ||||
|                 'attr' => array('class' => 'select2 '), | ||||
|                 'placeholder' => 'Choose the agent for whom this activity is created', | ||||
|                 'choice_label' => 'username' | ||||
| @@ -108,7 +113,6 @@ final class AsideActivityFormType extends AbstractType | ||||
|                     $seconds = $data->getTimezone()->getOffset($data); | ||||
|                     $data->setTimeZone($timezoneUTC); | ||||
|                     $data->add(new \DateInterval('PT'.$seconds.'S')); | ||||
|                     dump($data); | ||||
|  | ||||
|                     // test if the timestamp is in the choices. | ||||
|                     // If not, recreate the field with the new timestamp | ||||
|   | ||||
| @@ -0,0 +1,47 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Chill\AsideActivityBundle\Menu; | ||||
|  | ||||
| use Chill\MainBundle\Routing\LocalMenuBuilderInterface; | ||||
| use Knp\Menu\MenuItem; | ||||
| use Symfony\Contracts\Translation\TranslatorInterface; | ||||
|  | ||||
| /** | ||||
|  * Class SectionMenuBuilder | ||||
|  * | ||||
|  * @package Chill\AsideActivityBundle\Menu | ||||
|  */ | ||||
| class SectionMenuBuilder implements LocalMenuBuilderInterface | ||||
| { | ||||
|     protected TranslatorInterface $translator; | ||||
|  | ||||
|     public function __construct(TranslatorInterface $translator) | ||||
|     { | ||||
|         $this->translator = $translator; | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * @param $menuId | ||||
|      * @param MenuItem $menu | ||||
|      * @param array $parameters | ||||
|      */ | ||||
|     public function buildMenu($menuId, MenuItem $menu, array $parameters) | ||||
|     { | ||||
|  | ||||
|         $menu->addChild($this->translator->trans('Create an aside activity'), [ | ||||
|                 'route' => 'chill_crud_aside_activity_new' | ||||
|             ]) | ||||
|             ->setExtras([ | ||||
|                 'order' => 11, | ||||
|                 'icons' => [ 'plus' ] | ||||
|             ]); | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * @return array | ||||
|      */ | ||||
|     public static function getMenuIds(): array | ||||
|     { | ||||
|         return [ 'section' ]; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,14 @@ | ||||
| {% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} | ||||
|  | ||||
| {% block vertical_menu_content %} | ||||
| 	{{ chill_menu('admin_aside_activity', { | ||||
|         'layout': '@ChillAsideActivity/Admin/menu_asideactivity.html.twig', | ||||
|     }) }} | ||||
| {% endblock %} | ||||
|  | ||||
| {% block layout_wvm_content %} | ||||
| 	{% block admin_content %} | ||||
| 		<!-- block personcontent empty --> | ||||
| 		<h1>{{ 'Aside activity configuration' |trans }}</h1> | ||||
| 	{% endblock %} | ||||
| {% endblock  %} | ||||
| @@ -0,0 +1,4 @@ | ||||
| {% extends "@ChillMain/Menu/verticalMenu.html.twig" %} | ||||
| {% block v_menu_title %} | ||||
| 	{{ 'Aside activity configuration menu'|trans }} | ||||
| {% endblock %} | ||||
| @@ -1,37 +1,28 @@ | ||||
| <div class="{% block crud_content_main_div_class %}col-10 centered{% endblock %}"> | ||||
|     {% block crud_content_header %} | ||||
|         <h1>{{ ('crud.'~crud_name~'.title_delete')|trans({ '%as_string%': 'Aside Activity' }) }}</h1> | ||||
|     {% endblock crud_content_header %} | ||||
| 	{% block crud_content_header %} | ||||
| 		<h1>{{ ('crud.'~crud_name~'.title_delete')|trans({ '%as_string%': 'Aside Activity' }) }}</h1> | ||||
| 	{% 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"> | ||||
|             {% block content_form_actions_back %} | ||||
|                 <li class="cancel"> | ||||
|                     <a class="btn btn-cancel" href="{{ chill_return_path_or('chill_crud_'~crud_name~'_index') }}"> | ||||
|                         {{ 'Cancel'|trans }} | ||||
|                     </a> | ||||
|                 </li> | ||||
|             {% endblock %} | ||||
|             {% block content_form_actions_before %}{% endblock %} | ||||
|             {% block content_form_actions_view %} | ||||
|                 {% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %} | ||||
|                 <li class=""> | ||||
|                     <a class="btn btn-show" href="{{ chill_return_path_or('chill_crud_'~crud_name~'_view', { 'id': entity.id }) }}"> | ||||
|                         {{ 'crud.edit.back_to_view'|trans }} | ||||
|                     </a> | ||||
|                 </li> | ||||
|                 {% 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> | ||||
| 	<ul class="record_actions"> | ||||
| 		{% block content_form_actions_back %} | ||||
| 			<li class="cancel"> | ||||
| 				<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_crud_'~crud_name~'_index') }}"> | ||||
| 					{{ 'Cancel'|trans }} | ||||
| 				</a> | ||||
| 			</li> | ||||
| 		{% endblock %} | ||||
| 		{% block content_form_actions_before %}{% 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) }} | ||||
| </div> | ||||
| 	{{ form_end(form) }} | ||||
| </div> | ||||
|   | ||||
| @@ -1,107 +1,106 @@ | ||||
| {% extends "@ChillMain/layout.html.twig" %} | ||||
|  | ||||
| {% block title %}{{ 'Aside activity list' |trans }}{% endblock title %} | ||||
| {% block title %} | ||||
| 	{{ 'Aside activity list' |trans }} | ||||
| {% endblock title %} | ||||
|  | ||||
| {% block content %} | ||||
| <div class="col-md-10 col-xxl asideactivity-list"> | ||||
| <h2>{{ 'My aside activities' |trans }}</h2> | ||||
| 	<div class="col-md-10 col-xxl asideactivity-list"> | ||||
| 		<h2>{{ 'My aside activities' |trans }}</h2> | ||||
|  | ||||
| {% if entities|length == 0 %} | ||||
|     <p class="chill-no-data-statement"> | ||||
|         {{ "There aren't any aside activities."|trans }} | ||||
|         <a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create button-small"></a> | ||||
|     </p> | ||||
| {% else %} | ||||
| 		{% if entities|length == 0 %} | ||||
| 			<p class="chill-no-data-statement"> | ||||
| 				{{ "There aren't any aside activities."|trans }} | ||||
| 				<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create button-small"></a> | ||||
| 			</p> | ||||
| 		{% else %} | ||||
|  | ||||
| <div class="flex-table my-4 list-records"> | ||||
|     {# Sort activities according to date in descending order #} | ||||
|     {% for entity in entities|sort ((a, b) => b.date <=> a.date) %} | ||||
|         {% set t = entity.type %} | ||||
| 			<div | ||||
| 				class="flex-table my-4 list-records"> | ||||
| 				{# Sort activities according to date in descending order #} | ||||
| 				{% for entity in entities|sort ((a, b) => b.date <=> a.date) %} | ||||
| 					{% set t = entity.type %} | ||||
|  | ||||
|         {# only load aside activities of current user. #} | ||||
|         {% if entity.agent == app.user %} | ||||
| 					<div class="item-bloc"> | ||||
| 						<div class="item-row main"> | ||||
| 							<div class="item-col"> | ||||
|  | ||||
|         <div class="item-bloc"> | ||||
|             <div class="item-row main"> | ||||
|                 <div class="item-col"> | ||||
| 								<h3> | ||||
| 									<b>{{ entity.type.title | localize_translatable_string }}</b> | ||||
| 								</h3> | ||||
|  | ||||
|                     <h3> | ||||
|                         <b>{{ entity.type.title | localize_translatable_string }}</b> | ||||
|                     </h3> | ||||
| 								{% if entity.date %} | ||||
| 									<p>{{ entity.date|format_date('long') }}</p> | ||||
| 								{% endif %} | ||||
|  | ||||
|                     {% if entity.date %} | ||||
|                         <p>{{ entity.date|format_date('long') }}</p> | ||||
|                     {% endif %} | ||||
| 								<div class="duration"> | ||||
| 									<p> | ||||
| 										<i class="fa fa-fw fa-hourglass-end"></i> | ||||
| 										{{ entity.duration|date('H:i') }} | ||||
| 									</p> | ||||
| 								</div> | ||||
|  | ||||
|                     <div class="duration"> | ||||
|                             <p> | ||||
|                                 <i class="fa fa-fw fa-hourglass-end"></i> | ||||
|                                 {{ entity.duration|date('H:i') }} | ||||
|                             </p> | ||||
|                     </div> | ||||
| 							</div> | ||||
| 							<div class="item-col"> | ||||
| 								<ul class="list-content"> | ||||
| 									{% if entity.createdBy %} | ||||
| 										<li> | ||||
| 											<b>{{ 'Created by: '|trans }}{{ entity.createdBy.usernameCanonical }}</b> | ||||
| 										</li> | ||||
| 									{% endif %} | ||||
| 								</ul> | ||||
| 							</div> | ||||
| 						</div> | ||||
|  | ||||
|                 </div> | ||||
|                 <div class="item-col"> | ||||
|                     <ul class="list-content"> | ||||
|                         {% if entity.createdBy %} | ||||
|                         <li> | ||||
|                             <b>{{ 'Created by: '|trans }}{{ entity.createdBy.usernameCanonical }}</b> | ||||
|                         </li> | ||||
|                         {% endif %} | ||||
|                     </ul> | ||||
|                 </div> | ||||
|             </div> | ||||
| 						{# {% | ||||
| 												                if entity.note is not empty | ||||
| 												                or entity.createdBy|length > 0 | ||||
| 												            %} | ||||
| 												            <div class="item-row details"> | ||||
| 												                {% if entity.note is not empty %} | ||||
| 												                <div class="item-col comment"> | ||||
| 												                    {{ entity.note|chill_markdown_to_html }} | ||||
| 												                </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> | ||||
|  | ||||
|             {# {% | ||||
|                 if entity.note is not empty | ||||
|                 or entity.createdBy|length > 0 | ||||
|             %} | ||||
|             <div class="item-row details"> | ||||
|                 {% if entity.note is not empty %} | ||||
|                 <div class="item-col comment"> | ||||
|                     {{ entity.note|chill_markdown_to_html }} | ||||
|                 </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 %} | ||||
| 				{% 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 %} | ||||
|   | ||||
| @@ -1,44 +1,44 @@ | ||||
| {% extends "@ChillActivity/Admin/layout_activity.html.twig" %} | ||||
| {% extends "@ChillAsideActivity/Admin/layout_asideactivity.html.twig" %} | ||||
|  | ||||
| {% block admin_content %} | ||||
|     <h1>{{ 'ActivityType list'|trans }}</h1> | ||||
| 	<h1>{{ 'ActivityType list'|trans }}</h1> | ||||
|  | ||||
|     <table class="records_list table table-bordered border-dark"> | ||||
|         <thead> | ||||
|             <tr> | ||||
|                 <th>{{ 'Name'|trans }}</th> | ||||
|                 <th>{{ 'Active'|trans }}</th> | ||||
|                 <th>{{ 'Actions'|trans }}</th> | ||||
|             </tr> | ||||
|         </thead> | ||||
|         <tbody> | ||||
|         {% for entity in entities %} | ||||
|             <tr> | ||||
|                 <td>{{ entity.title|localize_translatable_string }}</td> | ||||
|                 <td style="text-align:center;"> | ||||
|                 {%- if entity.isActive -%} | ||||
|                     <i class="fa fa-check-square-o"></i> | ||||
|                 {%- else -%} | ||||
|                     <i class="fa fa-square-o"></i> | ||||
|                 {%- endif -%} | ||||
|             </td> | ||||
|                 <td> | ||||
|                 <ul class="record_actions sticky-form-buttons"> | ||||
|                     <li> | ||||
|                         <a href="{{ path('chill_crud_aside_activity_category_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'edit'|trans }}"></a> | ||||
|                     </li> | ||||
|                 </ul> | ||||
|                 </td> | ||||
|             </tr> | ||||
|         {% endfor %} | ||||
|         </tbody> | ||||
|     </table> | ||||
| 	<table class="records_list table table-bordered border-dark"> | ||||
| 		<thead> | ||||
| 			<tr> | ||||
| 				<th>{{ 'Name'|trans }}</th> | ||||
| 				<th>{{ 'Active'|trans }}</th> | ||||
| 				<th>{{ 'Actions'|trans }}</th> | ||||
| 			</tr> | ||||
| 		</thead> | ||||
| 		<tbody> | ||||
| 			{% for entity in entities %} | ||||
| 				<tr> | ||||
| 					<td>{{ entity.title|localize_translatable_string }}</td> | ||||
| 					<td style="text-align:center;"> | ||||
| 						{%- if entity.isActive -%} | ||||
| 							<i class="fa fa-check-square-o"></i> | ||||
| 						{%- else -%} | ||||
| 							<i class="fa fa-square-o"></i> | ||||
| 						{%- endif -%} | ||||
| 					</td> | ||||
| 					<td> | ||||
| 						<ul class="record_actions"> | ||||
| 							<li> | ||||
| 								<a href="{{ path('chill_crud_aside_activity_category_edit', { 'id': entity.id }) }}" class="btn btn-edit" title="{{ 'edit'|trans }}"></a> | ||||
| 							</li> | ||||
| 						</ul> | ||||
| 					</td> | ||||
| 				</tr> | ||||
| 			{% endfor %} | ||||
| 		</tbody> | ||||
| 	</table> | ||||
|  | ||||
|         <ul class="record_actions"> | ||||
|         <li> | ||||
|             <a href="{{ path('chill_crud_aside_activity_category_new') }}" class="btn btn-create"> | ||||
|                 {{ 'Create a new aside activity type'|trans }} | ||||
|             </a> | ||||
|         </li> | ||||
|     </ul> | ||||
|     {% endblock %} | ||||
| 	<ul class="record_actions"> | ||||
| 		<li> | ||||
| 			<a href="{{ path('chill_crud_aside_activity_category_new') }}" class="btn btn-create"> | ||||
| 				{{ 'Create a new aside activity type'|trans }} | ||||
| 			</a> | ||||
| 		</li> | ||||
| 	</ul> | ||||
| {% endblock %} | ||||
|   | ||||
| @@ -0,0 +1,73 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Chill\AsideActivityBundle\Tests\Controller; | ||||
|  | ||||
| use Chill\MainBundle\Test\PrepareClientTrait; | ||||
| use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||||
| use Chill\AsideActivityBundle\Entity\AsideActivity; | ||||
| use Doctrine\ORM\EntityManagerInterface; | ||||
|  | ||||
|  | ||||
| class AccompanyingCourseControllerTest extends WebTestCase | ||||
| { | ||||
|     use PrepareClientTrait; | ||||
|  | ||||
|     public function setUp() | ||||
|     { | ||||
|         parent::setUp(); | ||||
|         self::bootKernel(); | ||||
|         $this->client = $this->getClientAuthenticated(); | ||||
|     } | ||||
|  | ||||
|    public function testIndexWithoutUsers() | ||||
|     { | ||||
|         $this->client->request('GET', '/fr/asideactivity');  | ||||
|  | ||||
|         $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||||
|     } | ||||
|  | ||||
|     public function testNewWithoutUsers() | ||||
|     { | ||||
|         $this->client->request('GET', '/fr/asideactivity/new');  | ||||
|  | ||||
|         $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @dataProvider generateAsideActivityId | ||||
|      */ | ||||
|  | ||||
|     public function testEditWithoutUsers(int $asideActivityId) | ||||
|     { | ||||
|         $this->client->request('GET', "/fr/asideactivity/{$asideActivityId}/edit"); | ||||
|  | ||||
|         $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||||
|     } | ||||
|  | ||||
|     public function generateAsideActivityId() | ||||
|     { | ||||
|         self::bootKernel(); | ||||
|  | ||||
|         $qb = self::$container->get(EntityManagerInterface::class) | ||||
|             ->createQueryBuilder(); | ||||
|  | ||||
|         $asideActivityIds = $qb | ||||
|             ->select('DISTINCT asideactivity.id') | ||||
|             ->from(AsideActivity::class, 'asideactivity') | ||||
|             ->innerJoin('asideactivity.agent', 'agent') | ||||
|             ->where($qb->expr()->eq('agent.username', ':center_name')) | ||||
|             ->setParameter('center_name', 'center a_social') | ||||
|             ->setMaxResults(100) | ||||
|             ->getQuery() | ||||
|             ->getResult() | ||||
|         ; | ||||
|  | ||||
|         \shuffle($asideActivityIds); | ||||
|  | ||||
|         yield [ \array_pop($asideActivityIds)['id'] ]; | ||||
|         yield [ \array_pop($asideActivityIds)['id'] ]; | ||||
|         yield [ \array_pop($asideActivityIds)['id'] ]; | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
| @@ -1,3 +1,12 @@ | ||||
| chill_asideactivities_controllers: | ||||
|     resource: "@ChillAsideActivityBundle/Controller" | ||||
|     type: annotation | ||||
|   resource: "@ChillAsideActivityBundle/Controller" | ||||
|   type: annotation | ||||
|  | ||||
| chill_admin_aside_activity_redirect_to_admin_index: | ||||
|   path: /{_locale}/admin/activity_redirect_to_main | ||||
|   controller: Chill\ActivityBundle\Controller\AdminController::redirectToAdminIndexAction | ||||
|   options: | ||||
|     menus: | ||||
|       admin_aside_activity: | ||||
|         order: 0 | ||||
|         label: Main admin menu | ||||
|   | ||||
| @@ -1,8 +0,0 @@ | ||||
| # services: | ||||
| #     chill.asideactivity.form.type.asideactivity: | ||||
| #         class: Chill\AsideActivityBundle\Form\AsideActivityFormType | ||||
| #         arguments: | ||||
| #             - "@chill.main.helper.translatable_string" | ||||
| #             # - "%chill_activity.form.time_duration%" | ||||
| #         tags: | ||||
| #             - { name: form.type, alias: chill_asideactivitybundle_asideactivity } | ||||
| @@ -0,0 +1,6 @@ | ||||
| services: | ||||
|   Chill\AsideActivityBundle\Menu\SectionMenuBuilder: | ||||
|     arguments: | ||||
|       $translator: '@Symfony\Component\Translation\TranslatorInterface' | ||||
|     tags: | ||||
|       - { name: "chill.menu_builder" } | ||||
| @@ -1,9 +1,10 @@ | ||||
| #general | ||||
| Show the aside activity: Voir l'activité annexe | ||||
| Edit the aside activity: Modifier l'activité annexe | ||||
| Remove aside activity: Supprimer l'activité annexe | ||||
| Aside activity: Activité annexe | ||||
| Duration time: Durée | ||||
| durationTime:  durée | ||||
| durationTime: durée | ||||
| user_username: nom de l'utilisateur | ||||
| Remark: Commentaire | ||||
| No comments: Aucun commentaire | ||||
| @@ -25,7 +26,7 @@ Required: Obligatoire | ||||
| Persons: Personnes | ||||
| Users: Utilisateurs | ||||
| Emergency: Urgent | ||||
| by: 'Par ' | ||||
| by: "Par " | ||||
| location: Lieu | ||||
|  | ||||
| # Crud | ||||
| @@ -75,8 +76,12 @@ My aside activities: Mes activités annexes | ||||
| Date: Date | ||||
| Created by: Creér par | ||||
|  | ||||
|  | ||||
| #Aside activity delete | ||||
| 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%" ? | ||||
| 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" | ||||
| Aside activity configuration menu: "Menu de configuration des activités annexes" | ||||
| Aside activity configuration: "Configuration des activités annexes" | ||||
|   | ||||
| @@ -53,8 +53,12 @@ | ||||
|         {% block sublayout_content %} | ||||
|             <div class="row justify-content-center my-5"> | ||||
|  | ||||
|                 {# col-8 : width wasn't long enough. It would cause the message to be displayed on the left of  | ||||
|                 the screen and the list of activities on the right...  | ||||
|                 I don't know if this needs to be changed for the other flash messages too?  | ||||
|                 For other pages, it doesn't change much visually.  #} | ||||
|                 {% for flashMessage in app.session.flashbag.get('success') %} | ||||
|                     <div class="col-8 mb-5 alert alert-success flash_message"> | ||||
|                     <div class="col-10 mb-5 alert alert-success flash_message"> | ||||
|                         <span>{{ flashMessage|raw }}</span> | ||||
|                     </div> | ||||
|                 {% endfor %} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user