noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 23/32: New : Follow Up , the description mod


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 23/32: New : Follow Up , the description modifiable is using NicEdit
Date: Thu, 5 Jan 2023 14:18:31 -0500 (EST)

sparkyx pushed a commit to branch devel
in repository noalyss.

commit e932e56f2b8c9516c47c3bf88afa36f5f0dd2271
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Tue Dec 27 14:55:49 2022 +0100

    New  : Follow Up , the description modifiable is using NicEdit
---
 include/ajax/ajax_follow_up.php        |  19 ++++--
 include/class/follow_up.class.php      | 102 ++++++++++++++++++++++-----------
 include/lib/itextarea.class.php        |  18 ++----
 include/template/follow_up-display.php |  20 +++----
 4 files changed, 97 insertions(+), 62 deletions(-)

diff --git a/include/ajax/ajax_follow_up.php b/include/ajax/ajax_follow_up.php
index ccd11c5ba..7bce55c0f 100644
--- a/include/ajax/ajax_follow_up.php
+++ b/include/ajax/ajax_follow_up.php
@@ -28,6 +28,10 @@ if (!defined('ALLOWED'))
 $op=$http->request('op');
 global $g_user;
 
+/*
+ * Ajax for modifying the description , does not support ITextarea + enrich 
text
+ *
+ *
 if ($op=='update_comment_followUp')
 {
     $input=$http->request('input');
@@ -71,6 +75,8 @@ if ($op=='update_comment_followUp')
     }
     return;
 }
+*/
+
 // Modify followup 
 if ($op == 'followup_comment_oneedit') {
      $input=$http->request('input');
@@ -101,17 +107,18 @@ if ($op == 'followup_comment_oneedit') {
         case 'ok':
             if ($g_user->check_action(VIEWDOC)==1)
             {
-                $value=strip_tags($http->request('value'));
+                $value=$http->request('value');
                 if ($g_user->can_write_action($ag_id))
                 {
                     // retrieve the document
                     if ( $agc_id==-1) {
-                      $agc_id=  $cn->get_value("insert into 
action_gestion_comment(ag_id,agc_comment,tech_user)
-                                values ($1,$2,$3) returning agc_id" 
,[$ag_id,$value,$g_user->login]);
+                      $agc_id=  $cn->get_value("insert into 
action_gestion_comment(ag_id,agc_comment,agc_comment_raw,tech_user)
+                                values ($1,$2,$3,$4) returning agc_id" 
,[$ag_id,strip_tags($value),$value,$g_user->login]);
                     } else {
-                          $cn->exec_sql("update action_gestion_comment set 
agc_comment=$1,tech_user=$2
-                                where agc_id=$3
-                                " ,[$value,$g_user->login,$agc_id]);
+                          $cn->exec_sql("update action_gestion_comment set 
agc_comment=$1,tech_user=$2 ,
+                                  agc_comment_raw=$3
+                                where agc_id=$4
+                                " 
,[strip_tags($value),$g_user->login,$value,$agc_id]);
                     }
                     
                 }
diff --git a/include/class/follow_up.class.php 
b/include/class/follow_up.class.php
index 7fa5c4dee..dfacf4314 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -47,23 +47,46 @@ require_once NOALYSS_INCLUDE.'/lib/user_common.php';
 class Follow_Up
 {
 
-    var $db; /*!<  $db  database connexion    */
-    var $ag_timestamp;  /*!<   $ag_timestamp document date 
(ag_gestion.ag_timestamp) */
-    var $dt_id;   /*!<   $dt_id type of the document (document_type.dt_id) */
-    var $ag_state; /*!<   $ag_state stage of the document (printed, send to 
client...) */
-    var $d_number;   /*!<   $d_number number of the document */
-    var $d_filename; /*!<   $d_filename filename's document      */
-    var $d_mimetype; /*!<   $d_mimetype document's filename      */
-    var $ag_title;   /*!<   $ag_title title document         */
-    var $f_id; /*!<   $f_id_dest fiche id (From field )  */
-    var $ag_ref;  /*!< $ag_ref is the ref  */
-    var $ag_hour;  /*!< $ag_hour is the hour of the meeting, action */
-    var $ag_priority; /*!< $ag_priority is the priority 1 High, 2 medium, 3 
low */
-    var $ag_dest;  /*!< $ag_dest person who is in charged */
-    var $ag_contact;  /*!< $ag_contact contact */
-    var $ag_remind_date;  /*!< $ag_contact contact */
-    var $f_id_dest ; /*!< followup action recipient */
-    var $ag_description; /*!< description of the action with HTML tag*/
+    /*!<  $db  database connexion    */
+    var $db;
+    /*!<   $ag_timestamp document date (ag_gestion.ag_timestamp) */
+    var $ag_timestamp;
+    /*!<   $dt_id type of the document (document_type.dt_id) */
+    var $dt_id;
+    /*!<   $ag_state stage of the document (printed, send to client...) */
+    var $ag_state;
+    /*!<   $d_number number of the document */
+    var $d_number;
+    /*!<   $d_filename filename's document      */
+    var $d_filename;
+    /*!<   $d_mimetype document's filename      */
+    var $d_mimetype;
+    /*!<   $ag_title title document          */
+    var $ag_title;
+    /*!<   $f_id_dest fiche id (From field )  */
+    var $f_id;
+    /*!< $ag_ref is the ref  */
+    var $ag_ref;
+    /*!< $ag_hour is the hour of the meeting, action */
+    var $ag_hour;
+    /*!< $ag_priority is the priority 1 High, 2 medium, 3 low */
+    var $ag_priority;
+    /*!< $ag_dest person who is in charged */
+    var $ag_dest;
+    /*!< $ag_contact contact */
+    var $ag_contact;
+    /*!< $ag_contact contact */
+    var $ag_remind_date;
+    /*!< followup action recipient */
+    var $f_id_dest ;
+    /*!< description of the action with HTML tag*/
+    var $ag_description;
+
+    /**
+     * @var integer $ag_description_id if greater than 0 , it is the id in 
action_comment
+     * of the description (1st comment)
+     */
+    var $ag_description_id;
     /**
      * @brief $operation string related operation
      */
@@ -89,6 +112,7 @@ class Follow_Up
         $this->action="";
         $this->f_dest_id=0;
         $this->f_id_dest=0;
+        $this->ag_priority=2;
     }
 
     public function __toString(): string
@@ -268,7 +292,7 @@ class Follow_Up
         $title->name="ag_title";
         $title->value=$this->ag_title;
         $title->size=60;
-       $title->style='style="font-size:2rem;font-weight:bold"';
+           $title->style='style="font-size:2rem;font-weight:bold"';
 
 
         // Priority of the ag_priority
@@ -954,16 +978,27 @@ class Follow_Up
                 continue;
             $act->save();
         }
-        if (trim($this->ag_comment)!='')
+        if (trim(strip_tags($this->ag_comment)) !='')
         {
             $notag_comment=strip_tags($this->ag_comment);
             $this->db->exec_sql("insert into action_gestion_comment 
(ag_id,tech_user,agc_comment,agc_comment_raw) values ($1,$2,$3,$4)"
                     , array($this->ag_id, $_SESSION[SESSION_KEY.'g_user'], 
$notag_comment,$this->ag_comment));
         }
-        if (trim($this->ag_description)!='')
+        if (trim(strip_tags($this->ag_description))!='' )
         {
-            $this->db->exec_sql("insert into action_gestion_comment 
(ag_id,tech_user,agc_comment,agc_comment_raw) values ($1,$2,$3,$4)"
+            if (  $this->ag_description_id <0)
+                $this->db->exec_sql("insert into action_gestion_comment 
(ag_id,tech_user,agc_comment,agc_comment_raw) values ($1,$2,$3,$4)"
                     , array($this->ag_id, 
$_SESSION[SESSION_KEY.'g_user'],strip_tags($this->ag_description), 
$this->ag_description));
+            else
+                $this->db->exec_sql("
+                    update action_gestion_comment 
+                            set agc_comment = $1 , 
+                            agc_comment_raw = $2,
+                            tech_user= $3
+                                where agc_id = $4 "
+                    , array(strip_tags($this->ag_description), 
$this->ag_description, $_SESSION[SESSION_KEY.'g_user'],
+                        $this->ag_description_id));
+
         }
         $this->insert_operation();
         $this->insert_action();
@@ -1024,16 +1059,17 @@ class Follow_Up
         
$this->ag_dest=$http->extract("ag_dest","string",$g_user->get_profile());
         $this->ag_priority=$http->extract("ag_priority","string","2");
         $this->ag_contact=$http->extract("ag_contact","string","");
-       $ag_comment=trim($http->extract("ag_comment","raw",""));
-       if ( strip_tags($ag_comment) == '') 
-               $this->ag_comment='';
-       else 
-               $this->ag_comment=$ag_comment;
-        $ag_description=trim($http->extract("ag_description","raw",""));
-       if ( strip_tags($ag_description) == '') 
-               $this->ag_description='';
-       else 
-               $this->ag_description=$ag_description;
+       $ag_comment=trim($http->extract("ag_comment","raw",""));
+        if ( strip_tags($ag_comment) == '')
+            $this->ag_comment='';
+        else
+            $this->ag_comment=$ag_comment;
+            $ag_description=trim($http->extract("ag_description","raw",""));
+        if ( strip_tags($ag_description) == '')
+            $this->ag_description='';
+        else
+            $this->ag_description=$ag_description;
+        
$this->ag_description_id=$http->extract("ag_description_id","string",-1);
         $this->ag_remind_date=$http->extract("ag_remind_date","string",null);
         $this->operation=$http->extract("operation","string",null);
         $this->action=$http->extract("action","string",null);
@@ -1432,8 +1468,8 @@ class Follow_Up
 
     /**
      * @brief Show the result of a search in an inner windows, the result is 
limited to 25
-     * @param type $cn database connx
-     * @param type $p_sql the query
+     * @param Database $cn database connx
+     * @param string $p_sql where clause of the query
      */
     static function short_list($cn, $p_sql)
     {
diff --git a/include/lib/itextarea.class.php b/include/lib/itextarea.class.php
index 3d70aa61b..f604c5aef 100644
--- a/include/lib/itextarea.class.php
+++ b/include/lib/itextarea.class.php
@@ -65,18 +65,16 @@ class ITextarea extends HtmlInput
     */
     public function input($p_name=null,$p_value=null)
     {
-        if ( $this->enrichText == "plain" ) {
-            $this->name=($p_name==null)?$this->name:$p_name;
-            $this->value=($p_value==null)?$this->value:$p_value;
-            $this->id=($this->id=="")?$this->name:$this->id;
-
-            if ( $this->readOnly==true) return $this->display();
+        $this->name=($p_name==null)?$this->name:$p_name;
+        $this->value=($p_value==null)?$this->value:$p_value;
+        $this->id=($this->id=="")?$this->name:$this->id;
+        if ( $this->readOnly==true) return $this->display();
 
+        if ( $this->enrichText == "plain" ) {
             $r="";
             $r.='<TEXTAREA '.$this->style.'  name="'.$this->name.'" 
id="'.$this->id.'"';
             $r.='>';
             $r.=$this->value;
-
             $r.="</TEXTAREA>";
         } elseif ($this->enrichText=='enrich') {
             if ( empty($this->id)) $this->id=$this->name;
@@ -95,7 +93,6 @@ class ITextarea extends HtmlInput
             </script>
 EOF;
         }
-
         return $r;
     }
 
@@ -110,13 +107,10 @@ EOF;
             $r.=sprintf('<input type="hidden" name="%s" value="%s">',
                         $this->name,h($this->value));
             $r.='</p>';
-        } elseif ($this->enrichText=='enrich')  {
+        } elseif ($this->enrichText=='enrich' )  {
             $r=$this->value;
         }
         return $r;
 
     }
-    static public function test_me()
-    {
-    }
 }
diff --git a/include/template/follow_up-display.php 
b/include/template/follow_up-display.php
index 1db12fe9a..1dc1c595d 100644
--- a/include/template/follow_up-display.php
+++ b/include/template/follow_up-display.php
@@ -274,27 +274,23 @@ function small(p_id_textarea){
    $description->id="ag_description";
    $has_description = false;
     //---------------------------------- Description 
-------------------------------------------------------------------
+    // if there are comments then the first one is the description
     if ( count($acomment)> 0) {
             $has_description = true;
             $editable_description = 
Document_Option::is_enable_editable_description($this->dt_id);
+            // if editable and the description can be changed
             if ( $p_view != 'READ' && $editable_description == true){
                 echo h2(_("Description"));
                 $itDescription=new ITextarea("ag_description");
                 $itDescription->style='class="input_text field_follow_up" 
style="height:21rem;width:98%;margin-left:1em;"';
-
+                $itDescription->set_enrichText('enrich');
                 $ag_description_id= $acomment[0]['agc_id'];
-                $itDescription->value=$acomment[0]['agc_comment'];
+                $itDescription->value=$acomment[0]['agc_comment_raw'];
                 $itDescription->id="ag_description";
+                echo 
\HtmlInput::hidden("ag_description_id",$acomment[0]['agc_id']);
+
+                echo $itDescription->input();
 
-                // One editable comment is available
-                $editable_description=new Inplace_Edit($itDescription);
-                $editable_description->add_json_param("op", 
"followup_comment_oneedit");
-                $editable_description->add_json_param("agc_id", 
$ag_description_id);
-                $editable_description->add_json_param("ag_id", $ag_id);
-                $editable_description->add_json_param("gDossier", 
Dossier::id());
-                $editable_description->set_callback("ajax_misc.php");
-
-                echo $editable_description->input();
             }
             elseif ($p_view == 'READ' || $editable_description == false)
             {
@@ -305,6 +301,7 @@ function small(p_id_textarea){
                 echo '</pre>';
             }
     } else {
+        // there is no comments so there is no description, just input one
           echo h2(_("Description"));
           $description->set_enrichText('enrich');
           $description->style='style="height:250px;width:90%;"';
@@ -322,6 +319,7 @@ function small(p_id_textarea){
         if (count($acomment) > 1 )  {
             echo h2(_("Commentaire"));
             $comment=new ITextarea("ag_comment_edit");
+            $comment->set_enrichText("plain");
             $comment->style='class="input_text field_follow_up" 
style="height:21rem;width:98%;margin-left:5%;"';
 
             $ag_comment_id= (count($acomment) > 1)?$acomment[1]['agc_id']:-1;



reply via email to

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