noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 57/119: Upgrade DB to 145


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 57/119: Upgrade DB to 145
Date: Mon, 26 Oct 2020 18:27:20 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 4474640ef42ca975f88a73255c82055595e41a5d
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Tue Oct 6 19:45:32 2020 +0200

    Upgrade DB to 145
---
 include/class/tag_group_mtable.class.php           |   4 +
 include/constant.php                               |   2 +-
 .../sql/patch/upgrade144.sql                       |  78 +++++++--------
 include/template/card_multiple_display_option.php  | 110 +++++++++++++++++++++
 sql/upgrade.sql                                    |   1 -
 5 files changed, 152 insertions(+), 43 deletions(-)

diff --git a/include/class/tag_group_mtable.class.php 
b/include/class/tag_group_mtable.class.php
index e225d62..b993501 100644
--- a/include/class/tag_group_mtable.class.php
+++ b/include/class/tag_group_mtable.class.php
@@ -64,6 +64,10 @@ class Tag_Group_MTable extends Manage_Table_SQL
         $aTag=$cn->get_array("select jt_id,t_tag 
                                from tags join jnt_tag_group_tag on 
(tag_id=t_id) 
                                where tag_group_id=$1 order by 2", 
[$data_sql->tg_id]);
+        // not possible to add tag to inexisting group
+        if ( $data_sql->tg_id == -1){
+            return;
+        }
         echo '<ol id="ol_tag_group">';
         $nb=count($aTag);
         $dossier_id=Dossier::id();
diff --git a/include/constant.php b/include/constant.php
index 966ef5d..c6c0d23 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -107,7 +107,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) {
 if ( ! defined ("SYSINFO_DISPLAY")) {
     define ("SYSINFO_DISPLAY",TRUE);
 }
-define ("DBVERSION",144);
+define ("DBVERSION",145);
 define ("MONO_DATABASE",25);
 define ("DBVERSIONREPO",18);
 define ('NOTFOUND','--not found--');
diff --git a/sql/upgrade.sql b/include/sql/patch/upgrade144.sql
similarity index 76%
copy from sql/upgrade.sql
copy to include/sql/patch/upgrade144.sql
index e664d79..700f2e4 100644
--- a/sql/upgrade.sql
+++ b/include/sql/patch/upgrade144.sql
@@ -1,7 +1,8 @@
+begin;
+
 
 CREATE OR REPLACE FUNCTION comptaproc.jrn_check_periode()
  RETURNS trigger
- LANGUAGE plpgsql
 AS $function$
 declare
 bClosed bool;
@@ -42,9 +43,10 @@ end if;
 
 return lreturn;
 end;
-$function$;
+$function$
 LANGUAGE plpgsql;
 
+
 -- New right for action : delete
 ALTER TABLE public.user_sec_action_profile drop CONSTRAINT 
user_sec_action_profile_ua_right_check;
 ALTER TABLE public.user_sec_action_profile ADD CONSTRAINT 
user_sec_action_profile_ua_right_check check (ua_right in ('R','W','X','O'));
@@ -56,35 +58,13 @@ ALTER TABLE public.user_sec_action_profile ADD CONSTRAINT 
user_sec_action_profil
 
 -- DROP TABLE public.document_option_ref;
 
-CREATE TABLE public.document_option_ref (
-       do_id bigserial NOT NULL,
-       do_code varchar(20) NOT NULL, -- Code of the option to add
-       document_type_id int8 NULL, -- FK to document_type
-       CONSTRAINT document_option_ref_pk PRIMARY KEY (do_id)
-);
-COMMENT ON TABLE public.document_option_ref IS 'Reference of option of 
document_type';
-
--- Column comments
-
-COMMENT ON COLUMN public.document_option_ref.do_code IS 'Code of the option to 
add';
-COMMENT ON COLUMN public.document_option_ref.document_type_id IS 'FK to 
document_type';
-
-
--- public.document_option_ref foreign keys
-
-ALTER TABLE public.document_option_ref ADD CONSTRAINT document_option_ref_fk 
FOREIGN KEY (document_type_id) REFERENCES document_type(dt_id) ON UPDATE 
CASCADE ON DELETE CASCADE;
-
-
--- Drop table
 
 CREATE TABLE public.contact_option_ref (
        cor_id bigserial NOT NULL,
        cor_label varchar NOT NULL, -- Label de l'option
        cor_type int4 NOT NULL DEFAULT 0, -- 0 text , 1 select ,2 nombre , 3 
date
-       cor_value_json json NULL, -- json object if cor_type is a select
-       document_option_id int8 NOT NULL, -- FK to document_option
-       CONSTRAINT contact_option_ref_pk PRIMARY KEY (cor_id),
-       CONSTRAINT contact_option_ref_fk FOREIGN KEY (document_option_id) 
REFERENCES document_option(do_id) ON UPDATE CASCADE ON DELETE CASCADE
+       cor_value_select varchar NULL, -- Select values
+       CONSTRAINT contact_option_ref_pk PRIMARY KEY (cor_id)
 );
 COMMENT ON TABLE public.contact_option_ref IS 'Option for the contact';
 
@@ -92,8 +72,7 @@ COMMENT ON TABLE public.contact_option_ref IS 'Option for the 
contact';
 
 COMMENT ON COLUMN public.contact_option_ref.cor_label IS 'Label de l''option';
 COMMENT ON COLUMN public.contact_option_ref.cor_type IS '0 text , 1 select ,2 
nombre , 3 date';
-COMMENT ON COLUMN public.contact_option_ref.cor_value_json IS 'json object if 
cor_type is a select';
-COMMENT ON COLUMN public.contact_option_ref.document_option_id IS 'FK to 
document_option';
+COMMENT ON COLUMN public.contact_option_ref.cor_value_select IS 'Select 
values';
 
 
 
@@ -105,12 +84,6 @@ me_menu='Document Suivi'
 where me_code='CFGCATDOC';
 
 
-ALTER TABLE public.document_option ADD do_activate int NOT NULL DEFAULT 1;
-COMMENT ON COLUMN public.document_option.do_activate IS '1 the option is 
activated, 0 is inativated';
-
-ALTER TABLE public.document_option ADD CONSTRAINT document_option_un UNIQUE 
(do_code,document_type_id);
-ALTER TABLE public.document_option RENAME COLUMN do_activate TO do_enable;
-
 -- ajoute un menu pour les options de contacts
 INSERT INTO public.menu_ref 
(me_code,me_menu,me_file,me_url,me_description,me_parameter,me_javascript,me_type,me_description_etendue)
 VALUES 
 ('CFGCONTACT','Contact','contact_option_ref.inc.php',NULL,'Configure les 
options pours les contacts multiples',NULL,NULL,'ME',NULL)
@@ -120,13 +93,6 @@ INSERT INTO public.profile_menu 
(me_code,me_code_dep,p_id,p_order,p_type_display
 ('CFGCONTACT','DIVPARM',1,85,'E',0,56)
 ;
 
--- contact option globale pour toutes les actions
-ALTER TABLE public.contact_option_ref DROP COLUMN document_option_id;
-
--- on utilise un varchar pour stocker les possibilités
-ALTER TABLE public.contact_option_ref DROP COLUMN cor_value_json;
-ALTER TABLE public.contact_option_ref ADD cor_value_select varchar NULL;
-COMMENT ON COLUMN public.contact_option_ref.cor_value_select IS 'Select 
values';
 
 
 CREATE TABLE public.tag_group (
@@ -190,3 +156,33 @@ COMMENT ON COLUMN 
public.action_person_option.action_person_id IS 'FK to action_
 
 ALTER TABLE public.action_person_option ADD CONSTRAINT action_person_option_fk 
FOREIGN KEY (action_person_id) REFERENCES action_person(ap_id) ON UPDATE 
CASCADE ON DELETE CASCADE;
 ALTER TABLE public.action_person_option ADD CONSTRAINT contact_option_ref_fk 
FOREIGN KEY (contact_option_ref_id) REFERENCES contact_option_ref(cor_id) ON 
UPDATE CASCADE ON DELETE CASCADE;
+
+-- public.document_option definition
+
+-- Drop table
+
+-- DROP TABLE public.document_option;
+
+CREATE TABLE public.document_option (
+       do_id bigserial NOT NULL,
+       do_code varchar(20) NOT NULL, -- Code of the option to add
+       document_type_id int8 NULL, -- FK to document_type
+       do_enable int4 NOT NULL DEFAULT 1, -- 1 the option is activated, 0 is 
inativated
+       CONSTRAINT document_option_ref_pk PRIMARY KEY (do_id),
+       CONSTRAINT document_option_un UNIQUE (do_code, document_type_id)
+);
+COMMENT ON TABLE public.document_option IS 'Reference of option addable to 
document_type';
+
+-- Column comments
+
+COMMENT ON COLUMN public.document_option.do_code IS 'Code of the option to 
add';
+COMMENT ON COLUMN public.document_option.document_type_id IS 'FK to 
document_type';
+COMMENT ON COLUMN public.document_option.do_enable IS '1 the option is 
activated, 0 is inativated';
+
+
+-- public.document_option foreign keys
+
+ALTER TABLE public.document_option ADD CONSTRAINT document_option_ref_fk 
FOREIGN KEY (document_type_id) REFERENCES document_type(dt_id) ON UPDATE 
CASCADE ON DELETE CASCADE;
+
+insert into version (val,v_description) values (145,'Improve tags , add 
multiple contacts with options');
+commit;
diff --git a/include/template/card_multiple_display_option.php 
b/include/template/card_multiple_display_option.php
new file mode 100644
index 0000000..2b07f9e
--- /dev/null
+++ b/include/template/card_multiple_display_option.php
@@ -0,0 +1,110 @@
+<?php
+/*
+ *   This file is part of NOALYSS.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
+
+if (!defined('ALLOWED'))
+    die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief Show the option of a contact, 
+ * parameters received 
+ *      - $fiche_id 
+ *      - $ag_id 
+ *      - $a_option array
+ *               - $a_option.cor_id
+ *               - $a_option.cor_label
+ *               - $a_option.cor_type
+ *               - $a_option.ap_id (-1 if option for this contact doesn't 
exist)
+ * @see Card_Multiple
+ */
+?>
+<form method="POST" onsubmit="save_linked_card_option(this);return false">
+    <input type="hidden" name="op" value="card">
+    <input type="hidden" name="op2" value="save_card_option">
+    <input type="hidden" name="ctl" value="notused">
+    <input type="hidden" name="ag_id" value="<?=$ag_id?>">
+    <input type="hidden" name="f_id" value="<?=$fiche_id?>">
+    <input type="hidden" name="action_person_id" 
value="<?=$p_action_person_id?>">
+    <?= Dossier::hidden() ?>
+    <?php
+    $nb_option=count($a_option);
+    for ($i=0; $i<$nb_option; $i++):
+        switch ($a_option[$i]['cor_type'])
+        {
+            case 0:
+                $input=new IText("ap_value[]");
+                break;
+            case 2:
+                $input=new IDate("ap_value[]");
+                break;
+            case 1:
+                $input=new INum("ap_value[]");
+                break;
+            case 3:
+                $input=new ISelect("ap_value[]");
+                $input->value=array();
+                // for select , we need to take the list
+                if (!empty($a_option[$i]['cor_value_select']))
+                {
+                    $a_select=explode("|", $a_option[$i]['cor_value_select']);
+                    if (is_array($a_select))
+                    {
+                        $nb=count($a_select);
+                        $array=[];
+                        for ($e=0; $e<$nb; $e++)
+                        {
+                            $a["label"]=$a_select[$e];
+                            $a["value"]=$a_select[$e];
+                            $array[$e]=$a;
+                        }
+                        $input->value=$array;
+                        $input->selected = $a_option[$i]['ap_value']  ;
+                    }
+                }
+                break;
+        }
+       $input->set_value ($a_option[$i]['ap_value']);
+        echo '<span style="display:table-row">';
+        echo '<span style="display:table-cell">';
+        echo $a_option[$i]['cor_label'];
+        echo HtmlInput::hidden("f_id",$fiche_id);
+        echo HtmlInput::hidden("ap_id[]",$a_option[$i]['ap_id']);
+        echo HtmlInput::hidden("cor_id[]",$a_option[$i]['cor_id']);
+        echo '</span>';
+        echo '<span style="display:table-cell">';
+        echo $input->input();
+        echo '</span>';
+        echo '</span>';
+        
+    endfor;
+    
+    ?>
+    <ul class="aligned-block">
+        <li>
+            <?=HtmlInput::button_close("d_linked_card_option")?>
+        </li>
+        <li>
+            <?=HtmlInput::submit("save",_("Sauver"))?>
+        </li>
+        
+    </ul>
+        
+        
+</form>
\ No newline at end of file
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index e664d79..daa9ad8 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -1,7 +1,6 @@
 
 CREATE OR REPLACE FUNCTION comptaproc.jrn_check_periode()
  RETURNS trigger
- LANGUAGE plpgsql
 AS $function$
 declare
 bClosed bool;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]