Skip to content

Commit

Permalink
Merge branch 'release/2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Apr 15, 2019
2 parents 8aceb83 + 467e84f commit ed4bbea
Show file tree
Hide file tree
Showing 37 changed files with 2,331 additions and 1,255 deletions.
308 changes: 212 additions & 96 deletions composer.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,32 +298,32 @@ function plugin_order_addLeftJoin($type, $ref_table, $new_table, $linkfield, &$a

/* display custom fields in the search */
function plugin_order_giveItem($type, $ID, $data, $num) {
global $CFG_GLPI;

$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
$reference = new PluginOrderReference();
$itemnum = $data['raw']["ITEM_".$num];
$itemtype = isset($data['raw']["itemtype"]) ? $data['raw']["itemtype"] : "";
$itemtype = isset($data['raw']["ITEM_".$num."_itemtype"])
? $data['raw']["ITEM_".$num."_itemtype"]
: '';

switch ($table.'.'.$field) {
/* display associated items with order */
case "glpi_plugin_order_references.types_id" :
if ($data['raw']["itemtype"] == 'PluginOrderOther') {
if ($itemtype == 'PluginOrderOther') {
$file = GLPI_ROOT."/plugins/order/inc/othertype.class.php";
} else {
$file = GLPI_ROOT."/inc/".strtolower($itemtype)."type.class.php";
}
if (file_exists($file)) {
return Dropdown::getDropdownName(getTableForItemType($data["itemtype"]."Type"),
return Dropdown::getDropdownName(getTableForItemType($itemtype."Type"),
$itemnum);
} else {
return " ";
}
break;
case "glpi_plugin_order_references.models_id" :
if (file_exists(GLPI_ROOT."/inc/".strtolower($data["itemtype"])."model.class.php")) {
if (file_exists(GLPI_ROOT."/inc/".strtolower($itemtype)."model.class.php")) {
return Dropdown::getDropdownName(getTableForItemType($itemtype."Model"),
$itemnum);
} else {
Expand Down
8 changes: 7 additions & 1 deletion inc/link.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ public function generateInfoComRelatedToOrder($entity, $detailID, $itemtype, $it
$fields["suppliers_id"] = $order->fields["suppliers_id"];
$fields["value"] = $detail->fields["price_discounted"];
$fields["order_date"] = $order->fields["order_date"];
$fields["buy_date"] = $order->fields["order_date"];

if (!is_null($detail->fields["delivery_date"])) {
$fields["delivery_date"] = $detail->fields["delivery_date"];
Expand Down Expand Up @@ -1114,7 +1115,12 @@ public function generateNewItem($params) {
$reference = new PluginOrderReference();

foreach ($params["id"] as $key => $values) {
$add_item = $params['add_items'][$values['id']];
$add_item = $values;

//retrieve plugin_order_references_id from param if needed
if (!isset($add_item["plugin_order_references_id"])) {
$add_item["plugin_order_references_id"] = $params['plugin_order_references_id'];
}

//If itemtype cannot be generated, go to the new occurence
if (in_array($add_item['itemtype'], self::getTypesThanCannotBeGenerared())) {
Expand Down
3 changes: 1 addition & 2 deletions inc/order_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static function updateItem($item) {
default:
$field_set = false;
$unset_fields = ["order_number", "delivery_number", "budgets_id",
"suppliers_id", "value", "buy_date"];
"suppliers_id", "value"];
$orderitem->getFromDB($detail_id);
$order->getFromDB($orderitem->fields["plugin_order_orders_id"]);
$order_supplier->getFromDBByOrder($orderitem->fields["plugin_order_orders_id"]);
Expand All @@ -220,7 +220,6 @@ public static function updateItem($item) {
$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";
Expand Down
3 changes: 3 additions & 0 deletions inc/reference.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function rawSearchOptions() {
'injectable' => true,
'massiveaction' => false,
'nosearch' => true,
'additionalfields' => ['itemtype'],
];

$tab[] = [
Expand All @@ -129,6 +130,7 @@ public function rawSearchOptions() {
'massiveaction' => false,
'searchtype' => ['equals'],
'nosearch' => true,
'additionalfields' => ['itemtype'],
];

$tab[] = [
Expand All @@ -141,6 +143,7 @@ public function rawSearchOptions() {
'injectable' => true,
'massiveaction' => false,
'nosearch' => true,
'additionalfields' => ['itemtype'],
];

$tab[] = [
Expand Down
6 changes: 6 additions & 0 deletions inc/reference_supplier.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public static function getTypeName($nb = 0) {
return __("Supplier for the reference", "order");
}

function getRawName() {
$ref = new PluginOrderReference();
$ref->getFromDB($this->fields['plugin_order_references_id']);
return sprintf(__('Supplier for the reference "%1$s"'), $ref->getName());
}


public function getFromDBByReference($plugin_order_references_id) {
global $DB;
Expand Down
Binary file modified locales/cs_CZ.mo
Binary file not shown.
Loading

0 comments on commit ed4bbea

Please sign in to comment.