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()) { $PLUGIN_HOOKS['add_css']['order'][] = 'order.css'; /* 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 getSpecificFieldValue($itemtype, $searchOption, $field, &$values) { global $DB; $value = $values[$itemtype][$field]; switch ($searchOption['displaytype']) { case "reference_itemtype": unset($values[$itemtype]['itemtype']); $classes = PluginOrderOrder_Item::getClasses(); if (in_array($value, $classes)) { $value[$itemtype]['itemtype'] = $value; } else { foreach ($classes as $class) { if (call_user_func(array($class, 'getTypeName')) == $value) { $values[$itemtype]['itemtype'] = $class; break; } } } break; case "reference_model": case "reference_type": if ($searchOption['displaytype'] == 'reference_model') { $type_prefix = 'Model'; } else { $type_prefix = 'Type'; } if (isset($values[$itemtype]['itemtype']) && class_exists($values[$itemtype]['itemtype'])) { $itemtype_formodel = $values[$itemtype]['itemtype'] . $type_prefix; if (class_exists($itemtype_formodel)) { $values[$itemtype][$field] = Dropdown::getDropdownName(getTableForItemType($itemtype_formodel), $value); } } break; } return $value; }
public function dropdownAllItems($options = array()) { global $DB, $CFG_GLPI; $p['myname'] = ''; $p['value'] = ""; $p['orders_id'] = 0; $p['suppliers_id'] = 0; $p['entity'] = 0; $p['ajax_page'] = ''; $p['filter'] = ''; $p['class'] = ''; $p['span'] = ''; foreach ($options as $key => $value) { $p[$key] = $value; } $types = PluginOrderOrder_Item::getClasses(); echo "<select name='" . $p['myname'] . "' id='" . $p['myname'] . "'>"; echo "<option value='0' selected>" . Dropdown::EMPTY_VALUE . "</option>\n"; if ($p['filter']) { $used = array(); $table = $this->getTable(); $query = "SELECT `itemtype`\n FROM `{$table}` as t\n LEFT JOIN `glpi_plugin_order_references_suppliers` as s\n ON (`t`.`id` = `s`.`plugin_order_references_id`)\n WHERE `s`.`suppliers_id` = '{$p['suppliers_id']}'" . getEntitiesRestrictRequest("AND", 't', '', $p['entity'], true); $result = $DB->query($query); $number = $DB->numrows($result); if ($number) { while ($data = $DB->fetch_array($result)) { $used[] = $data["itemtype"]; } } foreach ($types as $tmp => $itemtype) { if (!in_array($itemtype, $used)) { unset($types[$tmp]); } } } foreach ($types as $type) { $item = new $type(); echo "<option value='" . $type . "' "; if (isset($p['value']) && $p['value'] == $type) { echo "selected"; } echo " >" . $item->getTypeName() . "</option>\n"; } echo "</select>"; $params = array('itemtype' => '__VALUE__', 'suppliers_id' => $p['suppliers_id'], 'entity_restrict' => $p['entity'], 'orders_id' => $p['orders_id'], 'span' => 'show_quantity'); if ($p['class'] != 'PluginOrderOrder_Item') { foreach (array("types_id", "models_id", "templates_id") as $field) { $params['field'] = $field; $params['plugin_order_references_id'] = $p['value']; Ajax::updateItemOnSelectEvent($p['myname'], "show_{$field}", $p['ajax_page'], $params); } } else { Ajax::updateItemOnSelectEvent($p['myname'], "show_reference", $p['ajax_page'], $params); } }
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if (get_class($item) == 'PluginOrderOrder') { if (!$item->fields['is_template']) { $order_item = new self(); $order_item->showItem($item->getID()); } } else { if (in_array($item->getType(), PluginOrderOrder_Item::getClasses(true))) { $order_item = new self(); $order_item->showPluginFromItems(get_class($item), $item->getField('id')); } } return true; }
function plugin_order_getAddSearchOptions($itemtype) { $plugin = new Plugin(); $sopt = array(); if ($plugin->isInstalled('order') && $plugin->isActivated('order') && Session::haveRight("plugin_order_order", READ)) { if (in_array($itemtype, PluginOrderOrder_Item::getClasses(true))) { $sopt[3160]['table'] = 'glpi_plugin_order_orders'; $sopt[3160]['field'] = 'name'; $sopt[3160]['linkfield'] = ''; $sopt[3160]['name'] = __("Order name", "order"); $sopt[3160]['forcegroupby'] = true; $sopt[3160]['datatype'] = 'itemlink'; $sopt[3160]['itemlink_type'] = 'PluginOrderOrder'; $sopt[3161]['table'] = 'glpi_plugin_order_orders'; $sopt[3161]['field'] = 'num_order'; $sopt[3161]['linkfield'] = ''; $sopt[3161]['name'] = __("Order number", "order"); $sopt[3161]['forcegroupby'] = true; $sopt[3161]['datatype'] = 'itemlink'; $sopt[3161]['itemlink_type'] = 'PluginOrderOrder'; } } return $sopt; }
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"; } } }