noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 01/02: #1263 : representation hierarchique d


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 01/02: #1263 : representation hierarchique des dépendances des tâches
Date: Thu, 28 Jan 2016 12:10:51 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 68ae3dd67c80a6d78595b4f41a1893c6ba46fc1c
Author: Dany De Bontridder <address@hidden>
Date:   Thu Jan 28 13:01:58 2016 +0100

    #1263 : representation hierarchique des dépendances des tâches
---
 html/js/scripts.js                 |    1 +
 html/style-classic.css             |    4 +-
 html/style-light.css               |    4 +-
 html/style-mandarine.css           |    6 +-
 include/class/class_follow_up.php  |  159 +++++++++++++++++++++++++++++++++--
 include/template/detail-action.php |  108 ++++++++++--------------
 6 files changed, 202 insertions(+), 80 deletions(-)

diff --git a/html/js/scripts.js b/html/js/scripts.js
index 929cb4a..a83dfd5 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -2053,6 +2053,7 @@ function view_action(ag_id, dossier, modify)
                         });
                         $(id).innerHTML = code_html;
                         if ( ctl_txt == 'ok') { compute_all_ledger();}
+                        code_html.evalScripts();
                     } catch (e) {
                         alert_box('view_action' + e.message);
                     }
diff --git a/html/style-classic.css b/html/style-classic.css
index 6485c72..f972e21 100644
--- a/html/style-classic.css
+++ b/html/style-classic.css
@@ -1846,7 +1846,7 @@ hr {
 /******************************************************************************
  * Hightlight row in a table 
  
******************************************************************************/
-tr.highlight{
+li.highlight,tr.highlight{
     font-weight: bolder;
     font-size:14px;
     background-color: navy;
@@ -1855,7 +1855,7 @@ tr.highlight{
     border-style: solid;
     border-color: blue;
 }
-tr.highlight a{
+li.highlight a,tr.highlight a{
     color:white !important;
     
 }
diff --git a/html/style-light.css b/html/style-light.css
index 0d4bd4f..4bb67b1 100644
--- a/html/style-light.css
+++ b/html/style-light.css
@@ -1803,7 +1803,7 @@ hr {
 /******************************************************************************
  * Hightlight row in a table 
  
******************************************************************************/
-tr.highlight{
+li.highlight , tr.highlight{
     font-weight: bolder;
     font-size:14px;
     background-color: #334975 !important;
@@ -1812,7 +1812,7 @@ tr.highlight{
     border-style: solid;
     border-color: blue;
 }
-tr.highlight a{
+li.highlight a, tr.highlight a{
     color:white !important;
     
 }
diff --git a/html/style-mandarine.css b/html/style-mandarine.css
index 1b66ab3..0099a82 100644
--- a/html/style-mandarine.css
+++ b/html/style-mandarine.css
@@ -1831,7 +1831,7 @@ filter: progid:DXImageTransform.Microsoft.gradient( 
startColorstr='#feccb1', end
 /******************************************************************************
  * Hightlight row in a table 
  
******************************************************************************/
-tr.highlight{
+li.highlight a,tr.highlight{
     font-weight: bolder;
     font-size:14px;
     background-color: lightgrey ! important;
@@ -1841,12 +1841,12 @@ tr.highlight{
     border-color: inherit;
     
 }
-tr.highlight a{
+li.highlight a,tr.highlight a{
     color:white !important;
     background-color:grey !important;
     
 }
-//--- Top menu and menu2
+/*--- Top menu and menu2-*/
 div.topmenu a.mtitle , div.menu2 a.mtitle{
     font-size:13.6px;
     font-size:0.85rem;
diff --git a/include/class/class_follow_up.php 
b/include/class/class_follow_up.php
index 8dc084c..13323bd 100644
--- a/include/class/class_follow_up.php
+++ b/include/class/class_follow_up.php
@@ -210,16 +210,6 @@ class Follow_Up
         $iconcerned=new IConcerned('operation');
 
         // List related action
-        $action=$this->db->get_array("
-                       select ag_id,ag_ref,substr(ag_title,1,40) as 
sub_title,to_char(ag_timestamp,'DD.MM.YY') as str_date ,
-                               ag_timestamp,dt_value
-                                       from action_gestion
-                                        join document_type on (ag_type=dt_id)
-                               where
-                               ag_id in (select aga_greatest from 
action_gestion_related where aga_least =$1)
-                               or
-                               ag_id in (select aga_least from 
action_gestion_related where aga_greatest =$1)
-                               order by ag_timestamp", array($this->ag_id));
         $iaction=new IRelated_Action('action');
         $iaction->value=(isset($this->action))?$this->action:"";
 
@@ -1842,4 +1832,153 @@ class Follow_Up
                     , array($this->ag_id, $_SESSION['g_user'], 
$this->ag_comment));
         }
     }
+    /**
+     * Return the first parent of the event tree, or -1 if not found
+     * @return integer (ag_id)
+     */
+    function get_parent() {
+        $value=$this->db->get_array('
+             with recursive t (aga_least,aga_greatest,depth) as (
+                select aga_least,aga_greatest , 1
+                from 
+                  action_gestion_related
+                 where aga_greatest=$1
+              union all
+                select p2.aga_least,p2.aga_greatest,depth + 1
+                from 
+                  t as p1, action_gestion_related as p2
+                where
+                  p2.aga_greatest is not null and
+                  p2.aga_greatest = p1.aga_least
+              ) select * from t order by depth desc limit 1
+                ' , array($this->ag_id)
+                );
+        if ( ! empty($value ) ) 
+            return $value[0]['aga_least'];
+        else
+            return -1;
+    }
+    /**
+     * Compute an array of the complete tree depending of $p_id
+     * @param $p_id ag_id
+     * @return array 
+     * key index :
+     *     - uniq value  , path 
+     *     - aga_least
+     *     - aga_greatest
+     *     - depth
+     */
+    function get_children($p_id) {
+        // retrieve parent
+        // Get information
+         $sql = "with recursive t (key_path, aga_least,aga_greatest,depth) as (
+                select 
+                 aga_least::text||'-'||aga_greatest::text as key_path ,
+                        aga_least,aga_greatest , 1
+                from 
+                        action_gestion_related
+              where aga_least=$1
+                union all
+            select key_path||'-'||p2.aga_greatest::text,
+              p2.aga_least,p2.aga_greatest,depth + 1
+            from 
+              t as p1, action_gestion_related as p2
+            where
+              p1.aga_greatest is not null and
+              p1.aga_greatest = p2.aga_least
+          ) 
+          select key_path,aga_greatest,ag_title as title,depth 
,to_char(ag_timestamp,'DD/MM/YY') as str_date,dt_value as action_ref
+          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
+         if ( empty($ret_array)) return array();
+         
+         
+         return $ret_array;
+    }
+
+    /**
+     * Display the tree of childrens of the current Action + related parents
+     * @return return the tree of children in a unordered list , HTML string 
+     */
+    function display_children($p_view, $p_base)
+    {
+        /**
+         * First we retrieve the parent
+         */
+        $parent=$this->get_parent();
+
+        $base=HtmlInput::request_to_string(array("gDossier", "ac", "sa", "sb", 
"sc",
+                    "f_id"));
+        $parent=$this->get_parent();
+        if ($parent==-1)
+        {
+            echo _('Principal');
+            $parent = $this->ag_id;
+        }
+        else
+        {
+            $fu_parent=new Follow_Up($this->db, $parent);
+            $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);
+        for ($o=0; $o<count($action); $o++)
+        {
+            $class=($this->ag_id == $action[$o]['aga_greatest'])?' 
class="highlight" ':'';
+            $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'],
+                        $_REQUEST['ag_id']);
+                $showAction='<a class="line" 
href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
+                $js='<a class="tinybutton" 
id="acact'.$action[$o]['aga_greatest'].'" href="javascript:void(0)" 
onclick="'.$rmAction.'">'.SMALLX.'</a>';
+                echo '<li '.$class.' 
id="act'.$action[$o]['aga_greatest'].'">'.$margin.$showAction.$action[$o]['str_date'].
+                
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')</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']).')</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]['sub_title']).'('.h($action[$o]['action_ref']).')</a>'." "
+                .'</li>';
+            }
+        }
+        echo '</ul>';
+    }
+
 }
diff --git a/include/template/detail-action.php 
b/include/template/detail-action.php
index eb2ab25..2d90e9b 100644
--- a/include/template/detail-action.php
+++ b/include/template/detail-action.php
@@ -1,9 +1,9 @@
 <?php
 //This file is part of NOALYSS and is under GPL 
 //see licence.txt
+$uniq=HtmlInput::generate_id("tab");
 ?><div>
-<h2 class="gest_name"><?php echo $sp->input();   ?></h2>
-<div style="width:47%;float:left;">
+<div style="float:left;">
 
 
     <table>
@@ -87,7 +87,7 @@
  <?php if ($p_view != 'READ') echo $str_add_button;?>
 
 </div>
-<div style="width:47%;float:left">
+<div style="float:left">
         <table>
 
          
@@ -161,9 +161,13 @@
         </table>
 
 </div>
-<div style="clear: both"></div>
-       <div style="float:left;width: 47%">
-               <h4 style="display:inline;">Opérations concernées</h4>
+<div id="choice_other_info_div" style="float:left;">
+    <ul class="tabs">
+        <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>
+    </ul>
+       <div id="related_operation_div<?php echo $uniq?>" style="display:none">
+
                <ol>
 
                <?php
@@ -181,64 +185,31 @@
                                                .'</li>';
                                }
                }
+               
+               
 
                ?>
                </ol>
                <?php if ($p_view != 'READ')   echo '<span 
class="noprint">'.$iconcerned->input().'</span>';?>
        </div>
 
-        <div style="float:left;width: 47%">
-               <h4 style="display:inline"><?php echo _("Actions 
concernées")?></h4>
-               <ol>
+        <div id="related_action_div<?php echo $uniq?>">
+               
+               
 
                <?php
-               
$base=HtmlInput::request_to_string(array("gDossier","ac","sa","sb","sc","f_id"));
-               for ($o=0;$o<count($action);$o++)
-               {
-                       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]['ag_id'],$_REQUEST['ag_id']);
-                            $showAction='<a class="line" 
href="'.$base."&ag_id=".$action[$o]['ag_id'].'">';
-                            $js= '<a class="tinybutton" 
id="acact'.$action[$o]['ag_id'].'" href="javascript:void(0)" 
onclick="'.$rmAction.'">'.SMALLX.'</a>';
-                            echo '<li 
id="act'.$action[$o]['ag_id'].'">'.$showAction.$action[$o]['str_date']." 
".$action[$o]['ag_ref']." ".
-                                       
h($action[$o]['sub_title']).'('.h($action[$o]['dt_value']).')</a>'." "
-                               .$js.'</li>';
-                       } else 
-                        /*
-                         * Display detail requested from Ajax Div
-                         */
-                         if ( $p_base == 'ajax' )
-                         {
-                            $xaction = 
sprintf('view_action(%d,%d,%d)',$action[$o]['ag_id'],Dossier::id(),1);
-                            $showAction='<a class="line" 
href="javascript:'.$xaction.'">';
-                            echo '<li>'.$showAction.$action[$o]['str_date']." 
".$action[$o]['ag_ref']." ".
-                                       
h($action[$o]['sub_title']).'('.h($action[$o]['dt_value']).')</a>'." "
-                               .'</li>';
-                         }
-                         /*
-                          * READ ONLY
-                          */
-                         else
-                         {
-                               $showAction='<a class="line" 
href="'.$base."&ag_id=".$action[$o]['ag_id'].'">';
-                               echo 
'<li>'.$showAction.$action[$o]['str_date']." ".$action[$o]['ag_ref']." ".
-                                       
h($action[$o]['sub_title']).'('.h($action[$o]['dt_value']).')</a>'." "
-                               .'</li>';
-                       }
-               }
+               $this->display_children($p_view,$p_base);
 
                ?>
-               </ol>
+               
                <?php if ( $p_view != 'READ') echo '<span 
class="noprint">'.$iaction->input().'</span>';?>
        </div>
 </div>
+
+</div>
 <div style="clear: both"></div>
 <div id="div_action_description">
-  <h1 class="legend">
-           <?php echo _('Description')?>
-  </h1>
+  
   <p>
 <script language="javascript">
    function enlarge(p_id_textarea){
@@ -252,10 +223,6 @@ function small(p_id_textarea){
 
    }
 </script>
-<?php if  ($p_view != 'NEW') : ?>
-Document créé le <?php echo $this->ag_timestamp ?> par <?php echo 
$this->ag_owner?>
-<?php endif; ?>
-  <h4 class="info" style="margin-left:110px"><?php echo _('Titre')?></h4>
     <p style="margin-left:100px">
     <?php echo $title->input();
     ?>
@@ -267,27 +234,23 @@ Document créé le <?php echo $this->ag_timestamp ?> par 
<?php echo $this->ag_ow
 for( $c=0;$c<count($acomment);$c++){
         if ($c == 0) { $m_desc=_('Description');}
         else
-        if ($c == 1) { $m_desc=_('Commentaire');}
-        else
-         { $m_desc="";}?>
-        <h4 class="info" >   <?php echo $m_desc;?></h4>
+         { $m_desc=_('Commentaire');}
 
-       <?php
-        if ( $p_view != 'READ')
+         if ( $p_view != 'READ' && $c > 0)
        {
                $rmComment=sprintf("return confirm_box(null,'"._('Voulez-vous 
effacer ce commentaire')." ?',function() {remove_comment('%s','%s');});",
                                                dossier::id(),
                                                $acomment[$c]['agc_id']);
                                $js= '<a class="tinybutton" 
id="accom'.$acomment[$c]['agc_id'].'" href="javascript:void(0)" 
onclick="'.$rmComment.'">'.SMALLX.'</a>';
-               echo 
hb('n°'.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." 
".$acomment[$c]['str_agc_date'].')').$js.
-                               '<pre style="white-space: 
-moz-pre-wrap;white-space: pre-wrap;border:1px solid blue;width:80%;" 
id="com'.$acomment[$c]['agc_id'].'"> '.
+               echo h($m_desc.' 
'.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." 
".$acomment[$c]['str_agc_date'].')').$js.
+                               '<pre style="margin-top:1px;white-space: 
-moz-pre-wrap;white-space: pre-wrap;border:1px solid blue;width:80%;" 
id="com'.$acomment[$c]['agc_id'].'"> '.
                                " ".h($acomment[$c]['agc_comment']).'</pre>'
                                ;
        }
        else
        {
-               echo 
hb('n°'.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." 
".$acomment[$c]['str_agc_date'].')').
-                               '<pre style="white-space: 
-moz-pre-wrap;white-space: pre-wrap;border:1px solid blue;width:80%;" 
id="com'.$acomment[$c]['agc_id'].'"> '.
+               echo h($m_desc.' 
'.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." 
".$acomment[$c]['str_agc_date'].')').
+                               '<pre style="margin-top:1px;white-space: 
-moz-pre-wrap;white-space: pre-wrap;border:1px solid blue;width:80%;" 
id="com'.$acomment[$c]['agc_id'].'"> '.
                                " ".h($acomment[$c]['agc_comment']).'</pre>'
                                ;
 
@@ -509,5 +472,24 @@ catch(exception) { alert('<?php echo j(_('Je ne peux pas 
ajouter de fichier'))?>
   </div>
  <?php endif;?>
 </div>
+<?php if  ($p_view != 'NEW') : ?>
+Document créé le <?php echo $this->ag_timestamp ?> par <?php echo 
$this->ag_owner?>
+<?php endif; ?>
+
 </div>
 <script>compute_all_ledger()</script>
+<script>
+  $('related_action_tab<?php echo $uniq?>').onclick=function() {
+      $('related_action_tab<?php echo $uniq?>').className='tabs_selected';
+      $('related_operation_tab<?php echo $uniq?>').className='tabs';
+      $('related_operation_div<?php echo $uniq?>').hide();
+      $('related_action_div<?php echo $uniq?>').show();
+  }  
+  $('related_operation_tab<?php echo $uniq?>').onclick=function() {
+      $('related_operation_tab<?php echo $uniq?>').className='tabs_selected';
+      $('related_action_tab<?php echo $uniq?>').className='tabs';
+      $('related_action_div<?php echo $uniq?>').hide();
+      $('related_operation_div<?php echo $uniq?>').show();
+  }  
+  
+</script>
\ No newline at end of file



reply via email to

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