Commit a17f9ed5 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Filtre sur les type de document

- Fix : Les structures "principale" s'affiche correctement dans la vue personnelle
parent 561f062e
Loading
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -2421,6 +2421,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                'mp' => 'Montant prévu',
                'at' => 'est de type',
                'st' => 'n\'est pas de type',
                'td' => 'Ayant ce type de document',
                'add' => 'Date de début',
                'adf' => 'Date de fin',
                'adc' => 'Date de création',
@@ -2801,6 +2802,15 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                        }
                        break;

                    case 'td':
                        $value1 = $crit['val1'] = explode(',', $params[1]);
                        try {
                            $ids = $this->getActivityService()->getActivitiesIdsWithTypeDocument($value1);
                        } catch (\Exception $e) {
                            throw new OscarException($e->getMessage());
                        }
                        break;

                    case 'ao' :
                    case 'so' :
                        $organizationId[] = $value1;
@@ -2984,7 +2994,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                }
                $criterias[] = $crit;
                if ($type == 'ap' || $type == 'ao' || $type == 'pm' || $type == 'om'
                    || $type == 'fdt' || $type == 'cb' || $type == 'cb2') {
                    || $type == 'fdt' || $type == 'cb' || $type == 'cb2' || $type == 'td') {
                    if ($filterIds === null) {
                        $filterIds = $ids;
                    } else {
@@ -3085,6 +3095,9 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                return $this->ajaxResponse($json);
            }

            // Données de la vue
            $documentsTypes = $this->getActivityService()->getTypesDocuments(true);

            $view = new ViewModel(
                [
                    'projectview' => $projectview,
@@ -3109,6 +3122,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                    'sortDirection' => $sortDirection,
                    'sortIgnoreNull' => $sortIgnoreNull,
                    'types' => $this->getActivityTypeService()->getActivityTypes(true),
                    'documentsTypes' => $documentsTypes,
                    'disciplines' => $this->getActivityService()->getDisciplines(),
                    'projectsIds' => $projectsIds,
                ]
+82 −60
Original line number Diff line number Diff line
@@ -19,8 +19,20 @@ use Oscar\Utils\DateTimeUtils;
 */
class ActivityRepository extends EntityRepository
{
    public function getActivitiesIdsWithTypeDocument(array $idsTypeDocument): array
    {
        $queryBuilder = $this->createQueryBuilder('a')
            ->select('DISTINCT a.id')
            ->innerJoin('a.documents', 'd')
            ->where('d.typeDocument IN(:typesDocument)')
            ->setParameter('typesDocument', $idsTypeDocument)
        ;

        return array_map('current', $queryBuilder->getQuery()->getArrayResult());
    }

    public function getActivitiesWithNumber( string $key ) :array {
    public function getActivitiesWithNumber(string $key): array
    {
        $len = strlen($key);
        $queryBuilder = $this->createQueryBuilder('a')
            ->where("a.numbers LIKE '%s:$len:\"" . $key . "\"%'");
@@ -40,8 +52,7 @@ class ActivityRepository extends EntityRepository
        $queryBuilder = $this->createQueryBuilder('a')
            ->select('a.id')
            ->where('a.codeEOTP IN(:pfis)')
            ->setParameter('pfis', $pfis)
        ;
            ->setParameter('pfis', $pfis);
        return array_map('current', $queryBuilder->getQuery()->getArrayResult());
    }

@@ -96,7 +107,9 @@ class ActivityRepository extends EntityRepository
            ->innerJoin('a.persons', 'ap')
            ->leftJoin('a.project', 'p')
            ->leftJoin('p.members', 'pp')
            ->where('(ap.person = :personId  OR pp.person = :personId) AND (a.dateStart < :date AND a.dateEnd >= :date)')
            ->where(
                '(ap.person = :personId  OR pp.person = :personId) AND (a.dateStart < :date AND a.dateEnd >= :date)'
            )
            ->setParameters(
                [
                    'personId' => "$personId",
@@ -190,9 +203,7 @@ class ActivityRepository extends EntityRepository
    public function getBaseQueryBuilder(): QueryBuilder
    {
        return $this->createQueryBuilder('c')
            ->leftJoin('c.project', 'p')

            ;
            ->leftJoin('c.project', 'p');
//            ->leftJoin('c.persons', 'm1')
//            ->leftJoin('m1.person', 'pers1')
//            ->leftJoin('c.disciplines', 'dis')
@@ -217,9 +228,11 @@ class ActivityRepository extends EntityRepository
            ->where('c.id in(:ids)')
            ->setFirstResult($offsetSQL)
            ->setMaxResults($limitSQL)
            ->setParameters([
            ->setParameters(
                [
                    'ids' => $ids
                            ]);
                ]
            );
    }

    /**
@@ -227,7 +240,8 @@ class ActivityRepository extends EntityRepository
     * @param int $idRole
     * @return array
     */
    public function getIdsWithoutPersonWithRole( int $idPerson, int $idRole ) :array {
    public function getIdsWithoutPersonWithRole(int $idPerson, int $idRole): array
    {
        $idsWith = $this->getIdsForPersonWithRole($idPerson, $idRole);
        $qb = $this->createQueryBuilder('a')
            ->select('a.id')
@@ -270,7 +284,8 @@ class ActivityRepository extends EntityRepository
     *
     * @return array
     */
    public function getIdsForPersonWithRole( int $idPerson, int $idRole ) :array {
    public function getIdsForPersonWithRole(int $idPerson, int $idRole): array
    {
        $qb = $this->createQueryBuilder('a')
            ->select('a.id')
            ->leftJoin('a.persons', 'act_per')
@@ -282,8 +297,10 @@ class ActivityRepository extends EntityRepository
        ];

        if ($idRole > 0) {
                $qb->where('(act_per.person = :person AND act_per.roleObj = :role) '
                           .'OR (prj_pers.person = :person AND prj_pers.roleObj = :role)');
            $qb->where(
                '(act_per.person = :person AND act_per.roleObj = :role) '
                . 'OR (prj_pers.person = :person AND prj_pers.roleObj = :role)'
            );
            $parameters['role'] = $idRole;
        } else {
            $qb->where('act_per.person = :person OR prj_pers.person = :person');
@@ -304,7 +321,8 @@ class ActivityRepository extends EntityRepository
     * @param array $status
     * @return array
     */
    public function getIdsWithStatus( array $status ) :array {
    public function getIdsWithStatus(array $status): array
    {
        $qb = $this->createQueryBuilder('a')
            ->select('a.id')
            ->where('a.status IN(:status)');
@@ -322,8 +340,8 @@ class ActivityRepository extends EntityRepository
        );
    }

    public function getBeetween2Dates( string $from, string $to, string $field ) :array {

    public function getBeetween2Dates(string $from, string $to, string $field): array
    {
        if (!$from && !$to) {
            throw new OscarException("Le filtrage par date implique des dates");
        }
@@ -354,7 +372,8 @@ class ActivityRepository extends EntityRepository
        );
    }

    public function getActivitiesIdsAll() :array {
    public function getActivitiesIdsAll(): array
    {
        $qb = $this->createQueryBuilder('a')
            ->select('a.id');

@@ -373,7 +392,8 @@ class ActivityRepository extends EntityRepository
     * @param int $idRole
     * @return array
     */
    public function getIdsWithoutOrganizationWithRole( int $idOrganization, int $idRole ) :array {
    public function getIdsWithoutOrganizationWithRole(int $idOrganization, int $idRole): array
    {
        $idsExclude = $this->getIdsForOrganizationWithRole($idOrganization, $idRole);
        $qb = $this->createQueryBuilder('a')
            ->select('a.id')
@@ -392,7 +412,8 @@ class ActivityRepository extends EntityRepository
     * @param int $idRole
     * @return array
     */
    public function getIdsForOrganizationWithRole( int $idOrganization, int $idRole ) :array {
    public function getIdsForOrganizationWithRole(int $idOrganization, int $idRole): array
    {
        $qb = $this->createQueryBuilder('a')
            ->select('a.id')
            ->leftJoin('a.organizations', 'act_org')
@@ -400,8 +421,7 @@ class ActivityRepository extends EntityRepository
            ->leftJoin('prj.partners', 'prj_org')
            ->where(
                'act_org.organization = :organization OR prj_org.organization = :organization'
            )
        ;
            );


        $parameters = [
@@ -409,8 +429,10 @@ class ActivityRepository extends EntityRepository
        ];

        if ($idRole > 0) {
            $qb->where('(act_org.organization = :organization AND act_org.roleObj = :role) '
                       .'OR (prj_org.organization = :organization AND prj_org.roleObj = :role)');
            $qb->where(
                '(act_org.organization = :organization AND act_org.roleObj = :role) '
                . 'OR (prj_org.organization = :organization AND prj_org.roleObj = :role)'
            );
            $parameters['role'] = $idRole;
        } else {
            $qb->where('act_org.organization = :organization OR prj_org.organization = :organization');
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ class JSONFormatter
                $principal = $activityOrganization->getRoleObj() && $activityOrganization->getRoleObj()->isPrincipal();

                if ($principal) {
                    if (!array_key_exists($role, $datas['organizations'])) {
                    if (!array_key_exists($role, $datas['organizations_primary'])) {
                        $datas['organizations_primary'][$role] = [];
                    }
                    $datas['organizations_primary'][$role][] = $organization;
+4 −0
Original line number Diff line number Diff line
@@ -1197,6 +1197,10 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi
        ];
    }

    public function getActivitiesIdsWithTypeDocument( array $idsTypeDocument ):array {
        return $this->getActivityRepository()->getActivitiesIdsWithTypeDocument($idsTypeDocument);
    }

    /**
     * Renomage des clefs pour les numérotations personnalisées;
     *
+27 −0
Original line number Diff line number Diff line
@@ -282,6 +282,25 @@
        </article>
    </script>

    <script type="text/x-handlebars" id="typedocument-tpl">
        <article class="criteria criteria-typedocument card">
            <div class="icon-docs"></div>
            {{#if error}}<strong class="text-danger"><i class="icon-attention-1"></i> {{error}}</strong>{{/if}}
            <input type="hidden" name="criteria[]" class="criteria" value="{{criteria}}"/>
            <small>{{typeLabel}}</small>
            <select class="select2 form-control val1 changer types" id="filter_typeorga" multiple>
                <?php foreach( $documentsTypes as $typeDocId=>$typeDoc ): ?>
                <option value="<?= $typeDocId ?>"><?= $typeDoc ?></option>
                <?php endforeach; ?>
            </select>
            <nav>
                <a href="#" class="delete">
                    <i class="icon-cancel-outline"></i>
                </a>
            </nav>
        </article>
    </script>

    <script type="text/x-handlebars" id="milestones-criteria-tpl">
        <article class="criteria criteria-{{type}} card">
            <div class="icon-calendar"></div>
@@ -758,6 +777,8 @@

                    var dom, applyChange;



                    if( datas.type == 'ap' || datas.type == 'sp' || datas.type == 'ao' || datas.type == 'so' ){
                        dom = $(tpl(datas));
                    }
@@ -783,6 +804,11 @@
                        datas.label = "Pays d'une des organisations";
                        dom = $(tplCountry(datas));
                    }
                    else if(datas.type == 'td' ){
                        //$documentsTypes
                        datas.label = "Type de document";
                        dom = $(tplTypeDocument(datas));
                    }
                    else if(datas.type == 'tnt' ) {
                        datas.label = "Type d'organisation";
                        dom = $(tplTypeOrga(datas));
@@ -1041,6 +1067,7 @@
                    tplStatus = Handlebars.compile($('#status-criteria-tpl').html()),
                    tplCountry = Handlebars.compile($('#country-tpl').html()),
                    tplTypeOrga = Handlebars.compile($('#typeorga-tpl').html()),
                    tplTypeDocument = Handlebars.compile($('#typedocument-tpl').html()),
                    tplFinance = Handlebars.compile($('#finance-criteria-tpl').html()),
                    tplType = Handlebars.compile($('#type-criteria-tpl').html()),
                    tplDiscipline = Handlebars.compile($('#discipline-criteria-tpl').html()),