[openmairie-framework-Commits] r4940 - in openmairie_exemple/branches/om5_rad: . gen/obj gen/sql/pgsql obj sql/pgsql

0 views
Skip to first unread message

fray...@users.adullact.net

unread,
Apr 25, 2024, 9:43:39 AMApr 25
to openmairie...@googlegroups.com
Author: fraynaud
Date: 2024-04-25 15:43:36 +0200 (Thu, 25 Apr 2024)
New Revision: 4940

Added:
openmairie_exemple/branches/om5_rad/gen/obj/om_actions.class.php
openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php
openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_actions.inc.php
openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php
openmairie_exemple/branches/om5_rad/obj/om_actions.class.php
openmairie_exemple/branches/om5_rad/obj/om_vues.class.php
openmairie_exemple/branches/om5_rad/sql/pgsql/om_actions.inc.php
openmairie_exemple/branches/om5_rad/sql/pgsql/om_vues.inc.php
Removed:
openmairie_exemple/branches/om5_rad/gen/obj/om_champs.class.php
openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_champs.inc.php
openmairie_exemple/branches/om5_rad/obj/om_champs.class.php
openmairie_exemple/branches/om5_rad/sql/pgsql/om_champs.inc.php
Modified:
openmairie_exemple/branches/om5_rad/HISTORY.txt
openmairie_exemple/branches/om5_rad/TODO.txt
Log:

ajout des actions et des vues
enleve les om_champs vue et table



Modified: openmairie_exemple/branches/om5_rad/HISTORY.txt
===================================================================
--- openmairie_exemple/branches/om5_rad/HISTORY.txt 2024-04-25 13:01:20 UTC (rev 4939)
+++ openmairie_exemple/branches/om5_rad/HISTORY.txt 2024-04-25 13:43:36 UTC (rev 4940)
@@ -118,7 +118,9 @@
* Evolution : gen_plus : moteur de recherche boolean et clé secondaire 16-04-2024

*** version 5 passage de la classe om_champs à om_forms pour remplacer om_champs 17-04-2024
-* Evolution : ajout de la colonne table_name
+un formulaire peut étre composé de champs, de calcul sql et de vues.
+om_champs est trop restrictif + assez lent à l'affichage de la vue
+* Evolution : ajout de la colonne table_name dans om_forms
* Evolution : generation : om_tables et om_forms
* Evolution : transfert des méthodes om_champs dans om_forms
* Evolution : ajout dans le menu de la composition om_forms
@@ -126,7 +128,12 @@
* Evolution : om_gen_plus : liste : formatage présentation du champ double précision avec round
-> cast en numeric -> sur 2 caractères
* Evolution : om_champs : ajout du type sql :-les 4 opérations sur champs de la table 24/04/24
+* Evolution : om_vues : affichage des vues - a terme suppression, modification, ajout 25/04/2024
+* Evolution : om_actions : ajout des actions à terme : édition, ajouter, modifier, supprimer 25/04/2024
+* Evolution : om_champs suppression vue et table 25/04/2024


+* bug : om_tables : si existe vue -> la suppression créé une erreur : a voir
+
4.10.0 (29/11/2022
-------------------

Modified: openmairie_exemple/branches/om5_rad/TODO.txt
===================================================================
--- openmairie_exemple/branches/om5_rad/TODO.txt 2024-04-25 13:01:20 UTC (rev 4939)
+++ openmairie_exemple/branches/om5_rad/TODO.txt 2024-04-25 13:43:36 UTC (rev 4940)
@@ -85,7 +85,7 @@
view_schema "om5";
view_name "article_montant_ht";
table_catalog "om5_rad";
-table_schema "om5";
+table_schema "om5";sv
table_name"article"

-> pb si creation de vue pour supprimer table -> drop table cascade

Added: openmairie_exemple/branches/om5_rad/gen/obj/om_actions.class.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/obj/om_actions.class.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/gen/obj/om_actions.class.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,229 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 14:34
+
+require_once PATH_OPENMAIRIE."om_dbform.class.php";
+
+class om_actions_gen extends dbform {
+
+ protected $_absolute_class_name = "om_actions";
+
+ var $table = "om_actions";
+ var $clePrimaire = "om_actions";
+ var $typeCle = "N";
+ var $required_field = array(
+ "libelle",
+ "module",
+ "om_actions"
+ );
+
+ var $foreign_keys_extended = array(
+ "om_tables" => array("om_tables", ),
+ );
+
+ /**
+ *
+ * @return string
+ */
+ function get_default_libelle() {
+ return $this->getVal($this->clePrimaire)."&nbsp;".$this->getVal("libelle");
+ }
+
+ /**
+ *
+ * @return array
+ */
+ function get_var_sql_forminc__champs() {
+ return array(
+ "om_actions",
+ "libelle",
+ "module",
+ "parametres",
+ "table_name",
+ );
+ }
+
+ /**
+ *
+ * @return string
+ */
+ function get_var_sql_forminc__sql_table_name() {
+ return "SELECT om_tables.table_name, om_tables.libelle FROM ".DB_PREFIXE."om_tables ORDER BY om_tables.libelle ASC";
+ }
+
+ /**
+ *
+ * @return string
+ */
+ function get_var_sql_forminc__sql_table_name_by_id() {
+ return "SELECT om_tables.table_name, om_tables.libelle FROM ".DB_PREFIXE."om_tables WHERE table_name = '<idx>'";
+ }
+
+
+
+
+ function setvalF($val = array()) {
+ //affectation valeur formulaire
+ if (!is_numeric($val['om_actions'])) {
+ $this->valF['om_actions'] = ""; // -> requis
+ } else {
+ $this->valF['om_actions'] = $val['om_actions'];
+ }
+ $this->valF['libelle'] = $val['libelle'];
+ $this->valF['module'] = $val['module'];
+ $this->valF['parametres'] = $val['parametres'];
+ if ($val['table_name'] == "") {
+ $this->valF['table_name'] = NULL;
+ } else {
+ $this->valF['table_name'] = $val['table_name'];
+ }
+ }
+
+ //=================================================
+ //cle primaire automatique [automatic primary key]
+ //==================================================
+
+ function setId(&$dnu1 = null) {
+ //numero automatique
+ $this->valF[$this->clePrimaire] = $this->f->db->nextId(DB_PREFIXE.$this->table);
+ }
+
+ function setValFAjout($val = array()) {
+ //numero automatique -> pas de controle ajout cle primaire
+ }
+
+ function verifierAjout($val = array(), &$dnu1 = null) {
+ //numero automatique -> pas de verfication de cle primaire
+ }
+
+ //==========================
+ // Formulaire [form]
+ //==========================
+ /**
+ *
+ */
+ function setType(&$form, $maj) {
+ // Récupération du mode de l'action
+ $crud = $this->get_action_crud($maj);
+
+ // MODE AJOUTER
+ if ($maj == 0 || $crud == 'create') {
+ $form->setType("om_actions", "hidden");
+ $form->setType("libelle", "text");
+ $form->setType("module", "text");
+ $form->setType("parametres", "text");
+ if ($this->is_in_context_of_foreign_key("om_tables", $this->retourformulaire)) {
+ $form->setType("table_name", "selecthiddenstatic");
+ } else {
+ $form->setType("table_name", "select");
+ }
+ }
+
+ // MDOE MODIFIER
+ if ($maj == 1 || $crud == 'update') {
+ $form->setType("om_actions", "hiddenstatic");
+ $form->setType("libelle", "text");
+ $form->setType("module", "text");
+ $form->setType("parametres", "text");
+ if ($this->is_in_context_of_foreign_key("om_tables", $this->retourformulaire)) {
+ $form->setType("table_name", "selecthiddenstatic");
+ } else {
+ $form->setType("table_name", "select");
+ }
+ }
+
+ // MODE SUPPRIMER
+ if ($maj == 2 || $crud == 'delete') {
+ $form->setType("om_actions", "hiddenstatic");
+ $form->setType("libelle", "hiddenstatic");
+ $form->setType("module", "hiddenstatic");
+ $form->setType("parametres", "hiddenstatic");
+ $form->setType("table_name", "selectstatic");
+ }
+
+ // MODE CONSULTER
+ if ($maj == 3 || $crud == 'read') {
+ $form->setType("om_actions", "static");
+ $form->setType("libelle", "static");
+ $form->setType("module", "static");
+ $form->setType("parametres", "static");
+ $form->setType("table_name", "selectstatic");
+ }
+
+ }
+
+
+ function setOnchange(&$form, $maj) {
+ //javascript controle client
+ $form->setOnchange('om_actions','VerifNum(this)');
+ }
+ /**
+ * Methode setTaille
+ */
+ function setTaille(&$form, $maj) {
+ $form->setTaille("om_actions", 11);
+ $form->setTaille("libelle", 30);
+ $form->setTaille("module", 30);
+ $form->setTaille("parametres", 10);
+ $form->setTaille("table_name", 30);
+ }
+
+ /**
+ * Methode setMax
+ */
+ function setMax(&$form, $maj) {
+ $form->setMax("om_actions", 11);
+ $form->setMax("libelle", 40);
+ $form->setMax("module", 40);
+ $form->setMax("parametres", -5);
+ $form->setMax("table_name", 40);
+ }
+
+
+ function setLib(&$form, $maj) {
+ //libelle des champs
+ $form->setLib('om_actions', __('om_actions'));
+ $form->setLib('libelle', __('libelle'));
+ $form->setLib('module', __('module'));
+ $form->setLib('parametres', __('parametres'));
+ $form->setLib('table_name', __('table_name'));
+ }
+ /**
+ *
+ */
+ function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {
+
+ // table_name
+ $this->init_select(
+ $form,
+ $this->f->db,
+ $maj,
+ null,
+ "table_name",
+ $this->get_var_sql_forminc__sql("table_name"),
+ $this->get_var_sql_forminc__sql("table_name_by_id"),
+ false
+ );
+ }
+
+
+ //==================================
+ // sous Formulaire
+ //==================================
+
+
+ function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) {
+ $this->retourformulaire = $retourformulaire;
+ if($validation == 0) {
+ if($this->is_in_context_of_foreign_key('om_tables', $this->retourformulaire))
+ $form->setVal('table_name', $idxformulaire);
+ }// fin validation
+ $this->set_form_default_values($form, $maj, $validation);
+ }// fin setValsousformulaire
+
+ //==================================
+ // cle secondaire
+ //==================================
+
+
+}

Deleted: openmairie_exemple/branches/om5_rad/gen/obj/om_champs.class.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/obj/om_champs.class.php 2024-04-25 13:01:20 UTC (rev 4939)
+++ openmairie_exemple/branches/om5_rad/gen/obj/om_champs.class.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -1,342 +0,0 @@
-<?php
-//$Id$
-//gen openMairie le 16/04/2024 18:25
-
-require_once PATH_OPENMAIRIE."om_dbform.class.php";
-
-class om_champs_gen extends dbform {
-
- protected $_absolute_class_name = "om_champs";
-
- var $table = "om_champs";
- var $clePrimaire = "column_name";
- var $typeCle = "A";
- var $required_field = array(
- "column_name"
- );
-
- var $foreign_keys_extended = array(
- "om_tables" => array("om_tables", ),
- );
-
- /**
- *
- * @return string
- */
- function get_default_libelle() {
- return $this->getVal($this->clePrimaire)."&nbsp;".$this->getVal("libelle");
- }
-
- /**
- *
- * @return array
- */
- function get_var_sql_forminc__champs() {
- return array(
- "column_name",
- "table_name",
- "table_schema",
- "data_type",
- "character_maximum_length",
- "is_nullable",
- "column_default",
- "comment",
- "parametres",
- "libelle",
- "type",
- "bloc",
- "position",
- "calcul",
- "liste",
- );
- }
-
- /**
- *
- * @return string
- */
- function get_var_sql_forminc__sql_table_name() {
- return "SELECT om_tables.table_name, om_tables.libelle FROM ".DB_PREFIXE."om_tables ORDER BY om_tables.libelle ASC";
- }
-
- /**
- *
- * @return string
- */
- function get_var_sql_forminc__sql_table_name_by_id() {
- return "SELECT om_tables.table_name, om_tables.libelle FROM ".DB_PREFIXE."om_tables WHERE table_name = '<idx>'";
- }
-
-
-
-
- function setvalF($val = array()) {
- //affectation valeur formulaire
- $this->valF['column_name'] = $val['column_name'];
- if ($val['table_name'] == "") {
- $this->valF['table_name'] = NULL;
- } else {
- $this->valF['table_name'] = $val['table_name'];
- }
- if ($val['table_schema'] == "") {
- $this->valF['table_schema'] = NULL;
- } else {
- $this->valF['table_schema'] = $val['table_schema'];
- }
- if ($val['data_type'] == "") {
- $this->valF['data_type'] = NULL;
- } else {
- $this->valF['data_type'] = $val['data_type'];
- }
- if (!is_numeric($val['character_maximum_length'])) {
- $this->valF['character_maximum_length'] = NULL;
- } else {
- $this->valF['character_maximum_length'] = $val['character_maximum_length'];
- }
- if ($val['is_nullable'] == "") {
- $this->valF['is_nullable'] = NULL;
- } else {
- $this->valF['is_nullable'] = $val['is_nullable'];
- }
- if ($val['column_default'] == "") {
- $this->valF['column_default'] = NULL;
- } else {
- $this->valF['column_default'] = $val['column_default'];
- }
- $this->valF['comment'] = $val['comment'];
- $this->valF['parametres'] = $val['parametres'];
- if ($val['libelle'] == "") {
- $this->valF['libelle'] = NULL;
- } else {
- $this->valF['libelle'] = $val['libelle'];
- }
- if ($val['type'] == "") {
- $this->valF['type'] = NULL;
- } else {
- $this->valF['type'] = $val['type'];
- }
- if ($val['bloc'] == "") {
- $this->valF['bloc'] = NULL;
- } else {
- $this->valF['bloc'] = $val['bloc'];
- }
- if (!is_numeric($val['position'])) {
- $this->valF['position'] = NULL;
- } else {
- $this->valF['position'] = $val['position'];
- }
- if ($val['calcul'] == "") {
- $this->valF['calcul'] = NULL;
- } else {
- $this->valF['calcul'] = $val['calcul'];
- }
- if (!is_numeric($val['liste'])) {
- $this->valF['liste'] = NULL;
- } else {
- $this->valF['liste'] = $val['liste'];
- }
- }
-
- //==========================
- // Formulaire [form]
- //==========================
- /**
- *
- */
- function setType(&$form, $maj) {
- // Récupération du mode de l'action
- $crud = $this->get_action_crud($maj);
-
- // MODE AJOUTER
- if ($maj == 0 || $crud == 'create') {
- $form->setType("column_name", "text");
- if ($this->is_in_context_of_foreign_key("om_tables", $this->retourformulaire)) {
- $form->setType("table_name", "selecthiddenstatic");
- } else {
- $form->setType("table_name", "select");
- }
- $form->setType("table_schema", "text");
- $form->setType("data_type", "text");
- $form->setType("character_maximum_length", "text");
- $form->setType("is_nullable", "text");
- $form->setType("column_default", "text");
- $form->setType("comment", "textarea");
- $form->setType("parametres", "textarea");
- $form->setType("libelle", "text");
- $form->setType("type", "text");
- $form->setType("bloc", "text");
- $form->setType("position", "text");
- $form->setType("calcul", "text");
- $form->setType("liste", "text");
- }
-
- // MDOE MODIFIER
- if ($maj == 1 || $crud == 'update') {
- $form->setType("column_name", "hiddenstatic");
- if ($this->is_in_context_of_foreign_key("om_tables", $this->retourformulaire)) {
- $form->setType("table_name", "selecthiddenstatic");
- } else {
- $form->setType("table_name", "select");
- }
- $form->setType("table_schema", "text");
- $form->setType("data_type", "text");
- $form->setType("character_maximum_length", "text");
- $form->setType("is_nullable", "text");
- $form->setType("column_default", "text");
- $form->setType("comment", "textarea");
- $form->setType("parametres", "textarea");
- $form->setType("libelle", "text");
- $form->setType("type", "text");
- $form->setType("bloc", "text");
- $form->setType("position", "text");
- $form->setType("calcul", "text");
- $form->setType("liste", "text");
- }
-
- // MODE SUPPRIMER
- if ($maj == 2 || $crud == 'delete') {
- $form->setType("column_name", "hiddenstatic");
- $form->setType("table_name", "selectstatic");
- $form->setType("table_schema", "hiddenstatic");
- $form->setType("data_type", "hiddenstatic");
- $form->setType("character_maximum_length", "hiddenstatic");
- $form->setType("is_nullable", "hiddenstatic");
- $form->setType("column_default", "hiddenstatic");
- $form->setType("comment", "hiddenstatic");
- $form->setType("parametres", "hiddenstatic");
- $form->setType("libelle", "hiddenstatic");
- $form->setType("type", "hiddenstatic");
- $form->setType("bloc", "hiddenstatic");
- $form->setType("position", "hiddenstatic");
- $form->setType("calcul", "hiddenstatic");
- $form->setType("liste", "hiddenstatic");
- }
-
- // MODE CONSULTER
- if ($maj == 3 || $crud == 'read') {
- $form->setType("column_name", "static");
- $form->setType("table_name", "selectstatic");
- $form->setType("table_schema", "static");
- $form->setType("data_type", "static");
- $form->setType("character_maximum_length", "static");
- $form->setType("is_nullable", "static");
- $form->setType("column_default", "static");
- $form->setType("comment", "textareastatic");
- $form->setType("parametres", "textareastatic");
- $form->setType("libelle", "static");
- $form->setType("type", "static");
- $form->setType("bloc", "static");
- $form->setType("position", "static");
- $form->setType("calcul", "static");
- $form->setType("liste", "static");
- }
-
- }
-
-
- function setOnchange(&$form, $maj) {
- //javascript controle client
- $form->setOnchange('character_maximum_length','VerifNum(this)');
- $form->setOnchange('position','VerifNum(this)');
- $form->setOnchange('liste','VerifNum(this)');
- }
- /**
- * Methode setTaille
- */
- function setTaille(&$form, $maj) {
- $form->setTaille("column_name", 30);
- $form->setTaille("table_name", 30);
- $form->setTaille("table_schema", 30);
- $form->setTaille("data_type", 30);
- $form->setTaille("character_maximum_length", 11);
- $form->setTaille("is_nullable", 10);
- $form->setTaille("column_default", 30);
- $form->setTaille("comment", 80);
- $form->setTaille("parametres", 80);
- $form->setTaille("libelle", 30);
- $form->setTaille("type", 30);
- $form->setTaille("bloc", 10);
- $form->setTaille("position", 11);
- $form->setTaille("calcul", 30);
- $form->setTaille("liste", 11);
- }
-
- /**
- * Methode setMax
- */
- function setMax(&$form, $maj) {
- $form->setMax("column_name", 120);
- $form->setMax("table_name", 40);
- $form->setMax("table_schema", 40);
- $form->setMax("data_type", 40);
- $form->setMax("character_maximum_length", 11);
- $form->setMax("is_nullable", 5);
- $form->setMax("column_default", 40);
- $form->setMax("comment", 6);
- $form->setMax("parametres", 6);
- $form->setMax("libelle", 80);
- $form->setMax("type", 40);
- $form->setMax("bloc", 5);
- $form->setMax("position", 11);
- $form->setMax("calcul", 255);
- $form->setMax("liste", 11);
- }
-
-
- function setLib(&$form, $maj) {
- //libelle des champs
- $form->setLib('column_name', __('column_name'));
- $form->setLib('table_name', __('table_name'));
- $form->setLib('table_schema', __('table_schema'));
- $form->setLib('data_type', __('data_type'));
- $form->setLib('character_maximum_length', __('character_maximum_length'));
- $form->setLib('is_nullable', __('is_nullable'));
- $form->setLib('column_default', __('column_default'));
- $form->setLib('comment', __('comment'));
- $form->setLib('parametres', __('parametres'));
- $form->setLib('libelle', __('libelle'));
- $form->setLib('type', __('type'));
- $form->setLib('bloc', __('bloc'));
- $form->setLib('position', __('position'));
- $form->setLib('calcul', __('calcul'));
- $form->setLib('liste', __('liste'));
- }
- /**
- *
- */
- function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {
-
- // table_name
- $this->init_select(
- $form,
- $this->f->db,
- $maj,
- null,
- "table_name",
- $this->get_var_sql_forminc__sql("table_name"),
- $this->get_var_sql_forminc__sql("table_name_by_id"),
- false
- );
- }
-
-
- //==================================
- // sous Formulaire
- //==================================
-
-
- function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) {
- $this->retourformulaire = $retourformulaire;
- if($validation == 0) {
- if($this->is_in_context_of_foreign_key('om_tables', $this->retourformulaire))
- $form->setVal('table_name', $idxformulaire);
- }// fin validation
- $this->set_form_default_values($form, $maj, $validation);
- }// fin setValsousformulaire
-
- //==================================
- // cle secondaire
- //==================================
-
-
-}

Added: openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/gen/obj/om_vues.class.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,130 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 13:51
+
+require_once PATH_OPENMAIRIE."om_dbform.class.php";
+
+class om_vues_gen extends dbform {
+
+ protected $_absolute_class_name = "om_vues";
+
+ var $table = "om_vues";
+ var $clePrimaire = "table_name";
+ var $typeCle = "A";
+ var $required_field = array(
+ "table_name"
+ );
+
+ var $foreign_keys_extended = array(
+ );
+
+ /**
+ *
+ * @return string
+ */
+ function get_default_libelle() {
+ return $this->getVal($this->clePrimaire)."&nbsp;".$this->getVal("view_definition");
+ }
+
+ /**
+ *
+ * @return array
+ */
+ function get_var_sql_forminc__champs() {
+ return array(
+ "table_name",
+ "view_definition",
+ );
+ }
+
+
+
+
+ function setvalF($val = array()) {
+ //affectation valeur formulaire
+ $this->valF['table_name'] = $val['table_name'];
+ $this->valF['view_definition'] = $val['view_definition'];
+ }
+
+ //==========================
+ // Formulaire [form]
+ //==========================
+ /**
+ *
+ */
+ function setType(&$form, $maj) {
+ // Récupération du mode de l'action
+ $crud = $this->get_action_crud($maj);
+
+ // MODE AJOUTER
+ if ($maj == 0 || $crud == 'create') {
+ $form->setType("table_name", "text");
+ $form->setType("view_definition", "textarea");
+ }
+
+ // MDOE MODIFIER
+ if ($maj == 1 || $crud == 'update') {
+ $form->setType("table_name", "hiddenstatic");
+ $form->setType("view_definition", "textarea");
+ }
+
+ // MODE SUPPRIMER
+ if ($maj == 2 || $crud == 'delete') {
+ $form->setType("table_name", "hiddenstatic");
+ $form->setType("view_definition", "hiddenstatic");
+ }
+
+ // MODE CONSULTER
+ if ($maj == 3 || $crud == 'read') {
+ $form->setType("table_name", "static");
+ $form->setType("view_definition", "textareastatic");
+ }
+
+ }
+
+ /**
+ * Methode setTaille
+ */
+ function setTaille(&$form, $maj) {
+ $form->setTaille("table_name", 30);
+ $form->setTaille("view_definition", 80);
+ }
+
+ /**
+ * Methode setMax
+ */
+ function setMax(&$form, $maj) {
+ $form->setMax("table_name", 80);
+ $form->setMax("view_definition", 6);
+ }
+
+
+ function setLib(&$form, $maj) {
+ //libelle des champs
+ $form->setLib('table_name', __('table_name'));
+ $form->setLib('view_definition', __('view_definition'));
+ }
+ /**
+ *
+ */
+ function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {
+
+ }
+
+
+ //==================================
+ // sous Formulaire
+ //==================================
+
+
+ function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) {
+ $this->retourformulaire = $retourformulaire;
+ $this->set_form_default_values($form, $maj, $validation);
+ }// fin setValsousformulaire
+
+ //==================================
+ // cle secondaire
+ //==================================
+
+
+}

Added: openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_actions.inc.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_actions.inc.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_actions.inc.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,59 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 14:34
+
+$DEBUG=0;
+$serie=15;
+$ent = __("administration")." -> ".__("om_actions");
+if(!isset($premier)) $premier='';
+if(!isset($tricolsf)) $tricolsf='';
+if(!isset($premiersf)) $premiersf='';
+if(!isset($selection)) $selection='';
+if(!isset($retourformulaire)) $retourformulaire='';
+if (!isset($idxformulaire)) {
+ $idxformulaire = '';
+}
+if (!isset($tricol)) {
+ $tricol = '';
+}
+if (!isset($valide)) {
+ $valide = '';
+}
+// FROM
+$table = DB_PREFIXE."om_actions
+ LEFT JOIN ".DB_PREFIXE."om_tables
+ ON om_actions.table_name=om_tables.table_name ";
+// SELECT
+$champAffiche = array(
+ 'om_actions.om_actions as "'.__("om_actions").'"',
+ 'om_actions.libelle as "'.__("libelle").'"',
+ 'om_actions.module as "'.__("module").'"',
+ 'om_actions.parametres as "'.__("parametres").'"',
+ 'om_tables.libelle as "'.__("table_name").'"',
+ );
+//
+$champNonAffiche = array(
+ );
+//
+$champRecherche = array(
+ 'om_actions.om_actions as "'.__("om_actions").'"',
+ 'om_actions.libelle as "'.__("libelle").'"',
+ 'om_actions.module as "'.__("module").'"',
+ 'om_tables.libelle as "'.__("table_name").'"',
+ );
+$tri="ORDER BY om_actions.libelle ASC NULLS LAST";
+$edition="om_actions";
+/**
+ * Gestion de la clause WHERE => $selection
+ */
+// Filtre listing standard
+$selection = "";
+// Liste des clés étrangères avec leurs éventuelles surcharges
+$foreign_keys_extended = array(
+ "om_tables" => array("om_tables", ),
+);
+// Filtre listing sous formulaire - om_tables
+if (in_array($retourformulaire, $foreign_keys_extended["om_tables"])) {
+ $selection = " WHERE (om_actions.table_name = '".$f->db->escapeSimple($idxformulaire)."') ";
+}
+

Deleted: openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_champs.inc.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_champs.inc.php 2024-04-25 13:01:20 UTC (rev 4939)
+++ openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_champs.inc.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -1,78 +0,0 @@
-<?php
-//$Id$
-//gen openMairie le 16/04/2024 18:25
-
-$DEBUG=0;
-$serie=15;
-$ent = __("administration")." -> ".__("om_champs");
-if(!isset($premier)) $premier='';
-if(!isset($tricolsf)) $tricolsf='';
-if(!isset($premiersf)) $premiersf='';
-if(!isset($selection)) $selection='';
-if(!isset($retourformulaire)) $retourformulaire='';
-if (!isset($idxformulaire)) {
- $idxformulaire = '';
-}
-if (!isset($tricol)) {
- $tricol = '';
-}
-if (!isset($valide)) {
- $valide = '';
-}
-// FROM
-$table = DB_PREFIXE."om_champs
- LEFT JOIN ".DB_PREFIXE."om_tables
- ON om_champs.table_name=om_tables.table_name ";
-// SELECT
-$champAffiche = array(
- 'om_champs.column_name as "'.__("column_name").'"',
- 'om_tables.libelle as "'.__("table_name").'"',
- 'om_champs.table_schema as "'.__("table_schema").'"',
- 'om_champs.data_type as "'.__("data_type").'"',
- 'om_champs.character_maximum_length as "'.__("character_maximum_length").'"',
- 'om_champs.is_nullable as "'.__("is_nullable").'"',
- 'om_champs.column_default as "'.__("column_default").'"',
- 'om_champs.libelle as "'.__("libelle").'"',
- 'om_champs.type as "'.__("type").'"',
- 'om_champs.bloc as "'.__("bloc").'"',
- 'om_champs.position as "'.__("position").'"',
- 'om_champs.calcul as "'.__("calcul").'"',
- 'om_champs.liste as "'.__("liste").'"',
- );
-//
-$champNonAffiche = array(
- 'om_champs.comment as "'.__("comment").'"',
- 'om_champs.parametres as "'.__("parametres").'"',
- );
-//
-$champRecherche = array(
- 'om_champs.column_name as "'.__("column_name").'"',
- 'om_tables.libelle as "'.__("table_name").'"',
- 'om_champs.table_schema as "'.__("table_schema").'"',
- 'om_champs.data_type as "'.__("data_type").'"',
- 'om_champs.character_maximum_length as "'.__("character_maximum_length").'"',
- 'om_champs.is_nullable as "'.__("is_nullable").'"',
- 'om_champs.column_default as "'.__("column_default").'"',
- 'om_champs.libelle as "'.__("libelle").'"',
- 'om_champs.type as "'.__("type").'"',
- 'om_champs.bloc as "'.__("bloc").'"',
- 'om_champs.position as "'.__("position").'"',
- 'om_champs.calcul as "'.__("calcul").'"',
- 'om_champs.liste as "'.__("liste").'"',
- );
-$tri="ORDER BY om_champs.libelle ASC NULLS LAST";
-$edition="om_champs";
-/**
- * Gestion de la clause WHERE => $selection
- */
-// Filtre listing standard
-$selection = "";
-// Liste des clés étrangères avec leurs éventuelles surcharges
-$foreign_keys_extended = array(
- "om_tables" => array("om_tables", ),
-);
-// Filtre listing sous formulaire - om_tables
-if (in_array($retourformulaire, $foreign_keys_extended["om_tables"])) {
- $selection = " WHERE (om_champs.table_name = '".$f->db->escapeSimple($idxformulaire)."') ";
-}
-

Added: openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php
===================================================================
--- openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/gen/sql/pgsql/om_vues.inc.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,43 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 13:51
+
+$DEBUG=0;
+$serie=15;
+$ent = __("administration")." -> ".__("om_vues");
+if(!isset($premier)) $premier='';
+if(!isset($tricolsf)) $tricolsf='';
+if(!isset($premiersf)) $premiersf='';
+if(!isset($selection)) $selection='';
+if(!isset($retourformulaire)) $retourformulaire='';
+if (!isset($idxformulaire)) {
+ $idxformulaire = '';
+}
+if (!isset($tricol)) {
+ $tricol = '';
+}
+if (!isset($valide)) {
+ $valide = '';
+}
+// FROM
+$table = DB_PREFIXE."om_vues";
+// SELECT
+$champAffiche = array(
+ 'om_vues.table_name as "'.__("table_name").'"',
+ );
+//
+$champNonAffiche = array(
+ 'om_vues.view_definition as "'.__("view_definition").'"',
+ );
+//
+$champRecherche = array(
+ 'om_vues.table_name as "'.__("table_name").'"',
+ );
+$tri="ORDER BY om_vues.view_definition ASC NULLS LAST";
+$edition="om_vues";
+/**
+ * Gestion de la clause WHERE => $selection
+ */
+// Filtre listing standard
+$selection = "";
+

Added: openmairie_exemple/branches/om5_rad/obj/om_actions.class.php
===================================================================
--- openmairie_exemple/branches/om5_rad/obj/om_actions.class.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/obj/om_actions.class.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,36 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 13:52
+
+
+require_once "../gen/obj/om_actions.class.php";
+
+
+class om_actions extends om_actions_gen {
+
+ function setType(&$form,$maj) {
+ parent::setType($form, $maj);
+ if($maj==0){
+ $form->setType("parametres", "textarea");
+ $form->setType("module", "select");
+ }
+ if($maj==1){
+ $form->setType("parametres", "textarea");
+ $form->setType("module", "select");
+ }
+ }
+
+ function setSelect(&$form, $maj, &$dnu1 = NULL, $dnu2 = NULL) {
+ parent :: setSelect($form, $maj, $dnu1, $dnu2);
+ if($maj<2){
+ // module
+ $contenu=array();
+ $contenu[0]=array('','edition','ajouter',
+ 'modifier','supprimer');
+ $contenu[1]=array(_('choisir un module'),_('edition'),_('ajouter'),
+ _('modifier'),_('supprimer'));
+ $form->setSelect("module",$contenu);
+ }
+ }
+
+}

Deleted: openmairie_exemple/branches/om5_rad/obj/om_champs.class.php
===================================================================
--- openmairie_exemple/branches/om5_rad/obj/om_champs.class.php 2024-04-25 13:01:20 UTC (rev 4939)
+++ openmairie_exemple/branches/om5_rad/obj/om_champs.class.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -1,1088 +0,0 @@
-<?php
-//$Id$
-//gen openMairie le 29/12/2023 18:02
-
-require_once "../gen/obj/om_champs.class.php";
-
-class om_champs extends om_champs_gen {
-
- // ne marche pas
- var $required_field = array(
- 'column_name',
- "table_name",
- 'data_type',
- 'is_nullable',
- );
-
- var $tab;
- var $cle_secondaire;
-
- function afterSousFormSpecificContent() {
- // initialiser les affichages des champs avec change_form_om_champs de script.js
- // pb de cle secondaire qui est integer
- echo '<script type="text/javascript">change_form_om_champs($("select#data_type").val());</script>';
- }
-
- function init_class_actions() {
- parent::init_class_actions();
-
- // ACTION - 004 - composer
- //
- $this->class_actions[4] = array(
- "identifier" => "composer",
- "view" => "view_composer",
- "permission_suffix" => "ajouter",
- );
-
- // ACTION - 005 - composer
- //
- $this->class_actions[5] = array(
- "identifier" => "composer-widget-ctl",
- "view" => "view_composer_widget_ctl",
- "permission_suffix" => "ajouter",
- );
- }
-
-
- function get_var_sql_forminc__champs() {
- return array(
- "data_type",
- "column_name",
- "table_name",
- "'' as tables",
- "table_schema",
- "character_maximum_length",
- "is_nullable",
- "column_default",
- "comment",
- //"parametres", // n'est pas dans la vue
- "libelle as libelle",
- "type",
- "bloc",
- "position",
- "calcul",
- "liste",
- );
- }
-
-
- /**
- *
- * @return string
- */
- function get_default_libelle() {
- return $this->getVal($this->clePrimaire)."&nbsp;".$this->getVal("table_name");
- }
-
-
- function setType(&$form,$maj) {
- parent::setType($form, $maj);
- if($maj==0){
- $form->setType("table_schema", "hidden");
- $form->setType("data_type", "select");
- $form->setType("is_nullable", "select");
- $form->setType("bloc", "select");
- $form->setType("type", "select");
- $form->setType("libelle", "hidden"); // libelle = champs original
- $form->setType("tables", "select"); // cle secondaire
- $form->setType("liste", "select");
- }
- if($maj==1){
- $form->setType("data_type", "select");
- $form->setType("is_nullable", "select");
- $form->setType("table_schema", "hidden");
- $form->setType("bloc", "select");
- $form->setType("type", "select");
- $form->setType("liste", "select");
- if ($this->cle_secondaire == 'oui')
- $form->setType("data_type", "hiddenstatic");
- else
- $form->setType("data_type", "select");
-
- $form->setType("tables", "hidden");
- }
- if ($maj == 2) {
- $form->setType('bloc', 'selectstatic');
- $form->setType('type', 'selectstatic');
- $form->setType('is_nullable', 'selectstatic');
- $form->setType('data_type', 'selectstatic');
- $form->setType("tables", "hidden");
- }
-
- $form->setType("comment", "hidden"); // documentation enligne
- $form->setType("parametres", "text"); // documentation enligne
- $form->setType("bloc", "hidden"); // utiliser composition
- $form->setType("position", "hidden");// utiliser composition
- $form->setType("character_maximum_length", "hidden"); // ne sert pas
- $form->setType("table_name", "hidden"); // clé secondaire -> formulaire
- $form->setType("column_default", "hidden"); // ne sert pas, si champs hidden renvoie un carctère vide et non un null ?
- }
-
- function setLib(&$form,$maj) {
- parent :: setLib($form,$maj);
- $form->setLib('table_name',_("Nom de la table"));
- $form->setLib('column_name',_("Nom du champs"));
- $form->setLib('default_value',_("Valeur par défaut"));
- $form->setLib('data_type',_("Type de champs"));
- $form->setLib('is_nullable',"");
- $form->setLib('type',"");
- $form->setLib('position',_("Position dans le bloc"));
- $form->setLib('tables',"");
- $form->setLib('liste',_("Affichage en liste"));
- }
-
- function setMax(&$form, $maj) {
-
- parent::setMax($form, $maj);
-
- if($maj==0)
- $form->setMax("column_name", 60); // sans la table
- else
- $form->setMax("column_name", 120); // 40 de table + 60 de champs + point
- }
-
-
- function setSelect(&$form, $maj, &$dnu1 = NULL, $dnu2 = NULL) {
- parent :: setSelect($form, $maj, $dnu1, $dnu2);
- if($maj<2){
- // accepte les nuls
- $contenu=array();
- $contenu[0]=array('YES','NO');
- $contenu[1]=array('Non obligatoire','Obligatoire');
- $form->setSelect("is_nullable",$contenu);
- // data type
- $contenu=array();
- $contenu[0]=array('character varying','integer','double precision','boolean','cle_secondaire','text','date');
- $contenu[1]=array(_('character varying'),_('entier'),_('décimal'),_('booléen'),_('clé secondaire'),_('texte'),_('Date'));
- $form->setSelect("data_type",$contenu);
- // bloc paramétré en om_tables ...
- $sql = " select ";
- $sql .=" parametres ";
- $sql .=" FROM ".DB_PREFIXE."om_tables_parametre ";
- $sql .=" where table_name = '".$this->getParameter("idxformulaire")."' ";
- $res = $this->f->db->getOne($sql);
- $this->f->addToLog("app/om_tables_class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
- $this->f->isDatabaseError($res);
- $col=json_decode($res);
- // bloc
- $contenu=array();
- $contenu[0]=array('C1','C2','C3');
- $contenu[1]=array($col->col1,$col->col2,$col->col3);
- $form->setSelect("bloc",$contenu);
- // type
- $contenu=array();
- $contenu[0]=array('','hidden','file','html');
- $contenu[1]=array('visible','non visible','fichier','editeur html' );
- $form->setSelect("type",$contenu);
-
- // tables
- $sql = " SELECT om_tables.table_name, om_tables.table_name as lib FROM ";
- $sql .= DB_PREFIXE."om_tables ";
- $sql .= " where substring(table_name,1,3) not like 'om_' ";
- $sql .= " and table_name not like '".$this->getParameter("idxformulaire")."' ";
- $sql .= " ORDER BY om_tables.table_name";
- $res = $this->f->db->query($sql);
- $this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE);
- $this->f->isDatabaseError($res);
- //
- $contenu = array(array(""), array(__("choisir une table")));
- while ($row =& $res->fetchrow()) {
- $contenu[0][] = $row[0];
- $contenu[1][] = $row[1];
- }
- $form->setSelect("tables", $contenu);
- // liste
- $contenu=array();
- $contenu[0]=array(1,0);
- $contenu[1]=array('Oui','Non');
- $form->setSelect("liste",$contenu);
- }
- }
-
- function setOnchange(&$form, $maj) {
- //javascript controle client
- $form->setOnchange('position','VerifNum(this)');
- $form->setOnchange('data_type','change_form_om_champs(this.value)');
- }
-
- function set_form_default_values(&$form, $maj, $validation) {
- parent::set_form_default_values($form, $maj, $validation);
- if($maj==0){
- $form->setVal('liste', 1);
- }
- If($maj>0){
- // clé secondaire
- $temp = explode(".", $this->getParameter("idx"));
- $temp = $temp[0]."_".$temp[1]."_fkey";
- $sql = "SELECT count(constraint_name) FROM information_schema.table_constraints ";
- $sql .= " where constraint_name = '".$temp."'";
- $res = $this->f->db->getOne($sql);
- $this->f->addToLog("obj/om_champs_class.php: db->getOne(\"".$sql."\");", DEBUG_MODE);
- $this->f->isDatabaseError($res);
- if($res>0){
- $form->setVal('data_type',"cle_secondaire");
- $form->setType('data_type', "hiddenstatic");
- $this->cle_secondaire='oui';
- }else{
- $this->cle_secondaire='non';
- $form->setType("type", "select");
- }
- // remplissage om_forms
- // -> pourquoi cela ne se rempli pas automatiquement comme om_tables depuis la vue om_champs ???
- // code à simplifier si on sait pourquoi !!!!
-
- $sql = "SELECT parametres->>'libelle' as libelle, parametres->>'type' as type ,";
- $sql .= " parametres->>'bloc' as bloc, parametres->>'position' as position, ";
- $sql .= " parametres->>'calcul' as calcul, parametres->>'liste' as liste";
- $sql .= " from ".DB_PREFIXE."om_forms ";
- $sql .= " where column_name = '".$this->getParameter("idx")."'";
- $this->f->addToLog("obj/om_champs_class.php: db->query(\"".$sql."\");", DEBUG_MODE);
- $res = $this->f->db->query($sql);
- $this->f->isDatabaseError($res);
- while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
- $form->setVal('libelle', $row['libelle']);
- $form->setVal('type', $row['type']);
- $form->setVal('position', $row['position']);
- $form->setVal('bloc', $row['bloc']);
- $form->setVal('calcul', $row['calcul']);
- $form->setVal('liste', $row['liste']);
- }
-
-
- }
- /*
- If($maj==3){
- // clé secondaire
- $temp = explode(".", $this->getParameter("idx"));
- $temp = $temp[0]."_".$temp[1]."_fkey";
- $sql = "SELECT count(constraint_name) FROM information_schema.table_constraints ";
- $sql .= " where constraint_name = '".$temp."'";
- $res = $this->f->db->getOne($sql);
- $this->f->addToLog("obj/om_champs_class.php: db->getOne(\"".$sql."\");", DEBUG_MODE);
- $this->f->isDatabaseError($res);
- if($res>0){
- $form->setVal('data_type',"cle_secondaire");
- }
- }
- */
- }
-
-
- function verifier($val = array(), &$dnu1 = null, $dnu2 = null) {
- parent::verifier($val, $dnu1, $dnu2);
- if($this->getParameter('maj')==0){ //ancienne méthode verifierAjout()
- // ===============================================
- // la clé ne doit pas être vide et elle est unique
- // ===============================================
- if ($this->valF['column_name'] == $this->valF['table_name'].".") {
- $this->correct = false;
- //$this->addToMessage("<br/>");
- $this->addToMessage( __("Le nom du champs est obligatoire")."&nbsp;");
- $this->addToMessage("[&nbsp;".__($this->clePrimaire)."&nbsp;]");
- }
- // la clé doit être différente
- if ($this->typeCle == "A") {
- $sql = "select count(*) from ".DB_PREFIXE.$this->table." ";
- $sql .= "where ".$this->clePrimaire."='".$this->valF[$this->clePrimaire]."' ";
- // Exécution de la requête
- $nb = $this->f->db->getone($sql);
- // Logger
- $this->addToLog(__METHOD__."(): db->getone(\"".$sql."\");", VERBOSE_MODE);
- // Vérification d'une éventuelle erreur de base de données
- $this->f->isDatabaseError($nb);
- //
- if ($nb > 0) {
- $this->correct = false;
- $this->addToMessage($nb." ");
- $this->addToMessage( __("cle primaire existante"));
- $this->addToMessage(" ".$this->table."<br />");
- }
- }
- }
- // =============================
- // Contrôle des types openMairie
- // =============================
- if($this->getParameter('maj')<2){
- // si data_type=text alors html est possible
- if($val['type']=="html" and $val['data_type']!="text"){
- $this->correct = false;
- $this->addToMessage( __("type html impossible pour champ non texte"));
- }
- // si data_type = character varying alors upload est possible
- if($val['type']=="file" and $val['data_type']!="character varying"){
- $this->correct = false;
- $this->addToMessage( __("type upload impossible pour champ non texte"));
- }
- // si un champ hidden ne doit pas être obligatoire
- if($val['type']=="hidden" and $val['is_nullable']=="NO"){
- $this->correct = false;
- $this->addToMessage( __("type non visible impossible pour champ obligatoire"));
- }
-
- }
- }
-
- // possibilité de modifier calcul
- function verifier_calcul($calcul) {
- // pb de la guillemet pour date('Y-m-d') en champs date
- if($calcul!=""){
- $calcul=str_replace("'","''",$calcul);
- $this->f->addToLog("obj/om_champs_class.php: db->getOne(\"".$calcul."\");", DEBUG_MODE);
- }
- // verification que les champs existent dans la table en cours
- if($this->valF['data_type'] == "double precision" or $this->valF['data_type'] == "integer"){
- $tp=str_replace("*", "|*|",$calcul);
- $tp=str_replace("+", "|+|",$tp);
- $tp=str_replace("-", "|-|",$tp);
- $tp=str_replace("/", "|/|",$tp);
- $tp=str_replace("(", "|(|",$tp);
- $tp=str_replace(")", "|)|",$tp);
- $tp=explode("|", $tp);
- $ch='';
- $i=0;
- $sql = " SELECT column_name";
- $sql .= " FROM ".DB_PREFIXE."om_champs ";
- $sql .= " where om_champs.table_name = '".$this->valF["table_name"]."' ";
- $res = $this->f->db->query($sql);
- $this->f->addToLog("app/om_champs_class.php: db->query(\"".$sql." ".$widget_id."\");", DEBUG_MODE);
- $this->f->isDatabaseError($res);
- $champs=array();
- while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
- array_push($champs,$row['column_name']);
- }
- foreach($tp as $el){
- if($el=='*' or $el=='+' or $el=='-' or $el=='/' or $el==')' or $el=='(')
- $ch .= $el;
- else
- if($el!='') // cas ou il a une opérande et une parenthèse de suite
- if(is_numeric($el)) // cas ou il y a une constante forcemment numérique
- $ch .= $el;
- else{
- // vérification de l'existence des champs dans la table en cours
- $ok=0;
- foreach($champs as $champ){
- $temp=explode(".",$champ);
- if($el==$temp[1] and $ok==0){
- $ok=1;
- }
- }
- if($ok==1)
- $ch .= $el;
- else{
- $ch .= $el;
- $this->addToMessage($el." "._("est un champs inexistant en table")." ".$this->valF["table_name"]);
- $this->correct=false;
- }
- }
- }
- $calcul=$ch;
- }
- return $calcul;
- }
-
- // possibilité de modifier libelle
- function verifier_libelle($libelle) {
- if($libelle!=""){
- $libelle=str_replace("'","''",$libelle);
- $this->f->addToLog("obj/om_champs_class.php: db->getOne(\"".$calcul."\");", DEBUG_MODE);
- }
- return $libelle;
- }
-
-
- function setvalF($val = array()) {
- //affectation valeur formulaire
- parent::setvalF($val);
- if($this->getParameter('maj')==0){
- if ($val['data_type'] == 'cle_secondaire'){
- $val['column_name'] = $val['tables'];
- $this->valF['column_name'] = $val['tables'];
- $this->addToMessage("nom de champs = ".$val['column_name']);
- }
- // clé primaire
- // traitement du nom de champs
- // le libellé prend la valeur du nom de champs origine
- // la sequence \ (echappement) n est pas traitée
- // caractères spéciaux
- $temp = str_replace( array( '%', '@', '\'', ';', '<', '>','@','[',']',' '), '_', $val['column_name']);
- $temp = str_replace( array( '#', '{', '}','&', '$' , '£', 'µ','*','|','?',':'), '_', $temp);
- // accents
- $temp = str_replace(array( 'é', 'è', 'ê'), 'e',$temp);
- $temp = str_replace(array( 'ô'), 'o',$temp);
- $temp = str_replace(array( 'ù'), 'u',$temp);
- $temp = str_replace(array( 'à'), 'a',$temp);
- $temp = str_replace(array( 'ç'), 'c',$temp);
- $temp = strtolower($temp);
- // 1er caractère ne doit pas être un chiffre -> remplacer par "_"
- if(is_numeric(substr($temp,0,1))){
- $temp="_".(substr($temp,1,strlen($temp)-1));
- }
- // clé primaire = table.champs
- // On remet la clé primaire en forme table.champs
- // en retour "insert" mettre en forme la clé primaire car sinon erreur suivante :
- // class om_champs - dbform::is_action_condition_satisfied(): return false;
- // en effet la clé primaire doit exister pour satisfaire la condition exist()
- $this->valF['column_name'] = $val['table_name'].".".$temp;
- $this->tab->libelle=$val['column_name'];
- // recherche position pour bloc = C1 en ajout
- // SELECT max(parametres->>'position') FROM om5.om_forms where SPLIT_PART(om_forms.column_name, '.', 1) = 'famille' and parametres->>'bloc' = 'C1'
-
- $sql = " SELECT ";
- $sql .= " max(parametres->>'position') ";
- $sql .= " FROM ".DB_PREFIXE."om_forms ";
- $sql .= " where SPLIT_PART(om_forms.column_name, '.', 1) = '".$this->valF["table_name"]."' ";
- $sql .= " and parametres->>'bloc' = 'C1'";
- $res = $this->f->db->getOne($sql);
- $this->f->addToLog("obj/om_forms_class.php - setvalF: db->getOne(\"".$sql."\");", DEBUG_MODE);
- $this->f->isDatabaseError($res);
- $position=intval($res);
- // recherche du max position
- $position++;
- $this->tab->bloc = 'C1';
- $this->tab->position = $position;
- }
- // update
- if($this->getParameter('maj')==1){
- if ($this->cle_secondaire == 'oui'){
- $val['data_type'] = "integer";
- $this->addToMessage("data_type = integer");
- }
- }
- }
-
- // ajout = alter nom_table add nom_colonne type
- function ajouter($val = array(), &$dnu1 = null, $dnu2 = null) {
- // Begin
- $this->begin_treatment(__METHOD__);
- // Mutateur de valF
- $this->setValF($val);
- // verifier si existe des champs
- $temp = explode(".", $this->valF['column_name']); // valeur du champ
- $this->verifier($val, $this->f->db, null);
- // methode de verification champ lib
- $val['calcul']=$this->verifier_calcul($val['calcul']);
- $val['libelle']=$this->verifier_libelle($val['libelle']);
- //$this->setValFAjout($val); -> dans verifier()
- if ($this->correct) {
- // cas cle secondaire
- if($this->valF['data_type']== 'cle_secondaire')
- $data_type = 'integer';
- else
- $data_type=$this->valF['data_type'];
- //$this->addToMessage($temp[1]);
- $sql = "alter table ".DB_PREFIXE.$this->valF['table_name']." add column ";
- //$sql .= $this->valF['column_name']." ".$data_type;
- $sql .= $temp[1]." ".$data_type;
- if($this->valF['is_nullable']== 'NO')
- $sql .= " not null ";;
- // default a peu d'intérêt -> utiliser setval car la mise a jour
- // se fait sur les enregistrements existants
- // et n'est pas pris en compte même si champs hidden
- if($this->valF['column_default'] != '')
- $sql .= " DEFAULT ".$this->valF['column_default'].""; // guillement à mettre ans le champs
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- //
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else{
- $this->addToMessage("création du champ ".$this->valF['column_name']);
- //*** modification comment -> om_forms/json
- $this->tab->type = $val['type'];
- $this->tab->calcul = $val['calcul'];
- $this->tab->liste = $val['liste']; //***
- $insert=json_encode($this->tab);
- //$sql = "comment on COLUMN ".DB_PREFIXE.$this->valF['table_name'].".".$temp[1]." IS ";
- $sql = "insert into ".DB_PREFIXE."om_forms ";
- $sql .= " VALUES ( '".$this->valF['column_name']."',";
- $sql .= "'".$insert."')";
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs[1
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else{
- $this->addToMessage("ajout des paramètres en commentaire du champs"." ".$this->valF['column_name']);
- if($this->triggermodifierapres($id, $this->f->db, $val, null) === false) {
- $this->correct = false;
- $this->addToLog(__METHOD__."(): ERROR", DEBUG_MODE);
- // Return
- return $this->end_treatment(__METHOD__, false);
- }
- }
- //***
- // Le premier parametre est vide car en MODE 'insert'
- // l'enregistrement n'existe pas encore donc il n'a pas
- // d'identifiant
-
- if($this->triggerajouterapres($this->valF[$this->clePrimaire], $this->f->db, $val, null) === false) {
- $this->correct = false;
- $this->addToLog(__METHOD__."(): ERROR", DEBUG_MODE);
- // Return
- return $this->end_treatment(__METHOD__, false);
- }
-
- }
- }else {
- // Message d'echec (saut d'une ligne supplementaire avant le
- // message pour qu'il soit mis en evidence)
- $this->addToMessage("<br/>".__("ajout non effectués")."<br/>");
- $message = __("champ non ajouté");
- $this->addToLog(__METHOD__."(): ".$message, VERBOSE_MODE);
- // Return
- return $this->end_treatment(__METHOD__, false);
- }
- return $this->end_treatment(__METHOD__, true);
- }
-
-
- // en modifier : alter table nom_table alter column nom_colonne type
- // COMMENT ON COLUMN om5.livre.fichier IS '{"bloc":"1","position":"2","libelle":"mon auteur", "type":"fichier"}';
-
- function modifier($val = array(), &$dnu1 = null, $dnu2 = null) {
- // Begin
- $this->begin_treatment(__METHOD__);
- // Mutateur de valF
- $this->setValF($val);
- // verifier si existe des champs
- $temp = explode(".", $this->valF['column_name']); // valeur du champ
- $this->verifier($val, $this->f->db, null);
- // methode de verification champ lib
- $val['calcul']=$this->verifier_calcul($val['calcul']);
- $val['libelle']=$this->verifier_libelle($val['libelle']);
- if ($this->correct) {
- // cas cle secondaire
- if($this->valF['data_type']== 'cle_secondaire')
- $data_type = 'integer';
- else
- $data_type=$this->valF['data_type'];
- // modifier
- $sql = "alter table ".DB_PREFIXE.$this->valF['table_name']." alter column ";
- $sql .= $temp[1]." type ".$data_type;
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else{
- $this->addToMessage("modification du champ ".$this->valF['column_name']);
- //*** modification comment
- $this->tab->libelle = $val['libelle'];
- $this->tab->type = $val['type'];
- $this->tab->bloc = $val['bloc'];
- $this->tab->position = $val['position'];
- $this->tab->calcul = $val['calcul'];
- $this->tab->liste = $val['liste']; //***
- $insert=json_encode($this->tab);
- //$sql = "comment on COLUMN ".DB_PREFIXE.$this->valF['table_name'].".".$temp[1]." IS ";
- $sql = "update ".DB_PREFIXE."om_forms set parametres = ";
- $sql .= "'".$insert."'";
- $sql .= " where column_name = '".$this->valF['column_name']."'";
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs[1
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else{
- $this->addToMessage("modification des paramètres en om_forms pour"." ".$this->valF['column_name']);
- if($this->triggermodifierapres($id, $this->f->db, $val, null) === false) {
- $this->correct = false;
- $this->addToLog(__METHOD__."(): ERROR", DEBUG_MODE);
- // Return
- return $this->end_treatment(__METHOD__, false);
- }
- }
- if($this->valF['is_nullable']== 'NO'){
- $sql = "alter table ".DB_PREFIXE.$this->valF['table_name']." alter column ";
- $sql .= $temp[1]." set not null ";
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else
- $this->addToMessage("modification du champ not null ".$this->valF['column_name']);
- }else{
- $sql = "alter table ".DB_PREFIXE.$this->valF['table_name']." alter column ";
- $sql .= $temp[1]." drop not null ";
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else
- $this->addToMessage("modification du champ null ".$this->valF['column_name']);
- }
- // *** column default
- // a peu d'intérêt -> utiliser setval car la mise a jour
- // se fait sur les enregistrements existants
- // et n'est pas pris en compte même si champs hidden
-
- if($this->valF['column_default'] == ''){
- $sql = "alter table ".DB_PREFIXE.$this->valF['table_name']." alter column ";
- $sql .= $temp[1]." drop DEFAULT ";
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else
- $this->addToMessage("suppression de la valeur par default ".$this->valF['column_name']);
- }else{
- $sql = "alter table ".DB_PREFIXE.$this->valF['table_name']." alter column ";
- $sql .= $temp[1]." set DEFAULT ".$this->valF['column_default'].""; // guillement à mettre ans le champs";
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs
- $this->addToMessage($res->getDebugInfo());
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else
- $this->addToMessage("ajout de la valeur par default ".$this->valF['column_name']);
- }
-
- }
- }else {
- // Message d'echec (saut d'une ligne supplementaire avant le
- // message pour qu'il soit mis en evidence)
- $this->addToMessage("<br/>".__("modification non effectués")."<br/>");
- $message = __("champ non modifié");
- $this->addToLog(__METHOD__."(): ".$message, VERBOSE_MODE);
- // Return
- return $this->end_treatment(__METHOD__, false);
- }
- return $this->end_treatment(__METHOD__, true);
- }
-
- // en supprimer : alter table nom_table drop nom_colonne
- function supprimer($val = array(), &$dnu1 = null, $dnu2 = null) {
- // Begin
- $this->begin_treatment(__METHOD__);
- // Mutateur de valF
- $this->setValF($val);
- // verifier si existe des champs
- $temp = explode(".", $this->valF['column_name']); // valeur du champ
- $this->verifier($val, $this->f->db, null);
- if ($this->correct) {
- // destruction de la table -> CASCADE ?
- $sql = "alter table ".DB_PREFIXE.$temp[0]." drop ";
- $sql .= $temp[1];
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- $this->addToMessage($res->getDebugInfo());
- // Appel de la methode de recuperation des erreurs
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->correct = false;
- // Return
- return $this->end_treatment(__METHOD__, false);
- }else{
-
- $this->addToMessage("destruction du champ ".$this->valF['column_name']);
- if($this->triggersupprimerapres($this->valF[$this->clePrimaire], $this->f->db, $val, null) === false) {
- $this->correct = false;
- $this->addToLog(__METHOD__."(): ERROR", DEBUG_MODE);
- // Return
- return $this->end_treatment(__METHOD__, false);
- }
- }
- }else {
- // Message d'echec (saut d'une ligne supplementaire avant le
- // message pour qu'il soit mis en evidence)
- $this->addToMessage("<br/>".__("destruction non effectués")."<br/>");
- $message = __("champ non détruit");
- $this->addToLog(__METHOD__."(): ".$message, VERBOSE_MODE);
- // Return
- return $this->end_treatment(__METHOD__, false);
- }
- return $this->end_treatment(__METHOD__, true);
- }
-
- // traitement du data_type cle_secondaire
- function triggerajouterapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) {
- if($this->valF['data_type']== 'cle_secondaire'){
- $this->cle_secondaire_contrainte($id, $dnu1, $val, $dnu2);
- }
-
- }
-
- function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) {
- // destruction d'om_forms
- $sql = "delete from ".DB_PREFIXE."om_forms";
- $sql .= " where column_name = '".$this->valF['column_name']."'";
- $res = $this->f->db->query($sql);
- $this->addToLog("triggersupprimerapres() : db->query(\"".$sql."\")", VERBOSE_MODE);
- if ($this->f->isDatabaseError($res, true)) {
- $this->addToMessage($res->getDebugInfo());
- }else
- $this->addToMessage(_("suppression enregistrement om_forms pour")." ".DB_PREFIXE.$this->valF['table_name']."");
- }
-
-
- function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) {
- if($this->valF['data_type']== 'cle_secondaire' and $this->cle_secondaire=='non'){
- $this->cle_secondaire_contrainte($id, $dnu1, $val, $dnu2);
- }
- }
-
- function cle_secondaire_contrainte($id, &$dnu1 = null, $val = array(), $dnu2 = null) {
- // recherche si le nom de champ correspond à une table
- $temp = explode(".", $this->valF['column_name']); // valeur du champ
- $schema = substr(DB_PREFIXE, 0, -1);
- $sql = "select table_name from information_schema.tables ";
- $sql .= " where table_type = 'BASE TABLE' and table_schema = '".$schema."'";
- $sql .= " and table_name = '".$temp[0]."'";
- $table= $this->f->db->getOne($sql);
- $this->addToLog("triggerajouterapres() : db->getOne(\"".$sql."\")", VERBOSE_MODE);;
- // test existence $table
- if($table){
- $sql = " ALTER TABLE ONLY ".DB_PREFIXE.$this->valF['table_name'];
- $sql .= " ADD CONSTRAINT ".$this->valF['table_name']."_".$temp[1]."_fkey FOREIGN KEY (";
- $sql .= $temp[1].") REFERENCES ";
- $sql .= DB_PREFIXE.$temp[1]."(".$temp[1].")";
- //$this->addToMessage($sql);
- $res = $this->f->db->query($sql);
- if ($this->f->isDatabaseError($res, true)) {
- // Appel de la methode de recuperation des erreurs
- $this->addToMessage($res->getDebugInfo());
- $this->addToMessage(_("pas de creation cle secondaire sur table ")." ".$temp[1]);
- $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
- $this->addToLog("triggerajouterapres() : db->query(\"".$sql."\")", VERBOSE_MODE);
- }else
- $this->addToMessage(_("creation cle secondaire sur table ")." ".$temp[1]);
- $this->db->commit();
- }else
- $this->addToMessage(_("pas de creation cle secondaire sur table inexixtante")." ".$temp[1]);
-
- }
-
-
-// ============================================
-// action 4 et 5 pour présenter les formulaires
-// ============================================
-
- // affichage en select des om_tables
- // recherche des champs dans les colonnes
- function view_composer() {
- // Verification de l'accessibilité sur l'élément
- $this->checkAccessibility();
-
- // Affichage du formulaire de sélection de tables
-
- // Ouverture du formulaire
- $this->f->layout->display__form_container__begin(array(
- "action" => $this->getDataSubmit(),
- "id" => "dashboard_composer_form",
- ));
- // ===============================================
- // Paramétrage des champs du formulaire table_name
- // ===============================================
- $champs = array("table_name");
- // Création d'un nouvel objet de type formulaire
- $form = $this->f->get_inst__om_formulaire(array(
- "validation" => 0,
- "maj" => 0,
- "champs" => $champs,
- ));
- // Paramétrage du champs table_name
- $form->setLib("table_name", __("Formulaire pour la table"));
- $form->setType("table_name", "select");
- $form->setTaille("table_name", 25);
- $form->setOnChange("table_name", "submit()");
- $form->setMax("table_name", 25);
- $form->setVal("table_name", (isset($_POST["table_name"]) ? $_POST["table_name"] : ""));
- $sql = " SELECT om_tables.table_name, om_tables.table_name as lib
- FROM ".DB_PREFIXE."om_tables where substring(table_name,1,3) not like 'om_' ORDER BY om_tables.table_name";
- $res = $this->f->db->query($sql);
- $this->addToLog(__METHOD__."(): db->query(\"".$sql."\");", VERBOSE_MODE);
- $this->f->isDatabaseError($res);
- //
- $contenu = array(array(""), array(__("choisir une table")));
- while ($row =& $res->fetchrow()) {
- $contenu[0][] = $row[0];
- $contenu[1][] = $row[1];
- }
- $form->setSelect("table_name", $contenu);
- // Affichage du formulaire
- $form->entete();
- $form->afficher($champs, 0, false, false);
- $form->enpied();
- // Fermeture du fomulaire
- $this->f->layout->display__form_container__end();
- // *** fin formulaire table
- // retour du nom de table choisi
- if (!isset($_POST["table_name"]) || $_POST["table_name"] == "") {
- return;
- }
- // Initialisation des paramètres
- $params = array(
- "edition" => array(
- "default_value" => 1,
- ),
- );
- foreach ($this->f->get_initialized_parameters($params) as $key => $value) {
- ${$key} = $value;
- }
- // affichage des widgets-champs
- echo "<div id=\"dashboard-composer\">\n";
- // Ouverture du conteneur #dashboard
- echo "<div id=\"dashboard\">\n";
- // Conteneur permettant de recevoir d'eventuels messages d'erreur des requetes
- // Ajax
- echo "<div id=\"info\">";
- echo "</div>\n";
- // Si le mode edition est active alors on affiche l'action pour ajouter un
- // nouveau widget
- // pas d affichage des champs
- // Si le mode edition est activé alors on affiche un lien contenant
- // le lien vers les actions de contrôle des widgets
- // le mode edition est toujours actif
- if ($edition == 1) {
- // creer un lien -> *** enleve display:none sinon pas d'affichage
- // lancement action 5 : view_composer_widget_ctl qui met à jour bloc et position en modification
- // et type=hidden en suppression
- printf(
- '<a id="widgetctl-href-base" href="%s" >&nbsp;</a>',
- OM_ROUTE_FORM."&obj=om_champs&idx=0&action=5"
- );
- }
- // Ouverture du conteneur de colonnes
- // nombre de colonne à afficher -> json d'om_tables
- $sql = " select parametres ";
- $sql .= " from ".DB_PREFIXE."om_tables_parametre ";
- $sql .=" where table_name = '".$_POST['table_name']."' ";
- $res = $this->f->db->getOne($sql);
- $this->f->addToLog("app/om_champs_ class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
- $this->f->isDatabaseError($res);
- $tab=json_decode($res);
- $nb_column=$tab->nombre_colonne;
- $this->addToLog("view_composer() : db->getOne(\"".$sql."\")", VERBOSE_MODE);;
- if(!is_numeric($nb_column))
- $nb_column=2;
- echo "<div class=\"col".$nb_column."\">\n";
- // ajout des champs par colonne
- // requête globale
- $sql = " SELECT om_forms.column_name, SPLIT_PART(om_forms.column_name, '.', 1) as table_name,";
- $sql .= " data_type, parametres->>'type' as type, parametres->>'bloc' as bloc, parametres->>'position' as position ";
- $sql .= " FROM ".DB_PREFIXE."om_champs ";
- $sql .= " left join ".DB_PREFIXE."om_forms on om_forms.column_name=om_champs.column_name";
- $sql .= " where SPLIT_PART(om_forms.column_name, '.', 1) = '".$_POST["table_name"]."'";
- $sql .= " order by parametres->>'bloc',parametres->>'position' ";
- //echo $sql;
- $res = $this->f->db->query($sql);
- $this->f->addToLog("app/om_champs_class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
- $this->f->isDatabaseError($res);
- while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
- //$temp=json_decode($row["comment"]);
- $c[$row["column_name"]]["position"]=$row['position'];
- $c[$row["column_name"]]["bloc"]=$row['bloc'];
- $c[$row["column_name"]]["type"]=$row['type'];
- $c[$row["column_name"]]["table_name"]=$row["table_name"];
- $c[$row["column_name"]]["column_name"]=$row["column_name"];
- $c[$row["column_name"]]["data_type"]=$row["data_type"];
- }
- // On boucle sur chacune des colonnes
- for ($i = 1; $i <= $nb_column; $i++) {
- // Ouverture du conteneur .column
- echo "<div class=\"column\" id=\"column_".$i."\">\n";
- foreach($c as $key => $elem){
- if($elem["bloc"]=="C".intval($i)){
- //echo "->".$elem['column_name']." ".$elem['position']." ";
- //echo $elem['bloc']."*<br>";
- if($elem['type'] == 'hidden'){
- echo $elem['column_name']." [non visible]";
- }else{
- // Affichage des colonnes
- $this->display_dashboard_widget(
- $elem['column_name'], // pour update et delete
- $elem['column_name'], // titre fenetre champ
- $elem['data_type']." - ". $elem['type'], // contenu
- $elem['data_type'],
- $elem['position'],
- $edition
- );
- }
- }
- }
- // Fermeture du conteneur .column
- echo "</div>\n";
- }
- // On affiche un conteneur vide pour avec la propriete clear a both pour
- // reinitialiser le positionnement des blocs
- echo "<div class=\"both\"><!-- --></div>\n";
- // Fermeture du conteneur de colonnes
- echo "</div>\n";
- // Fermeture du conteneur #dashboard
- echo "</div>\n";
- // Fermeture du conteneur #dashboard-composer
- echo "</div>\n";
- }
-
- // fonction appellée par view_composer()
- // affichage des colonnes
- function display_dashboard_widget($id = NULL, $title = NULL, $content = NULL, $footer = NULL, $type = NULL, $mode_edit = false) {
- // Ouverture du conteneur du widget
- echo "<div";
- echo " class=\"widget ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ".$class_sup."\"";
- echo " id=\"widget_".$id."\"";
- echo ">\n";
- // Titre du widget
- echo "<div class=\"widget-header ";
- if ($mode_edit == true) {
- echo "widget-header-edit widget-header-move ";
- }
- echo "ui-widget-header ui-corner-all\">";
- echo "<h3>";
- echo $title;
- echo "</h3>";
- echo "</div>\n";
- // Ouverture du wrapper : Contenu + Footer
- echo "<div class=\"widget-content-wrapper\">\n";
- // Contenu du widget
- echo "<!-- Start Widget Content -->\n";
- echo "<div class=\"widget-content\">\n\n";
- //
- echo $content;
- //
- echo "\n\n</div>\n";
- echo "<!-- End Widget Content -->\n";
- // Fermeture du wrapper : Contenu + Footer
- echo "</div>\n";
- // Fermeture du conteneur du widget
- echo "</div>\n";
- }
-
- // mise à jour de comment de om_champs: bloc, position, type
- function view_composer_widget_ctl() {
- // Initialisation des paramètres
- $params = array(
- "mode" => array(
- "default_value" => null,
- ),
- "widget" => array(
- "default_value" => null,
- ),
- "profil" => array(
- "default_value" => 0,
- ),
- );
- foreach ($this->f->get_initialized_parameters($params) as $key => $value) {
- ${$key} = $value;
- }
- //UPDATE
- //index.php?module=form&obj=om_champs&idx=0&action=5
- //&mode=update
- //&column_1=widget_livre.auteurxwidget_livre.titre
- //&column_2=widget_livre.fichier
- //&column_3=widget_livre.resume&
- if ($mode == "update") {
- $c=array();
- $nb=array();
- foreach($this->f->get_submitted_get_value() as $key => $values) {
- // On souhaite récupérer uniquement les paramètres column_*
- if (!$this->f->starts_with($key, "column_")) {
- continue;
- }
- $this->f->addToLog(__METHOD__."(): mode update (".$key.");", DEBUG_MODE);
- $bloc = "C".str_replace("column_", "", $key);
- $widgets = explode("xwidget_", $this->f->get_submitted_get_value($key));
- foreach($widgets as $i => $widget_id) {
- $position = $i+1;
- $widget_id = str_replace("widget_", "", $widget_id);
- // Lorsqu'une colonne est vide, il y a une valeur vide dans le
- // tableau widget, donc si c'est le cas on passe a l'iteration
- // suivante
- if ($widget_id == "") {
- //$this->f->addToLog(__METHOD__."(): mode update vide(".$table.");", DEBUG_MODE);
- continue;
- }else{
- // initialisation du nom de la table pour requête sql
- $temp1=explode(".", $widget_id);
- $table=$temp1[0];
- //$this->f->addToLog(__METHOD__."(): mode update existant(".$table.");", DEBUG_MODE);
- }
- $c[$widget_id]["position"]=$position;
- $c[$widget_id]["bloc"]=$bloc;
- // comptage par bloc
- }
- // max par colonne pour position des champs hidden
- $nb[$bloc]=$position;
- }
- //$this->f->addToLog(__METHOD__."(): mode update(".print_r($c, true).");", DEBUG_MODE);
- //$this->f->addToLog(__METHOD__."(): mode update(".$table.");", DEBUG_MODE);
- $sql = " select om_champs.column_name, om_champs.table_name, data_type, ";
- $sql .= " parametres->>'bloc' as bloc, parametres->>'position', ";
- $sql .= " parametres->>'type' as bloc, parametres->>'position' ";
- $sql .= " FROM ".DB_PREFIXE."om_champs left join ".DB_PREFIXE."om_forms ";
- $sql .= " on om_champs.column_name=om_forms.column_name ";
- $sql .= " where om_champs.table_name = '".$table."' ";
- $res = $this->f->db->query($sql);
- $this->f->addToLog("app/om_champs_class.php: db->query(\"".$sql." ".$widget_id."\");", DEBUG_MODE);
- $this->f->isDatabaseError($res);
- while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
- $temp1=explode(".", $row['column_name']);
- //$this->f->addToLog(__METHOD__."(): mode update type (".$temp->type.");", DEBUG_MODE);
- if($row['type']=='hidden'){ // cas des champs cachés non affichés
- $nb['C1']++;
- $row['bloc']= 'C1';
- $row['position']=$nb['C1'];
- $this->f->addToLog(__METHOD__."(): mode update type(".$temp->type.");", DEBUG_MODE);
- }else{
- $bloc=$c[$row['column_name']]["bloc"];
- $position=$c[$row['column_name']]["position"];
- }
- // update bloc
- $sql = " update ".DB_PREFIXE."om_forms set parametres = jsonb_set(parametres, '{bloc}', '\"".$bloc."\"')";
- $sql .= " WHERE column_name = '".$row['column_name']."'" ;
- $res3 = $this->f->db->query($sql);
- $this->f->addToLog(__METHOD__."(): mode update(\"".$sql."\", ".print_r($temp, true).");", DEBUG_MODE);
- $this->f->isDatabaseError($res3);
- // update position
- $sql = " update ".DB_PREFIXE."om_forms set parametres = jsonb_set(parametres, '{position}', '\"".$position."\"')";
- $sql .= " WHERE column_name = '".$row['column_name']."'" ;
- $res2 = $this->f->db->query($sql);
- $this->f->addToLog(__METHOD__."(): mode update(\"".$sql."\", ".print_r($temp, true).");", DEBUG_MODE);
- $this->f->isDatabaseError($res2);
-
- }
- return;
- }
- // DELETE
- // module=form&obj=om_forms&idx=0&action=5&mode=delete&widget=widget_livre.auteur
- if ($mode == "delete") {
- // widget est le column_name concerné
- $widget = str_replace("widget_", "", $widget);
- // en mode delete le champs est mis en hidden
- $sql = " update ".DB_PREFIXE."om_forms set parametres = jsonb_set(parametres, '{type}', '\"hidden\"')";
- $sql .= " WHERE column_name = '".$widget."'" ;
- $res = $this->f->db->query($sql);
- $this->f->addToLog(__METHOD__."(): mode delete ".$sql." ;", DEBUG_MODE);
- $this->f->isDatabaseError($res);
- return;
- }
- }
-
-}

Added: openmairie_exemple/branches/om5_rad/obj/om_vues.class.php
===================================================================
--- openmairie_exemple/branches/om5_rad/obj/om_vues.class.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/obj/om_vues.class.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,24 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 13:51
+
+
+require_once "../gen/obj/om_vues.class.php";
+
+
+class om_vues extends om_vues_gen {
+
+ /*
+ function getFormTitle($ent) {
+ //
+ $out = ""$ent;
+ if ($this->getVal($this->clePrimaire) != "") {
+ $out .= "<span class=\"libelle\"> -> ".$this->get_default_libelle()."</span>";
+ }
+ return $out;
+ }
+ */
+
+
+
+}

Added: openmairie_exemple/branches/om5_rad/sql/pgsql/om_actions.inc.php
===================================================================
--- openmairie_exemple/branches/om5_rad/sql/pgsql/om_actions.inc.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/sql/pgsql/om_actions.inc.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,5 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 13:52
+
+include "../gen/sql/pgsql/om_actions.inc.php";

Deleted: openmairie_exemple/branches/om5_rad/sql/pgsql/om_champs.inc.php
===================================================================
--- openmairie_exemple/branches/om5_rad/sql/pgsql/om_champs.inc.php 2024-04-25 13:01:20 UTC (rev 4939)
+++ openmairie_exemple/branches/om5_rad/sql/pgsql/om_champs.inc.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -1,41 +0,0 @@
-<?php
-//$Id$
-//gen openMairie le 03/05/2018 08:49
-
-include "../gen/sql/pgsql/om_champs.inc.php";
-
-$selection .= " and concat(om_champs.table_name,'.',om_champs.table_name) not like om_champs.column_name ";
-
-// SELECT
-
-// FROM
-$table = DB_PREFIXE."om_champs
- LEFT JOIN ".DB_PREFIXE."om_tables
- ON om_champs.table_name=om_tables.table_name
- LEFT JOIN ".DB_PREFIXE."om_contraintes
- ON om_champs.column_name=concat(om_contraintes.table_name,'.',om_contraintes.column_name)
- left join ".DB_PREFIXE."om_forms
- on om_champs.column_name=om_forms.column_name";
-// SELECT
-$champAffiche = array(
- //"concat(om_champs.table_name,'.',om_champs.column_name) as \"".__("champs")."\"",
- 'om_champs.column_name as "'.__("champ").'"',
- 'om_champs.table_name as "'.__("table").'"',
- //'om_champs.table_schema as "'.__("schema").'"',
- 'om_champs.data_type as "'.__("type").'"',
- 'om_champs.character_maximum_length as "'.__("max").'"',
- 'om_contraintes.constraint_name as "'.__("clé secondaire").'"',
- "case om_champs.is_nullable when 'YES' then 'Non' else 'Oui' end as \"".__("obligatoire")."\"",
- 'om_champs.column_default as "'.__("défaut").'"',
- //'om_champs.is_nullable as "'.__("accepte null").'"',
- //"replace(replace(replace(replace(om_champs.comment,'\"','&nbsp'),'}',''),'{',''),',','<br>') as ".'"'.__("parametres").'"',
- //"om_champs.comment as comment",
- "parametres->>'libelle' as libelle",
- "parametres->>'type' as type",
- "parametres->>'bloc' as bloc",
- "parametres->>'position' as position",
- "parametres->>'calcul' as calcul",
- "parametres->>'liste' as liste",
-
- );
-

Added: openmairie_exemple/branches/om5_rad/sql/pgsql/om_vues.inc.php
===================================================================
--- openmairie_exemple/branches/om5_rad/sql/pgsql/om_vues.inc.php (rev 0)
+++ openmairie_exemple/branches/om5_rad/sql/pgsql/om_vues.inc.php 2024-04-25 13:43:36 UTC (rev 4940)
@@ -0,0 +1,6 @@
+<?php
+//$Id$
+//gen openMairie le 25/04/2024 13:51
+
+include "../gen/sql/pgsql/om_vues.inc.php";
+

Reply all
Reply to author
Forward
0 new messages