PHRAS-1173 SQL fix and template update

This commit is contained in:
Xavier Rousset
2016-10-11 15:27:13 +02:00
parent c689a59409
commit 7945994140
2 changed files with 48 additions and 26 deletions

View File

@@ -84,7 +84,7 @@ class RegistrationRepository extends EntityRepository
$data = []; $data = [];
$rsm = $this->createResultSetMappingBuilder('d'); $rsm = $this->createResultSetMappingBuilder('d');
$rsm->addScalarResult('sbas_id','sbas_id'); $rsm->addScalarResult('sbas_id','sbas_id');
$rsm->addScalarResult('bas_id','bas_id'); $rsm->addScalarResult('base_id','base_id');
$rsm->addScalarResult('dbname','dbname'); $rsm->addScalarResult('dbname','dbname');
$rsm->addScalarResult('time_limited', 'time_limited'); $rsm->addScalarResult('time_limited', 'time_limited');
$rsm->addScalarResult('limited_from', 'limited_from'); $rsm->addScalarResult('limited_from', 'limited_from');
@@ -96,22 +96,20 @@ class RegistrationRepository extends EntityRepository
UNIX_TIMESTAMP( limited_from ) AS limited_from, UNIX_TIMESTAMP( limited_from ) AS limited_from,
UNIX_TIMESTAMP( limited_to ) AS limited_to, UNIX_TIMESTAMP( limited_to ) AS limited_to,
bas.server_coll_id, Users.id, basusr.actif, bas.server_coll_id, Users.id, basusr.actif,
bas.base_id AS bas_id , " . $rsm->generateSelectClause(['d' => 'd',]) . " bas.base_id, " . $rsm->generateSelectClause(['d' => 'd',]) . "
FROM (Users, bas, sbas) FROM (Users, bas, sbas)
LEFT JOIN basusr ON ( Users.id = basusr.usr_id AND bas.base_id = basusr.base_id ) LEFT JOIN basusr ON ( Users.id = basusr.usr_id AND bas.base_id = basusr.base_id )
LEFT JOIN Registrations d ON ( d.user_id = Users.id AND bas.base_id = d.base_id ) LEFT JOIN Registrations d ON ( d.user_id = Users.id AND bas.base_id = d.base_id )
WHERE bas.active = 1 AND bas.sbas_id = sbas.sbas_id WHERE basusr.actif = 1 AND bas.sbas_id = sbas.sbas_id
AND Users.id = ? AND Users.id = ?";
AND model_of = 0";
$query = $this->_em->createNativeQuery($sql, $rsm); $query = $this->_em->createNativeQuery($sql, $rsm);
$query->setParameter(1, $user->getId()); $query->setParameter(1, $user->getId());
foreach ($query->getResult() as $row) { foreach ($query->getResult() as $row) {
$registrationEntity = $row[0]; $registrationEntity = $row[0];
$data[$row['sbas_id']][$row['base_id']] = [
$data[$row['sbas_id']][$row['bas_id']] = [ 'base-id' => $row['base_id'],
'base-id' => $row['bas_id'],
'db-name' => $row['dbname'], 'db-name' => $row['dbname'],
'active' => (Boolean) $row['actif'], 'active' => (Boolean) $row['actif'],
'time-limited' => (Boolean) $row['time_limited'], 'time-limited' => (Boolean) $row['time_limited'],

View File

@@ -15,14 +15,16 @@
<td style="width: 180px;">&nbsp;</td> <td style="width: 180px;">&nbsp;</td>
</tr> </tr>
{% for sbasId, baseInfo in inscriptions %} {% for sbasId, baseInfo in inscriptions %}
{% set sbasName = sbasId | sbas_labels(app) %} {% set sbasName = sbasId | sbas_labels(app) %}
<tr> {% set private = 0 %}
<td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr>
{% if baseInfo["registrations"]["by-type"]["accepted"]|length > 0 %} {% if baseInfo["registrations"]["by-type"]["accepted"]|length > 0 %}
<tr>
<td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr>
<tr> <tr>
<th colspan="3" style="text-align: center"> <th colspan="3" style="text-align: center">
{{ "Allowed access to the following collections" | trans }} {{ "Allowed access to the following collections" | trans }}
@@ -44,8 +46,12 @@
<td> <td>
</td> </td>
</tr> </tr>
{% endif %} {% elseif baseInfo["registrations"]["by-type"]["rejected"]|length > 0 %}
{% if baseInfo["registrations"]["by-type"]["rejected"]|length > 0 %} <tr>
<td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr>
<tr> <tr>
<th colspan="3" style="text-align: center"> <th colspan="3" style="text-align: center">
{{ "Rejected access to the following collections" | trans }} {{ "Rejected access to the following collections" | trans }}
@@ -67,8 +73,12 @@
<td> <td>
</td> </td>
</tr> </tr>
{% endif %} {% elseif baseInfo["registrations"]["by-type"]["pending"]|length > 0 %}
{% if baseInfo["registrations"]["by-type"]["pending"]|length > 0 %} <tr>
<td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr>
<tr> <tr>
<th colspan="3" style="text-align: center"> <th colspan="3" style="text-align: center">
{{ "Pending access to the following collections" | trans }} {{ "Pending access to the following collections" | trans }}
@@ -88,8 +98,12 @@
<td> <td>
</td> </td>
</tr> </tr>
{% endif %} {% elseif baseInfo["registrations"]["by-type"]["in-time"]|length > 0 %}
{% if baseInfo["registrations"]["by-type"]["in-time"]|length > 0 %} <tr>
<td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr>
<tr> <tr>
<th colspan="3" style="text-align: center"> <th colspan="3" style="text-align: center">
{{ "Temporary access to the following collections" | trans }} {{ "Temporary access to the following collections" | trans }}
@@ -109,8 +123,12 @@
<td> <td>
</td> </td>
</tr> </tr>
{% endif %} {% elseif baseInfo["registrations"]["by-type"]["out-dated"]|length > 0 %}
{% if baseInfo["registrations"]["by-type"]["out-dated"]|length > 0 %} <tr>
<td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr>
<tr> <tr>
<th colspan="3" style="text-align: center"> <th colspan="3" style="text-align: center">
{{ "Outdated access to the following collections" | trans }} {{ "Outdated access to the following collections" | trans }}
@@ -130,8 +148,12 @@
<td> <td>
</td> </td>
</tr> </tr>
{% endif %} {% elseif baseInfo["registrations"]["by-type"]["inactive"]|length > 0 %}
{% if baseInfo["registrations"]["by-type"]["inactive"]|length > 0 %} <tr>
<td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr>
<tr> <tr>
<th colspan="3" style="text-align: center"> <th colspan="3" style="text-align: center">
{{ "Suspended access to the following collections" | trans }} {{ "Suspended access to the following collections" | trans }}
@@ -151,9 +173,11 @@
<td> <td>
</td> </td>
</tr> </tr>
{% else %}
{% set private = 1 %}
{% endif %} {% endif %}
{% if attribute(baseInfo["config"]["cgu"], app['locale']) is defined %} {% if attribute(baseInfo["config"]["cgu"], app['locale']) is defined and private == 0 %}
{% set TOU = attribute(baseInfo["config"]["cgu"], app['locale']) %} {% set TOU = attribute(baseInfo["config"]["cgu"], app['locale']) %}
<tr> <tr>
<td colspan="3" style="text-align: center;"> <td colspan="3" style="text-align: center;">
@@ -166,7 +190,7 @@
</tr> </tr>
{% endif %} {% endif %}
{% for collInfo in baseInfo["config"]["collections"] if (collInfo['registration'] is none and collInfo['can-register']) %} {% for collInfo in baseInfo["config"]["collections"] if (collInfo['registration'] is none and collInfo['can-register']) %}
{% if collInfo["cgu"] is not none %} {% if collInfo["cgu"] is not none and private == 0 %}
<tr> <tr>
<td colspan="3" style="text-align: center;">{{ "login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes" | trans }}</td> <td colspan="3" style="text-align: center;">{{ "login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes" | trans }}</td>
</tr> </tr>