Exemplo n.º 1
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 '';
 }
Exemplo n.º 2
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;
                     }
                 }
             }
         }
     }
 }