Beispiel #1
0
     } 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()) {
                         $pluginOrderOrder->updateOrderStatus($_POST["id"], $config->getDraftState(), $_POST["comment"]);
                         Session::addMessageAfterRedirect(__("Validation query is now canceled", "order"));
Beispiel #2
0
 public function showFormDetail($plugin_order_orders_id)
 {
     global $CFG_GLPI, $DB;
     $order = new PluginOrderOrder();
     $reference = new PluginOrderReference();
     $reception = new PluginOrderReception();
     $result_ref = $this->queryDetail($plugin_order_orders_id);
     $numref = $DB->numrows($result_ref);
     $rand = mt_rand();
     $canedit = $order->can($plugin_order_orders_id, UPDATE) && $order->canUpdateOrder();
     Session::initNavigateListItems($this->getType(), __("Order", "order") . " = " . $order->getName());
     while ($data_ref = $DB->fetch_array($result_ref)) {
         $global_rand = mt_rand();
         echo "<div class='center'>";
         echo "<form method='post' name='order_updatedetail_form{$rand}' " . "id='order_updatedetail_form{$rand}'  " . "action='" . Toolbox::getItemTypeFormURL('PluginOrderOrder') . "'>";
         echo "<input type='hidden' name='plugin_order_orders_id'\n                  value='" . $plugin_order_orders_id . "'>";
         echo "<input type='hidden' name='plugin_order_order_items_id'\n                  value='" . $data_ref['IDD'] . "'>";
         echo "<table class='tab_cadre_fixe'>";
         if (!$numref) {
             echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>";
         } else {
             $refID = $data_ref["id"];
             $price_taxfree = $data_ref["price_taxfree"];
             $discount = $data_ref["discount"];
             $rand = mt_rand();
             echo "<tr><th><ul><li>";
             echo "<a href=\"javascript:showHideDiv('detail{$rand}','detail_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">";
             echo "<img alt='' name='detail_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">";
             echo "</a>";
             echo "</li></ul></th>";
             echo "<th>" . __("Quantity", "order") . "</th>";
             echo "<th>" . __("Equipment", "order") . "</th>";
             echo "<th>" . __("Manufacturer") . "</th>";
             echo "<th>" . __("Reference") . "</th>";
             echo "<th>" . __("Type") . "</th>";
             echo "<th>" . __("Model") . "</th>";
             echo "<th>" . __("Unit price tax free", "order") . "</th>";
             echo "<th>" . __("Discount (%)", "order") . "</th>";
             echo "</tr>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td><div id='viewaccept{$rand}' style='display:none;'>";
             echo "<p><input type='submit' onclick=\"return confirm('" . __("Do you really want to update this item ?", "order") . "');\" name='update_item' value=\"" . _sx("button", "Update") . "\" class='submit'></p>";
             echo "<br /><p><input type='button' onclick=\"hideForm{$rand}();\" value=\"" . _sx("button", "Cancel") . "\" class='submit'></p>";
             echo "</div></td>";
             if ($canedit) {
                 echo "<script type='text/javascript' >\n";
                 echo "function hideForm{$rand}() {\n";
                 echo "\$('#quantity{$rand}').show();";
                 echo "\$('#pricetaxfree{$rand}').show();";
                 echo "\$('#discount{$rand}').show();";
                 echo "\$('#viewquantity{$rand} input').remove();";
                 echo "\$('#viewpricetaxfree{$rand} input').remove();";
                 echo "\$('#viewdiscount{$rand} input').remove();";
                 echo "\$('#viewaccept{$rand}').hide();";
                 echo "}\n";
                 echo "</script>\n";
             }
             /* quantity */
             $quantity = $this->getTotalQuantityByRefAndDiscount($plugin_order_orders_id, $refID, $price_taxfree, $discount);
             if ($canedit) {
                 echo "<td align='center'>";
                 echo "<script type='text/javascript' >\n";
                 echo "function showQuantity{$rand}() {\n";
                 echo "\$('#quantity{$rand}').hide();";
                 echo "\$('#viewaccept{$rand}').show();";
                 $params = array('maxlength' => 15, 'size' => 8, 'name' => 'quantity', 'class' => 'quantity', 'force_integer' => true, 'data' => rawurlencode($quantity));
                 Ajax::updateItemJsCode("viewquantity{$rand}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false);
                 echo "}";
                 echo "</script>\n";
                 echo "<div id='quantity{$rand}' class='center' onClick='showQuantity{$rand}()'>\n";
                 echo $quantity;
                 echo "</div>\n";
                 echo "<div id='viewquantity{$rand}'>\n";
                 echo "</div>\n";
                 echo "</td>";
             } else {
                 echo "<td align='center'>" . $quantity . "</td>";
             }
             /* type */
             $item = new $data_ref["itemtype"]();
             echo "<td align='center'>" . $item->getTypeName() . "</td>";
             /* manufacturer */
             echo "<td align='center'>" . Dropdown::getDropdownName("glpi_manufacturers", $data_ref["manufacturers_id"]) . "</td>";
             /* reference */
             echo "<td align='center'>";
             echo "<input type='hidden' name='old_plugin_order_references_id'\n                     value='" . $refID . "'>";
             echo $reference->getReceptionReferenceLink($data_ref);
             echo "</td>";
             /* type */
             echo "<td align='center'>";
             if (file_exists(GLPI_ROOT . "/inc/" . strtolower($data_ref["itemtype"]) . "type.class.php")) {
                 echo Dropdown::getDropdownName(getTableForItemType($data_ref["itemtype"] . "Type"), $data_ref["types_id"]);
             }
             echo "</td>";
             /* modele */
             echo "<td align='center'>";
             if (file_exists(GLPI_ROOT . "/inc/" . strtolower($data_ref["itemtype"]) . "model.class.php")) {
                 echo Dropdown::getDropdownName(getTableForItemType($data_ref["itemtype"] . "Model"), $data_ref["models_id"]);
             }
             echo "</td>";
             if ($canedit) {
                 echo "<td align='center'>";
                 echo "<input type='hidden' name='old_price_taxfree' value='" . $price_taxfree . "'>";
                 echo "<script type='text/javascript' >\n";
                 echo "function showPricetaxfree{$rand}() {\n";
                 echo "\$('#pricetaxfree{$rand}').hide();";
                 echo "\$('#viewaccept{$rand}').show();";
                 $params = array('maxlength' => 15, 'size' => 8, 'name' => 'price_taxfree', 'class' => 'decimal', 'data' => rawurlencode($price_taxfree));
                 Ajax::updateItemJsCode("viewpricetaxfree{$rand}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false);
                 echo "}";
                 echo "</script>\n";
                 echo "<div id='pricetaxfree{$rand}' class='center' onClick='showPricetaxfree{$rand}()'>\n";
                 echo Html::formatNumber($price_taxfree);
                 echo "</div>\n";
                 echo "<div id='viewpricetaxfree{$rand}'>\n";
                 echo "</div>\n";
                 echo "</td>";
             } else {
                 echo "<td align='center'>" . Html::formatNumber($price_taxfree) . "</td>";
             }
             /* reduction */
             if ($canedit) {
                 echo "<td align='center'>";
                 echo "<input type='hidden' name='old_discount' value='" . $discount . "'>";
                 echo "<script type='text/javascript' >\n";
                 echo "function showDiscount{$rand}() {\n";
                 echo "\$('#discount{$rand}').hide();";
                 echo "\$('#viewaccept{$rand}').show();";
                 $params = array('maxlength' => 15, 'size' => 8, 'name' => 'discount', 'class' => 'smalldecimal', 'data' => rawurlencode($discount));
                 Ajax::updateItemJsCode("viewdiscount{$rand}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false);
                 echo "}";
                 echo "</script>\n";
                 echo "<div id='discount{$rand}' class='center' onClick='showDiscount{$rand}()'>\n";
                 echo Html::formatNumber($discount);
                 echo "</div>\n";
                 echo "<div id='viewdiscount{$rand}'>\n";
                 echo "</div>\n";
                 echo "</td>";
             } else {
                 echo "<td align='center'>" . Html::formatNumber($discount) . "</td>";
             }
             echo "</tr></table>";
             Html::closeForm();
             echo "<div class='center' id='detail{$rand}' style='display:none'>";
             echo "<form method='post' name='order_detail_form{$rand}' id='order_detail_form{$rand}'  " . "action=\"" . Toolbox::getItemTypeFormURL('PluginOrderOrder') . "\">";
             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-top.png\" alt=''>";
                 echo "</td><td class='center'>";
                 echo "<a onclick= \"if ( markCheckboxes('order_detail_form{$rand}') ) return false;\" href='#'>" . __("Check all") . "</a></td>";
                 echo "<td>/</td><td class='center'>";
                 echo "<a onclick= \"if ( unMarkCheckboxes('order_detail_form{$rand}') ) " . " return false;\" href='#'>" . __("Uncheck all") . "</a>";
                 echo "</td><td align='left'>";
                 echo "<input type='submit' onclick=\"return confirm('" . __("Do you really want to delete these details ? Delivered items will not be linked to order !", "order") . "')\" name='delete_item' value=\"" . __("Delete permanently") . "\" class='submit'>";
                 echo "</td>";
                 // Edit buttons
                 echo "<td align='left' width='80%'>";
                 echo "<div id='detail_viewaccept{$global_rand}' style='display:none;'>";
                 echo "&nbsp;<input type='submit' onclick=\"return confirm('" . __("Do you really want to update this item ?", "order") . "');\" name='update_detail_item'\n                     value=\"" . _sx("button", "Update") . "\" class='submit'>&nbsp;";
                 echo "&nbsp;<input type='button' onclick=\"detail_hideForm{$global_rand}();\"\n                     value=\"" . _sx("button", "Cancel") . "\" class='submit'>";
                 echo "</div>";
                 echo "</td>";
                 echo "</table>";
                 echo "</div>";
             }
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr>";
             if ($canedit) {
                 echo "<th></th>";
             }
             if ($data_ref["itemtype"] != 'SoftwareLicense') {
                 echo "<th>" . __("ID") . "</th>";
             }
             echo "<th>" . __("Reference") . "</th>";
             echo "<th>" . __("Unit price tax free", "order") . "</th>";
             echo "<th>" . __("VAT", "order") . "</th>";
             echo "<th>" . __("Discount (%)", "order") . "</th>";
             echo "<th>" . __("Discounted price tax free", "order") . "</th>";
             echo "<th>" . __("Price ATI", "order") . "</th>";
             echo "<th>" . __("Status") . "</th></tr>";
             $query = "SELECT `" . $this->getTable() . "`.`id` AS IDD, `glpi_plugin_order_references`.`id`,\n                           `glpi_plugin_order_references`.`name`,\n                           `" . $this->getTable() . "`.`comment`,\n                           `" . $this->getTable() . "`.`price_taxfree`,\n                           `" . $this->getTable() . "`.`price_discounted`,\n                           `" . $this->getTable() . "`.`discount`,\n                           `" . $this->getTable() . "`.`plugin_order_ordertaxes_id`,\n                           `" . $this->getTable() . "`.`price_ati`\n                    FROM `" . $this->getTable() . "`, `glpi_plugin_order_references`\n                    WHERE `" . $this->getTable() . "`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n                      AND `" . $this->getTable() . "`.`plugin_order_references_id` = '" . $refID . "'\n                         AND `" . $this->getTable() . "`.`price_taxfree` LIKE '" . $price_taxfree . "'\n                            AND `" . $this->getTable() . "`.`discount` LIKE '" . $discount . "'\n                                AND `" . $this->getTable() . "`.`plugin_order_orders_id` = '{$plugin_order_orders_id}'";
             if ($data_ref["itemtype"] == '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);
             // Initialize for detail_hideForm javascript function
             $hideForm = "";
             while ($data = $DB->fetch_array($result)) {
                 $rand_line = mt_rand();
                 Session::addToNavigateListItems($this->getType(), $data['IDD']);
                 // Compute for detail_hideForm javascript function
                 $hideForm .= "\$('#detail_pricetaxfree{$rand_line}').show();\n";
                 $hideForm .= "\$('#detail_viewpricetaxfree{$rand_line} input').remove();\n";
                 $hideForm .= "\$('#detail_discount{$rand_line}').show();\n";
                 $hideForm .= "\$('#detail_viewdiscount{$rand_line} input').remove();\n";
                 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='" . $plugin_order_orders_id . "'>";
                     echo "</td>";
                 }
                 if ($data_ref["itemtype"] != 'SoftwareLicense') {
                     echo "<td align='center'><a href='" . Toolbox::getItemTypeFormURL('PluginOrderOrder_Item') . "?id=" . $data['IDD'] . "'>" . $data['IDD'] . "</a>";
                     echo "&nbsp;";
                     Html::showToolTip($data['comment']);
                 }
                 /* reference */
                 echo "<td align='center'>";
                 echo "<input type='hidden' name='detail_old_plugin_order_references_id[" . $data["IDD"] . "]'\n                           value='" . $data["id"] . "'>";
                 echo $reference->getReceptionReferenceLink($data);
                 echo "</td>";
                 if ($canedit) {
                     echo "<td align='center'>";
                     echo "<input type='hidden' name='detail_old_price_taxfree[" . $data["IDD"] . "]'\n                              value='" . $data["price_taxfree"] . "'>";
                     echo "<script type='text/javascript' >\n";
                     echo "function showDetailPricetaxfree{$rand_line}() {\n";
                     echo "\$('#detail_pricetaxfree{$rand_line}').hide();";
                     echo "\$('#detail_viewaccept{$global_rand}').show();";
                     $params = array('maxlength' => 15, 'size' => 8, 'name' => 'detail_price_taxfree[' . $data["IDD"] . ']', 'class' => 'decimal', 'data' => rawurlencode($data["price_taxfree"]));
                     Ajax::updateItemJsCode("detail_viewpricetaxfree{$rand_line}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false);
                     echo "}";
                     echo "</script>\n";
                     echo "<div id='detail_pricetaxfree{$rand_line}' class='center'\n                           onClick='showDetailPricetaxfree{$rand_line}()'>\n";
                     echo Html::formatNumber($data["price_taxfree"]);
                     echo "</div>\n";
                     echo "<div id='detail_viewpricetaxfree{$rand_line}'>\n";
                     echo "</div>\n";
                     echo "</td>";
                 } else {
                     echo "<td align='center'>" . Html::formatNumber($data["price_taxfree"]) . "</td>";
                 }
                 /* taxe */
                 echo "<td align='center'>";
                 echo Dropdown::getDropdownName(getTableForItemType("PluginOrderOrderTax"), $data["plugin_order_ordertaxes_id"]);
                 echo "</td>";
                 /* reduction */
                 if ($canedit) {
                     echo "<td align='center'>";
                     echo "<input type='hidden' name='detail_old_discount[" . $data["IDD"] . "]'\n                              value='" . $data["discount"] . "'>";
                     echo "<script type='text/javascript' >\n";
                     echo "function showDetailDiscount{$rand_line}() {\n";
                     echo "\$('#detail_discount{$rand_line}').hide();";
                     echo "\$('#detail_viewaccept{$global_rand}').show();";
                     $params = array('maxlength' => 15, 'size' => 8, 'name' => 'detail_discount[' . $data["IDD"] . ']', 'class' => 'smalldecimal', 'data' => rawurlencode($data["discount"]));
                     Ajax::updateItemJsCode("detail_viewdiscount{$rand_line}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/inputnumber.php", $params, false);
                     echo "}";
                     echo "</script>\n";
                     echo "<div id='detail_discount{$rand_line}' class='center'\n                           onClick='showDetailDiscount{$rand_line}()'>\n";
                     echo Html::formatNumber($data["discount"]);
                     echo "</div>\n";
                     echo "<div id='detail_viewdiscount{$rand_line}'>\n";
                     echo "</div>\n";
                     echo "</td>";
                 } else {
                     echo "<td align='center'>" . Html::formatNumber($data["discount"]) . "</td>";
                 }
                 /* price with reduction */
                 echo "<td align='center'>" . Html::formatNumber($data["price_discounted"]) . "</td>";
                 /* price ati */
                 echo "<td align='center'>" . Html::formatNumber($data["price_ati"]) . "</td>";
                 /* status  */
                 echo "<td align='center'>" . $reception->getReceptionStatus($data["IDD"]) . "</td></tr>";
             }
             echo "</table>";
             if ($canedit) {
                 echo "<script type='text/javascript' >\n";
                 echo "function detail_hideForm{$global_rand}() {\n";
                 echo $hideForm;
                 echo "\$('#detail_viewaccept{$global_rand}').hide();";
                 echo "}\n";
                 echo "</script>\n";
             }
             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=''>";
                 echo "</td><td class='center'>";
                 echo "<a onclick= \"if ( markCheckboxes('order_detail_form{$rand}') ) return false;\" href='#'>" . __("Check all") . "</a></td>";
                 echo "<td>/</td><td class='center'>";
                 echo "<a onclick= \"if ( unMarkCheckboxes('order_detail_form{$rand}') ) " . " return false;\" href='#'>" . __("Uncheck all") . "</a>";
                 echo "</td><td align='left'>";
                 echo "<input type='submit' onclick=\"return confirm('" . __("Do you really want to delete these details ? Delivered items will not be linked to order !", "order") . "')\" name='delete_item' value=\"" . __("Delete permanently") . "\" class='submit'>";
                 echo "</td>";
                 // Edit buttons
                 echo "<td align='left' width='80%'>";
                 echo "<div id='detail_viewaccept{$global_rand}' style='display:none;'>";
                 echo "&nbsp;<input type='submit' onclick=\"return confirm('" . __("Do you really want to update this item ?", "order") . "');\" name='update_detail_item'\n                     value=\"" . _sx("button", "Update") . "\" class='submit'>&nbsp;";
                 echo "&nbsp;<input type='button' onclick=\"detail_hideForm{$global_rand}();\"\n                     value=\"" . _sx("button", "Cancel") . "\" class='submit'>";
                 echo "</div>";
                 echo "</td>";
                 echo "</table>";
                 echo "</div>";
             }
             Html::closeForm();
             echo "</div>";
         }
         echo "<br>";
     }
 }
Beispiel #3
0
 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();
Session::checkLoginUser();
$PluginOrderReception = new PluginOrderReception();
echo "<table width='950px' class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><td>" . __("Delivery date") . "</td><td>";
Html::showDateFormItem("delivery_date", date("Y-m-d"), true, 1);
echo "</td><td>";
echo __("Delivery form") . "</td><td>";
echo "<input type='text' name='delivery_number' size='20'>";
echo "</td><td>";
echo "<input type='hidden' name='plugin_order_references_id' value='" . $_POST['plugin_order_references_id'] . "'>";
echo "<input type='hidden' name='plugin_order_orders_id' value='" . $_POST['plugin_order_orders_id'] . "'>";
echo __("Number to deliver", "order") . "</td><td width='10%'>";
$nb = $PluginOrderReception->checkItemStatus($_POST['plugin_order_orders_id'], $_POST['plugin_order_references_id'], PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED);
Dropdown::showInteger('number_reception', '', 1, $nb);
echo "</td><td>";
echo __("Delivery status", "order") . "&nbsp;";
PluginOrderDeliveryState::Dropdown(array('name' => "plugin_order_deliverystates_id"));
Beispiel #4
0
 public function dropdownLinkActions($itemtype, $plugin_order_references_id, $plugin_order_orders_id, $entities_id)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     $reception = new PluginOrderReception();
     $actions[0] = Dropdown::EMPTY_VALUE;
     if ($reception->checkItemStatus($plugin_order_orders_id, $plugin_order_references_id, PluginOrderOrder::ORDER_DEVICE_DELIVRED)) {
         if (!in_array($itemtype, self::getTypesThanCannotBeGenerared())) {
             $actions['generation'] = __("Generate item", "order");
         }
         if ($itemtype::canView()) {
             $actions['createLink'] = __("Link to an existing item", "order");
             $actions['deleteLink'] = __("Delete item link", "order");
         }
     }
     $rand = Dropdown::showFromArray('generationActions', $actions);
     $params = array('action' => '__VALUE__', 'itemtype' => $itemtype, 'plugin_order_references_id' => $plugin_order_references_id, 'plugin_order_orders_id' => $plugin_order_orders_id, 'entities_id' => $entities_id);
     Ajax::updateItemOnSelectEvent("dropdown_generationActions{$rand}", "show_generationActions{$rand}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/linkactions.php", $params);
     echo "<span id='show_generationActions{$rand}'>&nbsp;</span>";
 }
Beispiel #5
0
 @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";
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$reception = new PluginOrderReception();
$order_item = new PluginOrderOrder_Item();
if (isset($_POST["update"])) {
    if (PluginOrderReception::canCreate()) {
        $order_item->getFromDB($_POST["id"]);
        if ($order_item->fields["itemtype"] == 'SoftwareLicense') {
            $result = $order_item->queryRef($order_item->fields["plugin_order_orders_id"], $order_item->fields["plugin_order_references_id"], $order_item->fields["price_taxfree"], $order_item->fields["discount"], PluginOrderOrder::ORDER_DEVICE_DELIVRED);
            $nb = $DB->numrows($result);
            if ($nb) {
                for ($i = 0; $i < $nb; $i++) {
                    $ID = $DB->result($result, $i, 'id');
                    $input["id"] = $ID;
                    $input["delivery_date"] = $_POST["delivery_date"];
                    $input["delivery_number"] = $_POST["delivery_number"];
                    $input["plugin_order_deliverystates_id"] = $_POST["plugin_order_deliverystates_id"];
                    $input["delivery_comment"] = $_POST["delivery_comment"];