function translation_percent_bar($label, $percent) { $html = "<div class='languagepercent'>"; $html .= "<span class='languagepercentlabel'>{$label}</span>"; $html .= percent_bar($percent); $html .= "</div>"; return $html; }
$task->name = $strUntitled; } if (!empty($incidentTitle)) { $task->name = $incidentTitle; } if ($show == 'incidents') { echo "<a href=\"javascript:incident_details_window('{$incidentidL}','incident{$incidentidL}')\" class='info'>"; } else { echo "<a href='view_task.php?id={$task->id}' class='info'>"; } echo truncate_string($task->name, 100); echo "</a>"; echo "</td>"; if ($show != 'incidents') { echo "<td>" . priority_icon($task->priority) . priority_name($task->priority) . "</td>"; echo "<td>" . percent_bar($task->completion) . "</td>"; } } if ($mode != 'incident') { echo "<td"; if ($startdate > 0 and $startdate <= $now and $task->completion <= 0) { echo " class='urgent'"; } elseif ($startdate > 0 and $startdate <= $now and $task->completion >= 1 and $task->completion < 100) { echo " class='idle'"; } echo ">"; if ($startdate > 0) { echo ldate($CONFIG['dateformat_date'], $startdate); } echo "</td>"; echo "<td";
function dashboard_tasks($dashletid) { global $sit, $CONFIG, $iconset, $dbTasks; $user = $sit[2]; if ($CONFIG['tasks_enabled'] == TRUE) { $sql = "SELECT * FROM `{$dbTasks}` WHERE owner='{$user}' AND (completion < 100 OR completion='' OR completion IS NULL) AND "; $sql .= "(distribution = 'public' OR distribution = 'private') "; if (!empty($sort)) { if ($sort == 'id') { $sql .= "ORDER BY id "; } elseif ($sort == 'name') { $sql .= "ORDER BY name "; } elseif ($sort == 'priority') { $sql .= "ORDER BY priority "; } elseif ($sort == 'completion') { $sql .= "ORDER BY completion "; } elseif ($sort == 'startdate') { $sql .= "ORDER BY startdate "; } elseif ($sort == 'duedate') { $sql .= "ORDER BY duedate "; } elseif ($sort == 'distribution') { $sql .= "ORDER BY distribution "; } else { $sql = "ORDER BY id "; } if ($order == 'a' or $order == 'ASC' or $order = '') { $sql .= "ASC"; } else { $sql .= "DESC"; } } else { $sql .= "ORDER BY IF(duedate,duedate,99999999) ASC, duedate ASC, startdate DESC, priority DESC, completion ASC"; } $result = mysql_query($sql); if (mysql_error()) { trigger_error(mysql_error(), E_USER_WARNING); } if (mysql_num_rows($result) >= 1) { $content .= "<table align='center' width='100%'>"; $content .= "<tr>"; $content .= colheader('id', $GLOBALS['strID']); $content .= colheader('name', $GLOBALS['strTask']); $content .= colheader('priority', $GLOBALS['strPriority']); $content .= colheader('completion', $GLOBALS['strCompletion']); $content .= "</tr>\n"; $shade = 'shade1'; while ($task = mysql_fetch_object($result)) { $duedate = mysql2date($task->duedate); $startdate = mysql2date($task->startdate); if (empty($task->name)) { $task->name = $GLOBALS['strUntitled']; } $content .= "<tr class='{$shade}'>"; $content .= "<td>{$task->id}</td>"; $content .= "<td><a href='view_task.php?id={$task->id}' class='info'>" . truncate_string($task->name, 23); if (!empty($task->description)) { $content .= "<span>" . nl2br($task->description) . "</span>"; } $content .= "</a></td>"; $content .= "<td>" . priority_icon($task->priority) . priority_name($task->priority) . "</td>"; $content .= "<td>" . percent_bar($task->completion) . "</td>"; $content .= "</tr>\n"; if ($shade == 'shade1') { $shade = 'shade2'; } else { $shade = 'shade1'; } } $content .= "</table>\n"; } else { $content .= "<p align='center'>{$GLOBALS['strNoRecords']}</p>"; } } else { $content .= "<p class='warning'>{$GLOBALS['strDisabled']}</p>"; } echo dashlet('tasks', $dashletid, icon('task', 16), sprintf($GLOBALS['strXsTasks'], user_realname($user, TRUE)), 'tasks.php', $content); }
function gestion_donnees($sql_data, $list_fields, $tab_options, $form_name, $default_fields, $list_col_cant_del, $queryDetails, $table_name) { global $l, $protectedPost, $pages_refs; //p($tab_options['REPLACE_VALUE_ALL_TIME']); $_SESSION['OCS']['list_fields'][$table_name] = $list_fields; //requete de condition d'affichage //attention: la requete doit etre du style: //select champ1 AS FIRST from table where... if (isset($tab_options['REQUEST'])) { foreach ($tab_options['REQUEST'] as $field_name => $value) { $tab_condition[$field_name] = array(); $resultDetails = mysql2_query_secure($value, $_SESSION['OCS']["readServer"], $tab_options['ARG'][$field_name]); while ($item = mysqli_fetch_object($resultDetails)) { $tab_condition[$field_name][$item->FIRST] = $item->FIRST; } } } if (isset($sql_data)) { foreach ($sql_data as $i => $donnees) { foreach ($list_fields as $key => $value) { $htmlentities = true; $truelabel = $key; // p($tab_options); //gestion des as de colonne if (isset($tab_options['AS'][$value])) { $value = $tab_options['AS'][$value]; } //echo $value."<br>"; $num_col = $key; if ($default_fields[$key]) { $correct_list_fields[$num_col] = $num_col; } if ($list_col_cant_del[$key]) { $correct_list_col_cant_del[$num_col] = $num_col; } $alias = explode('.', $value); if (isset($alias[1])) { $no_alias_value = $alias[1]; } else { $no_alias_value = $value; } //echo $no_alias_value; //si aucune valeur, on affiche un espace if ($donnees[$no_alias_value] == "") { $value_of_field = " "; $htmlentities = false; } else { $value_of_field = $donnees[$no_alias_value]; } //utf8 or not? $value_of_field = data_encode_utf8($value_of_field); $col[$i] = $key; if ($protectedPost['sens_' . $table_name] == "ASC") { $sens = "DESC"; } else { $sens = "ASC"; } $affich = 'OK'; //on n'affiche pas de lien sur les colonnes non présentes dans la requete if (isset($tab_options['NO_TRI'][$key])) { $lien = 'KO'; } else { $lien = 'OK'; } if (isset($tab_options['REPLACE_VALUE_ALL_TIME'][$key])) { if (isset($tab_options['FIELD_REPLACE_VALUE_ALL_TIME'])) { $value_of_field = $tab_options['REPLACE_VALUE_ALL_TIME'][$key][$donnees[$tab_options['FIELD_REPLACE_VALUE_ALL_TIME']]]; } else { $value_of_field = $tab_options['REPLACE_VALUE_ALL_TIME'][$key][$donnees['ID']]; } } if (isset($tab_options['REPLACE_VALUE'][$key])) { //if multi value, $temp_val[1] isset $temp_val = explode('&&&', $value_of_field); $multi_value = 0; $temp_value_of_field = ""; while (isset($temp_val[$multi_value])) { $temp_value_of_field .= $tab_options['REPLACE_VALUE'][$key][$temp_val[$multi_value]] . "<br>"; $multi_value++; } $temp_value_of_field = substr($temp_value_of_field, 0, -4); $value_of_field = $temp_value_of_field; } if (isset($tab_options['REPLACE_WITH_CONDITION'][$key][$value_of_field])) { if (!is_array($tab_options['REPLACE_WITH_CONDITION'][$key][$value_of_field])) { $value_of_field = $tab_options['REPLACE_WITH_CONDITION'][$key][$value_of_field]; } else { foreach ($tab_options['REPLACE_WITH_CONDITION'][$key][$value_of_field] as $condition => $condition_value) { if ($donnees[$condition] == '' or is_null($donnees[$condition])) { $value_of_field = $condition_value; } } } } if (isset($tab_options['REPLACE_WITH_LIMIT']['UP'][$key])) { if ($value_of_field > $tab_options['REPLACE_WITH_LIMIT']['UP'][$key]) { $value_of_field = $tab_options['REPLACE_WITH_LIMIT']['UPVALUE'][$key]; } } if (isset($tab_options['REPLACE_WITH_LIMIT']['DOWN'][$key])) { if ($value_of_field < $tab_options['REPLACE_WITH_LIMIT']['DOWN'][$key]) { $value_of_field = $tab_options['REPLACE_WITH_LIMIT']['DOWNVALUE'][$key]; } } unset($key2); if (isset($tab_condition[$key])) { if (!$tab_condition[$key][$donnees[$tab_options['FIELD'][$key]]] and !$tab_options['EXIST'][$key] or $tab_condition[$key][$donnees[$tab_options['FIELD'][$key]]] and $tab_options['EXIST'][$key]) { if ($key == "STAT" or $key == "SUP" or $key == "CHECK") { $key2 = "NULL"; } else { $data[$i][$num_col] = $value_of_field; $affich = "KO"; } } } //if (!isset($entete[$num_col])){ if (!isset($tab_options['LBL'][$key])) { $entete[$num_col] = $key; } else { $entete[$num_col] = $tab_options['LBL'][$key]; } //} if (isset($tab_options['NO_LIEN_CHAMP']['SQL'][$key])) { $exit = false; foreach ($tab_options['NO_LIEN_CHAMP']['SQL'][$key] as $id => $sql_rest) { $sql = $sql_rest; if (isset($tab_options['NO_LIEN_CHAMP']['ARG'][$id][$key])) { $arg = $donnees[$tab_options['NO_LIEN_CHAMP']['ARG'][$id][$key]]; } else { $arg = ""; } $result_lien = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); if ($item = mysqli_fetch_object($result_lien)) { $data[$i][$num_col] = "<a href='" . $tab_options['LIEN_LBL'][$key][$id] . $donnees[$tab_options['LIEN_CHAMP'][$key][$id]] . "' target='_blank'>" . $value_of_field . "</a>"; // $exit=true; break; } else { echo 'toto'; } } } //si un lien doit être mis sur le champ //l'option $tab_options['NO_LIEN_CHAMP'] empêche de mettre un lien sur certaines //valeurs du champs //exemple, si vous ne voulez pas mettre un lien si le champ est 0, //$tab_options['NO_LIEN_CHAMP'][$key] = array(0); if (isset($tab_options['LIEN_LBL'][$key]) and !is_array($tab_options['LIEN_LBL'][$key]) and (!isset($tab_options['NO_LIEN_CHAMP'][$key]) or !in_array($value_of_field, $tab_options['NO_LIEN_CHAMP'][$key]))) { $affich = "KO"; if (!isset($tab_options['LIEN_TYPE'][$key])) { $data[$i][$num_col] = "<a href='" . $tab_options['LIEN_LBL'][$key] . $donnees[$tab_options['LIEN_CHAMP'][$key]] . "' target='_blank'>" . $value_of_field . "</a>"; } else { if (!isset($tab_options['POPUP_SIZE'][$key])) { $size = "width=550,height=350"; } else { $size = $tab_options['POPUP_SIZE'][$key]; } $data[$i][$num_col] = "<a href=\"" . $tab_options['LIEN_LBL'][$key] . $donnees[$tab_options['LIEN_CHAMP'][$key]] . "\")>" . $value_of_field . "</a>"; } } if (isset($tab_options['JAVA']['CHECK'])) { $javascript = "OnClick='confirme(\"" . htmlspecialchars($donnees[$tab_options['JAVA']['CHECK']['NAME']], ENT_QUOTES) . "\"," . $value_of_field . ",\"" . $form_name . "\",\"CONFIRM_CHECK\",\"" . htmlspecialchars($tab_options['JAVA']['CHECK']['QUESTION'], ENT_QUOTES) . " \")'"; } else { $javascript = ""; } //si on a demander un affichage que sur certaine ID if (is_array($tab_options) and !$tab_options['SHOW_ONLY'][$key][$value_of_field] and $tab_options['SHOW_ONLY'][$key]) { $key = "NULL"; } if (isset($tab_options['COLOR'][$key])) { $value_of_field = "<font color=" . $tab_options['COLOR'][$key] . ">" . $value_of_field . "</font>"; $htmlentities = false; } if ($affich == 'OK') { $lbl_column = array("SUP" => $l->g(122), "MODIF" => $l->g(115), "CHECK" => $l->g(1119) . "<input type='checkbox' name='ALL' id='ALL' Onclick='checkall();'>"); if (!isset($tab_options['NO_NAME']['NAME'])) { $lbl_column["NAME"] = $l->g(23); } //modify lbl of column if (!isset($entete[$num_col]) or $entete[$num_col] == $key and !isset($tab_options['LBL'][$key])) { if (array_key_exists($key, $lbl_column)) { $entete[$num_col] = $lbl_column[$key]; } else { $entete[$num_col] = $truelabel; } } if ($key == "NULL" or isset($key2)) { $data[$i][$num_col] = " "; $lien = 'KO'; } elseif ($key == "GROUP_NAME") { $data[$i][$num_col] = "<a href='index.php?" . PAG_INDEX . "=" . $pages_refs['ms_group_show'] . "&head=1&systemid=" . $donnees['ID'] . "' target='_blank'>" . $value_of_field . "</a>"; } elseif ($key == "SUP" and $value_of_field != ' ') { if (isset($tab_options['LBL_POPUP'][$key])) { if (isset($donnees[$tab_options['LBL_POPUP'][$key]])) { $lbl_msg = $l->g(640) . " " . $donnees[$tab_options['LBL_POPUP'][$key]]; } else { $lbl_msg = $tab_options['LBL_POPUP'][$key]; } } else { $lbl_msg = $l->g(640) . " " . $value_of_field; } $data[$i][$num_col] = "<a href=# OnClick='confirme(\"\",\"" . htmlspecialchars($value_of_field, ENT_QUOTES) . "\",\"" . $form_name . "\",\"SUP_PROF\",\"" . htmlspecialchars($lbl_msg, ENT_QUOTES) . "\");'><img src=image/delete-small.png></a>"; $lien = 'KO'; } elseif ($key == "MODIF") { if (!isset($tab_options['MODIF']['IMG'])) { $image = "image/modif_tab.png"; } else { $image = $tab_options['MODIF']['IMG']; } $data[$i][$num_col] = "<a href=# OnClick='pag(\"" . htmlspecialchars($value_of_field, ENT_QUOTES) . "\",\"MODIF\",\"" . $form_name . "\");'><img src=" . $image . "></a>"; $lien = 'KO'; } elseif ($key == "SELECT") { $data[$i][$num_col] = "<a href=# OnClick='confirme(\"\",\"" . htmlspecialchars($value_of_field, ENT_QUOTES) . "\",\"" . $form_name . "\",\"SELECT\",\"" . htmlspecialchars($tab_options['QUESTION']['SELECT'], ENT_QUOTES) . "\");'><img src=image/prec16.png></a>"; $lien = 'KO'; } elseif ($key == "OTHER") { $data[$i][$num_col] = "<a href=# OnClick='pag(\"" . htmlspecialchars($value_of_field, ENT_QUOTES) . "\",\"OTHER\",\"" . $form_name . "\");'><img src=image/red.png></a>"; $lien = 'KO'; } elseif ($key == "ZIP") { $data[$i][$num_col] = "<a href=\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_tele_compress'] . "&no_header=1×tamp=" . $value_of_field . "&type=" . $tab_options['TYPE']['ZIP'] . "\"><img src=image/archives.png></a>"; $lien = 'KO'; } elseif ($key == "STAT") { $data[$i][$num_col] = "<a href=\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_tele_stats'] . "&head=1&stat=" . $value_of_field . "\"><img src='image/stat.png'></a>"; $lien = 'KO'; } elseif ($key == "ACTIVE") { $data[$i][$num_col] = "<a href=\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_tele_popup_active'] . "&head=1&active=" . $value_of_field . "\"><img src='image/activer.png' ></a>"; $lien = 'KO'; } elseif ($key == "SHOWACTIVE") { $data[$i][$num_col] = "<a href='index.php?" . PAG_INDEX . "=" . $pages_refs['ms_tele_actives'] . "&head=1×tamp=" . $donnees['FILEID'] . "' target=_blank>" . $value_of_field . "</a>"; } elseif ($key == "CHECK" and $value_of_field != ' ') { $data[$i][$num_col] = "<input type='checkbox' name='check" . $value_of_field . "' id='check" . $value_of_field . "' " . $javascript . " " . (isset($protectedPost['check' . $value_of_field]) ? " checked " : "") . ">"; $lien = 'KO'; } elseif ($key == "NAME" and !isset($tab_options['NO_NAME']['NAME'])) { $link_computer = "index.php?" . PAG_INDEX . "=" . $pages_refs['ms_computer'] . "&head=1"; if ($donnees['ID']) { $link_computer .= "&systemid=" . $donnees['ID']; } if ($donnees['MD5_DEVICEID']) { $link_computer .= "&crypt=" . $donnees['MD5_DEVICEID']; } $data[$i][$num_col] = "<a href='" . $link_computer . "' target='_blank'>" . $value_of_field . "</a>"; } elseif ($key == "MAC") { //echo substr($value_of_field,0,8); //echo $_SESSION['OCS']["mac"][substr($value_of_field,0,8)]; if (isset($_SESSION['OCS']["mac"][mb_strtoupper(substr($value_of_field, 0, 8))])) { $constr = $_SESSION['OCS']["mac"][mb_strtoupper(substr($value_of_field, 0, 8))]; } else { $constr = "<font color=red>" . $l->g(885) . "</font>"; } //echo "=>".$constr."<br>"; $data[$i][$num_col] = $value_of_field . " (<small>" . $constr . "</small>)"; } elseif (substr($key, 0, 11) == "PERCENT_BAR") { require_once "function_graphic.php"; $data[$i][$num_col] = "<CENTER>" . percent_bar($value_of_field) . "</CENTER>"; //$lien = 'KO'; } else { if (isset($tab_options['OTHER'][$key][$value_of_field])) { $end = "<a href=# OnClick='pag(\"" . htmlspecialchars($value_of_field, ENT_QUOTES) . "\",\"OTHER\",\"" . $form_name . "\");'><img src=" . $tab_options['OTHER']['IMG'] . "></a>"; } elseif (isset($tab_options['OTHER_BIS'][$key][$value_of_field])) { $end = "<a href=# OnClick='pag(\"" . htmlspecialchars($value_of_field, ENT_QUOTES) . "\",\"OTHER_BIS\",\"" . $form_name . "\");'><img src=" . $tab_options['OTHER_BIS']['IMG'] . "></a>"; } elseif (isset($tab_options['OTHER_TER'][$key][$value_of_field])) { $end = "<a href=# OnClick='pag(\"" . htmlspecialchars($value_of_field, ENT_QUOTES) . "\",\"OTHER_TER\",\"" . $form_name . "\");'><img src=" . $tab_options['OTHER_TER']['IMG'] . "></a>"; } else { $end = ""; } if ($htmlentities) { //$value_of_field=htmlentities($value_of_field,ENT_COMPAT,'UTF-8'); $value_of_field = strip_tags_array($value_of_field); } $data[$i][$num_col] = $value_of_field . $end; } } if ($lien == 'OK') { $deb = "<a onclick='return tri(\"" . $value . "\",\"tri_" . $table_name . "\",\"" . $sens . "\",\"sens_" . $table_name . "\",\"" . $form_name . "\");' >"; $fin = "</a>"; $entete[$num_col] = $deb . $entete[$num_col] . $fin; if ($protectedPost['tri_' . $table_name] == $value) { if ($protectedPost['sens_' . $table_name] == 'ASC') { $img = "<img src='image/down.png'>"; } else { $img = "<img src='image/up.png'>"; } $entete[$num_col] = $img . $entete[$num_col]; } } } } if ($tab_options['UP']) { $i = 0; while ($data[$i]) { foreach ($tab_options['UP'] as $key => $value) { if ($data[$i][$key] == $value) { $value_temp = $data[$i]; unset($data[$i]); } } $i++; } array_unshift($data, $value_temp); } // echo $protectedPost['tri_'.$table_name]; // echo "<br><hr>"; //p($tab_options['REPLACE_VALUE']); if (isset($tab_options['REPLACE_VALUE'][$protectedPost['tri_' . $table_name]])) { //p($data); //echo "<br><hr><br>"; if ($protectedPost['sens_repart_tag'] == 'ASC') { asort($data); } else { arsort($data); } // p($data); } return array('ENTETE' => $entete, 'DATA' => $data, 'correct_list_fields' => $correct_list_fields, 'correct_list_col_cant_del' => $correct_list_col_cant_del); } else { return false; } }
/** * @author Paul Heaney * @returns string. HTML */ function stats_period_row($desc, $start, $end) { global $shade; if ($shade == '') { $shade = 'shade1'; } $count = count_incidents($start, $end); if ($count['users'] > 0) { $updatesperuser = @number_format($count['updates'] / $count['users'], 2); } else { $updatesperuser = 0; } if ($count['updated'] > 0) { $updatesperincident = @number_format($count['updates'] / $count['updated'], 2); } else { $updatesperincident = 0; } if ($count['owners'] > 0) { $incidentsperowner = @number_format($count['handled'] / $count['owners'], 2); } else { $incidentsperowner = 0; } /* $workload = $count['handled'] + $count['emailrx'] + $count['skills'] + $count['updates'] + $count['higherpriority']; $resource = $count['owners'] + $count['users'] + $count['emailtx'] + ($count['opened'] - $count['closed']); $busyrating = ($resource / $workload * 100); $busyrating = @number_format($busyrating * 4.5,1); */ if ($count['updated'] > 10) { $freshness = $count['updated'] / $count['handled'] * 100; } else { $freshness = $count['updated']; } if ($count['owners'] > 0) { $load = $count['handled'] / $count['owners'] / $count['handled'] * 100; } else { $load = 0; } if ($count['updates'] > 10) { $busyness = $count['updates'] / $count['users'] / $count['updates'] * 100; } else { $busyness = $count['updates']; } if ($count['users'] > 0 && $count['emailtx'] > 0) { $busyness2 = $count['emailtx'] / $count['users'] / $count['handled'] * 100; } else { $busyness2 = 0; } $activity = $freshness + $load + $busyness + $busyness2 / 400 * 100; $activity = @number_format($activity, 1); if ($activity > 100) { $activity = 100; } if ($activity < 0) { $activity = 0; } $html = "<tr class='{$shade}'><td>{$desc}</td>"; $html .= "<td><a href='{$_SERVER['PHP_SELF']}?mode=breakdown&query=0&start={$start}&end={$end}'>{$count['opened']}</a></td>"; $html .= "<td><a href='{$_SERVER['PHP_SELF']}?mode=breakdown&query=2&start={$start}&end={$end}'>{$count['updated']}</a></td>"; $html .= "<td><a href='{$_SERVER['PHP_SELF']}?mode=breakdown&query=1&start={$start}&end={$end}'>{$count['closed']}</a></td>"; $html .= "<td>{$count['handled']}</td>"; $html .= "<td>{$count['updates']}</td>"; $html .= "<td>{$updatesperincident}</td>"; $html .= "<td>{$count['skills']}</td>"; $html .= "<td>{$count['owners']}</td>"; $html .= "<td>{$count['users']}</td>"; $html .= "<td>{$updatesperuser}</td>"; $html .= "<td>{$incidentsperowner}</td>"; $html .= "<td>{$count['emailrx']}</td><td>{$count['emailtx']}</td>"; $html .= "<td>{$count['higherpriority']}</td>"; $html .= "<td>" . percent_bar($activity) . "</td>"; $html .= "</tr>\n"; if ($shade == 'shade1') { $shade = 'shade2'; } else { $shade = 'shade1'; } return $html; }