Beispiel #1
0
 /**
  *
  * @param $options
  *
  * return nothing
  */
 public static function generateAsset($options = array())
 {
     // Retrieve configuration for generate assets feature
     $config = PluginOrderConfig::getConfig();
     if ($config->canGenerateAsset()) {
         // Automatic generate assets on delivery
         $rand = mt_rand();
         $item = array("name" => $config->getGeneratedAssetName() . $rand, "serial" => $config->getGeneratedAssetSerial() . $rand, "otherserial" => $config->getGeneratedAssetOtherserial() . $rand, "entities_id" => $options['entities_id'], "itemtype" => $options["itemtype"], "id" => $options["items_id"], "plugin_order_orders_id" => $options["plugin_order_orders_id"]);
         $options_gen = array("plugin_order_orders_id" => $options["plugin_order_orders_id"], "plugin_order_references_id" => $options["plugin_order_references_id"], "id" => array($item));
         if ($config->canGenerateTicket()) {
             $options_gen["generate_ticket"] = array("entities_id" => $options['entities_id'], "tickettemplates_id" => $config->fields['tickettemplates_id_delivery']);
         }
         $link = new PluginOrderLink();
         $link->generateNewItem($options_gen);
     }
 }
Beispiel #2
0
 public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (in_array(get_class($item), PluginOrderOrder_Item::getClasses(true))) {
         $orderlink = new PluginOrderLink();
         if (!$orderlink->isItemLinkedToOrder(get_class($item), $item->getID())) {
             return '';
         }
         if ($item->getField('id') && !$withtemplate) {
             if ($_SESSION['glpishow_count_on_tabs']) {
                 return self::createTabEntry(__("Orders", "order"), self::countForItem($item));
             }
             return __("Orders", "order");
         }
     } elseif (get_class($item) == 'PluginOrderOrder') {
         if ($_SESSION['glpishow_count_on_tabs']) {
             return self::createTabEntry(__("Order item", "order"), self::countForOrder($item));
         }
         return __("Order", "order");
     }
     return '';
 }
Beispiel #3
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"] = "";
}
$link = new PluginOrderLink();
$order_item = new PluginOrderOrder_Item();
if (isset($_POST["generation"])) {
    if (isset($_POST["item"])) {
        foreach ($_POST["item"] as $key => $val) {
            if ($val == 1) {
                $order_item->getFromDB($_POST["id"][$key]);
                if ($order_item->fields["states_id"] == PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED) {
                    Session::addMessageAfterRedirect(__("Cannot generate items not delivered", "order"), true, ERROR);
                    Html::redirect($_SERVER["HTTP_REFERER"]);
                }
            }
        }
    }
    if (isset($_POST["item"])) {
        Html::header(__("Orders management", "order"), '', "plugins", "order", "order");
Beispiel #4
0
 public static function updateItem($item)
 {
     //TO DO : Must do check same values or update infocom
     $plugin = new Plugin();
     if ($plugin->isActivated("order")) {
         if (isset($item->fields["id"])) {
             $item->getFromDB($item->input["id"]);
             if (isset($item->fields["itemtype"]) & isset($item->fields["items_id"])) {
                 $orderlink = new PluginOrderLink();
                 $order = new PluginOrderOrder();
                 $orderitem = new self();
                 $order_supplier = new PluginOrderOrder_Supplier();
                 $detail_id = $orderlink->isItemLinkedToOrder($item->fields["itemtype"], $item->fields["items_id"]);
                 if ($detail_id > 0) {
                     switch ($item->fields["itemtype"]) {
                         default:
                             $field_set = false;
                             $unset_fields = array("order_number", "delivery_number", "budgets_id", "suppliers_id", "value", "buy_date");
                             $orderitem->getFromDB($detail_id);
                             $order->getFromDB($orderitem->fields["plugin_order_orders_id"]);
                             $order_supplier->getFromDBByOrder($orderitem->fields["plugin_order_orders_id"]);
                             $value["order_number"] = $order->fields["num_order"];
                             $value["delivery_number"] = $orderitem->fields["delivery_number"];
                             $value["budgets_id"] = $order->fields["budgets_id"];
                             $value["suppliers_id"] = $order->fields["suppliers_id"];
                             $value["value"] = $orderitem->fields["price_discounted"];
                             $value["buy_date"] = $order->fields["order_date"];
                             if (isset($order_supplier->fields["num_bill"]) && !empty($order_supplier->fields["num_bill"])) {
                                 $unset_fields[] = "bill";
                                 $value["bill"] = $order_supplier->fields["num_bill"];
                             }
                             foreach ($unset_fields as $field) {
                                 if (isset($item->input[$field])) {
                                     $field_set = true;
                                     $item->input[$field] = $value[$field];
                                 }
                             }
                             if ($field_set && !isset($item->input['_no_warning'])) {
                                 Session::addMessageAfterRedirect(__("Some fields cannont be modified because they belong to an order", "order"), true, ERROR);
                             }
                             break;
                         case 'Contract':
                             $orderitem->getFromDB($detail_id);
                             $order->getFromDB($orderitem->fields["plugin_order_orders_id"]);
                             $item->input['cost'] = $orderitem->fields["price_discounted"];
                             break;
                     }
                 }
             }
         }
     }
 }