noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 87/119: Document Type : CFGACTION cannot add


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 87/119: Document Type : CFGACTION cannot add new document, fix order in dialog box, Fix= cannot delete action cause cascade on action_person
Date: Mon, 26 Oct 2020 18:27:31 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit ed50fc802d59c74df8b9d1e61378bb228b405f23
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Mon Oct 12 12:59:22 2020 +0200

    Document Type : CFGACTION cannot add new document, fix order in dialog 
box,Fix= cannot delete action cause cascade on action_person
---
 include/ajax/ajax_cfgaction.php                    |  4 +-
 .../class/action_document_type_mtable.class.php    | 70 ++++++++++++++--------
 sql/upgrade.sql                                    |  2 +
 3 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/include/ajax/ajax_cfgaction.php b/include/ajax/ajax_cfgaction.php
index 6562531..8d2312e 100644
--- a/include/ajax/ajax_cfgaction.php
+++ b/include/ajax/ajax_cfgaction.php
@@ -63,13 +63,15 @@ $action_document_type->set_object_name($ctl_id);
 
 if ($action=="input")
 {
-   
+   $action_document_type->set_order(["dt_id", "dt_value","dt_prefix"]);
+
     header('Content-type: text/xml; charset=UTF-8');
     echo $action_document_type->ajax_input()->saveXML();
     return;
 }
 elseif ($action=="save")
 {
+    $action_document_type->set_order(["dt_id", "dt_value","dt_prefix"]);
     $xml=$action_document_type->ajax_save();
     header('Content-type: text/xml; charset=UTF-8');
     echo $xml->saveXML();
diff --git a/include/class/action_document_type_mtable.class.php 
b/include/class/action_document_type_mtable.class.php
index f02f56d..a48b98a 100644
--- a/include/class/action_document_type_mtable.class.php
+++ b/include/class/action_document_type_mtable.class.php
@@ -162,35 +162,55 @@ class Action_Document_Type_MTable extends Manage_Table_SQL
     function input()
     {
         parent::input();
-        
-        
-        
+
+
+
         // Detail option contact
         $table=$this->get_table();
         $cn=$table->cn;
-        // insert new contact options
-        $cn->exec_sql("insert into   jnt_document_option_contact 
(jdoc_enable,document_type_id,
-                                contact_option_ref_id) 
-                         select 0 , $1, cor_id 
-                         from contact_option_ref 
-                        where
-                        cor_id not in (select cor_id from 
-                                        jnt_document_option_contact a 
-                                        where 
a.document_type_id=$1)",[$table->dt_id]);
-        
-        // Select all
-        
-        $aOption=$cn->get_array("select 
cor_id,cor_label,cor_type,document_type_id ,coalesce(jdoc_enable,0) jdoc_enable
-                from 
-                contact_option_ref cor  
-                left join jnt_document_option_contact jdoc on 
(cor_id=contact_option_ref_id) 
-                where 
-                document_type_id is null
-                or document_type_id = $1
-                order by cor_label",[$this->table->dt_id]);
+        try
+        {
+            $cn->start();
+            if ( $table->dt_id == -1 ){
+                $aOption=$cn->get_array("select cor_id,cor_label,cor_type,-1 
document_type_id,0 jdoc_enable
+                    from 
+                    contact_option_ref cor  
+                    order by cor_label");
+                
+            } else {
+                // insert new contact options
+                $cn->exec_sql("insert into   jnt_document_option_contact 
(jdoc_enable,document_type_id,
+                                    contact_option_ref_id) 
+                             select 0 , $1, cor_id 
+                             from contact_option_ref 
+                            where
+                            cor_id not in (select cor_id from 
+                                            jnt_document_option_contact a 
+                                            where a.document_type_id=$1)", 
[$table->dt_id]);
+
+                // Select all
+                $aOption=$cn->get_array("select 
cor_id,cor_label,cor_type,document_type_id ,coalesce(jdoc_enable,0) jdoc_enable
+                    from 
+                    contact_option_ref cor  
+                    left join jnt_document_option_contact jdoc on 
(cor_id=contact_option_ref_id) 
+                    where 
+                    document_type_id is null
+                    or document_type_id = $1
+                    order by cor_label", [$this->table->dt_id]);
+            }
+
+            // Detail option
+            require NOALYSS_TEMPLATE."/action_document_type_mtable_input.php";
+            $cn->commit();
+        }
+        catch (Exception $exc)
+        {
+            $cn->rollback();
+                    
+            echo $exc->getMessage();
+            error_log($exc->getTraceAsString());
+        }
         
-        // Detail option
-        require NOALYSS_TEMPLATE."/action_document_type_mtable_input.php";
     }
 
     /**
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index e69de29..847dce7 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -0,0 +1,2 @@
+ALTER TABLE public.action_person drop CONSTRAINT action_gestion_ag_id_fk2 ;
+ALTER TABLE public.action_person ADD CONSTRAINT action_gestion_ag_id_fk2 
FOREIGN KEY (ag_id) REFERENCES action_gestion(ag_id) on delete cascade on 
update cascade;



reply via email to

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