substr function for utf8 string
static public strpos ( $str, $tofound, $offset ) : substring | ||
$str | string string | |
$tofound | string string to found | |
$offset | integer The search offset. If it is not specified, 0 is used. (default 0) | |
return | substring |
function reconstrucTimeline() { global $DB; $query = "TRUNCATE `" . $this->getTable() . "`"; $DB->query($query); $query = "SELECT id\n FROM `glpi_tickets`"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $queryGroup = "SELECT * FROM `glpi_logs`"; $queryGroup .= " WHERE `itemtype_link` = 'Group'"; $queryGroup .= " AND `items_id` = " . $data['id']; $queryGroup .= " AND `itemtype` = 'Ticket'"; $queryGroup .= " ORDER BY date_mod ASC"; $resultGroup = $DB->query($queryGroup); if ($resultGroup) { while ($dataGroup = $DB->fetch_array($resultGroup)) { if ($dataGroup['new_value'] != null) { $start = Toolbox::strpos($dataGroup['new_value'], "("); $end = Toolbox::strpos($dataGroup['new_value'], ")"); $length = $end - $start; $groups_id = Toolbox::substr($dataGroup['new_value'], $start + 1, $length - 1); $group = new Group(); if ($group->getFromDB($groups_id)) { if ($group->fields['is_requester'] == 0 && $group->fields['is_assign'] == 1) { $ticket = new Ticket(); $ticket->getFromDB($data['id']); $this->createGroup($ticket, $dataGroup['date_mod'], $groups_id, 'new'); } } } else { if ($dataGroup['old_value'] != null) { $start = Toolbox::strpos($dataGroup['old_value'], "("); $end = Toolbox::strpos($dataGroup['old_value'], ")"); $length = $end - $start; $groups_id = Toolbox::substr($dataGroup['old_value'], $start + 1, $length - 1); $group = new Group(); if ($group->getFromDB($groups_id)) { if ($group->fields['is_requester'] == 0 && $group->fields['is_assign'] == 1) { $ticket = new Ticket(); $ticket->getFromDB($data['id']); $this->createGroup($ticket, $dataGroup['date_mod'], $groups_id, 'delete'); } } } } } } } }
/** * Print pager for search option (first/previous/next/last) * * @param $start from witch item we start * @param $numrows total items * @param $target page would be open when click on the option (last,previous etc) * @param $parameters parameters would be passed on the URL. * @param $item_type_output item type display - if >0 display export PDF et Sylk form * (default 0) * @param $item_type_output_param item type parameter for export (default 0) * @param $additional_info Additional information to display (default '') * * @return nothing (print a pager) * **/ static function printPager($start, $numrows, $target, $parameters, $item_type_output = 0, $item_type_output_param = 0, $additional_info = '') { global $CFG_GLPI; $list_limit = $_SESSION['glpilist_limit']; // Forward is the next step forward $forward = $start + $list_limit; // This is the end, my friend $end = $numrows - $list_limit; // Human readable count starts here $current_start = $start + 1; // And the human is viewing from start to end $current_end = $current_start + $list_limit - 1; if ($current_end > $numrows) { $current_end = $numrows; } // Empty case if ($current_end == 0) { $current_start = 0; } // Backward browsing if ($current_start - $list_limit <= 0) { $back = 0; } else { $back = $start - $list_limit; } // Print it echo "<div><table class='tab_cadre_pager'>"; echo "<tr>"; if (strpos($target, '?') == false) { $fulltarget = $target . "?" . $parameters; } else { $fulltarget = $target . "&" . $parameters; } // Back and fast backward button if (!$start == 0) { echo "<th class='left'>"; echo "<a href='{$fulltarget}&start=0'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __s('Start') . "\" title=\"" . __s('Start') . "\" class='pointer'>"; echo "</a></th>"; echo "<th class='left'>"; echo "<a href='{$fulltarget}&start={$back}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\" class='pointer'>"; echo "</a></th>"; } // Print the "where am I?" echo "<td width='31%' class='tab_bg_2'>"; self::printPagerForm("{$fulltarget}&start={$start}"); echo "</td>"; if (!empty($additional_info)) { echo "<td class='tab_bg_2'>"; echo $additional_info; echo "</td>"; } if (!empty($item_type_output) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") { echo "<td class='tab_bg_2 responsive_hidden' width='30%'>"; echo "<form method='GET' action='" . $CFG_GLPI["root_doc"] . "/front/report.dynamic.php'\n target='_blank'>"; echo Html::hidden('item_type', array('value' => $item_type_output)); if ($item_type_output_param != 0) { echo Html::hidden('item_type_param', array('value' => Toolbox::prepareArrayForInput($item_type_output_param))); } $split = explode("&", $parameters); for ($i = 0; $i < count($split); $i++) { $pos = Toolbox::strpos($split[$i], '='); $length = Toolbox::strlen($split[$i]); echo Html::hidden(Toolbox::substr($split[$i], 0, $pos), array('value' => urldecode(Toolbox::substr($split[$i], $pos + 1)))); } Dropdown::showOutputFormat(); Html::closeForm(); echo "</td>"; } echo "<td width='20%' class='tab_bg_2 b'>"; //TRANS: %1$d, %2$d, %3$d are page numbers printf(__('From %1$d to %2$d on %3$d'), $current_start, $current_end, $numrows); echo "</td>\n"; // Forward and fast forward button if ($forward < $numrows) { echo "<th class='right'>"; echo "<a href='{$fulltarget}&start={$forward}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\" class='pointer'>"; echo "</a></th>\n"; echo "<th class='right'>"; echo "<a href='{$fulltarget}&start={$end}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/last.png' alt=\"" . __s('End') . "\" title=\"" . __s('End') . "\" class='pointer'>"; echo "</a></th>\n"; } // End pager echo "</tr></table></div>"; }
/** * Print pager for search option (first/previous/next/last) * * @param $start from witch item we start * @param $numrows total items * @param $target page would be open when click on the option (last,previous etc) * @param $parameters parameters would be passed on the URL. * @param $item_type_output item type display - if >0 display export PDF et Sylk form * (default 0) * @param $item_type_output_param item type parameter for export (default 0) * @param $additional_info Additional information to display (default '') * * @return nothing (print a pager) * * */ function printPager($start, $numrows, $target, $parameters, $item_type_output = 0, $item_type_output_param = 0, $additional_info = '') { global $CFG_GLPI; $list_limit = $_SESSION['glpilist_limit']; // Forward is the next step forward $forward = $start + $list_limit; // This is the end, my friend $end = $numrows - $list_limit; // Human readable count starts here $current_start = $start + 1; // And the human is viewing from start to end $current_end = $current_start + $list_limit - 1; if ($current_end > $numrows) { $current_end = $numrows; } // Empty case if ($current_end == 0) { $current_start = 0; } // Backward browsing if ($current_start - $list_limit <= 0) { $back = 0; } else { $back = $start - $list_limit; } // Print it echo "<div><table class='tab_cadre_pager'>"; echo "<tr>"; // Back and fast backward button if (!$start == 0) { echo "<th class='left'>"; echo "<a href='{$target}?{$parameters}&start=0'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __s('Start') . "\" title=\"" . __s('Start') . "\">"; echo "</a></th>"; echo "<th class='left'>"; echo "<a href='{$target}?{$parameters}&start={$back}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\">"; echo "</a></th>"; } // Print the "where am I?" echo "<td width='50%' class='tab_bg_2'>"; Html::printPagerForm("{$target}?{$parameters}&start={$start}"); echo "</td>"; if (!empty($additional_info)) { echo "<td class='tab_bg_2'>"; echo $additional_info; echo "</td>"; } if (!empty($item_type_output) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") { echo "<td class='tab_bg_2' width='30%'>"; echo "<form method='GET' action='" . $target . "' target='_blank'>"; echo Html::hidden('item_type', array('value' => $item_type_output)); if ($item_type_output_param != 0) { echo Html::hidden('item_type_param', array('value' => Toolbox::prepareArrayForInput($item_type_output_param))); } $split = explode("&", $parameters); for ($i = 0; $i < count($split); $i++) { $pos = Toolbox::strpos($split[$i], '='); $length = Toolbox::strlen($split[$i]); echo Html::hidden(Toolbox::substr($split[$i], 0, $pos), array('value' => urldecode(Toolbox::substr($split[$i], $pos + 1)))); } Dropdown::showOutputFormat(); $this->showCSVOptions(); echo "<script type='text/javascript'>"; echo "\$('select[name=display_type]').change(function() {\r\n switch(\$(this).val()){\r\n case '3' :case '-3' :\r\n \$('#display_csv_preferences').css('display', 'block');\r\n break;\r\n default : \r\n \$('#display_csv_preferences').css('display', 'none');\r\n break;\r\n }\r\n });"; echo "</script>"; Html::closeForm(); echo "</td>"; } echo "<td width='50%' class='tab_bg_2 b'>"; //TRANS: %1$d, %2$d, %3$d are page numbers printf(__('From %1$d to %2$d on %3$d'), $current_start, $current_end, $numrows); echo "</td>\n"; // Forward and fast forward button if ($forward < $numrows) { echo "<th class='right'>"; echo "<a href='{$target}?{$parameters}&start={$forward}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\">"; echo "</a></th>\n"; echo "<th class='right'>"; echo "<a href='{$target}?{$parameters}&start={$end}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/last.png' alt=\"" . __s('End') . "\" title=\"" . __s('End') . "\">"; echo "</a></th>\n"; } // End pager echo "</tr></table></div>"; }