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;
 }
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     $config = PluginOrderConfig::getConfig();
     if ($item->getType() == "DocumentCategory" && $config->canRenameDocuments()) {
         self::showForDocumentCategory($item);
     }
     return true;
 }
Beispiel #3
0
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);
                    }
                }
            }
            break;
    }
    PluginOrderOrder::updateBillState($order_item->fields['plugin_order_orders_id']);
    Html::back();
Beispiel #4
0
 public static function addDocumentCategory(Document $document)
 {
     $config = PluginOrderConfig::getConfig();
     if (isset($document->input['itemtype']) && $document->input['itemtype'] == __CLASS__ && !$document->input['documentcategories_id']) {
         $category = $config->getDefaultDocumentCategory();
         if ($category) {
             $document->update(array('id' => $document->getID(), 'documentcategories_id' => $category));
         }
     }
     // Fomrat document name
     if (isset($document->input['itemtype']) && $document->input['itemtype'] == __CLASS__ && $document->input['documentcategories_id'] && $config->canRenameDocuments()) {
         // Get document category
         $documentCategory = new PluginOrderDocumentCategory();
         if (!$documentCategory->getFromDBByQuery(" WHERE `documentcategories_id` = '" . $document->input['documentcategories_id'] . "'")) {
             $documentCategory->getEmpty();
         }
         // Get order linked to document
         $document_item = new Document_Item();
         if ($document_item->getFromDBByQuery(" WHERE `documents_id` = '" . $document->fields['id'] . "' AND `itemtype` = '" . self::getType() . "'")) {
             // Update document name
             $order = new self();
             $order->getFromDB($document_item->fields['items_id']);
             $extension = explode('.', $document->fields['filename']);
             $tag = "";
             if (!empty($documentCategory->fields['documentcategories_prefix'])) {
                 $tag = $documentCategory->fields['documentcategories_prefix'] . "-";
             }
             $document->fields['filename'] = $tag . $order->fields['num_order'] . "." . $extension[1];
             $document->updateInDB(array('filename'));
         }
     }
 }
Beispiel #5
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);
     }
 }
 public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     switch (get_class($item)) {
         case 'Supplier':
             return array(1 => __("Orders", "order"));
             break;
         case 'PluginOrderOrder':
             $config = PluginOrderConfig::getConfig();
             if ($config->canUseSupplierInformations() && $item->fields['suppliers_id']) {
                 return array(1 => __("Supplier Detail", "order"));
             }
             break;
         default:
             return '';
     }
 }
Beispiel #7
0
 @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";
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$pluginOrderOrder = new PluginOrderOrder();
$config = new PluginOrderConfig();
$pluginOrderOrder_Item = new PluginOrderOrder_Item();
$pluginOrderOrder_Supplier = new PluginOrderOrder_Supplier();
/* add order */
if (isset($_POST["add"])) {
    $pluginOrderOrder->check(-1, 'w', $_POST);
    /* FORCE Status */
    $_POST['plugin_order_orderstates_id'] = $config->getDraftState();
    $newID = $pluginOrderOrder->add($_POST);
    $url = Toolbox::getItemTypeFormURL('PluginOrderOrder') . "?id={$newID}";
    Html::redirect($url);
} else {
    if (isset($_POST["delete"])) {
        $pluginOrderOrder->check($_POST['id'], 'w');
        $pluginOrderOrder->delete($_POST);
        $pluginOrderOrder->redirectToList();
Beispiel #8
0
 public function showAddForm($plugin_order_orders_id)
 {
     global $CFG_GLPI, $DB;
     $order = new PluginOrderOrder();
     $reference = new PluginOrderReference();
     if ($order->getFromDB($plugin_order_orders_id) && $order->canUpdateOrder()) {
         if ($order->can($plugin_order_orders_id, UPDATE)) {
             echo "<form method='post' name='order_detail_form' id='order_detail_form'  action=\"" . Toolbox::getItemTypeFormURL('PluginOrderOrder') . "\">";
             echo "<input type='hidden' name='plugin_order_orders_id' value=\"{$plugin_order_orders_id}\">";
             echo "<div class='center'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th colspan='7'>" . __("Add to the order", "order") . "</th></tr>";
             if ($order->fields["suppliers_id"]) {
                 echo "<tr align='center'>";
                 echo "<th>" . __("Type") . "</th>";
                 echo "<th>" . __("Product reference", "order") . "</th>";
                 echo "<th>" . __("Quantity", "order") . "</th>";
                 echo "<th>" . __("Unit price tax free", "order") . "</th>";
                 echo "<th>" . __("VAT", "order") . "</th>";
                 echo "<th>" . __("Discount (%)", "order") . "</th>";
                 echo "<th></th>";
                 echo "</tr>";
                 echo "<tr align='center'>";
                 echo "<td class='tab_bg_1'>";
                 $query = "SELECT DISTINCT r.`itemtype`\n                         FROM `glpi_plugin_order_references` r\n                         LEFT JOIN `glpi_plugin_order_references_suppliers` s\n                            ON s.`plugin_order_references_id` = r.`id`\n                         WHERE s.`suppliers_id` = {$order->fields["suppliers_id"]}";
                 $result = $DB->query($query);
                 $itemtypeArray = array('' => Dropdown::EMPTY_VALUE);
                 while (list($itemtype) = $DB->fetch_array($result)) {
                     $type = new $itemtype();
                     $itemtypeArray[$itemtype] = $type->getTypeName();
                 }
                 asort($itemtypeArray);
                 $rand = mt_rand();
                 Dropdown::showFromArray('itemtype', $itemtypeArray, array('rand' => $rand, 'width' => 125));
                 $params = array('itemtype' => '__VALUE__', 'fieldname' => 'plugin_order_references_id', 'suppliers_id' => $order->fields["suppliers_id"], 'entities_id' => $order->fields["entities_id"], 'is_recursive' => $order->fields["is_recursive"], 'rand' => $rand);
                 Ajax::updateItemOnSelectEvent('dropdown_itemtype' . $rand, 'show_reference', '../ajax/dropdownReference.php', $params);
                 echo "</td>";
                 echo "<td class='tab_bg_1'><span id='show_reference'>";
                 Dropdown::showFromArray('plugin_order_references_id', array(0 => Dropdown::EMPTY_VALUE), array('rand' => $rand, 'width' => 200));
                 echo "</span></td>";
                 echo "<td class='tab_bg_1'><span id='show_quantity'>";
                 echo "<input type='number' name='quantity' value='0' class='quantity' />";
                 echo "</span></td>";
                 echo "<td class='tab_bg_1'><span id='show_priceht'>";
                 echo "<input type='number' step='" . PLUGIN_ORDER_NUMBER_STEP . "' name='price' value='0.00' class='decimal' />";
                 echo "</span></td>";
                 echo "<td class='tab_bg_1'><span id='show_taxe'>";
                 $config = PluginOrderConfig::getConfig();
                 PluginOrderOrderTax::Dropdown(array('name' => "plugin_order_ordertaxes_id", 'value' => $config->getDefaultTaxes(), 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order")));
                 echo "</span></td>";
                 echo "<td class='tab_bg_1'><span id='show_pricediscounted'>";
                 echo "<input type='number' step='" . PLUGIN_ORDER_NUMBER_STEP . "' name='discount' value='0' class='smalldecimal' />";
                 echo "</span></td>";
                 echo "<td class='tab_bg_1'><span id='show_validate'>";
                 echo "<input type='submit' name='add_item' value=\"" . __("Add") . "\" class='submit'>";
                 echo "</span></td>";
                 echo "</tr>";
             } else {
                 echo "<tr class='tab_bg_1'><td align='center'>" . __("Please select a supplier", "order") . "</td></tr>";
             }
             echo "</table></div>";
             Html::closeForm();
         }
     }
 }
Beispiel #9
0
 /**
  * Copy order documents into the newly generated item
  * @since 1.5.3
  * @param unknown_type $itemtype
  * @param unknown_type $items_id
  * @param unknown_type $orders_id
  * @param unknown_type $entity
  */
 public static function copyDocuments($itemtype, $items_id, $orders_id, $entity)
 {
     global $CFG_GLPI;
     $config = PluginOrderConfig::getConfig();
     if ($config->canCopyDocuments() && in_array($itemtype, $CFG_GLPI["document_types"])) {
         $document = new Document();
         $docitem = new Document_Item();
         $item = new $itemtype();
         $item->getFromDB($items_id);
         $is_recursive = 0;
         foreach (getAllDatasFromTable('glpi_documents_items', "`itemtype`='PluginOrderOrder'\n                                          AND `items_id`='{$orders_id}'") as $doc) {
             //Create a new document
             $document->getFromDB($doc['documents_id']);
             if ($document->getEntityID() != $entity && !$document->fields['is_recursive'] || !in_array($entity, getSonsOf('glpi_entities', $document->getEntityID()))) {
                 $found_docs = getAllDatasFromTable('glpi_documents', "`entities_id`='{$entity}'\n                                                 AND `sha1sum`='" . $document->fields['sha1sum'] . "'");
                 if (empty($found_docs)) {
                     $tmpdoc = $document->fields;
                     $tmpdoc['entities_id'] = $entity;
                     unset($tmpdoc['id']);
                     $documents_id = $document->add($tmpdoc);
                     $is_recursive = $document->fields['is_recursive'];
                 } else {
                     $found_doc = array_pop($found_docs);
                     $documents_id = $found_doc['id'];
                     $is_recursive = $found_doc['is_recursive'];
                 }
             } else {
                 $documents_id = $document->getID();
                 $is_recursive = $document->fields['is_recursive'];
             }
             //Link the document to the newly generated item
             $fields['documents_id'] = $documents_id;
             $fields['entities_id'] = $entity;
             $fields['items_id'] = $items_id;
             $fields['itemtype'] = $itemtype;
             $fields['is_recursive'] = $is_recursive;
             $newID = $docitem->add($fields);
         }
     }
 }
Beispiel #10
0
 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";
$config = new PluginOrderConfig();
if (isset($_POST["update"])) {
    $config->update($_POST);
    //Update singelton
    PluginOrderConfig::getConfig(true);
    Html::back();
} else {
    Html::header(__("Orders", "order"), $_SERVER['PHP_SELF'], "management", "PluginOrderMenu", "order");
    Session::checkRight("config", UPDATE);
    $config->showForm();
    Html::footer();
}
 /**
  * Copy order documents into the newly generated item
  * @since 1.5.3
  * @param unknown_type $itemtype
  * @param unknown_type $items_id
  * @param unknown_type $orders_id
  * @param unknown_type $entity
  */
 public static function copyDocuments($itemtype, $items_id, $orders_id, $entity)
 {
     global $CFG_GLPI;
     $config = PluginOrderConfig::getConfig();
     if ($config->canCopyDocuments() && in_array($itemtype, $CFG_GLPI["document_types"])) {
         $document = new Document();
         foreach (getAllDatasFromTable('glpi_documents_items', "`itemtype`='PluginOrderOrder' AND `items_id`='{$orders_id}'") as $doc) {
             $document->getFromDB($doc['documents_id']);
             $newdocument = clone $document;
             $newdocument->fields['entities_id'] = $entity;
             $newdocument->fields['items_id'] = $items_id;
             $newdocument->fields['itemtype'] = $itemtype;
             unset($newdocument->fields['id']);
             $document->add($newdocument->fields);
         }
     }
 }
Beispiel #12
0
function plugin_order_displayConfigItem($type, $ID, $data, $num)
{
    global $CFG_GLPI;
    $searchopt =& Search::getOptions($type);
    $table = $searchopt[$ID]["table"];
    $field = $searchopt[$ID]["field"];
    switch ($table . '.' . $field) {
        case "glpi_plugin_order_orders.is_late":
            $message = "";
            if ($data['raw']["ITEM_" . $num]) {
                $config = PluginOrderConfig::getConfig();
                if ($config->getShouldBeDevileredColor() != '') {
                    $message .= " style=\"background-color:" . $config->getShouldBeDevileredColor() . ";\" ";
                }
            }
            return $message;
    }
}
Beispiel #13
0
 static function addDocumentCategory(Document $document)
 {
     if (isset($document->input['itemtype']) && $document->input['itemtype'] == __CLASS__ && !$document->input['documentcategories_id']) {
         $config = PluginOrderConfig::getConfig();
         $category = $config->getDefaultDocumentCategory();
         if ($category) {
             $document->update(array('id' => $document->getID(), 'documentcategories_id' => $category));
         }
     }
 }
 public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (get_class($item) == 'PluginOrderOrder') {
         $config = PluginOrderConfig::getConfig();
         if ($config->canUseSupplierSatisfaction() && $item->getState() == PluginOrderOrderState::DELIVERED) {
             return array(1 => __("Supplier quality", "order"));
         }
     }
 }
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (get_class($item) == 'Supplier') {
         return array(1 => __("Orders", "order"));
     } elseif (get_class($item) == 'PluginOrderOrder') {
         $config = PluginOrderConfig::getConfig();
         if ($config->canUseSupplierInformations() && $item->fields['suppliers_id']) {
             return array(1 => __("Supplier Detail", "order"));
         }
     }
     return '';
 }
Beispiel #16
0
 /**
  * Copy order documents into the newly generated item
  * @since 1.5.3
  * @param unknown_type $itemtype
  * @param unknown_type $items_id
  * @param unknown_type $orders_id
  * @param unknown_type $entity
  */
 static function copyDocuments($itemtype, $items_id, $orders_id, $entity)
 {
     global $CFG_GLPI;
     $config = PluginOrderConfig::getConfig();
     if ($config->canCopyDocuments() && in_array($itemtype, $CFG_GLPI["document_types"])) {
         $document_item = new Document_Item();
         $document = new Document();
         foreach (getAllDatasFromTable('glpi_documents_items', "`itemtype`='PluginOrderOrder'\n                                           AND `items_id`='{$orders_id}'") as $doc) {
             $document->getFromDB($doc['documents_id']);
             $mime = $document->fields['mime'];
             $newdocument = clone $document;
             $newdocument->fields['entities_id'] = $entity;
             unset($newdocument->fields['id']);
             $newID = $document->add($newdocument->fields);
             $tmp['itemtype'] = $itemtype;
             $tmp['items_id'] = $items_id;
             $tmp['documents_id'] = $newID;
             $document_item->add($tmp);
             //force mimetype
             $document->update(array('id' => $newID, 'mime' => $mime));
         }
     }
 }