Beispiel #1
0
 public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'Profile' && $item->getField('interface') != 'helpdesk') {
         return PluginTypologyTypology::getTypeName(1);
     }
     return '';
 }
 function getTags()
 {
     $tags = array('typology.name' => PluginTypologyTypology::getTypeName(1), 'typology.itemtype' => __('Type'), 'typology.items_id' => __('Name'), 'typology.error' => __('Error'), 'typology.url' => __('Link to the typology', 'typology'), 'typology.itemurl' => __('Link to the element', 'typology'), 'typology.itemuser' => __('User'), 'typology.itemlocation' => __('Location'));
     foreach ($tags as $tag => $label) {
         $this->addTagToList(array('tag' => $tag, 'label' => $label, 'value' => true));
     }
     asort($this->tag_descriptions);
 }
Beispiel #3
0
                                $values = array('plugin_typology_typologies_id' => $input['plugin_typology_typologies_id'], 'items_id' => $input['items_id'], 'itemtype' => $input['itemtype']);
                                PluginTypologyTypology_Item::addLog($values, PluginTypologyTypology_Item::LOG_UPDATE);
                            }
                            Html::back();
                        } else {
                            if (isset($_POST["delete_item"])) {
                                if (!empty($_POST['itemtype'])) {
                                    $typo_item->delete($_POST);
                                    $values = array('plugin_typology_typologies_id' => $_POST['plugin_typology_typologies_id'], 'items_id' => $_POST['items_id'], 'itemtype' => $_POST['itemtype']);
                                    PluginTypologyTypology_Item::addLog($values, PluginTypologyTypology_Item::LOG_DELETE);
                                } else {
                                    foreach ($_POST["item"] as $key => $val) {
                                        if ($val == 1) {
                                            $typo_item->delete(array('id' => $key));
                                        }
                                    }
                                }
                                Html::back();
                            } else {
                                $typo->checkGlobal("r");
                                Html::header(PluginTypologyTypology::getTypeName(2), '', "plugins", "typology");
                                $typo->showForm($_GET["id"]);
                                Html::footer();
                            }
                        }
                    }
                }
            }
        }
    }
}
Beispiel #4
0
            Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param);
        }
    }
}
if ($res && $nbtot > 0) {
    $nbCols = $DB->num_fields($res);
    $nbrows = $DB->numrows($res);
    $num = 1;
    $link = $_SERVER['PHP_SELF'];
    $order = 'ASC';
    $issort = false;
    echo Search::showHeader($output_type, $nbrows, $nbCols, true);
    echo Search::showNewLine($output_type);
    showTitle($output_type, $num, __('Entity'), 'entity', true);
    showTitle($output_type, $num, __('Service'), 'groups_id', true);
    showTitle($output_type, $num, PluginTypologyTypology::getTypeName(1), 'typoID', true);
    showTitle($output_type, $num, __('Number', 'typology'), 'COUNT', true);
    echo Search::showEndLine($output_type);
    //By service and typology
    $queryService = "SELECT count(*) AS COUNT,\n                           `glpi_plugin_typology_typologies`.`entities_id` AS entity,\n                           `glpi_computers`.`groups_id`,\n                           `glpi_plugin_typology_typologies`.`id` AS typoID\n                     FROM `glpi_plugin_typology_typologies_items`\n                     LEFT JOIN `glpi_plugin_typology_typologies`\n                        ON(`glpi_plugin_typology_typologies_items`.`plugin_typology_typologies_id`\n                            = `glpi_plugin_typology_typologies`.`id`)\n                     LEFT JOIN `glpi_computers`\n                        ON (`glpi_plugin_typology_typologies_items`.`items_id` = `glpi_computers`.`id`\n                            AND `glpi_plugin_typology_typologies_items`.`itemtype` = 'Computer')\n                     LEFT JOIN `glpi_entities`\n                        ON (`glpi_plugin_typology_typologies`.`entities_id` = `glpi_entities`.`id`)\n                     WHERE {$condition} {$sqltypo}\n                     GROUP BY `glpi_entities`.`entities_id`,\n                              `glpi_computers`.`groups_id`,\n                              `glpi_plugin_typology_typologies`.`id`" . getOrderBy('entity', $columns);
    $resultService = $DB->query($queryService);
    $row_num = 1;
    while ($dataService = $DB->fetch_assoc($resultService)) {
        if ($dataService['groups_id'] == 0) {
            $serviceName = __('None');
        } else {
            $serviceName = Dropdown::getDropdownName("glpi_groups", $dataService['groups_id']);
        }
        if ($dataService['typoID'] == '0') {
            $typoName = __('None');
        } else {
 function getActions()
 {
     $actions = array();
     $actions['plugin_typology_typologies_id']['name'] = PluginTypologyTypology::getTypeName(1);
     $actions['plugin_typology_typologies_id']['table'] = "glpi_plugin_typology_typologies";
     $actions['plugin_typology_typologies_id']['type'] = "dropdown";
     $actions['plugin_typology_typologies_id']['force_actions'] = array('assign');
     return $actions;
 }
 /**
  * Display all the linked computers of a defined typology
  *
  *@param $typoID = typo ID.
  *
  *@return Nothing (displays)
  **/
 public static function showForTypology(PluginTypologyTypology $typo)
 {
     global $DB, $CFG_GLPI;
     $typoID = $typo->fields['id'];
     if (!$typo->can($typoID, 'r')) {
         return false;
     }
     $canedit = $typo->can($typoID, 'w');
     $canview = $typo->can($typoID, 'r');
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                    FROM `glpi_plugin_typology_typologies_items`\n                    WHERE `plugin_typology_typologies_id` = '{$typoID}'\n                    ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form method='post' name='typologies_form{$rand}' id='typologies_form{$rand}' action='" . $CFG_GLPI["root_doc"] . "/plugins/typology/front/typology.form.php'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th colspan='7'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<input type='hidden' name='plugin_typology_typologies_id' value='{$typoID}'>";
         Dropdown::showAllItems("items_id", 0, 0, $typo->fields['is_recursive'] ? -1 : $typo->fields['entities_id'], PluginTypologyTypology::getTypes());
         echo "</td>";
         echo "<td colspan='3' class='center' class='tab_bg_2'>";
         echo "<input type='submit' name='add_item' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array();
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='" . ($canedit ? 7 + $colsup : 6 + $colsup) . "'>";
     if ($DB->numrows($result) == 0) {
         _e('No linked element', 'typology');
     } else {
         _e('Linked elements', 'typology');
     }
     echo "</th></tr><tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</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 "<th>" . __('Responding to typology\'s criteria', 'typology') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($canview) {
             $column = "name";
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `" . $itemtable . "`.*,\n                                `glpi_plugin_typology_typologies_items`.`id` AS IDP,\n                                `glpi_plugin_typology_typologies_items`.`is_validated`,\n                                `glpi_plugin_typology_typologies_items`.`error`,\n                                `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_typology_typologies_items`, `" . $itemtable . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemtable . "`.`entities_id`) " . " WHERE `" . $itemtable . "`.`id` = `glpi_plugin_typology_typologies_items`.`items_id`\n                              AND `glpi_plugin_typology_typologies_items`.`itemtype` = '{$itemtype}'\n                              AND `glpi_plugin_typology_typologies_items`.`plugin_typology_typologies_id` = '{$typoID}'";
             if ($itemtype != 'User') {
                 $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             }
             if ($item->maybeTemplate()) {
                 $query .= " AND " . $itemtable . ".is_template='0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `" . $itemtable . "`.`{$column}` ";
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     Session::initNavigateListItems($itemtype, PluginTypologyTypology::getTypeName(1) . " = " . $typo->fields['name']);
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $ID = "";
                         $item->getFromDB($data["id"]);
                         Session::addToNavigateListItems($itemtype, $data["id"]);
                         if ($itemtype == 'User') {
                             $format = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1);
                         } else {
                             $format = $data["name"];
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $link = Toolbox::getItemTypeFormURL($itemtype);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $format;
                         if ($itemtype != 'User') {
                             $name .= "&nbsp;" . $ID;
                         }
                         $name .= "</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             Html::showMassiveActionCheckBox(__CLASS__, $data["IDP"]);
                             echo "</td>";
                         }
                         echo "<input type='hidden' name='plugin_typology_typologies_id' value='{$typoID}'>";
                         echo "<td class='center'>" . $item->getTypeName() . "</td>";
                         echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         if (Session::isMultiEntitiesMode()) {
                             if ($itemtype != 'User') {
                                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                             } else {
                                 echo "<td class='center'>-</td>";
                             }
                         }
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         if ($data["is_validated"] > 0) {
                             $critTypOK = __('Yes');
                         } else {
                             $critTypOK = "<font color='red'>" . __('No') . " " . __('for the criteria', 'typology') . " ";
                             $i = 0;
                             $critTypOK .= self::displayErrors($data["error"]);
                             $critTypOK .= "</font>";
                         }
                         echo "<td class ='center'><b>" . $critTypOK . "</b></td>";
                         echo "</tr>";
                     }
                 }
             }
         }
     }
     echo "</table>";
     if ($canedit && $number) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
Beispiel #7
0
function plugin_typology_getAddSearchOptions($itemtype)
{
    $plugin = new Plugin();
    $sopt = array();
    if ($plugin->isActivated('typology') && plugin_typology_haveRight("typology", "r")) {
        if (in_array($itemtype, PluginTypologyTypology::getTypes(true))) {
            $sopt[4650]['table'] = 'glpi_plugin_typology_typologies';
            $sopt[4650]['field'] = 'name';
            $sopt[4650]['name'] = PluginTypologyTypology::getTypeName(1) . " - " . __('Typology\'s name', 'typology');
            $sopt[4650]['forcegroupby'] = true;
            $sopt[4650]['datatype'] = 'itemlink';
            $sopt[4650]['massiveaction'] = false;
            $sopt[4650]['itemlink_type'] = 'PluginTypologyTypology';
            $sopt[4650]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_typology_typologies_items', 'joinparams' => array('jointype' => 'itemtype_item')));
            $sopt[4651]['table'] = 'glpi_plugin_typology_typologies_items';
            $sopt[4651]['field'] = 'is_validated';
            $sopt[4651]['datatype'] = 'bool';
            $sopt[4651]['massiveaction'] = false;
            $sopt[4651]['name'] = PluginTypologyTypology::getTypeName(1) . " - " . __('Responding to typology\'s criteria', 'typology');
            $sopt[4651]['forcegroupby'] = true;
            $sopt[4651]['joinparams'] = array('jointype' => 'itemtype_item');
            $sopt[4652]['table'] = 'glpi_plugin_typology_typologies_items';
            $sopt[4652]['field'] = 'error';
            $sopt[4652]['name'] = PluginTypologyTypology::getTypeName(1) . " - " . __('Result details');
            $sopt[4652]['forcegroupby'] = true;
            $sopt[4652]['massiveaction'] = false;
            $sopt[4652]['joinparams'] = array('jointype' => 'itemtype_item');
        }
    }
    return $sopt;
}
 /**
  * Show the criteria form
  *
  * @param $ID ID of the criteria
  * @param $options options
  *
  * @return nothing
  **/
 function showForm($ID, $options = array())
 {
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     //$options['colspan']      = 4;
     $this->showTabs($options);
     $this->showFormHeader($options);
     $itemtype = $this->fields["itemtype"];
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td><td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Item') . "</td><td>";
     echo $itemtype::getTypeName(0) . "</td>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Logical operator') . "</td><td>";
     Dropdown::showFromArray('link', array(0 => __('and'), 1 => __('or')), array('value' => $this->fields["link"]));
     echo "</td>";
     echo "<td>" . __('Active') . "</td><td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     $typo = new PluginTypologyTypology();
     $typo->getFromDB($this->fields['plugin_typology_typologies_id']);
     echo "<td>" . PluginTypologyTypology::getTypeName(1) . "</td>";
     echo "<td>";
     echo $typo->getLink();
     echo "</td>";
     echo "<td>" . __('Last update') . "</td>";
     echo "<td>" . ($this->fields["date_mod"] ? Html::convDateTime($this->fields["date_mod"]) : __('Never'));
     echo "</tr>\n";
     $this->showFormButtons($options);
     $this->addDivForTabs();
 }
Beispiel #9
0
 function getSearchOptions()
 {
     $tab = array();
     $tab['common'] = PluginTypologyTypology::getTypeName(1);
     $tab[1]['table'] = $this->getTable();
     $tab[1]['field'] = 'name';
     $tab[1]['name'] = __('Name');
     $tab[1]['datatype'] = 'itemlink';
     $tab[1]['itemlink_type'] = $this->getType();
     $tab[1]['massiveaction'] = false;
     $tab[2]['table'] = $this->getTable();
     $tab[2]['field'] = 'id';
     $tab[2]['name'] = __('ID');
     $tab[2]['massiveaction'] = false;
     $tab[2]['datatype'] = 'number';
     $tab[14]['table'] = $this->getTable();
     $tab[14]['field'] = 'date_mod';
     $tab[14]['name'] = __('Last update');
     $tab[14]['massiveaction'] = false;
     $tab[14]['datatype'] = 'datetime';
     $tab[16]['table'] = $this->getTable();
     $tab[16]['field'] = 'comment';
     $tab[16]['name'] = __('Comments');
     $tab[16]['datatype'] = 'text';
     $tab[16]['massiveaction'] = true;
     $tab[80]['table'] = 'glpi_entities';
     $tab[80]['field'] = 'completename';
     $tab[80]['name'] = __('Entity');
     $tab[80]['massiveaction'] = false;
     $tab[80]['datatype'] = 'dropdown';
     $tab[86]['table'] = $this->getTable();
     $tab[86]['field'] = 'is_recursive';
     $tab[86]['name'] = __('Child entities');
     $tab[86]['datatype'] = 'bool';
     $tab[86]['massiveaction'] = true;
     return $tab;
 }