예제 #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);
     }
 }
예제 #2
0
                    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");
        $link->showItemGenerationForm($_POST);
        Html::footer();
    } else {
        Session::addMessageAfterRedirect(__("No item selected", "order"), false, ERROR);
        Html::redirect($_SERVER["HTTP_REFERER"]);
    }
} elseif (isset($_POST["generate"])) {
    $link->generateNewItem($_POST);
    Html::redirect(Toolbox::getItemTypeFormURL('PluginOrderOrder') . "?id=" . $_POST["plugin_order_orders_id"] . "");
} elseif (isset($_POST["deleteLinkWithItem"])) {
    foreach ($_POST["item"] as $key => $val) {
        if ($val == 1) {
            $link->deleteLinkWithItem($key, $_POST["itemtype"][$key], $_POST["plugin_order_orders_id"]);
        }
    }
    Html::redirect(Toolbox::getItemTypeFormURL('PluginOrderOrder') . "?id=" . $_POST["plugin_order_orders_id"] . "");
} elseif (isset($_POST["createLinkWithItem"])) {
    if (isset($_POST["item"]) && $_POST['item']) {
        $i = 0;
        $doit = 1;
        if (!in_array($_POST["itemtype"], array('SoftwareLicense', 'ConsumableItem', 'CartridgeItem')) && count($_POST["item"]) > 1) {
            $doit = 0;
        }