예제 #1
0
 public static function showForBudget($budgets_id)
 {
     global $DB, $CFG_GLPI;
     $table = getTableForItemType(__CLASS__);
     $query = "SELECT *\n                FROM `{$table}`\n                WHERE `budgets_id` = '{$budgets_id}'\n                AND `is_template`='0'\n                ORDER BY `entities_id`, `name` ";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='center'>";
     if ($nb) {
         $start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
         $query_limit = $query . " LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
         Html::printAjaxPager(__("Linked orders", "order"), $start, $nb);
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th style='width:15%;'>" . _n("Action", "Actions", 2) . "</th>";
         echo "<th>" . __("Name") . "</th>";
         echo "<th>" . __("Order status", "order") . "</th>";
         echo "<th>" . __("Entity") . "</th>";
         echo "<th>" . __("Price tax free", "order") . "</th>";
         echo "<th>" . __("Price ATI", "order") . "</th>";
         echo "</tr>";
         $total = 0;
         foreach ($DB->request($query_limit) as $data) {
             $PluginOrderOrder_Item = new PluginOrderOrder_Item();
             $prices = $PluginOrderOrder_Item->getAllPrices($data["id"]);
             $postagewithTVA = $PluginOrderOrder_Item->getPricesATI($data["port_price"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $data["plugin_order_ordertaxes_id"]));
             $total += $prices["priceTTC"] + $postagewithTVA;
             $link = Toolbox::getItemTypeFormURL(__CLASS__);
             echo "<tr class='tab_bg_1' align='center'>";
             echo "<td>";
             echo "<a href=\"" . $link . "?unlink_order=unlink_order&id=" . $data["id"] . "\">" . __("Unlink", "order") . "</a>";
             echo "</td>";
             echo "<td>";
             if (self::canView()) {
                 echo "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "</a>";
             } else {
                 echo $data["name"];
             }
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName(getTableForItemType('PluginOrderOrderState'), $data["plugin_order_orderstates_id"]);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
             echo "</td>";
             echo "<td>";
             echo Html::formatNumber($prices["priceHT"]);
             echo "</td>";
             echo "<td>";
             echo Html::formatNumber($prices["priceTTC"] + $postagewithTVA);
             echo "</td>";
             echo "</tr>";
         }
         echo "</table></div>";
         echo "<br><div class='center'>";
         echo "<table class='tab_cadre' width='15%'>";
         echo "<tr class='tab_bg_2'><td>" . __("Budget already used") . ": </td>";
         echo "<td>";
         echo Html::formatNumber($total) . "</td>";
         echo "</tr>";
         echo "</table></div>";
     } else {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><td class='center'>" . __("No item to display") . "</td></tr>";
         echo "</table>";
     }
 }