Commit 8698e250 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Prévisualisation des PDF sur l'écran des visas + affichage des étapes

parent 2ac951d0
Loading
Loading
Loading
Loading
Loading
+1 −1
Changes for module/Oscar/config/module.config.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ return array(
                ////////////////////////////////////////////////////////////////
                [
                    'controller' => 'Project',
                    'action' => ['edit', 'export', 'makeProject', 'organizations', 'persons', 'new', 'search', 'show'],
                    'action' => ['edit', 'export', 'makeProject', 'organizations', 'persons', 'new', 'search', 'show', 'show2'],
                    'roles' => ['user'],
                ],
                [
+8 −0
Changes for module/Oscar/config/routes.yml: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -518,6 +518,14 @@ project:
          action: show
      may_terminate: true

    ### Fiche du projet :id
    show2:
      type: segment
      options:
        route: '/show2/:id'
        defaults:
          action: show2
      may_terminate: true

    ### Edition des informations
    edit:
+45 −0
Changes for module/Oscar/src/Oscar/Controller/ProjectController.php: 45 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -272,6 +272,51 @@ class ProjectController extends AbstractOscarController
        }
    }

    public function show2Action() {
        try {
            $id = $this->params()->fromRoute('id', 0);
            $entity = $this->getProjectService()->getProject($id, true);
            $this->getOscarUserContextService()->check(Privileges::PROJECT_SHOW, $entity);
            $format = $this->params()->fromQuery('f', null);


            if ($this->getRequest()->isXmlHttpRequest() || $format === 'json') {
                $perimeter = $this->params()->fromQuery('p', 'all');
                if ($perimeter) {
                    if ($perimeter == 'logs') {
                        $this->getOscarUserContextService()->check(Privileges::MAINTENANCE_MENU_ADMIN);
                        try {
                            $datas = $this->getProjectService()->api(
                                $entity->getId(),
                                $this->url(),
                                $this->getOscarUserContextService(),
                                'logs'
                            );
                            return $this->jsonOutput($datas);
                        } catch (\Exception $e) {
                            return $this->jsonError($e->getMessage());
                        }
                    } elseif ($perimeter == 'all') {
                        $datas = $this->getProjectService()->api(
                            $entity->getId(),
                            $this->url(),
                            $this->getOscarUserContextService(),
                            $perimeter
                        );
                        return $this->jsonOutput($datas);
                    } else {
                        throw new OscarException("Périmètre inconnu");
                    }
                }
            }
            return [
                'project' => $entity,
            ];
        } catch (\Exception $e) {
            throw new OscarException($e->getMessage());
        }
    }

    /**
     * Nouvelle description de Projet.
     *
+36 −0
Changes for module/Oscar/src/Oscar/Service/ProjectService.php: 36 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -142,6 +142,18 @@ class ProjectService implements UseServiceContainer
            'credentials' => null,
            'traces'       => $output
        ];

        if( $perimeters === 'all' ){
            $out['datas'] = [
                'core' => $this->getProjectDataCore($project),
                'activities' => $this->getProjectDataActivities(
                    $project,
                    $urlPlugin,
                    $oscarUserContext
                ),
            ];
        }

        return $out;
    }
    public function fixMovePartnersToActivities(
@@ -758,4 +770,28 @@ class ProjectService implements UseServiceContainer


    ///
    private function getProjectDataCore(Project $project) :array
    {
        return [
            'id' => $project->getId(),
            'label' => $project->getLabel(),
            'acronym' => $project->getAcronym(),
            'description' => $project->getDescription(),
        ];
    }

    private function getProjectDataActivities(Project $project, Url $urlHelper, OscarUserContext $oscarUserContext): array
    {
        $output = [];
        /** @var ProjectGrantApiService $projectGrantApiService */
        $projectGrantApiService = $this->getServiceContainer()->get(ProjectGrantApiService::class);
        foreach ($project->getActivities() as $activity) {
            $output[] = $projectGrantApiService->getActivityJson(
                $activity->getId(),
                $urlHelper,
                $oscarUserContext
            );
        }
        return $output;
    }
}
+8 −328
Changes for module/Oscar/view/oscar/project/show2.phtml: 8 added lines, 328 removed lines.
Original line number Diff line number Diff line
<?php

/** @var \Oscar\Entity\Project $project */

use Oscar\OscarText; ?>
<nav class="container">
    <a href="javascript:history.back()">
        <i class=" icon-angle-left"></i>Retour</a>
</nav>

<article class="project-full container">
    <section class="informations">
        <header class="jumbotron activity-header oscar-header has-btn">
            <div class="row">
                <div class="col-md-9">
                    <h4>
                        <i class="icon-cubes"></i>
                        <?= $this->oscarText("Projet") ?>
                    </h4>
                    <h1>
                        <?php if ($project->getAcronym()): ?>
                            <abbr title="<?= htmlentities($project->getLabel()) ?>">
                                <?= $project->getAcronym() ?>
                            </abbr>
                        <?php endif; ?>
                        <?= $project->getLabel() ?>
                    </h1>
                </div>
                <div class="col-md-3">
                    <div class="budget montant">
                        <small>
                            <em>
                                <?= $this->oscarText("Montant projet") ?>
                            </em>
                        </small><br>
                        <strong><?= $this->currency($project->getAmount()) ?></strong>
                    </div>
                </div>
            </div>

            <?php if( $this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_EDIT, $project) ): ?>
            <nav class="admin-bar">
                <a class="btn btn-primary"
                   href="<?= $this->url('project/edit', ['id'=>$project->getId()]) ?>">
                    <i class="icon-tag"></i> Modifier les informations
                </a>
                <?php if( $this->grant()->privilegeDeep(\Oscar\Provider\Privileges::ACTIVITY_CREATE)): ?>
                    <a class="btn btn-primary"
                       href="<?= $this->url('contract/new', ['projectid' => $project->getId()]) ?>">
                        <i class="icon-cube"></i>Ajouter une activité
                    </a>
                <?php endif; ?>

                <?php if ($this->grant()->privilege(\Oscar\Provider\Privileges::MAINTENANCE_MENU_ADMIN)): ?>
                    <a class="btn btn-danger"
                       href="<?= $this->url('project/delete', ['id' => $project->getId()]) ?>">
                        <i class="icon-trash"></i>
                        <?= $this->oscarText("Supprimer ce projet") ?>
                    </a>
                <?php endif; ?>

                <a class="btn btn-light" href="<?= $this->url('project/simplify-partners', ['id'=>$project->getId()]) ?>">
                    <i class="icon-building-filled"></i>
                    <?= $this->oscarText("Simplifier les partenaires") ?>
                </a>
                <a class="btn btn-light" href="<?= $this->url('project/simplify-members', ['id'=>$project->getId()]) ?>">
                    <i class="icon-group"></i>
                    <?= $this->oscarText("Simplifier les membres") ?>
                </a>
            </nav>
            <?php endif; ?>

        </header>

        <h2>
            <i class="icon-tag"></i>
            Informations
        </h2>

        <div class="row card has-btn">
            <?php if ($this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_EDIT, $project)): ?>
            <nav class="btn-area">
                <a href="<?= $this->url('project/edit', ['id' => $project->getId()]) ?>" class="smoke">
                    <i class="icon-pencil-1"></i> Modifier
                </a>
            </nav>
            <?php endif; ?>

            <div class="col-md-7">
                <h3>Description</h3>
                <p><?= $project->getDescription() ?></p>

                <h3>Codes</h3>
                <ul class="text-highlight">
                    <li>
                        N°<?= $this->options()->getConfiguration()->getFinancialLabel() ?> :
                        <strong><?= implode(', ', $project->getEotp()) ?></strong>
                    </li>
                </ul>
            </div>

            <div class="col-md-5 dates">
                <h3>Dates</h3>
                <ul class="text-highlight">
                    <li>Créé le <time><?= $this->moment($project->getDateCreated()) ?></time></li>
                    <li>MAJ le <time><?= $this->moment($project->getDateUpdated()) ?></time></li>
                </ul>
            </div>
        </div>
    </section>


    <section class="row">
        <div class="col-md-8">
            <?php if ($this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_SHOW, $project)): ?>
            <section id="activities" class="has-btn">

                <?php if ($this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_ACTIVITY_ADD, $project) && $this->grant()->privilegeDeep(\Oscar\Provider\Privileges::ACTIVITY_CREATE)): ?>
                    <div class="btn-area">
                        <a href="<?= $this->url('contract/new', ['projectid' => $project->getId()]) ?>" class="smoke">
                            <i class="icon-cube"></i>
                            <?= $this->oscarText("Nouvelle activité") ?>
                        </a>
                    </div>
                <?php endif; ?>

                <h2>
                    <i class="icon-cube"></i>
                    <?= $this->oscarText("Activités") ?>
                </h2>
                <?php
                $year = null; $totalYear = 0.0; $totalProject = 0.0; $nbrContratYear = 0;
                /** @var \Oscar\Entity\Activity $contract */
                foreach ($project->getGrants() as $contract):

                    // En-tête de regroupement
                    $projectYear = $contract->getDateCreated()->format('Y');
                    if($year != $projectYear ){
                        echo '<div class="list-separator"><h3 class="list-separator-label">'.$projectYear.'</h3></div>';
                        $year = $projectYear;
                        $totalYear = 0.0;
                        $nbrContratYear = 0.0;
                    } // En-tête de regroupement [fin]

                    $rate = $contract->getCurrency() ? $contract->getCurrency()->getRate() : 1;
                    $totalYear += $contract->getAmount() * $rate;
                    $totalProject += $contract->getAmount()  * $rate;
                    $nbrContratYear++;

                    echo $this->partial('/oscar/project-grant/item-list.phtml', ['activity' => $contract, 'hideProject'=> true, 'deepMembers' => false, 'documentsDisplay' => false])
                    ?>
                <?php endforeach; ?>

                <?php if( $this->grant()->privilege(\Oscar\Provider\Privileges::ACTIVITY_CHANGE_PROJECT) ): ?>
                    <form action="<?= $this->url('project/add-activities', ['id' => $project->getId() ]) ?>" method="post">
                        <?= $this->oscarText("Associer une activité existante à ce projet") ?>
                        <div class="row">
                            <div class="col-md-10">
                                <select name="activities_ids[]" id="activities-choose" data-url="<?= $this->url('contract/advancedsearch') ?>" multiple></select>
                            </div>
                            <div class="col-md-2">
                                <button type="submit" class="btn btn-primary" style="display: block">
                                    Envoyer
                                </button>
                            </div>
                        </div>
                        <div id="activities-toadd">

                        </div>
                    </form>
                    <script>
                        require(['jquery','select2'], function($) {
                            var formatRepo, formatRepoSelection;

                            formatRepo = function (repo) {
                                if (repo.loading) return repo.text;

                                var markup = '<div class="clearfix">';
                                markup += ( (repo.numOscar?'<strong>['+repo.numOscar+']</strong> ':'') + repo.label) || repo.text;
                                markup += '</div>';

                                return markup;
                            };

                            formatRepoSelection = function (repo) {
                                return ( (repo.numOscar?'<strong>['+repo.numOscar+']</strong> ':'') + repo.label) || repo.text;
                            };

                            $('#activities-choose').select2({
                                placeholder: 'Rechercher...',
                                width: '100%',
                                allowClear: true,
                                ajax: {
                                    url: $('#activities-choose').data('url'),
                                    dataType: 'json',
                                    delay: 250,
                                    data: function (params) {
                                        return {
                                            q: params.term, // search term
                                            page: params.page
                                        };
                                    },
                                    processResults: function (data, page) {
                                        return {results: data.activities};
                                    },
                                    cache: true
                                },
                                escapeMarkup: function (markup) {
                                    return markup;
                                },
                                minimumInputLength: 4,
                                templateResult: formatRepo, // omitted for brevity, see the source of this page
                                templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
                            });
                        });
                    </script>
                <?php endif; ?>

                <?php endif; ?>
            </section>
        </div>
        <div class="col-md-4">
            <!-- %%%%%%%%%%%%%%%%%%%%%%%% DEPENSES %%%%%%%%%%%%%%%%%%%%%%%% -->
            <?php
            /*
            'spentActivitiesIds' => $spentActivitiesIds,
                'spentMissingAcces' => $nbrSpentAllow < $nbrSpent,
             */
            // ------------------------------------------------------------------------------------------------ DÉPENSES
            if (count($spentActivitiesIds) > 0) : ?>
                <section>
                    <h2>
                        <i class="icon-book"></i>
                        <?= $this->oscarText("Dépenses") ?>
                    </h2>

                    <div id="depenses2"
                         data-syncurl=""
                         data-url="<?= $this->url('contract/spent-synthesis', ['id' => implode(',', $spentActivitiesIds)]) ?>">DEPENSES2
                    </div>
                    <?= $this->Vite()->addJs('src/ProjectActivitySpentSynthesis.js'); ?>

                </section>
            <?php endif; ?>


            <!-- %%%%%%%%%%%%%%%%%%%%%%%% DOCUMENTS %%%%%%%%%%%%%%%%%%%%%%%% -->
            <?php if($this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_DOCUMENT_SHOW, $project)): ?>
                <section id="documents" class="">
                    <h2>
                        <i class="icon-book"></i>
                        <?= $this->oscarText("Documents") ?>
                    </h2>

                    <?php if( count($documents) ): ?>
                        <?php
                        /** @var \Oscar\Entity\ContractDocument $document */
                        foreach( $documents as $document ): ?>
                            <?php if ($this->grant()->hasDocumentAccess($document)): ?>
                            <?= $this->partial('oscar/contract-document/list-item.phtml',
                                               ['document' => $document, 'showActivity'=>true]) ?>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <p class="no-data">Aucune information visible</p>
                    <?php endif; ?>
                </section>
            <?php endif; ?>
        </div>
    </section>



    <section>
        <?php if ($this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_PERSON_SHOW, $project)): ?>
            <section class="has-btn">
                <h2>
                    <i class="icon-group"></i>
                    <?= $this->oscarText("Membres") ?>
                </h2>
                <section id="persons_roled"
                         data-title="<?= $this->oscarText("Personne") ?>"
<div class="container">
    <div class="activity" id="project"
            <?php if( DEBUG_OSCAR ) echo 'data-debug-enabled="true"' ?>
         data-url="<?php echo $this->url('project/show2', ['id' => $project->getId()]) ?>"
         data-enrole-with-date="<?= $this->oscarConfig("enroleWithDate", true) ? "" : "false"  ?>"
                         data-url="<?= $this->url('project/persons', ['idproject' => $project->getId()]) ?>"></section>
                <?= $this->Vite()->addJs('src/EntityWithRolePersons.js'); ?>
            </section>
        <?php endif; ?>

        <?php if ($this->grant()->privilege(\Oscar\Provider\Privileges::ACTIVITY_ORGANIZATION_SHOW, $project)): ?>
            <section class="has-btn">
                <h2>
                    <i class="icon-group"></i>
                    <?= $this->oscarText("Partenaires") ?>
                </h2>
                <section id="organizations_roled"
                         data-title="<?= $this->oscarText('Organisation') ?>"
                         data-enrole-with-date="<?= $this->oscarConfig("enroleWithDate", true) ? "" : "false"  ?>"
                         data-url="<?= $this->url('project/organizations', ['idproject' => $project->getId()]) ?>"></section>
                <?= $this->Vite()->addJs('src/EntityWithRoleOrganizations.js'); ?>
            </section>
        <?php endif; ?>

        <?php if ($this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_ORGANIZATION_SHOW, $project)): ?>
        <?php else: ?>
            <p class="credential-msg">Droits insuffisants</p>
        <?php endif; ?>
    </section>

    <?php if( $this->grant()->privilege(\Oscar\Provider\Privileges::MAINTENANCE_MENU_ADMIN) ): ?>
    <section id="logs" class="">
        <h2>
            <i class="icon-signal"></i>
            Logs
        </h2>
        <section id="activity-logs"
                 data-url="<?= $logs_url ?>"></section>
        <?= $this->Vite()->addJs('src/ProjectActivityLogs.js'); ?>
    </section>
    <?php endif; ?>

    <script>
        Initer.ready(function(){
            require(['modalform'], function(modalform){
               modalform($('body'));
            });
        });
    </script>
</article>
         data-manage="<?php $this->grant()->privilege(\Oscar\Provider\Privileges::PROJECT_EDIT, $project) ? "true" : "false" ?>"
    ></div>
    <?= $this->Vite()->addJs('src/Project.js'); ?>
</div>
 No newline at end of file
Loading