showSimpleForm() static public method

create a minimal form for simple action
static public showSimpleForm ( $action, $btname, $btlabel, array $fields = [], $btimage = '', $btoption = '', $confirm = '' )
$action String URL to call on submit
$btname String button name
$btlabel String button label
$fields array Array field name => field value
$btimage String button image uri (optional) (default '')
$btoption String optional button option (default '')
$confirm String optional confirm message (default '')
 function displaySpecificTypeField($ID, $field = array())
 {
     global $CFG_GLPI;
     switch ($field['type']) {
         case 'groups':
             $groups = json_decode($this->fields[$field['name']], true);
             if (!empty($groups)) {
                 echo "<table class='tab_cadrehov' cellpadding='5'>";
                 foreach ($groups as $key => $val) {
                     echo "<tr class='tab_bg_1 center'>";
                     echo "<td>";
                     echo Dropdown::getDropdownName("glpi_groups", $val);
                     echo "</td>";
                     echo "<td>";
                     Html::showSimpleForm(Toolbox::getItemTypeFormURL('PluginTimelineticketConfig'), 'delete_groups', _x('button', 'Delete permanently'), array('delete_groups' => 'delete_groups', 'id' => $ID, '_groups_id_assign' => $val), $CFG_GLPI["root_doc"] . "/pics/delete.png");
                     echo " </td>";
                     echo "</tr>";
                 }
                 echo "</table>";
             } else {
                 _e('None');
             }
             break;
     }
 }
Esempio n. 2
0
 function listOfTemplates($target, $add = 0)
 {
     $restrict = "`is_template` = '1'";
     $restrict .= getEntitiesRestrictRequest(" AND ", $this->getTable(), '', '', $this->maybeRecursive());
     $restrict .= " ORDER BY `name`";
     $templates = getAllDatasFromTable($this->getTable(), $restrict);
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     echo "<div align='center'><table class='tab_cadre_fixe'>";
     if ($add) {
         echo "<tr><th colspan='" . (2 + $colsup) . "'>" . __('Choose a template') . " - " . self::getTypeName(2) . "</th>";
     } else {
         echo "<tr><th colspan='" . (2 + $colsup) . "'>" . __('Templates') . " - " . self::getTypeName(2) . "</th>";
     }
     echo "</tr>";
     if ($add) {
         echo "<tr>";
         echo "<td colspan='" . (2 + $colsup) . "' class='center tab_bg_1'>";
         echo "<a href=\"{$target}?id=-1&amp;withtemplate=2\">&nbsp;&nbsp;&nbsp;" . __('Blank Template') . "&nbsp;&nbsp;&nbsp;</a></td>";
         echo "</tr>";
     }
     foreach ($templates as $template) {
         $templname = $template["template_name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($template["template_name"])) {
             $templname .= "(" . $template["id"] . ")";
         }
         echo "<tr>";
         echo "<td class='center tab_bg_1'>";
         if (!$add) {
             echo "<a href=\"{$target}?id=" . $template["id"] . "&amp;withtemplate=1\">&nbsp;&nbsp;&nbsp;{$templname}&nbsp;&nbsp;&nbsp;</a></td>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center tab_bg_2'>";
                 echo Dropdown::getDropdownName("glpi_entities", $template['entities_id']);
                 echo "</td>";
             }
             echo "<td class='center tab_bg_2'>";
             Html::showSimpleForm($target, 'purge', _x('button', 'Delete permanently'), array('id' => $template["id"], 'withtemplate' => 1));
             echo "</td>";
         } else {
             echo "<a href=\"{$target}?id=" . $template["id"] . "&amp;withtemplate=2\">&nbsp;&nbsp;&nbsp;{$templname}&nbsp;&nbsp;&nbsp;</a></td>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center tab_bg_2'>";
                 echo Dropdown::getDropdownName("glpi_entities", $template['entities_id']);
                 echo "</td>";
             }
         }
         echo "</tr>";
     }
     if (!$add) {
         echo "<tr>";
         echo "<td colspan='" . (2 + $colsup) . "' class='tab_bg_2 center'>";
         echo "<b><a href=\"{$target}?withtemplate=1\">" . __('Add a template...') . "</a></b>";
         echo "</td>";
         echo "</tr>";
     }
     echo "</table></div>";
 }
 /**
  * Show the current ticketfollowup summary
  *
  * @param $ticket Ticket object
  **/
 function showSummary($ticket)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRightsOr(self::$rightname, array(self::SEEPUBLIC, self::SEEPRIVATE))) {
         return false;
     }
     $tID = $ticket->fields['id'];
     // Display existing Followups
     $showprivate = Session::haveRight(self::$rightname, self::SEEPRIVATE);
     $caneditall = Session::haveRight(self::$rightname, self::UPDATEALL);
     $tmp = array('tickets_id' => $tID);
     $canadd = $this->can(-1, CREATE, $tmp);
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $techs = $ticket->getAllUsers(CommonITILActor::ASSIGN);
     $reopen_case = false;
     if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray()) && $ticket->isAllowedStatus($ticket->fields['status'], Ticket::INCOMING)) {
         $reopen_case = true;
     }
     $tech = Session::haveRight(self::$rightname, self::ADDALLTICKET) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']);
     $RESTRICT = "";
     if (!$showprivate) {
         $RESTRICT = " AND (`is_private` = '0'\n                            OR `users_id` ='" . Session::getLoginUserID() . "') ";
     }
     $query = "SELECT `glpi_ticketfollowups`.*, `glpi_users`.`picture`\n                FROM `glpi_ticketfollowups`\n                LEFT JOIN `glpi_users` ON (`glpi_ticketfollowups`.`users_id` = `glpi_users`.`id`)\n                WHERE `tickets_id` = '{$tID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     $rand = mt_rand();
     if ($caneditall || $canadd) {
         echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n";
     }
     if ($canadd) {
         echo "<script type='text/javascript' >\n";
         echo "function viewAddFollowup" . $ticket->fields['id'] . "{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $ticket->fields['id'], 'id' => -1);
         Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo Html::jsHide('addbutton' . $ticket->fields['id'] . "{$rand}");
         echo "};";
         echo "</script>\n";
         // Not closed ticket or closed
         if (!in_array($ticket->fields["status"], array_merge($ticket->getSolvedStatusArray(), $ticket->getClosedStatusArray())) || $reopen_case) {
             if (isset($_GET['_openfollowup']) && $_GET['_openfollowup']) {
                 echo Html::scriptBlock("viewAddFollowup" . $ticket->fields['id'] . "{$rand}()");
             } else {
                 echo "<div id='addbutton" . $ticket->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddFollowup" . $ticket->fields['id'] . "{$rand}();'>";
                 if ($reopen_case) {
                     _e('Reopen the ticket');
                 } else {
                     _e('Add a new followup');
                 }
                 echo "</a></div>\n";
             }
         }
     }
     if ($DB->numrows($result) == 0) {
         echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
         echo "<th class='b'>" . __('No followup for this ticket.') . "</th></tr></table>";
     } else {
         $today = strtotime('today');
         $lastmonday = strtotime('last monday');
         $lastlastmonday = strtotime('last monday', strtotime('last monday'));
         // Case of monday
         if ($today - $lastmonday == 7 * DAY_TIMESTAMP) {
             $lastlastmonday = $lastmonday;
             $lastmonday = $today;
         }
         $steps = array(0 => array('end' => $today, 'name' => __('Today')), 1 => array('end' => $lastmonday, 'name' => __('This week')), 2 => array('end' => $lastlastmonday, 'name' => __('Last week')), 3 => array('end' => strtotime('midnight first day of'), 'name' => __('This month')), 4 => array('end' => strtotime('midnight first day of last month'), 'name' => __('Last month')), 5 => array('end' => 0, 'name' => __('Before the last month')));
         $currentpos = -1;
         while ($data = $DB->fetch_assoc($result)) {
             $this->getFromDB($data['id']);
             $candelete = $this->canPurge() && $this->canPurgeItem();
             $canedit = $this->canUpdate() && $this->canUpdateItem();
             $time = strtotime($data['date']);
             if (!isset($steps[$currentpos]) || $steps[$currentpos]['end'] > $time) {
                 $currentpos++;
                 while ($steps[$currentpos]['end'] > $time && isset($steps[$currentpos + 1])) {
                     $currentpos++;
                 }
                 if (isset($steps[$currentpos])) {
                     echo "<h3>" . $steps[$currentpos]['name'] . "</h3>";
                 }
             }
             $id = 'followup' . $data['id'] . $rand;
             $color = 'byuser';
             if (isset($techs[$data['users_id']])) {
                 $color = 'bytech';
             }
             $classtoadd = '';
             if ($canedit) {
                 $classtoadd = " pointer";
             }
             echo "<div class='boxnote {$color}' id='view{$id}'";
             echo ">";
             echo "<div class='boxnoteleft'>";
             echo "<img class='user_picture_verysmall' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($data['picture']) . "'>";
             echo "</div>";
             // boxnoteleft
             echo "<div class='boxnotecontent'";
             echo ">";
             echo "<div class='boxnotefloatleft'>";
             $username = NOT_AVAILABLE;
             if ($data['users_id']) {
                 $username = getUserName($data['users_id'], $showuserlink);
             }
             $name = sprintf(__('Create by %1$s on %2$s'), $username, Html::convDateTime($data['date']));
             if ($data['requesttypes_id']) {
                 $name = sprintf(__('%1$s - %2$s'), $name, Dropdown::getDropdownName('glpi_requesttypes', $data['requesttypes_id']));
             }
             if ($showprivate && $data["is_private"]) {
                 $name = sprintf(__('%1$s - %2$s'), $name, __('Private'));
             }
             echo $name;
             echo "</div>";
             // floatright
             echo "<div class='boxnotetext {$classtoadd}'";
             if ($canedit) {
                 echo " onClick=\"viewEditFollowup" . $ticket->fields['id'] . $data['id'] . "{$rand}(); " . Html::jsHide("view{$id}") . " " . Html::jsShow("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}") . "\" ";
             }
             echo ">";
             $content = nl2br($data['content']);
             if (empty($content)) {
                 $content = NOT_AVAILABLE;
             }
             echo $content . '</div>';
             // boxnotetext
             echo "</div>";
             // boxnotecontent
             echo "<div class='boxnoteright'>";
             if ($candelete) {
                 Html::showSimpleForm(Toolbox::getItemTypeFormURL('TicketFollowup'), array('purge' => 'purge'), _x('button', 'Delete permanently'), array('id' => $data['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png", '', __('Confirm the final deletion?'));
             }
             echo "</div>";
             // boxnoteright
             echo "</div>";
             // boxnote
             if ($canedit) {
                 echo "<div id='viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}' class='starthidden'></div>\n";
                 echo "\n<script type='text/javascript' >\n";
                 echo "function viewEditFollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}() {\n";
                 $params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $data["tickets_id"], 'id' => $data["id"]);
                 Ajax::updateItemJsCode("viewfollowup" . $ticket->fields['id'] . $data["id"] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                 echo "};";
                 echo "</script>\n";
             }
         }
     }
 }
 /**
  * show actor part in ITIL object form
  *
  * @param $ID        integer  ITIL object ID
  * @param $options   array    options for default values ($options of showForm)
  *
  * @return nothing display
  **/
 function showActorsPartForm($ID, array $options)
 {
     global $CFG_GLPI;
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $options['_default_use_notification'] = 1;
     if (isset($options['entities_id'])) {
         $options['_default_use_notification'] = Entity::getUsedConfig('is_notif_enable_default', $options['entities_id'], '', 1);
     }
     // check is_hidden fields
     foreach (array('_users_id_requester', '_groups_id_requester', '_users_id_observer', '_groups_id_observer', '_users_id_assign', '_groups_id_assign', '_suppliers_id_assign') as $f) {
         $is_hidden[$f] = false;
         if (isset($options['_tickettemplate']) && $options['_tickettemplate']->isHiddenField($f)) {
             $is_hidden[$f] = true;
         }
     }
     $can_admin = $this->canAdminActors();
     $can_assign = $this->canAssign();
     $can_assigntome = $this->canAssignToMe();
     if (isset($options['_noupdate']) && !$options['_noupdate']) {
         $can_admin = false;
         $can_assign = false;
         $can_assigntome = false;
     }
     // Manage actors : requester and assign
     echo "<table class='tab_cadre_fixe' id='mainformtable5'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th rowspan='2' width='13%'>" . __('Actor') . "</th>";
     echo "<th width='29%'>";
     if (!$is_hidden['_users_id_requester'] || !$is_hidden['_groups_id_requester']) {
         _e('Requester');
     }
     $rand_requester = -1;
     $candeleterequester = false;
     if ($ID && $can_admin && (!$is_hidden['_users_id_requester'] || !$is_hidden['_groups_id_requester'])) {
         $rand_requester = mt_rand();
         echo "&nbsp;&nbsp;";
         echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                onClick=\"" . Html::jsShow("itilactor{$rand_requester}") . "\"\n                class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         $candeleterequester = true;
     }
     echo "</th>";
     echo "<th width='29%'>";
     if (!$is_hidden['_users_id_observer'] || !$is_hidden['_groups_id_observer']) {
         _e('Watcher');
     }
     $rand_observer = -1;
     $candeleteobserver = false;
     if ($ID && $can_admin && (!$is_hidden['_users_id_observer'] || !$is_hidden['_groups_id_observer'])) {
         $rand_observer = mt_rand();
         echo "&nbsp;&nbsp;";
         echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                onClick=\"" . Html::jsShow("itilactor{$rand_observer}") . "\"\n                class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         $candeleteobserver = true;
     } else {
         if ($ID > 0 && !in_array($this->fields['status'], $this->getClosedStatusArray()) && !$is_hidden['_users_id_observer'] && !$this->isUser(CommonITILActor::OBSERVER, Session::getLoginUserID()) && !$this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID())) {
             echo "&nbsp;&nbsp;&nbsp;&nbsp;";
             Html::showSimpleForm($this->getFormURL(), 'addme_observer', __('Associate myself'), array($this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/addme.png");
         }
     }
     echo "</th>";
     echo "<th width='29%'>";
     if (!$is_hidden['_users_id_assign'] || !$is_hidden['_groups_id_assign'] || !$is_hidden['_suppliers_id_assign']) {
         _e('Assigned to');
     }
     $rand_assign = -1;
     $candeleteassign = false;
     if ($ID && ($can_assign || $can_assigntome) && (!$is_hidden['_users_id_assign'] || !$is_hidden['_groups_id_assign'] || !$is_hidden['_suppliers_id_assign']) && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
         $rand_assign = mt_rand();
         echo "&nbsp;&nbsp;";
         echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                onClick=\"" . Html::jsShow("itilactor{$rand_assign}") . "\"\n                class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
     }
     if ($ID && $can_assigntome && !in_array($this->fields['status'], $this->getClosedStatusArray()) && !$is_hidden['_users_id_assign'] && !$this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
         Html::showSimpleForm($this->getFormURL(), 'addme_assign', __('Associate myself'), array($this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/addme.png");
     }
     if ($ID && $can_assign) {
         $candeleteassign = true;
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1 top'>";
     echo "<td>";
     if ($rand_requester >= 0) {
         $this->showActorAddForm(CommonITILActor::REQUESTER, $rand_requester, $this->fields['entities_id'], $is_hidden);
     }
     // Requester
     if (!$ID) {
         $reqdisplay = false;
         if ($can_admin && !$is_hidden['_users_id_requester']) {
             $this->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $options);
             $reqdisplay = true;
         } else {
             $delegating = User::getDelegateGroupsForUser($options['entities_id']);
             if (count($delegating) && !$is_hidden['_users_id_requester']) {
                 //$this->getDefaultActor(CommonITILActor::REQUESTER);
                 $options['_right'] = "delegate";
                 $this->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $options);
                 $reqdisplay = true;
             } else {
                 // predefined value
                 if (isset($options["_users_id_requester"]) && $options["_users_id_requester"]) {
                     echo self::getActorIcon('user', CommonITILActor::REQUESTER) . "&nbsp;";
                     echo Dropdown::getDropdownName("glpi_users", $options["_users_id_requester"]);
                     echo "<input type='hidden' name='_users_id_requester' value=\"" . $options["_users_id_requester"] . "\">";
                     echo '<br>';
                     $reqdisplay = true;
                 }
             }
         }
         //If user have access to more than one entity, then display a combobox : Ticket case
         if ($this->userentity_oncreate && isset($this->countentitiesforuser) && $this->countentitiesforuser > 1) {
             echo "<br>";
             $rand = Entity::dropdown(array('value' => $this->fields["entities_id"], 'entity' => $this->userentities, 'on_change' => 'this.form.submit()'));
         } else {
             echo "<input type='hidden' name='entities_id' value='" . $this->fields["entities_id"] . "'>";
         }
         if ($reqdisplay) {
             echo '<hr>';
         }
     } else {
         if (!$is_hidden['_users_id_requester']) {
             $this->showUsersAssociated(CommonITILActor::REQUESTER, $candeleterequester, $options);
         }
     }
     // Requester Group
     if (!$ID) {
         if ($can_admin && !$is_hidden['_groups_id_requester']) {
             echo self::getActorIcon('group', CommonITILActor::REQUESTER);
             /// For ticket templates : mandatories
             if (isset($options['_tickettemplate'])) {
                 echo $options['_tickettemplate']->getMandatoryMark('_groups_id_requester');
             }
             echo "&nbsp;";
             Group::dropdown(array('name' => '_groups_id_requester', 'value' => $options["_groups_id_requester"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_requester`'));
         } else {
             // predefined value
             if (isset($options["_groups_id_requester"]) && $options["_groups_id_requester"]) {
                 echo self::getActorIcon('group', CommonITILActor::REQUESTER) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_requester"]);
                 echo "<input type='hidden' name='_groups_id_requester' value=\"" . $options["_groups_id_requester"] . "\">";
                 echo '<br>';
             }
         }
     } else {
         if (!$is_hidden['_groups_id_requester']) {
             $this->showGroupsAssociated(CommonITILActor::REQUESTER, $candeleterequester, $options);
         }
     }
     echo "</td>";
     echo "<td>";
     if ($rand_observer >= 0) {
         $this->showActorAddForm(CommonITILActor::OBSERVER, $rand_observer, $this->fields['entities_id'], $is_hidden);
     }
     // Observer
     if (!$ID) {
         if ($can_admin && !$is_hidden['_users_id_observer']) {
             $this->showActorAddFormOnCreate(CommonITILActor::OBSERVER, $options);
             echo '<hr>';
         } else {
             // predefined value
             if (isset($options["_users_id_observer"]) && $options["_users_id_observer"]) {
                 echo self::getActorIcon('user', CommonITILActor::OBSERVER) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_users", $options["_users_id_observer"]);
                 echo "<input type='hidden' name='_users_id_observer' value=\"" . $options["_users_id_observer"] . "\">";
                 echo '<hr>';
             }
         }
     } else {
         if (!$is_hidden['_users_id_observer']) {
             $this->showUsersAssociated(CommonITILActor::OBSERVER, $candeleteobserver, $options);
         }
     }
     // Observer Group
     if (!$ID) {
         if ($can_admin && !$is_hidden['_groups_id_observer']) {
             echo self::getActorIcon('group', CommonITILActor::OBSERVER);
             /// For ticket templates : mandatories
             if (isset($options['_tickettemplate'])) {
                 echo $options['_tickettemplate']->getMandatoryMark('_groups_id_observer');
             }
             echo "&nbsp;";
             Group::dropdown(array('name' => '_groups_id_observer', 'value' => $options["_groups_id_observer"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_requester`'));
         } else {
             // predefined value
             if (isset($options["_groups_id_observer"]) && $options["_groups_id_observer"]) {
                 echo self::getActorIcon('group', CommonITILActor::OBSERVER) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_observer"]);
                 echo "<input type='hidden' name='_groups_id_observer' value=\"" . $options["_groups_id_observer"] . "\">";
                 echo '<br>';
             }
         }
     } else {
         if (!$is_hidden['_groups_id_observer']) {
             $this->showGroupsAssociated(CommonITILActor::OBSERVER, $candeleteobserver, $options);
         }
     }
     echo "</td>";
     echo "<td>";
     if ($rand_assign >= 0) {
         $this->showActorAddForm(CommonITILActor::ASSIGN, $rand_assign, $this->fields['entities_id'], $is_hidden, $this->canAssign(), $this->canAssign());
     }
     // Assign User
     if (!$ID) {
         if ($can_assign && !$is_hidden['_users_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
             $this->showActorAddFormOnCreate(CommonITILActor::ASSIGN, $options);
             echo '<hr>';
         } else {
             if ($can_assigntome && !$is_hidden['_users_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                 echo self::getActorIcon('user', CommonITILActor::ASSIGN) . "&nbsp;";
                 User::dropdown(array('name' => '_users_id_assign', 'value' => $options["_users_id_assign"], 'entity' => $this->fields["entities_id"], 'ldap_import' => true));
                 echo '<hr>';
             } else {
                 // predefined value
                 if (isset($options["_users_id_assign"]) && $options["_users_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                     echo self::getActorIcon('user', CommonITILActor::ASSIGN) . "&nbsp;";
                     echo Dropdown::getDropdownName("glpi_users", $options["_users_id_assign"]);
                     echo "<input type='hidden' name='_users_id_assign' value=\"" . $options["_users_id_assign"] . "\">";
                     echo '<hr>';
                 }
             }
         }
     } else {
         if (!$is_hidden['_users_id_assign']) {
             $this->showUsersAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options);
         }
     }
     // Assign Groups
     if (!$ID) {
         if ($can_assign && !$is_hidden['_groups_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
             echo self::getActorIcon('group', CommonITILActor::ASSIGN);
             /// For ticket templates : mandatories
             if (isset($options['_tickettemplate'])) {
                 echo $options['_tickettemplate']->getMandatoryMark('_groups_id_assign');
             }
             echo "&nbsp;";
             $rand = mt_rand();
             $params = array('name' => '_groups_id_assign', 'value' => $options["_groups_id_assign"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_assign`', 'rand' => $rand);
             if ($this->getType() == 'Ticket') {
                 $params['toupdate'] = array('value_fieldname' => 'value', 'to_update' => "countgroupassign_{$rand}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/ticketassigninformation.php", 'moreparams' => array('groups_id_assign' => '__VALUE__'));
             }
             Group::dropdown($params);
             echo "<span id='countgroupassign_{$rand}'>";
             echo "</span>";
             echo "<script type='text/javascript'>";
             Ajax::updateItemJsCode("countgroupassign_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/ticketassigninformation.php", array('groups_id_assign' => '__VALUE__'), "dropdown__groups_id_assign{$rand}");
             echo "</script>";
             echo '<hr>';
         } else {
             // predefined value
             if (isset($options["_groups_id_assign"]) && $options["_groups_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                 echo self::getActorIcon('group', CommonITILActor::ASSIGN) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_assign"]);
                 echo "<input type='hidden' name='_groups_id_assign' value=\"" . $options["_groups_id_assign"] . "\">";
                 echo '<hr>';
             }
         }
     } else {
         if (!$is_hidden['_groups_id_assign']) {
             $this->showGroupsAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options);
         }
     }
     // Assign Suppliers
     if (!$ID) {
         if ($can_assign && !$is_hidden['_suppliers_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
             $this->showSupplierAddFormOnCreate($options);
         } else {
             // predefined value
             if (isset($options["_suppliers_id_assign"]) && $options["_suppliers_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                 echo self::getActorIcon('supplier', CommonITILActor::ASSIGN) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_suppliers", $options["_suppliers_id_assign"]);
                 echo "<input type='hidden' name='_suppliers_id_assign' value=\"" . $options["_suppliers_id_assign"] . "\">";
                 echo '<hr>';
             }
         }
     } else {
         if (!$is_hidden['_suppliers_id_assign']) {
             $this->showSuppliersAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options);
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
Esempio n. 5
0
 /**
  * Print the contact form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Config::canView() || !$this->getFromDB($ID)) {
         return false;
     }
     $options['candel'] = false;
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td class ='b'>";
     $name = $this->fields["name"];
     if ($isplug = isPluginItemType($this->fields["itemtype"])) {
         $name = sprintf(__('%1$s - %2$s'), $isplug["plugin"], $name);
     }
     echo $name . "</td>";
     echo "<td rowspan='6' class='middle right'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='6'>";
     echo "<textarea cols='45' rows='8' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Description') . "</td><td>";
     echo $this->getDescription($ID);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Run frequency') . "</td><td>";
     $this->dropdownFrequency('frequency', $this->fields["frequency"]);
     echo "</td></tr>";
     $tmpstate = $this->fields["state"];
     echo "<tr class='tab_bg_1'><td>" . __('Status') . "</td><td>";
     if (is_file(GLPI_CRON_DIR . '/' . $this->fields["name"] . '.lock') || is_file(GLPI_CRON_DIR . '/all.lock')) {
         echo "<span class='b'>" . __('System lock') . "</span><br>";
         $tmpstate = self::STATE_DISABLE;
     }
     if ($isplug) {
         $plug = new Plugin();
         if (!$plug->isActivated($isplug["plugin"])) {
             echo "<span class='b'>" . __('Disabled plugin') . "</span><br>";
             $tmpstate = self::STATE_DISABLE;
         }
     }
     if ($this->fields["state"] == self::STATE_RUNNING) {
         echo "<span class='b'>" . $this->getStateName(self::STATE_RUNNING) . "</span>";
     } else {
         self::dropdownState('state', $this->fields["state"]);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Run mode') . "</td><td>";
     $modes = array();
     if ($this->fields['allowmode'] & self::MODE_INTERNAL) {
         $modes[self::MODE_INTERNAL] = self::getModeName(self::MODE_INTERNAL);
     }
     if ($this->fields['allowmode'] & self::MODE_EXTERNAL) {
         $modes[self::MODE_EXTERNAL] = self::getModeName(self::MODE_EXTERNAL);
     }
     Dropdown::showFromArray('mode', $modes, array('value' => $this->fields['mode']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Run period') . "</td><td>";
     Dropdown::showNumber('hourmin', array('value' => $this->fields['hourmin'], 'min' => 0, 'max' => 24, 'width' => '35%'));
     echo "&nbsp;->&nbsp;";
     Dropdown::showNumber('hourmax', array('value' => $this->fields['hourmax'], 'min' => 0, 'max' => 24, 'width' => '35%'));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Number of days this action logs are stored') . "</td><td>";
     Dropdown::showNumber('logs_lifetime', array('value' => $this->fields['logs_lifetime'], 'min' => 10, 'max' => 360, 'step' => 10, 'toadd' => array(0 => __('Infinite'))));
     echo "</td><td>" . __('Last run') . "</td><td>";
     if (empty($this->fields['lastrun'])) {
         _e('Never');
     } else {
         echo Html::convDateTime($this->fields['lastrun']);
         echo "&nbsp;";
         Html::showSimpleForm(static::getFormURL(), 'resetdate', __('Blank'), array('id' => $ID), $CFG_GLPI['root_doc'] . "/pics/reset.png");
     }
     echo "</td></tr>";
     $label = $this->getParameterDescription();
     echo "<tr class='tab_bg_1'><td>";
     if (empty($label)) {
         echo "&nbsp;</td><td>&nbsp;";
     } else {
         echo $label . "&nbsp;</td><td>";
         Dropdown::showNumber('param', array('value' => $this->fields['param'], 'min' => 0, 'max' => 400));
     }
     echo "</td><td>" . __('Next run') . "</td><td>";
     if ($tmpstate == self::STATE_RUNNING) {
         $launch = false;
     } else {
         $launch = $this->fields['allowmode'] & self::MODE_INTERNAL;
     }
     if ($tmpstate != self::STATE_WAITING) {
         echo $this->getStateName($tmpstate);
     } else {
         if (empty($this->fields['lastrun'])) {
             _e('As soon as possible');
         } else {
             $next = strtotime($this->fields['lastrun']) + $this->fields['frequency'];
             $h = date('H', $next);
             $deb = $this->fields['hourmin'] < 10 ? "0" . $this->fields['hourmin'] : $this->fields['hourmin'];
             $fin = $this->fields['hourmax'] < 10 ? "0" . $this->fields['hourmax'] : $this->fields['hourmax'];
             if ($deb < $fin && $h < $deb) {
                 $disp = date('Y-m-d', $next) . " {$deb}:00:00";
                 $next = strtotime($disp);
             } else {
                 if ($deb < $fin && $h >= $this->fields['hourmax']) {
                     $disp = date('Y-m-d', $next + DAY_TIMESTAMP) . " {$deb}:00:00";
                     $next = strtotime($disp);
                 }
             }
             if ($deb > $fin && $h < $deb && $h >= $fin) {
                 $disp = date('Y-m-d', $next) . " {$deb}:00:00";
                 $next = strtotime($disp);
             } else {
                 $disp = date("Y-m-d H:i:s", $next);
             }
             if ($next < time()) {
                 echo __('As soon as possible') . '<br>(' . Html::convDateTime($disp) . ') ';
             } else {
                 echo Html::convDateTime($disp);
             }
         }
     }
     if ($launch) {
         echo "&nbsp;";
         Html::showSimpleForm(static::getFormURL(), array('execute' => $this->fields['name']), __('Execute'));
     }
     if ($tmpstate == self::STATE_RUNNING) {
         Html::showSimpleForm(static::getFormURL(), 'resetstate', __('Blank'), array('id' => $ID), $CFG_GLPI['root_doc'] . "/pics/reset.png");
     }
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
Esempio n. 6
0
 /**
  * Show Infocom form for an item (not a standard showForm)
  *
  * @param $item                  CommonDBTM object
  * @param $withtemplate integer  template or basic item (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $CFG_GLPI;
     // Show Infocom or blank form
     if (!Session::haveRight("infocom", "r")) {
         return false;
     }
     if (!$item) {
         echo "<div class='spaced'>" . __('Requested item not found') . "</div>";
     } else {
         $date_tax = $CFG_GLPI["date_tax"];
         $dev_ID = $item->getField('id');
         $ic = new self();
         $option = "";
         if ($withtemplate == 2) {
             $option = " readonly ";
         }
         if (!strpos($_SERVER['PHP_SELF'], "infocoms-show") && in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
             echo "<div class='firstbloc center'>" . __('For this type of item, the financial and administrative information are only a model for the items which you should add.') . "</div>";
         }
         if (!$ic->getFromDBforDevice($item->getType(), $dev_ID)) {
             $input = array('itemtype' => $item->getType(), 'items_id' => $dev_ID, 'entities_id' => $item->getEntityID());
             if ($ic->can(-1, "w", $input) && $withtemplate != 2) {
                 echo "<div class='spaced b'>";
                 echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><th>";
                 echo sprintf(__('%1$s - %2$s'), $item->getTypeName(1), $item->getName()) . "</th></tr>";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 Html::showSimpleForm($CFG_GLPI["root_doc"] . "/front/infocom.form.php", 'add', __('Enable the financial and administrative information'), array('itemtype' => $item->getType(), 'items_id' => $dev_ID));
                 echo "</td></tr></table></div>";
             }
         } else {
             // getFromDBforDevice
             $canedit = $ic->can($ic->fields['id'], "w") && $withtemplate != 2;
             if ($canedit) {
                 echo "<form name='form_ic' method='post' action='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php'>";
             }
             echo "<div class='spaced'>";
             echo "<table class='tab_cadre" . (!strpos($_SERVER['PHP_SELF'], "infocoms-show") ? "_fixe" : "") . "'>";
             echo "<tr><th colspan='4'>" . __('Financial and administrative information') . "</th></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Supplier') . "</td>";
             echo "<td>";
             if ($withtemplate == 2) {
                 echo Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]);
             } else {
                 Supplier::dropdown(array('value' => $ic->fields["suppliers_id"], 'entity' => $item->getEntityID()));
             }
             echo "</td>";
             if (Session::haveRight("budget", "r")) {
                 echo "<td>" . __('Budget') . "</td><td >";
                 Budget::dropdown(array('value' => $ic->fields["budgets_id"], 'entity' => $item->getEntityID(), 'comments' => 1));
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td></tr>";
             // Can edit calendar ?
             $editcalendar = $withtemplate != 2;
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Order number') . "</td>";
             echo "<td >";
             Html::autocompletionTextField($ic, "order_number", array('option' => $option));
             echo "</td>";
             echo "<td>" . __('Order date') . "</td><td>";
             Html::showDateFormItem("order_date", $ic->fields["order_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             $istemplate = '';
             if ($item->isTemplate() || in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
                 $istemplate = '*';
             }
             echo "<td>" . sprintf(__('%1$s%2$s'), __('Immobilization number'), $istemplate) . "</td>";
             echo "<td>";
             $objectName = autoName($ic->fields["immo_number"], "immo_number", $withtemplate == 2, 'Infocom', $item->getEntityID());
             Html::autocompletionTextField($ic, "immo_number", array('value' => $objectName, 'option' => $option));
             echo "</td>";
             echo "<td>" . __('Date of purchase') . "</td><td>";
             Html::showDateFormItem("buy_date", $ic->fields["buy_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Invoice number') . "</td>";
             echo "<td>";
             Html::autocompletionTextField($ic, "bill", array('option' => $option));
             echo "</td>";
             echo "<td>" . __('Delivery date') . "</td><td>";
             Html::showDateFormItem("delivery_date", $ic->fields["delivery_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Delivery form') . "</td><td>";
             Html::autocompletionTextField($ic, "delivery_number", array('option' => $option));
             echo "</td>";
             echo "<td>" . __('Startup date') . "</td><td>";
             Html::showDateFormItem("use_date", $ic->fields["use_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Value') . "</td>";
             echo "<td><input type='text' name='value' {$option} value='" . Html::formatNumber($ic->fields["value"], true) . "' size='14'></td>";
             echo "</td>";
             echo "<td>" . __('Date of last physical inventory') . "</td><td>";
             Html::showDateFormItem("inventory_date", $ic->fields["inventory_date"], true, $editcalendar);
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Warranty extension value') . "</td>";
             echo "<td><input type='text' {$option} name='warranty_value' value='" . Html::formatNumber($ic->fields["warranty_value"], true) . "' size='14'></td>";
             echo "<td rowspan='5'>" . __('Comments') . "</td>";
             echo "<td rowspan='5' class='middle'>";
             echo "<textarea cols='45' rows='9' name='comment' >" . $ic->fields["comment"];
             echo "</textarea></td></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Account net value') . "</td><td>";
             echo Html::formatNumber(self::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $date_tax, "n"));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Amortization type') . "</td><td >";
             if ($withtemplate == 2) {
                 echo self::getAmortTypeName($ic->fields["sink_type"]);
             } else {
                 self::dropdownAmortType("sink_type", $ic->fields["sink_type"]);
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Amortization duration') . "</td><td>";
             if ($withtemplate == 2) {
                 printf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]);
             } else {
                 Dropdown::showNumber("sink_time", array('value' => $ic->fields["sink_time"], 'max' => 15, 'unit' => 'year'));
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Amortization coefficient') . "</td>";
             echo "<td>";
             Html::autocompletionTextField($ic, "sink_coeff", array('size' => 14, 'option' => $option));
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             if (!in_array($item->getType(), array('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software', 'SoftwareLicense'))) {
                 echo "<td>" . __('TCO (value + tracking cost)') . "</td><td>";
                 echo self::showTco($item->getField('ticket_tco'), $ic->fields["value"]);
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td>";
             if (!in_array($item->getType(), array('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software', 'SoftwareLicense'))) {
                 echo "<td>" . __('Monthly TCO') . "</td><td>";
                 echo self::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]);
             } else {
                 echo "<td colspan='2'>";
             }
             echo "</td></tr>";
             echo "<tr><th colspan='4'>" . __('Warranty information') . "</th></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Start date of warranty') . "</td><td>";
             Html::showDateFormItem("warranty_date", $ic->fields["warranty_date"], true, $editcalendar);
             echo "</td>";
             echo "<td>" . __('Warranty duration') . "</td><td>";
             if ($withtemplate == 2) {
                 // -1 = life
                 if ($ic->fields["warranty_duration"] == -1) {
                     _e('Lifelong');
                 } else {
                     printf(_n('%d month', '%d months', $ic->fields["warranty_duration"]), $ic->fields["warranty_duration"]);
                 }
             } else {
                 Dropdown::showInteger("warranty_duration", $ic->fields["warranty_duration"], 0, 120, 1, array(-1 => __('Lifelong')), array('unit' => 'month'));
             }
             $tmpdat = self::getWarrantyExpir($ic->fields["warranty_date"], $ic->fields["warranty_duration"], 0, true);
             if ($tmpdat) {
                 echo "<span class='small_space'>" . sprintf(__('Valid to %s'), $tmpdat) . "</span>";
             }
             echo "</td></tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Warranty information') . "</td>";
             echo "<td >";
             Html::autocompletionTextField($ic, "warranty_info", array('option' => $option));
             echo "</td>";
             if ($CFG_GLPI['use_mailing']) {
                 echo "<td>" . __('Alarms on financial and administrative information') . "</td>";
                 echo "<td>";
                 self::dropdownAlert(array('name' => "alert", 'value' => $ic->fields["alert"]));
                 Alert::displayLastAlert('Infocom', $ic->fields['id']);
                 echo "</td>";
             } else {
                 echo "</td><td colspan='2'>";
             }
             echo "</td></tr>";
             if ($canedit) {
                 echo "<tr>";
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='hidden' name='id' value='" . $ic->fields['id'] . "'>";
                 echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n                      class='submit'>";
                 echo "</td>";
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 echo "<input type='submit' name='delete' value=\"" . _sx('button', 'Delete permanently') . "\"\n                      class='submit'>";
                 echo "</td></tr>";
                 echo "</table></div>";
                 Html::closeForm();
             } else {
                 echo "</table></div>";
             }
         }
     }
 }
Esempio n. 7
0
 function showFormReplicatesConfig()
 {
     global $DB;
     $ID = $this->getField('id');
     $target = $this->getFormURL();
     $rand = mt_rand();
     AuthLdapReplicate::addNewReplicateForm($target, $ID);
     $sql = "SELECT *\n              FROM `glpi_authldapreplicates`\n              WHERE `authldaps_id` = '{$ID}'\n              ORDER BY `name`";
     $result = $DB->query($sql);
     if (($nb = $DB->numrows($result)) > 0) {
         echo "<br>";
         $canedit = Config::canUpdate();
         echo "<div class='center'>";
         Html::openMassiveActionsForm('massAuthLdapReplicate' . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'massAuthLdapReplicate' . $rand);
         Html::showMassiveActions($massiveactionparams);
         echo "<input type='hidden' name='id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'>" . "<th colspan='4'>" . __('List of LDAP directory replicates') . "</th></tr>";
         if (isset($_SESSION["LDAP_TEST_MESSAGE"])) {
             echo "<tr class='tab_bg_2'><td class='center' colspan='4'>";
             echo $_SESSION["LDAP_TEST_MESSAGE"];
             echo "</td></tr>";
             unset($_SESSION["LDAP_TEST_MESSAGE"]);
         }
         $header_begin = "<tr>";
         $header_top = "<th>" . Html::getCheckAllAsCheckbox('massAuthLdapReplicate' . $rand) . "</th>";
         $header_bottom = "<th>" . Html::getCheckAllAsCheckbox('massAuthLdapReplicate' . $rand) . "</th>";
         $header_end = "<th class='center b'>" . __('Name') . "</th>";
         $header_end .= "<th class='center b'>" . _n('Replicate', 'Replicates', 1) . "</th>" . "<th class='center'></th></tr>";
         echo $header_begin . $header_top . $header_end;
         while ($ldap_replicate = $DB->fetch_assoc($result)) {
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             Html::showMassiveActionCheckBox('AuthLdapReplicate', $ldap_replicate["id"]);
             echo "</td>";
             echo "<td class='center'>" . $ldap_replicate["name"] . "</td>";
             echo "<td class='center'>" . sprintf(__('%1$s: %2$s'), $ldap_replicate["host"], $ldap_replicate["port"]);
             echo "</td>";
             echo "<td class='center'>";
             Html::showSimpleForm(Toolbox::getItemTypeFormURL(self::getType()), 'test_ldap_replicate', _sx('button', 'Test'), array('id' => $ID, 'ldap_replicate_id' => $ldap_replicate["id"]));
             echo "</td></tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
         echo "</div>";
     }
 }
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     if (!self::canView()) {
         return false;
     }
     $this->check($ID, READ);
     $recursiveItems = $this->recursivelyGetItems();
     if (count($recursiveItems) > 0) {
         $lastItem = $recursiveItems[count($recursiveItems) - 1];
         $lastItem_entities_id = $lastItem->getField('entities_id');
     } else {
         $lastItem_entities_id = $_SESSION['glpiactive_entity'];
     }
     $options['entities_id'] = $lastItem_entities_id;
     $this->showFormHeader($options);
     $options['canedit'] = false;
     $options['candel'] = false;
     $number_errors = 0;
     foreach (self::getMotives() as $key => $name) {
         if ($this->fields[$key] == 1) {
             $number_errors++;
         }
     }
     $motives = self::getMotives();
     $interface_cell = "td";
     $address_cell = "td";
     $network_cell = "td";
     $gateway_cell = "td";
     $address = new IPAddress();
     $netmask = new IPNetmask();
     $number_real_errors = 0;
     if (!$address->setAddressFromString($this->fields['ip']) || !$netmask->setNetmaskFromString($this->fields['netmask'], $address->getVersion())) {
         unset($address);
         unset($netmask);
     } else {
         $network = new IPNetwork();
         $params = array("address" => $address, "netmask" => $netmask);
         if (isset($this->fields["address"])) {
             $params["exclude IDs"] = $this->fields["address"];
         }
         if (isset($this->fields["entities_id"])) {
             $entity = $this->fields["entities_id"];
         } else {
             $entity = -1;
         }
         $networkports_ids = IPNetwork::searchNetworks("equals", $params, $entity, false);
         if (count($networkports_ids) == 0) {
             unset($network);
         } else {
             $network->getFromDB($networkports_ids[0]);
         }
     }
     if ($this->fields['unknown_interface_type'] == 1) {
         $options['canedit'] = true;
         $number_real_errors++;
         $interface_cell = "th";
         echo "<tr class='tab_bg_1'><th>" . $motives['unknown_interface_type'] . "</th>\n" . "<td>" . __('Transform this network port to');
         echo "</td><td colspan=2>";
         Dropdown::showItemTypes('transform_to', NetworkPort::getNetworkPortInstantiations(), array('value' => "NetworkPortEthernet"));
         echo "</td></tr>\n";
     }
     if ($this->fields['invalid_network'] == 1) {
         $number_real_errors++;
         $network_cell = "th";
         $address_cell = "th";
         echo "<tr class='tab_bg_1'><th>" . $motives['invalid_network'] . "</th>\n<td colspan=3>";
         if (isset($network)) {
             printf(__('Network port information conflicting with %s'), $network->getLink());
         } else {
             if (!isset($address) || !isset($netmask)) {
                 _e('Invalid address or netmask');
             } else {
                 _e('No conflicting network');
             }
             echo "&nbsp;<a href='" . Toolbox::getItemTypeFormURL('IPNetwork') . "'>" . __('you may have to add a network') . "</a>";
         }
         echo "</td></tr>\n";
     }
     if ($this->fields['invalid_gateway'] == 1) {
         $number_real_errors++;
         $gateway_cell = "th";
         echo "<tr class='tab_bg_1'><th>" . $motives['invalid_gateway'] . "</th>\n<td colspan=3>";
         if (isset($network)) {
             printf(__('Append a correct gateway to the network %s'), $network->getLink());
         } else {
             printf(__('%1$s: %2$s'), __('Unknown network'), "<a href='" . Toolbox::getItemTypeFormURL('IPNetwork') . "'>" . __('Add a network') . "\n                    </a>");
         }
         echo "</td></tr>\n";
     }
     if ($this->fields['invalid_address'] == 1) {
         $number_real_errors++;
         $address_cell = "th";
         echo "<tr class='tab_bg_1'><th>" . $motives['invalid_address'] . "</th>\n<td colspan=3>";
         $networkPort = new NetworkPort();
         if ($networkPort->getFromDB($this->getID())) {
             $number_real_errors++;
             echo "<a href='" . $networkPort->getLinkURL() . "'>" . __('Add a correct IP to the network port') . "</a>";
         } else {
             _e('Unknown network port');
         }
         echo "</td></tr>\n";
     }
     if ($number_real_errors == 0) {
         echo "<tr class='tab_bg_1'><th colspan='3'>" . __('I don\'t understand why this migration error is not deleted.');
         echo "</th><th>";
         Html::showSimpleForm($this->getFormURL(), 'delete', __('You can delete this migration error'), array('id' => $this->getID()));
         echo "</th></tr>\n";
     } else {
         echo "<tr class='tab_bg_1'><th>" . __('At all events') . "</th>\n";
         echo "<td colspan='3'>";
         Html::showSimpleForm($this->getFormURL(), 'delete', __('You can delete this migration error'), array('id' => $this->getID()));
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td colspan='4'>&nbsp;</td></tr>\n";
     echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Original network port information') . "</th>" . "</tr>\n";
     echo "<tr class='tab_bg_1'><td>";
     $this->displayRecursiveItems($recursiveItems, 'Type');
     echo "</td>\n<td>";
     $this->displayRecursiveItems($recursiveItems, "Link");
     echo "</td>\n";
     echo "<td>" . __('Comments') . "</td>";
     echo "<td class='middle'>" . $this->fields["comment"] . "</td></tr>\n";
     echo "<tr class='tab_bg_1'><td>" . __('Network address') . "</td>\n";
     echo "<{$network_cell}>" . $this->fields['subnet'] . "</{$network_cell}>\n";
     echo "<td>" . IPNetmask::getTypeName(1) . "</td>\n";
     echo "<{$network_cell}>" . $this->fields['netmask'] . "</{$network_cell}></tr>\n";
     echo "<tr class='tab_bg_1'><td>" . IPAddress::getTypeName(1) . "</td>\n";
     echo "<{$address_cell}>" . $this->fields['ip'] . "</{$address_cell}>\n";
     echo "<td>" . __('Gateway') . "</td>\n";
     echo "<{$gateway_cell}>" . $this->fields['gateway'] . "</{$gateway_cell}></tr>\n";
     echo "<tr class='tab_bg_1'><td>" . __('Network interface') . "</td><{$interface_cell}>\n";
     if (TableExists('glpi_networkinterfaces')) {
         $query = "SELECT `name`\n                   FROM `glpi_networkinterfaces`\n                   WHERE `id`='" . $this->fields['networkinterfaces_id'] . "'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             $row = $DB->fetch_assoc($result);
             echo $row['name'];
         } else {
             _e('Unknown interface');
         }
     }
     echo "</{$interface_cell}>";
     echo "<{$interface_cell}></{$interface_cell}>";
     echo "<{$interface_cell}></{$interface_cell}></tr>\n";
     $this->showFormButtons($options);
 }
Esempio n. 9
0
 /**
  * Show notepads for an item
  *
  * @param $item                  CommonDBTM object
  * @param $withtemplate integer  template or basic item (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $CFG_GLPI;
     if (!Session::haveRight($item::$rightname, READNOTE)) {
         return false;
     }
     $notes = static::getAllForItem($item);
     $rand = mt_rand();
     $canedit = Session::haveRight($item::$rightname, UPDATENOTE);
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     if ($canedit) {
         echo "<div class='boxnote center'>";
         echo "<div class='boxnoteleft'></div>";
         echo "<form name='addnote_form{$rand}' id='addnote_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('Notepad') . "'>";
         echo Html::hidden('itemtype', array('value' => $item->getType()));
         echo Html::hidden('items_id', array('value' => $item->getID()));
         echo "<div class='boxnotecontent'>";
         echo "<div class='floatleft'>";
         echo "<textarea name='content' rows=5 cols=100></textarea>";
         echo "</div>";
         echo "</div>";
         // box notecontent
         echo "<div class='boxnoteright'><br>";
         echo Html::submit(_x('button', 'Add'), array('name' => 'add'));
         echo "</div>";
         Html::closeForm();
         echo "</div>";
         // boxnote
     }
     if (count($notes)) {
         foreach ($notes as $note) {
             $id = 'note' . $note['id'] . $rand;
             $classtoadd = '';
             if ($canedit) {
                 $classtoadd = " pointer";
             }
             echo "<div class='boxnote' id='view{$id}'>";
             echo "<div class='boxnoteleft'>";
             echo "<img class='user_picture_verysmall' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($note['picture']) . "'>";
             echo "</div>";
             // boxnoteleft
             echo "<div class='boxnotecontent'>";
             echo "<div class='boxnotefloatright'>";
             $username = NOT_AVAILABLE;
             if ($note['users_id_lastupdater']) {
                 $username = getUserName($note['users_id_lastupdater'], $showuserlink);
             }
             $update = sprintf(__('Last update by %1$s on %2$s'), $username, Html::convDateTime($note['date_mod']));
             $username = NOT_AVAILABLE;
             if ($note['users_id']) {
                 $username = getUserName($note['users_id'], $showuserlink);
             }
             $create = sprintf(__('Create by %1$s on %2$s'), $username, Html::convDateTime($note['date']));
             printf(__('%1$s / %2$s'), $update, $create);
             echo "</div>";
             // floatright
             echo "<div class='boxnotetext {$classtoadd}' ";
             if ($canedit) {
                 echo "onclick=\"" . Html::jsHide("view{$id}") . " " . Html::jsShow("edit{$id}") . "\"";
             }
             echo ">";
             $content = nl2br($note['content']);
             if (empty($content)) {
                 $content = NOT_AVAILABLE;
             }
             echo $content . '</div>';
             // boxnotetext
             echo "</div>";
             // boxnotecontent
             echo "<div class='boxnoteright'>";
             if ($canedit) {
                 Html::showSimpleForm(Toolbox::getItemTypeFormURL('Notepad'), array('purge' => 'purge'), _x('button', 'Delete permanently'), array('id' => $note['id']), $CFG_GLPI["root_doc"] . "/pics/delete.png", '', __('Confirm the final deletion?'));
             }
             echo "</div>";
             // boxnoteright
             echo "</div>";
             // boxnote
             if ($canedit) {
                 echo "<div class='boxnote starthidden' id='edit{$id}'>";
                 echo "<form name='update_form{$id}{$rand}' id='update_form{$id}{$rand}' ";
                 echo " method='post' action='" . Toolbox::getItemTypeFormURL('Notepad') . "'>";
                 echo "<div class='boxnoteleft'></div>";
                 echo "<div class='boxnotecontent'>";
                 echo Html::hidden('id', array('value' => $note['id']));
                 echo "<textarea name='content' rows=5 cols=100>" . $note['content'] . "</textarea>";
                 echo "</div>";
                 // boxnotecontent
                 echo "<div class='boxnoteright'><br>";
                 echo Html::submit(_x('button', 'Update'), array('name' => 'update'));
                 echo "</div>";
                 // boxnoteright
                 Html::closeForm();
                 echo "</div>";
                 // boxnote
             }
         }
     }
     return true;
 }
Esempio n. 10
0
 /**
  * Prints the model add form (into devices)
  *
  * @param $device the device ID
  * @param $type the device type
  * @return nothing (print out a table)
  *
  */
 static function showForm($itemtype, $items_id)
 {
     global $DB, $CFG_GLPI;
     $canedit = plugin_manufacturersimports_haveRight('manufacturersimports', 'w');
     $query = "SELECT *\n          FROM `glpi_plugin_manufacturersimports_models`\n          WHERE `itemtype` = '" . $itemtype . "'\n          AND `items_id` = '" . $items_id . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/manufacturersimports/front/config.form.php\">";
     echo "<div align=\"center\"><table class=\"tab_cadre_fixe\"  cellspacing=\"2\" cellpadding=\"2\">";
     echo "<tr>";
     echo "<th>" . PluginManufacturersimportsPreImport::getTypeName(2) . "</th>";
     echo "<th>" . __('Model Number', 'manufacturersimports') . "</th>";
     echo "</tr>";
     if ($number == 1) {
         while ($line = $DB->fetch_array($result)) {
             $ID = $line["id"];
             echo "<tr class='tab_bg_2'>";
             echo "<td class='left'>";
             echo "<input type='text' name='model_name' size='30' value='" . $line["model_name"] . "'>";
             echo "</td>";
             if ($canedit) {
                 echo "<td class='center' class='tab_bg_2'>";
                 Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/manufacturersimports/front/config.form.php', 'delete_model', _x('button', 'Delete permanently'), array('id' => $ID));
                 echo "</td>";
             } else {
                 echo "<td>";
                 echo "</td>";
             }
             echo "</tr>";
         }
     } else {
         if ($canedit) {
             echo "<tr>";
             echo "<th colspan='2'>";
             echo "<input type='text' name='model_name' size='30'>";
             echo "<input type='hidden' name='items_id' value='" . $items_id . "'>";
             echo "<input type='hidden' name='itemtype' value='" . $itemtype . "'>";
             echo "<input type=\"submit\" name=\"update_model\" class=\"submit\" value='" . _sx('button', 'Save') . "' >";
             echo "</th></tr>";
         }
     }
     echo "</table></div>";
     Html::closeForm();
 }
Esempio n. 11
0
 /**
  * Show bookmarks list
  *
  * @param $target       target to use for links
  * @param $is_private   show private of public bookmarks ? (default 1)
  *
  * @return nothing
  **/
 function showBookmarkList($target, $is_private = 1)
 {
     global $DB, $CFG_GLPI;
     if (!$is_private && !static::canView()) {
         return false;
     }
     $query = "SELECT `" . $this->getTable() . "`.*,\n                       `glpi_bookmarks_users`.`id` AS IS_DEFAULT\n                FROM `" . $this->getTable() . "`\n                LEFT JOIN `glpi_bookmarks_users`\n                  ON (`" . $this->getTable() . "`.`itemtype` = `glpi_bookmarks_users`.`itemtype`\n                      AND `" . $this->getTable() . "`.`id` = `glpi_bookmarks_users`.`bookmarks_id`\n                      AND `glpi_bookmarks_users`.`users_id` = '" . Session::getLoginUserID() . "')\n                WHERE ";
     if ($is_private) {
         $query .= "(`" . $this->getTable() . "`.`is_private`='1'\n                     AND `" . $this->getTable() . "`.`users_id`='" . Session::getLoginUserID() . "') ";
     } else {
         $query .= "(`" . $this->getTable() . "`.`is_private`='0' " . getEntitiesRestrictRequest("AND", $this->getTable(), "", "", true) . ")";
     }
     $query .= " ORDER BY `itemtype`, `name`";
     // get bookmarks
     $bookmarks = array();
     if ($result = $DB->query($query)) {
         if ($numrows = $DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $bookmarks[$data['id']] = $data;
             }
         }
     }
     $ordered_bookmarks = array();
     // get personal order
     if ($is_private) {
         $user = new User();
         $personalorderfield = 'privatebookmarkorder';
         if ($user->getFromDB(Session::getLoginUserID())) {
             $personalorder = importArrayFromDB($user->fields[$personalorderfield]);
         }
         if (!is_array($personalorder)) {
             $personalorder = array();
         }
         // Add bookmarks on personal order
         if (count($personalorder)) {
             foreach ($personalorder as $val) {
                 if (isset($bookmarks[$val])) {
                     $ordered_bookmarks[$val] = $bookmarks[$val];
                     unset($bookmarks[$val]);
                 }
             }
         }
     }
     // Add unsaved in order bookmarks
     if (count($bookmarks)) {
         foreach ($bookmarks as $key => $val) {
             $ordered_bookmarks[$key] = $val;
         }
     }
     if ($is_private) {
         // New bookmark : save order
         $store_bookmark = array_keys($ordered_bookmarks);
         $user->update(array('id' => Session::getLoginUserID(), $personalorderfield => exportArrayToDB($store_bookmark)));
     }
     $rand = mt_rand();
     $numrows = $DB->numrows($result);
     Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     echo "<div class='center' id='tabsbody' >";
     $maactions = array('purge' => _x('button', 'Delete permanently'));
     if ($is_private) {
         $maactions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'move_bookmark'] = __('Move');
     }
     $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand, 'width' => 600, 'extraparams' => array('is_private' => $is_private), 'height' => 200, 'specific_actions' => $maactions);
     // No massive action on bottom
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     echo "<th>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     echo "<th class='center' colspan='2'>" . _n('Bookmark', 'Bookmarks', Session::getPluralNumber()) . "</th>";
     echo "<th width='20px'>&nbsp;</th>";
     echo "<th>" . __('Default view') . "</th>";
     $colspan = 5;
     if ($is_private) {
         $colspan += 2;
         echo "<th colspan='2'>&nbsp;</th>";
     }
     echo "</tr>";
     if ($totalcount = count($ordered_bookmarks)) {
         $current_type = -1;
         $number = 0;
         $current_type_name = NOT_AVAILABLE;
         foreach ($ordered_bookmarks as $key => $this->fields) {
             $number++;
             if ($current_type != $this->fields['itemtype']) {
                 $current_type = $this->fields['itemtype'];
                 $current_type_name = NOT_AVAILABLE;
                 if ($current_type == "AllAssets") {
                     $current_type_name = __('Global');
                 } else {
                     if ($item = getItemForItemtype($current_type)) {
                         $current_type_name = $item->getTypeName(1);
                     }
                 }
             }
             $canedit = $this->canEdit($this->fields["id"]);
             echo "<tr class='tab_bg_1'>";
             echo "<td width='10px'>";
             if ($canedit) {
                 Html::showMassiveActionCheckBox(__CLASS__, $this->fields["id"]);
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
             echo "<td>{$current_type_name}</td>";
             echo "<td>";
             if ($canedit) {
                 echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=edit&amp;id=" . $this->fields["id"] . "\" alt='" . _sx('button', 'Update') . "'>" . $this->fields["name"] . "</a>";
             } else {
                 echo $this->fields["name"];
             }
             echo "</td>";
             echo "<td><a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=load&amp;id=" . $this->fields["id"] . "\" class='vsubmit'>" . __('Load') . "</a>";
             echo "</td>";
             echo "<td class='center'>";
             if ($this->fields['type'] == self::SEARCH) {
                 if (is_null($this->fields['IS_DEFAULT'])) {
                     echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=edit&amp;" . "mark_default=1&amp;id=" . $this->fields["id"] . "\" alt=\"" . __s('Not default search') . "\" itle=\"" . __s('Not default search') . "\">" . "<img src=\"" . $CFG_GLPI['root_doc'] . "/pics/bookmark_record.png\" class='pointer'></a>";
                 } else {
                     echo "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/bookmark.php?action=edit&amp;" . "mark_default=0&amp;id=" . $this->fields["id"] . "\" alt=\"" . __s('Default search') . "\" title=\"" . __s('Default search') . "\">" . "<img src=\"" . $CFG_GLPI['root_doc'] . "/pics/bookmark_default.png\" class='pointer'></a>";
                 }
             }
             echo "</td>";
             if ($is_private) {
                 if ($number != 1) {
                     echo "<td>";
                     Html::showSimpleForm($this->getSearchURL(), array('action' => 'up'), '', array('id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_up.png");
                     echo "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
                 if ($number != $totalcount) {
                     echo "<td>";
                     Html::showSimpleForm($this->getSearchURL(), array('action' => 'down'), '', array('id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_down.png");
                     echo "</td>";
                 } else {
                     echo "<td>&nbsp;</td>";
                 }
             }
             echo "</tr>";
             $first = false;
         }
         echo "</table></div>";
         if ($is_private || Session::haveRight('bookmark_public', PURGE)) {
             $massiveactionparams['ontop'] = false;
             $massiveactionparams['forcecreate'] = true;
             Html::showMassiveActions($massiveactionparams);
         }
     } else {
         echo "<tr class='tab_bg_1'><td colspan='{$colspan}'>";
         _e('You have not recorded any bookmarks yet');
         echo "</td></tr></table>";
     }
     Html::closeForm();
 }
Esempio n. 12
0
 /**
  * Display Ajax Footer for debug
  **/
 static function ajaxFooter()
 {
     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         // mode debug
         $rand = mt_rand();
         echo "<div class='center' id='debugajax'>";
         echo "<a class='debug-float' href=\"javascript:showHideDiv('see_ajaxdebug{$rand}','','','');\">\n                AJAX DEBUG</a>";
         if (!isset($_POST['full_page_tab']) && strstr($_SERVER['REQUEST_URI'], '/ajax/common.tabs.php')) {
             echo "&nbsp;&nbsp;&nbsp;&nbsp;";
             Html::showSimpleForm($_SERVER['REQUEST_URI'], 'full_page_tab', 'Display only tab for debug', $_POST);
         }
         echo "</div>";
         echo "<div id='see_ajaxdebug{$rand}' name='see_ajaxdebug{$rand}' style=\"display:none;\">";
         self::displayDebugInfos(false);
         echo "</div></div>";
     }
 }
Esempio n. 13
0
 /**
  * Display linked projets to a projet
  *
  * @param $ID ID of the projet id
  *
  * @return nothing display
  **/
 static function displayLinkedProjetTasksTo($ID, $notif = false)
 {
     global $DB, $CFG_GLPI;
     $tasks = self::getParentProjetTasksTo($ID);
     $canupdate = plugin_projet_haveRight('task', 'w');
     $task = new PluginProjetTask();
     if (is_array($tasks) && count($tasks)) {
         foreach ($tasks as $linkID => $data) {
             if ($notif) {
                 return Dropdown::getDropdownName("glpi_plugin_projet_tasks", $data['plugin_projet_tasks_id']);
             } else {
                 echo self::getLinkName($data['link']) . "&nbsp;";
                 if (!$_SESSION['glpiis_ids_visible']) {
                     echo __('ID') . "&nbsp;" . $data['plugin_projet_tasks_id'] . "&nbsp;:&nbsp;";
                 }
                 if ($task->getFromDB($data['plugin_projet_tasks_id'])) {
                     echo $task->getLink();
                     if ($canupdate) {
                         echo "&nbsp;";
                         Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/projet/front/task.form.php', 'delete_link', _x('button', 'Delete permanently'), array('delete_link' => 'delete_link', 'id' => $linkID, 'plugin_projet_tasks_id' => $ID), $CFG_GLPI["root_doc"] . "/pics/delete.png");
                     }
                 }
             }
         }
     }
 }
Esempio n. 14
0
 /**
  * Dropdown for global item management
  *
  * @param $ID           item ID
  * @param attrs   array which contains the extra paramters
  *
  * Parameters can be :
  * - target target for actions
  * - withtemplate template or basic computer
  * - value value of global state
  * - management_restrict global management restrict mode
  **/
 static function showGlobalSwitch($ID, $attrs = array())
 {
     global $CFG_GLPI;
     $params['management_restrict'] = 0;
     $params['value'] = 0;
     $params['name'] = 'is_global';
     $params['target'] = '';
     foreach ($attrs as $key => $value) {
         if ($value != '') {
             $params[$key] = $value;
         }
     }
     if ($params['value'] && empty($params['withtemplate'])) {
         _e('Global management');
         if ($params['management_restrict'] == 2) {
             echo "&nbsp;";
             Html::showSimpleForm($params['target'], 'unglobalize', __('Use unitary management'), array('id' => $ID), '', '', array(__('Do you really want to use unitary management for this item?'), __('Duplicate the element as many times as there are connections')));
             echo "&nbsp;";
             echo "<img alt=\"" . __s('Duplicate the element as many times as there are connections') . "\" title=\"" . __s('Duplicate the element as many times as there are connections') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/info-small.png' class='pointer'>";
         }
     } else {
         if ($params['management_restrict'] == 2) {
             $rand = mt_rand();
             $values = array(MANAGEMENT_UNITARY => __('Unit management'), MANAGEMENT_GLOBAL => __('Global management'));
             Dropdown::showFromArray($params['name'], $values, array('value' => $params['value']));
         } else {
             // Templates edition
             if (!empty($params['withtemplate'])) {
                 echo "<input type='hidden' name='is_global' value='" . $params['management_restrict'] . "'>";
                 echo !$params['management_restrict'] ? __('Unit management') : __('Global management');
             } else {
                 echo !$params['value'] ? __('Unit management') : __('Global management');
             }
         }
     }
 }
Esempio n. 15
0
 /**
  * Override title function to display the link to reinitialisation of the network tree
  **/
 function title()
 {
     parent::title();
     if (Session::haveRight('internet', UPDATE) && Session::isViewAllEntities()) {
         echo "<div class='spaced' id='tabsbody'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><td class='center'>";
         Html::showSimpleForm(IPNetwork::getFormURL(), 'reinit_network', __('Reinit the network topology'));
         echo "</td></tr>";
         echo "</table>";
         echo "</div>";
     }
 }
 /**
  * Display a connection of a networking port
  *
  * @param $netport      to be displayed
  * @param $edit         boolean permit to edit ? (false by default)
  **/
 static function showConnection($netport, $edit = false)
 {
     $ID = $netport->fields["id"];
     if (empty($ID)) {
         return false;
     }
     $device1 = $netport->getItem();
     if (!$device1->can($device1->getID(), READ)) {
         return false;
     }
     $canedit = $device1->canEdit($device1->fields["id"]);
     $relations_id = 0;
     $oppositePort = NetworkPort_NetworkPort::getOpposite($netport, $relations_id);
     if ($oppositePort !== false) {
         $device2 = $oppositePort->getItem();
         if ($device2->can($device2->fields["id"], READ)) {
             $networklink = $oppositePort->getLink();
             $tooltip = Html::showToolTip($oppositePort->fields['comment'], array('display' => false));
             $netlink = sprintf(__('%1$s %2$s'), "<span class='b'>" . $networklink . "</span>\n", $tooltip);
             //TRANS: %1$s and %2$s are links
             echo "&nbsp;" . sprintf(__('%1$s on %2$s'), $netlink, "<span class='b'>" . $device2->getLink() . "</span>");
             if ($device1->fields["entities_id"] != $device2->fields["entities_id"]) {
                 echo "<br>(" . Dropdown::getDropdownName("glpi_entities", $device2->getEntityID()) . ")";
             }
             // write rights on dev1 + READ on dev2 OR READ on dev1 + write rights on dev2
             if ($canedit || $device2->canEdit($device2->fields["id"])) {
                 echo "&nbsp;";
                 Html::showSimpleForm($oppositePort->getFormURL(), 'disconnect', _x('button', 'Disconnect'), array('id' => $relations_id));
             }
         } else {
             if (rtrim($oppositePort->fields["name"]) != "") {
                 $netname = $oppositePort->fields["name"];
             } else {
                 $netname = __('Without name');
             }
             printf(__('%1$s on %2$s'), "<span class='b'>" . $netname . "</span>", "<span class='b'>" . $device2->getName() . "</span>");
             echo "<br>(" . Dropdown::getDropdownName("glpi_entities", $device2->getEntityID()) . ")";
         }
     } else {
         echo "<div id='not_connected_display{$ID}'>" . __('Not connected.') . "</div>";
         if ($canedit) {
             if (!$device1->isTemplate()) {
                 if ($edit) {
                     self::dropdownConnect($ID, array('name' => 'NetworkPortConnect_networkports_id_2', 'entity' => $device1->fields["entities_id"], 'entity_sons' => $device1->isRecursive()));
                 } else {
                     echo "<a href=\"" . $netport->getFormURL() . "?id={$ID}\">" . _x('button', 'Connect') . "</a>";
                 }
             } else {
                 echo "&nbsp;";
             }
         }
     }
 }
 /**
  * Prints the model add form (into devices)
  *
  * @param $device the device ID
  * @param $type the device type
  * @return nothing (print out a table)
  *
  */
 static function showForm($itemtype, $items_id)
 {
     global $DB, $CFG_GLPI;
     $canedit = Session::haveRight(static::$rightname, UPDATE);
     $query = "SELECT *\n               FROM `glpi_plugin_manufacturersimports_models`\n               WHERE `itemtype` = '" . $itemtype . "'\n                  AND `items_id` = '" . $items_id . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $config_url = PluginManufacturersimportsConfig::getFormUrl(true);
     echo "<form method='post' action='" . $config_url . "'>";
     echo "<div align='center'><table class='tab_cadre_fixe'  cellspacing='2' cellpadding='2'>";
     echo "<tr>";
     echo "<th>" . PluginManufacturersimportsPreImport::getTypeName(2) . "</th>";
     echo "<th>" . __('Model Number', 'manufacturersimports') . "</th>";
     echo "</tr>";
     if ($number == 1) {
         while ($line = $DB->fetch_array($result)) {
             $ID = $line["id"];
             echo "<tr class='tab_bg_2'>";
             echo "<td class='left'>";
             echo "<input type='text' name='model_name' size='30' value='" . $line["model_name"] . "'>";
             echo "</td>";
             if ($canedit) {
                 echo "<td class='center' class='tab_bg_2'>";
                 Html::showSimpleForm($config_url, 'delete_model', _x('button', 'Delete permanently'), array('id' => $ID));
                 echo "</td>";
             } else {
                 echo "<td>";
                 echo "</td>";
             }
             echo "</tr>";
         }
     } else {
         if ($canedit) {
             echo "<tr>";
             echo "<th colspan='2'>";
             echo "<input type='text' name='model_name' size='30'>";
             echo Html::hidden('items_id', array('value' => $items_id));
             echo Html::hidden('itemtype', array('value' => $itemtype));
             echo Html::submit(_sx('button', 'Save'), array('name' => 'update_model'));
             echo "</th></tr>";
         }
     }
     echo "</table></div>";
     Html::closeForm();
 }
Esempio n. 18
0
 /**
  * Display a list of computers to add or to link
  *
  * @param plugin_ocsinventoryng_ocsservers_id the ID of the ocs server
  * @param advanced display detail about the computer import or not (target entity, matched rules, etc.)
  * @param check indicates if checkboxes are checked or not
  * @param start display a list of computers starting at rowX
  * @param entity a list of entities in which computers can be added or linked
  * @param tolinked false for an import, true for a link
  *
  * @return nothing
  **/
 static function showComputersToAdd($plugin_ocsinventoryng_ocsservers_id, $advanced, $check, $start, $entity = 0, $tolinked = false)
 {
     global $DB, $PluginOcsinventoryngDBocs, $CFG_GLPI;
     if (!plugin_ocsinventoryng_haveRight("ocsng", "w")) {
         return false;
     }
     $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.import.php';
     if ($tolinked) {
         $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.link.php';
     }
     $cfg_ocs = self::getConfig($plugin_ocsinventoryng_ocsservers_id);
     $WHERE = self::getTagLimit($cfg_ocs);
     $query_ocs = "SELECT `hardware`.*,\n                           `accountinfo`.`TAG` AS TAG,\n                           `bios`.`SSN` AS SERIAL,\n                           `bios`.`SMODEL`,\n                           `bios`.`SMANUFACTURER`\n                    FROM `hardware`\n                    INNER JOIN `accountinfo` ON (`hardware`.`id` = `accountinfo`.`HARDWARE_ID`)\n                    INNER JOIN `bios` ON (`hardware`.`id` = `bios`.`HARDWARE_ID`)" . (!empty($WHERE) ? "WHERE {$WHERE}" : "") . "\n                    ORDER BY `hardware`.`NAME`";
     $result_ocs = $PluginOcsinventoryngDBocs->query($query_ocs);
     // Existing OCS - GLPI link
     $query_glpi = "SELECT*\n                     FROM `glpi_plugin_ocsinventoryng_ocslinks`\n                     WHERE `plugin_ocsinventoryng_ocsservers_id`\n                              = '{$plugin_ocsinventoryng_ocsservers_id}'";
     $result_glpi = $DB->query($query_glpi);
     if ($PluginOcsinventoryngDBocs->numrows($result_ocs) > 0) {
         // Get all hardware from OCS DB
         $hardware = array();
         while ($data = $PluginOcsinventoryngDBocs->fetch_array($result_ocs)) {
             $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
             $hardware[$data["ID"]]["date"] = $data["LASTDATE"];
             $hardware[$data["ID"]]["name"] = $data["NAME"];
             $hardware[$data["ID"]]["TAG"] = $data["TAG"];
             $hardware[$data["ID"]]["id"] = $data["ID"];
             $hardware[$data["ID"]]["serial"] = $data["SERIAL"];
             $hardware[$data["ID"]]["model"] = $data["SMODEL"];
             $hardware[$data["ID"]]["manufacturer"] = $data["SMANUFACTURER"];
             $query_network = "SELECT*\n                              FROM `networks`\n                              WHERE `HARDWARE_ID` = '" . $data["ID"] . "'";
             //Get network informations for this computer
             //Ignore informations that contains "??"
             foreach ($PluginOcsinventoryngDBocs->request($query_network) as $network) {
                 if (isset($network['IPADDRESS']) && $network['IPADDRESS'] != '??') {
                     $hardware[$data["ID"]]['IPADDRESS'][] = $network['IPADDRESS'];
                 }
                 if (isset($network['IPSUBNET']) && $network['IPSUBNET'] != '??') {
                     $hardware[$data["ID"]]['IPSUBNET'][] = $network['IPSUBNET'];
                 }
                 if (isset($network['MACADDRESS']) && $network['MACADDR'] != '??') {
                     $hardware[$data["ID"]]['MACADDRESS'][] = $network['MACADDR'];
                 }
             }
         }
         // Get all links between glpi and OCS
         $already_linked = array();
         if ($DB->numrows($result_glpi) > 0) {
             while ($data = $PluginOcsinventoryngDBocs->fetch_array($result_glpi)) {
                 $already_linked[$data["ocsid"]] = $data["last_update"];
             }
         }
         // Clean $hardware from already linked element
         if (count($already_linked) > 0) {
             foreach ($already_linked as $ID => $date) {
                 if (isset($hardware[$ID]) && isset($already_linked[$ID])) {
                     unset($hardware[$ID]);
                 }
             }
         }
         if ($tolinked && count($hardware)) {
             echo "<div class='center b'>" . __('Caution! The imported data (see your configuration) will overwrite the existing one', 'ocsinventoryng') . "</div>";
         }
         echo "<div class='center'>";
         if (($numrows = count($hardware)) > 0) {
             $parameters = "check={$check}";
             Html::printPager($start, $numrows, $target, $parameters);
             // delete end
             array_splice($hardware, $start + $_SESSION['glpilist_limit']);
             // delete begin
             if ($start > 0) {
                 array_splice($hardware, 0, $start);
             }
             //Show preview form only in import even in multi-entity mode because computer import
             //can be refused by a rule
             if (!$tolinked) {
                 echo "<div class='firstbloc'>";
                 echo "<form method='post' name='ocsng_import_mode' id='ocsng_import_mode'\n                      action='{$target}'>\n";
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . __('Manual import mode', 'ocsinventoryng') . "</th></tr>\n";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 if ($advanced) {
                     Html::showSimpleForm($target, 'change_import_mode', __('Disable preview', 'ocsinventoryng'), array('id' => 'false'));
                 } else {
                     Html::showSimpleForm($target, 'change_import_mode', __('Enable preview', 'ocsinventoryng'), array('id' => 'true'));
                 }
                 echo "</td></tr>";
                 echo "<tr class='tab_bg_1'><td class='center b'>" . __('Check first that duplicates have been correctly managed in OCSNG', 'ocsinventoryng') . "</td>";
                 echo "</tr></table>";
                 Html::closeForm();
                 echo "</div>";
             }
             echo "<form method='post' name='ocsng_form' id='ocsng_form' action='{$target}'>";
             if (!$tolinked) {
                 self::checkBox($target);
             }
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
             echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">";
             echo "</td></tr>\n";
             echo "<tr><th>" . __('Name') . "</th>\n";
             echo "<th>" . __('Manufacturer') . "</th>\n";
             echo "<th>" . __('Model') . "</th>\n";
             echo "<th>" . __('Serial number') . "</th>\n";
             echo "<th>" . __('Date') . "</th>\n";
             echo "<th>" . __('OCSNG TAG', 'ocsinventoryng') . "</th>\n";
             if ($advanced && !$tolinked) {
                 echo "<th>" . __('Match the rule ?', 'ocsinventoryng') . "</th>\n";
                 echo "<th>" . __('Destination entity') . "</th>\n";
                 echo "<th>" . __('Target location', 'ocsinventoryng') . "</th>\n";
             }
             echo "<th>&nbsp;</th></tr>\n";
             $rule = new RuleImportEntityCollection();
             foreach ($hardware as $ID => $tab) {
                 $comp = new Computer();
                 $comp->fields["id"] = $tab["id"];
                 $data = array();
                 if ($advanced && !$tolinked) {
                     $data = $rule->processAllRules(array('ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, '_source' => 'ocsinventoryng'), array(), array('ocsid' => $tab["id"]));
                 }
                 echo "<tr class='tab_bg_2'><td>" . $tab["name"] . "</td>\n";
                 echo "<td>" . $tab["manufacturer"] . "</td><td>" . $tab["model"] . "</td>";
                 echo "<td>" . $tab["serial"] . "</td>\n";
                 echo "<td>" . Html::convDateTime($tab["date"]) . "</td>\n";
                 echo "<td>" . $tab["TAG"] . "</td>\n";
                 if ($advanced && !$tolinked) {
                     if (!isset($data['entities_id']) || $data['entities_id'] == -1) {
                         echo "<td class='center'><img src=\"" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png\"></td>\n";
                         $data['entities_id'] = -1;
                     } else {
                         echo "<td class='center'>";
                         $tmprule = new RuleImportEntity();
                         if ($tmprule->can($data['_ruleid'], 'r')) {
                             echo "<a href='" . $tmprule->getLinkURL() . "'>" . $tmprule->getName() . "</a>";
                         } else {
                             echo $tmprule->getName();
                         }
                         echo "</td>\n";
                     }
                     echo "<td>";
                     Entity::dropdown(array('name' => "toimport_entities[" . $tab["id"] . "]=" . $data['entities_id'], 'value' => $data['entities_id'], 'comments' => 0));
                     echo "</td>\n";
                     echo "<td>";
                     if (!isset($data['locations_id'])) {
                         $data['locations_id'] = 0;
                     }
                     Location::dropdown(array('name' => "toimport_locations[" . $tab["id"] . "]=" . $data['locations_id'], 'value' => $data['locations_id'], 'comments' => 0));
                     echo "</td>\n";
                 }
                 echo "<td>";
                 if (!$tolinked) {
                     echo "<input type='checkbox' name='toimport[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . ">";
                 } else {
                     $rulelink = new RuleImportComputerCollection();
                     $rulelink_results = array();
                     $params = array('entities_id' => $entity, 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id);
                     $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab), array(), $params);
                     //Look for the computer using automatic link criterias as defined in OCSNG configuration
                     $options = array('name' => "tolink[" . $tab["id"] . "]");
                     $show_dropdown = true;
                     //If the computer is not explicitly refused by a rule
                     if (!isset($rulelink_results['action']) || $rulelink_results['action'] != self::LINK_RESULT_NO_IMPORT) {
                         if (!empty($rulelink_results['found_computers'])) {
                             $options['value'] = $rulelink_results['found_computers'][0];
                             $options['entity'] = $entity;
                         }
                         Computer::dropdown($options);
                     } else {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'>";
                     }
                 }
                 echo "</td></tr>\n";
             }
             echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
             echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">\n";
             echo "<input type=hidden name='plugin_ocsinventoryng_ocsservers_id' " . "value='{$plugin_ocsinventoryng_ocsservers_id}'>";
             echo "</td></tr>";
             echo "</table>\n";
             Html::closeForm();
             if (!$tolinked) {
                 self::checkBox($target);
             }
             Html::printPager($start, $numrows, $target, $parameters);
         } else {
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . __('Import new computers') . "</th></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
             echo "</table>";
         }
         echo "</div>";
     } else {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('Import new computers', 'ocsinventoryng') . "</th></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
         echo "</table></div>";
     }
 }
Esempio n. 19
0
 /**
  * Show discovered feeds
  *
  * @return nothin
  **/
 function showDiscoveredFeeds()
 {
     $feed = new SimplePie();
     $feed->set_cache_location(GLPI_RSS_DIR);
     $feed->enable_cache(false);
     $feed->set_feed_url($this->fields['url']);
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         return false;
     }
     foreach ($feed->get_all_discovered_feeds() as $f) {
         $newurl = $f->url;
         $newfeed = self::getRSSFeed($newurl);
         if ($newfeed && !$newfeed->error()) {
             $link = $newfeed->get_permalink();
             if (!empty($link)) {
                 echo "<a href='{$newurl}'>" . $newfeed->get_title() . "</a>&nbsp;";
                 Html::showSimpleForm($this->getFormURL(), 'update', _x('button', 'Use'), array('id' => $this->getID(), 'url' => $newurl));
                 echo "<br>";
             }
         }
     }
 }
Esempio n. 20
0
 /**
  * Show simple inventory information of an item
  *
  * @param $item                   CommonDBTM object
  *
  * @return nothing
  **/
 static function showSimpleForItem(CommonDBTM $item)
 {
     global $DB, $CFG_GLPI;
     $target = Toolbox::getItemTypeFormURL(__CLASS__);
     if (in_array($item->getType(), array('Computer'))) {
         $items_id = $item->getField('id');
         if (!empty($items_id) && $item->fields["is_dynamic"] && Session::haveRight("plugin_ocsinventoryng_view", READ)) {
             $query = "SELECT *\n                      FROM `glpi_plugin_ocsinventoryng_ocslinks`\n                      WHERE `computers_id` = '{$items_id}' " . getEntitiesRestrictRequest("AND", "glpi_plugin_ocsinventoryng_ocslinks");
             $result = $DB->query($query);
             if ($DB->numrows($result) > 0) {
                 $data = $DB->fetch_assoc($result);
                 if (count($data)) {
                     $ocs_config = PluginOcsinventoryngOcsServer::getConfig($data['plugin_ocsinventoryng_ocsservers_id']);
                     echo "<table class='tab_glpi'>";
                     echo "<tr class='tab_bg_1'><th colspan='2'>" . __('OCS Inventory NG') . "</th>";
                     if (isset($data["last_ocs_conn"])) {
                         echo "<tr class='tab_bg_1'><td>" . __('Last OCSNG connection date', 'ocsinventoryng');
                         echo "</td><td>" . Html::convDateTime($data["last_ocs_conn"]) . '</td></tr>';
                     }
                     echo "<tr class='tab_bg_1'><td>" . __('Last OCSNG inventory date', 'ocsinventoryng');
                     echo "</td><td>" . Html::convDateTime($data["last_ocs_update"]) . '</td></tr>';
                     echo "<tr class='tab_bg_1'><td>" . __('GLPI import date', 'ocsinventoryng');
                     echo "</td><td>" . Html::convDateTime($data["last_update"]) . '</td></tr>';
                     echo "<tr class='tab_bg_1'><td>" . __('Inventory agent', 'ocsinventoryng');
                     echo "</td><td>" . $data["ocs_agent_version"] . '</td></tr>';
                     if (isset($data["ip_src"])) {
                         echo "<tr class='tab_bg_1'><td>" . __('IP Source', 'ocsinventoryng');
                         echo "</td><td>" . $data["ip_src"] . '</td></tr>';
                     }
                     echo "<tr class='tab_bg_1'><td>" . __('Server');
                     echo "</td><td>";
                     if (Session::haveRight("plugin_ocsinventoryng", READ)) {
                         echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/front/ocsserver.form.php?id=" . $ocs_config['id'] . "'>" . $ocs_config['name'] . "</a>";
                     } else {
                         echo $ocs_config['name'];
                     }
                     echo '</td></tr>';
                     //If have write right on OCS and ocsreports url is not empty in OCS config
                     if (Session::haveRight("plugin_ocsinventoryng", UPDATE) && $ocs_config["ocs_url"] != '') {
                         echo "<tr class='tab_bg_1'><td colspan='2' class='center'>";
                         echo PluginOcsinventoryngOcsServer::getComputerLinkToOcsConsole($ocs_config['id'], $data["ocsid"], __('OCS NG Interface', 'ocsinventoryng'));
                         echo "</td></tr>";
                     }
                     echo "<tr class='tab_bg_1'><td>" . __('OCSNG TAG', 'ocsinventoryng') . "</td>";
                     echo "<td>";
                     echo $data["tag"];
                     echo "</td></tr>";
                     if (Session::haveRight("plugin_ocsinventoryng_view", READ) && Session::haveRight("plugin_ocsinventoryng_sync", UPDATE)) {
                         echo "<tr class='tab_bg_1'><td>" . __('Automatic update OCSNG', 'ocsinventoryng') . "</td>";
                         echo "<td>";
                         echo Dropdown::getYesNo($data["use_auto_update"]);
                         echo "</td></tr>";
                     }
                     if (Session::haveRight("plugin_ocsinventoryng_sync", UPDATE)) {
                         echo "<tr class='tab_bg_1'><td class='center' colspan='2'>";
                         Html::showSimpleForm($target, 'force_ocs_resynch', _sx('button', 'Force synchronization', 'ocsinventoryng'), array('id' => $items_id, 'resynch_id' => $data["id"]));
                         echo "</td></tr>";
                     }
                     echo '</table>';
                 }
             }
         }
     }
 }
Esempio n. 21
0
 /**
  * List availabled plugins
  **/
 function listPlugins()
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     $this->checkStates();
     echo "<div class='center'><table class='tab_cadrehov'>";
     $pluglist = $this->find("", "name, directory");
     $i = 0;
     $PLUGIN_HOOKS_SAVE = $PLUGIN_HOOKS;
     echo "<tr><th colspan='9'>" . __('Plugins list') . "</th></tr>\n";
     if (!empty($pluglist)) {
         echo "<tr><th>" . __('Name') . "</th><th>" . _n('Version', 'Versions', 1) . "</th>";
         echo "<th>" . __('License') . "</th>";
         echo "<th>" . __('Status') . "</th><th>" . _n('Author', 'Authors', Session::getPluralNumber()) . "</th>";
         echo "<th>" . __('Website') . "</th>";
         echo "<th>" . __('CSRF compliant') . "</th>";
         echo "<th colspan='2'>&nbsp;</th></tr>\n";
         foreach ($pluglist as $ID => $plug) {
             if (function_exists("plugin_" . $plug['directory'] . "_check_config")) {
                 // init must not be called for incompatible plugins
                 self::load($plug['directory'], true);
             }
             $i++;
             $class = 'tab_bg_1';
             if ($i % 2 == 0) {
                 $class = 'tab_bg_2';
             }
             echo "<tr class='{$class}'>";
             echo "<td>";
             $name = trim($plug['name']);
             if (empty($name)) {
                 $plug['name'] = $plug['directory'];
             }
             // Only config for install plugins
             if (in_array($plug['state'], array(self::ACTIVATED, self::TOBECONFIGURED, self::NOTACTIVATED)) && isset($PLUGIN_HOOKS['config_page'][$plug['directory']])) {
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/" . $plug['directory'] . "/" . $PLUGIN_HOOKS['config_page'][$plug['directory']] . "'>\n                      <span class='b'>" . $plug['name'] . "</span></a>";
             } else {
                 echo $plug['name'];
             }
             echo "</td>";
             echo "<td>" . $plug['version'] . "</td><td>";
             if ($plug['license']) {
                 $link = '';
                 if (file_exists(GLPI_ROOT . '/plugins/' . $plug['directory'] . '/LICENSE')) {
                     $link = $CFG_GLPI['root_doc'] . '/plugins/' . $plug['directory'] . '/LICENSE';
                 } else {
                     if (file_exists(GLPI_ROOT . '/plugins/' . $plug['directory'] . '/COPYING.txt')) {
                         $link = $CFG_GLPI['root_doc'] . '/plugins/' . $plug['directory'] . '/COPYING.txt';
                     }
                 }
                 if ($link) {
                     echo "<a href='{$link}'>" . $plug['license'] . "</a>";
                 } else {
                     echo $plug['license'];
                 }
             } else {
                 echo "&nbsp;";
             }
             echo "</td><td>";
             switch ($plug['state']) {
                 case self::ANEW:
                     echo _x('status', 'New');
                     break;
                 case self::ACTIVATED:
                     echo _x('plugin', 'Enabled');
                     break;
                 case self::NOTINSTALLED:
                     echo _x('plugin', 'Not installed');
                     break;
                 case self::NOTUPDATED:
                     _e('To update');
                     break;
                 case self::TOBECONFIGURED:
                     echo _x('plugin', 'Installed / not configured');
                     break;
                 case self::NOTACTIVATED:
                     echo _x('plugin', 'Installed / not activated');
                     break;
                 case self::TOBECLEANED:
                 default:
                     _e('Error / to clean');
                     break;
             }
             echo "</td>";
             echo "<td>" . $plug['author'] . "</td>";
             $weblink = trim($plug['homepage']);
             echo "<td>";
             if (!empty($weblink)) {
                 echo "<a href='" . formatOutputWebLink($weblink) . "' target='_blank'>";
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/web.png' class='middle' alt=\"" . __s('Web') . "\" title=\"" . __s('Web') . "\" ></a>";
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
             // CSRF
             echo "<td>";
             if (isset($PLUGIN_HOOKS['csrf_compliant'][$plug['directory']]) && $PLUGIN_HOOKS['csrf_compliant'][$plug['directory']]) {
                 _e('Yes');
             } else {
                 echo "<span class='red b'>";
                 _e('No');
                 echo "</span>";
             }
             echo "</td>";
             switch ($plug['state']) {
                 case self::ACTIVATED:
                     echo "<td>";
                     Html::showSimpleForm(static::getFormURL(), array('action' => 'unactivate'), _x('button', 'Disable'), array('id' => $ID));
                     echo "</td>";
                     echo "<td>";
                     if (function_exists("plugin_" . $plug['directory'] . "_uninstall")) {
                         Html::showSimpleForm(static::getFormURL(), array('action' => 'uninstall'), _x('button', 'Uninstall'), array('id' => $ID));
                     } else {
                         //TRANS: %s is the list of missing functions
                         echo sprintf(__('%1$s: %2$s'), __('Non-existent function'), "plugin_" . $plug['directory'] . "_uninstall");
                     }
                     echo "</td>";
                     break;
                 case self::ANEW:
                 case self::NOTINSTALLED:
                 case self::NOTUPDATED:
                     echo "<td>";
                     if (function_exists("plugin_" . $plug['directory'] . "_install") && function_exists("plugin_" . $plug['directory'] . "_check_config")) {
                         $function = 'plugin_' . $plug['directory'] . '_check_prerequisites';
                         $do_install = true;
                         if (function_exists($function)) {
                             $do_install = $function();
                         }
                         if ($plug['state'] == self::NOTUPDATED) {
                             $msg = _x('button', 'Upgrade');
                         } else {
                             $msg = _x('button', 'Install');
                         }
                         if ($do_install) {
                             Html::showSimpleForm(static::getFormURL(), array('action' => 'install'), $msg, array('id' => $ID));
                         }
                     } else {
                         $missing = '';
                         if (!function_exists("plugin_" . $plug['directory'] . "_install")) {
                             $missing .= "plugin_" . $plug['directory'] . "_install";
                         }
                         if (!function_exists("plugin_" . $plug['directory'] . "_check_config")) {
                             $missing .= " plugin_" . $plug['directory'] . "_check_config";
                         }
                         //TRANS: %s is the list of missing functions
                         printf(__('%1$s: %2$s'), __('Non-existent function'), $missing);
                     }
                     echo "</td><td>";
                     if (function_exists("plugin_" . $plug['directory'] . "_uninstall")) {
                         if (function_exists("plugin_" . $plug['directory'] . "_check_config")) {
                             Html::showSimpleForm(static::getFormURL(), array('action' => 'uninstall'), _x('button', 'Uninstall'), array('id' => $ID));
                         } else {
                             // This is an incompatible plugin (0.71), uninstall fonction could crash
                             echo "&nbsp;";
                         }
                     } else {
                         printf(__('%1$s: %2$s'), __('Non-existent function'), "plugin_" . $plug['directory'] . "_uninstall");
                     }
                     echo "</td>";
                     break;
                 case self::TOBECONFIGURED:
                     echo "<td>";
                     $function = 'plugin_' . $plug['directory'] . '_check_config';
                     if (function_exists($function)) {
                         if ($function(true)) {
                             $this->update(array('id' => $ID, 'state' => self::NOTACTIVATED));
                             Html::redirect($this->getSearchURL());
                         }
                     } else {
                         printf(__('%1$s: %2$s'), __('Non-existent function'), "plugin_" . $plug['directory'] . "_check_config");
                     }
                     echo "</td><td>";
                     if (function_exists("plugin_" . $plug['directory'] . "_uninstall")) {
                         Html::showSimpleForm(static::getFormURL(), array('action' => 'uninstall'), _x('button', 'Uninstall'), array('id' => $ID));
                     } else {
                         printf(__('%1$s: %2$s'), __('Non-existent function'), "plugin_" . $plug['directory'] . "_uninstall");
                     }
                     echo "</td>";
                     break;
                 case self::NOTACTIVATED:
                     echo "<td>";
                     $function = 'plugin_' . $plug['directory'] . '_check_prerequisites';
                     if (!isset($PLUGIN_HOOKS['csrf_compliant'][$plug['directory']]) || !$PLUGIN_HOOKS['csrf_compliant'][$plug['directory']]) {
                         _e('Not CSRF compliant');
                     } else {
                         if (function_exists($function) && $function()) {
                             Html::showSimpleForm(static::getFormURL(), array('action' => 'activate'), _x('button', 'Enable'), array('id' => $ID));
                         }
                     }
                     // Else : reason displayed by the plugin
                     echo "</td><td>";
                     if (function_exists("plugin_" . $plug['directory'] . "_uninstall")) {
                         Html::showSimpleForm(static::getFormURL(), array('action' => 'uninstall'), _x('button', 'Uninstall'), array('id' => $ID));
                     } else {
                         printf(__('%1$s: %2$s'), __('Non-existent function'), "plugin_" . $plug['directory'] . "_uninstall");
                     }
                     echo "</td>";
                     break;
                 case self::TOBECLEANED:
                 default:
                     echo "<td colspan='2'>";
                     Html::showSimpleForm(static::getFormURL(), array('action' => 'clean'), _x('button', 'Clean'), array('id' => $ID));
                     echo "</td>";
                     break;
             }
             echo "</tr>\n";
         }
     } else {
         echo "<tr class='tab_bg_1'><td class='center' colspan='7'>" . __('No plugin installed') . "</td></tr>";
     }
     echo "</table></div>";
     echo "<br>";
     echo "<div class='center'><p>";
     echo "<a href='http://plugins.glpi-project.org'  class='vsubmit' target='_blank'>" . __('See the catalog of plugins') . "</a></p>";
     echo "</div>";
     $PLUGIN_HOOKS = $PLUGIN_HOOKS_SAVE;
 }
Esempio n. 22
0
 /**
  * Show the minimal form for the rule
  *
  * @param $target             link to the form page
  * @param $first              is it the first rule ?(false by default)
  * @param $last               is it the last rule ? (false by default)
  * @param $display_entities   display entities / make it read only display (false by default)
  * @param $active_condition   active condition used (default 0)
  **/
 function showMinimalForm($target, $first = false, $last = false, $display_entities = false, $active_condition = 0)
 {
     global $CFG_GLPI;
     $canedit = self::canUpdate() && !$display_entities;
     echo "<tr class='tab_bg_1'>";
     if ($canedit) {
         echo "<td width='10'>";
         Html::showMassiveActionCheckBox($this->getType(), $this->fields["id"]);
         echo "</td>";
     } else {
         echo "<td>&nbsp;</td>";
     }
     $link = $this->getLink();
     if (!empty($this->fields["comment"])) {
         $link = sprintf(__('%1$s %2$s'), $link, Html::showToolTip($this->fields["comment"], array('display' => false)));
     }
     echo "<td>" . $link . "</td>";
     echo "<td>" . $this->fields["description"] . "</td>";
     if ($this->useConditions()) {
         echo "<td>" . $this->getConditionName($this->fields["condition"]) . "</td>";
     }
     echo "<td>" . Dropdown::getYesNo($this->fields["is_active"]) . "</td>";
     if ($display_entities) {
         $entname = Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']);
         if ($this->maybeRecursive() && $this->fields['is_recursive']) {
             $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
         }
         echo "<td>" . $entname . "</td>";
     }
     if (!$display_entities) {
         if ($this->can_sort && !$first && $canedit) {
             echo "<td>";
             Html::showSimpleForm($target, array('action' => 'up', 'condition' => $active_condition), '', array('type' => $this->fields["sub_type"], 'id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_up.png");
             echo "</td>";
         } else {
             echo "<td>&nbsp;</td>";
         }
     }
     if (!$display_entities) {
         if ($this->can_sort && !$last && $canedit) {
             echo "<td>";
             Html::showSimpleForm($target, array('action' => 'down', 'condition' => $active_condition), '', array('type' => $this->fields["sub_type"], 'id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_down.png");
             echo "</td>";
         } else {
             echo "<td>&nbsp;</td>";
         }
     }
     echo "</tr>\n";
 }
Esempio n. 23
0
* @brief
*/
include '../inc/includes.php';
Session::checkSeveralRightsOr(array('notification' => 'r', 'config' => 'w'));
Html::header(_n('Notification', 'Notifications', 2), $_SERVER['PHP_SELF'], "config", "mailing", -1);
if (isset($_POST['activate'])) {
    $config = new Config();
    $tmp['id'] = $CFG_GLPI['id'];
    $tmp['use_mailing'] = 1;
    $config->update($tmp);
    Html::back();
}
if (!$CFG_GLPI['use_mailing']) {
    if (Session::haveRight("config", "w")) {
        echo "<div class='center'>";
        Html::showSimpleForm($_SERVER['PHP_SELF'], 'activate', __('Enable followup via email'));
        echo "</div>";
    }
} else {
    if (!Session::haveRight("config", "r") && Session::haveRight("notification", "r") && $CFG_GLPI['use_mailing']) {
        Html::redirect($CFG_GLPI["root_doc"] . '/front/notification.php');
    } else {
        echo "<table class='tab_cadre'>";
        echo "<tr><th>" . _n('Notification', 'Notifications', 2) . "</th></tr>";
        if (Session::haveRight("config", "r")) {
            echo "<tr class='tab_bg_1'><td class='center'>" . "<a href='notificationmailsetting.form.php'>" . __('Email followups configuration') . "</a></td></tr>";
            echo "<tr class='tab_bg_1'><td class='center'><a href='notificationtemplate.php'>" . _n('Notification template', 'Notification templates', 2) . "</a></td> </tr>";
        }
        if (Session::haveRight("notification", "r") && $CFG_GLPI['use_mailing']) {
            echo "<tr class='tab_bg_1'><td class='center'>" . "<a href='notification.php'>" . _n('Notification', 'Notifications', 2) . "</a></td></tr>";
        } else {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_reports_doublons_backlists` (\n               `id` int(11) NOT NULL AUTO_INCREMENT,\n               `type` int(11) NOT NULL DEFAULT '0',\n               `addr` varchar(255) DEFAULT NULL,\n               `comment` varchar(255) DEFAULT NULL,\n               PRIMARY KEY (`id`)\n             ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
        $query = "INSERT INTO`glpi_plugin_reports_doublons_backlists`\n                    (`type`, `addr`, `comment`)\n             VALUES (1, '44:45:53:54:42:00', 'Nortel IPSECSHM Adapter'),\n                    (1, 'BA:D0:BE:EF:FA:CE', 'GlobeTrotter Module 3G+ Network Card'),\n                    (1, '00:53:45:00:00:00', 'WAN (PPP/SLIP) Interface'),\n                    (1, '80:00:60:0F:E8:00', 'Windows Mobile-based'),\n                    (2, '127.0.0.1', 'loopback'),\n                    (3, 'INVALID', 'from OCSNG'),\n                    (3, 'XxXxXxX', 'from IBM')";
        $DB->query($query);
    }
}
// ---------- Form ------------
echo "<div class='center'><table class='tab_cadre' cellpadding='5'>\n";
echo "<tr class='tab_bg_1 center'><th><a href='" . GLPI_ROOT . "/plugins/reports/front/config.form.php'>" . __('Reports plugin configuration', 'reports') . "</a><br />&nbsp;<br />" . sprintf(__('%1$s: %2$s'), __('Report configuration', 'reports'), __('Duplicate computers', 'reports')) . "</th></tr>\n";
$plug = new Plugin();
if ($plug->isActivated('reports')) {
    echo "<tr class='tab_bg_1 center'><td>";
    echo "<a href='./doublons.php'>" . sprintf(__('%1$s - %2$s'), __('Report'), __('Duplicate computers', 'reports')) . "</a>";
    echo "</td></tr>\n";
}
echo "</table>\n";
echo "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'><br />" . "<table class='tab_cadre' cellpadding='5'>\n" . "<tr class='tab_bg_1 center'><th colspan='4'>" . __('Exception list setup', 'reports') . "</th>" . "</tr>\n" . "<tr class='tab_bg_1 center'><th>" . _n('Type', 'Types', 1) . "</th><th>" . sprintf(__('%1$s / %2$s'), __('IP'), __('MAC')) . "</th>" . "<th>" . __('Comments') . "</th><th>&nbsp;</th></tr>\n";
echo "<tr class='tab_bg_1 center'><td>";
Dropdown::showFromArray("type", $types);
echo "</td><td><input type='text' name='addr' size='20'></td><td>" . "<input type='text' name='comment' size='40'></td>" . "<td><input type='submit' name='add' value='" . _sx('button', 'Add') . "' class='submit' ></td></tr>\n";
$query = "SELECT *\n          FROM `glpi_plugin_reports_doublons_backlists`\n          ORDER BY `type`, `addr`";
$res = $DB->query($query);
while ($data = $DB->fetch_array($res)) {
    echo "<tr class='tab_bg_1 center'><td>" . $types[$data["type"]] . "</td>" . "<td>" . $data["addr"] . "</td><td>" . $data["comment"] . "</td><td>";
    Html::showSimpleForm($_SERVER["PHP_SELF"], 'delete', _x('button', 'Put in dustbin'), array('id' => $data["id"]));
    echo "</td></td></tr>\n";
}
echo "</table>";
Html::closeForm();
echo "</div>";
Html::footer();
Esempio n. 25
0
 /**
  * Display tickets for an item
  *
  * Will also display tickets of linked items
  *
  * @param $item CommonDBTM object
  *
  * @return nothing (display a table)
  **/
 static function showListForItem(CommonDBTM $item)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRightsOr(self::$rightname, array(self::READALL, self::READMY, self::READASSIGN, CREATE))) {
         return false;
     }
     if ($item->isNewID($item->getID())) {
         return false;
     }
     $restrict = '';
     $order = '';
     $options['reset'] = 'reset';
     switch ($item->getType()) {
         case 'User':
             $restrict = "(`glpi_tickets_users`.`users_id` = '" . $item->getID() . "' " . " AND `glpi_tickets_users`.`type` = " . CommonITILActor::REQUESTER . ")";
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['reset'] = 'reset';
             $options['criteria'][0]['field'] = 4;
             // status
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         case 'SLT':
             $restrict = "`slts_tto_id` = '" . $item->getID() . "'\n                           OR `slts_ttr_id` = '" . $item->getID() . "'";
             $order = '`glpi_tickets`.`due_date` DESC';
             $options['criteria'][0]['field'] = 30;
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         case 'Supplier':
             $restrict = "(`glpi_suppliers_tickets`.`suppliers_id` = '" . $item->getID() . "' " . "  AND `glpi_suppliers_tickets`.`type` = " . CommonITILActor::ASSIGN . ")";
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['criteria'][0]['field'] = 6;
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         case 'Group':
             // Mini search engine
             if ($item->haveChildren()) {
                 $tree = Session::getSavedOption(__CLASS__, 'tree', 0);
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'><th>" . __('Last tickets') . "</th></tr>";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 echo __('Child groups') . "&nbsp;";
                 Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
             } else {
                 $tree = 0;
             }
             echo "</td></tr></table>";
             if ($tree) {
                 $restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $item->getID())) . ")";
             } else {
                 $restrict = "='" . $item->getID() . "'";
             }
             $restrict = "(`glpi_groups_tickets`.`groups_id` {$restrict}" . " AND `glpi_groups_tickets`.`type` = " . CommonITILActor::REQUESTER . ")";
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['criteria'][0]['field'] = 71;
             $options['criteria'][0]['searchtype'] = $tree ? 'under' : 'equals';
             $options['criteria'][0]['value'] = $item->getID();
             $options['criteria'][0]['link'] = 'AND';
             break;
         default:
             $restrict = "(`glpi_items_tickets`.`items_id` = '" . $item->getID() . "' " . " AND `glpi_items_tickets`.`itemtype` = '" . $item->getType() . "')";
             // you can only see your tickets
             if (!Session::haveRight(self::$rightname, self::READALL)) {
                 $restrict .= " AND (`glpi_tickets`.`users_id_recipient` = '" . Session::getLoginUserID() . "'\n                                   OR (`glpi_tickets_users`.`tickets_id` = '" . $item->getID() . "'\n                                       AND `glpi_tickets_users`.`users_id`\n                                            = '" . Session::getLoginUserID() . "'))";
             }
             $order = '`glpi_tickets`.`date_mod` DESC';
             $options['criteria'][0]['field'] = 12;
             $options['criteria'][0]['searchtype'] = 'equals';
             $options['criteria'][0]['value'] = 'all';
             $options['criteria'][0]['link'] = 'AND';
             $options['metacriteria'][0]['itemtype'] = $item->getType();
             $options['metacriteria'][0]['field'] = Search::getOptionNumber($item->getType(), 'id');
             $options['metacriteria'][0]['searchtype'] = 'equals';
             $options['metacriteria'][0]['value'] = $item->getID();
             $options['metacriteria'][0]['link'] = 'AND';
             break;
     }
     $query = "SELECT " . self::getCommonSelect() . "\n                FROM `glpi_tickets` " . self::getCommonLeftJoin() . "\n                WHERE {$restrict} " . getEntitiesRestrictRequest("AND", "glpi_tickets") . "\n                ORDER BY {$order}\n                LIMIT " . intval($_SESSION['glpilist_limit']);
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $colspan = 11;
     if (count($_SESSION["glpiactiveentities"]) > 1) {
         $colspan++;
     }
     // Ticket for the item
     echo "<div class='firstbloc'>";
     // Link to open a new ticket
     if ($item->getID() && Ticket::isPossibleToAssignType($item->getType()) && self::canCreate()) {
         Html::showSimpleForm($CFG_GLPI["root_doc"] . "/front/ticket.form.php", '_add_fromitem', __('New ticket for this item...'), array('itemtype' => $item->getType(), 'items_id' => $item->getID()));
     }
     echo "</div><div>";
     if ($number > 0) {
         echo "<table class='tab_cadre_fixehov'>";
         if (Session::haveRight(self::$rightname, self::READALL)) {
             Session::initNavigateListItems('Ticket', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
             echo "<tr class='noHover'><th colspan='{$colspan}'>";
             $title = sprintf(_n('Last %d ticket', 'Last %d tickets', $number), $number);
             $link = "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&amp;') . "'>" . __('Show all') . "</a>";
             $title = printf(__('%1$s (%2$s)'), $title, $link);
             echo "</th></tr>";
         } else {
             echo "<tr><th colspan='{$colspan}'>" . __("You don't have right to see all tickets") . "</th></tr>";
         }
     } else {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('No ticket found.') . "</th></tr>";
     }
     if ($item->getID() && $item->getType() == 'User' && self::canCreate()) {
         echo "<tr><td class='tab_bg_2 center b' colspan='{$colspan}'>";
         Html::showSimpleForm($CFG_GLPI["root_doc"] . "/front/ticket.form.php", '_add_fromitem', __('New ticket for this item...'), array('_users_id_requester' => $item->getID()));
         echo "</td></tr>";
     }
     // Ticket list
     if ($number > 0) {
         self::commonListHeader(Search::HTML_OUTPUT);
         while ($data = $DB->fetch_assoc($result)) {
             Session::addToNavigateListItems('Ticket', $data["id"]);
             self::showShort($data["id"]);
         }
         self::commonListHeader(Search::HTML_OUTPUT);
     }
     echo "</table></div>";
     // Tickets for linked items
     $linkeditems = $item->getLinkedItems();
     $restrict = array();
     if (count($linkeditems)) {
         foreach ($linkeditems as $ltype => $tab) {
             foreach ($tab as $lID) {
                 $restrict[] = "(`glpi_items_tickets`.`itemtype` = '{$ltype}' AND `glpi_items_tickets`.`items_id` = '{$lID}')";
             }
         }
     }
     if (count($restrict) && Session::haveRight(self::$rightname, self::READALL)) {
         $query = "SELECT " . self::getCommonSelect() . "\n                   FROM `glpi_tickets` " . self::getCommonLeftJoin() . "\n                   WHERE " . implode(' OR ', $restrict) . getEntitiesRestrictRequest(' AND ', 'glpi_tickets') . "\n                   ORDER BY `glpi_tickets`.`date_mod` DESC\n                   LIMIT " . intval($_SESSION['glpilist_limit']);
         $result = $DB->query($query);
         $number = $DB->numrows($result);
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='12'>";
         echo _n('Ticket on linked items', 'Tickets on linked items', $number);
         echo "</th></tr>";
         if ($number > 0) {
             self::commonListHeader(Search::HTML_OUTPUT);
             while ($data = $DB->fetch_assoc($result)) {
                 // Session::addToNavigateListItems(TRACKING_TYPE,$data["id"]);
                 self::showShort($data["id"]);
             }
             self::commonListHeader(Search::HTML_OUTPUT);
         } else {
             echo "<tr><th>" . __('No ticket found.') . "</th></tr>";
         }
         echo "</table></div>";
     }
     // Subquery for linked item
 }
Esempio n. 26
0
 function showTransferList()
 {
     global $DB, $CFG_GLPI;
     if (isset($_SESSION['glpitransfer_list']) && count($_SESSION['glpitransfer_list'])) {
         echo "<div class='center b'>" . __('You can continue to add elements to be transferred or execute the transfer now');
         echo "<br>" . __('Think of making a backup before transferring items.') . "</div>";
         echo "<table class='tab_cadre_fixe' >";
         echo '<tr><th>' . __('Items to transfer') . '</th><th>' . __('Transfer mode') . "&nbsp;";
         $rand = Transfer::dropdown(array('name' => 'id', 'comments' => false, 'toupdate' => array('value_fieldname' => 'id', 'to_update' => "transfer_form", 'url' => $CFG_GLPI["root_doc"] . "/ajax/transfers.php")));
         echo '</th></tr>';
         echo "<tr><td class='tab_bg_1 top'>";
         foreach ($_SESSION['glpitransfer_list'] as $itemtype => $tab) {
             if (count($tab)) {
                 $table = getTableForItemType($itemtype);
                 $query = "SELECT `{$table}`.`id`,\n                                 `{$table}`.`name`,\n                                 `glpi_entities`.`completename` AS locname,\n                                 `glpi_entities`.`id` AS entID\n                          FROM `{$table}`\n                          LEFT JOIN `glpi_entities`\n                               ON (`{$table}`.`entities_id` = `glpi_entities`.`id`)\n                          WHERE `{$table}`.`id` IN " . $this->createSearchConditionUsingArray($tab) . "\n                         ORDER BY locname, `{$table}`.`name`";
                 $entID = -1;
                 if (!($item = getItemForItemtype($itemtype))) {
                     continue;
                 }
                 if ($result = $DB->query($query)) {
                     if ($DB->numrows($result)) {
                         echo '<h3>' . $item->getTypeName() . '</h3>';
                         while ($data = $DB->fetch_assoc($result)) {
                             if ($entID != $data['entID']) {
                                 if ($entID != -1) {
                                     echo '<br>';
                                 }
                                 $entID = $data['entID'];
                                 echo "<span class='b spaced'>" . $data['locname'] . "</span><br>";
                             }
                             echo ($data['name'] ? $data['name'] : "(" . $data['id'] . ")") . "<br>";
                         }
                     }
                 }
             }
         }
         echo "</td><td class='tab_bg_2 top'>";
         if (countElementsInTable('glpi_transfers') == 0) {
             _e('No item found');
         } else {
             $params = array('id' => '__VALUE__');
             Ajax::updateItemOnSelectEvent("dropdown_id{$rand}", "transfer_form", $CFG_GLPI["root_doc"] . "/ajax/transfers.php", $params);
         }
         echo "<div class='center' id='transfer_form'><br>";
         Html::showSimpleForm($CFG_GLPI["root_doc"] . "/front/transfer.action.php", 'clear', __('To empty the list of elements to be transferred'));
         echo "</div>";
         echo '</td></tr>';
         echo '</table>';
     } else {
         _e('No selected element or badly defined operation');
     }
 }
Esempio n. 27
0
 /**
  * @param $networkPortID
  **/
 static function showFormForNetworkPort($networkPortID)
 {
     global $DB, $CFG_GLPI;
     $name = new self();
     $number_names = 0;
     if ($networkPortID > 0) {
         $query = "SELECT `id`\n                   FROM `" . $name->getTable() . "`\n                   WHERE `itemtype` = 'NetworkPort'\n                   AND `items_id` = '{$networkPortID}'\n                   AND `is_deleted` = '0'";
         $result = $DB->query($query);
         if ($DB->numrows($result) > 1) {
             echo "<tr class='tab_bg_1'><th colspan='4'>" . __("Several network names available! Go to the tab 'Network Name' to manage them.") . "</th></tr>\n";
             return;
         }
         switch ($DB->numrows($result)) {
             case 1:
                 $nameID = $DB->fetch_assoc($result);
                 $name->getFromDB($nameID['id']);
                 break;
             case 0:
                 $name->getEmpty();
                 break;
         }
     } else {
         $name->getEmpty();
     }
     echo "<tr class='tab_bg_1'><th colspan='4'>";
     // If the networkname is defined, we must be able to edit it. So we make a link
     if ($name->getID() > 0) {
         echo "<a href='" . $name->getLinkURL() . "'>" . self::getTypeName(1) . "</a>";
         echo "<input type='hidden' name='NetworkName_id' value='" . $name->getID() . "'>&nbsp;\n";
         Html::showSimpleForm($name->getFormURL(), 'unaffect', _sx('button', 'Dissociate'), array('id' => $name->getID()), $CFG_GLPI["root_doc"] . '/pics/sub_dropdown.png');
     } else {
         echo self::getTypeName(1);
     }
     echo "</th>\n";
     echo "</tr><tr class='tab_bg_1'>";
     echo "<td>" . self::getTypeName(1) . "</td><td>\n";
     Html::autocompletionTextField($name, "name", array('name' => 'NetworkName_name'));
     echo "</td>\n";
     echo "<td>" . FQDN::getTypeName(1) . "</td><td>";
     Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField("fqdns_id")), array('value' => $name->fields["fqdns_id"], 'name' => 'NetworkName_fqdns_id', 'entity' => $name->getEntityID(), 'displaywith' => array('view')));
     echo "</td>\n";
     echo "</tr><tr class='tab_bg_1'>\n";
     echo "<td>" . IPAddress::getTypeName(Session::getPluralNumber());
     IPAddress::showAddChildButtonForItemForm($name, 'NetworkName__ipaddresses');
     echo "</td>";
     echo "<td>";
     IPAddress::showChildsForItemForm($name, 'NetworkName__ipaddresses');
     echo "</td>";
     // MoYo : really need to display it here ?
     // make confure because not updatable
     //       echo "<td>".IPNetwork::getTypeName(Session::getPluralNumber())."&nbsp;";
     //       Html::showToolTip(__('IP network is not included in the database. However, you can see current available networks.'));
     //       echo "</td><td>";
     //       IPNetwork::showIPNetworkProperties($name->getEntityID());
     //       echo "</td>\n";
     echo "<td colspan='2'>&nbsp;</td>";
     echo "</tr>\n";
 }
Esempio n. 28
0
closedir($dir);
$dir = opendir($path);
unset($files);
$files = array();
while ($file = readdir($dir)) {
    if ($file != "." && $file != ".." && preg_match("/\\.xml\$/i", $file)) {
        $files[$file] = filemtime($path . "/" . $file);
    }
}
arsort($files);
if (count($files)) {
    foreach ($files as $file => $date) {
        $taille_fic = filesize($path . "/" . $file);
        echo "<tr class='tab_bg_1'><td colspan='6'><hr noshade></td></tr>" . "<tr class='tab_bg_2'><td>{$file}&nbsp;</td>" . "<td class='right'>" . Toolbox::getSize($taille_fic) . "</td>" . "<td>&nbsp;" . Html::convDateTime(date("Y-m-d H:i", $date)) . "</td>";
        if (Session::haveRight('backup', PURGE)) {
            echo "<td colspan=2>";
            //TRANS: %s is the filename
            $string = sprintf(__('Delete the file %s?'), $file);
            Html::showSimpleForm($_SERVER['PHP_SELF'], 'delfile', _x('button', 'Delete permanently'), array('file' => $file), '', '', $string);
            echo "</td>";
        }
        if (Session::haveRight('backup', CREATE)) {
            echo "<td>&nbsp;<a class='vsubmit' href=\"document.send.php?file=_dumps/{$file}\">" . __('Download') . "</a></td>";
        }
        echo "</tr>";
    }
}
closedir($dir);
echo "</table>";
echo "</div>";
Html::footer();
Esempio n. 29
0
 /**
  * @param $item   CommonDBTM object
  **/
 static function showActivationFormForItem(CommonDBTM $item)
 {
     if (!self::canUpdate()) {
         return false;
     }
     if ($item->getID()) {
         // Recursive type case => need entity right
         if ($item->isRecursive()) {
             if (!Session::haveAccessToEntity($item->fields["entities_id"])) {
                 return false;
             }
         }
     } else {
         return false;
     }
     $ri = new self();
     echo "<div>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Reserve an item') . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     if ($ri->getFromDBbyItem($item->getType(), $item->getID())) {
         echo "<td class='center'>";
         //Switch reservation state
         if ($ri->fields["is_active"]) {
             Html::showSimpleForm(static::getFormURL(), 'update', __('Make unavailable'), array('id' => $ri->fields['id'], 'is_active' => 0));
         } else {
             Html::showSimpleForm(static::getFormURL(), 'update', __('Make available'), array('id' => $ri->fields['id'], 'is_active' => 1));
         }
         echo '</td><td>';
         Html::showSimpleForm(static::getFormURL(), 'purge', __('Prohibit reservations'), array('id' => $ri->fields['id']), '', '', array(__('Are you sure you want to return this non-reservable item?'), __('That will remove all the reservations in progress.')));
         echo "</td>";
     } else {
         echo "<td class='center'>";
         Html::showSimpleForm(static::getFormURL(), 'add', __('Authorize reservations'), array('items_id' => $item->getID(), 'itemtype' => $item->getType(), 'entities_id' => $item->getEntityID(), 'is_recursive' => $item->isRecursive()));
         echo "</td>";
     }
     echo "</tr></table>";
     echo "</div>";
 }
Esempio n. 30
0
 /**
  * Print out an HTML Menu for knowbase item
  *
  * @return nothing (display the form)
  **/
 function showMenu()
 {
     global $CFG_GLPI;
     $ID = $this->fields['id'];
     if (!$this->can($ID, 'r') || Session::getLoginUserID() === false) {
         return false;
     }
     $edit = $this->can($ID, 'w');
     $isFAQ = $this->fields["is_faq"];
     $editFAQ = Session::haveRight("faq", "w");
     echo "<table class='tab_cadre_fixe'><tr><th colspan='3'>";
     if ($isFAQ) {
         _e('This item is part of the FAQ');
     } else {
         _e('This item is not part of the FAQ');
     }
     echo "</th></tr>\n";
     if ($edit) {
         echo "<tr class='tab_bg_1'>";
         if ($editFAQ) {
             echo "<td class='center' width='33%'>";
             if ($isFAQ) {
                 Html::showSimpleForm(static::getFormURL(), 'update', __('Delete this item from the FAQ'), array('id' => $ID, 'is_faq' => 0), $CFG_GLPI["root_doc"] . "/pics/faqremove.png");
             } else {
                 Html::showSimpleForm(static::getFormURL(), 'update', __('Put this item in the FAQ'), array('id' => $ID, 'is_faq' => 1), $CFG_GLPI["root_doc"] . "/pics/faqadd.png");
             }
             echo "</td>\n";
         }
         echo "<td class='center' width='34%'><a href=\"" . $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id={$ID}&amp;modify=yes\">";
         echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/faqedit.png\" alt=\"" . __s('Edit') . "\" title=\"" . __s('Edit') . "\"></a></td>\n";
         echo "<td class='center' width='33%'>";
         Html::showSimpleForm(static::getFormURL(), 'delete', _x('button', 'Delete permanently'), array('id' => $ID), $CFG_GLPI["root_doc"] . "/pics/faqdelete.png", '', __("Are you sure you want to delete this item?"));
         echo "</td>";
         echo "</tr>";
     }
     echo "</table><br>";
 }