mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
- Display hilighted lists depending on each object's status
- Fixed the setup page to use UTF-8 - Create the admin account with the chosen default language SVN:trunk[565]
This commit is contained in:
@@ -748,6 +748,7 @@ class UserRightsProfile extends UserRightsAddOnAPI
|
||||
$oUser->Set('login', $sAdminUser);
|
||||
$oUser->Set('password', $sAdminPwd);
|
||||
$oUser->Set('userid', $iContactId);
|
||||
$oUser->Set('language', utils::GetConfig()->GetDefaultLanguage()); // Default language was chosen during the installation
|
||||
$iUserId = $oUser->DBInsertTrackedNoReload($oChange);
|
||||
|
||||
// Add this user to the very specific 'admin' profile
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
|
||||
define('OBJECT_PROPERTIES_TAB', 'ObjectProperties');
|
||||
|
||||
define('HILIGHT_CLASS_CRITICAL', 'red');
|
||||
define('HILIGHT_CLASS_WARNING', 'orange');
|
||||
define('HILIGHT_CLASS_OK', 'green');
|
||||
define('HILIGHT_CLASS_NONE', '');
|
||||
|
||||
require_once('../core/cmdbobject.class.inc.php');
|
||||
require_once('../application/utils.inc.php');
|
||||
require_once('../application/applicationcontext.class.inc.php');
|
||||
@@ -302,14 +307,18 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
$oPage->details($aDetails);
|
||||
}
|
||||
|
||||
// Comment by Rom: this helper may be used to display objects of class DBObject
|
||||
// -> I am using this to display the changes history
|
||||
public static function DisplaySet(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
|
||||
{
|
||||
$oPage->add(self::GetDisplaySet($oPage, $oSet, $aExtraParams));
|
||||
}
|
||||
|
||||
//public static function GetDisplaySet(WebPage $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false)
|
||||
|
||||
/**
|
||||
* Get the HTML fragment corresponding to the display of a table representing a set of objects
|
||||
* @param WebPage $oPage The page object is used for out-of-band information (mostly scripts) output
|
||||
* @param CMDBObjectSet The set of objects to display
|
||||
* @param Hash $aExtraParams Some extra configuration parameters to tweak the behavior of the display
|
||||
* @return String The HTML fragment representing the table of objects
|
||||
*/
|
||||
public static function GetDisplaySet(WebPage $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
|
||||
{
|
||||
static $iListId = 0;
|
||||
@@ -336,12 +345,14 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
$bDisplayMenu = isset($aExtraParams['menu']) ? $aExtraParams['menu'] == true : true;
|
||||
$bSelectMode = isset($aExtraParams['selection_mode']) ? $aExtraParams['selection_mode'] == true : false;
|
||||
$bSingleSelectMode = isset($aExtraParams['selection_type']) ? ($aExtraParams['selection_type'] == 'single') : false;
|
||||
$aExtraFields = isset($aExtraParams['extra_fields']) ? explode(',', trim($aExtraParams['extra_fields'])) : array();
|
||||
|
||||
$sHtml = '';
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sClassName = $oSet->GetFilter()->GetClass();
|
||||
$aAttribs = array();
|
||||
$aList = MetaModel::GetZListItems($sClassName, 'list');
|
||||
$aList = array_merge($aList, $aExtraFields);
|
||||
if (!empty($sLinkageAttribute))
|
||||
{
|
||||
// The set to display is in fact a set of links between the object specified in the $sLinkageAttribute
|
||||
@@ -408,6 +419,11 @@ abstract class cmdbAbstractObject extends CMDBObject
|
||||
while (($oObj = $oSet->Fetch()) && ($iMaxObjects != 0))
|
||||
{
|
||||
$aRow = array();
|
||||
$sHilightClass = $oObj->GetHilightClass();
|
||||
if ($sHilightClass != '')
|
||||
{
|
||||
$aRow['@class'] = $sHilightClass;
|
||||
}
|
||||
if ($bViewLink)
|
||||
{
|
||||
$aRow['key'] = $oObj->GetHyperLink();
|
||||
@@ -1489,5 +1505,19 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a 'hilight' CSS class, used to hilight a given row in a table
|
||||
* There are currently (i.e defined in the CSS) 4 possible values HILIGHT_CLASS_CRITICAL,
|
||||
* HILIGHT_CLASS_WARNING, HILIGHT_CLASS_OK, HILIGHT_CLASS_NONE
|
||||
* To Be overridden by derived classes
|
||||
* @param void
|
||||
* @return String The desired higlight class for the object/row
|
||||
*/
|
||||
public function GetHilightClass()
|
||||
{
|
||||
// Possible return values are:
|
||||
// HILIGHT_CLASS_CRITICAL, HILIGHT_CLASS_WARNING, HILIGHT_CLASS_OK, HILIGHT_CLASS_NONE
|
||||
return HILIGHT_CLASS_NONE; // Not hilighted by default
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -90,6 +90,20 @@ class iTopWebPage extends NiceWebPage
|
||||
}
|
||||
});
|
||||
|
||||
$.tablesorter.addWidget({
|
||||
// give the widget a id
|
||||
id: "myZebra",
|
||||
// format is called when the on init and when a sorting has finished
|
||||
format: function(table)
|
||||
{
|
||||
// Replace the 'red even' lines by 'red_even' since most browser do not support 2 classes selector in CSS, etc..
|
||||
$("tbody tr:even",table).addClass('even');
|
||||
$("tbody tr.red:even",table).removeClass('red').removeClass('even').addClass('red_even');
|
||||
$("tbody tr.orange:even",table).removeClass('orange').removeClass('even').addClass('orange_even');
|
||||
$("tbody tr.green:even",table).removeClass('green').removeClass('even').addClass('green_even');
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
var myLayout; // a var is required because this page utilizes: myLayout.allowOverflow() method
|
||||
@@ -138,7 +152,7 @@ class iTopWebPage extends NiceWebPage
|
||||
|
||||
$("div[id^=tabbedContent]").tabs(); // tabs
|
||||
$("table.listResults").tableHover(); // hover tables
|
||||
$(".listResults").tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra', 'truncatedList']} ); // sortable and zebra tables
|
||||
$(".listResults").tablesorter( { headers: { 0:{sorter: false }}, widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
|
||||
$(".date-pick").datepicker({
|
||||
showOn: 'button',
|
||||
buttonImage: '../images/calendar.png',
|
||||
|
||||
@@ -142,7 +142,14 @@ class WebPage
|
||||
$sHtml .= "<tbody>\n";
|
||||
foreach($aData as $aRow)
|
||||
{
|
||||
$sHtml .= "<tr>\n";
|
||||
if (isset($aRow['@class'])) // Row specific class, for hilighting certain rows
|
||||
{
|
||||
$sHtml .= "<tr class=\"{$aRow['@class']}\">\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sHtml .= "<tr>\n";
|
||||
}
|
||||
foreach($aConfig as $sName=>$aAttribs)
|
||||
{
|
||||
$aMatches = array();
|
||||
@@ -262,6 +269,7 @@ class WebPage
|
||||
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
|
||||
echo "<html>\n";
|
||||
echo "<head>\n";
|
||||
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
|
||||
echo "<title>{$this->s_title}</title>\n";
|
||||
echo $this->get_base_tag();
|
||||
foreach($this->a_linked_scripts as $s_script)
|
||||
|
||||
@@ -69,9 +69,30 @@ tr.containerHeader, tr.containerHeader td {
|
||||
tr.even td {
|
||||
background-color: #f9f9f1;
|
||||
}
|
||||
tr.red_even td {
|
||||
background-color: #f97e75;
|
||||
color: #ffffff;
|
||||
}
|
||||
tr.red td {
|
||||
background-color: #f9a397;
|
||||
color: #ffffff;
|
||||
}
|
||||
tr.orange_even td {
|
||||
background-color: #f4d07a;
|
||||
}
|
||||
tr.orange td {
|
||||
background-color: #f4e96c;
|
||||
}
|
||||
tr.green_even td {
|
||||
background-color: #bee5a3;
|
||||
}
|
||||
tr.green td {
|
||||
background-color: #b3e5b4;
|
||||
}
|
||||
|
||||
tr td.hover, tr.even td.hover, .hover a, .hover a:visited, .hover a:hover {
|
||||
background-color: #fdf5d0;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
th {
|
||||
@@ -632,7 +653,7 @@ div.HRDrawer {
|
||||
}
|
||||
|
||||
/* Beware: IE6 does not support multiple selector with multiple classes, only the last class is used */
|
||||
table.listResults tr.odd td.truncated {
|
||||
table.listResults tr.odd td.truncated, table.listResults tr td.truncated {
|
||||
background: url(../images/truncated.png) bottom repeat-x;
|
||||
}
|
||||
|
||||
@@ -647,7 +668,7 @@ table.listResults tr.even td.hover.truncated {
|
||||
}
|
||||
|
||||
/* Beware: IE6 does not support multiple selector with multiple classes, only the last class is used */
|
||||
table.listResults tr.odd td.hover.truncated {
|
||||
table.listResults tr.odd td.hover.truncated, table.listResults tr td.hover.truncated{
|
||||
background: #fdf5d0 url(../images/truncated.png) bottom repeat-x;
|
||||
}
|
||||
|
||||
|
||||
@@ -460,6 +460,60 @@ abstract class ResponseTicket extends Ticket
|
||||
$this->Set('closure_deadline', null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the ticket must be hilighted in the list, if we're about to miss a SLA for instance
|
||||
*/
|
||||
public function GetHilightClass()
|
||||
{
|
||||
$sHilightClass = '';
|
||||
switch($this->GetState())
|
||||
{
|
||||
case 'new':
|
||||
$oEscalationDeadline = $this->Get('escalation_deadline');
|
||||
if ($oEscalationDeadline != null)
|
||||
{
|
||||
// A SLA is running
|
||||
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
|
||||
$iEscalationDeadline = AttributeDateTime::GetAsUnixSeconds($oEscalationDeadline);
|
||||
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
|
||||
if ($ratio <= 0)
|
||||
{
|
||||
$sHilightClass = HILIGHT_CLASS_CRITICAL;
|
||||
}
|
||||
else if ($ratio <= 0.25)
|
||||
{
|
||||
$sHilightClass = HILIGHT_CLASS_WARNING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'assigned':
|
||||
$oClosureDeadline = $this->Get('closure_deadline');
|
||||
if ($oClosureDeadline != null)
|
||||
{
|
||||
// A SLA is running
|
||||
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
|
||||
$iClosureDeadline = AttributeDateTime::GetAsUnixSeconds($oClosureDeadline);
|
||||
$ratio = ($iClosureDeadline - time())/($iClosureDeadline - $iStartDate);
|
||||
if ($ratio <= 0)
|
||||
{
|
||||
$sHilightClass = HILIGHT_CLASS_CRITICAL;
|
||||
}
|
||||
else if ($ratio <= 0.25)
|
||||
{
|
||||
$sHilightClass = HILIGHT_CLASS_WARNING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'escalated_tto':
|
||||
case 'escalated_ttr':
|
||||
$sHilightClass = HILIGHT_CLASS_CRITICAL;
|
||||
break;
|
||||
}
|
||||
return $sHilightClass;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user