本文整理汇总了PHP中Dropdown::getValueWithUnit方法的典型用法代码示例。如果您正苦于以下问题:PHP Dropdown::getValueWithUnit方法的具体用法?PHP Dropdown::getValueWithUnit怎么用?PHP Dropdown::getValueWithUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dropdown
的用法示例。
在下文中一共展示了Dropdown::getValueWithUnit方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForTicket
//.........这里部分代码省略.........
//
// echo "<table class='tab_cadre_fixe'>";
// echo "<tr class='tab_bg_2'><th colspan='3'>".__('Add a project task')."</th></tr>";
//
// echo "<tr class='tab_bg_2'><td class='right'>";
// echo "<input type='hidden' name='tickets_id' value='$ID'>";
// $condition = "`glpi_projecttasks`.`projectstates_id` <> 3";
// ProjectTask::dropdown(array('used' => $used,
// 'entity' => $ticket->getEntityID(),
// 'entity_sons' => $ticket->isRecursive(),
// 'condition' => $condition,
// 'displaywith' => array('id')));
// echo "</td><td width='20%'>";
// // echo "<a href='".Toolbox::getItemTypeFormURL('ProjectTask')."?tickets_id=$ID'>";
// // _e('Create a project task from this ticket');
// // echo "</a>";
// echo "</td><td class='center'>";
// echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>";
// echo "</td></tr>";
//
// echo "</table>";
// Html::closeForm();
// echo "</div>";
// }
echo "<div class='spaced'>";
if ($numrows) {
$columns = array('projectname' => Project::getTypeName(Session::getPluralNumber()), 'name' => ProjectTask::getTypeName(Session::getPluralNumber()), 'tname' => __('Type'), 'sname' => __('Status'), 'percent_done' => __('Percent done'), 'plan_start_date' => __('Planned start date'), 'plan_end_date' => __('Planned end date'), 'planned_duration' => __('Planned duration'), '_effect_duration' => __('Effective duration'), 'fname' => __('Father'));
if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
$order = "DESC";
} else {
$order = "ASC";
}
if (!isset($_GET["sort"]) || empty($_GET["sort"])) {
$_GET["sort"] = "plan_start_date";
}
if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) {
$sort = "`" . $_GET["sort"] . "`";
} else {
$sort = "`plan_start_date` {$order}, `name`";
}
$query = "SELECT `glpi_projecttasks`.*,\n `glpi_projecttasktypes`.`name` AS tname,\n `glpi_projectstates`.`name` AS sname,\n `glpi_projectstates`.`color`,\n `father`.`name` AS fname,\n `father`.`id` AS fID,\n `glpi_projects`.`name` AS projectname,\n `glpi_projects`.`content` AS projectcontent\n FROM `glpi_projecttasks`\n LEFT JOIN `glpi_projecttasktypes`\n ON (`glpi_projecttasktypes`.`id` = `glpi_projecttasks`.`projecttasktypes_id`)\n LEFT JOIN `glpi_projectstates`\n ON (`glpi_projectstates`.`id` = `glpi_projecttasks`.`projectstates_id`)\n LEFT JOIN `glpi_projecttasks` as father\n ON (`father`.`id` = `glpi_projecttasks`.`projecttasks_id`)\n LEFT JOIN `glpi_projecttasks_tickets`\n ON (`glpi_projecttasks_tickets`.`projecttasks_id` = `glpi_projecttasks`.`id`)\n LEFT JOIN `glpi_projects`\n ON (`glpi_projecttasks`.`projects_id` = `glpi_projects`.`id`)\n WHERE `glpi_projecttasks_tickets`.`tickets_id` = '{$ID}'\n ORDER BY {$sort} {$order}";
Session::initNavigateListItems('ProjectTask', sprintf(__('%1$s = %2$s'), $ticket::getTypeName(1), $ticket->getName()));
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='10'>" . ProjectTask::getTypeName($numrows) . "</th>";
echo "</tr>";
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
$header = '<tr>';
foreach ($columns as $key => $val) {
// Non order column
if ($key[0] == '_') {
$header .= "<th>{$val}</th>";
} else {
$header .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>";
}
}
$header .= "</tr>\n";
echo $header;
while ($data = $DB->fetch_assoc($result)) {
Session::addToNavigateListItems('ProjectTask', $data['id']);
$rand = mt_rand();
echo "<tr class='tab_bg_2'>";
echo "<td>";
$link = "<a id='Project" . $data["projects_id"] . $rand . "' href='project.form.php?id=" . $data['projects_id'] . "'>" . $data['projectname'] . (empty($data['projectname']) ? "(" . $data['projects_id'] . ")" : "") . "</a>";
echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['projectcontent'], array('display' => false, 'applyto' => "Project" . $data["projects_id"] . $rand)));
echo "</td>";
echo "<td>";
$link = "<a id='ProjectTask" . $data["id"] . $rand . "' href='projecttask.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a>";
echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['content'], array('display' => false, 'applyto' => "ProjectTask" . $data["id"] . $rand)));
echo "</td>";
echo "<td>" . $data['tname'] . "</td>";
echo "<td";
echo " style=\"background-color:" . $data['color'] . "\"";
echo ">" . $data['sname'] . "</td>";
echo "<td>";
echo Dropdown::getValueWithUnit($data["percent_done"], "%");
echo "</td>";
echo "<td>" . Html::convDateTime($data['plan_start_date']) . "</td>";
echo "<td>" . Html::convDateTime($data['plan_end_date']) . "</td>";
echo "<td>" . Html::timestampToString($data['planned_duration'], false) . "</td>";
echo "<td>" . Html::timestampToString(ProjectTask::getTotalEffectiveDuration($data['id']), false) . "</td>";
echo "<td>";
if ($data['projecttasks_id'] > 0) {
$father = Dropdown::getDropdownName('glpi_projecttasks', $data['projecttasks_id']);
echo "<a id='ProjectTask" . $data["projecttasks_id"] . $rand . "' href='projecttask.form.php?id=" . $data['projecttasks_id'] . "'>" . $father . (empty($father) ? "(" . $data['projecttasks_id'] . ")" : "") . "</a>";
}
echo "</td></tr>";
}
echo $header;
echo "</table>\n";
} else {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table>\n";
}
}
echo "</div>";
}
}
示例2: giveItem
//.........这里部分代码省略.........
$function = 'plugin_' . $plug . '_giveItem';
if (function_exists($function)) {
$out = $function($itemtype, $ID, $data, $num);
if (!empty($out)) {
return $out;
}
}
}
}
}
$unit = '';
if (isset($searchopt[$ID]['unit'])) {
$unit = $searchopt[$ID]['unit'];
}
// Preformat items
if (isset($searchopt[$ID]["datatype"])) {
switch ($searchopt[$ID]["datatype"]) {
case "itemlink":
$linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]);
$out = "";
$count_display = 0;
$separate = self::LBBR;
if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
$separate = self::LBHR;
}
for ($k = 0; $k < $data[$num]['count']; $k++) {
if (isset($data[$num][$k]['id'])) {
if ($count_display) {
$out .= $separate;
}
$count_display++;
$page = $linkitemtype::getFormUrl();
$page .= strpos($page, '?') ? '&id' : '?id';
$name = Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit);
if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][$k]['name'])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][$k]['id']);
}
$out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $data[$num][$k]['id'] . "' href='{$page}=" . $data[$num][$k]['id'] . "'>" . $name . "</a>";
}
}
return $out;
case "text":
$separate = self::LBBR;
if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
$separate = self::LBHR;
}
$out = '';
$count_display = 0;
for ($k = 0; $k < $data[$num]['count']; $k++) {
if (strlen(trim($data[$num][$k]['name'])) > 0) {
if ($count_display) {
$out .= $separate;
}
$count_display++;
$text = "";
if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) {
$text = Html::clean(Toolbox::unclean_cross_side_scripting_deep(nl2br($data[$num][$k]['name'])));
} else {
$text = nl2br($data[$num][$k]['name']);
}
if (self::$output_type == self::HTML_OUTPUT && Toolbox::strlen($text) > $CFG_GLPI['cut']) {
$rand = mt_rand();
$out .= sprintf(__('%1$s %2$s'), "<span id='text{$rand}'>" . Html::resume_text($text, $CFG_GLPI['cut']) . '</span>', Html::showToolTip($text, array('applyto' => "text{$rand}", 'display' => false)));
} else {
$out .= $text;
}
示例3: getSpecificValueToDisplay
static function getSpecificValueToDisplay($field, $values, array $options = array())
{
global $CFG_GLPI;
if (!is_array($values)) {
$values = array($field => $values);
}
switch ($field) {
case "id":
self::$currentItem = new PluginMonitoringUnavailability();
self::$currentItem->getFromDB($values[$field]);
break;
case "name":
return "test";
break;
case "scheduled":
$out = Dropdown::getValueWithUnit(Dropdown::getYesNo($values[$field]), '');
if (Session::haveRight("plugin_monitoring_acknowledge", READ)) {
$newValue = self::$currentItem->fields['scheduled'] == '0' ? '1' : '0';
$out .= " ";
$out .= "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/unavailability.form.php?id=" . self::$currentItem->fields['id'] . "&scheduled=" . $newValue . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_checked.png'" . " alt='" . __('Change unavailability period schedule status', 'monitoring') . "'" . " title='" . __('Change unavailability period schedule status', 'monitoring') . "'" . " width='20' height='20'/>" . "</a>";
}
return $out;
}
return '';
}
示例4: getActionValue
/**
* Return a "display" value associated with a pattern associated to a criteria
*
* @param $ID the given action
* @param $type the type of action
* @param $value the value
**/
function getActionValue($ID, $type, $value)
{
$action = $this->getAction($ID);
if (isset($action['type'])) {
switch ($action['type']) {
case "dropdown":
if ($type == 'fromuser' || $type == 'fromitem') {
return Dropdown::getYesNo($value);
}
// $type == assign
$tmp = Dropdown::getDropdownName($action["table"], $value);
return $tmp == ' ' ? NOT_AVAILABLE : $tmp;
case "dropdown_status":
return Ticket::getStatus($value);
case "dropdown_assign":
case "dropdown_users":
case "dropdown_users_validate":
return getUserName($value);
case "dropdown_groups_validate":
return Dropdown::getDropdownName('glpi_groups', $value);
case "dropdown_validation_percent":
return Dropdown::getValueWithUnit($value, '%');
case "yesonly":
case "yesno":
return Dropdown::getYesNo($value);
case "dropdown_urgency":
return Ticket::getUrgencyName($value);
case "dropdown_impact":
return Ticket::getImpactName($value);
case "dropdown_priority":
return Ticket::getPriorityName($value);
case "dropdown_tickettype":
return Ticket::getTicketTypeName($value);
case "dropdown_management":
return Dropdown::getGlobalSwitch($value);
default:
return $this->displayAdditionRuleActionValue($value);
}
}
return $value;
}
示例5: array_splice
for ($i = $_POST['min']; $i <= $_POST['max']; $i += $_POST['step']) {
$values[$i] = $i;
}
}
if ($one_item < 0 && count($values)) {
$start = ($_POST['page'] - 1) * $_POST['page_limit'];
$tosend = array_splice($values, $start, $_POST['page_limit']);
foreach ($tosend as $i) {
$txt = $i;
if (isset($_POST['unit'])) {
$txt = Dropdown::getValueWithUnit($i, $_POST['unit']);
}
array_push($datas, array('id' => $i, 'text' => strval($txt)));
$count++;
}
} else {
if (!isset($toadd[$one_item])) {
if (isset($_POST['unit'])) {
$txt = Dropdown::getValueWithUnit($one_item, $_POST['unit']);
}
array_push($datas, array('id' => $one_item, 'text' => strval(stripslashes($txt))));
$count++;
}
}
if ($one_item >= 0 && isset($datas[0])) {
echo json_encode($datas[0]);
} else {
$ret['results'] = $datas;
$ret['count'] = $count;
echo json_encode($ret);
}
示例6: getDatasForTemplate
/**
* @see NotificationTarget::getDatasForTemplate()
**/
function getDatasForTemplate($event, $options = array())
{
global $CFG_GLPI, $DB;
//----------- Reservation infos -------------- //
$events = $this->getAllEvents();
$item = $this->obj;
$this->datas['##projecttask.action##'] = $events[$event];
$this->datas['##projecttask.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "ProjectTask_" . $item->getField("id"));
$this->datas["##projecttask.name##"] = $item->getField('name');
$this->datas["##projecttask.project##"] = Dropdown::getDropdownName('glpi_projects', $item->getField('projects_id'));
$this->datas["##projecttask.projecturl##"] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("projects_id"));
$this->datas["##projecttask.description##"] = $item->getField('content');
$this->datas["##projecttask.comments##"] = $item->getField('comment');
$this->datas["##projecttask.creationdate##"] = Html::convDateTime($item->getField('date'));
$this->datas["##projecttask.lastupdatedate##"] = Html::convDateTime($item->getField('date_mod'));
$this->datas["##projecttask.percent##"] = Dropdown::getValueWithUnit($item->getField('percent_done'), "%");
$this->datas["##projecttask.planstartdate##"] = Html::convDateTime($item->getField('plan_start_date'));
$this->datas["##projecttask.planenddate##"] = Html::convDateTime($item->getField('plan_end_date'));
$this->datas["##projecttask.realstartdate##"] = Html::convDateTime($item->getField('real_start_date'));
$this->datas["##projecttask.realenddate##"] = Html::convDateTime($item->getField('real_end_date'));
$this->datas["##projecttask.plannedduration##"] = Html::timestampToString($item->getField('planned_duration'), false);
$this->datas["##projecttask.effectiveduration##"] = Html::timestampToString($item->getField('effective_duration'), false);
$ticket_duration = ProjectTask_Ticket::getTicketsTotalActionTime($item->getID());
$this->datas["##projecttask.ticketsduration##"] = Html::timestampToString($ticket_duration, false);
$this->datas["##projecttask.totalduration##"] = Html::timestampToString($ticket_duration + $item->getField('effective_duration'), false);
$entity = new Entity();
$this->datas["##projecttask.entity##"] = '';
$this->datas["##projecttask.shortentity##"] = '';
if ($entity->getFromDB($this->getEntity())) {
$this->datas["##projecttask.entity##"] = $entity->getField('completename');
$this->datas["##projecttask.shortentity##"] = $entity->getField('name');
}
$this->datas["##projecttask.father##"] = '';
if ($item->getField('projecttasks_id')) {
$this->datas["##projecttask.father##"] = Dropdown::getDropdownName('glpi_projecttasks', $item->getField('projecttasks_id'));
}
$this->datas["##projecttask.state##"] = '';
if ($item->getField('projectstates_id')) {
$this->datas["##projecttask.state##"] = Dropdown::getDropdownName('glpi_projectstates', $item->getField('projectstates_id'));
}
$this->datas["##projecttask.type##"] = '';
if ($item->getField('projecttasktypes_id')) {
$this->datas["##projecttask.type##"] = Dropdown::getDropdownName('glpi_projecttasktypes', $item->getField('projecttasktypes_id'));
}
$this->datas["##projecttask.createbyuser##"] = '';
if ($item->getField('users_id')) {
$user_tmp = new User();
$user_tmp->getFromDB($item->getField('users_id'));
$this->datas["##projecttask.createbyuser##"] = $user_tmp->getName();
}
// Team infos
$restrict = "`projecttasks_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_projecttaskteams', $restrict);
$this->datas['teammembers'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##teammember.itemtype##'] = $item2->getTypeName();
$tmp['##teammember.name##'] = $item2->getName();
$this->datas['teammembers'][] = $tmp;
}
}
}
}
$this->datas['##projecttask.numberofteammembers##'] = count($this->datas['teammembers']);
// Task infos
$restrict = "`projecttasks_id`='" . $item->getField('id') . "'";
$restrict .= " ORDER BY `date` DESC, `id` ASC";
$tasks = getAllDatasFromTable('glpi_projecttasks', $restrict);
$this->datas['tasks'] = array();
foreach ($tasks as $task) {
$tmp = array();
$tmp['##task.creationdate##'] = Html::convDateTime($task['date']);
$tmp['##task.lastupdatedate##'] = Html::convDateTime($task['date_mod']);
$tmp['##task.name##'] = $task['name'];
$tmp['##task.description##'] = $task['content'];
$tmp['##task.comments##'] = $task['comment'];
$tmp['##task.state##'] = Dropdown::getDropdownName('glpi_projectstates', $task['projectstates_id']);
$tmp['##task.type##'] = Dropdown::getDropdownName('glpi_projecttasktypes', $task['projecttasktypes_id']);
$tmp['##task.percent##'] = Dropdown::getValueWithUnit($task['percent_done'], "%");
$this->datas["##task.planstartdate##"] = '';
$this->datas["##task.planenddate##"] = '';
$this->datas["##task.realstartdate##"] = '';
$this->datas["##task.realenddate##"] = '';
if (!is_null($task['plan_start_date'])) {
$tmp['##task.planstartdate##'] = Html::convDateTime($task['plan_start_date']);
}
if (!is_null($task['plan_end_date'])) {
$tmp['##task.planenddate##'] = Html::convDateTime($task['plan_end_date']);
}
if (!is_null($task['real_start_date'])) {
$tmp['##task.realstartdate##'] = Html::convDateTime($task['real_start_date']);
}
if (!is_null($task['real_end_date'])) {
$tmp['##task.realenddate##'] = Html::convDateTime($task['real_end_date']);
//.........这里部分代码省略.........
示例7: showFor
//.........这里部分代码省略.........
$sort = "`plan_start_date` {$order}, `name`";
}
$canedit = false;
if ($item->getType() == 'Project') {
$canedit = $item->canEdit($ID);
}
switch ($item->getType()) {
case 'Project':
$where = "WHERE `glpi_projecttasks`.`projects_id` = '{$ID}'";
break;
case 'ProjectTask':
$where = "WHERE `glpi_projecttasks`.`projecttasks_id` = '{$ID}'";
break;
default:
// Not available type
return;
}
echo "<div class='spaced'>";
if ($canedit) {
echo "<div class='center firstbloc'>";
echo "<a class='vsubmit' href='projecttask.form.php?projects_id={$ID}'>" . _x('button', 'Add a task') . "</a>";
echo "</div>";
}
if ($item->getType() == 'ProjectTask' && $item->can($ID, UPDATE)) {
$rand = mt_rand();
echo "<div class='firstbloc'>";
echo "<form name='projecttask_form{$rand}' id='projecttask_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('ProjectTask') . "'>";
$projet = $item->fields['projects_id'];
echo "<a href='" . Toolbox::getItemTypeFormURL('ProjectTask') . "?projecttasks_id={$ID}&projects_id={$projet}'>";
_e('Create a sub task from this task of project');
echo "</a>";
Html::closeForm();
echo "</div>";
}
$addselect = '';
$addjoin = '';
if (Session::haveTranslations('ProjectTaskType', 'name')) {
$addselect .= ", `namet2`.`value` AS transname2";
$addjoin .= " LEFT JOIN `glpi_dropdowntranslations` AS namet2\n ON (`namet2`.`itemtype` = 'ProjectTaskType'\n AND `namet2`.`items_id` = `glpi_projecttasks`.`projecttasktypes_id`\n AND `namet2`.`language` = '" . $_SESSION['glpilanguage'] . "'\n AND `namet2`.`field` = 'name')";
}
if (Session::haveTranslations('ProjectState', 'name')) {
$addselect .= ", `namet3`.`value` AS transname3";
$addjoin .= "LEFT JOIN `glpi_dropdowntranslations` AS namet3\n ON (`namet3`.`itemtype` = 'ProjectState'\n AND `namet3`.`language` = '" . $_SESSION['glpilanguage'] . "'\n AND `namet3`.`field` = 'name')";
$where .= " AND `namet3`.`items_id` = `glpi_projectstates`.`id` ";
}
$query = "SELECT `glpi_projecttasks`.*,\n `glpi_projecttasktypes`.`name` AS tname,\n `glpi_projectstates`.`name` AS sname,\n `glpi_projectstates`.`color`,\n `father`.`name` AS fname,\n `father`.`id` AS fID\n {$addselect}\n FROM `glpi_projecttasks`\n {$addjoin}\n LEFT JOIN `glpi_projecttasktypes`\n ON (`glpi_projecttasktypes`.`id` = `glpi_projecttasks`.`projecttasktypes_id`)\n LEFT JOIN `glpi_projectstates`\n ON (`glpi_projectstates`.`id` = `glpi_projecttasks`.`projectstates_id`)\n LEFT JOIN `glpi_projecttasks` as father\n ON (`father`.`id` = `glpi_projecttasks`.`projecttasks_id`)\n {$where}\n ORDER BY {$sort} {$order}";
Session::initNavigateListItems('ProjectTask', sprintf(__('%1$s = %2$s'), $item::getTypeName(1), $item->getName()));
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
echo "<table class='tab_cadre_fixehov'>";
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
$header = '<tr>';
foreach ($columns as $key => $val) {
// Non order column
if ($key[0] == '_') {
$header .= "<th>{$val}</th>";
} else {
$header .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>";
}
}
$header .= "</tr>\n";
echo $header;
while ($data = $DB->fetch_assoc($result)) {
Session::addToNavigateListItems('ProjectTask', $data['id']);
$rand = mt_rand();
echo "<tr class='tab_bg_2'>";
echo "<td>";
$link = "<a id='ProjectTask" . $data["id"] . $rand . "' href='projecttask.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a>";
echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['content'], array('display' => false, 'applyto' => "ProjectTask" . $data["id"] . $rand)));
echo "</td>";
$name = !empty($data['transname2']) ? $data['transname2'] : $data['tname'];
echo "<td>" . $name . "</td>";
echo "<td";
$statename = !empty($data['transname3']) ? $data['transname3'] : $data['sname'];
echo " style=\"background-color:" . $data['color'] . "\"";
echo ">" . $statename . "</td>";
echo "<td>";
echo Dropdown::getValueWithUnit($data["percent_done"], "%");
echo "</td>";
echo "<td>" . Html::convDateTime($data['plan_start_date']) . "</td>";
echo "<td>" . Html::convDateTime($data['plan_end_date']) . "</td>";
echo "<td>" . Html::timestampToString($data['planned_duration'], false) . "</td>";
echo "<td>" . Html::timestampToString(self::getTotalEffectiveDuration($data['id']), false) . "</td>";
echo "<td>";
if ($data['projecttasks_id'] > 0) {
$father = Dropdown::getDropdownName('glpi_projecttasks', $data['projecttasks_id']);
echo "<a id='ProjectTask" . $data["projecttasks_id"] . $rand . "' href='projecttask.form.php?id=" . $data['projecttasks_id'] . "'>" . $father . (empty($father) ? "(" . $data['projecttasks_id'] . ")" : "") . "</a>";
}
echo "</td></tr>";
}
echo $header;
echo "</table>\n";
} else {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table>\n";
}
}
echo "</div>";
}
示例8: giveItem
//.........这里部分代码省略.........
//// Default case
// Link with plugin tables : need to know left join structure
if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) {
if (count($matches) == 2) {
$plug = $matches[1];
$function = 'plugin_' . $plug . '_giveItem';
if (function_exists($function)) {
$out = $function($itemtype, $ID, $data, $num);
if (!empty($out)) {
return $out;
}
}
}
}
$unit = '';
if (isset($searchopt[$ID]['unit'])) {
$unit = $searchopt[$ID]['unit'];
}
/// TODO try to use getvalueToDisplay instead of redefine display system
// Preformat items
if (isset($searchopt[$ID]["datatype"])) {
switch ($searchopt[$ID]["datatype"]) {
case "itemlink":
$linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]);
if (isset($data[$NAME . $num . "_2"]) && strlen($data[$NAME . $num . "_2"])) {
$link = Toolbox::getItemTypeFormURL($linkitemtype);
$out = "<a id='" . $itemtype . "_" . $data[$NAME . $num . "_2"] . "' href=\"" . $link;
$out .= strstr($link, '?') ? '&' : '?';
$out .= 'id=' . $data[$NAME . $num . "_2"];
if (isset($searchopt[$ID]['forcetab'])) {
$out .= "&forcetab=" . $searchopt[$ID]['forcetab'];
}
$out .= "\">";
$name = Dropdown::getValueWithUnit($data[$NAME . $num], $unit);
if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $data[$NAME . $num . "_2"]);
}
$out .= $name . "</a>";
return $out;
}
$out = "";
$split = explode("\$\$\$\$", $data[$NAME . $num]);
$count_display = 0;
$separate = '<br>';
if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
$separate = '<hr>';
}
for ($k = 0; $k < count($split); $k++) {
if (strlen(trim($split[$k])) > 0) {
$split2 = self::explodeWithID("\$\$", $split[$k]);
if (isset($split2[1]) && $split2[1] > 0) {
if ($count_display) {
$out .= $separate;
}
$count_display++;
$page = Toolbox::getItemTypeFormURL($linkitemtype);
$page .= strpos($page, '?') ? '&id' : '?id';
$name = Dropdown::getValueWithUnit($split2[0], $unit);
if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $split2[1]);
}
$out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $split2[1] . "' href='{$page}=" . $split2[1] . "'>" . $name . "</a>";
}
}
}
return $out;
示例9: showSummary
/**
* Print the validation list into item
*
* @param $item class
**/
function showSummary($item)
{
global $DB, $CFG_GLPI;
if (!Session::haveRightsOr(static::$rightname, array_merge(static::getCreateRights(), static::getValidateRights(), static::getPurgeRights()))) {
return false;
}
$tID = $item->fields['id'];
$tmp = array(static::$items_id => $tID);
$canadd = $this->can(-1, CREATE, $tmp);
$rand = mt_rand();
if ($canadd) {
echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(static::$itemtype) . "'>";
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th colspan='3'>" . self::getTypeName(Session::getPluralNumber()) . "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Global approval status') . "</td>";
echo "<td colspan='2'>";
if (Session::haveRightsOr(static::$rightname, TicketValidation::getCreateRights())) {
self::dropdownStatus("global_validation", array('value' => $item->fields["global_validation"]));
} else {
echo TicketValidation::getStatus($item->fields["global_validation"]);
}
echo "</td></tr>";
echo "<tr>";
echo "<th colspan='2'>" . _x('item', 'State') . "</th>";
echo "<th colspan='2'>";
echo self::getValidationStats($tID);
echo "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Minimum validation required') . "</td>";
if ($canadd) {
echo "<td>";
echo $item->getValueToSelect('validation_percent', 'validation_percent', $item->fields["validation_percent"]);
echo "</td>";
echo "<td><input type='submit' name='update' class='submit' value='" . _sx('button', 'Save') . "'>";
if (!empty($tID)) {
echo "<input type='hidden' name='id' value='{$tID}'>";
}
echo "</td>";
} else {
echo "<td colspan='2'>";
echo Dropdown::getValueWithUnit($item->fields["validation_percent"], "%");
echo "</td>";
}
echo "</tr>";
echo "</table>";
if ($canadd) {
Html::closeForm();
}
echo "<div id='viewvalidation" . $tID . "{$rand}'></div>\n";
if ($canadd) {
echo "<script type='text/javascript' >\n";
echo "function viewAddValidation" . $tID . "{$rand}() {\n";
$params = array('type' => $this->getType(), 'parenttype' => static::$itemtype, static::$items_id => $tID, 'id' => -1);
Ajax::updateItemJsCode("viewvalidation" . $tID . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
if (!in_array($item->fields['status'], array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray()))) {
echo "<div class='center'>";
echo "<a class='vsubmit' href='javascript:viewAddValidation" . $tID . "{$rand}();'>";
echo __('Send an approval request') . "</a></div><br>\n";
}
}
$query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `" . static::$items_id . "` = '" . $item->getField('id') . "'";
if (!$canadd) {
$query .= " AND `users_id_validate` = '" . Session::getLoginUserID() . "'";
}
$query .= " ORDER BY submission_date DESC";
$result = $DB->query($query);
$number = $DB->numrows($result);
if ($number) {
$colonnes = array(_x('item', 'State'), __('Request date'), __('Approval requester'), __('Request comments'), __('Approval status'), __('Approver'), __('Approval comments'));
$nb_colonnes = count($colonnes);
echo "<table class='tab_cadre_fixehov'>";
echo "<tr class='noHover'><th colspan='" . $nb_colonnes . "'>" . __('Approvals for the ticket') . "</th></tr>";
$header = "<tr>";
foreach ($colonnes as $colonne) {
$header .= "<th>" . $colonne . "</th>";
}
$header .= "</tr>";
echo $header;
Session::initNavigateListItems($this->getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->fields["name"]));
while ($row = $DB->fetch_assoc($result)) {
$canedit = $this->canEdit($row["id"]);
Session::addToNavigateListItems($this->getType(), $row["id"]);
$bgcolor = self::getStatusColor($row['status']);
$status = self::getStatus($row['status']);
echo "<tr class='tab_bg_1' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditValidation" . $item->fields['id'] . $row["id"] . "{$rand}();\"" : '') . " id='viewvalidation" . $this->fields[static::$items_id] . $row["id"] . "{$rand}'>";
echo "<td>";
if ($canedit) {
echo "\n<script type='text/javascript' >\n";
//.........这里部分代码省略.........
示例10: getDatasForTemplate
/**
* @see NotificationTarget::getDatasForTemplate()
**/
function getDatasForTemplate($event, $options = array())
{
global $CFG_GLPI, $DB;
//----------- Reservation infos -------------- //
$events = $this->getAllEvents();
$item = $this->obj;
$this->datas['##project.action##'] = $events[$event];
$this->datas['##project.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("id"));
$this->datas["##project.name##"] = $item->getField('name');
$this->datas["##project.code##"] = $item->getField('code');
$this->datas["##project.description##"] = $item->getField('content');
$this->datas["##project.comments##"] = $item->getField('comment');
$this->datas["##project.creationdate##"] = Html::convDateTime($item->getField('date'));
$this->datas["##project.lastupdatedate##"] = Html::convDateTime($item->getField('date_mod'));
$this->datas["##project.priority##"] = CommonITILObject::getPriorityName($item->getField('priority'));
$this->datas["##project.percent##"] = Dropdown::getValueWithUnit($item->getField('percent_done'), "%");
$this->datas["##project.planstartdate##"] = Html::convDateTime($item->getField('plan_start_date'));
$this->datas["##project.planenddate##"] = Html::convDateTime($item->getField('plan_end_date'));
$this->datas["##project.realstartdate##"] = Html::convDateTime($item->getField('real_start_date'));
$this->datas["##project.realenddate##"] = Html::convDateTime($item->getField('real_end_date'));
$this->datas["##project.plannedduration##"] = Html::timestampToString(ProjectTask::getTotalPlannedDurationForProject($item->getID()), false);
$this->datas["##project.effectiveduration##"] = Html::timestampToString(ProjectTask::getTotalEffectiveDurationForProject($item->getID()), false);
$entity = new Entity();
$this->datas["##project.entity##"] = '';
$this->datas["##project.shortentity##"] = '';
if ($entity->getFromDB($this->getEntity())) {
$this->datas["##project.entity##"] = $entity->getField('completename');
$this->datas["##project.shortentity##"] = $entity->getField('name');
}
$this->datas["##project.father##"] = '';
if ($item->getField('projects_id')) {
$this->datas["##project.father##"] = Dropdown::getDropdownName('glpi_projects', $item->getField('projects_id'));
}
$this->datas["##project.state##"] = '';
if ($item->getField('projectstates_id')) {
$this->datas["##project.state##"] = Dropdown::getDropdownName('glpi_projectstates', $item->getField('projectstates_id'));
}
$this->datas["##project.type##"] = '';
if ($item->getField('projecttypes_id')) {
$this->datas["##project.type##"] = Dropdown::getDropdownName('glpi_projecttypes', $item->getField('projecttypes_id'));
}
$this->datas["##project.manager##"] = '';
if ($item->getField('users_id')) {
$user_tmp = new User();
$user_tmp->getFromDB($item->getField('users_id'));
$this->datas["##project.manager##"] = $user_tmp->getName();
}
$this->datas["##project.managergroup##"] = '';
if ($item->getField('groups_id')) {
$this->datas["##project.managergroup##"] = Dropdown::getDropdownName('glpi_groups', $item->getField('groups_id'));
}
// Team infos
$restrict = "`projects_id` = '" . $item->getField('id') . "'";
$items = getAllDatasFromTable('glpi_projectteams', $restrict);
$this->datas['teammembers'] = array();
if (count($items)) {
foreach ($items as $data) {
if ($item2 = getItemForItemtype($data['itemtype'])) {
if ($item2->getFromDB($data['items_id'])) {
$tmp = array();
$tmp['##teammember.itemtype##'] = $item2->getTypeName();
$tmp['##teammember.name##'] = $item2->getName();
$this->datas['teammembers'][] = $tmp;
}
}
}
}
$this->datas['##project.numberofteammembers##'] = count($this->datas['teammembers']);
// Task infos
$restrict = "`projects_id`='" . $item->getField('id') . "'";
$restrict .= " ORDER BY `date` DESC, `id` ASC";
$tasks = getAllDatasFromTable('glpi_projecttasks', $restrict);
$this->datas['tasks'] = array();
foreach ($tasks as $task) {
$tmp = array();
$tmp['##task.creationdate##'] = Html::convDateTime($task['date']);
$tmp['##task.lastupdatedate##'] = Html::convDateTime($task['date_mod']);
$tmp['##task.name##'] = $task['name'];
$tmp['##task.description##'] = $task['content'];
$tmp['##task.comments##'] = $task['comment'];
$tmp['##task.state##'] = Dropdown::getDropdownName('glpi_projectstates', $task['projectstates_id']);
$tmp['##task.type##'] = Dropdown::getDropdownName('glpi_projecttasktypes', $task['projecttasktypes_id']);
$tmp['##task.percent##'] = Dropdown::getValueWithUnit($task['percent_done'], "%");
$this->datas["##task.planstartdate##"] = '';
$this->datas["##task.planenddate##"] = '';
$this->datas["##task.realstartdate##"] = '';
$this->datas["##task.realenddate##"] = '';
if (!is_null($task['plan_start_date'])) {
$tmp['##task.planstartdate##'] = Html::convDateTime($task['plan_start_date']);
}
if (!is_null($task['plan_end_date'])) {
$tmp['##task.planenddate##'] = Html::convDateTime($task['plan_end_date']);
}
if (!is_null($task['real_start_date'])) {
$tmp['##task.realstartdate##'] = Html::convDateTime($task['real_start_date']);
}
if (!is_null($task['real_end_date'])) {
//.........这里部分代码省略.........
示例11: getValueToDisplay
/**
* display a field using standard system
*
* @since version 0.83
*
* @param $field_id_or_search_options integer/string/array id of the search option field
* or field name
* or search option array
* @param $values mixed value to display
* @param $options array of possible options:
* Parameters which could be used in options array :
* - comments : boolean / is the comments displayed near the value (default false)
* - any others options passed to specific display method
*
* @return return the string to display
**/
function getValueToDisplay($field_id_or_search_options, $values, $options = array())
{
global $CFG_GLPI;
$param['comments'] = false;
$param['html'] = false;
foreach ($param as $key => $val) {
if (!isset($options[$key])) {
$options[$key] = $val;
}
}
$searchoptions = array();
if (is_array($field_id_or_search_options)) {
$searchoptions = $field_id_or_search_options;
} else {
$searchopt = $this->getSearchOptions();
// Get if id of search option is passed
if (is_numeric($field_id_or_search_options)) {
if (isset($searchopt[$field_id_or_search_options])) {
$searchoptions = $searchopt[$field_id_or_search_options];
}
} else {
// Get if field name is passed
$searchoptions = $this->getSearchOptionByField('field', $field_id_or_search_options, $this->getTable());
}
}
if (count($searchoptions)) {
$field = $searchoptions['field'];
// Normalize option
if (is_array($values)) {
$value = $values[$field];
} else {
$value = $values;
$values = array($field => $value);
}
if (isset($searchoptions['datatype'])) {
$unit = '';
if (isset($searchoptions['unit'])) {
$unit = $searchoptions['unit'];
}
switch ($searchoptions['datatype']) {
case "count":
case "number":
if (isset($searchoptions['toadd']) && isset($searchoptions['toadd'][$value])) {
return $searchoptions['toadd'][$value];
}
if ($options['html']) {
return Dropdown::getValueWithUnit(Html::formatNumber($value, false, 0), $unit);
}
return $value;
case "decimal":
if ($options['html']) {
return Dropdown::getValueWithUnit(Html::formatNumber($value), $unit);
}
return $value;
case "string":
case "mac":
case "ip":
return $value;
case "text":
if ($options['html']) {
$text = nl2br($value);
} else {
$text = $value;
}
if (isset($searchoptions['htmltext']) && $searchoptions['htmltext']) {
$text = Html::clean(Toolbox::unclean_cross_side_scripting_deep($text));
}
return $text;
case "bool":
return Dropdown::getYesNo($value);
case "date":
case "date_delay":
if (isset($options['relative_dates']) && $options['relative_dates']) {
$dates = Html::getGenericDateTimeSearchItems(array('with_time' => true, 'with_future' => true));
return $dates[$value];
}
return Html::convDate(Html::computeGenericDateTimeSearch($value, true));
case "datetime":
if (isset($options['relative_dates']) && $options['relative_dates']) {
$dates = Html::getGenericDateTimeSearchItems(array('with_time' => true, 'with_future' => true));
return $dates[$value];
}
return Html::convDateTime(Html::computeGenericDateTimeSearch($value, false));
case "timestamp":
//.........这里部分代码省略.........
示例12: getWidgetContentForItem
function getWidgetContentForItem($widgetId)
{
global $CFG_GLPI, $DB;
if (empty($this->form)) {
$this->init();
}
switch ($widgetId) {
case $this->getType() . "1":
$plugin = new Plugin();
if ($plugin->isActivated("tasklists")) {
$widget = new PluginMydashboardDatatable();
$headers = array(__('Name'), __('Priority'), _n('Context', 'Contexts', 1, 'tasklists'), __('User'), __('Percent done'), __('Due date'), __('Action'));
$query = "SELECT `glpi_plugin_tasklists_tasks`.*,`glpi_plugin_tasklists_tasktypes`.`completename` as 'type' \n FROM `glpi_plugin_tasklists_tasks`\n LEFT JOIN `glpi_plugin_tasklists_tasktypes` ON (`glpi_plugin_tasklists_tasks`.`plugin_tasklists_tasktypes_id` = `glpi_plugin_tasklists_tasktypes`.`id`) \n WHERE NOT `glpi_plugin_tasklists_tasks`.`is_deleted`\n AND `glpi_plugin_tasklists_tasks`.`state` < 2 ";
$query .= getEntitiesRestrictRequest('AND', 'glpi_plugin_tasklists_tasks');
$query .= "ORDER BY `glpi_plugin_tasklists_tasks`.`priority`DESC ";
$tasks = array();
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
while ($data = $DB->fetch_array($result)) {
//$groups = Group_User::getGroupUsers($data['groups_id']);
$groupusers = Group_User::getGroupUsers($data['groups_id']);
$groups = array();
foreach ($groupusers as $groupuser) {
$groups[] = $groupuser["id"];
}
if ($data['visibility'] == 1 && $data['users_id'] == Session::getLoginUserID() || $data['visibility'] == 2 && ($data['users_id'] == Session::getLoginUserID() || in_array(Session::getLoginUserID(), $groups)) || $data['visibility'] == 3) {
$ID = $data['id'];
$rand = mt_rand();
$url = Toolbox::getItemTypeFormURL("PluginTasklistsTask") . "?id=" . $data['id'];
$tasks[$data['id']][0] = "<a id='task" . $data["id"] . $rand . "' target='_blank' href='{$url}'>" . $data['name'] . "</a>";
$tasks[$data['id']][0] .= Html::showToolTip($data['comment'], array('applyto' => 'task' . $data["id"] . $rand, 'display' => false));
$bgcolor = $_SESSION["glpipriority_" . $data['priority']];
$tasks[$data['id']][1] = "<div class='center' style='background-color:{$bgcolor};'>" . CommonITILObject::getPriorityName($data['priority']) . "</div>";
$tasks[$data['id']][2] = $data['type'];
$tasks[$data['id']][3] = getUserName($data['users_id']);
$tasks[$data['id']][4] = Dropdown::getValueWithUnit($data['percent_done'], "%");
$due_date = $data['due_date'];
$display = Html::convDate($data['due_date']);
if ($due_date <= date('Y-m-d') && !empty($due_date)) {
$display = "<div class='deleted'>" . Html::convDate($data['due_date']) . "</div>";
}
$tasks[$data['id']][5] = $display;
$tasks[$data['id']][6] = "<div align='center'>";
if (Session::haveRight("plugin_tasklists", UPDATE)) {
$tasks[$data['id']][6] .= "<a class='pointer' onclick=\" submitGetLink('" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/front/task.form.php', {'done': 'done', 'id': '" . $data['id'] . "', '_glpi_csrf_token': '" . Session::getNewCSRFToken() . "', '_glpi_simple_form': '1'});\"><img src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/ok.png' title='" . __('Mark as done', 'tasklists') . "'></a>";
}
if (Session::haveRight("plugin_tasklists", UPDATENOTE)) {
$link = " <a href=\"javascript:" . Html::jsGetElementbyID('comment' . $rand) . ".dialog('open');\">";
$link .= "<img class='pointer' src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/plus.png' title='" . __('Add comment', 'tasklists') . "'>";
$link .= "</a>";
$link .= Ajax::createIframeModalWindow('comment' . $rand, $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/comment.form.php?id=" . $ID, array('title' => __('Add comment', 'tasklists'), 'reloadonclose' => false, 'width' => 1100, 'display' => false, 'height' => 300));
$tasks[$data['id']][6] .= $link;
}
$tasks[$data['id']][6] .= "</div>";
}
}
}
}
$widget->setTabDatas($tasks);
$widget->setTabNames($headers);
$widget->setOption("bSort", false);
$widget->toggleWidgetRefresh();
$link = "<div align='right'><a class='vsubmit' href=\"javascript:" . Html::jsGetElementbyID('task') . ".dialog('open');\">";
$link .= __('Add task', 'tasklists');
$link .= "</a></div>";
$link .= Ajax::createIframeModalWindow('task', $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/task.form.php", array('title' => __('Add task', 'tasklists'), 'reloadonclose' => false, 'width' => 1180, 'display' => false, 'height' => 600));
$widget->appendWidgetHtmlContent($link);
$widget->setWidgetTitle(__("Tasks list", 'tasklists'));
return $widget;
} else {
$widget = new PluginMydashboardDatatable();
$widget->setWidgetTitle(__("Tasks list", 'tasklists'));
return $widget;
}
break;
}
}