getTypeName() static public method

static public getTypeName ( $nb )
Exemplo n.º 1
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         $nb = 0;
         switch ($item->getType()) {
             case 'Supplier':
                 if (Contract::canView()) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         $nb = self::countForSupplier($item);
                     }
                     return self::createTabEntry(Contract::getTypeName(Session::getPluralNumber()), $nb);
                 }
                 break;
             case 'Contract':
                 if (Session::haveRight("contact_enterprise", READ)) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         $nb = self::countForContract($item);
                     }
                     return self::createTabEntry(Supplier::getTypeName(Session::getPluralNumber()), $nb);
                 }
                 break;
         }
     }
     return '';
 }
Exemplo n.º 2
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         switch ($item->getType()) {
             case 'Supplier':
                 if (Session::haveRight("contract", "r")) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         return self::createTabEntry(Contract::getTypeName(2), self::countForSupplier($item));
                     }
                     return Contract::getTypeName(2);
                 }
                 break;
             case 'Contract':
                 if (Session::haveRight("contact_enterprise", "r")) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         return self::createTabEntry(Supplier::getTypeName(2), self::countForContract($item));
                     }
                     return Supplier::getTypeName(2);
                 }
                 break;
         }
     }
     return '';
 }
Exemplo n.º 3
0
 /**
  * Print the contract costs
  *
  * @param $contract               Contract object
  * @param $withtemplate  boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForContract(Contract $contract, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $contract->fields['id'];
     if (!$contract->getFromDB($ID) || !$contract->can($ID, READ)) {
         return false;
     }
     $canedit = $contract->can($ID, UPDATE);
     echo "<div class='center'>";
     $query = "SELECT *\n                FROM `glpi_contractcosts`\n                WHERE `contracts_id` = '{$ID}'\n                ORDER BY `begin_date`";
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function viewAddCost" . $ID . "_{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $ID, 'id' => -1);
         Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "};";
         echo "</script>\n";
         echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>";
         echo __('Add a new cost') . "</a></div>\n";
     }
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th colspan='5'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>";
         if ($DB->numrows($result)) {
             echo "<tr><th>" . __('Name') . "</th>";
             echo "<th>" . __('Begin date') . "</th>";
             echo "<th>" . __('End date') . "</th>";
             echo "<th>" . __('Budget') . "</th>";
             echo "<th>" . __('Cost') . "</th>";
             echo "</tr>";
             Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Contract::getTypeName(1), $contract->getName()));
             $total = 0;
             while ($data = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data['contracts_id'] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">";
                 $name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name'];
                 echo "<td>";
                 printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false)));
                 if ($canedit) {
                     echo "\n<script type='text/javascript' >\n";
                     echo "function viewEditCost" . $data['contracts_id'] . "_" . $data["id"] . "_{$rand}() {\n";
                     $params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $data["contracts_id"], 'id' => $data["id"]);
                     Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                     echo "};";
                     echo "</script>\n";
                 }
                 echo "</td>";
                 echo "<td>" . Html::convDate($data['begin_date']) . "</td>";
                 echo "<td>" . Html::convDate($data['end_date']) . "</td>";
                 echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>";
                 echo "<td class='numeric'>" . Html::formatNumber($data['cost']) . "</td>";
                 $total += $data['cost'];
                 echo "</tr>";
                 Session::addToNavigateListItems(__CLASS__, $data['id']);
             }
             echo "<tr class='b noHover'><td colspan='3'>&nbsp;</td>";
             echo "<td class='right'>" . __('Total cost') . '</td>';
             echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>';
         } else {
             echo "<tr><th colspan='5'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
     }
     echo "</div><br>";
 }
Exemplo n.º 4
0
        $contract->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $contract->check($_POST['id'], 'd');
            if ($contract->restore($_POST)) {
                Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            }
            $contract->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $contract->check($_POST['id'], 'd');
                if ($contract->delete($_POST, 1)) {
                    Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                }
                $contract->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $contract->check($_POST['id'], 'w');
                    if ($contract->update($_POST)) {
                        Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    }
                    Html::back();
                } else {
                    Html::header(Contract::getTypeName(2), $_SERVER['PHP_SELF'], "financial", "contract");
                    $contract->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"]));
                    Html::footer();
                }
            }
        }
    }
}
Exemplo n.º 5
0
 /**
  * @see CommonGLPI::getTabNameForItem()
  **/
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     global $CFG_GLPI;
     // Can exists on template
     if (Contract::canView()) {
         switch ($item->getType()) {
             case 'Contract':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     return self::createTabEntry(_n('Item', 'Items', Session::getPluralNumber()), self::countForContract($item));
                 }
                 return _n('Item', 'Items', Session::getPluralNumber());
             default:
                 if ($_SESSION['glpishow_count_on_tabs'] && in_array($item->getType(), $CFG_GLPI["contract_types"])) {
                     return self::createTabEntry(Contract::getTypeName(Session::getPluralNumber()), self::countForItem($item));
                 }
                 return _n('Contract', 'Contracts', Session::getPluralNumber());
         }
     }
     return '';
 }
Exemplo n.º 6
0
        $contract->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $contract->check($_POST['id'], DELETE);
            if ($contract->restore($_POST)) {
                Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            }
            $contract->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $contract->check($_POST['id'], PURGE);
                if ($contract->delete($_POST, 1)) {
                    Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                }
                $contract->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $contract->check($_POST['id'], UPDATE);
                    if ($contract->update($_POST)) {
                        Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    }
                    Html::back();
                } else {
                    Html::header(Contract::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "contract");
                    $contract->display(array('id' => $_GET["id"], 'withtemplate' => $_GET["withtemplate"]));
                    Html::footer();
                }
            }
        }
    }
}
Exemplo n.º 7
0
 function dropdownTaskItems($ID, $name, $used = array())
 {
     global $DB, $CFG_GLPI;
     $restrict = "`plugin_projet_projets_id` = '{$ID}'";
     $items = getAllDatasFromTable("glpi_plugin_projet_projets_items", $restrict);
     $restrictdoc = "`items_id` = '{$ID}' AND `itemtype` = 'PluginProjetProjet'";
     $docs = getAllDatasFromTable("glpi_documents_items", $restrictdoc);
     $restrictcontract = "`items_id` = '{$ID}' AND `itemtype` = 'PluginProjetProjet'";
     $contracts = getAllDatasFromTable("glpi_contracts_items", $restrictcontract);
     echo "<select name='{$name}'>";
     echo "<option value='0' selected>" . Dropdown::EMPTY_VALUE . "</option>";
     if (!empty($items)) {
         foreach ($items as $item) {
             $table = getTableForItemType($item["itemtype"]);
             $query = "SELECT `" . $table . "`.*\n                     FROM `glpi_plugin_projet_projets_items`\n                     INNER JOIN `" . $table . "` ON (`" . $table . "`.`id` = `glpi_plugin_projet_projets_items`.`items_id`)\n                     WHERE `glpi_plugin_projet_projets_items`.`itemtype` = '" . $item["itemtype"] . "'\n                     AND `glpi_plugin_projet_projets_items`.`items_id` = '" . $item["items_id"] . "' ";
             if (count($used)) {
                 $query .= " AND `" . $table . "`.`id` NOT IN (0";
                 foreach ($used as $ID) {
                     $query .= ",{$ID}";
                 }
                 $query .= ")";
             }
             $query .= " GROUP BY `" . $table . "`.`name`";
             $query .= " ORDER BY `" . $table . "`.`name`";
             $result_linked = $DB->query($query);
             if ($DB->numrows($result_linked)) {
                 while ($data = $DB->fetch_assoc($result_linked)) {
                     $name = $data["name"];
                     $itemclass = new $item["itemtype"]();
                     if ($item["itemtype"] == 'User') {
                         $name = getUserName($data["id"]);
                     }
                     echo "<option value='" . $data["id"] . "," . $item["itemtype"] . "'>" . $itemclass->getTypeName() . " - " . $name;
                     if (empty($data["name"]) || $_SESSION["glpiis_ids_visible"] == 1) {
                         echo " (";
                         echo $data["id"] . ")";
                     }
                     echo "</option>";
                 }
             }
         }
     }
     if (!empty($docs)) {
         foreach ($docs as $doc) {
             $docclass = new Document();
             if ($docclass->getFromDB($doc["documents_id"])) {
                 $name = $docclass->fields["name"];
                 echo "<option value='" . $doc["documents_id"] . ",Document'>" . $docclass->getTypeName() . " - " . $name;
                 if (empty($name) || $_SESSION["glpiis_ids_visible"] == 1) {
                     echo " (";
                     echo $doc["documents_id"] . ")";
                 }
                 echo "</option>";
             }
         }
     }
     if (!empty($contracts)) {
         foreach ($contracts as $contract) {
             $contractclass = new Contract();
             if ($contractclass->getFromDB($contract["contracts_id"])) {
                 $name = $contractclass->fields["name"];
                 echo "<option value='" . $contract["contracts_id"] . ",Contract'>" . $contractclass->getTypeName() . " - " . $name;
                 if (empty($name) || $_SESSION["glpiis_ids_visible"] == 1) {
                     echo " (";
                     echo $contract["contracts_id"] . ")";
                 }
                 echo "</option>";
             }
         }
     }
     echo "</select>";
 }