Example #1
0
if (isset($_REQUEST['purge'])) {
    $bill->delete($_REQUEST);
    $bill->redirectToList();
}
if (isset($_POST['action'])) {
    // Retrieve configuration for generate assets feature
    $order_item = new PluginOrderOrder_Item();
    switch ($_POST['chooseAction']) {
        case 'bill':
        case 'state':
            if (isset($_POST["item"])) {
                foreach ($_POST["item"] as $key => $val) {
                    if ($val == 1) {
                        $tmp = $_POST;
                        $tmp['id'] = $key;
                        $order_item->update($tmp);
                        // Update infocom
                        $ic = new Infocom();
                        $ic->getFromDBforDevice($order_item->fields['itemtype'], $order_item->fields['items_id']);
                        $config = PluginOrderConfig::getConfig();
                        if ($config->canAddBillDetails()) {
                            if ($bill->getFromDB($_POST["plugin_order_bills_id"])) {
                                $fields['id'] = $ic->fields['id'];
                                $fields['bill'] = $bill->fields['number'];
                                $fields['warranty_date'] = $bill->fields['billdate'];
                            }
                        }
                        $ic->update($fields);
                    }
                }
            }
Example #2
0
 public function receptionAllItem($detailID, $ref_id, $orders_id, $delivery_date, $delivery_nb, $state_id)
 {
     global $DB;
     $detail = new PluginOrderOrder_Item();
     $detail->getFromDB($detailID);
     $result = $detail->queryRef($_POST["plugin_order_orders_id"], $ref_id, $detail->fields["price_taxfree"], $detail->fields["discount"], PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED);
     $nb = $DB->numrows($result);
     if ($nb) {
         for ($i = 0; $i < $nb; $i++) {
             $detailID = $DB->result($result, $i, 'id');
             $input["id"] = $detailID;
             $input["delivery_date"] = $delivery_date;
             $input["states_id"] = PluginOrderOrder::ORDER_DEVICE_DELIVRED;
             $input["delivery_number"] = $delivery_nb;
             $input["plugin_order_deliverystates_id"] = $state_id;
             $detail->update($input);
         }
     }
     Session::addMessageAfterRedirect(__("Item successfully taken delivery", "order"), true);
 }
Example #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";
$item = new PluginOrderOrder_Item();
if (isset($_POST['update'])) {
    $item->update($_POST);
    $item->updatePrices($_POST['id']);
    Html::redirect($_SERVER['HTTP_REFERER']);
}
Html::header(__("Orders management", "order"), $_SERVER['PHP_SELF'], "management", "PluginOrderMenu", "order");
$item->display($_REQUEST);
Html::footer();
Example #4
0
 public function transfer($ID, $entity)
 {
     global $DB;
     if ($ID <= 0 || !$this->getFromDB($ID)) {
         return 0;
     }
     //If reference is not visible in the target entity : transfer it!
     if (!countElementsInTableForEntity($this->getTable(), $entity, "`id`='" . $this->getID() . "'")) {
         $input = $this->fields;
         $input['entities_id'] = $entity;
         $oldref = $input['id'];
         unset($input['id']);
         $input['transfert'] = 1;
         $newid = $this->add($input);
         $reference_supplier = new PluginOrderReference_Supplier();
         $reference_supplier->getFromDBByReference($oldref);
         $input = $reference_supplier->fields;
         $input['entities_id'] = $entity;
         $input['plugin_order_references_id'] = $newid;
         unset($input['id']);
         $reference_supplier->add($input);
         $PluginOrderOrder_Item = new PluginOrderOrder_Item();
         $query = "SELECT `id`\n                   FROM `glpi_plugin_order_orders_items`\n                   WHERE `plugin_order_references_id` = '{$oldref}'";
         $result = $DB->query($query);
         $num = $DB->numrows($result);
         if ($num) {
             while ($dataref = $DB->fetch_array($result)) {
                 $values["id"] = $dataref['id'];
                 $values["plugin_order_references_id"] = $newid;
                 $PluginOrderOrder_Item->update($values);
             }
         }
     }
 }
Example #5
0
 public function deleteLinkWithItem($detailID, $itemtype, $plugin_order_orders_id)
 {
     global $DB;
     if ($itemtype == 'SoftWareLicense') {
         $detail = new PluginOrderOrder_Item();
         $detail->getFromDB($detailID);
         $license = $detail->fields["items_id"];
         $this->removeInfoComRelatedToOrder($itemtype, $license);
         $result = $PluginOrderOrder_Item->queryRef($detail->fields["plugin_order_orders_id"], $detail->fields["plugin_order_references_id"], $detail->fields["price_taxfree"], $detail->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["items_id"] = 0;
                 $detail->update($input);
                 $lic = new SoftwareLicense();
                 $lic->getFromDB($license);
                 $values["id"] = $lic->fields["id"];
                 $values["number"] = $lic->fields["number"] - 1;
                 $lic->update($values);
             }
             $order = new PluginOrderOrder();
             $order->getFromDB($detail->fields["plugin_order_orders_id"]);
             $new_value = __("Item unlink form order", "order") . ' : ' . $order->fields["name"];
             $order->addHistory($itemtype, '', $new_value, $license);
             $item = new $itemtype();
             $item->getFromDB($license);
             $new_value = __("Item unlink form order", "order") . ' : ' . $item->getField("name");
             $order->addHistory('PluginOrderOrder', '', $new_value, $order->fields["id"]);
         }
     } else {
         $order = new PluginOrderOrder();
         $order->getFromDB($plugin_order_orders_id);
         $detail = new PluginOrderOrder_Item();
         $detail->getFromDB($detailID);
         $items_id = $detail->fields["items_id"];
         $this->removeInfoComRelatedToOrder($itemtype, $items_id);
         if ($items_id != 0) {
             $input = $detail->fields;
             $input["items_id"] = 0;
             $detail->update($input);
         } else {
             Session::addMessageAfterRedirect(__("One or several selected rows haven't linked items", "order"), TRUE, ERROR);
         }
         $new_value = __("Item unlink form order", "order") . ' : ' . $order->fields["name"];
         $order->addHistory($itemtype, '', $new_value, $items_id);
         $item = new $itemtype();
         $item->getFromDB($items_id);
         $new_value = __("Item unlink form order", "order") . ' : ' . $item->getField("name");
         $order->addHistory('PluginOrderOrder', '', $new_value, $order->fields["id"]);
     }
 }