Commit 4ea95329 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Affiche du ou des statuts sur l'IHM de recherche d'intervenant

parent b2ad8516
......@@ -482,15 +482,27 @@ class IntervenantController extends AbstractController
}
}
$container->recents[$intervenant->getCode()] = [
'civilite' => $intervenant->getCivilite() ? $intervenant->getCivilite()->getLibelleLong() : null,
'nom' => $intervenant->getNomUsuel(),
'prenom' => $intervenant->getPrenom(),
'date-naissance' => $intervenant->getDateNaissance(),
'structure' => (string)$intervenant->getStructure(),
'numero-personnel' => $intervenant->getSourceCode(),
'__horo_ajout__' => (int)date('U'),
];
if (isset($container->recents[$intervenant->getCode()])) {
$container->recents[$intervenant->getCode()] = [
'civilite' => $intervenant->getCivilite() ? $intervenant->getCivilite()->getLibelleLong() : null,
'nom' => $intervenant->getNomUsuel(),
'prenom' => $intervenant->getPrenom(),
'date-naissance' => $intervenant->getDateNaissance(),
'structure' => (string)$intervenant->getStructure(),
'statut' => (string)$intervenant->getStatut(),
'numero-personnel' => $intervenant->getSourceCode(),
'__horo_ajout__' => (int)date('U'),
];
} else {
if ($container->recents[$intervenant->getCode()]['statut'] && !is_array($container->recents[$intervenant->getCode()]['statut'])) {
$container->recents[$intervenant->getCode()]['statut'] = [$container->recents[$intervenant->getCode()]['statut']];
}
if (is_array($container->recents[$intervenant->getCode()]['statut'])) {
$container->recents[$intervenant->getCode()]['statut'][] = (string)$intervenant->getStatut();
} else {
$container->recents[$intervenant->getCode()]['statut'] = (string)$intervenant->getStatut();
}
}
uasort($container->recents, function ($a, $b) {
return $a['nom'] . ' ' . $a['prenom'] > $b['nom'] . ' ' . $b['prenom'];
......
......@@ -22,15 +22,31 @@ class RechercheProcessus
*/
public function rechercher($critere, $limit = 50, string $key = ':CODE')
{
if (strlen($critere) < 2) return [];
try {
return $this->rechercheGenerique($critere, $limit, $key, false);
} catch (\Exception $e) {
return $this->rechercheGenerique($critere, $limit, $key, true);
}
}
$anneeId = (int)$this->getServiceContext()->getAnnee()->getId();
$critere = Util::reduce($critere);
$criteres = explode('_', $critere);
$sql = '
WITH vrec AS (
/**
* @param string $critere
* @param integer $limit
*
* @return array
*/
public function rechercherLocalement($critere, $limit = 50, string $key = ':CODE')
{
return $this->rechercheGenerique($critere, $limit, $key, true);
}
private function sqlLocale(): string
{
return "
SELECT
i.id,
i.code,
......@@ -41,17 +57,24 @@ class RechercheProcessus
i.date_naissance,
s.libelle_court structure,
c.libelle_long civilite,
si.libelle statut,
i.critere_recherche critere,
i.annee_id
FROM
intervenant i
LEFT JOIN structure s ON s.id = i.structure_id
LEFT JOIN civilite c ON c.id = i.civilite_id
LEFT JOIN statut_intervenant si ON si.id = i.statut_id
WHERE
i.histo_destruction IS NULL
UNION ALL
";
}
private function sqlSource(): string
{
return "
SELECT
null id,
i.code,
......@@ -62,67 +85,32 @@ class RechercheProcessus
i.date_naissance,
s.libelle_court structure,
c.libelle_long civilite,
si.libelle statut,
i.critere_recherche critere,
i.annee_id
FROM
src_intervenant i
LEFT JOIN structure s ON s.id = i.structure_id
LEFT JOIN civilite c ON c.id = i.civilite_id
)
SELECT * FROM vrec WHERE
rownum <= ' . (int)$limit . ' AND annee_id = ' . $anneeId;
$sqlCri = '';
$criCode = 0;
LEFT JOIN statut_intervenant si ON si.id = i.statut_id
";
}
foreach ($criteres as $c) {
$cc = (int)$c;
if (0 === $cc) {
if ($sqlCri != '') $sqlCri .= ' AND ';
$sqlCri .= 'critere LIKE q\'[%' . $c . '%]\'';
} else {
$criCode = $cc;
}
}
$orc = [];
if ($sqlCri != '') {
$orc[] = '(' . $sqlCri . ')';
}
if ($criCode) {
$orc[] = 'code LIKE \'%' . $criCode . '%\'';
}
$orc = implode(' OR ', $orc);
$sql .= ' AND (' . $orc . ') ORDER BY nom_usuel, prenom';
$intervenants = [];
try {
$stmt = $this->getEntityManager()->getConnection()->executeQuery($sql);
while ($r = $stmt->fetch()) {
$intervenants[$this->makeKey($r, $key)] = [
'civilite' => $r['CIVILITE'],
'nom' => $r['NOM_USUEL'],
'prenom' => $r['PRENOM'],
'date-naissance' => new \DateTime($r['DATE_NAISSANCE']),
'structure' => $r['STRUCTURE'],
'numero-personnel' => $r['CODE'],
];
}
} catch (\Exception $e) {
return $this->rechercherLocalement($critere, $limit, $key);
protected function makeKey(array $data, string $key): string
{
$resKey = $key;
foreach ($data as $k => $v) {
$resKey = str_replace(':' . $k, $v, $resKey);
}
return $intervenants;
return $resKey;
}
/**
* @param string $critere
* @param integer $limit
*
* @return array
*/
public function rechercherLocalement($critere, $limit = 50, string $key = ':CODE')
private function rechercheGenerique($critere, $limit = 50, string $key = ':CODE', $onlyLocale = false)
{
if (strlen($critere) < 2) return [];
......@@ -131,26 +119,15 @@ class RechercheProcessus
$critere = Util::reduce($critere);
$criteres = explode('_', $critere);
$sqlSource = '';
if (!$onlyLocale) {
$sqlSource = ' UNION ALL ' . $this->sqlSource();
}
$sql = '
WITH vrec AS (
SELECT
i.id,
i.code,
i.statut_id,
i.nom_usuel,
i.nom_patronymique,
i.prenom,
i.date_naissance,
s.libelle_court structure,
c.libelle_long civilite,
i.critere_recherche critere,
i.annee_id
FROM
intervenant i
LEFT JOIN structure s ON s.id = i.structure_id
LEFT JOIN civilite c ON c.id = i.civilite_id
WHERE
i.histo_destruction IS NULL
' . $this->sqlLocale() . '
' . $sqlSource . '
)
SELECT * FROM vrec WHERE
rownum <= ' . (int)$limit . ' AND annee_id = ' . $anneeId;
......@@ -178,34 +155,33 @@ class RechercheProcessus
$intervenants = [];
try {
$stmt = $this->getEntityManager()->getConnection()->executeQuery($sql);
while ($r = $stmt->fetch()) {
$intervenants[$this->makeKey($r, $key)] = [
$stmt = $this->getEntityManager()->getConnection()->executeQuery($sql);
while ($r = $stmt->fetch()) {
$k = $this->makeKey($r, $key);
if (!isset($intervenants[$k])) {
$intervenants[$k] = [
'civilite' => $r['CIVILITE'],
'nom' => $r['NOM_USUEL'],
'prenom' => $r['PRENOM'],
'date-naissance' => new \DateTime($r['DATE_NAISSANCE']),
'structure' => $r['STRUCTURE'],
'statut' => $r['STATUT'],
'numero-personnel' => $r['CODE'],
];
} else {
if ($intervenants[$k]['statut'] && !is_array($intervenants[$k]['statut'])) {
$intervenants[$k]['statut'] = [$intervenants[$k]['statut']];
}
if (is_array($intervenants[$k]['statut'])) {
$intervenants[$k]['statut'][] = $r['STATUT'];
} else {
$intervenants[$k]['statut'] = $r['STATUT'];
}
}
} catch (\Exception $e) {
// à traiter si la vue source intervenant n'existe pas!!
}
return $intervenants;
}
protected function makeKey(array $data, string $key): string
{
$resKey = $key;
foreach ($data as $k => $v) {
$resKey = str_replace(':' . $k, $v, $resKey);
}
return $resKey;
}
}
\ No newline at end of file
......@@ -71,7 +71,7 @@ class IndicateurService extends AbstractEntityService
/* Filtrage par structure, si nécessaire */
if (!$structure) {
$role = $this->getServiceContext()->getSelectedIdentityRole();
if ($role){
if ($role) {
$structure = $role->getStructure();
}
}
......@@ -86,12 +86,12 @@ class IndicateurService extends AbstractEntityService
/**
* @param integer|Indicateur $indicateur Indicateur concerné
* @param Structure|null $structure
* @param integer|Indicateur $indicateur Indicateur concerné
* @param Structure|null $structure
*/
public function getCount(Indicateur $indicateur, Structure $structure = null)
{
$key = $indicateur->getNumero().'_'.($structure ? $structure->getId() : '0');
$key = $indicateur->getNumero() . '_' . ($structure ? $structure->getId() : '0');
if (!isset($this->countCache[$key])) {
$qb = $this->getBaseQueryBuilder($indicateur, $structure);
......@@ -117,7 +117,7 @@ class IndicateurService extends AbstractEntityService
$qb->join('indicateur.intervenant', 'intervenant');
$qb->addSelect('indicateur');
$qb->addSelect('partial intervenant.{id, nomUsuel, prenom, email, code, sourceCode}');
$qb->addSelect('partial intervenant.{id, nomUsuel, prenom, emailPerso, emailPro, code}');
$qb->addSelect('partial structure.{id, libelleCourt, libelleLong}');
$qb->leftJoin('indicateur.structure', 'structure');
......@@ -183,7 +183,7 @@ class IndicateurService extends AbstractEntityService
*/
public function orderBy(QueryBuilder $qb = null, $alias = null)
{
list($qb, $alias) = $this->initQuery($qb, $alias);
[$qb, $alias] = $this->initQuery($qb, $alias);
$qb->addOrderBy("$alias.type, $alias.ordre");
......@@ -201,7 +201,7 @@ class IndicateurService extends AbstractEntityService
*/
public function getList(QueryBuilder $qb = null, $alias = null)
{
list($qb, $alias) = $this->initQuery($qb, $alias);
[$qb, $alias] = $this->initQuery($qb, $alias);
$qb->andWhere("$alias.enabled = 1");
......
......@@ -3,6 +3,7 @@
namespace Application\View\Helper\Intervenant;
use Application\Constants;
use Application\Service\Traits\ContextServiceAwareTrait;
use Zend\View\Helper\AbstractHtmlElement;
use Application\Entity\Db\Intervenant;
use Application\Entity\Db\Traits\IntervenantAwareTrait;
......@@ -15,6 +16,7 @@ use Application\Entity\Db\Traits\IntervenantAwareTrait;
class IntervenantViewHelper extends AbstractHtmlElement
{
use IntervenantAwareTrait;
use ContextServiceAwareTrait;
......@@ -127,9 +129,15 @@ class IntervenantViewHelper extends AbstractHtmlElement
public function renderTitle(?string $title)
{
$title = 'tt' . $title;
$title = $title;
$intervenant = $this->getIntervenant();
if ($this->getServiceContext()->getIntervenant() == $intervenant) {
} else {
}
//echo $intervenant . ' <small>' . $intervenant->getStatut() . '</small>';
$this->getView()->headTitle()->append($intervenant->getNomUsuel())->append($title);
......
......@@ -5,11 +5,12 @@
<thead>
<tr>
<th style="width:1%">&nbsp;</th>
<th style="width:10%">Civilité</th>
<th style="width:18%">Nom</th>
<th style="width:18%">Prénom</th>
<th style="width:18%">Structure</th>
<th style="width:18%">Date de naissance</th>
<th style="width:5%">Civilité</th>
<th style="width:15%">Nom</th>
<th style="width:15%">Prénom</th>
<th style="width:15%">Structure</th>
<th style="width:15%">Statut</th>
<th style="width:15%">Date de naissance</th>
<th style="width:10%">N° personnel</th>
</tr>
</thead>
......@@ -25,6 +26,12 @@
<td><?= $intervenant['nom'] ?></td>
<td><?= $intervenant['prenom'] ?></td>
<td><?= $intervenant['structure'] ?></td>
<td><?php if (is_array($intervenant['statut'])): ?>
<abbr title="<?= implode("\n", $intervenant['statut']) ?>">Multiples</abbr>
<?php else: ?>
<?= $intervenant['statut'] ?>
<?php endif; ?>
</td>
<td><?= $intervenant['date-naissance']->format(\Application\Constants::DATE_FORMAT) ?></td>
<td><?= $intervenant['numero-personnel'] ?></td>
</tr>
......
Supports Markdown
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