Ejemplo n.º 1
0
 function showPluginFromItems($itemtype, $ID)
 {
     global $CFG_GLPI;
     $infos = $this->getOrderInfosByItem($itemtype, $ID);
     if ($infos) {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr align='center'><th colspan='2'>" . __("Order informations", "order") . "</th></tr>";
         echo "<tr align='center'><td class='tab_bg_2'>" . __("Order name", "order") . "</td>";
         echo "<td class='tab_bg_2'>";
         $order = new PluginOrderOrder();
         $order->getFromDB($infos['id']);
         echo $order->getLink(PluginOrderOrder::canView());
         $result = getAllDatasFromTable($this->getTable(), "`plugin_order_orders_id`='" . $infos['id'] . "'\n                                           AND `itemtype`='{$itemtype}'\n                                              AND `items_id`='{$ID}'");
         if (!empty($result)) {
             $link = array_shift($result);
             $reference = new PluginOrderReference();
             $reference->getFromDB($link['plugin_order_references_id']);
             if (plugin_order_haveRight('reference', 'r')) {
                 echo "<tr align='center'><td class='tab_bg_2'>" . __("Reference") . "</td>";
                 echo "<td class='tab_bg_2'>" . $reference->getLink(PluginOrderReference::canView()) . "</td></tr>";
             }
             echo "<tr align='center'><td class='tab_bg_2'>" . __("Delivery date") . "</td>";
             echo "<td class='tab_bg_2'>" . Html::convDate($link["delivery_date"]) . "</td></tr>";
         }
         echo "</table></div>";
     }
 }
Ejemplo n.º 2
0
 static function canView()
 {
     return plugin_order_haveRight('order', 'r');
 }
 static function canView()
 {
     return plugin_order_haveRight('reference', 'r');
 }
Ejemplo n.º 4
0
 static function showForBudget($budgets_id)
 {
     global $DB, $CFG_GLPI;
     $query = "SELECT *\n               FROM `" . getTableForItemType(__CLASS__) . "`\n               WHERE `budgets_id` = '" . $budgets_id . "' AND `is_template`='0'\n               ORDER BY `entities_id`, `name` ";
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='center'>";
     if ($nb) {
         if (isset($_REQUEST["start"])) {
             $start = $_REQUEST["start"];
         } else {
             $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>" . __("Entity") . "</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 (plugin_order_haveRight('order', 'r')) {
                 echo "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "</a>";
             } else {
                 echo $data["name"];
             }
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
             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>";
     }
 }
Ejemplo n.º 5
0
function plugin_order_AssignToTicket($types)
{
    if (plugin_order_haveRight("open_ticket", "1")) {
        $types['PluginOrderOrder'] = __("Order", "order");
    }
    return $types;
}
Ejemplo n.º 6
0
function plugin_init_order()
{
    global $PLUGIN_HOOKS, $CFG_GLPI, $ORDER_TYPES;
    Plugin::registerClass('PluginOrderProfile');
    $PLUGIN_HOOKS['csrf_compliant']['order'] = true;
    /* load changeprofile function */
    $PLUGIN_HOOKS['change_profile']['order'] = array('PluginOrderProfile', 'changeProfile');
    $plugin = new Plugin();
    if ($plugin->isInstalled('order')) {
        $PLUGIN_HOOKS['migratetypes']['order'] = 'plugin_order_migratetypes';
    }
    if ($plugin->isInstalled('order') && $plugin->isActivated('order')) {
        $PLUGIN_HOOKS['assign_to_ticket']['order'] = true;
        //Itemtypes in use for an order
        $ORDER_TYPES = array('Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Printer', 'Phone', 'ConsumableItem', 'CartridgeItem', 'Contract', 'PluginOrderOther', 'SoftwareLicense');
        $PLUGIN_HOOKS['pre_item_purge']['order'] = array('Profile' => array('PluginOrderProfile', 'purgeProfiles'));
        $PLUGIN_HOOKS['pre_item_update']['order'] = array('Infocom' => array('PluginOrderOrder_Item', 'updateItem'), 'Contract' => array('PluginOrderOrder_Item', 'updateItem'));
        $PLUGIN_HOOKS['item_add']['order'] = array('Document' => array('PluginOrderOrder', 'addDocumentCategory'));
        include_once GLPI_ROOT . "/plugins/order/inc/order_item.class.php";
        foreach (PluginOrderOrder_Item::getClasses(true) as $type) {
            $PLUGIN_HOOKS['item_purge']['order'][$type] = 'plugin_item_purge_order';
        }
        Plugin::registerClass('PluginOrderOrder', array('document_types' => true, 'unicity_types' => true, 'notificationtemplates_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'contract_types' => true, 'linkuser_types' => true, 'addtabon' => array('Budget')));
        Plugin::registerClass('PluginOrderReference', array('document_types' => true));
        Plugin::registerClass('PluginOrderOrder_Item', array('notificationtemplates_types' => true, 'addtabon' => PluginOrderOrder_Item::getClasses(true)));
        Plugin::registerClass('PluginOrderProfile', array('addtabon' => array('Profile')));
        if (plugin_order_haveRight('order', 'r')) {
            Plugin::registerClass('PluginOrderOrder_Supplier', array('addtabon' => array('Supplier')));
            Plugin::registerClass('PluginOrderPreference', array('addtabon' => array('Preference')));
        }
        /*if glpi is loaded */
        if (Session::getLoginUserID()) {
            /* link to the config page in plugins menu */
            if (Session::haveRight("config", "w")) {
                $PLUGIN_HOOKS['config_page']['order'] = 'front/config.form.php';
            }
            if (plugin_order_haveRight("order", "r") || plugin_order_haveRight("reference", "r") || plugin_order_haveRight("bill", "r")) {
                $PLUGIN_HOOKS['menu_entry']['order'] = 'front/menu.php';
                // Manage redirects
                $PLUGIN_HOOKS['redirect_page']['order']['order'] = "front/order.form.php";
                $PLUGIN_HOOKS['redirect_page']['order']['reference'] = "front/reference.form.php";
                $PLUGIN_HOOKS['redirect_page']['order']['reception'] = "front/reception.form.php";
                //menu
                if (plugin_order_haveRight("order", "r")) {
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['menu']['title'] = __("Menu", "order");
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['menu']['page'] = '/plugins/order/front/menu.php';
                }
                //order
                if (plugin_order_haveRight("order", "r")) {
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['order']['title'] = __("Orders", "order");
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['order']['page'] = '/plugins/order/front/order.php';
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['order']['links']['search'] = '/plugins/order/front/order.php';
                }
                //references
                if (plugin_order_haveRight("reference", "r")) {
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['reference']['title'] = __("References", "order");
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['reference']['page'] = '/plugins/order/front/reference.php';
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['reference']['links']['search'] = '/plugins/order/front/reference.php';
                }
                //bill
                if (plugin_order_haveRight("bill", "r")) {
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['PluginOrderBill']['title'] = __("Bill", "order");
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['PluginOrderBill']['page'] = '/plugins/order/front/bill.php';
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['PluginOrderBill']['links']['search'] = '/plugins/order/front/bill.php';
                }
            }
            if (plugin_order_haveRight("order", "w")) {
                //order
                $PLUGIN_HOOKS['submenu_entry']['order']['options']['order']['links']['template'] = '/front/setup.templates.php?itemtype=PluginOrderOrder&add=0';
                $PLUGIN_HOOKS['submenu_entry']['order']['options']['order']['links']['add'] = '/front/setup.templates.php?itemtype=PluginOrderOrder&add=1';
                if (Session::haveRight('config', 'w')) {
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['order']['links']['config'] = '/plugins/order/front/config.form.php';
                }
            }
            if (plugin_order_haveRight("bill", "w")) {
                //order
                $PLUGIN_HOOKS['submenu_entry']['order']['options']['PluginOrderBill']['links']['add'] = '/plugins/order/front/bill.form.php';
            }
            if (plugin_order_haveRight("reference", "w")) {
                //references
                $PLUGIN_HOOKS['submenu_entry']['order']['options']['reference']['links']['add'] = '/plugins/order/front/reference.form.php';
                if (Session::haveRight('config', 'w')) {
                    $PLUGIN_HOOKS['submenu_entry']['order']['options']['reference']['links']['config'] = '/plugins/order/front/config.form.php';
                }
            }
            if (Session::haveRight("config", "w")) {
                $PLUGIN_HOOKS['submenu_entry']['order']['options']['config']['title'] = __("Setup");
                $PLUGIN_HOOKS['submenu_entry']['order']['options']['config']['page'] = '/plugins/order/front/config.form.php';
                if (Session::haveRight('config', 'w')) {
                    $PLUGIN_HOOKS['submenu_entry']['order']['config'] = 'front/config.form.php';
                }
            }
            $PLUGIN_HOOKS['use_massive_action']['order'] = 1;
            $PLUGIN_HOOKS['plugin_datainjection_populate']['order'] = "plugin_datainjection_populate_order";
        }
    }
}
Ejemplo n.º 7
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->getType() == 'PluginOrderOrder') {
         if (plugin_order_haveRight('delivery', 'r') && $item->getState() > PluginOrderOrderState::DRAFT) {
             return self::createTabEntry(__("Item delivered", "order"), self::countForOrder($item));
         }
     }
 }