noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 107/119: Follow-Up : comment optional


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 107/119: Follow-Up : comment optional
Date: Mon, 26 Oct 2020 18:27:39 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 1f037f640ed4167cd40d69d80abfcd9d15d56016
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Wed Oct 14 16:39:45 2020 +0200

    Follow-Up : comment optional
---
 include/action.common.inc.php                      |  6 ++---
 .../class/action_document_type_mtable.class.php    |  6 +++++
 include/class/document_option.class.php            | 31 ++++++++++++++++++++++
 include/class/follow_up.class.php                  |  3 ++-
 include/constant.php                               |  2 +-
 include/sql/patch/upgrade148.sql                   |  6 +++++
 .../template/action_document_type_mtable_input.php |  8 ++++++
 include/template/detail-action.php                 |  6 +++--
 8 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/include/action.common.inc.php b/include/action.common.inc.php
index cd75424..ad64808 100644
--- a/include/action.common.inc.php
+++ b/include/action.common.inc.php
@@ -193,10 +193,9 @@ if ($sub_action == "update")
                 }
                 $act->f_id_dest=$act->qcode_dest;
                 $act->save();
-               echo '<div class="content">';
 
                // Add hidden tag
-               echo '<form  enctype="multipart/form-data" action="do.php" 
method="post"">';
+               echo '<form  enctype="multipart/form-data" 
style="display:inline" action="do.php" method="post"">';
 
                
                
@@ -207,7 +206,6 @@ if ($sub_action == "update")
                echo '<input type="submit" class="button" 
name="save_action_st2" value="' . _('Enregistrer') . '">';
                echo $supl_hidden;
                echo '</form>';
-               echo '</div>';
                 return;
        }
 }
@@ -228,7 +226,7 @@ if ($sub_action == 'detail')
        if ($g_user->can_write_action($ag_id)  == true)
        {
             
-            echo '<form  enctype="multipart/form-data"  id="action_common_frm" 
class="print" action="do.php"  method="post"   >';
+            echo '<form  enctype="multipart/form-data"  id="action_common_frm" 
class="print" action="do.php"  method="post"    style="display:inline">';
             echo $supl_hidden;
             echo HtmlInput::hidden('ac', $http->request('ac'));
             echo dossier::hidden();
diff --git a/include/class/action_document_type_mtable.class.php 
b/include/class/action_document_type_mtable.class.php
index 64c8c57..d0d3640 100644
--- a/include/class/action_document_type_mtable.class.php
+++ b/include/class/action_document_type_mtable.class.php
@@ -79,6 +79,7 @@ class Action_Document_Type_MTable extends Manage_Table_SQL
         $this->other['detail_operation']=$http->request("detail_operation", 
"string", 0);
         $this->other['contact_multiple']=$http->request("det_contact_mul", 
"string", 0);
         $this->other['make_invoice']=$http->request("make_invoice", "string", 
0);
+        $this->other['followup_comment']=$http->request("followup_comment", 
"string", 0);
         $this->other['seq']=$http->request("seq", "string", 0);
         
$this->other['select_option_operation']=$http->request("select_option_operation",
 "string", null);
         $this->other["cor_id"]=$http->request("cor_id","array",[]);
@@ -258,6 +259,10 @@ class Action_Document_Type_MTable extends Manage_Table_SQL
         $cn->exec_sql("insert into document_option 
(do_code,document_type_id,do_enable) values ($1,$2,$3) 
             on conflict on constraint document_option_un
             do update set do_enable=$3 ", ["make_invoice", $object_sql->dt_id, 
$this->other['make_invoice']]);
+        // Option for comments
+            $cn->exec_sql("insert into document_option 
(do_code,document_type_id,do_enable) values ($1,$2,$3) 
+                on conflict on constraint document_option_un
+                do update set do_enable=$3 ", ["followup_comment", 
$object_sql->dt_id, $this->other['followup_comment']]);
         
         // Option contact to save
         $cn->exec_sql("delete from jnt_document_option_contact where 
document_type_id=$1",[$object_sql->dt_id]);
@@ -272,6 +277,7 @@ class Action_Document_Type_MTable extends Manage_Table_SQL
             } 
         }
         
+        
     }
 
 }
diff --git a/include/class/document_option.class.php 
b/include/class/document_option.class.php
index cc55533..4fd974c 100644
--- a/include/class/document_option.class.php
+++ b/include/class/document_option.class.php
@@ -49,6 +49,23 @@ class Document_Option
         return $display_operation;
     }
     /**
+     * returns true if comment are available otherwise false
+     * 
+     * @param int $p_document_type Document_Type.dt_id
+     * @return boolean
+     */
+    static function is_enable_comment($p_document_type)
+    {
+        $display_operation=false;
+        $cn=Dossier::connect();
+        if ($cn->get_value("select do_enable from document_option where 
document_type_id=$1 and do_code = $2",
+                        [$p_document_type, 'followup_comment'])=='1')
+        {
+            $display_operation=true;
+        }
+        return $display_operation;
+    }
+    /**
      * returns option from  the operation_detail 
      * 
      * @param int $p_document_type Document_Type.dt_id
@@ -98,5 +115,19 @@ class Document_Option
         }
         return $return;
     }
+    /**
+     * Returns true if we can add a comment , or false if it is not possible
+     * @param integer $p_id is the action_gestion.ag_id
+     */
+    static  function can_add_comment($p_id) {
+        $cn=Dossier::connect();
+        $document_type=$cn->get_value("select ag_type from action_gestion 
where ag_id=$1",[$p_id]);
+        if (Document_Option::is_enable_comment($document_type)) return true;
+        // If comment are disable, only the first one is authorized as event 
description
+        $cnt=$cn->get_value("select count(*) from action_gestion_comment where 
ag_id=$1",[$p_id]);
+        if ($cnt == 0 ) return true;
+        return false;
+        
+    }
 
 }
diff --git a/include/class/follow_up.class.php 
b/include/class/follow_up.class.php
index dfc1ec8..52aeecb 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -38,6 +38,7 @@ require_once NOALYSS_INCLUDE.'/lib/inum.class.php';
 require_once NOALYSS_INCLUDE.'/lib/sort_table.class.php';
 require_once NOALYSS_INCLUDE.'/lib/irelated_action.class.php';
 require_once NOALYSS_INCLUDE.'/class/tag.class.php';
+require_once NOALYSS_INCLUDE.'/class/document_option.class.php';
 require_once NOALYSS_INCLUDE.'/class/default_menu.class.php';
 require_once NOALYSS_INCLUDE.'/lib/inplace_edit.class.php';
 require_once NOALYSS_INCLUDE.'/lib/noalyss_csv.class.php';
@@ -592,7 +593,7 @@ class Follow_Up
         /* Upload the documents */
         $doc=new Document($this->db);
         $doc->Upload($this->ag_id);
-        if (trim($this->ag_comment)!='')
+        if (trim($this->ag_comment)!='' && 
Document_Option::can_add_comment($this->ag_id))
         {
             $this->db->exec_sql("insert into action_gestion_comment 
(ag_id,tech_user,agc_comment) values ($1,$2,$3)"
                     , array($this->ag_id, $_SESSION['g_user'], 
$this->ag_comment));
diff --git a/include/constant.php b/include/constant.php
index 07b2dce..fe77c4d 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",148);
+define ("DBVERSION",149);
 define ("MONO_DATABASE",25);
 define ("DBVERSIONREPO",18);
 define ('NOTFOUND','--not found--');
diff --git a/include/sql/patch/upgrade148.sql b/include/sql/patch/upgrade148.sql
new file mode 100644
index 0000000..76477c1
--- /dev/null
+++ b/include/sql/patch/upgrade148.sql
@@ -0,0 +1,6 @@
+begin;
+INSERT INTO public.document_option (do_code, document_type_id, do_enable, 
do_option) select 'followup_comment', dt_id, 1, NULL
+from document_type ;
+
+insert into version (val,v_description) values (149,'Default values for 
document_option,comment on followup');
+commit;
diff --git a/include/template/action_document_type_mtable_input.php 
b/include/template/action_document_type_mtable_input.php
index 784a4f0..a02401f 100644
--- a/include/template/action_document_type_mtable_input.php
+++ b/include/template/action_document_type_mtable_input.php
@@ -94,6 +94,14 @@ echo $i->input();
 echo _("Création de facture");
 ?>
         </li> 
+        <li>
+<?php
+$i=new ICheckBox("followup_comment",1);
+if ( Document_Option::is_enable_comment($table->dt_id)) $i->set_check(1); else 
$i->set_check(0);
+echo $i->input();
+echo _("Commentaire");
+?>
+        </li> 
     </ul>
 
 </div>
diff --git a/include/template/detail-action.php 
b/include/template/detail-action.php
index 0516e5f..f43d321 100644
--- a/include/template/detail-action.php
+++ b/include/template/detail-action.php
@@ -276,10 +276,12 @@ for( $c=0;$c<count($acomment);$c++){
         echo $comment;
 }
 echo '<span class="noprint">';
-echo $desc->input();
+if (  Document_Option::can_add_comment($ag_id) ) {
+    echo $desc->input();
+}
 echo '</span>';
 ?>
-<?php if ($p_view != "READ" ): ?>
+<?php if ($p_view != "READ" && Document_Option::can_add_comment($ag_id)): ?>
 <p class="noprint">
 <input type="button" id="bt_enlarge" <?php echo $style_enl?> value="+" 
onclick="enlarge('ag_comment');return false;">
 <input type="button" id="bt_small"  <?php echo $style_small?> value="-" 
style="display:none" onclick="small('ag_comment');return false;">



reply via email to

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