1 |
softime |
8752 |
<?php |
2 |
|
|
/** |
3 |
|
|
* |
4 |
|
|
* @package openfoncier |
5 |
|
|
* @version SVN : $Id$ |
6 |
|
|
*/ |
7 |
|
|
// |
8 |
|
|
require_once "../gen/sql/pgsql/storage.inc.php"; |
9 |
|
|
|
10 |
softime |
8768 |
// |
11 |
|
|
$tab_actions['corner']['ajouter'] = null; |
12 |
|
|
|
13 |
softime |
10573 |
// |
14 |
softime |
8752 |
if ($retourformulaire === 'sitadel') { |
15 |
|
|
|
16 |
|
|
$champAffiche = array( |
17 |
|
|
'storage.storage as "'.__("storage").'"', |
18 |
softime |
8768 |
'storage.filename as "'.__("fichier").'"', |
19 |
softime |
8772 |
'to_char(storage.creation_date, \'DD/MM/YYYY\') as "'.__("date de création").'"', |
20 |
softime |
8752 |
'storage.creation_time as "'.__("heure de création").'"', |
21 |
softime |
8772 |
'to_char(to_date(storage.info::json->>\'date_debut\', \'YYYY-MM-DD\'), \'DD/MM/YYYY\') as "'.__("date de début de la période").'"', |
22 |
|
|
'to_char(to_date(storage.info::json->>\'date_fin\', \'YYYY-MM-DD\'), \'DD/MM/YYYY\') as "'.__("date de fin de la période").'"', |
23 |
softime |
8752 |
); |
24 |
softime |
8792 |
if ($_SESSION['niveau'] === '2') { |
25 |
softime |
18876 |
array_push($champAffiche, "om_collectivite.libelle as \"".__("collectivite")."\""); |
26 |
softime |
8792 |
} |
27 |
softime |
8752 |
|
28 |
|
|
$selection = sprintf( |
29 |
softime |
8792 |
" WHERE storage.type = '%s' %s ", |
30 |
|
|
$retourformulaire, |
31 |
|
|
$_SESSION['niveau'] !== '2' ? sprintf(" AND storage.om_collectivite = '%s' ", $_SESSION["collectivite"]) : '' |
32 |
softime |
8752 |
); |
33 |
softime |
8768 |
|
34 |
softime |
8772 |
$tri = ' ORDER BY to_date(storage.info::json->>\'date_fin\', \'YYYY-MM-DD\') DESC NULLS LAST, storage.storage DESC '; |
35 |
|
|
|
36 |
softime |
8768 |
$tab_actions['left']["telecharger"] = array( |
37 |
|
|
'lien' => OM_ROUTE_FORM.'&snippet=file&obj='.$obj.'&champ=uid&id=', |
38 |
|
|
'id' => '', |
39 |
|
|
'lib' => '<span class="om-icon om-icon-16 om-icon-fix reqmo-16" title="'.__('Télécharger').'">'.__('Télécharger').'</span>', |
40 |
softime |
8774 |
'rights' => array('list' => array($obj, $obj.'_uid_telecharger'), 'operator' => 'OR'), |
41 |
softime |
8768 |
'ordre' => 20, |
42 |
|
|
"target" => "_blank", |
43 |
|
|
); |
44 |
softime |
8752 |
} |
45 |
softime |
10573 |
|
46 |
|
|
// |
47 |
|
|
if ($retourformulaire === 'rapport_instruction') { |
48 |
|
|
|
49 |
|
|
$table .= "LEFT JOIN ".DB_PREFIXE."rapport_instruction |
50 |
|
|
ON storage.uid=rapport_instruction.om_fichier_rapport_instruction "; |
51 |
|
|
|
52 |
|
|
$champAffiche = array( |
53 |
|
|
'storage.storage as "'.__("storage").'"', |
54 |
|
|
'to_char(storage.creation_date, \'DD/MM/YYYY\') as "'.__("date de création").'"', |
55 |
|
|
'storage.creation_time as "'.__("heure de création").'"', |
56 |
|
|
'storage.info::json->>\'createur\' as "'.__("créateur").'"', |
57 |
|
|
'(storage.info::json->>\'version\')::int as "'.__("version").'"', |
58 |
|
|
); |
59 |
|
|
|
60 |
|
|
// Sélectionne toutes les versions du rapport d'instruction du dossier sauf la dernière |
61 |
|
|
// si le dossier est finalisé. Sinon c'est qu'il existe une version en cours d'édition |
62 |
|
|
// et donc que la dernière stocké n'est pas la dernière version du document. |
63 |
|
|
// La dernière version du rapport stocké dans storage est identifié par le fait que son uid |
64 |
|
|
// est identique a celui du rapport (dans la jointure). C'est la seule qui a une correspondance |
65 |
|
|
// dans la table rapport_instruction. |
66 |
|
|
$selection = sprintf( |
67 |
|
|
" WHERE storage.type = '%1\$s' AND storage.info::json->>'dossier' = '%2\$s' |
68 |
|
|
AND (rapport_instruction.om_final_rapport_instruction IS FALSE |
69 |
|
|
OR rapport_instruction.rapport_instruction IS NULL)", |
70 |
|
|
$retourformulaire, |
71 |
|
|
$idxformulaire, |
72 |
|
|
DB_PREFIXE |
73 |
|
|
); |
74 |
|
|
|
75 |
|
|
$tri = ' ORDER BY storage.info::json->>\'version\' DESC NULLS LAST, storage.storage DESC '; |
76 |
|
|
|
77 |
|
|
$tab_actions['left']["telecharger"] = array( |
78 |
|
|
'lien' => OM_ROUTE_FORM.'&snippet=file&obj='.$obj.'&champ=uid&id=', |
79 |
|
|
'id' => '', |
80 |
|
|
'lib' => '<span class="om-icon om-icon-16 om-icon-fix reqmo-16" title="'.__('Télécharger').'">'.__('Télécharger').'</span>', |
81 |
|
|
'rights' => array('list' => array($obj, $obj.'_uid_telecharger'), 'operator' => 'OR'), |
82 |
|
|
'ordre' => 20, |
83 |
|
|
"target" => "_blank", |
84 |
|
|
); |
85 |
|
|
} |