Skip to content

Commit ed4bbea

Browse files
committed
Merge branch 'release/2.5.0'
2 parents 8aceb83 + 467e84f commit ed4bbea

37 files changed

+2331
-1255
lines changed

composer.lock

Lines changed: 212 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hook.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,32 +298,32 @@ function plugin_order_addLeftJoin($type, $ref_table, $new_table, $linkfield, &$a
298298

299299
/* display custom fields in the search */
300300
function plugin_order_giveItem($type, $ID, $data, $num) {
301-
global $CFG_GLPI;
302-
303301
$searchopt = &Search::getOptions($type);
304302
$table = $searchopt[$ID]["table"];
305303
$field = $searchopt[$ID]["field"];
306304
$reference = new PluginOrderReference();
307305
$itemnum = $data['raw']["ITEM_".$num];
308-
$itemtype = isset($data['raw']["itemtype"]) ? $data['raw']["itemtype"] : "";
306+
$itemtype = isset($data['raw']["ITEM_".$num."_itemtype"])
307+
? $data['raw']["ITEM_".$num."_itemtype"]
308+
: '';
309309

310310
switch ($table.'.'.$field) {
311311
/* display associated items with order */
312312
case "glpi_plugin_order_references.types_id" :
313-
if ($data['raw']["itemtype"] == 'PluginOrderOther') {
313+
if ($itemtype == 'PluginOrderOther') {
314314
$file = GLPI_ROOT."/plugins/order/inc/othertype.class.php";
315315
} else {
316316
$file = GLPI_ROOT."/inc/".strtolower($itemtype)."type.class.php";
317317
}
318318
if (file_exists($file)) {
319-
return Dropdown::getDropdownName(getTableForItemType($data["itemtype"]."Type"),
319+
return Dropdown::getDropdownName(getTableForItemType($itemtype."Type"),
320320
$itemnum);
321321
} else {
322322
return " ";
323323
}
324324
break;
325325
case "glpi_plugin_order_references.models_id" :
326-
if (file_exists(GLPI_ROOT."/inc/".strtolower($data["itemtype"])."model.class.php")) {
326+
if (file_exists(GLPI_ROOT."/inc/".strtolower($itemtype)."model.class.php")) {
327327
return Dropdown::getDropdownName(getTableForItemType($itemtype."Model"),
328328
$itemnum);
329329
} else {

inc/link.class.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ public function generateInfoComRelatedToOrder($entity, $detailID, $itemtype, $it
857857
$fields["suppliers_id"] = $order->fields["suppliers_id"];
858858
$fields["value"] = $detail->fields["price_discounted"];
859859
$fields["order_date"] = $order->fields["order_date"];
860+
$fields["buy_date"] = $order->fields["order_date"];
860861

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

11161117
foreach ($params["id"] as $key => $values) {
1117-
$add_item = $params['add_items'][$values['id']];
1118+
$add_item = $values;
1119+
1120+
//retrieve plugin_order_references_id from param if needed
1121+
if (!isset($add_item["plugin_order_references_id"])) {
1122+
$add_item["plugin_order_references_id"] = $params['plugin_order_references_id'];
1123+
}
11181124

11191125
//If itemtype cannot be generated, go to the new occurence
11201126
if (in_array($add_item['itemtype'], self::getTypesThanCannotBeGenerared())) {

inc/order_item.class.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public static function updateItem($item) {
210210
default:
211211
$field_set = false;
212212
$unset_fields = ["order_number", "delivery_number", "budgets_id",
213-
"suppliers_id", "value", "buy_date"];
213+
"suppliers_id", "value"];
214214
$orderitem->getFromDB($detail_id);
215215
$order->getFromDB($orderitem->fields["plugin_order_orders_id"]);
216216
$order_supplier->getFromDBByOrder($orderitem->fields["plugin_order_orders_id"]);
@@ -220,7 +220,6 @@ public static function updateItem($item) {
220220
$value["budgets_id"] = $order->fields["budgets_id"];
221221
$value["suppliers_id"] = $order->fields["suppliers_id"];
222222
$value["value"] = $orderitem->fields["price_discounted"];
223-
$value["buy_date"] = $order->fields["order_date"];
224223
if (isset($order_supplier->fields["num_bill"])
225224
&& !empty($order_supplier->fields["num_bill"])) {
226225
$unset_fields[] = "bill";

inc/reference.class.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function rawSearchOptions() {
106106
'injectable' => true,
107107
'massiveaction' => false,
108108
'nosearch' => true,
109+
'additionalfields' => ['itemtype'],
109110
];
110111

111112
$tab[] = [
@@ -129,6 +130,7 @@ public function rawSearchOptions() {
129130
'massiveaction' => false,
130131
'searchtype' => ['equals'],
131132
'nosearch' => true,
133+
'additionalfields' => ['itemtype'],
132134
];
133135

134136
$tab[] = [
@@ -141,6 +143,7 @@ public function rawSearchOptions() {
141143
'injectable' => true,
142144
'massiveaction' => false,
143145
'nosearch' => true,
146+
'additionalfields' => ['itemtype'],
144147
];
145148

146149
$tab[] = [

inc/reference_supplier.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public static function getTypeName($nb = 0) {
4646
return __("Supplier for the reference", "order");
4747
}
4848

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

5056
public function getFromDBByReference($plugin_order_references_id) {
5157
global $DB;

locales/cs_CZ.mo

864 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)