Commit 8f3971ce authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix : Plus de mail envoyé quand des notifications non-active sont non-lues...

Fix : Plus de mail envoyé quand des notifications non-active sont non-lues (Prend uniquement en compte les notifications actives)
parent 2fe4dfbf
Loading
Loading
Loading
Loading
+93 −8
Original line number Diff line number Diff line
<template>
  <div>

    <template>
      <div class="oscar-ajax" v-show="loading || error">
        <div class="oscar-ajax-content">
@@ -15,7 +14,7 @@
        </div>
      </div>
    </template>
    <code>{{ entityEdited }}</code>

    <div class="overlay" v-if="entityDelete">
      <div class="overlay-content">
        <i class="icon-cancel-outline overlay-closer" @click="entityDelete = null"></i>
@@ -62,6 +61,7 @@
                en tant que <em>{{ entityEdited.role }}</em>
            </span>
          </h2>

          <input type="hidden" name="enroled" class="form-control select2" v-model="entityEdited.enrolled"/>

          <div class="row">
@@ -172,7 +172,56 @@
        <i class="icon-doc-add"></i>
        Nouveau
      </a>
      <a class="oscar-link" @click="handlerEditEnable()">
        <i class="icon-edit"></i>
        Modifier
      </a>
    </nav>

    <section v-if="editMode">
      <div class="alert alert-info">
        Détails des affectations. Une personne peut apparaître plusieurs fois selon le contexte et le rôle
      </div>
      <article class="row card" v-for="e in sortedFull">
        <div class="col-md-6">
          <i class="icon-cube" v-if="e.context == 'activity'"></i>
          <i class="icon-cubes" v-else></i>
          <strong>{{ e.enrolledLabel }}</strong>
          <small>
            (<span v-if="e.context == 'activity'">
                <i class="icon-cube"></i>
                {{ e.contextKey }}</span>
              <span v-else>
                <i class="icon-cubes"></i>
                {{ e.contextKey }}</span>)
          </small>
        </div>
        <div class="col-md-3">
          <em :class="{'bold': e.rolePrincipal }">{{ e.roleLabel }}</em>
        </div>
        <div class="col-md-3 text-right">
          <a  @click="handlerEdit(e)" style="white-space: nowrap">
            <i class="icon-pencil-1 icon-clickable" v-if="manage"></i>&nbsp;Modifier
          </a>

          <a  @click="handlerDelete(e)" style="white-space: nowrap">
            <i class="icon-trash icon-clickable" v-if="manage"></i>&nbsp;Supprimer
          </a>
        </div>
      </article>
    </section>
    <section v-else>
      <span class="cartouche" v-for="e in stacked" :class="e.hasPrimary ? 'primary' : 'default' ">
        {{ e.enrolledLabel }}
        <span class="addon principal" >
          <span v-for="r in e.roles" class="addon-module" :class="{'primary': r.rolePrincipal}">
            {{ r.role }}
          </span>
        </span>
      </span>
    </section>

<!--
    <span class="cartouche" v-for="e in entities" :class="{'primary': e.rolePrincipal, 'outofdate past': e.past }">
      <i v-if="e.context == 'activity'" class="icon-cube"></i>
      <i v-else class="icon-cubes"></i>
@@ -184,6 +233,7 @@
        <i class="icon-trash icon-clickable" v-if="manage" @click="handlerDelete(e)"></i>
      </span>
    </span>
-->
  </div>
</template>
<script>
@@ -221,10 +271,42 @@ export default {
      entityDelete: null,
      entityNew: null,
      error: null,
      loading: false
      loading: false,
      editMode: false
    };
  },

  computed: {
    sortedFull(){
      console.log("sort");
      return this.entities.sort( (a, b) => a.enrolled - b.enrolled )
    },
    stacked(){
      let stacks = {};
      this.entities.forEach(i => {
        let id = i.enrolled;
        if( !stacks.hasOwnProperty(id) ){
          stacks[id] = {
            enrolled: i.enrolled,
            enrolledLabel: i.enrolledLabel,
            hasPrimary: false
          }
          stacks[id]['roles'] = {};
        }
        stacks[id]['roles'][i.roleId] = {
          role: i.roleLabel,
          roleId: i.roleId,
          rolePrincipal: i.rolePrincipal,
          context: i.context,
        };
        if( i.rolePrincipal ){
          stacks[id].hasPrimary = true;
        }

      })
      return stacks;
    }
  },

  methods: {
    handlerEdit(item) {
@@ -266,9 +348,12 @@ export default {
      document.location = url;
    },

    handlerEditEnable() {
      this.editMode = !this.editMode;
    },

    performDelete() {
      this.loading = "Suppression...";
      console.log(url, this.entityDelete);
      var url = this.entityDelete.urlDelete;
      this.entityDelete = null;

+9 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ use Oscar\Service\OscarUserContext;
use Oscar\Service\PersonService;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

@@ -19,6 +20,7 @@ class OscarNotificationsMailsPersonsCommand extends OscarCommandAbstract
    {
        $this
            ->setDescription("Déclenche la procédure d'envoi des notifications par mail")
            ->addOption('date', 'd', InputOption::VALUE_OPTIONAL, 'date de déclenchement', null)
        ;
    }

@@ -28,9 +30,15 @@ class OscarNotificationsMailsPersonsCommand extends OscarCommandAbstract

        $io = new SymfonyStyle($input, $output);

        $date = $input->getOption('date');
        $dateRef = null;
        if( $date ){
            $dateRef = new \DateTime(date('Y-m-d ') . $date);
        }

        /** @var PersonService $personService */
        $personService = $this->getServicemanager()->get(PersonService::class);

        $personService->mailPersonsWithUnreadNotification(null, $io);
        $personService->mailPersonsWithUnreadNotification($dateRef->format('Y-m-d H:i:s'), $io);
    }
}
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -2124,6 +2124,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $editable = $editableA;
                $deletable = $deletableA;
                $context = "activity";
                $contextKey = $activityPerson->getActivity()->getOscarNum();
                $idEnroller = $activityPerson->getActivity()->getId();
            } else {
                $urlDelete = $deletableA ? $this->url()->fromRoute(
@@ -2137,6 +2138,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $editable = $editableP;
                $deletable = $deletableP;
                $context = "project";
                $contextKey = $activityPerson->getProject()->getAcronym();
                $idEnroller = $activityPerson->getProject()->getId();
            }
            $urlShow = false;
@@ -2155,6 +2157,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                'rolePrincipal' => $activityPerson->isPrincipal(),
                'urlDelete' => $urlDelete,
                'context' => $context,
                'contextKey' => $contextKey,
                'urlEdit' => $urlEdit,
                'urlShow' => $urlShow,
                'past' => $activityPerson->isPast(),
@@ -2223,10 +2226,12 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                $editable = $editableA;
                $deletable = $deletableA;
                $context = "activity";
                $contextKey = $activityOrganization->getActivity()->getOscarNum();
            } else {
                $editable = $editableP;
                $deletable = $deletableP;
                $context = "project";
                $contextKey = $activityOrganization->getProject()->getAcronym();
            }

            $urlDelete = $deletableA ? $this->url()->fromRoute(
@@ -2252,6 +2257,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
                'rolePrincipal' => $activityOrganization->isPrincipal(),
                'urlDelete' => $urlDelete,
                'context' => $context,
                'contextKey' => $contextKey,
                'urlEdit' => $urlEdit,
                'urlShow' => $urlShow,
                'enroller' => $activity->getId(),
+4 −1
Original line number Diff line number Diff line
@@ -243,7 +243,10 @@ class PersonRepository extends EntityRepository implements IConnectedRepository
                )
            )
            ->innerJoin(NotificationPerson::class, 'n', Join::WITH, $qb->expr()->eq('p.id', 'n.person'))
            ->where('n.read IS NULL')
            ->innerJoin('n.notification', 'nt')
            ->where('n.read IS NULL AND nt.dateEffective <= :now')
            ->orderBy('p.lastname', 'ASC')
            ->setParameter('now', date('Y-m-d'))
            ->getQuery()
            ->getResult();

+7 −0
Original line number Diff line number Diff line
@@ -57,6 +57,13 @@ class EnrollToArrayFormatter
        $output['rolePrincipal'] = $affectation->getRoleObj()->isPrincipal();
        $output['roleId'] = $affectation->getRoleObj()->getId();
        $output['context'] = $context;
        $output['contextKey'] = '';
        if( $context == 'activity' ){
            $output['contextKey'] = $affectation->getEnroller()->getOscarNum();
        }
        if( $context == 'project' ){
            $output['contextKey'] = $affectation->getEnroller()->getAcronym();
        }

        $manage = false;
        $show = false;
Loading