static function getMenuContent() { global $CFG_GLPI; $menu = array(); $menu['title'] = self::getTypeName(2); $menu['page'] = self::getSearchURL(false); if (PluginOrderConfig::canView()) { $menu['links']['config'] = PluginOrderConfig::getFormURL(false); } if (PluginOrderOrder::canView()) { $menu['options']['order']['title'] = PluginOrderOrder::getTypeName(2); $menu['options']['order']['page'] = PluginOrderOrder::getSearchURL(false); $menu['options']['order']['links']['add'] = "/front/setup.templates.php?itemtype=PluginOrderOrder&add=1"; if (PluginOrderOrder::canCreate()) { $menu['options']['order']['links']['search'] = PluginOrderOrder::getSearchURL(false); } $menu['options']['order']['links']['template'] = "/front/setup.templates.php?itemtype=PluginOrderOrder&add=0"; if (PluginOrderConfig::canView()) { $menu['options']['order']['links']['config'] = PluginOrderConfig::getFormURL(false); } } $menu['options']['bill']['title'] = PluginOrderBill::getTypeName(2); $menu['options']['bill']['page'] = PluginOrderBill::getSearchURL(false); $menu['options']['bill']['links']['search'] = PluginOrderBill::getSearchURL(false); $menu['options']['bill']['links']['add'] = PluginOrderBill::getFormURL(false); $menu['options']['bill']['links']['config'] = PluginOrderConfig::getFormURL(false); $menu['options']['references']['title'] = PluginOrderReference::getTypeName(2); $menu['options']['references']['page'] = PluginOrderReference::getSearchURL(false); $menu['options']['references']['links']['search'] = PluginOrderReference::getSearchURL(false); $menu['options']['references']['links']['add'] = PluginOrderReference::getFormURL(false); $menu['options']['references']['links']['config'] = PluginOrderConfig::getFormURL(false); return $menu; }
function plugin_init_order() { global $PLUGIN_HOOKS, $CFG_GLPI, $ORDER_TYPES; Plugin::registerClass('PluginOrderProfile'); $PLUGIN_HOOKS['csrf_compliant']['order'] = true; /* Init current profile */ $PLUGIN_HOOKS['change_profile']['order'] = array('PluginOrderProfile', 'initProfile'); $plugin = new Plugin(); if ($plugin->isActivated('order')) { $PLUGIN_HOOKS['migratetypes']['order'] = 'plugin_order_migratetypes'; $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'), 'DocumentCategory' => array('PluginOrderDocumentCategory', 'purgeItem')); $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('PluginOrderProfile', array('addtabon' => array('Profile'))); Plugin::registerClass('PluginOrderOrder_Item', array('notificationtemplates_types' => true, 'addtabon' => PluginOrderOrder_Item::getClasses(true))); if (PluginOrderOrder::canView()) { Plugin::registerClass('PluginOrderDocumentCategory', array('addtabon' => array('DocumentCategory'))); 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", UPDATE)) { $PLUGIN_HOOKS['config_page']['order'] = 'front/config.form.php'; } if (PluginOrderOrder::canView() || PluginOrderReference::canView() || PluginOrderBill::canView()) { $PLUGIN_HOOKS['menu_toadd']['order']['management'] = 'PluginOrderMenu'; } $PLUGIN_HOOKS['assign_to_ticket']['order'] = true; $PLUGIN_HOOKS['use_massive_action']['order'] = 1; $PLUGIN_HOOKS['plugin_datainjection_populate']['order'] = "plugin_datainjection_populate_order"; } } }
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item->getType() == 'PluginOrderOrder') { if (Session::haveRight('plugin_order_order', PluginOrderOrder::canView()) && $item->getState() > PluginOrderOrderState::DRAFT) { return self::createTabEntry(__("Item delivered", "order"), self::countForOrder($item)); } } }
if (isset($_POST['id'])) { $id = $_POST['id']; } else { $id = $_GET['id']; } $pluginOrderOrder->check($id, 'w'); $pluginOrderOrder->delete(array('id' => $id), 1); $pluginOrderOrder->redirectToList(); } else { if (isset($_POST["update"])) { $pluginOrderOrder->check($_POST['id'], 'w'); $pluginOrderOrder->update($_POST); Html::redirect($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["validate"])) { if (PluginOrderOrder::canView() && (PluginOrderOrder::canValidate() || !$config->useValidation())) { $pluginOrderOrder->updateOrderStatus($_POST["id"], $config->getApprovedState(), $_POST["comment"]); PluginOrderReception::updateDelivryStatus($_POST["id"]); Session::addMessageAfterRedirect(__("Order is validated", "order")); } Html::redirect($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["waiting_for_approval"])) { if (pluginOrderOrder::canCreate()) { $pluginOrderOrder->updateOrderStatus($_POST["id"], $config->getWaitingForApprovalState(), $_POST["comment"]); Session::addMessageAfterRedirect(__("Order validation successfully requested", "order")); } Html::redirect($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["cancel_waiting_for_approval"])) { if (pluginOrderOrder::canView() && pluginOrderOrder::canCancel()) {
public function showOrders($ref) { global $DB; $order = new PluginOrderOrder(); $query = "SELECT `glpi_plugin_order_orders_items`.*\n FROM `glpi_plugin_order_orders_items`\n LEFT JOIN `glpi_plugin_order_references`\n ON (`glpi_plugin_order_references`.`id` = `glpi_plugin_order_orders_items`.`plugin_order_references_id`)\n WHERE `plugin_order_references_id` = '" . $ref->getID() . "'"; $query .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_order_references", "entities_id", $ref->fields["entities_id"], true); $query .= " GROUP BY `glpi_plugin_order_orders_items`.`plugin_order_orders_id`\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>" . __("Name") . "</a></th>"; echo "<th>" . __("Entity") . "</th>"; echo "</tr>"; foreach ($DB->request($query_limit) as $data) { echo "<tr class='tab_bg_1' align='center'>"; echo "<td>"; $order->getFromDB($data['plugin_order_orders_id']); echo $order->getLink(PluginOrderOrder::canView()); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName("glpi_entities", $order->fields["entities_id"]); echo "</td>"; echo "</tr>"; } echo "</table>"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td class='center'>" . __("No item to display") . "</td></tr>"; echo "</table>"; } echo "</div>"; }
public 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 (Session::haveRight('plugin_order_reference', READ)) { 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>"; } }
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Order plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI; along with Order. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- @package order @author the order plugin team @copyright Copyright (c) 2010-2015 Order plugin team @license GPLv2+ http://www.gnu.org/licenses/gpl.txt @link https://forge.indepnet.net/projects/order @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ include "../../../inc/includes.php"; Html::header(__("Orders", "order"), $_SERVER['PHP_SELF'], "management", "PluginOrderMenu", "order"); $order = new PluginOrderOrder(); if (PluginOrderOrder::canView() || Session::haveRight("config", UPDATE)) { Search::show("PluginOrderOrder"); } else { echo "<div align='center'><br><br><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt=\"warning\"><br><br>"; echo "<b>" . __("Access denied") . "</b></div>"; } Html::footer();
$PluginOrderOrder = new PluginOrderOrder(); $PluginOrderReference = new PluginOrderReference(); $PluginOrderBill = new PluginOrderBill(); //If there's only one possibility, do not display menu! if (PluginOrderOrder::canView() && !PluginOrderReference::canView() && !PluginOrderBill::canView()) { Html::redirect(Toolbox::getItemTypeSearchURL('PluginOrderOrder')); } elseif (!PluginOrderOrder::canView() && PluginOrderReference::canView() && !PluginOrderBill::canView()) { Html::redirect(Toolbox::getItemTypeSearchURL('PluginOrderReference')); } elseif (!PluginOrderOrder::canView() && !PluginOrderReference::canView() && PluginOrderBill::canView()) { Html::redirect(Toolbox::getItemTypeSearchURL('PluginOrderBill')); } if (PluginOrderOrder::canView() || PluginOrderReference::canView()) { echo "<div class='center'>"; echo "<table class='tab_cadre'>"; echo "<tr><th colspan='2'>" . __("Orders management", "order") . "</th></tr>"; if (PluginOrderOrder::canView()) { echo "<tr class='tab_bg_1' align='center'>"; echo "<td><img src='../pics/order-icon.png'></td>"; echo "<td><a href='" . Toolbox::getItemTypeSearchURL('PluginOrderOrder') . "'>" . __("Orders", "order") . "</a></td></tr>"; } if (PluginOrderReference::canView()) { echo "<tr class='tab_bg_1' align='center'>"; echo "<td><img src='../pics/reference-icon.png'></td>"; echo "<td><a href='" . Toolbox::getItemTypeSearchURL('PluginOrderReference') . "'>" . __("Products references", "order") . "</a></td></tr>"; } if (PluginOrderBill::canView()) { echo "<tr class='tab_bg_1' align='center'>"; echo "<td><img src='../pics/bill-icon.png'></td>"; echo "<td><a href='" . Toolbox::getItemTypeSearchURL('PluginOrderBill') . "'>" . __("Bills", "order") . "</a></td></tr>"; } echo "</table></div>";