openArrowMassives() static public method

show arrow for massives actions : opening
static public openArrowMassives ( $formname, $fixed = false, $ontop = false, $onright = false )
$formname string
$fixed boolean used tab_cadre_fixe in both tables (false by default)
$ontop display on top of the list (false by default)
$onright display on right of the list (false by default) \deprecated since 0.84
 function showForm($target)
 {
     global $DB;
     $rand = mt_rand();
     $query = "SELECT *\n                 FROM `" . $this->getTable() . "`\n                 ORDER BY `states_id` ASC ";
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<div align='center'><form method='post' name='massiveaction_form{$rand}' id='massiveaction_form{$rand}'  action=\"{$target}\">";
             echo "<table class='tab_cadre_fixe' cellpadding='5'>";
             echo "<tr>";
             echo "<th></th><th>" . _n('Status', 'Statuses', 2) . "</th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 $ID = $ligne["id"];
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10' class='center'>";
                 echo "<input type='hidden' name='id' value='{$ID}'>";
                 echo "<input type='checkbox' name='item[{$ID}]' value='1'>";
                 echo "</td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_states", $ligne["states_id"]) . "</td>";
                 echo "</tr>";
             }
             Html::openArrowMassives("massiveaction_form{$rand}", true);
             Html::closeArrowMassives(array('delete_state' => __('Delete permanently')));
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
     }
 }
 function showForm()
 {
     global $DB;
     $query = "SELECT * FROM\n               `" . $this->getTable() . "`\n               ORDER BY `states_id` ASC";
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($number != 0) {
             echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action='" . $this->getFormURL() . "'>";
             echo "<div align='center'>";
             echo "<table class='tab_cadre_fixe' cellpadding='5'>";
             echo "<tr>";
             echo "<th>" . __('Status') . "</th><th></th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 $ID = $ligne["id"];
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10'>";
                 echo "<input type='checkbox' name='item[{$ID}]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
                 echo "</td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_states", $ligne["states_id"]) . "</td>";
                 echo "</tr>";
             }
             echo "</table></div>";
             Html::openArrowMassives("massiveaction_form", true);
             Html::closeArrowMassives(array('delete_state' => _sx('button', 'Delete permanently')));
             Html::closeForm();
             echo "<div align='center'><form method='post' action='" . $this->getFormURL() . "'>";
             echo "<table class='tab_cadre_fixe' cellpadding='5'><tr ><th colspan='2'>";
             echo __('Disposal status', 'financialreports') . " : </th></tr>";
             echo "<tr class='tab_bg_1'><td>";
             Dropdown::show('State', array('name' => "states_id", 'value' => $ligne["states_id"]));
             echo "</td>";
             echo "<td>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add_state' value='" . _sx('button', 'Post') . "' class='submit' >";
             echo "</div></td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         } else {
             echo "<div align='center'><form method='post' action='" . $this->getFormURL() . "'>";
             echo "<table class='tab_cadre' cellpadding='5'><tr ><th colspan='2'>";
             echo __('Disposal status', 'financialreports') . " : </th></tr>";
             echo "<tr class='tab_bg_1'><td>";
             Dropdown::show('State', array('name' => "states_id"));
             echo "</td>";
             echo "<td>";
             echo "<div align='center'>";
             echo "<input type='submit' name='add_state' value='" . _sx('button', 'Post') . "' class='submit' >";
             echo "</div></td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
     }
 }
Exemplo n.º 3
0
 function manageGroup($groups_id)
 {
     global $CFG_GLPI;
     $group = new Group();
     if (Session::haveRight('group', 'w')) {
         echo "<form method='post' name='' id='manageGroup' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/escalade/front/group_group.form.php\">";
     }
     echo "<table width='950' class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo "Escalade";
     echo "</th>";
     echo "</tr>";
     $gg_found = $this->find("groups_id_source='{$groups_id}'");
     if (Session::haveRight('group', 'w')) {
         $groups_id_used = array();
         foreach ($gg_found as $gg) {
             $groups_id_used[] = $gg['groups_id_destination'];
         }
         echo "<tr>";
         echo "<td colspan='2' align='center'>";
         Dropdown::show('Group', array('name' => 'groups_id_destination', 'condition' => "is_assign=1", 'used' => $groups_id_used));
         echo "<input type='hidden' name='groups_id_source' value='" . $groups_id . "' />";
         echo "&nbsp;<input type='submit' class='submit' name='addgroup' value='" . _sx('button', 'Add') . "'/>";
         echo "</td>";
         echo "</tr>";
     }
     foreach ($gg_found as $gg_id => $gg) {
         $group->getFromDB($gg['groups_id_destination']);
         echo "<tr class='tab_bg_1'>";
         echo "<td width='30'>";
         if (Session::haveRight('group', 'w')) {
             echo "<input type='checkbox' name='delgroup[]' value='{$gg_id}' />";
         }
         echo "</td>";
         echo "<td>";
         echo $group->getLink(true);
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
     if (Session::haveRight('group', 'w')) {
         Html::openArrowMassives("manageGroup", true);
         Html::closeArrowMassives(array('deleteitem' => _sx('button', 'Delete permanently')));
     }
     Html::closeForm();
 }
Exemplo n.º 4
0
 function showForm($target)
 {
     global $CFG_GLPI;
     $categories = getAllDatasFromTable($this->getTable());
     if (!empty($categories)) {
         echo "<div align='center'>";
         $rand = mt_rand();
         echo "<form method='post' name='massiveaction_form_ticket{$rand}' \n                                    id='massiveaction_form_ticket{$rand}' action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe' cellpadding='5'>";
         echo "<tr>";
         echo "<th></th><th>" . __('Category of created tickets', 'resources') . "</th>";
         echo "</tr>";
         foreach ($categories as $categorie) {
             $ID = $categorie["id"];
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center' width='10'>";
             echo "<input type='hidden' name='id' value='{$ID}'>";
             echo "<input type='checkbox' name='item[{$ID}]' value='1'>";
             echo "</td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_itilcategories", $categorie["ticketcategories_id"]) . "</td>";
             echo "</tr>";
         }
         Html::openArrowMassives("massiveaction_form_ticket{$rand}", true);
         Html::closeArrowMassives(array('delete_ticket' => __s('Delete permanently')));
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     } else {
         echo "<div align='center'><form method='post'  action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe' cellpadding='5'><tr ><th colspan='2'>";
         echo __('Category of created tickets', 'resources') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>";
         Dropdown::show('ITILCategory', array('name' => "ticketcategories_id"));
         echo "</td>";
         echo "<td>";
         echo "<div align='center'>";
         echo "<input type='submit' name='add_ticket' value=\"" . _sx('button', 'Add') . "\" \n                                                                                 class='submit'>";
         echo "</div></td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
 }
Exemplo n.º 5
0
 function manageGroup($groups_id)
 {
     global $DB, $CFG_GLPI;
     $group = new Group();
     $a_groups_tmp = $group->find('', '`name`');
     $a_groups = array();
     foreach ($a_groups_tmp as $data) {
         $a_groups[$data['id']] = $data['name'];
     }
     unset($a_groups[$groups_id]);
     echo "<form method='post' name='' id=''  action=\"" . $CFG_GLPI['root_doc'] . "/plugins/escalation/front/group_group.form.php\">";
     echo "<table width='950' class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='2'>";
     echo "Escalade";
     echo "</th>";
     echo "</tr>";
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `groups_id_source`='" . $groups_id . "'";
     $result = $DB->query($query);
     echo "<tr>";
     echo "<td colspan='2' align='center'>";
     while ($data = $DB->fetch_array($result)) {
         unset($a_groups[$data['groups_id_destination']]);
     }
     Dropdown::showFromArray("groups_id_destination", $a_groups);
     echo "<input type='hidden' name='groups_id_source' value='" . $groups_id . "' />";
     echo "&nbsp;<input type='submit' class='submit' name='addgroup' value='" . __('Add') . "'/>";
     echo "</td>";
     echo "</tr>";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $group->getFromDB($data['groups_id_destination']);
         echo "<tr class='tab_bg_1'>";
         echo "<td width='30'>";
         echo "<input type='checkbox' name='delgroup[]' value='" . $data['id'] . "' />";
         echo "</td>";
         echo "<td>";
         echo $group->getName();
         echo "</td>";
         echo "</tr>";
     }
     echo "</table>";
     Html::openArrowMassives("delgroup", true);
     Html::closeArrowMassives(array('deleteitem' => __('Delete permanently')));
     Html::closeForm();
 }
Exemplo n.º 6
0
 static function showForItem(CommonDBTM $item)
 {
     global $DB, $LANG;
     if (!$item->canView()) {
         return false;
     }
     //       if (PluginSimcardSimcard::canCreate()) {
     //       	 if ($item->canEdit($item->getField('id'))) {
     // 	         $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard');
     // 	         $url.= "?itemtype=".$item->getType()."&items_id=".$item->getID()."&id=-1";
     // 	         echo "<div class='center'><a href='$url'>".__s('New SIM card', 'simcard')."</a></div><br>";
     //       	 }
     //       }
     $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`items_id` = '" . $item->getID() . "' AND `itemtype`='" . get_class($item) . "'");
     echo "<div class='spaced'>";
     echo "<form id='items' name='items' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='6'>" . __s('Associated item') . "</th></tr>";
     if (!empty($results)) {
         echo "<tr><th></th>";
         echo "<th>" . __s('Entity') . "</th>";
         echo "<th>" . __s('Name') . "</th>";
         echo "<th>" . __s('IMSI') . "</th>";
         echo "<th>" . __s('Inventory number') . "</th>";
         echo "</tr>";
         foreach ($results as $data) {
             $tmp = new PluginSimcardSimcard();
             $tmp->getFromDB($data['plugin_simcard_simcards_id']);
             echo "<tr>";
             echo "<td>";
             if (PluginSimcardSimcard::canDelete()) {
                 echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>";
             }
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']);
             echo "</td>";
             echo "<td>";
             echo $tmp->getLink();
             echo "</td>";
             echo "<td>";
             echo $tmp->fields['serial'];
             echo "</td>";
             echo "<td>";
             echo $tmp->fields['otherserial'];
             echo "</td>";
             echo "</tr>";
         }
     }
     if (PluginSimcardSimcard::canUpdate()) {
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>";
         echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
         $used = array();
         $query = "SELECT `id`\n                   FROM `glpi_plugin_simcard_simcards`\n                   WHERE `is_template`='0'\n                      AND `id` IN (SELECT `plugin_simcard_simcards_id`\n                                   FROM `glpi_plugin_simcard_simcards_items`)";
         foreach ($DB->request($query) as $use) {
             $used[] = $use['id'];
         }
         Dropdown::show('PluginSimcardSimcard', array('name' => "plugin_simcard_simcards_id", 'entity' => $item->fields['entities_id'], 'used' => $used));
         echo "</td>";
         echo "<td colspan='2' class='center' class='tab_bg_2'>";
         echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>";
         if (!empty($results)) {
             Html::openArrowMassives('items', true);
             Html::closeArrowMassives(array('delete_items' => _sx('button', 'Disconnect')));
         }
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Exemplo n.º 7
0
 /**
  * Display form to unlock fields and links
  *
  * @param CommonDBTM $item the source item
  **/
 static function showForItem(CommonDBTM $item)
 {
     global $DB;
     $ID = $item->getID();
     $itemtype = $item->getType();
     $header = false;
     //If user doesn't have write right on the item, lock form must not be displayed
     if (!$item->canCreate()) {
         return false;
     }
     echo "<div width='50%'>";
     echo "<form method='post' id='lock_form'\n             name='lock_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<input type='hidden' name='id' value='{$ID}'>\n";
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>\n";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2''>" . __('Locked items') . "</th></tr>";
     //Use a hook to allow external inventory tools to manage per field lock
     $results = Plugin::doHookFunction('display_locked_fields', array('item' => $item, 'header' => $header));
     $header |= $results['header'];
     //Special locks for computers only
     if ($itemtype == 'Computer') {
         //Locks for items recorded in glpi_computers_items table
         $types = array('Monitor', 'Peripheral', 'Printer');
         foreach ($types as $type) {
             $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID, 'itemtype' => $type);
             $params['FIELDS'] = array('id', 'items_id');
             $first = true;
             foreach ($DB->request('glpi_computers_items', $params) as $line) {
                 $tmp = new $type();
                 $tmp->getFromDB($line['items_id']);
                 $header = true;
                 if ($first) {
                     echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
                     $first = false;
                 }
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='Computer_Item[" . $line['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>" . $tmp->getName() . "</td>";
                 echo "</tr>\n";
             }
         }
         $types = array('ComputerDisk', 'ComputerVirtualMachine');
         foreach ($types as $type) {
             $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
             $params['FIELDS'] = array('id', 'name');
             $first = true;
             foreach ($DB->request(getTableForItemType($type), $params) as $line) {
                 $header = true;
                 if ($first) {
                     echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
                     $first = false;
                 }
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='" . $type . "[" . $line['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>" . $line['name'] . "</td>";
                 echo "</tr>\n";
             }
         }
         //Software versions
         $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
         $first = true;
         $query = "SELECT `csv`.`id` AS `id`,\n                           `sv`.`name` AS `version`,\n                           `s`.`name` AS `software`\n                    FROM `glpi_computers_softwareversions` AS csv\n                    LEFT JOIN `glpi_softwareversions` AS sv\n                       ON (`csv`.`softwareversions_id` = `sv`.`id`)\n                    LEFT JOIN `glpi_softwares` AS s\n                       ON (`sv`.`softwares_id` = `s`.`id`)\n                    WHERE `csv`.`is_deleted` = '1'\n                          AND `csv`.`is_dynamic` = '1'\n                          AND `csv`.`computers_id` = '{$ID}'";
         foreach ($DB->request($query) as $line) {
             $header = true;
             if ($first) {
                 echo "<tr><th colspan='2'>" . Software::getTypeName(2) . "</th></tr>\n";
                 $first = false;
             }
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             echo "<input type='checkbox' name='Computer_SoftwareVersion[" . $line['id'] . "]'></td>";
             echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
             echo "</tr>\n";
         }
         //Software licenses
         $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
         $first = true;
         $query = "SELECT `csv`.`id` AS `id`,\n                           `sv`.`name` AS `version`,\n                           `s`.`name` AS `software`\n                    FROM `glpi_computers_softwarelicenses` AS csv\n                    LEFT JOIN `glpi_softwarelicenses` AS sv\n                       ON (`csv`.`softwarelicenses_id` = `sv`.`id`)\n                    LEFT JOIN `glpi_softwares` AS s\n                       ON (`sv`.`softwares_id` = `s`.`id`)\n                    WHERE `csv`.`is_deleted` = '1'\n                          AND `csv`.`is_dynamic` = '1'\n                          AND `csv`.`computers_id` = '{$ID}'";
         foreach ($DB->request($query) as $line) {
             $header = true;
             if ($first) {
                 echo "<tr><th colspan='2'>" . SoftwareLicense::getTypeName(2) . "</th>" . "</tr>\n";
                 $first = false;
             }
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             echo "<input type='checkbox' name='Computer_SoftwareLicense[" . $line['id'] . "]'></td>";
             echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
             echo "</tr>\n";
         }
     }
     $first = true;
     $item = new NetworkPort();
     $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'items_id' => $ID, 'itemtype' => $itemtype);
     $params['FIELDS'] = array('id');
     foreach ($DB->request('glpi_networkports', $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . NetworkPort::getTypeName(2) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='NetworkPort[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $first = true;
     $item = new NetworkName();
     $params = array('`glpi_networknames`.`is_dynamic`' => 1, '`glpi_networknames`.`is_deleted`' => 1, '`glpi_networknames`.`itemtype`' => 'NetworkPort', '`glpi_networknames`.`items_id`' => '`glpi_networkports`.`id`', '`glpi_networkports`.`items_id`' => $ID, '`glpi_networkports`.`itemtype`' => $itemtype);
     $params['FIELDS'] = array('glpi_networknames' => 'id');
     foreach ($DB->request(array('glpi_networknames', 'glpi_networkports'), $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . NetworkName::getTypeName(2) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='NetworkName[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $first = true;
     $item = new IPAddress();
     $params = array('`glpi_ipaddresses`.`is_dynamic`' => 1, '`glpi_ipaddresses`.`is_deleted`' => 1, '`glpi_ipaddresses`.`itemtype`' => 'Networkname', '`glpi_ipaddresses`.`items_id`' => '`glpi_networknames`.`id`', '`glpi_networknames`.`itemtype`' => 'NetworkPort', '`glpi_networknames`.`items_id`' => '`glpi_networkports`.`id`', '`glpi_networkports`.`items_id`' => $ID, '`glpi_networkports`.`itemtype`' => $itemtype);
     $params['FIELDS'] = array('glpi_ipaddresses' => 'id');
     foreach ($DB->request(array('glpi_ipaddresses', 'glpi_networknames', 'glpi_networkports'), $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . IPAddress::getTypeName(2) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='IPAddress[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $types = Item_Devices::getDeviceTypes();
     $nb = 0;
     foreach ($types as $old => $type) {
         $nb += countElementsInTable(getTableForItemType($type), "`items_id`='{$ID}'\n                                         AND `itemtype`='{$itemtype}'\n                                         AND `is_dynamic`='1'\n                                         AND `is_deleted`='1'");
     }
     if ($nb) {
         $header = true;
         echo "<tr><th colspan='2'>" . _n('Component', 'Components', 2) . "</th></tr>\n";
         foreach ($types as $old => $type) {
             $associated_type = str_replace('Item_', '', $type);
             $associated_table = getTableForItemType($associated_type);
             $fk = getForeignKeyFieldForTable($associated_table);
             $query = "SELECT `i`.`id`,\n                             `t`.`designation` AS `name`\n                      FROM `" . getTableForItemType($type) . "` AS i\n                      LEFT JOIN `{$associated_table}` AS t\n                         ON (`t`.`id` = `i`.`{$fk}`)\n                      WHERE `itemtype` = '{$itemtype}'\n                            AND `items_id` = '{$ID}'\n                            AND `is_dynamic` = '1'\n                            AND `is_deleted` = '1'";
             foreach ($DB->request($query) as $data) {
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='" . $type . "[" . $data['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>";
                 printf(__('%1$s: %2$s'), $associated_type::getTypeName(), $data['name']);
                 echo "</td></tr>\n";
             }
         }
     }
     if ($header) {
         echo "</table>";
         Html::openArrowMassives('lock_form', true);
         Html::closeArrowMassives(array('unlock' => _sx('button', 'Unlock')));
     } else {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>" . __('No locked item') . "</td></tr>";
         echo "</table>";
     }
     Html::closeForm();
     echo "</div>\n";
 }
Exemplo n.º 8
0
 public function showOrderReception($orders_id)
 {
     global $DB, $CFG_GLPI;
     $order_order = new PluginOrderOrder();
     $order_item = new PluginOrderOrder_Item();
     $reference = new PluginOrderReference();
     $order_order->getFromDB($orders_id);
     Session::initNavigateListItems($this->getType(), __("Order", "order") . " = " . $order_order->fields["name"]);
     $canedit = self::canCreate() && !$order_order->canUpdateOrder() && !$order_order->isCanceled();
     $result_ref = $order_item->queryDetail($orders_id);
     $numref = $DB->numrows($result_ref);
     while ($data_ref = $DB->fetch_array($result_ref)) {
         echo "<div class='center'><table class='tab_cadre_fixe'>";
         if (!$numref) {
             echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>";
         } else {
             $references_id = $data_ref["id"];
             $typeRef = $data_ref["itemtype"];
             $price_taxfree = $data_ref["price_taxfree"];
             $discount = $data_ref["discount"];
             $item = new $typeRef();
             $rand = mt_rand();
             echo "<tr><th><ul><li>";
             echo "<a href=\"javascript:showHideDiv('reception{$rand}','reception_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">";
             echo "<img alt='' name='reception_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">";
             echo "</a>";
             echo "</li></ul></th>";
             echo "<th>" . __("Type") . "</th>";
             echo "<th>" . __("Manufacturer") . "</th>";
             echo "<th>" . __("Product reference", "order") . "</th>";
             echo "<th>" . __("Delivered items", "order") . "</th>";
             echo "</tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td></td>";
             echo "<td align='center'>" . $item->getTypeName() . "</td>";
             echo "<td align='center'>" . Dropdown::getDropdownName("glpi_manufacturers", $data_ref["manufacturers_id"]) . "</td>";
             echo "<td>" . $reference->getReceptionReferenceLink($data_ref) . "</td>";
             $total = $order_item->getTotalQuantityByRefAndDiscount($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]);
             echo "<td>" . $order_item->getDeliveredQuantity($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]) . " / " . $total . "</td>";
             echo "</tr></table>";
             echo "<div class='center' id='reception{$rand}' style='display:none'>";
             echo "<form method='post' name='order_reception_form{$rand}' id='order_reception_form{$rand}'" . " action=\"" . Toolbox::getItemTypeFormURL("PluginOrderReception") . "\">";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             echo "<th width='15'></th>";
             if ($typeRef != 'SoftwareLicense') {
                 echo "<th>" . __("ID") . "</th>";
             }
             echo "<th>" . __("Reference") . "</th>";
             echo "<th>" . __("Status") . "</th>";
             echo "<th>" . __("Delivery date") . "</th>";
             echo "<th>" . __("Delivery form") . "</th>";
             echo "<th>" . __("Delivery status", "order") . "</th>";
             echo "</tr>";
             $query = "SELECT `glpi_plugin_order_orders_items`.`id` AS IDD,\n                             `glpi_plugin_order_references`.`id` AS id,\n                             `glpi_plugin_order_references`.`templates_id`,\n                             `glpi_plugin_order_orders_items`.`states_id`,\n                             `glpi_plugin_order_orders_items`.`comment`,\n                             `glpi_plugin_order_orders_items`.`plugin_order_deliverystates_id`,\n                             `glpi_plugin_order_orders_items`.`delivery_date`,\n                             `glpi_plugin_order_orders_items`.`delivery_number`,\n                             `glpi_plugin_order_references`.`name`,\n                             `glpi_plugin_order_references`.`itemtype`,\n                             `glpi_plugin_order_orders_items`.`items_id`\n                    FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references`\n                    WHERE `plugin_order_orders_id` = '{$orders_id}'\n                    AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = '" . $references_id . "'\n                    AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n                    AND `glpi_plugin_order_orders_items`.`discount` LIKE '" . $discount . "'\n                    AND `glpi_plugin_order_orders_items`.`price_taxfree` LIKE '" . $price_taxfree . "' ";
             if ($typeRef == 'SoftwareLicense') {
                 $query .= " GROUP BY `glpi_plugin_order_references`.`name` ";
             }
             $query .= " ORDER BY `glpi_plugin_order_references`.`name` ";
             $result = $DB->query($query);
             $num = $DB->numrows($result);
             while ($data = $DB->fetch_array($result)) {
                 $random = mt_rand();
                 $detailID = $data["IDD"];
                 Session::addToNavigateListItems($this->getType(), $detailID);
                 echo "<tr class='tab_bg_2'>";
                 $status = 1;
                 if ($typeRef != 'SoftwareLicense') {
                     $status = $this->checkThisItemStatus($detailID, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED);
                 }
                 if ($order_order->canDeliver() && $status) {
                     echo "<td width='15' align='left'>";
                     $sel = "";
                     if (isset($_GET["select"]) && $_GET["select"] == "all") {
                         $sel = "checked";
                     }
                     echo "<input type='checkbox' name='item[" . $detailID . "]' value='1' {$sel}>";
                     echo "</td>";
                 } else {
                     echo "<td width='15' align='left'></td>";
                 }
                 if ($typeRef != 'SoftwareLicense') {
                     echo "<td align='center'>" . $data["IDD"] . "&nbsp;";
                     Html::showTooltip($data['comment']);
                     echo "</td>";
                 }
                 echo "<td align='center'>" . $reference->getReceptionReferenceLink($data) . "</td>";
                 echo "<td align='center'>";
                 $link = Toolbox::getItemTypeFormURL($this->getType());
                 if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) {
                     echo "<a href=\"" . $link . "?id=" . $data["IDD"] . "\">";
                 }
                 echo $this->getReceptionStatus($detailID);
                 if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) {
                     echo "</a>";
                 }
                 echo "</td>";
                 echo "<td align='center'>" . Html::convDate($data["delivery_date"]) . "</td>";
                 echo "<td align='center'>" . $data["delivery_number"] . "</td>";
                 echo "<td align='center'>" . Dropdown::getDropdownName("glpi_plugin_order_deliverystates", $data["plugin_order_deliverystates_id"]) . "</td>";
                 echo "<input type='hidden' name='id[{$detailID}]' value='{$detailID}'>";
                 echo "<input type='hidden' name='name[{$detailID}]' value='" . $data["name"] . "'>";
                 echo "<input type='hidden' name='plugin_order_references_id[{$detailID}]' value='" . $data["id"] . "'>";
                 echo "<input type='hidden' name='itemtype[{$detailID}]' value='" . $data["itemtype"] . "'>";
                 echo "<input type='hidden' name='templates_id[{$detailID}]' value='" . $data["templates_id"] . "'>";
                 echo "<input type='hidden' name='states_id[{$detailID}]' value='" . $data["states_id"] . "'>";
             }
             echo "</table>";
             if ($order_order->canDeliver() && $this->checkItemStatus($orders_id, $references_id, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED)) {
                 Html::openArrowMassives("order_reception_form{$rand}", true);
                 echo "<input type='hidden' name='plugin_order_orders_id' value='{$orders_id}'>";
                 $this->dropdownReceptionActions($typeRef, $references_id, $orders_id);
                 Html::closeArrowMassives(array());
                 $rand = mt_rand();
                 if ($typeRef != 'SoftwareLicense') {
                     echo "<div id='massreception" . $orders_id . $rand . "'></div>\n";
                     echo "<script type='text/javascript' >\n";
                     echo "function viewmassreception" . $orders_id . "{$rand}(){\n";
                     $params = array('plugin_order_orders_id' => $orders_id, 'plugin_order_references_id' => $references_id);
                     Ajax::updateItemJsCode("massreception" . $orders_id . $rand, $CFG_GLPI["root_doc"] . "/plugins/order/ajax/massreception.php", $params, false);
                     echo "};";
                     echo "</script>\n";
                     echo "<p><a href='javascript:viewmassreception" . $orders_id . "{$rand}();'>";
                     echo __("Take item delivery (bulk)", "order") . "</a></p><br>\n";
                 }
             }
             Html::closeForm();
             echo "</div>";
         }
         echo "<br>";
     }
 }
Exemplo n.º 9
0
 /**
  *
  * Display additional information form from Model form
  * @param PluginDatainjectionModel $model
  */
 static function showFormInfos(PluginDatainjectionModel $model)
 {
     $canedit = $model->can($model->fields['id'], UPDATE);
     self::showAddInfo($model, $canedit);
     $model->loadInfos();
     $nb = count($model->getInfos());
     if ($nb > 0) {
         echo "<form method='post' name='info_form' id='info_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         if ($canedit) {
             echo "<th>&nbsp;</th>";
         }
         echo "<th>" . __('Tables', 'datainjection') . "</th>";
         echo "<th>" . __('Fields', 'datainjection') . "</th>";
         echo "<th>" . __('Mandatory information', 'datainjection') . "</th>";
         echo "</tr>";
         foreach ($model->getInfos() as $info) {
             $info->fields = Toolbox::stripslashes_deep($info->fields);
             $infos_id = $info->fields['id'];
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 $sel = "";
                 if (isset($_GET["select"]) && $_GET["select"] == "all") {
                     $sel = "checked";
                 }
                 echo "<input type='checkbox' name='item[" . $infos_id . "]' value='1' {$sel}>";
                 echo "</td>";
             }
             echo "<td class='center'>";
             $rand = PluginDatainjectionInjectionType::dropdownLinkedTypes($info, array('primary_type' => $model->fields['itemtype']));
             echo "</td>";
             echo "<td class='center'><span id='span_field_{$infos_id}'></span></td>";
             echo "<td class='center'><span id='span_mandatory_{$infos_id}'></span></td></tr>";
         }
         if ($canedit) {
             echo "<tr>";
             echo "<td class='tab_bg_2 center' colspan='4'>";
             echo "<input type='hidden' name='models_id' value='" . $model->fields['id'] . "'>";
             echo "<input type='submit' name='update' value='" . _sx('button', 'Save') . "' class='submit'>";
             echo "</td></tr>";
             Html::openArrowMassives("info_form", true);
             Html::closeArrowMassives(array('delete' => __('Delete permanently')));
         }
         echo "</table>";
         Html::closeForm();
     }
 }
Exemplo n.º 10
0
 static function showForItem(CommonDBTM $item)
 {
     global $DB, $LANG;
     if (!$item->can($item->getID(), 'r')) {
         return false;
     }
     if (Session::haveRight('simcard', 'w')) {
         $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard');
         $url .= "?itemtype=" . $item->getType() . "&items_id=" . $item->getID() . "&id=-1";
         echo "<div class='center'><a href='{$url}'>" . $LANG['plugin_simcard'][10] . "</a></div><br>";
     }
     $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`items_id` = '" . $item->getID() . "' AND `itemtype`='" . get_class($item) . "'");
     echo "<div class='spaced'>";
     echo "<form id='items' name='items' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='6'>" . $LANG['document'][19] . "</th></tr>";
     if (!empty($results)) {
         echo "<tr><th></th>";
         echo "<th>" . $LANG['entity'][0] . "</th>";
         echo "<th>" . $LANG['common'][16] . "</th>";
         echo "<th>" . $LANG['common'][19] . "</th>";
         echo "<th>" . $LANG['common'][20] . "</th>";
         echo "</tr>";
         foreach ($results as $data) {
             $tmp = new PluginSimcardSimcard();
             $tmp->getFromDB($data['plugin_simcard_simcards_id']);
             echo "<tr>";
             echo "<td>";
             if (Session::haveRight('simcard', 'w')) {
                 echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>";
             }
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']);
             echo "</td>";
             echo "<td>";
             echo $tmp->getLink();
             echo "</td>";
             echo "<td>";
             echo $tmp->fields['serial'];
             echo "</td>";
             echo "<td>";
             echo $tmp->fields['otherserial'];
             echo "</td>";
             echo "</tr>";
         }
     }
     if (Session::haveRight('simcard', 'w')) {
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>";
         echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
         $used = array();
         $query = "SELECT `id`\n                   FROM `glpi_plugin_simcard_simcards`\n                   WHERE `is_template`='0'\n                      AND `id` IN (SELECT `plugin_simcard_simcards_id`\n                                   FROM `glpi_plugin_simcard_simcards_items`)";
         foreach ($DB->request($query) as $use) {
             $used[$use['id']] = $use['id'];
         }
         Dropdown::show('PluginSimcardSimcard', array('name' => "plugin_simcard_simcards_id", 'entity' => $item->fields['entities_id'], 'used' => $used));
         echo "</td>";
         echo "<td colspan='2' class='center' class='tab_bg_2'>";
         echo "<input type='submit' name='additem' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</td></tr>";
         if (!empty($results)) {
             Html::openArrowMassives('items');
             Html::closeArrowMassives(array('delete_items' => $LANG['buttons'][10]));
         }
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Exemplo n.º 11
0
 public static function showOrderSupplierSurvey($ID)
 {
     global $DB, $CFG_GLPI;
     $order = new PluginOrderOrder();
     $order->getFromDB($ID);
     $survey = new self();
     $table = getTableForItemType(__CLASS__);
     Session::initNavigateListItems(__CLASS__, __("Order", "order") . " = " . $order->fields["name"]);
     $candelete = $order->can($ID, DELETE);
     $query = "SELECT * FROM `{$table}` WHERE `plugin_order_orders_id` = '{$ID}' ";
     $result = $DB->query($query);
     $rand = mt_rand();
     echo "<div class='center'>";
     echo "<form method='post' name='show_suppliersurvey{$rand}' id='show_suppliersurvey{$rand}' " . " action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\">";
     echo "<input type='hidden' name='plugin_order_orders_id' value='" . $ID . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='5'>" . __("Supplier quality", "order") . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th>" . __("Supplier") . "</th>";
     echo "<th>" . __("Note", "order") . "</th>";
     echo "<th>" . __("Comment on survey", "order") . "</th>";
     echo "</tr>";
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_array($result)) {
             Session::addToNavigateListItems(__CLASS__, $data['id']);
             echo "<input type='hidden' name='item[" . $data["id"] . "]' value='" . $ID . "'>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td>";
             if ($candelete) {
                 echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
             }
             echo "</td>";
             $link = Toolbox::getItemTypeFormURL(__CLASS__);
             echo "<td><a href='" . $link . "?id=" . $data["id"] . "&plugin_order_orders_id=" . $ID . "'>" . Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]) . "</a></td>";
             echo "<td>";
             $total = $survey->getTotalNotation($ID);
             echo $total . " / 10";
             echo "</td>";
             echo "<td>";
             echo $data["comment"];
             echo "</td>";
             echo "</tr>";
         }
         echo "</table>";
         if ($candelete) {
             echo "<div class='center'>";
             Html::openArrowMassives("show_suppliersurvey{$rand}", true);
             Html::closeArrowMassives(array("delete" => __("Delete permanently")));
             echo "</div>";
         }
     } else {
         echo "</table>";
     }
     Html::closeForm();
     echo "</div>";
 }
 /**
  * Prints display pre import
  *
  * @param $type the type of device
  * @param $configID the ID of the supplier config
  * @param $start for pager display
  * @param $complete to see all device (already imported and not)
  * @return nothing (print out a table)
  *
  */
 static function seePreImport($params)
 {
     global $DB, $CFG_GLPI;
     // Default values of parameters
     $p['link'] = array();
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '1';
     $p['order'] = 'ASC';
     $p['start'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     $p['itemtype'] = '';
     $p['manufacturers_id'] = '';
     $p['imported'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $globallinkto = self::getArrayUrlLink("field", $p['field']) . self::getArrayUrlLink("link", $p['link']) . self::getArrayUrlLink("contains", $p['contains']) . self::getArrayUrlLink("searchtype", $p['searchtype']) . self::getArrayUrlLink("field2", $p['field2']) . self::getArrayUrlLink("contains2", $p['contains2']) . self::getArrayUrlLink("searchtype2", $p['searchtype2']) . self::getArrayUrlLink("itemtype2", $p['itemtype2']) . self::getArrayUrlLink("link2", $p['link2']);
     $modeltable = "";
     $target = $CFG_GLPI["root_doc"] . "/plugins/manufacturersimports/front/import.php";
     if ($p['itemtype'] && $p['manufacturers_id']) {
         $config = new PluginManufacturersimportsConfig();
         $config->getFromDB($p['manufacturers_id']);
         $suppliername = $config->fields["name"];
         $supplierclass = "PluginManufacturersimports" . $suppliername;
         $supplier = new $supplierclass();
         $infocom = new Infocom();
         $canedit = Session::haveRight(static::$rightname, UPDATE) && $infocom->canUpdate();
         if (!$p['start']) {
             $p['start'] = 0;
         }
         $modeltable = getTableForItemType($p['itemtype'] . "Model");
         $modelfield = getForeignKeyFieldForTable(getTableForItemType($p['itemtype'] . "Model"));
         $item = new $p['itemtype']();
         $itemtable = getTableForItemType($p['itemtype']);
         $query = "SELECT `" . $itemtable . "`.`id`,\n                        `" . $itemtable . "`.`name`, \n                        `" . $itemtable . "`.`serial`,\n                        `" . $itemtable . "`.`entities_id`,\n                         `glpi_plugin_manufacturersimports_logs`.`import_status`,\n                          `glpi_plugin_manufacturersimports_logs`.`items_id`,\n                           `glpi_plugin_manufacturersimports_logs`.`itemtype`, \n                           `glpi_plugin_manufacturersimports_logs`.`documents_id`,\n                            `glpi_plugin_manufacturersimports_logs`.`date_import`, \n                            '" . $p['itemtype'] . "' AS type,\n                            `{$modeltable}`.`name` AS model_name\n                  FROM `" . $itemtable . "` ";
         //model device left join
         $query .= "LEFT JOIN `{$modeltable}` ON (`{$modeltable}`.`id` = `" . $itemtable . "`.`" . $modelfield . "`) ";
         $query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemtable . "`.`entities_id`)";
         $query .= " LEFT JOIN `glpi_plugin_manufacturersimports_configs` \n         ON (`glpi_plugin_manufacturersimports_configs`.`manufacturers_id` = `" . $itemtable . "`.`manufacturers_id`)";
         $query .= " LEFT JOIN `glpi_plugin_manufacturersimports_logs` \n         ON (`glpi_plugin_manufacturersimports_logs`.`items_id` = `" . $itemtable . "`.`id` \n         AND `glpi_plugin_manufacturersimports_logs`.`itemtype` = '" . $p['itemtype'] . "')";
         $query .= " LEFT JOIN `glpi_plugin_manufacturersimports_models` \n         ON (`glpi_plugin_manufacturersimports_models`.`items_id` = `" . $itemtable . "`.`id` \n         AND `glpi_plugin_manufacturersimports_models`.`itemtype` = '" . $p['itemtype'] . "')";
         //serial must be not empty
         $query .= " WHERE `" . $itemtable . "`.`is_deleted` = '0'\n          AND `" . $itemtable . "`.`is_template` = '0'\n          AND `glpi_plugin_manufacturersimports_configs`.`id` = '" . $p['manufacturers_id'] . "'\n          AND `" . $itemtable . "`.`serial` != '' ";
         //already imported
         if ($p['imported'] == self::IMPORTED) {
             $query .= " AND `import_status` != " . self::IMPORTED . "";
             //not imported
         } else {
             if ($p['imported'] == self::NOT_IMPORTED) {
                 $query .= " AND (`date_import` IS NULL OR `import_status` = " . self::IMPORTED . " ";
                 $query .= ") ";
             }
         }
         $entities = "";
         if ($config->isRecursive()) {
             $entities = getSonsOf('glpi_entities', $config->getEntityID());
         } else {
             $entities = $config->getEntityID();
         }
         $query .= "" . getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive());
         //// 4 - ORDER
         $ORDER = " ORDER BY `entities_id`,`" . $itemtable . "`.`name` ";
         $toview = array("name" => 1);
         foreach ($toview as $key => $val) {
             if ($p['sort'] == $val) {
                 $ORDER = self::addOrderBy($p['itemtype'], $p['sort'], $p['order'], $key);
             }
         }
         $query .= $ORDER;
         $result = $DB->query($query);
         $numrows = $DB->numrows($result);
         if ($p['start'] < $numrows) {
             // Set display type for export if define
             $output_type = Search::HTML_OUTPUT;
             if (isset($_GET["display_type"])) {
                 $output_type = $_GET["display_type"];
             }
             $parameters = "itemtype=" . $p['itemtype'] . "&amp;manufacturers_id=" . $p['manufacturers_id'] . "&amp;imported=" . $p['imported'];
             $total = 0;
             if ($output_type == Search::HTML_OUTPUT) {
                 self::printPager($p['start'], $numrows, $target, $parameters, $p['itemtype']);
             }
             // Define begin and end var for loop
             // Search case
             $begin_display = $p['start'];
             $end_display = $p['start'] + $_SESSION["glpilist_limit"];
             // Export All case
             if (isset($_GET['export_all'])) {
                 $begin_display = 0;
                 $end_display = $numrows;
             }
             if (Session::isMultiEntitiesMode()) {
                 $colsup = 1;
             } else {
                 $colsup = 0;
             }
             //////////////////////HEADER///////////////
             if ($output_type == Search::HTML_OUTPUT) {
                 echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"../ajax/massiveaction.php\">";
             }
             //echo Search::displaySearchHeader($output_type,0); //table + div
             if ($canedit) {
                 $nbcols = 11 + $colsup;
             } else {
                 $nbcols = 10 + $colsup;
             }
             $LIST_LIMIT = $_SESSION['glpilist_limit'];
             $begin_display = $p['start'];
             $end_display = $p['start'] + $LIST_LIMIT;
             foreach ($toview as $key => $val) {
                 $linkto = '';
                 if (!isset($searchopt["PluginManufacturersimportsPreImport"][$val]['nosort']) || !$searchopt["PluginManufacturersimportsPreImport"][$val]['nosort']) {
                     $linkto = "{$target}?itemtype=" . $p['itemtype'] . "&amp;manufacturers_id=" . $p['manufacturers_id'] . "&amp;imported=" . $p['imported'] . "&amp;sort=" . $val . "&amp;order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&amp;start=" . $p['start'] . $globallinkto;
                 }
             }
             echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols);
             echo Search::showNewLine($output_type);
             $header_num = 1;
             echo Search::showHeaderItem($output_type, "", $header_num);
             echo Search::showHeaderItem($output_type, __('Name'), $header_num, $linkto, $p['sort'] == $val, $p['order']);
             if (Session::isMultiEntitiesMode()) {
                 echo Search::showHeaderItem($output_type, __('Entity'), $header_num);
             }
             echo Search::showHeaderItem($output_type, __('Serial number'), $header_num);
             echo $supplier->showItemTitle($output_type, $header_num);
             echo Search::showHeaderItem($output_type, __('Financial and administrative information'), $header_num);
             echo Search::showHeaderItem($output_type, __('Supplier attached', 'manufacturersimports'), $header_num);
             echo Search::showHeaderItem($output_type, __('New warranty attached', 'manufacturersimports'), $header_num);
             echo Search::showHeaderItem($output_type, _n('Link', 'Links', 1), $header_num);
             echo Search::showHeaderItem($output_type, _n('Status', 'Statuses', 1), $header_num);
             echo $supplier->showDocTitle($output_type, $header_num);
             // End Line for column headers
             echo Search::showEndLine($output_type);
             $i = $p['start'];
             if (isset($_GET['export_all'])) {
                 $i = 0;
             }
             if ($i > 0) {
                 $DB->data_seek($result, $i);
             }
             $row_num = 1;
             while ($i < $numrows && $i < $end_display) {
                 $i++;
                 $item_num = 1;
                 $line = $DB->fetch_array($result);
                 $compSerial = $line['serial'];
                 $compId = $line['id'];
                 $model = $line["model_name"];
                 if (!$line["itemtype"]) {
                     $line["itemtype"] = $p['itemtype'];
                 }
                 self::showImport($row_num, $item_num, $line, $output_type, $p['manufacturers_id'], $line["import_status"], $p['imported']);
                 //1.show already imported items && import_status not failed
                 if ($p['imported'] == 1) {
                     $total += 1;
                 }
             }
             echo "<tr class='tab_bg_1'><td colspan='" . ($canedit ? 11 + $colsup : 10 + $colsup) . "'>";
             echo sprintf(__('Total number of devices to import %s', 'manufacturersimports'), $total);
             echo "</td></tr>";
             // Close Table
             $title = "";
             // Create title
             if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
                 $title .= PluginManufacturersimportsPreImport::getTypeName(2) . " " . $suppliername;
             }
             echo Search::showFooter($output_type, $title);
             //massive action
             if ($canedit && $output_type == Search::HTML_OUTPUT) {
                 if ($_SESSION['glpilist_limit'] < Toolbox::get_max_input_vars()) {
                     Html::openArrowMassives("massiveaction_form", false);
                     self::dropdownMassiveAction($compId, $p['itemtype'], $p['manufacturers_id'], $p['start'], $p['imported']);
                     Html::closeArrowMassives(array());
                 } else {
                     echo "<table class='tab_cadre' width='80%'><tr class='tab_bg_1'>" . "<td><span class='b'>";
                     echo __('Selection too large, massive action disabled.') . "</span>";
                     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
                         echo "<br>" . __('To increase the limit: change max_input_vars or suhosin.post.max_vars in php configuration.');
                     }
                     echo "</td></tr></table>";
                 }
                 Html::closeForm();
             } else {
                 echo "</table>";
                 echo "</div>";
             }
             echo "<br>";
             if ($output_type == Search::HTML_OUTPUT) {
                 self::printPager($p['start'], $numrows, $target, $parameters, $p['itemtype']);
             }
         } else {
             echo "<div align='center'><b>" . __('No device finded', 'manufacturersimports') . "</b></div>";
         }
     }
 }
Exemplo n.º 13
0
 /**
  * show Export Form from popup.php
  * for odt export
  */
 function showExportForm($opt)
 {
     global $LANG;
     $classname = $opt["classname"];
     if ($classname) {
         echo "<div align='center'>";
         echo "<form method='POST' action='export.php?switchto=odtall&classname=" . $classname . "' \n                     id='exportform' name='exportform'>\n";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>";
         echo $LANG['plugin_mreporting']["export"][0];
         echo "</th></tr>";
         $reports = $this->getAllReports(false, $opt);
         foreach ($reports as $class => $report) {
             $i = 0;
             $nb_per_line = 2;
             $graphs = array();
             foreach ($report['functions'] as $function) {
                 if ($function['gtype'] === "sunburst") {
                     continue;
                 }
                 if ($function['is_active']) {
                     $graphs[$classname][$function['category_func']][] = $function;
                 }
             }
             foreach ($graphs[$classname] as $cat => $graph) {
                 echo "<tr class='tab_bg_1'><th colspan='4'>" . $cat . "</th></tr>";
                 foreach ($graph as $k => $v) {
                     if ($v['is_active']) {
                         if ($i % $nb_per_line == 0) {
                             if ($i != 0) {
                                 echo "</tr>";
                             }
                             echo "<tr class='tab_bg_1'>";
                         }
                         echo "<td>";
                         echo "<input type='checkbox' name='check[" . $v['function'] . $classname . "]'";
                         if (isset($_POST['check']) && $_POST['check'] == 'all') {
                             echo " checked ";
                         }
                         echo ">";
                         echo "</td>";
                         echo "<td>";
                         echo "<img src='" . $v['pic'] . "' />&nbsp;";
                         echo $v['title'];
                         echo "</td>";
                         $i++;
                     }
                 }
                 while ($i % $nb_per_line != 0) {
                     echo "<td width='10'>&nbsp;</td>";
                     echo "<td>&nbsp;</td>";
                     $i++;
                 }
             }
             echo "</tr>";
         }
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan ='4' class='center'>";
         echo "<div align='center'>";
         echo "<table><tr class='tab_bg_2'>";
         echo "<td>";
         echo __("Begin date");
         echo "</td>";
         echo "<td>";
         $date1 = strftime("%Y-%m-%d", time() - 30 * 24 * 60 * 60);
         Html::showDateFormItem("date1", $date1, true);
         echo "</td>";
         echo "<td>";
         echo __("End date");
         echo "</td>";
         echo "<td>";
         $date2 = strftime("%Y-%m-%d");
         Html::showDateFormItem("date2", $date2, true);
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         echo "</div>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         Html::openArrowMassives("exportform", true);
         $option[0] = $LANG['plugin_mreporting']["export"][3];
         $option[1] = $LANG['plugin_mreporting']["export"][4];
         Dropdown::showFromArray("withdata", $option, array());
         echo "&nbsp;";
         echo "<input type='button' id='export_submit'  value='" . __("Export") . "' class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         echo "<script type='text/javascript'>\n            Ext.get('export_submit').on('click', function () {\n               //get new crsf\n               Ext.Ajax.request({\n                  url: '../ajax/get_new_crsf_token.php',\n                  success: function(response, opts) {\n                     var token = response.responseText;\n                     Ext.select('#exportform input[name=_glpi_csrf_token]').set({'value': token});\n                     document.getElementById('exportform').submit();\n                  }\n               });\n            });\n         </script>";
     }
 }
Exemplo n.º 14
0
 /**
  * Execute the report
  *
  * @param $options   array
  **/
 function execute($options = array())
 {
     global $DB, $CFG_GLPI, $HEADER_LOADED;
     // Require (for pager) when not called by displayCriteriasForm
     $this->manageCriteriasValues();
     if (isset($_POST['list_limit'])) {
         $_SESSION['glpilist_limit'] = $_POST['list_limit'];
         unset($_POST['list_limit']);
     }
     $limit = $_SESSION['glpilist_limit'];
     if (isset($_POST["display_type"])) {
         $output_type = $_POST["display_type"];
         if ($output_type < 0) {
             $output_type = -$output_type;
             $limit = 0;
         }
     } else {
         $output_type = Search::HTML_OUTPUT;
     }
     $title = $this->title;
     if ($this->subname) {
         $title = sprintf(__('%1$s - %2$s'), $title, $this->subname);
     }
     $res = $DB->query($this->sql);
     $nbtot = $res ? $DB->numrows($res) : 0;
     if ($limit) {
         $start = isset($_GET["start"]) ? $_GET["start"] : 0;
         if ($start >= $nbtot) {
             $start = 0;
         }
         if ($start > 0 || $start + $limit < $nbtot) {
             $res = $DB->query($this->sql . " LIMIT {$start},{$limit}");
         }
     } else {
         $start = 0;
     }
     if ($nbtot == 0) {
         if (!$HEADER_LOADED) {
             Html::header($title, $_SERVER['PHP_SELF'], "utils", "report");
             Report::title();
         }
         echo "<div class='center'><font class='red b'>" . __('No item found') . "</font></div>";
         Html::footer();
     } else {
         if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             include GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php";
         } else {
             if ($output_type == Search::HTML_OUTPUT) {
                 if (!$HEADER_LOADED) {
                     Html::header($title, $_SERVER['PHP_SELF'], "utils", "report");
                     Report::title();
                 }
                 echo "<div class='center'><table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . $title . "</th></tr>\n";
                 echo "<tr class='tab_bg_2 center'><td class='center'>";
                 echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n";
                 $param = "";
                 foreach ($_POST as $key => $val) {
                     if (is_array($val)) {
                         foreach ($val as $k => $v) {
                             echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >";
                             if (!empty($param)) {
                                 $param .= "&";
                             }
                             $param .= $key . "[" . $k . "]=" . urlencode($v);
                         }
                     } else {
                         echo "<input type='hidden' name='" . $key . "' value='{$val}' >";
                         if (!empty($param)) {
                             $param .= "&";
                         }
                         $param .= "{$key}=" . urlencode($val);
                     }
                 }
                 Dropdown::showOutputFormat();
                 Html::closeForm();
                 echo "</td></tr>";
                 echo "</table></div>";
                 Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param);
             }
         }
     }
     if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) {
         if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) {
             echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php\">";
         }
     }
     plugin_reports_checkRight($this->plug, $this->name, "r");
     if ($res && $nbtot > 0) {
         $nbcols = $DB->num_fields($res);
         $nbrows = $DB->numrows($res);
         echo Search::showHeader($output_type, $nbrows, $nbcols, true);
         echo Search::showNewLine($output_type);
         $num = 1;
         // fill $sqlcols with default sql query fields so we can validate $columns
         $sqlcols = array();
         for ($i = 0; $i < $nbcols; $i++) {
             $colname = $DB->field_name($res, $i);
             $sqlcols[] = $colname;
         }
         $colsname = array();
         // if $columns is not empty, display $columns
         if (count($this->columns) > 0) {
             foreach ($this->columns as $colname => $column) {
                 // display only $columns that are valid
                 if (in_array($colname, $sqlcols)) {
                     $column->showTitle($output_type, $num);
                     $colsname[$colname] = $column;
                 }
             }
         } else {
             // else display default columns from SQL query
             foreach ($sqlcols as $colname) {
                 $column = new PluginReportsColumn($colname, $colname);
                 $column->showTitle($output_type, $num);
                 $colsname[$colname] = $column;
             }
         }
         echo Search::showEndLine($output_type);
         $prev = "";
         for ($row_num = 2; $row = $DB->fetch_assoc($res); $row_num++) {
             $crt = "";
             foreach ($this->group_by as $colname) {
                 if (isset($row[$colname])) {
                     $crt .= $row[$colname] . "####";
                 }
             }
             echo Search::showNewLine($output_type);
             $num = 1;
             foreach ($colsname as $colname => $column) {
                 //If value needs to be modified on the fly
                 if (isset($this->columns_mapping[$colname]) && isset($this->columns_mapping[$colname][$row[$colname]])) {
                     $new_value = $this->columns_mapping[$colname][$row[$colname]];
                     $row[$colname] = $new_value;
                 }
                 if (!in_array($colname, $this->group_by)) {
                     $column->showValue($output_type, $row, $num, $row_num);
                 } else {
                     if ($crt == $prev) {
                         $column->showValue($output_type, $output_type == Search::CSV_OUTPUT ? $row : array(), $num, $row_num);
                     } else {
                         $column->showValue($output_type, $row, $num, $row_num, true);
                     }
                 }
             }
             // Each column
             echo Search::showEndLine($output_type);
             $prev = $crt;
         }
         // Each row
         if (isset($options['withtotal']) && $options['withtotal']) {
             echo Search::showNewLine($output_type);
             $num = 1;
             foreach ($colsname as $colname => $column) {
                 $column->showTotal($output_type, $num, $row_num);
             }
             echo Search::showEndLine($output_type);
         }
     }
     echo Search::showFooter($output_type, $title);
     if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) {
         if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) {
             Html::openArrowMassives("massiveaction_form", true);
             Dropdown::showForMassiveAction($options['withmassiveaction']);
             $options = array();
             Html::closeArrowMassives($options);
             Html::closeForm();
         }
         Html::footer();
     }
 }
 function showItemFromPlugin($instID, $face)
 {
     global $DB, $CFG_GLPI;
     if (!$this->canView()) {
         return false;
     }
     $rand = mt_rand();
     $PluginRacksRack = new PluginRacksRack();
     $PluginRacksConfig = new PluginRacksConfig();
     if ($PluginRacksRack->getFromDB($instID)) {
         $canedit = $PluginRacksRack->can($instID, UPDATE);
         if ($canedit) {
             $this->AddItemToRack($PluginRacksRack, $instID, $face);
         }
         //LIST
         echo "<form method='post' name='racks_form{$rand}' id='racks_form{$rand}'  \n               action=\"" . PluginRacksRack::getFormURL(true) . "\">";
         echo "<div class='center'><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='12'>" . __('Rack enclosure arrangement', 'racks') . ":</th></tr><tr>";
         if ($face == PluginRacksRack::FRONT_FACE) {
             $query = "SELECT `" . $this->getTable() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n              AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n              AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \n               OR (`" . $this->getTable() . "`.`faces_id` ='" . PluginRacksRack::BACK_FACE . "' \n                  AND `glpi_plugin_racks_itemspecifications`.`length` = 1 ))\n              ORDER BY `" . $this->getTable() . "`.`position` ASC";
         } else {
             $query = "SELECT `" . $this->getTable() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n              AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n              AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \n               OR (`" . $this->getTable() . "`.`faces_id` ='" . PluginRacksRack::FRONT_FACE . "' \n                  AND `glpi_plugin_racks_itemspecifications`.`length` = 1 ))\n              ORDER BY `" . $this->getTable() . "`.`position` ASC";
         }
         $result = $DB->query($query);
         $number = $DB->numrows($result);
         $amps_tot = 0;
         $flow_rate_tot = 0;
         $dissip_tot = 0;
         $weight_tot = $PluginRacksRack->fields["weight"];
         $nbcordons = 0;
         $nbcordons_tot = 0;
         $cordons_amps_tot = 0;
         $computer_tot = 0;
         $computer_size_tot = 0;
         $networking_tot = 0;
         $networking_size_tot = 0;
         $peripheral_tot = 0;
         $peripheral_size_tot = 0;
         $others_tot = 0;
         $others_size_tot = 0;
         $next = 0;
         $device_size = 0;
         echo "<th>&nbsp;</th>";
         echo "<th>" . __('Position', 'racks') . "</th>";
         echo "<th>" . __('Name') . "</th>";
         // nom
         echo "<th>" . __('Type') . "</th>";
         // type de materiel
         echo "<th>" . __('Model') . "</th>";
         echo "<th>" . __('Power supply 1', 'racks') . "</th>";
         //alim1
         echo "<th>" . __('Power supply 2', 'racks') . "</th>";
         //alim2
         echo "<th>" . __('C13 Power Cord Quantity', 'racks') . "</th>";
         // nb cordons
         echo "<th>" . __('Total Current', 'racks') . "<br>(" . __('amps', 'racks') . ")</th>";
         // Courant consommé
         echo "<th>" . __('Calorific waste', 'racks') . "<br>";
         // Dissipation calorifique
         echo " (";
         $PluginRacksConfig->getUnit("dissipation");
         echo ")</th>";
         echo "<th>" . __('Flow Rate', 'racks') . "<br>";
         // Débit d'air frais
         echo " (";
         $PluginRacksConfig->getUnit("dissipation");
         echo ")</th>";
         echo "<th>" . __('Weight', 'racks') . "<br>";
         // poids
         echo " (";
         $PluginRacksConfig->getUnit("weight");
         echo ")</th>";
         echo "</tr>";
         for ($i = $PluginRacksRack->fields['rack_size']; $i >= 1; $i--) {
             $alim1 = 0;
             $alim2 = 0;
             $j = $i;
             if ($i < 10) {
                 $j = "0" . $i;
             }
             if ($face == PluginRacksRack::FRONT_FACE) {
                 // recherche de l'equipement a la position courante
                 $query = "SELECT `" . $this->getTable() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n              AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n              AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \n                  OR (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \n                     AND `glpi_plugin_racks_itemspecifications`.`length` = 1)) AND `position` ='{$j}'\n              ORDER BY `" . $this->getTable() . "`.`position` ASC";
             } else {
                 $query = "SELECT `" . $this->getTable() . "`.*\n              FROM `" . $this->getTable() . "`,`glpi_plugin_racks_itemspecifications`\n              WHERE `" . $this->getTable() . "`.`plugin_racks_itemspecifications_id` = `glpi_plugin_racks_itemspecifications`.`id` \n               AND `" . $this->getTable() . "`.`plugin_racks_racks_id` = '{$instID}'\n               AND (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::BACK_FACE . "' \n                  OR (`" . $this->getTable() . "`.`faces_id` = '" . PluginRacksRack::FRONT_FACE . "' \n                     AND `glpi_plugin_racks_itemspecifications`.`length` = 1)) AND `position` ='{$j}'\n              ORDER BY `" . $this->getTable() . "`.`position` ASC";
             }
             $result = $DB->query($query);
             $number = $DB->numrows($result);
             // Si equipement
             if ($number != 0) {
                 $data = $DB->fetch_array($result);
                 $class = substr($data["itemtype"], 0, -5);
                 $item = new $class();
                 $table = getTableForItemType($class);
                 $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $data["items_id"] . "' ");
                 $device = $DB->fetch_array($r);
                 $modelclass = $data["itemtype"];
                 $model_table = getTableForItemType($modelclass);
                 $modelfield = getForeignKeyFieldForTable(getTableForItemType($modelclass));
                 $query = "SELECT `" . $model_table . "`.`name` AS model,`" . $model_table . "`.`id` AS modelid, `glpi_plugin_racks_itemspecifications`.* \n                        FROM `glpi_plugin_racks_itemspecifications` " . " LEFT JOIN `" . $model_table . "` \n                        ON (`glpi_plugin_racks_itemspecifications`.`model_id` = `" . $model_table . "`.`id`)" . " LEFT JOIN `" . $table . "` \n                        ON (`glpi_plugin_racks_itemspecifications`.`model_id` = `" . $table . "`.`" . $modelfield . "` \n                           AND `glpi_plugin_racks_itemspecifications`.`itemtype` = '" . $modelclass . "')" . " WHERE `" . $table . "`.`id` = '" . $data["items_id"] . "' ";
                 //Rack recursivity .getEntitiesRestrictRequest(" AND ",$table,'','',$item->maybeRecursive())
                 $res = $DB->query($query);
                 $device_spec = $DB->fetch_array($res);
                 $device_size = $device_spec["size"];
                 if ($data["first_powersupply"] > 0) {
                     $nbcordons += 1;
                     $nbcordons_tot += 1;
                 }
                 if ($data["second_powersupply"] > 0) {
                     $nbcordons += 1;
                     $nbcordons_tot += 1;
                 }
                 if ($data["itemtype"] == 'ComputerModel') {
                     $computer_tot += 1;
                     $computer_size_tot += $device_spec["size"];
                 } else {
                     if ($data["itemtype"] == 'PeripheralModel') {
                         $peripheral_tot += 1;
                         $peripheral_size_tot += $device_spec["size"];
                     } else {
                         if ($data["itemtype"] == 'NetworkEquipmentModel') {
                             $networking_tot += 1;
                             $networking_size_tot += $device_spec["size"];
                         } else {
                             if ($data["itemtype"] == 'PluginRacksOtherModel') {
                                 $others_tot += 1;
                                 $others_size_tot += $device_spec["size"];
                             }
                         }
                     }
                 }
                 for ($t = 0; $t < $device_size; $t++) {
                     if ($t == 0) {
                         if ($data["itemtype"] == 'ComputerModel') {
                             echo "<tr class='plugin_racks_device_computers_color'>";
                         } else {
                             if ($data["itemtype"] == 'PeripheralModel') {
                                 echo "<tr class='plugin_racks_device_peripherals_color'>";
                             } else {
                                 if ($data["itemtype"] == 'NetworkEquipmentModel') {
                                     echo "<tr class='plugin_racks_device_networking_color'>";
                                 } else {
                                     if ($data["itemtype"] == 'PluginRacksOtherModel') {
                                         echo "<tr class='plugin_racks_device_others_color'>";
                                     }
                                 }
                             }
                         }
                         echo "<td width='10' rowspan='" . $device_size . "'>";
                         $sel = "";
                         if (isset($_GET["select"]) && $_GET["select"] == "all") {
                             $sel = "checked";
                         }
                         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>";
                         echo "</td>";
                         echo "<td class='center'>U";
                         if ($canedit) {
                             echo "<input type='text' size='3' name='position" . $data["id"] . "' value='{$j}'>";
                             echo "&nbsp;<input type='image' name='updateDevice[" . $data["id"] . "]' value=\"" . _sx('button', 'Save') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' class='calendrier'>";
                         } else {
                             echo $j;
                         }
                         echo "</td>";
                         $link = Toolbox::getItemTypeFormURL(substr($data["itemtype"], 0, -5));
                         if ($data["itemtype"] != 'PluginRacksOtherModel') {
                             $name = "<a href=\"" . $link . "?id=" . $data["items_id"] . "\">" . $device["name"] . "</a>";
                         } else {
                             $name = $device["name"];
                         }
                         echo "<input type='hidden' name='plugin_racks_racks_id' value='" . $PluginRacksRack->fields['id'] . "'>";
                         echo "<input type='hidden' name='rack_size' value='" . $PluginRacksRack->fields['rack_size'] . "'>";
                         echo "<input type='hidden' name='type" . $data["id"] . "' value='" . $data["itemtype"] . "'>";
                         echo "<input type='hidden' name='items_id" . $data["id"] . "' value='" . $data["items_id"] . "'>";
                         echo "<input type='hidden' name='plugin_racks_itemspecifications_id" . $data["id"] . "' value='" . $data["plugin_racks_itemspecifications_id"] . "'>";
                         echo "<input type='hidden' name='update_server' value='1'>";
                         echo "<input type='hidden' name='faces_id' value='" . $face . "'>";
                         if ($data["itemtype"] != 'PluginRacksOtherModel') {
                             echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . " >" . $name . "</td>";
                         } else {
                             $PluginRacksOther = new PluginRacksOther();
                             $PluginRacksOther->GetfromDB($data["items_id"]);
                             echo "<td class='center'><input type='text' name='name" . $data["id"] . "' value='" . $PluginRacksOther->fields["name"] . "' size='10'></td>";
                         }
                         echo "<td class='center'>" . $item::getTypeName(2) . "</td>";
                         $linkmodel = Toolbox::getItemTypeFormURL($modelclass);
                         echo "<td class='center'><a href=\"" . $linkmodel . "?id=" . $device_spec["modelid"] . "\">" . $device_spec["model"] . " (" . $device_spec["size"] . "U)</a></td>";
                         echo "<td class='center'>";
                         echo Dropdown::getDropdownName("glpi_plugin_racks_connections", $data["first_powersupply"]);
                         echo "</td>";
                         echo "<td class='center'>";
                         echo Dropdown::getDropdownName("glpi_plugin_racks_connections", $data["second_powersupply"]);
                         echo "</td>";
                         echo "<td class='center'>" . $nbcordons . "</td>";
                         if ($data["amps"] == '0.0000') {
                             $amps = $device_spec["amps"];
                         } else {
                             $amps = $data["amps"];
                         }
                         $cordons_amps_tot += $amps * $nbcordons;
                         echo "<td class='center'>" . Html::formatNumber($amps, true) . "</td>";
                         if ($data["dissipation"] == '0.0000') {
                             $dissipation = $device_spec["dissipation"];
                         } else {
                             $dissipation = $data["dissipation"];
                         }
                         echo "<td class='center'>" . Html::formatNumber($dissipation, true) . "</td>";
                         if ($data["flow_rate"] == '0.0000') {
                             $flow_rate = $device_spec["flow_rate"];
                         } else {
                             $flow_rate = $data["flow_rate"];
                         }
                         echo "<td class='center'>" . Html::formatNumber($flow_rate, true) . "</td>";
                         if ($data["weight"] == '0.0000') {
                             $weight = $device_spec["weight"];
                         } else {
                             $weight = $data["weight"];
                         }
                         echo "<td class='center'>" . Html::formatNumber($weight, true) . "</td>";
                         echo "</tr>";
                         if ($data["amps"] == '0.0000') {
                             $amps_tot += $device_spec["amps"];
                         } else {
                             $amps_tot += $data["amps"];
                         }
                         if ($data["flow_rate"] == '0.0000') {
                             $flow_rate_tot += $device_spec["flow_rate"];
                         } else {
                             $flow_rate_tot += $data["flow_rate"];
                         }
                         if ($data["dissipation"] == '0.0000') {
                             $dissip_tot += $device_spec["dissipation"];
                         } else {
                             $dissip_tot += $data["dissipation"];
                         }
                         if ($data["weight"] == '0.0000') {
                             $weight_tot += $device_spec["weight"];
                         } else {
                             $weight_tot += $data["weight"];
                         }
                     } else {
                         $name = $j - $t;
                         if ($data["itemtype"] == 'ComputerModel') {
                             echo "<tr class='plugin_racks_device_computers_color'>";
                         } else {
                             if ($data["itemtype"] == 'PeripheralModel') {
                                 echo "<tr class='plugin_racks_device_peripherals_color'>";
                             } else {
                                 if ($data["itemtype"] == 'NetworkEquipmentModel') {
                                     echo "<tr class='plugin_racks_device_networking_color'>";
                                 } else {
                                     if ($data["itemtype"] == 'PluginRacksOtherModel') {
                                         echo "<tr class='plugin_racks_device_others_color'>";
                                     }
                                 }
                             }
                         }
                         echo "<td class='center'>U{$name}</td><td colspan='10'></td></tr>";
                     }
                 }
                 if ($device_size > 1) {
                     for ($d = 1; $d < $device_size; $d++) {
                         $i--;
                     }
                 }
             } else {
                 // Si pas d'equipement a la position courante
                 echo "<tr class='tab_bg_1'><td></td><td class='center'>" . __('U', 'racks') . $j;
                 echo "</td><td colspan='10'></td></tr>";
             }
             $nbcordons = 0;
         }
         echo "<tr class='tab_bg_1'>";
         echo "<td></td>";
         echo "<td class='center'><b>" . __('Total') . "</b></td>";
         echo "<td colspan='3' class='center'><b>";
         if ($computer_tot != 0) {
             echo __('Total Servers', 'racks') . " : " . $computer_tot . " (" . $computer_size_tot . __('U', 'racks') . ")<br>";
         }
         if ($networking_tot != 0) {
             echo __('Total Network equipements', 'racks') . " : " . $networking_tot . " (" . $networking_size_tot . __('U', 'racks') . ")<br>";
         }
         if ($peripheral_tot != 0) {
             echo __('Total Peripherals', 'racks') . " : " . $peripheral_tot . " (" . $peripheral_size_tot . __('U', 'racks') . ")<br>";
         }
         if ($others_tot != 0) {
             echo __('Total Others', 'racks') . " : " . $others_tot . " (" . $others_size_tot . __('U', 'racks') . ")<br>";
         }
         //number of U availables
         $available = $PluginRacksRack->fields['rack_size'] - $computer_size_tot - $networking_size_tot - $peripheral_size_tot - $others_size_tot;
         if ($available > 0) {
             echo "<font color='green'>" . $available . " " . __('U availables', 'racks') . "</font>";
         } else {
             echo "<font color='red'>" . $available . " " . __('U availables', 'racks') . "</font>";
         }
         echo "</b></td>";
         echo "<td colspan='3' class='center'><b>" . __('Total power Cords', 'racks') . " : " . $nbcordons_tot . "</b><br>";
         echo "<b>" . __('Amperage on power Cords', 'racks') . " : " . $cordons_amps_tot . " " . __('amps', 'racks') . "</b></td>";
         echo "<td class='center'><b>" . Html::formatNumber($amps_tot, true) . " " . __('amps', 'racks') . "</b></td>";
         echo "<td class='center'><b>" . Html::formatNumber($dissip_tot, true) . " ";
         $PluginRacksConfig->getUnit("dissipation");
         echo "</b></td>";
         echo "<td class='center'><b>" . Html::formatNumber($flow_rate_tot, true) . " ";
         $PluginRacksConfig->getUnit("rate");
         echo "</b></td>";
         echo "<td class='center'><b>" . Html::formatNumber($weight_tot, true) . " ";
         $PluginRacksConfig->getUnit("weight");
         echo "</b></td>";
         echo "</tr>";
         echo "</table></div>";
         if ($canedit) {
             Html::openArrowMassives("racks_form{$rand}", true);
             Html::closeArrowMassives(array('deleteDevice' => _sx('button', 'Delete permanently')));
         } else {
             echo "<input type='hidden' name='rack_size' value='" . $PluginRacksRack->fields['rack_size'] . "'>";
             echo "</table></div>";
         }
         Html::closeForm();
         ////////////////////////////////////////////////////
         // Recherche des racks a gauche et a droite
         // Recuperation de la rangee
         $qPos = "SELECT `name`\n                                                        FROM `glpi_plugin_racks_roomlocations`\n                                                        WHERE `id` = '" . $PluginRacksRack->fields['plugin_racks_roomlocations_id'] . "' ";
         $rPos = $DB->query($qPos);
         $nbPos = $DB->numrows($rPos);
         $pos = "";
         $next = "";
         $prev = "";
         if ($nbPos != 0) {
             $dataPos = $DB->fetch_array($rPos);
             $pos = $dataPos['name'];
         }
         // Incrementation & docrementation de la lettre de rang
         if (!empty($pos)) {
             // Z is the last letter...
             if ($pos[0] != "Z") {
                 $next = chr(ord($pos[0]) + 1);
                 for ($h = 1; $h < strlen($pos); $h++) {
                     $next .= $pos[$h];
                 }
             }
             // A is the first letter....
             if ($pos[0] != "A") {
                 $prev = chr(ord($pos[0]) - 1);
                 for ($h = 1; $h < strlen($pos); $h++) {
                     $prev .= $pos[$h];
                 }
             }
             $qLeft = "SELECT `glpi_plugin_racks_racks`.`id`, `glpi_plugin_racks_roomlocations`.`name`\n            FROM `glpi_plugin_racks_racks`\n            LEFT JOIN `glpi_plugin_racks_roomlocations`\n            ON (`glpi_plugin_racks_roomlocations`.`id` = `glpi_plugin_racks_racks`.`plugin_racks_roomlocations_id`)\n            WHERE `glpi_plugin_racks_racks`.`is_deleted` = '0' AND `glpi_plugin_racks_roomlocations`.`name` = '" . $prev . "' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_racks_racks", '', '', $PluginRacksRack->maybeRecursive());
             $rLeft = $DB->query($qLeft);
             $nb = $DB->numrows($rLeft);
             echo "<br><br>";
             echo "<div align='center'><table border='0' width='950px'><tr><td class='left'>";
             if ($nb != 0) {
                 $left_racks = $DB->fetch_array($rLeft);
                 echo "<a href =\"" . $CFG_GLPI["root_doc"] . "/plugins/racks/front/rack.form.php?id=" . $left_racks['id'] . "\">\n               <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/left.png\" alt=''>&nbsp;" . __('Left rack enclosure', 'racks') . " " . $left_racks['name'] . "</a>";
             } else {
                 echo __('No rack enclosure on the left', 'racks');
             }
             echo "</td>";
             echo "<td>";
             echo "</td>";
             echo "<td class='right'>";
             $qRight = "SELECT `glpi_plugin_racks_racks`.`id`, `glpi_plugin_racks_roomlocations`.`name`\n            FROM `glpi_plugin_racks_racks`\n            LEFT JOIN `glpi_plugin_racks_roomlocations`\n            ON (`glpi_plugin_racks_roomlocations`.`id` = `glpi_plugin_racks_racks`.`plugin_racks_roomlocations_id`)\n            WHERE `glpi_plugin_racks_racks`.`is_deleted` = '0' AND `glpi_plugin_racks_roomlocations`.`name` = '" . $next . "' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_racks_racks", '', '', $PluginRacksRack->maybeRecursive());
             $rRight = $DB->query($qRight);
             $nb = $DB->numrows($rRight);
             if ($nb != 0) {
                 $right_racks = $DB->fetch_array($rRight);
                 echo "<a href =\"" . $CFG_GLPI["root_doc"] . "/plugins/racks/front/rack.form.php?id=" . $right_racks['id'] . "\">" . __('Right rack enclosure', 'racks') . " " . $right_racks['name'] . "&nbsp;<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/right.png\" alt=''></a>";
             } else {
                 echo __('No rack enclosure on the right', 'racks');
             }
             echo "</td></tr></table></div>";
         }
     }
 }
Exemplo n.º 16
0
 public function showOrderLink($plugin_order_orders_id)
 {
     global $DB, $CFG_GLPI;
     $PluginOrderOrder = new PluginOrderOrder();
     $PluginOrderOrder_Item = new PluginOrderOrder_Item();
     $PluginOrderReference = new PluginOrderReference();
     $PluginOrderReception = new PluginOrderReception();
     $PluginOrderOrder->getFromDB($plugin_order_orders_id);
     $canedit = $PluginOrderOrder->canDeliver() && !$PluginOrderOrder->canUpdateOrder() && !$PluginOrderOrder->isCanceled();
     $query_ref = "SELECT `glpi_plugin_order_orders_items`.`id` AS IDD,\n                           `glpi_plugin_order_orders_items`.`plugin_order_references_id` AS id,\n                           `glpi_plugin_order_references`.`name`,\n                           `glpi_plugin_order_references`.`itemtype`,\n                           `glpi_plugin_order_references`.`manufacturers_id`,\n                           `glpi_plugin_order_orders_items`.`price_taxfree`,\n                           `glpi_plugin_order_orders_items`.`discount`\n                    FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references`\n                    WHERE `plugin_order_orders_id` = '{$plugin_order_orders_id}'\n                    AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n                    AND `glpi_plugin_order_orders_items`.`states_id` = '" . PluginOrderOrder::ORDER_DEVICE_DELIVRED . "'\n                    GROUP BY `glpi_plugin_order_orders_items`.`plugin_order_references_id`\n                    ORDER BY `glpi_plugin_order_references`.`name`";
     $result_ref = $DB->query($query_ref);
     $numref = $DB->numrows($result_ref);
     while ($data_ref = $DB->fetch_array($result_ref)) {
         echo "<div class='center'><table class='tab_cadre_fixe'>";
         if (!$numref) {
             echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>";
         } else {
             $plugin_order_references_id = $data_ref["id"];
             $itemtype = $data_ref["itemtype"];
             $canuse = $itemtype != 'PluginOrderOther';
             $item = new $itemtype();
             $rand = mt_rand();
             $query = "SELECT  `glpi_plugin_order_orders_items`.`id` AS IDD,\n                              `glpi_plugin_order_references`.`id` AS id,\n                              `glpi_plugin_order_references`.`templates_id`,\n                              `glpi_plugin_order_orders_items`.`states_id`,\n                              `glpi_plugin_order_orders_items`.`delivery_date`,\n                              `glpi_plugin_order_orders_items`.`delivery_number`,\n                              `glpi_plugin_order_references`.`name`,\n                              `glpi_plugin_order_references`.`itemtype`,\n                              `glpi_plugin_order_orders_items`.`items_id`,\n                              `glpi_plugin_order_orders_items`.`price_taxfree`,\n                              `glpi_plugin_order_orders_items`.`discount`\n                       FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references`\n                       WHERE `plugin_order_orders_id` = '{$plugin_order_orders_id}'\n                       AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = '{$plugin_order_references_id}'\n                       AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n                       AND `glpi_plugin_order_orders_items`.`states_id` = '" . PluginOrderOrder::ORDER_DEVICE_DELIVRED . "'";
             if ($itemtype == 'SoftwareLicense') {
                 $query .= " GROUP BY `glpi_plugin_order_orders_items`.`price_taxfree`,\n                                    `glpi_plugin_order_orders_items`.`discount`";
             }
             $query .= " ORDER BY `glpi_plugin_order_references`.`name`";
             $result = $DB->query($query);
             $num = $DB->numrows($result);
             echo "<tr><th><ul><li>";
             echo "<a href=\"javascript:showHideDiv('generation{$rand}','generation_img{$rand}', " . "'" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">";
             echo "<img alt='' name='generation_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">";
             echo "</a>";
             echo "</li></ul></th>";
             echo "<th>" . __("Type") . "</th>";
             echo "<th>" . __("Manufacturer") . "</th>";
             echo "<th>" . __("Product reference", "order") . "</th>";
             echo "</tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td></td>";
             echo "<td align='center'>" . $item->getTypeName() . "</td>";
             echo "<td align='center'>" . Dropdown::getDropdownName("glpi_manufacturers", $data_ref["manufacturers_id"]) . "</td>";
             echo "<td>" . $PluginOrderReference->getReceptionReferenceLink($data_ref) . "&nbsp;({$num})</td>";
             echo "</tr>";
             echo "</table>";
             echo "<div class='center' id='generation{$rand}' style='display:none'>";
             echo "<form method='post' name='order_generation_form{$rand}'\n                     id='order_generation_form{$rand}'  action=\"" . Toolbox::getItemTypeFormUrl(__CLASS__) . "\">";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             if ($canedit & $canuse) {
                 echo "<th width='15'></th>";
             }
             if ($itemtype != 'SoftwareLicense') {
                 echo "<th>" . __("ID") . "</th>";
             } else {
                 echo "<th>" . __("Quantity", "order") . "</th>";
             }
             echo "<th>" . __("Reference") . "</th>";
             echo "<th>" . __("Status") . "</th>";
             echo "<th>" . __("Delivery date") . "</th>";
             echo "<th>" . _n("Associated item", "Associated items", 2) . "</th></tr>";
             while ($data = $DB->fetch_array($result)) {
                 $random = mt_rand();
                 $detailID = $data["IDD"];
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit & $canuse) {
                     echo "<td width='15' align='left'>";
                     $sel = "";
                     if (isset($_GET["select"]) && $_GET["select"] == "all") {
                         $sel = "checked";
                     }
                     echo "<input type='checkbox' name='item[" . $detailID . "]' value='1' {$sel}>";
                     echo "</td>";
                 }
                 if ($itemtype != 'SoftwareLicense') {
                     echo "<td align='center'>" . $data["IDD"] . "</td>";
                 } else {
                     echo "<td align='center'>";
                     echo $PluginOrderOrder_Item->getTotalQuantityByRefAndDiscount($plugin_order_orders_id, $plugin_order_references_id, $data["price_taxfree"], $data["discount"]);
                     echo "</td>";
                 }
                 echo "<td align='center'>" . $PluginOrderReference->getReceptionReferenceLink($data) . "</td>";
                 echo "<td align='center'>" . $PluginOrderReception->getReceptionStatus($detailID) . "</td>";
                 echo "<td align='center'>" . Html::convDate($data["delivery_date"]) . "</td>";
                 echo "<td align='center'>" . $this->getReceptionItemName($data["items_id"], $data["itemtype"]);
                 echo "<input type='hidden' name='id[{$detailID}]' value='{$detailID}'>";
                 echo "<input type='hidden' name='name[{$detailID}]' value='" . $data["name"] . "'>";
                 echo "<input type='hidden' name='itemtype[{$detailID}]' value='" . $data["itemtype"] . "'>";
                 echo "<input type='hidden' name='templates_id[{$detailID}]' value='" . $data["templates_id"] . "'>";
                 echo "<input type='hidden' name='states_id[{$detailID}]' value='" . $data["states_id"] . "'>";
             }
             echo "</tr>";
             echo "</table>";
             if ($canedit & $canuse) {
                 Html::openArrowMassives("order_generation_form{$rand}", true);
                 echo "<input type='hidden' name='plugin_order_orders_id' value='{$plugin_order_orders_id}'>";
                 $entities_id = $PluginOrderOrder->fields['entities_id'];
                 $this->dropdownLinkActions($itemtype, $plugin_order_references_id, $plugin_order_orders_id, $entities_id);
                 Html::closeArrowMassives(array());
             }
             Html::closeForm();
             echo "</div>";
         }
         echo "<br>";
     }
 }
Exemplo n.º 17
0
 static function showReports($ID, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $resource = new PluginResourcesResource();
     $resource->getFromDB($ID);
     $canedit = $resource->can($ID, 'w');
     Session::initNavigateListItems("PluginResourcesReportConfig", PluginResourcesResource::getTypeName(1) . " = " . $resource->fields["name"]);
     $query = "SELECT `glpi_plugin_resources_reportconfigs`.`id`,\n               `glpi_plugin_resources_reportconfigs`.`plugin_resources_resources_id`,\n                `glpi_plugin_resources_reportconfigs`.`information`, \n                `glpi_plugin_resources_reportconfigs`.`comment`\n                 FROM `glpi_plugin_resources_reportconfigs` ";
     $query .= " LEFT JOIN `glpi_plugin_resources_resources` ON (`glpi_plugin_resources_resources`.`id` = `glpi_plugin_resources_reportconfigs`.`plugin_resources_resources_id`)";
     $query .= " WHERE `glpi_plugin_resources_reportconfigs`.`plugin_resources_resources_id` = '{$ID}'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $row_num = 1;
     if ($number != "0") {
         if ($withtemplate < 2) {
             echo "<form method='post' name='form_reports{$rand}' id='form_reports{$rand}' action=\"./reportconfig.form.php\">";
         }
         echo "<div align='center'><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='5'>" . self::getTypeName(1) . "</th></tr>";
         $sel = "";
         if (isset($_GET["select"]) && $_GET["select"] == "all") {
             $sel = "checked";
         }
         echo "<tr>";
         if (plugin_resources_haveRight('resources', 'w') && $canedit && $withtemplate < 2) {
             echo "<th>&nbsp;</th>";
         }
         echo "<th>" . __('Comments') . "</th>";
         echo "<th>" . __('Information', 'Informations', 2) . "</th>";
         if ($withtemplate < 2) {
             echo "<th>&nbsp;</th>";
         }
         echo "</tr>";
         while ($data = $DB->fetch_array($result)) {
             Session::addToNavigateListItems("PluginResourcesReportConfig", $data['id']);
             $i++;
             $row_num++;
             echo "<tr class='tab_bg_1 center'>";
             if (plugin_resources_haveRight('resources', 'w') && $canedit && $withtemplate < 2) {
                 echo "<td width='10'>";
                 echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
                 echo "</td>";
             }
             echo "<td class='left'>" . nl2br($data["comment"]) . "</td>";
             echo "<td class='left'>" . nl2br($data["information"]) . "</td>";
             if ($withtemplate < 2) {
                 echo "<td class='center'>";
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/reportconfig.form.php?id=" . $data["id"] . "&amp;plugin_resources_resources_id=" . $data["plugin_resources_resources_id"] . "'>";
                 _e('Update');
                 if ($_SESSION["glpiis_ids_visible"]) {
                     echo " (" . $data["id"] . ")";
                 }
                 echo "</a></td>";
             }
             echo "</tr>";
         }
         echo "</table></div>";
         if ($number && $canedit && $withtemplate < 2) {
             if (plugin_resources_haveRight('resources', 'w')) {
                 Html::openArrowMassives("form_reports{$rand}", true);
                 Html::closeArrowMassives(array('delete_report' => _sx('button', 'Delete permanently')));
             }
         }
         if ($withtemplate < 2) {
             Html::closeForm();
         }
     }
 }
Exemplo n.º 18
0
 /**
  *
  * Displat all fields present in DB for an itemtype
  * @param $id the itemtype's id
  */
 public static function showObjectFieldsForm($id)
 {
     global $DB, $GO_BLACKLIST_FIELDS, $GO_READONLY_FIELDS, $GO_FIELDS, $CFG_GLPI;
     $url = Toolbox::getItemTypeFormURL(__CLASS__);
     $object_type = new PluginGenericobjectType();
     $object_type->getFromDB($id);
     $itemtype = $object_type->fields['itemtype'];
     $fields_in_db = PluginGenericobjectSingletonObjectField::getInstance($itemtype);
     $used_fields = array();
     //Reset fields definition only to keep the itemtype ones
     $GO_FIELDS = array();
     plugin_genericobject_includeCommonFields(true);
     $file = GLPI_ROOT . "/plugins/genericobject/fields/constants/" . $object_type->fields['name'] . ".constant.php";
     if (file_exists($file)) {
         include $file;
     }
     PluginGenericobjectType::includeConstants($itemtype, true);
     foreach ($GO_BLACKLIST_FIELDS as $autofield) {
         if (!in_array($autofield, $used_fields)) {
             $used_fields[$autofield] = $autofield;
         }
     }
     echo "<div class='center'>";
     echo "<form name='fieldslist' method='POST' action='{$url}'>";
     echo "<table class='tab_cadre_fixe' >";
     echo "<input type='hidden' name='id' value='{$id}'>";
     echo "<tr class='tab_bg_1'><th colspan='7'>";
     echo __("Fields associated with the object", "genericobject") . " : ";
     echo $itemtype::getTypeName();
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='10'></th>";
     echo "<th>" . __("Label", "genericobject") . "</th>";
     echo "<th>" . __("Name in DB", "genericobject") . "</th>";
     echo "<th width='10'></th>";
     echo "<th width='10'></th>";
     echo "</tr>";
     $total = count($fields_in_db);
     $global_index = $index = 1;
     foreach ($fields_in_db as $field => $value) {
         self::displayFieldDefinition($url, $itemtype, $field, $index, $global_index == $total);
         //All backlisted fields cannot be moved, and are listed first
         if (!in_array($field, $GO_READONLY_FIELDS)) {
             $index++;
         }
         //If it's a plugin dropdowns, get it's real name
         //(it may not be the one from the DB, in case it's a global field)
         $table = getTableNameForForeignKeyField($field);
         /*if ($table != '' && isPluginItemType(getItemTypeForTable($table))) {
              $classname = getItemTypeForTable($table);
              $class     = new $classname();
              $used_fields[$class->getFieldName()] = $class->getFieldName();
           } else {*/
         $used_fields[$field] = $field;
         //}
         $global_index++;
     }
     echo "</table>";
     Html::openArrowMassives('fieldslist', true);
     Html::closeArrowMassives(array('delete' => __("Delete permanently")));
     echo "<table class='tab_cadre'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Add new field", "genericobject") . "</td>";
     echo "<td align='left'>";
     self::dropdownFields("new_field", $itemtype, $used_fields);
     echo "</td>";
     echo "<td>";
     echo "<input type='submit' name='add_field' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Exemplo n.º 19
0
   function showContacts($itemtype, $items_id) {
      global $DB,$CFG_GLPI;

      $this->addContact($itemtype, $items_id);

      $group = new Group();
      $user  = new User();

      $rand = mt_rand();

      echo "<form method='post' name='contact_item_form$rand' id='contact_item_form$rand' action=\"".
                $CFG_GLPI["root_doc"]."/plugins/monitoring/front/contact_item.form.php\">";

      echo "<table class='tab_cadre_fixe'>";

      echo "<tr>";
      echo "<th>";
      echo __('Contacts', 'monitoring');
      echo "</th>";
      echo "</tr>";

      echo "</table>";

      echo "<table class='tab_cadre_fixe'>";

      echo "<tr>";
      echo "<th width='10'>&nbsp;</th>";
      echo "<th>".__('Group')." - ".__('Name')."</th>";
      echo "<th colspan='3'></th>";
      echo "</tr>";

      $used = array();
      // Display groups first
      $query = "SELECT * FROM `".$this->getTable()."`
         WHERE `items_id`='".$items_id."'
            AND `itemtype`='".$itemtype."'
            AND `groups_id` > 0";
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $group->getFromDB($data['groups_id']);

         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $group->getLink(1);
         echo "</td>";
         echo "<td colspan='3'>";

         echo "</td>";

         echo "</tr>";
      }

      echo "<tr>";
      echo "<th width='10'>&nbsp;</th>";
      echo "<th>".__('User')." - ".__('Name')."</th>";
      echo "<th>".__('Entity')."</th>";
      echo "<th>".__('Email address')."</th>";
      echo "<th>".__('Phone')."</th>";
      echo "</tr>";

      $entity = new Entity();
      $used = array();
      // Display Users
      $query = "SELECT * FROM `".$this->getTable()."`
         WHERE `items_id`='".$items_id."'
            AND `itemtype`='".$itemtype."'
            AND `users_id` > 0";
      $result = $DB->query($query);
      while ($data=$DB->fetch_array($result)) {
         $user->getFromDB($data['users_id']);

         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[".$data["id"]."]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $user->getLink(1);
         echo "</td>";
         $entity->getFromDB($data['entities_id']);
         echo "<td class='center'>";
         echo $entity->getName()." <strong>(R)</strong>";
         echo "</td>";
         echo "<td class='center'>";
         $a_emails = UserEmail::getAllForUser($data['users_id']);
         $first = 0;
         foreach ($a_emails as $email) {
            if ($first == 0) {
               echo $email;
            }
            $first++;
         }
         echo "</td>";
         echo "<td class='center'>";
         echo $user->fields['phone'];
         echo "</td>";

         echo "</tr>";
      }

      Html::openArrowMassives("contact_item_form$rand", true);
      Html::closeArrowMassives(array('deleteitem' => _sx('button', 'Delete permanently')));
      Html::closeForm();
      echo "</table>";

   }
Exemplo n.º 20
0
 public function showItemFromPlugin($instID, $search = '')
 {
     global $DB, $CFG_GLPI;
     if (!$this->canView()) {
         return false;
     }
     $rand = mt_rand();
     $PluginConnectionsConnection = new PluginConnectionsConnection();
     if ($PluginConnectionsConnection->getFromDB($instID)) {
         $canedit = $PluginConnectionsConnection->can($instID, UPDATE);
         $query = "SELECT DISTINCT `itemtype`\n                   FROM `" . $this->getTable() . "`\n                   WHERE `plugin_connections_connections_id` = '" . (int) $instID . "'\n                   ORDER BY `itemtype`";
         $result = $DB->query($query);
         $number = $DB->numrows($result);
         if (Session::isMultiEntitiesMode()) {
             $colsup = 1;
         } else {
             $colsup = 0;
         }
         echo "<form method='post' name='connections_form{$rand}' id='connections_form{$rand}'\n                  action=\"" . $CFG_GLPI["root_doc"] . "/plugins/connections/front/connection.form.php\">";
         echo "<div class='center'><table class='tab_cadrehov'>";
         echo "<tr><th colspan='" . ($canedit ? 5 + $colsup : 4 + $colsup) . "'>" . __('Associated element') . ":</th></tr><tr>";
         if ($canedit) {
             echo "<th>&nbsp;</th>";
         }
         echo "<th>" . __('Type') . "</th>";
         echo "<th>" . __('Name') . "</th>";
         if (Session::isMultiEntitiesMode()) {
             echo "<th>" . __('Entity') . "</th>";
         }
         echo "<th>" . __('Serial Number') . "</th>";
         echo "<th>" . __('Inventory number') . "</th>";
         echo "</tr>";
         for ($i = 0; $i < $number; $i++) {
             $type = $DB->result($result, $i, "itemtype");
             if (!class_exists($type)) {
                 continue;
             }
             $item = new $type();
             if ($item->canView()) {
                 $column = "name";
                 $table = getTableForItemType($type);
                 $itemTable = $this->getTable();
                 $entitiesRestrict = getEntitiesRestrictRequest(" AND ", 't', '', '', $item->maybeRecursive());
                 $mayBeTemplate = $item->maybeTemplate() ? " AND t.`is_template` = '0'" : '';
                 $query = "SELECT t.*, it.`id` AS items_id, `glpi_entities`.`ID` AS entity\n                         FROM `{$itemTable}` it, `{$table}` t\n                         LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = t.`entities_id`)\n                         WHERE t.`id` = it.`items_id`\n                         AND it.`itemtype` = '{$type}'\n                         AND it.`plugin_connections_connections_id` = '{$instID}'\n                         {$entitiesRestrict}\n                         {$mayBeTemplate}\n                         ORDER BY `glpi_entities`.`completename`, t.`{$column}`;";
                 if ($result_linked = $DB->query($query)) {
                     if ($DB->numrows($result_linked)) {
                         Session::initNavigateListItems($type, __('Connections', 'connections') . " = " . $PluginConnectionsConnection->fields['name']);
                         while ($data = $DB->fetch_assoc($result_linked)) {
                             $item->getFromDB($data["id"]);
                             Session::addToNavigateListItems($type, $data["id"]);
                             $ID = $_SESSION["glpiis_ids_visible"] || empty($data["name"]) ? " (" . $data["id"] . ")" : "";
                             $link = Toolbox::getItemTypeFormURL($type);
                             $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . $ID . "</a>";
                             echo "<tr class='tab_bg_1'>";
                             if ($canedit) {
                                 echo "<td width='10'>";
                                 $sel = isset($_GET["select"]) && "all" == $_GET["select"] ? "checked" : "";
                                 echo "<input type='checkbox' name='item[" . $data["items_id"] . "]' value='1' " . $sel . ">";
                                 echo "</td>";
                             }
                             echo "<td class='center'>" . $item->getTypeName() . "</td>";
                             $is_deleted = isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "";
                             echo "<td class='center' " . $is_deleted . ">" . $name . "</td>";
                             if (Session::isMultiEntitiesMode()) {
                                 echo "<td class='center'>";
                                 echo Dropdown::getDropdownName("glpi_entities", $data['entity']);
                                 echo "</td>";
                             }
                             echo "<td class='center'>";
                             echo isset($data["serial"]) ? $data["serial"] : "-";
                             echo "</td>";
                             echo "<td class='center'>";
                             echo isset($data["otherserial"]) ? $data["otherserial"] : "-";
                             echo "</td>";
                             echo "</tr>";
                         }
                     }
                 }
             }
         }
         if ($canedit) {
             echo "<tr class='tab_bg_1'><td colspan='" . (3 + $colsup) . "' class='center'>";
             echo "<input type='hidden' name='plugin_connections_connections_id' value='{$instID}'>";
             Dropdown::showAllItems("items_id", 0, 0, $PluginConnectionsConnection->fields['is_recursive'] ? -1 : $PluginConnectionsConnection->fields['entities_id'], $this->getClasses());
             echo "</td>";
             echo "<td colspan='2' class='center' class='tab_bg_2'>";
             echo "<input type='submit' name='additem' value=\"" . __('Add') . "\" class='submit'>";
             echo "</td></tr>";
             echo "</table></div>";
             Html::openArrowMassives("connections_form{$rand}");
             Html::closeArrowMassives(array('deleteitem' => __('Delete')));
         } else {
             echo "</table></div>";
         }
         echo Html::closeForm(false);
     }
 }
 function showHosts($componentscatalogs_id, $static)
 {
     global $DB, $CFG_GLPI;
     if ($static == '1') {
         $this->addHost($componentscatalogs_id);
     }
     $rand = mt_rand();
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'\n            AND `is_static`='" . $static . "'";
     $result = $DB->query($query);
     echo "<form method='post' name='componentscatalog_host_form{$rand}' id='componentscatalog_host_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/componentscatalog_host.form.php\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='5'>";
     if ($DB->numrows($result) == 0) {
         echo __('No associated hosts', 'monitoring');
     } else {
         echo __('Associated hosts', 'monitoring');
     }
     echo "</th>";
     echo "</tr>";
     echo "</table>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Entity') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     while ($data = $DB->fetch_array($result)) {
         $itemtype = $data['itemtype'];
         $item = new $itemtype();
         $display_normal = 1;
         $networkports = false;
         if ($itemtype == 'NetworkEquipment') {
             $querys = "SELECT * FROM `glpi_plugin_monitoring_services`\n               WHERE `plugin_monitoring_componentscatalogs_hosts_id`='" . $data['id'] . "'\n                  AND `networkports_id`='0'";
             $results = $DB->query($querys);
             if ($DB->numrows($results) == 0) {
                 $display_normal = 0;
             }
             $querys = "SELECT * FROM `glpi_plugin_monitoring_services`\n               WHERE `plugin_monitoring_componentscatalogs_hosts_id`='" . $data['id'] . "'\n                  AND `networkports_id`!='0'";
             $results = $DB->query($querys);
             if ($DB->numrows($results) > 0) {
                 $networkports = true;
             }
         }
         $item->getFromDB($data['items_id']);
         if ($display_normal == 1) {
             echo "<tr>";
             echo "<td>";
             echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
             echo "</td>";
             echo "<td class='center'>";
             echo $item->getTypeName();
             echo "</td>";
             echo "<td class='center'>";
             echo Dropdown::getDropdownName("glpi_entities", $item->fields['entities_id']) . "</td>";
             echo "<td class='center" . (isset($item->fields['is_deleted']) && $item->fields['is_deleted'] ? " tab_bg_2_2'" : "'");
             echo ">" . $item->getLink() . "</td>";
             echo "<td class='center'>" . (isset($item->fields["serial"]) ? "" . $item->fields["serial"] . "" : "-") . "</td>";
             echo "<td class='center'>" . (isset($item->fields["otherserial"]) ? "" . $item->fields["otherserial"] . "" : "-") . "</td>";
             echo "</tr>";
         }
         if ($networkports) {
             $itemport = new NetworkPort();
             while ($datas = $DB->fetch_array($results)) {
                 $itemport->getFromDB($datas['networkports_id']);
                 echo "<tr>";
                 echo "<td>";
                 echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
                 echo "</td>";
                 echo "<td class='center'>";
                 echo $itemport->getTypeName();
                 echo "</td>";
                 echo "<td class='center'>";
                 echo Dropdown::getDropdownName("glpi_entities", $item->fields['entities_id']) . "</td>";
                 echo "<td colspan='3' class='left" . (isset($item->fields['is_deleted']) && $item->fields['is_deleted'] ? " tab_bg_2_2'" : "'");
                 echo ">" . $itemport->getLink() . " on " . $item->getLink(1) . "</td>";
                 echo "</tr>";
             }
         }
     }
     if ($static == '1') {
         Html::openArrowMassives("componentscatalog_host_form{$rand}", true);
         Html::closeArrowMassives(array('deleteitem' => _sx('button', 'Delete permanently')));
         Html::closeForm();
     }
     echo "</table>";
 }
Exemplo n.º 22
0
 public static function showOrderSupplierInfos($ID)
 {
     //TODO : en cours
     global $DB;
     $order = new PluginOrderOrder();
     $order->getFromDB($ID);
     $suppliers_id = $order->fields["suppliers_id"];
     Session::initNavigateListItems(__CLASS__, __("Order", "order") . " = " . $order->fields["name"]);
     $candelete = $order->can($ID, UPDATE);
     $rand = mt_rand();
     $link = Toolbox::getItemTypeFormURL(__CLASS__);
     echo "<form method='post' name='show_supplierinfos{$rand}' id='show_supplierinfos{$rand}' " . "action=\"" . $link . "\">";
     echo "<div class='center'>";
     echo "<input type='hidden' name='plugin_order_orders_id' value='" . $ID . "'>";
     $table = getTableForItemType(__CLASS__);
     $nb_elements = countElementsInTable($table, "`plugin_order_orders_id` = '{$ID}'");
     if ($nb_elements > 0) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . __("Supplier Detail", "order") . "</th></tr>";
         echo "<tr>";
         echo "<th>&nbsp;</th>";
         echo "<th>" . __("Supplier") . "</th>";
         echo "<th>" . __("Quote number", "order") . "</th>";
         echo "<th>" . __("Order number") . "</th>";
         echo "</tr>";
         $datas = getAllDatasFromTable($table, "`plugin_order_orders_id` = '{$ID}'");
         foreach ($datas as $data) {
             Session::addToNavigateListItems(__CLASS__, $data['id']);
             echo "<input type='hidden' name='item[" . $data["id"] . "]' value='" . $ID . "'>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td>";
             if ($candelete) {
                 echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
             }
             echo "</td>";
             echo "<td><a href='" . $link . "?id=" . $data["id"] . "&plugin_order_orders_id=" . $ID . "'>" . Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]) . "</a></td>";
             echo "<td>" . $data["num_quote"] . "</td>";
             echo "<td>" . $data["num_order"] . "</td>";
             echo "</tr>";
         }
         echo "</table></div>";
         if ($candelete) {
             Html::openArrowMassives("show_supplierinfos{$rand}", true);
             Html::closeArrowMassives(array('delete' => __("Delete permanently")));
         }
     }
     Html::closeForm();
 }
 function showComponents($componentscatalogs_id)
 {
     global $DB, $CFG_GLPI;
     $this->addComponent($componentscatalogs_id);
     $rand = mt_rand();
     $pmComponent = new PluginMonitoringComponent();
     $pmCommand = new PluginMonitoringCommand();
     $pmCheck = new PluginMonitoringCheck();
     $calendar = new Calendar();
     echo "<form method='post' name='componentscatalog_component_form{$rand}' id='componentscatalog_component_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/monitoring/front/componentscatalog_component.form.php\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>";
     echo __('Associated components', 'monitoring');
     echo "</th>";
     echo "</tr>";
     echo "</table>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th width='10'>&nbsp;</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Command name', 'monitoring') . "</th>";
     echo "<th>" . __('Check definition', 'monitoring') . "</th>";
     echo "<th>" . __('Check period', 'monitoring') . "</th>";
     echo "<th>" . __('Remote check', 'monitoring') . "</th>";
     echo "</tr>";
     $used = array();
     $query = "SELECT * FROM `" . $this->getTable() . "`\n         WHERE `plugin_monitoring_componentscalalog_id`='" . $componentscatalogs_id . "'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $used[] = $data['plugin_monitoring_components_id'];
         $pmComponent->getFromDB($data['plugin_monitoring_components_id']);
         echo "<tr>";
         echo "<td>";
         echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>";
         echo "</td>";
         echo "<td class='center'>";
         echo $pmComponent->getLink(1);
         echo "</td>";
         echo "<td class='center'>";
         $pmCommand->getFromDB($pmComponent->fields['plugin_monitoring_commands_id']);
         echo $pmCommand->getLink();
         echo "</td>";
         echo "<td class='center'>";
         $pmCheck->getFromDB($pmComponent->fields['plugin_monitoring_checks_id']);
         echo $pmCheck->getLink();
         echo "</td>";
         echo "<td class='center'>";
         $calendar->getFromDB($pmComponent->fields['calendars_id']);
         echo $calendar->getLink();
         echo "</td>";
         echo "<td class='center'>";
         if ($pmComponent->fields['remotesystem'] == '') {
             echo "-";
         } else {
             echo $pmComponent->fields['remotesystem'];
         }
         echo "</td>";
         echo "</tr>";
     }
     Html::openArrowMassives("componentscatalog_host_form{$rand}", true);
     Html::closeArrowMassives(array('deleteitem' => _sx('button', 'Delete permanently')));
     Html::closeForm();
     echo "</table>";
 }
Exemplo n.º 24
0
            echo "<td class='blue'>" . $data["Baddr"] . "</td>";
        }
        echo "<td class='blue'>" . getLastOcsUpdate($data['BID']) . "</td>";
        echo "</tr>\n";
    }
    echo "<tr class='tab_bg_4'><td class='center' colspan='{$colspan}'>";
    if ($i) {
        printf(__('%1$s: %2$s'), __('Duplicate computers', 'reports'), $i);
    } else {
        _e('No item found');
    }
    echo "</td></tr>\n";
    echo "</table>";
    if ($canedit) {
        if ($i) {
            Html::openArrowMassives("massiveaction_form");
            Dropdown::showForMassiveAction('Computer');
            $options = array();
            Html::closeArrowMassives($options);
        }
        Html::closeForm();
    }
}
Html::footer();
function buildBookmarkUrl($url, $crit)
{
    return $url . "?crit=" . $crit;
}
function getLastOcsUpdate($computers_id)
{
    global $DB;
 /**
  *
  * Displat all fields present in DB for an itemtype
  * @param $id the itemtype's id
  */
 public static function showObjectFieldsForm($id)
 {
     global $DB, $GO_BLACKLIST_FIELDS, $GO_READONLY_FIELDS, $GO_FIELDS, $CFG_GLPI;
     $url = Toolbox::getItemTypeFormURL(__CLASS__);
     $object_type = new PluginGenericobjectType();
     $object_type->getFromDB($id);
     $itemtype = $object_type->fields['itemtype'];
     $fields_in_db = PluginGenericobjectSingletonObjectField::getInstance($itemtype);
     $used_fields = array();
     //Reset fields definition only to keep the itemtype ones
     $GO_FIELDS = array();
     plugin_genericobject_includeCommonFields(true);
     //ToolBox::logDebug(PluginGenericobjectSingletonObjectField::$_dbfields);
     PluginGenericobjectType::includeConstants($object_type->fields['name'], true);
     self::addReadOnlyFields($object_type);
     foreach ($GO_BLACKLIST_FIELDS as $autofield) {
         if (!in_array($autofield, $used_fields)) {
             $used_fields[$autofield] = $autofield;
         }
     }
     echo "<div class='center'>";
     echo "<form name='fieldslist' method='POST' action='{$url}'>";
     echo "<table class='tab_cadre_fixe' >";
     echo "<input type='hidden' name='id' value='{$id}'>";
     echo "<tr class='tab_bg_1'><th colspan='7'>";
     echo __("Fields associated with the object", "genericobject") . " : ";
     echo $itemtype::getTypeName();
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='10'></th>";
     echo "<th>" . __("Label", "genericobject") . "</th>";
     echo "<th>" . __("Name in DB", "genericobject") . "</th>";
     echo "<th width='10'></th>";
     echo "<th width='10'></th>";
     echo "</tr>";
     $total = count($fields_in_db);
     $global_index = $index = 1;
     foreach ($fields_in_db as $field => $value) {
         self::displayFieldDefinition($url, $itemtype, $field, $index, $global_index == $total);
         //All backlisted fields cannot be moved, and are listed first
         if (!in_array($field, $GO_READONLY_FIELDS)) {
             $index++;
         }
         $table = getTableNameForForeignKeyField($field);
         $used_fields[$field] = $field;
         $global_index++;
     }
     echo "</table>";
     Html::openArrowMassives('fieldslist', true);
     Html::closeArrowMassives(array('delete' => __("Delete permanently")));
     echo "<table class='tab_cadre genericobject_fields add_new'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='label'>" . __("Add new field", "genericobject") . "</td>";
     echo "<td align='left' class='dropdown'>";
     self::dropdownFields("new_field", $itemtype, $used_fields);
     echo "</td>";
     echo "<td>";
     echo "<input type='submit' name='add_field' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Exemplo n.º 26
0
 /**
  * @param $target
  **/
 function showProcesses($target)
 {
     global $DB, $CFG_GLPI;
     $canedit = Session::haveRight("plugin_ocsinventoryng", UPDATE);
     $config = new PluginOcsinventoryngConfig();
     $config->getFromDB(1);
     $minfreq = 9999;
     //$task    = new CronTask();
     //if ($task->getFromDBbyName('PluginOcsinventoryngThread', 'CleanOldThreads')) {
     //First of all, deleted old processes
     //   $this->deleteOldProcesses($task->fields['param']);
     //   if ($task->fields['param'] > 0) {
     //      $minfreq=$task->fields['param'];
     //   }
     //}
     $imported_number = new PluginOcsinventoryngMiniStat();
     $synchronized_number = new PluginOcsinventoryngMiniStat();
     $linked_number = new PluginOcsinventoryngMiniStat();
     $failed_number = new PluginOcsinventoryngMiniStat();
     $notupdated_number = new PluginOcsinventoryngMiniStat();
     $notunique_number = new PluginOcsinventoryngMiniStat();
     $linkedrefused_number = new PluginOcsinventoryngMiniStat();
     $process_time = new PluginOcsinventoryngMiniStat();
     $sql = "SELECT `id`, `processid`, SUM(`total_number_machines`) AS total_machines,\n                     `plugin_ocsinventoryng_ocsservers_id`, `status`, COUNT(*) AS threads_number,\n                     MIN(`start_time`) AS starting_date, MAX(`end_time`) AS ending_date,\n                     TIME_TO_SEC(MAX(`end_time`)) - TIME_TO_SEC(MIN(`start_time`)) AS duree,\n                     SUM(`imported_machines_number`) AS imported_machines,\n                     SUM(`synchronized_machines_number`) AS synchronized_machines,\n                     SUM(`linked_machines_number`) AS linked_machines,\n                     SUM(`failed_rules_machines_number`) AS failed_rules_machines,\n                     SUM(`notupdated_machines_number`) AS notupdated_machines,\n                     SUM(`not_unique_machines_number`) AS not_unique_machines_number,\n                     SUM(`link_refused_machines_number`) AS link_refused_machines_number,\n                     `end_time` >= DATE_ADD(NOW(), INTERVAL - " . $minfreq . " HOUR) AS DoStat\n              FROM `" . $this->getTable() . "`\n              GROUP BY `processid`\n              ORDER BY `id` DESC\n              LIMIT 50";
     $result = $DB->query($sql);
     echo "<div class='center'>";
     echo "<form name='processes' id='processes' action='{$target}' method='post'>";
     echo "<table class='tab_cadrehov'>";
     echo "<tr><th colspan='16'>" . __('Processes execution of automatic actions', 'ocsinventoryng') . "</th></tr>";
     echo "<tr>";
     echo "<th>&nbsp;</th>";
     echo "<th>&nbsp;</th>";
     echo "<th>" . __('Status') . "</th>";
     echo "<th>" . __('Number of threads', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Beginning date of execution', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Ending date of execution', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers imported by automatic actions', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers synchronized', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers linked', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers not imported by automatic actions', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers not updated', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers not unique', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Computers refused', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Process time execution', 'ocsinventoryng') . "</th>";
     echo "<th>" . __('Server') . "</th>";
     echo "<th>&nbsp;</th>";
     echo "</th></tr>\n";
     if ($DB->numrows($result)) {
         while ($thread = $DB->fetch_array($result)) {
             if ($config->fields["is_displayempty"] || $thread["status"] != PLUGIN_OCSINVENTORYNG_STATE_FINISHED || !$config->fields["is_displayempty"] && $thread["total_machines"] > 0 && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) {
                 if ($thread["DoStat"] && $thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) {
                     $imported_number->AddValue($thread["imported_machines"]);
                     $synchronized_number->AddValue($thread["synchronized_machines"]);
                     $linked_number->AddValue($thread["linked_machines"]);
                     $failed_number->AddValue($thread["failed_rules_machines"]);
                     $notupdated_number->AddValue($thread["notupdated_machines"]);
                     $notunique_number->AddValue($thread["not_unique_machines_number"]);
                     $linkedrefused_number->AddValue($thread["link_refused_machines_number"]);
                     $process_time->AddValue($thread["duree"]);
                 } else {
                     if ($imported_number->GetCount() > 0) {
                         $this->showshowStat($minfreq, $imported_number, $synchronized_number, $linked_number, $failed_number, $notupdated_number, $notunique_number, $linkedrefused_number, $process_time);
                         $imported_number->Reset();
                     }
                 }
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='10'>";
                 if ($canedit) {
                     echo "<input type='checkbox' name='item[" . $thread["processid"] . "]' value='1'>";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 echo "<td class='center'>";
                 echo "<a href=\"./thread.form.php?pid=" . $thread["processid"] . "\">" . $thread["processid"] . "</a></td>";
                 echo "<td class='center'>";
                 $this->displayProcessStatusIcon($this->getProcessStatus($thread["processid"]));
                 echo "</td>";
                 echo "<td class='center'>" . $thread["threads_number"] . "</td>";
                 echo "<td class='center'>" . Html::convDateTime($thread["starting_date"]) . "</td>";
                 echo "<td class='center'>" . Html::convDateTime($thread["ending_date"]) . "</td>";
                 echo "<td class='center'>" . $thread["imported_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["synchronized_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["linked_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["failed_rules_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["notupdated_machines"] . "</td>";
                 echo "<td class='center'>" . $thread["not_unique_machines_number"] . "</td>";
                 echo "<td class='center'>" . $thread["link_refused_machines_number"] . "</td>";
                 echo "<td class='center'>";
                 if ($thread["status"] == PLUGIN_OCSINVENTORYNG_STATE_FINISHED) {
                     echo Html::timestampToString($thread["duree"]);
                 } else {
                     echo Dropdown::EMPTY_VALUE;
                 }
                 echo "</td>";
                 echo "<td class='center'>";
                 if ($thread["plugin_ocsinventoryng_ocsservers_id"] != -1) {
                     $ocsConfig = PluginOcsinventoryngOcsServer::getConfig($thread["plugin_ocsinventoryng_ocsservers_id"]);
                     echo "<a href=\"ocsserver.form.php?id=" . $ocsConfig["id"] . "\">" . $ocsConfig["name"] . "</a>";
                 } else {
                     _e('All servers', 'ocsinventoryng');
                 }
                 echo "</td>";
                 echo "<td class='center'>";
                 echo "<a href=\"detail.php?reset=reset_before&field[0]=" . "5&contains[0]=^" . $thread["processid"] . '$">' . "<img  src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png'</a></td>";
                 echo "</tr>\n";
             }
         }
     }
     if ($imported_number->GetCount() > 0) {
         $this->showshowStat($minfreq, $imported_number, $synchronized_number, $linked_number, $failed_number, $notupdated_number, $notunique_number, $linkedrefused_number, $process_time);
     }
     echo "</table>";
     if ($canedit) {
         Html::openArrowMassives("processes");
         Html::closeArrowMassives(array("delete_processes" => _x('button', 'Delete permanently')));
     }
     Html::closeForm();
 }
Exemplo n.º 27
0
 /**
  * Show the Device associated with an applicatif
  *
  * Called from the applicatif form
  **/
 static function showForAppliance(PluginAppliancesAppliance $appli)
 {
     global $DB, $CFG_GLPI;
     $instID = $appli->fields['id'];
     if (!$appli->can($instID, "r")) {
         return false;
     }
     $rand = mt_rand();
     $canedit = $appli->can($instID, 'w');
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_plugin_appliances_appliances_items`\n                WHERE `plugin_appliances_appliances_id` = '" . $instID . "'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     echo "<form method='post' name='appliances_form{$rand}' id='appliances_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/appliances/front/appliance.form.php\">";
     echo "<div class='center'><table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='" . ($canedit ? 6 + $colsup : 5 + $colsup) . "'>" . __('Associated items', 'appliances') . "</th></tr><tr>";
     if ($canedit) {
         echo "<th>&nbsp;</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     if ($appli->fields["relationtype"]) {
         echo "<th>" . __('Item to link', 'appliances') . "<br>" . __('User fields', 'appliances') . "</th>";
     }
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $type = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($type))) {
             continue;
         }
         if ($item->canView()) {
             $column = "name";
             if ($type == 'Ticket') {
                 $column = "id";
             }
             if ($type == 'KnowbaseItem') {
                 $column = "question";
             }
             $query = "SELECT `" . $item->getTable() . "`.*,\n                             `glpi_plugin_appliances_appliances_items`.`id` AS IDD,\n                             `glpi_entities`.`id` AS entity\n                      FROM `glpi_plugin_appliances_appliances_items`, " . getTableForItemType($type) . "\n                      LEFT JOIN `glpi_entities`\n                           ON (`glpi_entities`.`id` = `" . $item->getTable() . "`.`entities_id`)\n                      WHERE `" . $item->getTable() . "`.`id`\n                                 = `glpi_plugin_appliances_appliances_items`.`items_id`\n                            AND `glpi_plugin_appliances_appliances_items`.`itemtype` = '" . $type . "'\n                            AND `glpi_plugin_appliances_appliances_items`.`plugin_appliances_appliances_id`\n                                 = '" . $instID . "' " . getEntitiesRestrictRequest(" AND ", $item->getTable());
             if ($item->maybeTemplate()) {
                 $query .= " AND `" . $item->getTable() . "`.`is_template` = '0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `" . $item->getTable() . "`.{$column}";
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     Session::initNavigateListItems($type, _n('Appliance', 'Appliances', 2, 'appliances') . "\n                                                   = " . $appli->getNameID());
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $item->getFromDB($data["id"]);
                         Session::addToNavigateListItems($type, $data["id"]);
                         //TODO $ID never user - why this part ?
                         $ID = "";
                         if ($type == 'Ticket') {
                             $data["name"] = sprintf(__('%1$s %2$s'), __('Ticket'), $data["id"]);
                         }
                         if ($type == 'KnowbaseItem') {
                             $data["name"] = $data["question"];
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $name = $item->getLink();
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             $sel = "";
                             if (isset($_GET["select"]) && $_GET["select"] == "all") {
                                 $sel = "checked";
                             }
                             echo "<input type='checkbox' name='item[" . $data["IDD"] . "]' value='1' {$sel}>";
                             echo "</td>";
                         }
                         echo "<td class='center'>" . $item->getTypeName() . "</td>";
                         echo "<td class='center' " . (isset($data['deleted']) && $data['deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         if (Session::isMultiEntitiesMode()) {
                             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                         }
                         if ($appli->fields["relationtype"]) {
                             echo "<td class='center'>" . PluginAppliancesRelation::getTypeName($appli->fields["relationtype"]) . "&nbsp;:&nbsp;";
                             PluginAppliancesRelation::showList($appli->fields["relationtype"], $data["IDD"], $item->fields["entities_id"], false);
                             PluginAppliancesOptvalue_Item::showList($type, $data["id"], $instID, false);
                             echo "</td>";
                         }
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
         }
     }
     if ($canedit) {
         echo "<tr class='tab_bg_1'><td colspan='" . (3 + $colsup) . "' class='center'>";
         echo "<input type='hidden' name='conID' value='{$instID}'>";
         Dropdown::showAllItems("item", 0, 0, $appli->fields['is_recursive'] ? -1 : $appli->fields['entities_id'], $appli->getTypes());
         echo "</td>";
         echo "<td colspan='3' class='center' class='tab_bg_2'>";
         echo "<input type='submit' name='additem' value='" . __('Add') . "' class='submit'>";
         echo "</td></tr>";
         echo "</table></div>";
         Html::openArrowMassives("appliances_form{$rand}", true);
         Html::closeArrowMassives(array('deleteitem' => __('Delete permanently')));
     } else {
         echo "</table></div>";
     }
     Html::closeForm();
 }
Exemplo n.º 28
0
 public function showAesKey($ID)
 {
     global $DB;
     $this->h->getFromDB($ID);
     Session::initNavigateListItems("PluginAccountsAesKey", __('Hash', 'accounts') . " = " . $this->h->fields["name"]);
     $candelete = $this->h->can($ID, 'w');
     $query = "SELECT *\n      FROM `glpi_plugin_accounts_aeskeys`\n      WHERE `plugin_accounts_hashes_id` = '{$ID}' ";
     $result = $DB->query($query);
     $rand = mt_rand();
     echo "<div class='center'>";
     echo "<form method='post' name='show_aeskey{$rand}' id='show_aeskey{$rand}' action=\"./aeskey.form.php\">";
     echo "<input type='hidden' name='plugin_accounts_hashes_id' value='" . $ID . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='5'>" . __('Encryption key', 'accounts') . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th class='left'>" . __('Name') . "</th>";
     echo "</tr>";
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_array($result)) {
             Session::addToNavigateListItems("PluginAccountsAesKey", $data['id']);
             echo "<input type='hidden' name='item[" . $data["id"] . "]' value='" . $ID . "'>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td width='10'>";
             if ($candelete) {
                 echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
             }
             echo "</td>";
             $link = Toolbox::getItemTypeFormURL("PluginAccountsAesKey");
             echo "<td class='left'><a href='" . $link . "?id=" . $data["id"] . "&plugin_accounts_hashes_id=" . $ID . "'>";
             echo __('Encryption key', 'accounts') . "</a></td>";
             echo "</tr>";
         }
         echo "</table>";
         if ($candelete) {
             Html::openArrowMassives("show_aeskey{$rand}", true);
             Html::closeArrowMassives(array('delete' => __('Delete permanently')));
         }
     } else {
         echo "</table>";
     }
     Html::closeForm();
     echo "</div>";
 }
 /**
  * Display the add Definition form
  *
  * @param $typocrit_id typocrit ID
  **/
 static function showForCriteria(PluginTypologyTypologyCriteria $typocrit)
 {
     global $DB;
     $typocrit_id = $typocrit->getField('id');
     $query = "SELECT `glpi_plugin_typology_typologycriteriadefinitions`.`id`,\n                        `glpi_plugin_typology_typologycriterias`.`itemtype`,\n                        `glpi_plugin_typology_typologycriterias`.`link`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`field`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`action_type`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`value`,\n                       `glpi_plugin_typology_typologycriteriadefinitions`.`plugin_typology_typologycriterias_id`\n                FROM `glpi_plugin_typology_typologycriteriadefinitions`\n                  LEFT JOIN `glpi_plugin_typology_typologycriterias`\n                     ON (`glpi_plugin_typology_typologycriterias`.`id`\n                           = `glpi_plugin_typology_typologycriteriadefinitions`.`plugin_typology_typologycriterias_id`)\n                WHERE `plugin_typology_typologycriterias_id` = '" . $typocrit_id . "'\n                ORDER BY `glpi_plugin_typology_typologycriteriadefinitions`.`id`";
     echo "<div class='firstbloc'>";
     if ($result = $DB->query($query)) {
         echo "<form method='post' action='./typologycriteria.form.php'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='6'>" . PluginTypologyTypologyCriteriaDefinition::getTypeName(1) . "</tr>";
         echo "<input type='hidden' name='plugin_typology_typologycriterias_id' value='{$typocrit_id}'>";
         echo "<input type='hidden' name='entities_id' value='" . $typocrit->getField('entities_id') . "'>";
         echo "<input type='hidden' name='is_recursive' value='" . $typocrit->getField('is_recursive') . "'>";
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . _n('Field', 'Fields', 2) . "</td><td>";
         PluginTypologyTypologyCriteriaDefinition::dropdownFields($typocrit_id);
         echo "</td>";
         echo "<td>";
         echo "<span id='span_actions' name='span_actions'></span></td>";
         echo "<td>";
         echo "<span id='span_values' name='span_values'></span></td>";
         echo "<td class='tab_bg_2 left' width='80px'>";
         echo "<input type='submit' name='add_action' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         if ($DB->num_fields($result) > 0) {
             if (plugin_typology_haveRight('typology', 'w')) {
                 echo "<form name='critDef_form' id='critDef_form' method='post' action='./typologycriteria.form.php'>";
             }
             echo "<div class='center'><table class='tab_cadre_fixe'>";
             echo "<tr><th colspan='4'>" . PluginTypologyTypologyCriteriaDefinition::getTypeName(2) . "</th></tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<th colspan='2'>" . _n('Field', 'Fields', 2) . "</th>";
             echo "<th class='center b'>" . __('Logical operator') . "</th>";
             echo "<th class='center b'>" . __('Value') . "</th>";
             echo "</tr>";
             while ($ligne = $DB->fetch_array($result)) {
                 echo "<tr class='tab_bg_2'>";
                 if (plugin_typology_haveRight('typology', 'w')) {
                     echo "<td width='10'>";
                     echo "<input type='checkbox' name='item[" . $ligne["id"] . "]' value='1'>";
                     echo "<input type='hidden' name='plugin_typology_typologycriterias_id' value='{$typocrit_id}'>";
                     echo "</td>";
                 }
                 self::showMinimalDefinitionForm($ligne);
                 echo "</tr>";
             }
             if (plugin_typology_haveRight('typology', 'w')) {
                 Html::openArrowMassives("critDef_form", true);
                 Html::closeArrowMassives(array('delete_action' => __('Delete permanently')));
             }
             echo "</table></div>";
             if (plugin_typology_haveRight('typology', 'w')) {
                 Html::closeForm();
             }
         }
     }
 }