Bonjour,

Petite modification par rapport aux specs du ticket, la config se fait
dans les préférences utilisateurs (comme les couleurs de priorité).

Ci-joint le patch financé par l'INSERM pour la 0.84 nommé
"ticket3699_duedate_progressbar.diff" et le patch pour la 0.83 (si
certains le veulent pour leur version de glpi 0.83.x) nommé
"ticket3699_duedate_progressbar_0.83.diff"


Cordialement,
--
David DURIEUX
Tel : +33 (0)4.82.53.30.53
Mail : d.duri...@siprossii.com
Site Web : http://www.siprossii.com/

SIPROSSII
Les Lafôrets
69430 Beaujeu
FRANCE
Index: config/define.php
===================================================================
--- config/define.php	(revision 19007)
+++ config/define.php	(working copy)
@@ -306,7 +306,11 @@
                                      'names_format', 'number_format', 'priority_1', 'priority_2',
                                      'priority_3', 'priority_4', 'priority_5', 'priority_6',
                                      'refresh_ticket_list', 'set_default_tech', 'show_count_on_tabs',
-                                     'show_jobs_at_login', 'task_private', 'use_flat_dropdowntree');
+                                     'show_jobs_at_login', 'task_private', 'use_flat_dropdowntree',
+                                     'use_flat_dropdowntree', 'duedateok_color', 
+                                     'duedatewarning_color', 'duedatecritical_color', 
+                                     'duedatewarning_less', 'duedatecritical_less', 
+                                     'duedatewarning_unit', 'duedatecritical_unit');
 
 /// TODO need this array be empty
 // Itemtypes not implements : need to create class to avoid warning on autoload
Index: install/update_0831_0833.php
===================================================================
--- install/update_0831_0833.php	(revision 19007)
+++ install/update_0831_0833.php	(working copy)
@@ -142,6 +142,22 @@
       }
    }
 
+   $migration->addField("glpi_configs", "notification_to_myself", "bool");
+   $migration->addField("glpi_configs", 'duedateok_color', "char(20) COLLATE utf8_unicode_ci DEFAULT '#06ff00'");
+   $migration->addField("glpi_configs", 'duedatewarning_color', "char(20) COLLATE utf8_unicode_ci DEFAULT '#ffb800'");
+   $migration->addField("glpi_configs", 'duedatecritical_color', "char(20) COLLATE utf8_unicode_ci DEFAULT '#ff0000'");
+   $migration->addField("glpi_configs", 'duedatewarning_less', "int(11) NOT NULL DEFAULT '20'");
+   $migration->addField("glpi_configs", 'duedatecritical_less', "int(11) NOT NULL DEFAULT '5'");
+   $migration->addField("glpi_configs", 'duedatewarning_unit', "char(6) NOT NULL DEFAULT '%'");
+   $migration->addField("glpi_configs", 'duedatecritical_unit', "char(6) NOT NULL DEFAULT '%'");
+   $migration->addField("glpi_users", 'duedateok_color', "char(20) COLLATE utf8_unicode_ci DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatewarning_color', "char(20) COLLATE utf8_unicode_ci DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatecritical_color', "char(20) COLLATE utf8_unicode_ci DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatewarning_less', "int(11) DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatecritical_less', "int(11) DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatewarning_unit', "char(6) DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatecritical_unit', "char(6) DEFAULT NULL");
+   
    // must always be at the end
    $migration->executeMigration();
 
Index: install/mysql/glpi-0.83.1-empty.sql
===================================================================
--- install/mysql/glpi-0.83.1-empty.sql	(revision 19007)
+++ install/mysql/glpi-0.83.1-empty.sql	(working copy)
@@ -765,6 +765,13 @@
   `allow_search_all` tinyint(1) NOT NULL DEFAULT '1',
   `allow_search_global` tinyint(1) NOT NULL DEFAULT '1',
   `display_count_on_home` int(11) NOT NULL DEFAULT '5',
+  `duedateok_color` char(20) COLLATE utf8_unicode_ci DEFAULT '#06ff00',
+  `duedatewarning_color` char(20) COLLATE utf8_unicode_ci DEFAULT '#ffb800',
+  `duedatecritical_color` char(20) COLLATE utf8_unicode_ci DEFAULT '#ff0000',
+  `duedatewarning_less` int(11) NOT NULL DEFAULT '20',
+  `duedatecritical_less` int(11) NOT NULL DEFAULT '5',
+  `duedatewarning_unit` char(6) NOT NULL DEFAULT '%',
+  `duedatecritical_unit` char(6) NOT NULL DEFAULT '%',
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
@@ -4986,6 +4993,13 @@
   `personal_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
   `personal_token_date` datetime DEFAULT NULL,
   `display_count_on_home` int(11) DEFAULT NULL,
+  `duedateok_color` char(20) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `duedatewarning_color` char(20) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `duedatecritical_color` char(20) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `duedatewarning_less` int(11) DEFAULT NULL,
+  `duedatecritical_less` int(11) DEFAULT NULL,
+  `duedatewarning_unit` char(6) DEFAULT NULL,
+  `duedatecritical_unit` char(6) DEFAULT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `unicity` (`name`),
   KEY `firstname` (`firstname`),
Index: inc/config.class.php
===================================================================
--- inc/config.class.php	(revision 19007)
+++ inc/config.class.php	(working copy)
@@ -679,7 +679,7 @@
          }
          echo "</tr>\n";
       }
-
+      
       echo "<tr class='tab_bg_2'>";
       echo "<td colspan='7' class='center'>";
       echo "<input type='hidden' name='id' value='" . $CFG_GLPI["id"] . "'>";
@@ -890,6 +890,41 @@
          echo "</td></tr>";
       }
 
+      echo "<tr><th colspan='4'>Configuration de la barre de date d'échéance</th></tr>";
+      
+      echo "<tr class='tab_bg_1'>".
+           "<td colspan='2'>Statut ok</td>";
+      echo "<td colspan='2' bgcolor='".$data['duedateok_color']."'>";
+      echo "<input name='duedateok_color' size='7' value='".$data['duedateok_color']."' type='text'/>";
+      echo "</td>";
+      echo "</tr>";
+      
+      echo "<tr class='tab_bg_1'>".
+           "<td colspan='2'>Statut warning</td>";
+      echo "<td colspan='2' bgcolor='".$data['duedatewarning_color']."'>";
+      echo "<input name='duedatewarning_color' size='7' value='".$data['duedatewarning_color']."' type='text'/>&nbsp;";
+      echo "et moins de ";
+      Dropdown::showInteger("duedatewarning_less", $data['duedatewarning_less'])." ";
+      $elements = array('%' => '%',
+                       'hours' => "heures",
+                       'days' => "jours");
+      Dropdown::showFromArray("duedatewarning_unit", $elements, array('value'=>$data['duedatewarning_unit']));
+      echo "</td>";
+      echo "</tr>";
+      
+      echo "<tr class='tab_bg_1'>".
+           "<td colspan='2'>Statut critique</td>";
+      echo "<td colspan='2' bgcolor='#ff0000'>";
+      echo "<input name='duedatecritical_color' size='7' value='#ff0000' type='text'/>&nbsp;";
+      echo "et moins de ";
+      Dropdown::showInteger("duedatecritical_less", $data['duedatecritical_less'])." ";
+      $elements = array('%' => '%',
+                       'hour' => "heures",
+                       'day' => "jours");
+      Dropdown::showFromArray("duedatecritical_unit", $elements, array('value'=>$data['duedatecritical_unit']));
+      echo "</td>";
+      echo "</tr>";
+      
       echo "<tr class='tab_bg_2'>";
       echo "<td colspan='4' class='center'>";
       echo "<input type='submit' name='update' class='submit' value=\"".$LANG['buttons'][2]."\">";
@@ -1292,4 +1327,4 @@
    }
 }
 
-?>
\ No newline at end of file
+?>
Index: inc/ticket.class.php
===================================================================
--- inc/ticket.class.php	(revision 19007)
+++ inc/ticket.class.php	(working copy)
@@ -1786,6 +1788,12 @@
       $tab[18]['datatype']      = 'datetime';
       $tab[18]['maybefuture']   = true;
       $tab[18]['massiveaction'] = false;
+      
+       $tab[151]['table']             = $this->getTable();
+       $tab[151]['field']             = 'due_date';
+       $tab[151]['name']              = $LANG['sla'][5]." (barre de progression)";
+       $tab[151]['datatype']          = 'nothing';
+       $tab[151]['massiveaction']     = false;
 
       $tab[82]['table']         = $this->getTable();
       $tab[82]['field']         = 'is_late';
Index: inc/search.class.php
===================================================================
--- inc/search.class.php	(revision 19007)
+++ inc/search.class.php	(working copy)
@@ -4045,6 +4045,81 @@
             }
             return $out;
 
+         case "glpi_tickets.due_date" :
+            
+            if ($ID == 151) {
+               if (is_null($data[$NAME.$num])) {
+                  return '';
+               }
+               $ticket = new Ticket();
+               $ticket->getFromDB($data['ITEM_0']);
+               if ($ticket->fields['status'] == 'solved'
+                       OR $ticket->fields['status'] == 'closed') {
+                  return '';
+               }              
+               $percentage = 0;
+               if ($ticket->fields['slas_id'] != 0) { // Have SLA
+                  $sla = new SLA();
+                  $sla->getFromDB($ticket->fields['slas_id']);
+                  $currenttime = $sla->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
+                  $totaltime = $sla->getActiveTimeBetween($ticket->fields['date'], $data[$NAME.$num]);
+                  $percentage = round((100 * $currenttime) / $totaltime);
+               } else {
+                  $calendars_id = EntityData::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
+                  if ($calendars_id != 0) { // Ticket entity have calendar
+                     $calendar = new Calendar();
+                     $calendar->getFromDB($calendars_id);
+                     $currenttime = $calendar->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
+                     $totaltime = $calendar->getActiveTimeBetween($ticket->fields['date'], $data[$NAME.$num]);
+                     $percentage = round((100 * $currenttime) / $totaltime);
+                  } else { // No calendar
+                     $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($ticket->fields['date']);
+                     $totaltime = strtotime($data[$NAME.$num]) - strtotime($ticket->fields['date']);
+                     $percentage = round((100 * $currenttime) / $totaltime);
+                  }
+               }
+               $percentage_text = $percentage;
+               if ($percentage > 100) {
+                  $percentage = 100;
+               }
+               
+               if ($_SESSION['glpiduedatewarning_unit'] == '%') {
+                  $less_warn_limit = $_SESSION['glpiduedatewarning_less'];
+                  $less_warn = (100 - $percentage);
+               } else if ($_SESSION['glpiduedatewarning_unit'] == 'hour') {
+                  $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * 3600;
+                  $less_warn = ($totaltime - $currenttime);
+               } else if ($_SESSION['glpiduedatewarning_unit'] == 'day') {
+                  $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * 3600 * 24;
+                  $less_warn = ($totaltime - $currenttime);
+               }
+
+               if ($_SESSION['glpiduedatecritical_unit'] == '%') {
+                  $less_crit_limit = $_SESSION['glpiduedatecritical_less'];
+                  $less_crit = (100 - $percentage);
+               } else if ($_SESSION['glpiduedatecritical_unit'] == 'hour') {
+                  $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * 3600;
+                  $less_crit = ($totaltime - $currenttime);
+               } else if ($_SESSION['glpiduedatecritical_unit'] == 'day') {
+                  $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * 3600 * 24;
+                  $less_crit = ($totaltime - $currenttime);
+               }
+
+               $color = $_SESSION['glpiduedateok_color'];
+               if ($less_crit < $less_crit_limit) {
+                  $color = $_SESSION['glpiduedatecritical_color'];
+               } else if ($less_warn < $less_warn_limit) {
+                  $color = $_SESSION['glpiduedatewarning_color'];
+               }
+               
+               //Calculate bar progress
+               $out = "<div class='center' style='background-color: #ffffff; width: 100%;border: 1px solid #9BA563;' >";
+               $out .= "<div style='position:absolute;'>&nbsp;".$percentage_text."%</div>";
+               $out .= "<div class='center' style='background-color: ".$color."; width: ".$percentage."%; height: 12px' ></div>";
+               $out .= "</div>";
+               return $out;
+            }
+            
          case "glpi_softwarelicenses.number" :
             if ($data[$NAME.$num."_2"]==-1) {
                return $LANG['software'][4];
Index: config/define.php
===================================================================
--- config/define.php	(revision 19404)
+++ config/define.php	(working copy)
@@ -293,7 +293,10 @@
                                      'priority_2', 'priority_3', 'priority_4', 'priority_5',
                                      'priority_6', 'refresh_ticket_list', 'set_default_tech',
                                      'show_count_on_tabs', 'show_jobs_at_login', 'task_private',
-                                     'use_flat_dropdowntree',);
+                                     'use_flat_dropdowntree', 'duedateok_color', 
+                                     'duedatewarning_color', 'duedatecritical_color', 
+                                     'duedatewarning_less', 'duedatecritical_less', 
+                                     'duedatewarning_unit', 'duedatecritical_unit');
 
 /// TODO need this array be empty
 // Itemtypes not implements : need to create class to avoid warning on autoload
Index: install/update_0831_084.php
===================================================================
--- install/update_0831_084.php	(revision 19404)
+++ install/update_0831_084.php	(working copy)
@@ -251,9 +251,9 @@
 
    $updateresult     = true;
    $ADDTODISPLAYPREF = array();
-
+   
    //TRANS: %s is the number of new version
-   $migration->displayTitle(sprintf(_('Update to %s'), '0.84'));
+   //$migration->displayTitle(sprintf(_('Update to %s'), '0.84'));
    $migration->setVersion('0.84');
 
 
@@ -1792,8 +1792,23 @@
                               'condition' => 'WHERE `id`=0'));
 
    $migration->addField("glpi_configs", "notification_to_myself", "bool");
+   $migration->addField("glpi_configs", 'duedateok_color', "char(20) COLLATE utf8_unicode_ci DEFAULT '#06ff00'");
+   $migration->addField("glpi_configs", 'duedatewarning_color', "char(20) COLLATE utf8_unicode_ci DEFAULT '#ffb800'");
+   $migration->addField("glpi_configs", 'duedatecritical_color', "char(20) COLLATE utf8_unicode_ci DEFAULT '#ff0000'");
+   $migration->addField("glpi_configs", 'duedatewarning_less', "int(11) NOT NULL DEFAULT '20'");
+   $migration->addField("glpi_configs", 'duedatecritical_less', "int(11) NOT NULL DEFAULT '5'");
+   $migration->addField("glpi_configs", 'duedatewarning_unit', "char(6) NOT NULL DEFAULT '%'");
+   $migration->addField("glpi_configs", 'duedatecritical_unit', "char(6) NOT NULL DEFAULT '%'");
    $migration->addField("glpi_users", "notification_to_myself", "tinyint(1) NULL DEFAULT NULL");
-
+   $migration->addField("glpi_users", 'duedateok_color', "char(20) COLLATE utf8_unicode_ci DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatewarning_color', "char(20) COLLATE utf8_unicode_ci DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatecritical_color', "char(20) COLLATE utf8_unicode_ci DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatewarning_less', "int(11) DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatecritical_less', "int(11) DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatewarning_unit', "char(6) DEFAULT NULL");
+   $migration->addField("glpi_users", 'duedatecritical_unit', "char(6) DEFAULT NULL");
+  
+   
    $migration->addField("glpi_reservationitems", "is_deleted", "bool");
    $migration->addKey("glpi_reservationitems", "is_deleted");
 
Index: install/mysql/glpi-0.84-empty.sql
===================================================================
--- install/mysql/glpi-0.84-empty.sql	(revision 19404)
+++ install/mysql/glpi-0.84-empty.sql	(working copy)
@@ -808,6 +808,13 @@
   `use_check_pref` tinyint(1) NOT NULL DEFAULT '0',
   `notification_to_myself` tinyint(1) NOT NULL DEFAULT '0',
   `ssovariables_id` int(11) NOT NULL DEFAULT '0',
+  `duedateok_color` char(20) COLLATE utf8_unicode_ci DEFAULT '#06ff00',
+  `duedatewarning_color` char(20) COLLATE utf8_unicode_ci DEFAULT '#ffb800',
+  `duedatecritical_color` char(20) COLLATE utf8_unicode_ci DEFAULT '#ff0000',
+  `duedatewarning_less` int(11) NOT NULL DEFAULT '20',
+  `duedatecritical_less` int(11) NOT NULL DEFAULT '5',
+  `duedatewarning_unit` char(6) NOT NULL DEFAULT '%',
+  `duedatecritical_unit` char(6) NOT NULL DEFAULT '%',
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
@@ -5570,6 +5577,13 @@
   `personal_token_date` datetime DEFAULT NULL,
   `display_count_on_home` int(11) DEFAULT NULL,
   `notification_to_myself` tinyint(1) DEFAULT NULL,
+  `duedateok_color` char(20) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `duedatewarning_color` char(20) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `duedatecritical_color` char(20) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `duedatewarning_less` int(11) DEFAULT NULL,
+  `duedatecritical_less` int(11) DEFAULT NULL,
+  `duedatewarning_unit` char(6) DEFAULT NULL,
+  `duedatecritical_unit` char(6) DEFAULT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `unicity` (`name`),
   KEY `firstname` (`firstname`),
Index: inc/config.class.php
===================================================================
--- inc/config.class.php	(revision 19404)
+++ inc/config.class.php	(working copy)
@@ -691,7 +691,7 @@
          }
          echo "</tr>\n";
       }
-
+      
       echo "<tr class='tab_bg_2'>";
       echo "<td colspan='7' class='center'>";
       echo "<input type='hidden' name='id' value='" . $CFG_GLPI["id"] . "'>";
@@ -916,6 +916,41 @@
          echo "</td></tr>";
       }
 
+      echo "<tr><th colspan='4'>".__('Configuring the due date bar')."</th></tr>";
+      
+      echo "<tr class='tab_bg_1'>".
+           "<td colspan='2'>".__('Ok state')."</td>";
+      echo "<td colspan='2' bgcolor='".$data['duedateok_color']."'>";
+      echo "<input name='duedateok_color' size='7' value='".$data['duedateok_color']."' type='text'/>";
+      echo "</td>";
+      echo "</tr>";
+      
+      echo "<tr class='tab_bg_1'>".
+           "<td colspan='2'>".__('Warning state')."</td>";
+      echo "<td colspan='2' bgcolor='".$data['duedatewarning_color']."'>";
+      echo "<input name='duedatewarning_color' size='7' value='".$data['duedatewarning_color']."' type='text'/>&nbsp;";
+      echo __('and less')." ";
+      Dropdown::showNumber("duedatewarning_less", array('value'=>$data['duedatewarning_less']))." ";
+      $elements = array('%' => '%',
+                       'hours' => __('hours'),
+                       'days' => __('days'));
+      Dropdown::showFromArray("duedatewarning_unit", $elements, array('value'=>$data['duedatewarning_unit']));
+      echo "</td>";
+      echo "</tr>";
+      
+      echo "<tr class='tab_bg_1'>".
+           "<td colspan='2'>".__('Critical state')."</td>";
+      echo "<td colspan='2' bgcolor='#ff0000'>";
+      echo "<input name='duedatecritical_color' size='7' value='#ff0000' type='text'/>&nbsp;";
+      echo __('and less')." ";
+      Dropdown::showNumber("duedatecritical_less", array('value'=>$data['duedatecritical_less']))." ";
+      $elements = array('%' => '%',
+                       'hour' => __('hour'),
+                       'day' => __('day'));
+      Dropdown::showFromArray("duedatecritical_unit", $elements, array('value'=>$data['duedatecritical_unit']));
+      echo "</td>";
+      echo "</tr>";
+      
       echo "<tr class='tab_bg_2'>";
       echo "<td colspan='4' class='center'>";
       echo "<input type='submit' name='update' class='submit' value=\""._sx('button', 'Save')."\">";
Index: inc/ticket.class.php
===================================================================
--- inc/ticket.class.php	(revision 19404)
+++ inc/ticket.class.php	(working copy)
@@ -1911,6 +1911,12 @@
       $tab[18]['datatype']          = 'datetime';
       $tab[18]['maybefuture']       = true;
       $tab[18]['massiveaction']     = false;
+      
+      $tab[151]['table']             = $this->getTable();
+      $tab[151]['field']             = 'due_date';
+      $tab[151]['name']              = __('Due date')." (".__('progress bar').")";
+      $tab[151]['datatype']          = 'nothing';
+      $tab[151]['massiveaction']     = false;
 
       $tab[82]['table']             = $this->getTable();
       $tab[82]['field']             = 'is_late';
Index: inc/search.class.php
===================================================================
--- inc/search.class.php	(revision 19404)
+++ inc/search.class.php	(working copy)
@@ -3867,7 +3867,6 @@
       $linkfield = $searchopt[$ID]["linkfield"];
 
       /// TODO try to clean all specific cases using SpecificToDisplay
-
       switch ($table.'.'.$field) {
          case "glpi_users.name" :
             // USER search case
@@ -4196,6 +4195,81 @@
             }
             return $out;
 
+         case "glpi_tickets.due_date" :
+            
+            if ($ID == 151) {
+               if (is_null($data[$NAME.$num])) {
+                  return '';
+               }
+               $ticket = new Ticket();
+               $ticket->getFromDB($data['ITEM_0']);
+               if ($ticket->fields['status'] == Ticket::SOLVED
+                       OR $ticket->fields['status'] == Ticket::CLOSED) {
+                  return '';
+               }              
+               $percentage = 0;
+               if ($ticket->fields['slas_id'] != 0) { // Have SLA
+                  $sla = new SLA();
+                  $sla->getFromDB($ticket->fields['slas_id']);
+                  $currenttime = $sla->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
+                  $totaltime = $sla->getActiveTimeBetween($ticket->fields['date'], $data[$NAME.$num]);
+                  $percentage = round((100 * $currenttime) / $totaltime);
+               } else {
+                  $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']);
+                  if ($calendars_id != 0) { // Ticket entity have calendar
+                     $calendar = new Calendar();
+                     $calendar->getFromDB($calendars_id);
+                     $currenttime = $calendar->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s'));
+                     $totaltime = $calendar->getActiveTimeBetween($ticket->fields['date'], $data[$NAME.$num]);
+                     $percentage = round((100 * $currenttime) / $totaltime);
+                  } else { // No calendar
+                     $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($ticket->fields['date']);
+                     $totaltime = strtotime($data[$NAME.$num]) - strtotime($ticket->fields['date']);
+                     $percentage = round((100 * $currenttime) / $totaltime);
+                  }
+               }
+               $percentage_text = $percentage;
+               if ($percentage > 100) {
+                  $percentage = 100;
+               }
+               
+               if ($_SESSION['glpiduedatewarning_unit'] == '%') {
+                  $less_warn_limit = $_SESSION['glpiduedatewarning_less'];
+                  $less_warn = (100 - $percentage);
+               } else if ($_SESSION['glpiduedatewarning_unit'] == 'hour') {
+                  $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * 3600;
+                  $less_warn = ($totaltime - $currenttime);
+               } else if ($_SESSION['glpiduedatewarning_unit'] == 'day') {
+                  $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * 3600 * 24;
+                  $less_warn = ($totaltime - $currenttime);
+               }
+
+               if ($_SESSION['glpiduedatecritical_unit'] == '%') {
+                  $less_crit_limit = $_SESSION['glpiduedatecritical_less'];
+                  $less_crit = (100 - $percentage);
+               } else if ($_SESSION['glpiduedatecritical_unit'] == 'hour') {
+                  $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * 3600;
+                  $less_crit = ($totaltime - $currenttime);
+               } else if ($_SESSION['glpiduedatecritical_unit'] == 'day') {
+                  $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * 3600 * 24;
+                  $less_crit = ($totaltime - $currenttime);
+               }
+
+               $color = $_SESSION['glpiduedateok_color'];
+               if ($less_crit < $less_crit_limit) {
+                  $color = $_SESSION['glpiduedatecritical_color'];
+               } else if ($less_warn < $less_warn_limit) {
+                  $color = $_SESSION['glpiduedatewarning_color'];
+               }
+               
+               //Calculate bar progress
+               $out = "<div class='center' style='background-color: #ffffff; width: 100%;border: 1px solid #9BA563;' >";
+               $out .= "<div style='position:absolute;'>&nbsp;".$percentage_text."%</div>";
+               $out .= "<div class='center' style='background-color: ".$color."; width: ".$percentage."%; height: 12px' ></div>";
+               $out .= "</div>";
+               return $out;
+            }
+            
          case "glpi_softwarelicenses.number" :
             if ($data[$NAME.$num."_2"] == -1) {
                return __('Unlimited');
_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev

Reply via email to