sdet...@users.adullact.net
unread,May 7, 2024, 9:54:35 AMMay 7Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openmairie-ope...@googlegroups.com
Author: sdethyre
Date: 2024-05-07 15:54:32 +0200 (Tue, 07 May 2024)
New Revision: 1838
Modified:
branches/evo-type-licence-dates-validite/data/pgsql/v3.0.0-rc2.dev0.sql
branches/evo-type-licence-dates-validite/gen/dyn/gen.inc.php
branches/evo-type-licence-dates-validite/gen/obj/declaration.class.php
branches/evo-type-licence-dates-validite/gen/obj/licence.class.php
branches/evo-type-licence-dates-validite/gen/obj/type_licence.class.php
branches/evo-type-licence-dates-validite/gen/sql/pgsql/type_licence.inc.php
branches/evo-type-licence-dates-validite/sql/pgsql/type_licence.inc.php
branches/evo-type-licence-dates-validite/tests/resources/app/type_licence.robot
Log:
feat: ajout des dates d'om_validite sur type_licence
Modified: branches/evo-type-licence-dates-validite/data/pgsql/v3.0.0-rc2.dev0.sql
===================================================================
--- branches/evo-type-licence-dates-validite/data/pgsql/v3.0.0-rc2.dev0.sql 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/data/pgsql/v3.0.0-rc2.dev0.sql 2024-05-07 13:54:32 UTC (rev 1838)
@@ -0,0 +1,10 @@
+
+
+-- Ajout des dates d'om_validite
+
+ALTER TABLE type_licence
+ADD COLUMN om_validite_debut date,
+ADD COLUMN om_validite_fin date;
+
+COMMENT ON COLUMN type_licence.om_validite_debut IS 'Date de début de validité du type de licence';
+COMMENT ON COLUMN type_licence.om_validite_fin IS 'Date de fin de validité du type de licence';
\ No newline at end of file
Modified: branches/evo-type-licence-dates-validite/gen/dyn/gen.inc.php
===================================================================
--- branches/evo-type-licence-dates-validite/gen/dyn/gen.inc.php 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/gen/dyn/gen.inc.php 2024-05-07 13:54:32 UTC (rev 1838)
@@ -374,5 +374,6 @@
"tabs_in_form" => false,
"tablename_in_page_title" => "types de licences",
"breadcrumb_in_page_title" => array($administration_parametrage, "tables de référence", ),
+ "om_validite" => "hidden_by_default",
),
);
Modified: branches/evo-type-licence-dates-validite/gen/obj/declaration.class.php
===================================================================
--- branches/evo-type-licence-dates-validite/gen/obj/declaration.class.php 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/gen/obj/declaration.class.php 2024-05-07 13:54:32 UTC (rev 1838)
@@ -1,6 +1,6 @@
<?php
//$Id$
-//gen openMairie le 30/11/2023 11:09
+//gen openMairie le 07/05/2024 14:05
require_once "../obj/om_dbform.class.php";
@@ -127,7 +127,7 @@
* @return string
*/
function get_var_sql_forminc__sql_type_licence() {
- return "SELECT type_licence.type_licence, type_licence.libelle FROM ".DB_PREFIXE."type_licence ORDER BY type_licence.libelle ASC";
+ return "SELECT type_licence.type_licence, type_licence.libelle FROM ".DB_PREFIXE."type_licence WHERE ((type_licence.om_validite_debut IS NULL AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE)) OR (type_licence.om_validite_debut <= CURRENT_DATE AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE))) ORDER BY type_licence.libelle ASC";
}
/**
@@ -462,7 +462,7 @@
"type_licence",
$this->get_var_sql_forminc__sql("type_licence"),
$this->get_var_sql_forminc__sql("type_licence_by_id"),
- false
+ true
);
}
Modified: branches/evo-type-licence-dates-validite/gen/obj/licence.class.php
===================================================================
--- branches/evo-type-licence-dates-validite/gen/obj/licence.class.php 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/gen/obj/licence.class.php 2024-05-07 13:54:32 UTC (rev 1838)
@@ -1,6 +1,6 @@
<?php
//$Id$
-//gen openMairie le 25/10/2023 23:45
+//gen openMairie le 07/05/2024 14:05
require_once "../obj/om_dbform.class.php";
@@ -70,7 +70,7 @@
* @return string
*/
function get_var_sql_forminc__sql_type_licence() {
- return "SELECT type_licence.type_licence, type_licence.libelle FROM ".DB_PREFIXE."type_licence ORDER BY type_licence.libelle ASC";
+ return "SELECT type_licence.type_licence, type_licence.libelle FROM ".DB_PREFIXE."type_licence WHERE ((type_licence.om_validite_debut IS NULL AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE)) OR (type_licence.om_validite_debut <= CURRENT_DATE AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE))) ORDER BY type_licence.libelle ASC";
}
/**
@@ -287,7 +287,7 @@
"type_licence",
$this->get_var_sql_forminc__sql("type_licence"),
$this->get_var_sql_forminc__sql("type_licence_by_id"),
- false
+ true
);
}
Modified: branches/evo-type-licence-dates-validite/gen/obj/type_licence.class.php
===================================================================
--- branches/evo-type-licence-dates-validite/gen/obj/type_licence.class.php 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/gen/obj/type_licence.class.php 2024-05-07 13:54:32 UTC (rev 1838)
@@ -1,6 +1,6 @@
<?php
//$Id$
-//gen openMairie le 05/04/2024 12:23
+//gen openMairie le 07/05/2024 14:05
require_once "../obj/om_dbform.class.php";
@@ -38,6 +38,8 @@
"contrainte_proximite",
"couleur",
"panneau",
+ "om_validite_debut",
+ "om_validite_fin",
);
}
@@ -63,6 +65,16 @@
$this->valF['couleur'] = $val['couleur'];
}
$this->valF['panneau'] = $val['panneau'];
+ if ($val['om_validite_debut'] != "") {
+ $this->valF['om_validite_debut'] = $this->dateDB($val['om_validite_debut']);
+ } else {
+ $this->valF['om_validite_debut'] = NULL;
+ }
+ if ($val['om_validite_fin'] != "") {
+ $this->valF['om_validite_fin'] = $this->dateDB($val['om_validite_fin']);
+ } else {
+ $this->valF['om_validite_fin'] = NULL;
+ }
}
//=================================================
@@ -81,7 +93,35 @@
function verifierAjout($val = array(), &$dnu1 = null) {
//numero automatique -> pas de verfication de cle primaire
}
+ /**
+ * Methode verifier
+ */
+ function verifier($val = array(), &$dnu1 = null, $dnu2 = null) {
+ // On appelle la methode de la classe parent
+ parent::verifier($val, $this->f->db, null);
+ // gestion des dates de validites
+ $date_debut = $this->valF['om_validite_debut'];
+ $date_fin = $this->valF['om_validite_fin'];
+
+ if ($date_debut != '' and $date_fin != '') {
+
+ $date_debut = explode('-', $this->valF['om_validite_debut']);
+ $date_fin = explode('-', $this->valF['om_validite_fin']);
+
+ $time_debut = mktime(0, 0, 0, $date_debut[1], $date_debut[2],
+ $date_debut[0]);
+ $time_fin = mktime(0, 0, 0, $date_fin[1], $date_fin[2],
+ $date_fin[0]);
+
+ if ($time_debut > $time_fin or $time_debut == $time_fin) {
+ $this->correct = false;
+ $this->addToMessage(__('La date de fin de validite doit etre future a la de debut de validite.'));
+ }
+ }
+ }
+
+
//==========================
// Formulaire [form]
//==========================
@@ -99,6 +139,16 @@
$form->setType("contrainte_proximite", "checkbox");
$form->setType("couleur", "text");
$form->setType("panneau", "textarea");
+ if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) {
+ $form->setType("om_validite_debut", "date");
+ } else {
+ $form->setType("om_validite_debut", "hiddenstaticdate");
+ }
+ if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) {
+ $form->setType("om_validite_fin", "date");
+ } else {
+ $form->setType("om_validite_fin", "hiddenstaticdate");
+ }
}
// MDOE MODIFIER
@@ -108,6 +158,16 @@
$form->setType("contrainte_proximite", "checkbox");
$form->setType("couleur", "text");
$form->setType("panneau", "textarea");
+ if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) {
+ $form->setType("om_validite_debut", "date");
+ } else {
+ $form->setType("om_validite_debut", "hiddenstaticdate");
+ }
+ if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) {
+ $form->setType("om_validite_fin", "date");
+ } else {
+ $form->setType("om_validite_fin", "hiddenstaticdate");
+ }
}
// MODE SUPPRIMER
@@ -117,6 +177,8 @@
$form->setType("contrainte_proximite", "hiddenstatic");
$form->setType("couleur", "hiddenstatic");
$form->setType("panneau", "hiddenstatic");
+ $form->setType("om_validite_debut", "hiddenstatic");
+ $form->setType("om_validite_fin", "hiddenstatic");
}
// MODE CONSULTER
@@ -126,6 +188,8 @@
$form->setType("contrainte_proximite", "checkboxstatic");
$form->setType("couleur", "static");
$form->setType("panneau", "textareastatic");
+ $form->setType("om_validite_debut", "datestatic");
+ $form->setType("om_validite_fin", "datestatic");
}
}
@@ -134,6 +198,8 @@
function setOnchange(&$form, $maj) {
//javascript controle client
$form->setOnchange('type_licence','VerifNum(this)');
+ $form->setOnchange('om_validite_debut','fdate(this)');
+ $form->setOnchange('om_validite_fin','fdate(this)');
}
/**
* Methode setTaille
@@ -144,6 +210,8 @@
$form->setTaille("contrainte_proximite", 1);
$form->setTaille("couleur", 10);
$form->setTaille("panneau", 80);
+ $form->setTaille("om_validite_debut", 12);
+ $form->setTaille("om_validite_fin", 12);
}
/**
@@ -155,6 +223,8 @@
$form->setMax("contrainte_proximite", 1);
$form->setMax("couleur", 6);
$form->setMax("panneau", 6);
+ $form->setMax("om_validite_debut", 12);
+ $form->setMax("om_validite_fin", 12);
}
@@ -165,6 +235,8 @@
$form->setLib('contrainte_proximite', __('contrainte_proximite'));
$form->setLib('couleur', __('couleur'));
$form->setLib('panneau', __('panneau'));
+ $form->setLib('om_validite_debut', __('om_validite_debut'));
+ $form->setLib('om_validite_fin', __('om_validite_fin'));
}
/**
*
Modified: branches/evo-type-licence-dates-validite/gen/sql/pgsql/type_licence.inc.php
===================================================================
--- branches/evo-type-licence-dates-validite/gen/sql/pgsql/type_licence.inc.php 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/gen/sql/pgsql/type_licence.inc.php 2024-05-07 13:54:32 UTC (rev 1838)
@@ -1,10 +1,11 @@
<?php
//$Id$
-//gen openMairie le 05/04/2024 12:23
+//gen openMairie le 07/05/2024 15:23
$DEBUG=0;
$serie=15;
$ent = __("administration & paramétrage")." -> ".__("tables de référence")." -> ".__("types de licences");
+$om_validite = true;
if(!isset($premier)) $premier='';
if(!isset($tricolsf)) $tricolsf='';
if(!isset($premiersf)) $premiersf='';
@@ -28,9 +29,22 @@
"case type_licence.contrainte_proximite when 't' then 'Oui' else 'Non' end as \"".__("contrainte_proximite")."\"",
'type_licence.couleur as "'.__("couleur").'"',
);
+// Spécificité des dates de validité
+$displayed_fields_validite = array(
+ 'to_char(type_licence.om_validite_debut ,\'DD/MM/YYYY\') as "'.__("om_validite_debut").'"',
+ 'to_char(type_licence.om_validite_fin ,\'DD/MM/YYYY\') as "'.__("om_validite_fin").'"',
+);
+// On affiche les champs de date de validité uniquement lorsque le paramètre
+// d'affichage des éléments expirés est activé
+if (isset($_GET['valide']) && $_GET['valide'] === 'false') {
+ $champAffiche = array_merge($champAffiche, $displayed_fields_validite);
+}
+
//
$champNonAffiche = array(
'type_licence.panneau as "'.__("panneau").'"',
+ 'type_licence.om_validite_debut as "'.__("om_validite_debut").'"',
+ 'type_licence.om_validite_fin as "'.__("om_validite_fin").'"',
);
//
$champRecherche = array(
@@ -44,7 +58,19 @@
* Gestion de la clause WHERE => $selection
*/
// Filtre listing standard
-$selection = "";
+$selection = " WHERE ((type_licence.om_validite_debut IS NULL AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE)) OR (type_licence.om_validite_debut <= CURRENT_DATE AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE)))";
+$where_om_validite = " WHERE ((type_licence.om_validite_debut IS NULL AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE)) OR (type_licence.om_validite_debut <= CURRENT_DATE AND (type_licence.om_validite_fin IS NULL OR type_licence.om_validite_fin > CURRENT_DATE)))";
+// Gestion OMValidité - Suppression du filtre si paramètre
+if (isset($_GET["valide"]) and $_GET["valide"] == "false") {
+ if (!isset($where_om_validite)
+ or (isset($where_om_validite) and $where_om_validite == "")) {
+ if (trim($selection) != "") {
+ $selection = "";
+ }
+ } else {
+ $selection = trim(str_replace($where_om_validite, "", $selection));
+ }
+}
/**
* Gestion SOUSFORMULAIRE => $sousformulaire
Modified: branches/evo-type-licence-dates-validite/sql/pgsql/type_licence.inc.php
===================================================================
--- branches/evo-type-licence-dates-validite/sql/pgsql/type_licence.inc.php 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/sql/pgsql/type_licence.inc.php 2024-05-07 13:54:32 UTC (rev 1838)
@@ -15,3 +15,8 @@
"case type_licence.contrainte_proximite when 't' then 'Oui' else 'Non' end as \"".__("contrainte_proximite")."\"",
'type_licence.couleur as "'.__("couleur").'"',
);
+
+// Rappel d'array_merge pour le bon affichage des spécificités des dates de validité
+if (isset($_GET['valide']) && $_GET['valide'] === 'false') {
+ $champAffiche = array_merge($champAffiche, $displayed_fields_validite);
+}
Modified: branches/evo-type-licence-dates-validite/tests/resources/app/type_licence.robot
===================================================================
--- branches/evo-type-licence-dates-validite/tests/resources/app/type_licence.robot 2024-05-07 09:40:24 UTC (rev 1837)
+++ branches/evo-type-licence-dates-validite/tests/resources/app/type_licence.robot 2024-05-07 13:54:32 UTC (rev 1838)
@@ -2,6 +2,17 @@
Documentation Mots-clés rattachés aux types de licence.
*** Keywords ***
+Depuis le listing des types de licences
+ [Documentation] ...
+ [Tags] type de licence
+ Depuis le listing type_licence
+
+Depuis le listing des types de licences expirés
+ [Documentation] Accède au listing des *types de licences* expirés
+ [Tags] sanction_type sanction
+ Depuis le listing des types de licences
+ Click Element css=.om_validite_link
+
Depuis le contexte du type de licence
[Documentation] ...
[Tags] type de licence
@@ -47,3 +58,5 @@
Si "contrainte_proximite" existe dans "${values}" on execute "Set Checkbox" dans le formulaire
Si "couleur" existe dans "${values}" on execute "Input Text" dans le formulaire
Si "panneau" existe dans "${values}" on execute "Input Text" dans le formulaire
+ Si "om_validite_debut" existe dans "${values}" on execute "Input Text" dans le formulaire
+ Si "om_validite_fin" existe dans "${values}" on execute "Input Datepicker" dans le formulaire
\ No newline at end of file