noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 33/34: Task #2323 : follow-up correct dependi


From: dwm
Subject: [Noalyss-commit] [noalyss] 33/34: Task #2323 : follow-up correct depending action + cosmetic
Date: Wed, 17 Jan 2024 12:54:09 -0500 (EST)

sparkyx pushed a commit to branch devel
in repository noalyss.

commit 8bc3ce7710b65c932a9ff0d48948fdea0febb889
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Tue Jan 16 14:29:01 2024 +0100

    Task #2323 : follow-up correct depending action + cosmetic
---
 html/css/style-classic7.css                   |  14 +++
 include/class/follow_up.class.php             | 159 +++++++++++++-------------
 include/template/follow_up-display.php        |  57 +++++----
 include/template/followup-show-action-add.php |   8 +-
 sql/upgrade.sql                               |  27 +++++
 5 files changed, 164 insertions(+), 101 deletions(-)

diff --git a/html/css/style-classic7.css b/html/css/style-classic7.css
index fac6a4ea1..01ef67236 100644
--- a/html/css/style-classic7.css
+++ b/html/css/style-classic7.css
@@ -3396,4 +3396,18 @@ li.li-active {
      background-color: rgba(246, 180, 157, 0.58);
      color:red;
 
+ }
+ /** followup : detail : list of concerned actions **/
+ div.concerned_action {
+         height: 11rem;
+         overflow: auto;
+     background-color: white;
+     border:navy 1px solid;
+     width: 100%;
+     scroll-padding-right: 20px;
+ }
+ div.FullDetailActionChildren {
+     z-index: 12;
+     position: absolute;
+     height: auto;
  }
\ No newline at end of file
diff --git a/include/class/follow_up.class.php 
b/include/class/follow_up.class.php
index ae9308982..e03750c6d 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -616,12 +616,12 @@ class Follow_Up
         /* upload the documents */
         $doc=new Document($this->db);
         $doc->upload($this->ag_id);
-        if (trim($this->ag_comment??"")!='' && 
Document_Option::can_add_comment($this->ag_id))
+        if (noalyss_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,agc_comment_raw) values ($1,$2,$3,$4)"
                 , array($this->ag_id, $_SESSION[SESSION_KEY.'g_user'], 
strip_tags($this->ag_description),$this->ag_comment));
         }
-        if (trim($this->ag_description)!='' && 
Document_Option::can_add_comment($this->ag_id))
+        if (noalyss_trim($this->ag_description)!='' && 
Document_Option::can_add_comment($this->ag_id))
         {
             $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));
@@ -1918,7 +1918,7 @@ where
         }
     }
     /**
-     * Return the first parent of the event tree, or -1 if not found. The 
parent is an action with a lower id, 
+     * @brief Return the first parent of the event tree, or -1 if not found. 
The parent is an action with a lower id,
      * so it can happen than an action has several ones
      * @return arrary of integer (ag_id)
      */
@@ -1977,7 +1977,7 @@ where
           from 
             action_gestion join t on (ag_id=aga_greatest)
             join document_type on (ag_type=dt_id)
-            
+             order by key_path
 ";
          $ret_array=$this->db->get_array($sql,array($p_id));
          // Empty returns
@@ -1996,82 +1996,80 @@ where
         /*
          * First we retrieve the parent
          */
-        $parent=$this->get_parent();
+        $parent_id=$this->db->get_value("select min( get_follow_up_tree) from 
comptaproc.get_follow_up_tree($1)",[$this->ag_id]);
         $http=new HttpInput();
         $base=HtmlInput::request_to_string(array("gDossier", "ac",  "sb", "sc",
                     "f_id"))."&amp;sa=detail";
-        if ($parent==-1)
+        $parent=array();
+        if (empty($parent_id))
         {
             echo _('Principal');
-            $parent=array();
-            $parent [0]['aga_least']= $this->ag_id;
+            $parent_id= $this->ag_id;
         }
-       
-        $nb_parent=count($parent);
-        for ($i=0;$i< $nb_parent;$i++)
+
+
+        $fu_parent=new Follow_Up($this->db, $parent_id);
+        $fu_parent->get();
+        echo'<span class="highlight">';
+        $xaction=sprintf('view_action(%d,%d,%d)', $fu_parent->ag_id,
+                    Dossier::id(), 1);
+        $showAction='<a class="line" href="javascript:'.$xaction.'">';
+        echo $showAction.
+            $fu_parent->ag_timestamp," ",
+            h($fu_parent->ag_title),
+            '('.h($fu_parent->ag_ref).')',
+                '</a>';
+
+        echo "</span>";
+        echo '<ul style="padding-left:10px;list-style-type: none;">';
+
+        $action=$this->get_children($parent_id);
+        for ($o=0; $o<count($action); $o++)
         {
-            $fu_parent=new Follow_Up($this->db, $parent[$i]['aga_least']);
-            $fu_parent->get();
-            echo'<span class="highlight">';
-            $xaction=sprintf('view_action(%d,%d,%d)', $fu_parent->ag_id,
+            $class=($this->ag_id == $action[$o]['aga_greatest'])?' 
class="highlight" ':'';
+
+            // Count the number of direct parents
+            $count_parent =$this->db->get_value('select count(*) from 
action_gestion_related where aga_greatest = 
$1',array($action[$o]['aga_greatest']));
+            $direct_parent=($count_parent > 1 ) ? _('direct parent 
').$count_parent:"";
+
+            $margin=($action[$o]['depth']>1 
)?str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",$action[$o]['depth']-1)."&#8680;":"";
+            if ($p_view!='READ'&&$p_base!='ajax')
+            {
+                $rmAction=sprintf("return confirm_box(null,'"._('Voulez-vous 
effacer cette action ')."', function () {remove_action('%s','%s','%s');});",
+                        dossier::id(), $action[$o]['aga_greatest'],
+                        $http->request('ag_id',"number"));
+                $showAction='<a class="line" 
href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
+                $js=Icon_Action::trash("acact".$action[$o]['aga_greatest'], 
$rmAction);
+                echo '<li '.$class.' 
id="act'.$action[$o]['aga_greatest'].'">'.$margin.$showAction.$action[$o]['str_date'].
+                
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
 "
+                .$js.'</li>';
+            }
+            else
+            /*
+             * Display detail requested from Ajax Div
+             */
+            if ($p_base=='ajax')
+            {
+                $xaction=sprintf('view_action(%d,%d,%d)', 
$action[$o]['aga_greatest'],
                         Dossier::id(), 1);
-            $showAction='<a class="line" href="javascript:'.$xaction.'">';
-            echo $showAction.
-                $fu_parent->ag_timestamp," ",
-                h($fu_parent->ag_title),
-                '('.h($fu_parent->ag_ref).')',
-                    '</a>';
-
-            echo "</span>";
-            echo '<ul style="padding-left:10px;list-style-type: none;">';
-
-            $action=$this->get_children($parent[$i]['aga_least']);
-            for ($o=0; $o<count($action); $o++)
+                $showAction='<a class="line" href="javascript:'.$xaction.'">';
+                echo '<li  '.$class.' 
>'.$margin.$showAction.$action[$o]['str_date']." ".
+                
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
 "
+                .'</li>';
+            }
+            /*
+             * READ ONLY
+             */
+            else
             {
-                $class=($this->ag_id == $action[$o]['aga_greatest'])?' 
class="highlight" ':'';
-
-                // Count the number of direct parents
-                $count_parent =$this->db->get_value('select count(*) from 
action_gestion_related where aga_greatest = 
$1',array($action[$o]['aga_greatest']));
-                $direct_parent=($count_parent > 1 ) ? _('direct parent 
').$count_parent:"";
-
-                $margin=($action[$o]['depth']>1 
)?str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;",$action[$o]['depth']-1)."&#8680;":"";
-                if ($p_view!='READ'&&$p_base!='ajax')
-                {
-                    $rmAction=sprintf("return 
confirm_box(null,'"._('Voulez-vous effacer cette action ')."', function () 
{remove_action('%s','%s','%s');});",
-                            dossier::id(), $action[$o]['aga_greatest'],
-                            $http->request('ag_id',"number"));
-                    $showAction='<a class="line" 
href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
-                    
$js=Icon_Action::trash("acact".$action[$o]['aga_greatest'], $rmAction);
-                    echo '<li '.$class.' 
id="act'.$action[$o]['aga_greatest'].'">'.$margin.$showAction.$action[$o]['str_date'].
-                    
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
 "
-                    .$js.'</li>';
-                }
-                else
-                /*
-                 * Display detail requested from Ajax Div
-                 */
-                if ($p_base=='ajax')
-                {
-                    $xaction=sprintf('view_action(%d,%d,%d)', 
$action[$o]['aga_greatest'],
-                            Dossier::id(), 1);
-                    $showAction='<a class="line" 
href="javascript:'.$xaction.'">';
-                    echo '<li  '.$class.' 
>'.$margin.$showAction.$action[$o]['str_date']." ".
-                    
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
 "
-                    .'</li>';
-                }
-                /*
-                 * READ ONLY
-                 */
-                else
-                {
-                    $showAction='<a class="line" 
href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
-                    echo '<li  '.$class.' 
>'.$margin.$showAction.$action[$o]['str_date']." ".
-                    
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
 "
-                    .'</li>';
-                }
+                $showAction='<a class="line" 
href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
+                echo '<li  '.$class.' 
>'.$margin.$showAction.$action[$o]['str_date']." ".
+                
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
 "
+                .'</li>';
             }
-            echo '</ul>';
         }
+        echo '</ul>';
+
     }
     /**
      * @brief Display the list of parent of the current Follow_Up
@@ -2084,18 +2082,23 @@ where
     {
         $a_parent=$this->db->get_array(
                 "
-                 select ag_id,ag_title as title 
,to_char(ag_timestamp,'DD/MM/YY') as str_date,ag_ref||' '||dt_value as 
action_ref
-                 from 
-                action_gestion 
-                join document_type on (ag_type=dt_id)
-                where ag_id in (select aga_least from action_gestion_related 
where aga_greatest = $1)
-                order by ag_id
+ select ag1.ag_id
+      ,ag1.ag_title as title 
+      ,to_char(ag1.ag_timestamp,'DD/MM/YY') as str_date
+      ,ag1.ag_ref||' '||dt_value as action_ref
+ from 
+    action_gestion ag1
+    join document_type on (ag_type=dt_id)
+    join (select distinct get_follow_up_tree from 
comptaproc.get_follow_up_tree($1)) tree_ag 
+            on (tree_ag.get_follow_up_tree=ag1.ag_id)
+order by ag_id
                 ", array($this->ag_id)
                 );
         if ( empty($a_parent ) ) return;
         echo '<ul style="padding-left:10px;list-style-type: none;">';
         $base=HtmlInput::request_to_string(array("gDossier", "ac", "sa", "sb", 
"sc",
                     "f_id"));
+        $http=new HttpInput();
         for ($o=0; $o<count($a_parent); $o++)
         {
             $class=($this->ag_id == $a_parent[$o]['ag_id'])?' 
class="highlight" ':'';
@@ -2104,9 +2107,11 @@ where
             {
                 $rmAction=sprintf("return confirm_box(null,'"._('Voulez-vous 
effacer cette action ')."', function () {remove_action('%s','%s','%s');});",
                         dossier::id(), $a_parent[$o]['ag_id'],
-                        $_REQUEST['ag_id']);
+                        $http->request('ag_id',"number"));
                 $showAction='<a class="line" 
href="'.$base."&ag_id=".$a_parent[$o]['ag_id'].'">';
-                $js='<a class="tinybutton" 
id="acact'.$a_parent[$o]['ag_id'].'" href="javascript:void(0)" 
onclick="'.$rmAction.'">'.SMALLX.'</a>';
+
+                
$js=\Icon_Action::trash('acact'.$a_parent[$o]['ag_id'],$rmAction);
+                
                 echo '<li '.$class.' 
id="act'.$a_parent[$o]['ag_id'].'">'.$showAction.$a_parent[$o]['str_date'].
                 
h($a_parent[$o]['title']).'('.h($a_parent[$o]['action_ref']).')'.'</a>'." "
                 .$js.'</li>';
diff --git a/include/template/follow_up-display.php 
b/include/template/follow_up-display.php
index 807dbc2ed..5d098abca 100644
--- a/include/template/follow_up-display.php
+++ b/include/template/follow_up-display.php
@@ -3,13 +3,14 @@
 //This file is part of NOALYSS and is under GPL 
 //see licence.txt
 $uniq=uniqid("tab",TRUE);
-?><div>
+?>
+<div>
     <?php
     \Noalyss\Dbg::echo_file(__FILE__);
     ?>
-<div style="float:left;">
-
+<div class="row">
 
+<div class="col">
     <table>
         <tr class="highlight">
             <TD>
@@ -110,9 +111,10 @@ if ($this->ag_id > 0 && 
Document_Option::is_enable_contact_multiple($this->dt_id
           <?php endif; ?>
         </table>
  <?php if ($p_view != 'READ') echo $str_add_button;?>
-
 </div>
-<div style="float:left">
+
+
+<div class="col">
         <table>
 
          
@@ -186,16 +188,19 @@ if ($this->ag_id > 0 && 
Document_Option::is_enable_contact_multiple($this->dt_id
         </table>
 
 </div>
-<div id="choice_other_info_div" style="float:left;">
+
+<div id="choice_other_info_div" class="col-12 col-lg-6">
+    <div class="row">
+
     <ul class="tabs noprint" >
         <li id="related_action_tab<?php echo $uniq?>" 
class="tabs_selected"><?php echo _("Actions concernées")?></li>
         <li id="related_operation_tab<?php echo $uniq?>" class="tabs"><?php 
echo _('Opérations concernées')?></li>
         <li id="dependant_action_tab<?php echo $uniq?>" class="tabs"><?php 
echo _('Dépendant')?></li>
     </ul>
-    
-    <div style="clear:both"></div>
-       <div id="related_operation_div<?php echo $uniq?>" style="display:none" 
class="print">
-
+    </div>
+    <div class="row">
+       <div id="related_operation_div<?php echo $uniq?>" style="display:none;" 
class="print concerned_action">
+        <?php if ($p_view != 'READ')   echo '<span 
class="noprint">'.$iconcerned->input().'</span>';?>
                <ol>
 
                <?php
@@ -218,27 +223,35 @@ if ($this->ag_id > 0 && 
Document_Option::is_enable_contact_multiple($this->dt_id
 
                ?>
                </ol>
-               <?php if ($p_view != 'READ')   echo '<span 
class="noprint">'.$iconcerned->input().'</span>';?>
-       </div>
 
-        <div id="related_action_div<?php echo $uniq?>" class="print">
-               
-               
+       </div>
+        <div id="related_action_div<?php echo $uniq?>" class="print 
concerned_action"  style="width: 95%" >
+            <div class="" style="display:block">
+                <div>
 
-               <?php
-               $this->display_children($p_view,$p_base);
+                <?php if ( $p_view != 'READ') echo $iaction->input();?>
+                
<?=\Icon_Action::detail('SmallDetailActionChildren'.$uniq.'_bt', 
"$('related_action_div{$uniq}').addClassName('FullDetailActionChildren');$('FullDetailActionChildren{$uniq}_bt').show();$('SmallDetailActionChildren{$uniq}_bt').hide()")?>
+                <?php
+                echo 
\Icon_Action::hide_icon("FullDetailActionChildren{$uniq}_bt"
+                    , 
"$('related_action_div{$uniq}').removeClassName('FullDetailActionChildren');$('FullDetailActionChildren{$uniq}_bt').hide();$('SmallDetailActionChildren{$uniq}_bt').show()");?>
+                </div>
+                <?php
+                $this->display_children($p_view,$p_base);
 
-               ?>
-               
-               <?php if ( $p_view != 'READ') echo '<span 
class="noprint">'.$iaction->input().'</span>';?>
+                ?>
+                
<script>$('FullDetailActionChildren<?=$uniq?>_bt').hide()</script>
+            </div>
        </div>
-        <div id="dependant_action_div<?php echo $uniq?>" style="display:none" 
class="print">
+        <div id="dependant_action_div<?php echo $uniq?>" style="display:none" 
class="print concerned_action">
         <?php
+        //@todo a enlever obsolete
             $this->display_parent($p_view,$p_base);
         ?>
         </div>
+    </div>
 </div>
 
+</div>
 </div>
 <div style="clear: both"></div>
 <div id="div_action_description">
@@ -256,7 +269,7 @@ function small(p_id_textarea){
 
    }
 </script>
-    <p style="margin-left:10px;">
+    <p style="margin-left:5%;">
     <?php echo $title->input();
     ?>
 </p>
diff --git a/include/template/followup-show-action-add.php 
b/include/template/followup-show-action-add.php
index 2f749ff10..2983cc60f 100644
--- a/include/template/followup-show-action-add.php
+++ b/include/template/followup-show-action-add.php
@@ -21,6 +21,8 @@
 
 if (!defined('ALLOWED'))
     die('Appel direct ne sont pas permis');
+
+\Noalyss\Dbg::echo_file(__FILE__);
 $sup_parameter=HtmlInput::array_to_string(["sc","sb","f_id","qcode"], 
$_REQUEST,"&amp;");
 $cn=Dossier::connect();
 /**
@@ -34,10 +36,10 @@ if ( ! empty ($g_user->get_writable_profile()))
         
'onclick="document.getElementById(\'action_add_d\').style.display=\'block\';"');
 }
 ?>
-<div id="action_add_d" class="inner_box" 
style="width:25rem;display:none;top:10rem;">
+<div id="action_add_d" class="inner_box" 
style="position:fixed;min-width:25rem;display:none;top:10rem;">
     <?php echo HtmlInput::title_box(_("Choississez une action"), 
"action_add_d"); ?>
     <div style="text-align: center">
-
+<?=\Noalyss\Dbg::echo_file(__FILE__)?>
         <form method="get" >
 
             <?php
@@ -71,3 +73,5 @@ if ( ! empty ($g_user->get_writable_profile()))
         </form>
     </div>
 </div>
+<?php
+include "show-all-variable.php";
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index e69de29bb..56e744ad2 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -0,0 +1,27 @@
+CREATE OR REPLACE FUNCTION comptaproc.get_follow_up_tree(action_gestion_id 
integer)
+    RETURNS SETOF integer
+    LANGUAGE plpgsql
+AS $function$
+declare
+    i int;
+    x int;
+    e int;
+begin
+    for x in select aga_least
+             from action_gestion_related
+             where
+                 aga_greatest = action_gestion_id
+        loop
+            return next x;
+
+            for e in select *  from  comptaproc.get_follow_up_tree(x)
+                loop
+                    return next e;
+                end loop;
+
+        end loop;
+    return;
+end;
+$function$
+;
+        
\ No newline at end of file



reply via email to

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