Skip to content

Commit

Permalink
Merge branch 'release/2.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jul 8, 2019
2 parents 21536ee + 381d5d8 commit e5d5004
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 59 deletions.
2 changes: 1 addition & 1 deletion ajax/dropdownReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
$result = $DB->query($query);
$price = $DB->result($result, 0, 'price_taxfree');
$price = Html::formatNumber($price, true);
echo "<input value='$price' type='number' step='".PLUGIN_ORDER_NUMBER_STEP."' name='price' class='decimal' />";
echo "<input value='$price' type='number' step='".PLUGIN_ORDER_NUMBER_STEP."' name='price' class='decimal' min='0' />";
}
11 changes: 10 additions & 1 deletion ajax/inputnumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@
$class = "class='".$_REQUEST['class']."'";
}

$min = 0;
if (isset($_REQUEST['min'])) {
if (isset($_REQUEST['force_integer']) && $_REQUEST['force_integer']) {
$min = (int)$_REQUEST['min'];
} else {
$min = (float)$_REQUEST['min'];
}
}

$data = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(rawurldecode(stripslashes($_POST["data"]))));

echo "<input type='number' step='$step' name='".$_POST['name']."' value='$data' $class>";
echo "<input type='number' step='$step' min='$min' name='".$_POST['name']."' value='$data' $class>";
}
6 changes: 3 additions & 3 deletions ajax/referencedetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
$_POST["suppliers_id"]);
switch ($_POST["update"]) {
case 'quantity':
echo "<input type='number' name='quantity' class='quantity'>";
echo "<input type='number' min='0' name='quantity' class='quantity'>";
break;
case 'priceht':
echo "<input type='number' step='".PLUGIN_ORDER_NUMBER_STEP."'
echo "<input type='number' min='0' step='".PLUGIN_ORDER_NUMBER_STEP."'
name='price' value='".Html::formatNumber($price, true)."' class='decimal'>";
break;
case 'pricediscounted':
echo "<input type='number' step='".PLUGIN_ORDER_NUMBER_STEP."'
echo "<input type='number' min='0' step='".PLUGIN_ORDER_NUMBER_STEP."'
name='discount' class='smalldecimal' value='0'>";
break;
case 'taxe':
Expand Down
62 changes: 31 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inc/accountsection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function install(Migration $migration) {
`comment` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;";
$DB->query($query) or die ($DB->error());
}
}
Expand Down
2 changes: 1 addition & 1 deletion inc/analyticnature.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function install(Migration $migration) {
`comment` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;";
$DB->query($query) or die ($DB->error());
}
}
Expand Down
19 changes: 10 additions & 9 deletions inc/link.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,11 @@ public function generateNewItem($params) {
$reference = new PluginOrderReference();

foreach ($params["id"] as $key => $values) {
$add_item = array_merge($params['add_items'][$values['id']], $values);
$add_item = $values;
if (array_key_exists('add_items', $params)
&& array_key_exists($values['id'], $params['add_items'])) {
$add_item = array_merge($params['add_items'][$values['id']], $add_item);
}

//retrieve plugin_order_references_id from param if needed
if (!isset($add_item["plugin_order_references_id"])) {
Expand Down Expand Up @@ -1145,6 +1149,7 @@ public function generateNewItem($params) {
unset($item->fields["is_template"]);
unset($item->fields["date_mod"]);

$input = [];
$fields = [];
foreach ($item->fields as $key => $value) {
if ($value != ''
Expand All @@ -1155,7 +1160,7 @@ public function generateNewItem($params) {
}
}

if (isset($values["states_id"])) {
if (isset($values["states_id"]) && $values["states_id"] != 0) {
$input['states_id'] = $values['states_id'];
} else {
if ($config->getGeneratedAssetState()) {
Expand Down Expand Up @@ -1191,10 +1196,6 @@ public function generateNewItem($params) {
}
}

if ($config->canAddLocation()) {
$input['locations_id'] = $order->fields['locations_id'];
}

} else if ($add_item["itemtype"] == 'Contract') {
$input["name"] = $values["name"];
$input["entities_id"] = $entity;
Expand Down Expand Up @@ -1226,15 +1227,15 @@ public function generateNewItem($params) {
$input["name"] = $values["name"];
}

if ($input["manufacturers_id"] == 0) {
if (!array_key_exists('manufacturers_id', $input) || $input["manufacturers_id"] == 0) {
$input["manufacturers_id"] = $reference->fields["manufacturers_id"];
}
$typefield = getForeignKeyFieldForTable(getTableForItemType($add_item["itemtype"]."Type"));
if ($input[$typefield] == 0) {
if (!array_key_exists($typefield, $input) || $input[$typefield] == 0) {
$input[$typefield] = $reference->fields["types_id"];
}
$modelfield = getForeignKeyFieldForTable(getTableForItemType($add_item["itemtype"]."Model"));
if ($input[$modelfield] == 0) {
if (!array_key_exists($modelfield, $input) || $input[$modelfield] == 0) {
$input[$modelfield] = $reference->fields["models_id"];
}

Expand Down
2 changes: 1 addition & 1 deletion inc/order.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ public function showForm ($ID, $options = []) {
echo "<td>".__("Postage", "order").": </td>";
echo "<td>";
if ($canedit) {
echo "<input type='number' step='".PLUGIN_ORDER_NUMBER_STEP."' name='port_price' size='5'"
echo "<input type='number' min='0' step='".PLUGIN_ORDER_NUMBER_STEP."' name='port_price' size='5'"
." value=\"".Html::formatNumber($this->fields["port_price"], true)."\">";
} else {
echo Html::formatNumber($this->fields["port_price"]);
Expand Down
17 changes: 9 additions & 8 deletions inc/order_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,11 @@ public function showAddForm($plugin_order_orders_id) {
echo "</td>";

echo "<td class='tab_bg_1'><span id='show_quantity'>";
echo "<input type='number' name='quantity' value='0' class='quantity' />";
echo "<input type='number' min='0' 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 "<input type='number' min='0' 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'>";
Expand All @@ -425,7 +425,7 @@ public function showAddForm($plugin_order_orders_id) {
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 "<input type='number' min='0' step='".PLUGIN_ORDER_NUMBER_STEP."' name='discount' value='0' class='smalldecimal' />";
echo "</span></td>";

echo "<td class='tab_bg_1'><span id='show_validate'>";
Expand Down Expand Up @@ -486,11 +486,11 @@ public function showAddForm($plugin_order_orders_id) {
echo "</td>";

echo "<td class='tab_bg_1'><span id='show_quantity'>";
echo "<input type='number' name='quantity' value='0' class='quantity' />";
echo "<input type='number' min='0' 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 "<input type='number' min='0' 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'>";
Expand All @@ -504,7 +504,7 @@ public function showAddForm($plugin_order_orders_id) {
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 "<input type='number' min='0' step='" . PLUGIN_ORDER_NUMBER_STEP . "' name='discount' value='0' class='smalldecimal' />";
echo "</span></td>";

echo "<td class='tab_bg_1'><span id='show_addreference'>";
Expand Down Expand Up @@ -826,6 +826,7 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
'name' => 'quantity',
'class' => 'quantity',
'force_integer' => true,
'min' => rawurlencode($quantity),
'data' => rawurlencode($quantity)
], false);
echo "}";
Expand Down Expand Up @@ -1366,7 +1367,7 @@ public function showForm ($ID, $options = []) {
echo "<tr class='tab_bg_1'>";
echo "<td>".__("Unit price tax free", "order").": </td>";
if ($canedit) {
echo "<td><input type='number' step='".PLUGIN_ORDER_NUMBER_STEP."' name='price_taxfree' value='".$this->fields['price_taxfree']."' class='decimal'>";
echo "<td><input type='number' min='0' step='".PLUGIN_ORDER_NUMBER_STEP."' name='price_taxfree' value='".$this->fields['price_taxfree']."' class='decimal'>";
} else {
echo "<td>".Html::formatNumber($this->fields['price_taxfree'])."</td>";
}
Expand All @@ -1385,7 +1386,7 @@ public function showForm ($ID, $options = []) {
echo "<tr class='tab_bg_1'>";
echo "<td>".__("Discount (%)", "order").": </td>";
if ($canedit) {
echo "<td><input type='number' step='".PLUGIN_ORDER_NUMBER_STEP."' name='discount'
echo "<td><input type='number' min='0' step='".PLUGIN_ORDER_NUMBER_STEP."' name='discount'
value='".$this->fields['discount']."' class='decimal'>";
} else {
echo "<td>".Html::formatNumber($this->fields['discount'])."</td>";
Expand Down
3 changes: 2 additions & 1 deletion inc/reception.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ public static function generateAsset($options = []) {
"plugin_order_orders_id" => $options["plugin_order_orders_id"],
"plugin_order_references_id" => $options["plugin_order_references_id"],
"id" => [$item],
'itemtype' => $options['itemtype'],
];

if ($config->canGenerateTicket()) {
Expand All @@ -945,7 +946,7 @@ public static function countForOrder(PluginOrderOrder $item) {
public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
if ($item->getType() == 'PluginOrderOrder'
&& Session::haveRight('plugin_order_order', PluginOrderOrder::canView())
&& $item->getState() > PluginOrderOrderState::DRAFT) {
&& $item->getState() > PluginOrderOrderState::WAITING_FOR_APPROVAL) {
return self::createTabEntry(__("Item delivered", "order"), self::countForOrder($item));
}
}
Expand Down
2 changes: 1 addition & 1 deletion inc/reference_supplier.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function showForm ($ID, $options = []) {

echo "<td>".__("Unit price tax free", "order").": </td>";
echo "<td>";
echo "<input type='number' step='".PLUGIN_ORDER_NUMBER_STEP."' name='price_taxfree' value=\""
echo "<input type='number' min='0' step='".PLUGIN_ORDER_NUMBER_STEP."' name='price_taxfree' value=\""
.Html::formatNumber($this->fields["price_taxfree"], true)."\" class='decimal'>";
echo "</td>";

Expand Down
Loading

0 comments on commit e5d5004

Please sign in to comment.