Commit 8b160883 by Julien Jorry

User payment Autocompletion for adherent (ajax) / prestataire

parent 3ae5203e
......@@ -30,3 +30,14 @@
@import "~bootstrap/scss/bootstrap";
@import "./custom/bootswatch";
// @import "~bootstrap/scss/bootstrap-grid";
@import "~select2/dist/css/select2";
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height: 34px;
}
.select2-container .select2-selection--single {
height: 34px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height: 32px;
}
......@@ -45,6 +45,9 @@ require('../js/flash-messages.js');
require('../js/geoloc.js');
require('select2/dist/js/select2.full');
require('select2/dist/js/i18n/fr');
$('#flash-messages').flashNotification('init');
var $collectionHolder;
......@@ -155,6 +158,22 @@ jQuery(document).ready(function() {
// Get the ul that holds the collection of groupes
$collectionHolder = $('.groupeprestas');
$('.select2').select2({
language: 'fr',
width: '100%',
});
$('.select2adh').select2({
minimumInputLength: 3,
language: 'fr',
width: '100%',
ajax: {
delay: 350,
cache: true,
url: '/search/adherent',
dataType: 'json'
}
});
// add a delete link to all of the existing tag form li elements
$collectionHolder.find('div.form-group').each(function() {
$(this).addClass('row mx-2');
......
......@@ -21,6 +21,7 @@
"ckeditor": "^4.12.1",
"jquery": "^3.3.1",
"popper.js": "^1.16.1",
"sass": "1.35.1"
"sass": "1.35.1",
"select2": "^4.1.0-rc.0"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -34,10 +34,20 @@
* Date: 2020-05-04T22:49Z
*/
/*!
* jQuery Mousewheel 3.1.13
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*/
/*! =======================================================
VERSION 11.0.2
========================================================= */
/*! Select2 4.1.0-rc.0 | https://github.com/select2/select2/blob/master/LICENSE.md */
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.16.1
......
/*
Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
CKEDITOR.dialog.add("anchor",function(c){function e(b,a){return b.createFakeElement(b.document.createElement("a",{attributes:a}),"cke_anchor","anchor")}return{title:c.lang.link.anchor.title,minWidth:300,minHeight:60,onOk:function(){var b=CKEDITOR.tools.trim(this.getValueOf("info","txtName")),a={id:b,name:b,"data-cke-saved-name":b};this._.selectedElement?this._.selectedElement.data("cke-realelement")?(b=e(c,a),b.replace(this._.selectedElement),CKEDITOR.env.ie&&c.getSelection().selectElement(b)):this._.selectedElement.setAttributes(a):
(b=(b=c.getSelection())&&b.getRanges()[0],b.collapsed?(a=e(c,a),b.insertNode(a)):(CKEDITOR.env.ie&&9>CKEDITOR.env.version&&(a["class"]="cke_anchor"),a=new CKEDITOR.style({element:"a",attributes:a}),a.type=CKEDITOR.STYLE_INLINE,a.applyToRange(b)))},onHide:function(){delete this._.selectedElement},onShow:function(){var b=c.getSelection(),a;a=b.getRanges()[0];var d=b.getSelectedElement();a.shrink(CKEDITOR.SHRINK_ELEMENT);a=(d=a.getEnclosedNode())&&d.type===CKEDITOR.NODE_ELEMENT&&("anchor"===d.data("cke-real-element-type")||
d.is("a"))?d:void 0;var f=(d=a&&a.data("cke-realelement"))?CKEDITOR.plugins.link.tryRestoreFakeAnchor(c,a):CKEDITOR.plugins.link.getSelectedLink(c);if(f){this._.selectedElement=f;var e=f.data("cke-saved-name");this.setValueOf("info","txtName",e||"");!d&&b.selectElement(f);a&&(this._.selectedElement=a)}this.getContentElement("info","txtName").focus()},contents:[{id:"info",label:c.lang.link.anchor.title,accessKey:"I",elements:[{type:"text",id:"txtName",label:c.lang.link.anchor.name,required:!0,validate:function(){return this.getValue()?
!0:(alert(c.lang.link.anchor.errorName),!1)}}]}]}});
\ No newline at end of file
......@@ -3,10 +3,10 @@
"app": {
"js": [
"/build/runtime.6ad5c9da.js",
"/build/app.7a755b3c.js"
"/build/app.f88c3afa.js"
],
"css": [
"/build/app.1fb37df4.css"
"/build/app.f135e702.css"
]
},
"admin": {
......
{
"build/app.css": "/build/app.1fb37df4.css",
"build/app.js": "/build/app.7a755b3c.js",
"build/app.css": "/build/app.f135e702.css",
"build/app.js": "/build/app.f88c3afa.js",
"build/admin.css": "/build/admin.5dc0eea7.css",
"build/admin.js": "/build/admin.8a6adf4b.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js",
......
......@@ -19,6 +19,7 @@ use App\Utils\OperationUtils;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
......@@ -175,6 +176,22 @@ class UserController extends AbstractController
}
/**
* @Route("/search/adherent", methods="GET", name="searchadherent")
* @IsGranted("ROLE_USER")
*/
public function searchAdherentAction(Request $request)
{
$term = $request->get('term');
$result = $this->em->getRepository(Adherent::class)->findsByData(['email' => $term, 'name' => $term]);
$arrayData = [];
foreach ($result as $adherent) {
$arrayData[] = ['id' => $adherent->getId(), 'text' => $adherent->__toString()];
}
return new JsonResponse(['results' => $arrayData]);
}
/**
* @Route("/user/achatMonnaieAConfirmer", name="achatMonnaieAConfirmer")
* @IsGranted({"ROLE_ADHERENT", "ROLE_PRESTATAIRE"})
*/
......
......@@ -190,9 +190,12 @@ class Adherent extends AccountableObject implements AccountableInterface
if (!empty($this->getUser()->getUsername())) {
return $this->getUser()->getUsername();
}
if (!empty($this->getUser()->getEmail())) {
return $this->getUser()->getEmail();
}
}
return 'Adhérent [' . $this->getId() . ']';
return 'Adhérent xxx';
}
public function getFullname(): string
......@@ -211,6 +214,6 @@ class Adherent extends AccountableObject implements AccountableInterface
return $return;
}
return 'Adhérent [' . $this->getId() . ']';
return 'Adhérent xxx';
}
}
......@@ -1087,7 +1087,7 @@ class Prestataire extends AccountableObject implements AccountableInterface
public function __toString(): string
{
return $this->raison ? $this->raison : 'Prestataire ' . $this->id;
return $this->raison ? $this->raison : 'Prestataire xxx';
}
public function getMapContent(): ?string
......
......@@ -23,7 +23,10 @@ class TransactionAdherentAdherentFormType extends TransactionFormType
->add('destinataire', EntityType::class, [
'class' => Adherent::class,
'choices' => $this->em->getRepository(Adherent::class)->findbyExclude($this->security->getUser()->getAdherent()),
'placeholder' => 'Adherent',
'attr' => [
'class' => 'form-control select2adh',
],
'placeholder' => 'Choisissez un adhérent',
'required' => true,
'label' => 'Adherent :',
])
......
......@@ -24,7 +24,10 @@ class TransactionAdherentPrestataireFormType extends TransactionFormType
->add('destinataire', EntityType::class, [
'class' => Prestataire::class,
'choices' => $this->em->getRepository(Prestataire::class)->findForEPaiement(true),
'placeholder' => 'Prestataire',
'attr' => [
'class' => 'form-control select2',
],
'placeholder' => 'Choisissez un prestataire',
'required' => true,
'label' => 'Prestataire :',
])
......
......@@ -24,7 +24,10 @@ class TransactionPrestataireAdherentFormType extends TransactionFormType
->add('destinataire', EntityType::class, [
'class' => Adherent::class,
'choices' => $this->em->getRepository(Adherent::class)->findOrderByName(),
'placeholder' => 'Adherent',
'attr' => [
'class' => 'form-control select2',
],
'placeholder' => 'Choisissez un adhérent',
'required' => true,
'label' => 'Adherent :',
])
......
......@@ -23,7 +23,10 @@ class TransactionPrestatairePrestataireFormType extends TransactionFormType
->add('destinataire', EntityType::class, [
'class' => Prestataire::class,
'choices' => $this->em->getRepository(Prestataire::class)->findbyExclude($this->session->get('_prestagere')),
'placeholder' => 'Prestataire',
'attr' => [
'class' => 'form-control select2',
],
'placeholder' => 'Choisissez un prestataire',
'required' => true,
'label' => 'Prestataire :',
])
......
......@@ -46,10 +46,18 @@ class AdherentRepository extends ServiceEntityRepository
if (isset($data['email'])) {
$qb =
$qb
->where('u.email = :email')
->orWhere('u.email = :email')
->setParameter('email', $data['email'])
;
}
if (isset($data['name'])) {
$qb =
$qb
->orWhere('u.firstname = :firstname')
->orWhere('u.lastname = :firstname')
->setParameter('email', $data['name'])
;
}
return $qb
->getQuery()
......@@ -57,6 +65,39 @@ class AdherentRepository extends ServiceEntityRepository
;
}
public function findsByData(array $data)
{
$qb = $this->createQueryBuilder('p');
$qb = $qb
->leftjoin('p.user', 'u')
;
if (isset($data['email'])) {
$qb =
$qb
->orWhere('u.email = :email')
->setParameter('email', $data['email'])
;
}
if (isset($data['name'])) {
$qb =
$qb
->orWhere('CONCAT(u.firstname, \' \', u.lastname) = :name')
->orWhere('CONCAT(u.lastname, \' \', u.firstname) = :name')
->setParameter('name', $data['name'])
;
}
return $qb
->andWhere('p.enabled = :enabled')
->setParameter('enabled', true)
->orderBy('u.lastname', 'ASC')
->getQuery()
->getResult()
;
}
public function findOrderByName()
{
$qb = $this->createQueryBuilder('p');
......
......@@ -4771,6 +4771,11 @@ select-hose@^2.0.0:
resolved "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz"
integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=
select2@^4.1.0-rc.0:
version "4.1.0-rc.0"
resolved "https://registry.yarnpkg.com/select2/-/select2-4.1.0-rc.0.tgz#ba3cd3901dda0155e1c0219ab41b74ba51ea22d8"
integrity sha512-Hr9TdhyHCZUtwznEH2CBf7967mEM0idtJ5nMtjvk3Up5tPukOLXbHUNmh10oRfeNIhj+3GD3niu+g6sVK+gK0A==
selfsigned@^1.10.11:
version "1.10.11"
resolved "https://registry.npmjs.org/selfsigned/-/selfsigned-1.10.11.tgz"
......
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