Beispiel #1
0
 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;
 }
Beispiel #2
0
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";
        }
    }
}
Beispiel #3
0
 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";
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
Session::checkCentralAccess();
$params = array('itemtype' => $_POST['itemtype'], 'orders_id' => $_POST['orders_id'], 'suppliers_id' => $_POST['suppliers_id'], 'entity' => $_POST['entity_restrict'], 'span' => $_POST['span'], 'action' => $CFG_GLPI["root_doc"] . "/plugins/order/ajax/detail.php", 'condition' => '');
$ref = new PluginOrderReference();
$ref->dropdownReferencesByEnterprise("PluginOrderReference", $params);
Beispiel #4
0
 public function transfer($ID, $entity)
 {
     global $DB;
     $supplier = new PluginOrderOrder_Supplier();
     $reference = new PluginOrderReference();
     $this->getFromDB($ID);
     $input["id"] = $ID;
     $input["entities_id"] = $entity;
     $this->update($input);
     if ($supplier->getFromDBByOrder($ID)) {
         $input["id"] = $supplier->fields["id"];
         $input["entities_id"] = $entity;
         $supplier->update($input);
     }
     $query = "SELECT `plugin_order_references_id`\n                FROM `glpi_plugin_order_orders_items`\n                WHERE `plugin_order_orders_id` = '{$ID}'\n                GROUP BY plugin_order_references_id";
     $result = $DB->query($query);
     $num = $DB->numrows($result);
     if ($num) {
         while ($detail = $DB->fetch_array($result)) {
             $ref = $reference->transfer($detail["plugin_order_references_id"], $entity);
         }
     }
 }
Beispiel #5
0
 public function showOrderReception($orders_id)
 {
     global $DB, $CFG_GLPI;
     $order_order = new PluginOrderOrder();
     $order_item = new PluginOrderOrder_Item();
     $reference = new PluginOrderReference();
     $order_order->getFromDB($orders_id);
     Session::initNavigateListItems($this->getType(), __("Order", "order") . " = " . $order_order->fields["name"]);
     $canedit = self::canCreate() && !$order_order->canUpdateOrder() && !$order_order->isCanceled();
     $result_ref = $order_item->queryDetail($orders_id);
     $numref = $DB->numrows($result_ref);
     while ($data_ref = $DB->fetch_array($result_ref)) {
         echo "<div class='center'><table class='tab_cadre_fixe'>";
         if (!$numref) {
             echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>";
         } else {
             $references_id = $data_ref["id"];
             $typeRef = $data_ref["itemtype"];
             $price_taxfree = $data_ref["price_taxfree"];
             $discount = $data_ref["discount"];
             $item = new $typeRef();
             $rand = mt_rand();
             echo "<tr><th><ul><li>";
             echo "<a href=\"javascript:showHideDiv('reception{$rand}','reception_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">";
             echo "<img alt='' name='reception_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">";
             echo "</a>";
             echo "</li></ul></th>";
             echo "<th>" . __("Type") . "</th>";
             echo "<th>" . __("Manufacturer") . "</th>";
             echo "<th>" . __("Product reference", "order") . "</th>";
             echo "<th>" . __("Delivered items", "order") . "</th>";
             echo "</tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td></td>";
             echo "<td align='center'>" . $item->getTypeName() . "</td>";
             echo "<td align='center'>" . Dropdown::getDropdownName("glpi_manufacturers", $data_ref["manufacturers_id"]) . "</td>";
             echo "<td>" . $reference->getReceptionReferenceLink($data_ref) . "</td>";
             $total = $order_item->getTotalQuantityByRefAndDiscount($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]);
             echo "<td>" . $order_item->getDeliveredQuantity($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]) . " / " . $total . "</td>";
             echo "</tr></table>";
             echo "<div class='center' id='reception{$rand}' style='display:none'>";
             echo "<form method='post' name='order_reception_form{$rand}' id='order_reception_form{$rand}'" . " action=\"" . Toolbox::getItemTypeFormURL("PluginOrderReception") . "\">";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             echo "<th width='15'></th>";
             if ($typeRef != 'SoftwareLicense') {
                 echo "<th>" . __("ID") . "</th>";
             }
             echo "<th>" . __("Reference") . "</th>";
             echo "<th>" . __("Status") . "</th>";
             echo "<th>" . __("Delivery date") . "</th>";
             echo "<th>" . __("Delivery form") . "</th>";
             echo "<th>" . __("Delivery status", "order") . "</th>";
             echo "</tr>";
             $query = "SELECT `glpi_plugin_order_orders_items`.`id` AS IDD,\n                             `glpi_plugin_order_references`.`id` AS id,\n                             `glpi_plugin_order_references`.`templates_id`,\n                             `glpi_plugin_order_orders_items`.`states_id`,\n                             `glpi_plugin_order_orders_items`.`comment`,\n                             `glpi_plugin_order_orders_items`.`plugin_order_deliverystates_id`,\n                             `glpi_plugin_order_orders_items`.`delivery_date`,\n                             `glpi_plugin_order_orders_items`.`delivery_number`,\n                             `glpi_plugin_order_references`.`name`,\n                             `glpi_plugin_order_references`.`itemtype`,\n                             `glpi_plugin_order_orders_items`.`items_id`\n                    FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references`\n                    WHERE `plugin_order_orders_id` = '{$orders_id}'\n                    AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = '" . $references_id . "'\n                    AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n                    AND `glpi_plugin_order_orders_items`.`discount` LIKE '" . $discount . "'\n                    AND `glpi_plugin_order_orders_items`.`price_taxfree` LIKE '" . $price_taxfree . "' ";
             if ($typeRef == 'SoftwareLicense') {
                 $query .= " GROUP BY `glpi_plugin_order_references`.`name` ";
             }
             $query .= " ORDER BY `glpi_plugin_order_references`.`name` ";
             $result = $DB->query($query);
             $num = $DB->numrows($result);
             while ($data = $DB->fetch_array($result)) {
                 $random = mt_rand();
                 $detailID = $data["IDD"];
                 Session::addToNavigateListItems($this->getType(), $detailID);
                 echo "<tr class='tab_bg_2'>";
                 $status = 1;
                 if ($typeRef != 'SoftwareLicense') {
                     $status = $this->checkThisItemStatus($detailID, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED);
                 }
                 if ($order_order->canDeliver() && $status) {
                     echo "<td width='15' align='left'>";
                     $sel = "";
                     if (isset($_GET["select"]) && $_GET["select"] == "all") {
                         $sel = "checked";
                     }
                     echo "<input type='checkbox' name='item[" . $detailID . "]' value='1' {$sel}>";
                     echo "</td>";
                 } else {
                     echo "<td width='15' align='left'></td>";
                 }
                 if ($typeRef != 'SoftwareLicense') {
                     echo "<td align='center'>" . $data["IDD"] . "&nbsp;";
                     Html::showTooltip($data['comment']);
                     echo "</td>";
                 }
                 echo "<td align='center'>" . $reference->getReceptionReferenceLink($data) . "</td>";
                 echo "<td align='center'>";
                 $link = Toolbox::getItemTypeFormURL($this->getType());
                 if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) {
                     echo "<a href=\"" . $link . "?id=" . $data["IDD"] . "\">";
                 }
                 echo $this->getReceptionStatus($detailID);
                 if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) {
                     echo "</a>";
                 }
                 echo "</td>";
                 echo "<td align='center'>" . Html::convDate($data["delivery_date"]) . "</td>";
                 echo "<td align='center'>" . $data["delivery_number"] . "</td>";
                 echo "<td align='center'>" . Dropdown::getDropdownName("glpi_plugin_order_deliverystates", $data["plugin_order_deliverystates_id"]) . "</td>";
                 echo "<input type='hidden' name='id[{$detailID}]' value='{$detailID}'>";
                 echo "<input type='hidden' name='name[{$detailID}]' value='" . $data["name"] . "'>";
                 echo "<input type='hidden' name='plugin_order_references_id[{$detailID}]' value='" . $data["id"] . "'>";
                 echo "<input type='hidden' name='itemtype[{$detailID}]' value='" . $data["itemtype"] . "'>";
                 echo "<input type='hidden' name='templates_id[{$detailID}]' value='" . $data["templates_id"] . "'>";
                 echo "<input type='hidden' name='states_id[{$detailID}]' value='" . $data["states_id"] . "'>";
             }
             echo "</table>";
             if ($order_order->canDeliver() && $this->checkItemStatus($orders_id, $references_id, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED)) {
                 Html::openArrowMassives("order_reception_form{$rand}", true);
                 echo "<input type='hidden' name='plugin_order_orders_id' value='{$orders_id}'>";
                 $this->dropdownReceptionActions($typeRef, $references_id, $orders_id);
                 Html::closeArrowMassives(array());
                 $rand = mt_rand();
                 if ($typeRef != 'SoftwareLicense') {
                     echo "<div id='massreception" . $orders_id . $rand . "'></div>\n";
                     echo "<script type='text/javascript' >\n";
                     echo "function viewmassreception" . $orders_id . "{$rand}(){\n";
                     $params = array('plugin_order_orders_id' => $orders_id, 'plugin_order_references_id' => $references_id);
                     Ajax::updateItemJsCode("massreception" . $orders_id . $rand, $CFG_GLPI["root_doc"] . "/plugins/order/ajax/massreception.php", $params, false);
                     echo "};";
                     echo "</script>\n";
                     echo "<p><a href='javascript:viewmassreception" . $orders_id . "{$rand}();'>";
                     echo __("Take item delivery (bulk)", "order") . "</a></p><br>\n";
                 }
             }
             Html::closeForm();
             echo "</div>";
         }
         echo "<br>";
     }
 }
Beispiel #6
0
include "../../../inc/includes.php";
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
if (isset($_POST["popup"])) {
    $_GET["popup"] = $_POST["popup"];
} else {
    $_GET["popup"] = "";
}
if (!isset($_GET["itemtype"])) {
    $_GET["itemtype"] = "";
}
$reference = new PluginOrderReference();
if (isset($_POST["add"])) {
    $reference->check(-1, UPDATE, $_POST);
    $newID = $reference->add($_POST);
    $url = Toolbox::getItemTypeFormURL('PluginOrderReference') . "?id={$newID}";
    if (isset($_GET["popup"]) && $_GET["popup"] == 1) {
        $url .= "&popup=1";
    }
    Html::redirect($url);
    /* delete order */
} elseif (isset($_POST["delete"])) {
    $reference->check($_POST['id'], UPDATE);
    $reference->delete($_POST);
    $reference->redirectToList();
    /* restore order */
} elseif (isset($_POST["restore"])) {
Beispiel #7
0
 public static function showOrdersItems(PluginOrderBill $bill)
 {
     global $DB, $CFG_GLPI;
     $reference = new PluginOrderReference();
     $order = new PluginOrderOrder();
     $order->getFromDB($bill->fields['plugin_order_orders_id']);
     //Can write orders, and order is not already paid
     $canedit = $order->can($order->getID(), UPDATE) && !$order->isPaid() && !$order->isCanceled();
     $query_ref = "SELECT `glpi_plugin_order_orders_items`.`id` AS IDD, " . "`glpi_plugin_order_orders_items`.`plugin_order_references_id` AS id, " . "`glpi_plugin_order_references`.`name`, " . "`glpi_plugin_order_references`.`itemtype`, " . "`glpi_plugin_order_references`.`manufacturers_id` " . "FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references` " . "WHERE `plugin_order_orders_id` = '" . $order->getID() . "' " . "AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id` " . "GROUP BY `glpi_plugin_order_orders_items`.`plugin_order_references_id` " . "ORDER BY `glpi_plugin_order_references`.`name`";
     $result_ref = $DB->query($query_ref);
     while ($data_ref = $DB->fetch_array($result_ref)) {
         echo "<div class='center'><table class='tab_cadre_fixe'>";
         if (!$DB->numrows($result_ref)) {
             echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>";
         } else {
             $order_item = new PluginOrderOrder_Item();
             $rand = mt_rand();
             $itemtype = $data_ref["itemtype"];
             $item = new $itemtype();
             echo "<tr><th><ul><li>";
             echo "<a href=\"javascript:showHideDiv('generation{$rand}','generation_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">";
             echo "<img alt='' name='generation_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">";
             echo "</a>";
             echo "</li></ul></th>";
             echo "<th>" . __("Type") . "</th>";
             echo "<th>" . __("Manufacturer") . "</th>";
             echo "<th>" . __("Product reference", "order") . "</th>";
             echo "</tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td></td>";
             echo "<td align='center'>" . $item->getTypeName() . "</td>";
             //Entity
             echo "<td align='center'>";
             echo Dropdown::getDropdownName('glpi_entities', $order->getEntityID());
             echo "</td>";
             echo "<td>" . $reference->getReceptionReferenceLink($data_ref) . "</td>";
             echo "</tr></table>";
             echo "<div class='center' id='generation{$rand}' style='display:none'>";
             echo "<form method='post' name='bills_form{$rand}' id='bills_form{$rand}'\n                     action='" . Toolbox::getItemTypeFormURL('PluginOrderBill') . "'>";
             echo "<input type='hidden' name='plugin_order_orders_id' value='" . $order->getID() . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<th></th>";
             echo "<th>" . __("Reference") . "</th>";
             echo "<th>" . __("Type") . "</th>";
             echo "<th>" . __("Model") . "</th>";
             echo "<th>" . __("Bill", "order") . "</th>";
             echo "<th>" . __("Bill status", "order") . "</th>";
             echo "</tr>";
             $results = $order_item->queryBills($order->getID(), $data_ref['id']);
             while ($data = $DB->fetch_array($results)) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td width='10'>";
                     $sel = "";
                     if (isset($_GET["select"]) && $_GET["select"] == "all") {
                         $sel = "checked";
                     }
                     echo "<input type='checkbox' name='item[" . $data["IDD"] . "]' value='1' {$sel}>";
                     echo "<input type='hidden' name='plugin_order_orders_id' value='" . $order->getID() . "'>";
                     echo "</td>";
                 }
                 //Reference
                 echo "<td align='center'>";
                 echo $reference->getReceptionReferenceLink($data);
                 echo "</td>";
                 //Type
                 echo "<td align='center'>";
                 if (file_exists($CFG_GLPI['root_doc'] . "/inc/" . strtolower($data["itemtype"]) . "type.class.php")) {
                     echo Dropdown::getDropdownName(getTableForItemType($data["itemtype"] . "Type"), $data["types_id"]);
                 }
                 echo "</td>";
                 //Model
                 echo "<td align='center'>";
                 if (file_exists($CFG_GLPI['root_doc'] . "/inc/" . strtolower($data["itemtype"]) . "model.class.php")) {
                     echo Dropdown::getDropdownName(getTableForItemType($data["itemtype"] . "Model"), $data["models_id"]);
                 }
                 $bill = new PluginOrderBill();
                 echo "<td align='center'>";
                 if ($data["plugin_order_bills_id"] > 0) {
                     if ($bill->can($data['plugin_order_bills_id'], READ)) {
                         echo "<a href='" . $bill->getLinkURL() . "'>" . $bill->getName(true) . "</a>";
                     } else {
                         echo $bill->getName();
                     }
                 }
                 echo "</td>";
                 echo "<td align='center'>";
                 echo Dropdown::getDropdownName(getTableForItemType('PluginOrderBillState'), $data['plugin_order_billstates_id']);
                 echo "</td>";
                 echo "</tr>";
             }
         }
         echo "</table>";
         if ($canedit) {
             echo "<div class='center'>";
             echo "<table width='950px' class='tab_glpi'>";
             echo "<tr><td><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png\" alt=''></td><td class='center'>";
             echo "<a onclick= \"if ( markCheckboxes('bills_form{$rand}') ) " . "return false;\" href='#'>" . __("Check all") . "</a></td>";
             echo "<td>/</td><td class='center'>";
             echo "<a onclick= \"if ( unMarkCheckboxes('bills_form{$rand}') ) " . "return false;\" href='#'>" . __("Uncheck all") . "</a>";
             echo "</td><td align='left' width='80%'>";
             echo "<input type='hidden' name='plugin_order_orders_id' value='" . $order->getID() . "'>";
             $order_item->dropdownBillItemsActions($order->getID());
             echo "</td>";
             echo "</table>";
             echo "</div>";
         }
         Html::closeForm();
         echo "</div>";
     }
     echo "<br>";
 }
 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
 ---------------------------------------------------------------------- */
$AJAX_INCLUDE = 1;
include "../../../inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (!isset($_GET['target'])) {
    $_GET['target'] = $CFG_GLPI['root_doc'] . "/plugins/order/front/reference.php";
}
PluginOrderReference::showSelector($_GET['target']);
Html::ajaxFooter();
Beispiel #9
0
 public function generateNewItem($params)
 {
     global $DB;
     // Retrieve plugin configuration
     $config = new PluginOrderConfig();
     $reference = new PluginOrderReference();
     foreach ($params["id"] as $tmp => $values) {
         //If itemtype cannot be generated, go to the new occurence
         if (in_array($values['itemtype'], self::getTypesThanCannotBeGenerared())) {
             continue;
         }
         $entity = $values["entities_id"];
         //------------- Template management -----------------------//
         //Look for a template in the entity
         $templateID = $reference->checkIfTemplateExistsInEntity($values["id"], $values["itemtype"], $entity);
         $item = new $values["itemtype"]();
         if ($values['itemtype']) {
             $order = new PluginOrderOrder();
         }
         $order->getFromDB($values["plugin_order_orders_id"]);
         $reference->getFromDB($params["plugin_order_references_id"]);
         if ($templateID) {
             $item->getFromDB($templateID);
             unset($item->fields["is_template"]);
             unset($item->fields["date_mod"]);
             $fields = array();
             foreach ($item->fields as $key => $value) {
                 if ($value != '' && (!isset($fields[$key]) || $fields[$key] == '' || $fields[$key] == 0)) {
                     $input[$key] = $value;
                 }
             }
             if ($config->getGeneratedAssetState()) {
                 $input["states_id"] = $config->getGeneratedAssetState();
             }
             $input["entities_id"] = $entity;
             $input["serial"] = $values["serial"];
             if ($item->fields['name']) {
                 $input["name"] = autoName($item->fields["name"], "name", $templateID, $values["itemtype"], $entity);
             } else {
                 $input["name"] = $values["name"];
             }
             if ($item->getField('otherserial') != NOT_AVAILABLE) {
                 if ($item->fields['otherserial']) {
                     $input["otherserial"] = autoName($item->fields["otherserial"], "otherserial", $templateID, $values["itemtype"], $entity);
                 } else {
                     $input["otherserial"] = $values["otherserial"];
                 }
             }
             if ($config->canAddLocation()) {
                 $input['locations_id'] = $order->fields['locations_id'];
             }
         } elseif ($values["itemtype"] == 'Contract') {
             $input["name"] = $values["name"];
             $input["entities_id"] = $entity;
             $input['contracttypes_id'] = $reference->fields['types_id'];
         } else {
             if ($config->getGeneratedAssetState()) {
                 $input["states_id"] = $config->getGeneratedAssetState();
             } else {
                 $input["states_id"] = 0;
             }
             $input["entities_id"] = $entity;
             $input["serial"] = $values["serial"];
             $input["otherserial"] = $values["otherserial"];
             $input["name"] = $values["name"];
             // Get bill data
             if ($config->canAddLocation()) {
                 $input['locations_id'] = $order->fields['locations_id'];
             }
             $input["manufacturers_id"] = $reference->fields["manufacturers_id"];
             $typefield = getForeignKeyFieldForTable(getTableForItemType($values["itemtype"] . "Type"));
             $input[$typefield] = $reference->fields["types_id"];
             $modelfield = getForeignKeyFieldForTable(getTableForItemType($values["itemtype"] . "Model"));
             $input[$modelfield] = $reference->fields["models_id"];
         }
         $input = Toolbox::addslashes_deep($input);
         $newID = $item->add($input);
         // Attach new ticket if option is on
         if (isset($params['generate_ticket'])) {
             $tkt = new TicketTemplate();
             if ($tkt->getFromDB($params['generate_ticket']['tickettemplates_id'])) {
                 $input = array();
                 $input = Ticket::getDefaultValues($entity);
                 $ttp = new TicketTemplatePredefinedField();
                 $predefined = $ttp->getPredefinedFields($params['generate_ticket']['tickettemplates_id'], true);
                 if (count($predefined)) {
                     foreach ($predefined as $predeffield => $predefvalue) {
                         $input[$predeffield] = $predefvalue;
                     }
                 }
                 $input['entities_id'] = $entity;
                 $input['_users_id_requester'] = empty($order->fields['users_id']) ? Session::getLoginUserID() : $order->fields['users_id'];
                 $input['items_id'] = $newID;
                 $input['itemtype'] = $values["itemtype"];
                 $ticket = new Ticket();
                 $ticketID = $ticket->add($input);
             }
         }
         //-------------- End template management ---------------------------------//
         $result = $this->createLinkWithItem($values["id"], $newID, $values["itemtype"], $values["plugin_order_orders_id"], $entity, $templateID, false, false);
         //Add item's history
         $new_value = __("Item generated by using order", "order") . ' : ' . $order->fields["name"];
         $order->addHistory($values["itemtype"], '', $new_value, $newID);
         //Add order's history
         $new_value = __("Item generated by using order", "order") . ' : ';
         $new_value .= $item->getTypeName() . " -> " . $item->getField("name");
         $order->addHistory('PluginOrderOrder', '', $new_value, $values["plugin_order_orders_id"]);
         //Copy order documents if needed
         self::copyDocuments($values['itemtype'], $newID, $values["plugin_order_orders_id"], $entity);
         Session::addMessageAfterRedirect(__("Item successfully selected", "order"), true);
     }
 }
Beispiel #10
0
 @package   order
 @author    the order plugin team
 @copyright Copyright (c) 2010-2011 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";
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
$reference = new PluginOrderReference();
if (isset($_POST["action"])) {
    switch ($_POST["action"]) {
        case "generation":
            echo "&nbsp;<input type='hidden' name='plugin_order_references_id' " . "  value='" . $_POST["plugin_order_references_id"] . "'>";
            echo "<input type='submit' name='generation' class='submit' " . "   value='" . __("Post") . "'>";
            break;
        case "createLink":
            echo "&nbsp;<input type='hidden' name='itemtype' value='" . $_POST["itemtype"] . "'>";
            $reference->getFromDB($_POST["plugin_order_references_id"]);
            $reference->dropdownAllItemsByType("items_id", $_POST["itemtype"], $_POST["entities_id"], $reference->fields["types_id"], $reference->fields["models_id"]);
            echo "&nbsp;<input type='submit' name='createLinkWithItem' " . "  class='submit' value='" . __("Post") . "'>";
            break;
        case "deleteLink":
            echo "&nbsp;<input type='submit' name='deleteLinkWithItem' " . "  class='submit' value='" . __("Post") . "'>";
            break;
Beispiel #11
0
 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-2011 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(PluginOrderReference::getTypeName(), '', "plugins", "order", "reference");
$reference = new PluginOrderReference();
if (PluginOrderReference::canView()) {
    Search::show("PluginOrderReference");
} 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();
 public static function showReferencesFromSupplier($ID)
 {
     global $DB, $CFG_GLPI;
     if (isset($_POST["start"])) {
         $start = $_POST["start"];
     } else {
         $start = 0;
     }
     $query = "SELECT  `gr`.`id`, `gr`.`manufacturers_id`, `gr`.`entities_id`, `gr`.`itemtype`, `gr`.`name`,\n                        `grm`.`price_taxfree`, `grm`.`reference_code`\n               FROM `glpi_plugin_order_references_suppliers` AS grm, `glpi_plugin_order_references` AS gr\n               WHERE `grm`.`suppliers_id` = '{$ID}'\n               AND `grm`.`plugin_order_references_id` = `gr`.`id`" . getEntitiesRestrictRequest(" AND ", "gr", '', '', true);
     $query_limit = $query . " LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     $result = $DB->query($query);
     $nb = $DB->numrows($result);
     echo "<div class='center'>";
     if ($nb) {
         $result = $DB->query($query_limit);
         Html::printAjaxPager(__("List references", "order"), $start, $nb);
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th>" . __("Entity") . "</th>";
         echo "<th>" . __("Manufacturer") . "</th>";
         echo "<th>" . __("Product reference", "order") . "</th>";
         echo "<th>" . __("Reference") . "</th>";
         echo "<th>" . __("Product reference", "order") . "</th>";
         echo "<th>" . __("Unit price tax free", "order") . "</th></tr>";
         while ($data = $DB->fetch_array($result)) {
             echo "<tr class='tab_bg_1' align='center'>";
             echo "<td>";
             echo Dropdown::getDropdownName("glpi_entities", $data["entities_id"]);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"]);
             echo "</td>";
             echo "<td>";
             $PluginOrderReference = new PluginOrderReference();
             echo $PluginOrderReference->getReceptionReferenceLink($data);
             echo "</td>";
             echo "<td>";
             $item = new $data["itemtype"]();
             echo $item->getTypeName();
             echo "</td>";
             echo "<td>";
             echo $data['reference_code'];
             echo "</td>";
             echo "<td>";
             echo number_format($data["price_taxfree"], 2);
             echo "</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     echo "</div>";
 }
Beispiel #13
0
function plugin_order_giveItem($type, $ID, $data, $num)
{
    global $CFG_GLPI;
    $searchopt =& Search::getOptions($type);
    $table = $searchopt[$ID]["table"];
    $field = $searchopt[$ID]["field"];
    $reference = new PluginOrderReference();
    switch ($table . '.' . $field) {
        /* display associated items with order */
        case "glpi_plugin_order_references.types_id":
            if ($data['raw']["itemtype"] == 'PluginOrderOther') {
                $file = GLPI_ROOT . "/plugins/order/inc/othertype.class.php";
            } else {
                $file = GLPI_ROOT . "/inc/" . strtolower($data['raw']["itemtype"]) . "type.class.php";
            }
            if (file_exists($file)) {
                return Dropdown::getDropdownName(getTableForItemType($data["itemtype"] . "Type"), $data['raw']["ITEM_" . $num]);
            } else {
                return " ";
            }
            break;
        case "glpi_plugin_order_references.models_id":
            if (file_exists(GLPI_ROOT . "/inc/" . strtolower($data["itemtype"]) . "model.class.php")) {
                return Dropdown::getDropdownName(getTableForItemType($data['raw']["itemtype"] . "Model"), $data['raw']["ITEM_" . $num]);
            } else {
                return " ";
            }
            break;
        case "glpi_plugin_order_references.templates_id":
            if (!$data['raw']["ITEM_" . $num]) {
                return " ";
            } else {
                return $reference->getTemplateName($data['raw']["itemtype"], $data['raw']["ITEM_" . $num]);
            }
            break;
    }
    return "";
}
 @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";
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
if (!defined('GLPI_ROOT')) {
    die("Can not acces directly to this file");
}
Session::checkCentralAccess();
$PluginOrderReference = new PluginOrderReference();
if ($_POST["itemtype"]) {
    switch ($_POST["field"]) {
        case "types_id":
            if ($_POST["itemtype"] == 'PluginOrderOther') {
                $file = 'other';
            } else {
                $file = $_POST["itemtype"];
            }
            if (file_exists(GLPI_ROOT . "/inc/" . strtolower($_POST["itemtype"]) . "type.class.php") || file_exists(GLPI_ROOT . "/plugins/order/inc/" . strtolower($file) . "type.class.php")) {
                Dropdown::show($_POST["itemtype"] . "Type", array('name' => "types_id"));
            }
            break;
        case "models_id":
            if (file_exists(GLPI_ROOT . "/inc/" . strtolower($_POST["itemtype"]) . "model.class.php")) {
                Dropdown::show($_POST["itemtype"] . "Model", array('name' => "models_id"));
Beispiel #15
0
function plugin_order_MassiveActionsProcess($data)
{
    global $DB;
    switch ($data['action']) {
        case "plugin_order_transfert":
            if ($data['itemtype'] == 'PluginOrderOrder') {
                $order = new PluginOrderOrder();
                foreach ($data["item"] as $key => $val) {
                    if ($val == 1) {
                        $order->transfer($key, $data['entities_id']);
                    }
                }
            }
            break;
        case "plugin_order_copy_reference":
            if ($data['itemtype'] == 'PluginOrderReference') {
                $reference = new PluginOrderReference();
                foreach ($data["item"] as $key => $val) {
                    if ($val == 1) {
                        $reference->copy($key);
                    }
                }
            }
            break;
        case "plugin_order_transfer_reference":
            if ($data['itemtype'] == 'PluginOrderReference') {
                $reference = new PluginOrderReference();
                foreach ($data["item"] as $key => $val) {
                    if ($val == 1) {
                        $reference->transfer($key, $data['entities_id']);
                    }
                }
            }
            break;
    }
}