From 1fe789fabf3173b5d5656126f358fb425dad1b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Thu, 4 Jul 2019 10:23:34 +0200 Subject: [PATCH 1/7] Switch remaining MyISAM tables to InnoDB; fixes #242 (#245) --- inc/accountsection.class.php | 2 +- inc/analyticnature.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/accountsection.class.php b/inc/accountsection.class.php index 97325413ce..08c600cb58 100644 --- a/inc/accountsection.class.php +++ b/inc/accountsection.class.php @@ -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()); } } diff --git a/inc/analyticnature.class.php b/inc/analyticnature.class.php index bca274dae1..cf7b2eb440 100644 --- a/inc/analyticnature.class.php +++ b/inc/analyticnature.class.php @@ -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()); } } From 442b3ecc17f0f2c3fb5b92389e35d54a19663d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 1 Jul 2019 14:29:18 +0200 Subject: [PATCH 2/7] Fix automatic asset generation; see #234 --- inc/link.class.php | 19 ++++++++++--------- inc/reception.class.php | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/inc/link.class.php b/inc/link.class.php index b580aea391..2495f1eb4e 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -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"])) { @@ -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 != '' @@ -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()) { @@ -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; @@ -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"]; } diff --git a/inc/reception.class.php b/inc/reception.class.php index 447c5adf95..e35ce003d2 100644 --- a/inc/reception.class.php +++ b/inc/reception.class.php @@ -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()) { From 8091161bd8b2c1910dc9bc07859bd03110994d1f Mon Sep 17 00:00:00 2001 From: Alexandre Delaunay Date: Wed, 3 Jul 2019 13:17:19 +0200 Subject: [PATCH 3/7] set mininaml to 0 in input number html tags --- ajax/dropdownReference.php | 2 +- ajax/inputnumber.php | 2 +- ajax/referencedetail.php | 6 +++--- inc/order.class.php | 2 +- inc/order_item.class.php | 16 ++++++++-------- inc/reference_supplier.class.php | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ajax/dropdownReference.php b/ajax/dropdownReference.php index 1f32981dc3..27f09ff139 100644 --- a/ajax/dropdownReference.php +++ b/ajax/dropdownReference.php @@ -70,5 +70,5 @@ $result = $DB->query($query); $price = $DB->result($result, 0, 'price_taxfree'); $price = Html::formatNumber($price, true); - echo ""; + echo ""; } diff --git a/ajax/inputnumber.php b/ajax/inputnumber.php index 3b3f48f334..0e20ec3df2 100644 --- a/ajax/inputnumber.php +++ b/ajax/inputnumber.php @@ -54,5 +54,5 @@ $data = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(rawurldecode(stripslashes($_POST["data"])))); - echo ""; + echo ""; } diff --git a/ajax/referencedetail.php b/ajax/referencedetail.php index 20a51254a4..d0a7a5677e 100644 --- a/ajax/referencedetail.php +++ b/ajax/referencedetail.php @@ -45,14 +45,14 @@ $_POST["suppliers_id"]); switch ($_POST["update"]) { case 'quantity': - echo ""; + echo ""; break; case 'priceht': - echo ""; break; case 'pricediscounted': - echo ""; break; case 'taxe': diff --git a/inc/order.class.php b/inc/order.class.php index a052cec8be..451b5c1f99 100644 --- a/inc/order.class.php +++ b/inc/order.class.php @@ -1008,7 +1008,7 @@ public function showForm ($ID, $options = []) { echo "".__("Postage", "order").": "; echo ""; if ($canedit) { - echo "fields["port_price"], true)."\">"; } else { echo Html::formatNumber($this->fields["port_price"]); diff --git a/inc/order_item.class.php b/inc/order_item.class.php index 48346c93bf..473ca42eda 100644 --- a/inc/order_item.class.php +++ b/inc/order_item.class.php @@ -407,11 +407,11 @@ public function showAddForm($plugin_order_orders_id) { echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; @@ -425,7 +425,7 @@ public function showAddForm($plugin_order_orders_id) { echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; @@ -486,11 +486,11 @@ public function showAddForm($plugin_order_orders_id) { echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; @@ -504,7 +504,7 @@ public function showAddForm($plugin_order_orders_id) { echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; @@ -1366,7 +1366,7 @@ public function showForm ($ID, $options = []) { echo ""; echo "".__("Unit price tax free", "order").": "; if ($canedit) { - echo ""; + echo ""; } else { echo "".Html::formatNumber($this->fields['price_taxfree']).""; } @@ -1385,7 +1385,7 @@ public function showForm ($ID, $options = []) { echo ""; echo "".__("Discount (%)", "order").": "; if ($canedit) { - echo ""; } else { echo "".Html::formatNumber($this->fields['discount']).""; diff --git a/inc/reference_supplier.class.php b/inc/reference_supplier.class.php index 52127c46d8..f8648fe03d 100644 --- a/inc/reference_supplier.class.php +++ b/inc/reference_supplier.class.php @@ -223,7 +223,7 @@ public function showForm ($ID, $options = []) { echo "".__("Unit price tax free", "order").": "; echo ""; - echo "fields["price_taxfree"], true)."\" class='decimal'>"; echo ""; From 41ac369e1355590b8f801b2371e371aa620906fc Mon Sep 17 00:00:00 2001 From: Alexandre Delaunay Date: Wed, 3 Jul 2019 13:30:52 +0200 Subject: [PATCH 4/7] we cant decrease the quantity when editing items of an order --- ajax/inputnumber.php | 11 ++++++++++- inc/order_item.class.php | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ajax/inputnumber.php b/ajax/inputnumber.php index 0e20ec3df2..3f2d3f6b4b 100644 --- a/ajax/inputnumber.php +++ b/ajax/inputnumber.php @@ -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 ""; + echo ""; } diff --git a/inc/order_item.class.php b/inc/order_item.class.php index 473ca42eda..96bceae583 100644 --- a/inc/order_item.class.php +++ b/inc/order_item.class.php @@ -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 "}"; From 3aa284205a5ba44a1e7881ad227dfa992703f693 Mon Sep 17 00:00:00 2001 From: Alexandre Delaunay Date: Wed, 3 Jul 2019 15:49:34 +0200 Subject: [PATCH 5/7] don't show reception tab until command is validated --- inc/reception.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/reception.class.php b/inc/reception.class.php index e35ce003d2..798d5968bd 100644 --- a/inc/reception.class.php +++ b/inc/reception.class.php @@ -946,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)); } } From 77a3454fcfbd7316674539dd32e65083122a7d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 8 Jul 2019 14:46:54 +0200 Subject: [PATCH 6/7] Update PHP dependencies --- composer.lock | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/composer.lock b/composer.lock index 1c40bcf520..495fcba0ae 100644 --- a/composer.lock +++ b/composer.lock @@ -1167,16 +1167,16 @@ }, { "name": "symfony/console", - "version": "v3.4.28", + "version": "v3.4.29", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6" + "reference": "c4d2f3529755ffc0be9fb823583b28d8744eeb3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6", - "reference": "8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6", + "url": "https://api.github.com/repos/symfony/console/zipball/c4d2f3529755ffc0be9fb823583b28d8744eeb3d", + "reference": "c4d2f3529755ffc0be9fb823583b28d8744eeb3d", "shasum": "" }, "require": { @@ -1235,20 +1235,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-05-09T08:42:51+00:00" + "time": "2019-06-05T11:33:52+00:00" }, { "name": "symfony/debug", - "version": "v3.4.28", + "version": "v3.4.29", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "671fc55bd14800668b1d0a3708c3714940e30a8c" + "reference": "1172dc1abe44dfadd162239153818b074e6e53bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/671fc55bd14800668b1d0a3708c3714940e30a8c", - "reference": "671fc55bd14800668b1d0a3708c3714940e30a8c", + "url": "https://api.github.com/repos/symfony/debug/zipball/1172dc1abe44dfadd162239153818b074e6e53bf", + "reference": "1172dc1abe44dfadd162239153818b074e6e53bf", "shasum": "" }, "require": { @@ -1291,20 +1291,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2019-05-18T13:32:47+00:00" + "time": "2019-06-18T21:26:03+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.4.28", + "version": "v3.4.29", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "a088aafcefb4eef2520a290ed82e4374092a6dff" + "reference": "f18fdd6cc7006441865e698420cee26bac94741f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a088aafcefb4eef2520a290ed82e4374092a6dff", - "reference": "a088aafcefb4eef2520a290ed82e4374092a6dff", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f18fdd6cc7006441865e698420cee26bac94741f", + "reference": "f18fdd6cc7006441865e698420cee26bac94741f", "shasum": "" }, "require": { @@ -1354,20 +1354,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-04-02T08:51:52+00:00" + "time": "2019-06-25T07:45:31+00:00" }, { "name": "symfony/filesystem", - "version": "v3.4.28", + "version": "v3.4.29", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "acf99758b1df8e9295e6b85aa69f294565c9fedb" + "reference": "70adda061ef83bb7def63a17953dc41f203308a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/acf99758b1df8e9295e6b85aa69f294565c9fedb", - "reference": "acf99758b1df8e9295e6b85aa69f294565c9fedb", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/70adda061ef83bb7def63a17953dc41f203308a7", + "reference": "70adda061ef83bb7def63a17953dc41f203308a7", "shasum": "" }, "require": { @@ -1404,20 +1404,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2019-02-04T21:34:32+00:00" + "time": "2019-06-23T09:29:17+00:00" }, { "name": "symfony/finder", - "version": "v3.4.28", + "version": "v3.4.29", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "fa5d962a71f2169dfe1cbae217fa5a2799859f6c" + "reference": "5f80266a729e30bbcc37f8bf0e62c3d5a38c8208" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/fa5d962a71f2169dfe1cbae217fa5a2799859f6c", - "reference": "fa5d962a71f2169dfe1cbae217fa5a2799859f6c", + "url": "https://api.github.com/repos/symfony/finder/zipball/5f80266a729e30bbcc37f8bf0e62c3d5a38c8208", + "reference": "5f80266a729e30bbcc37f8bf0e62c3d5a38c8208", "shasum": "" }, "require": { @@ -1453,7 +1453,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-05-24T12:25:55+00:00" + "time": "2019-05-30T15:47:52+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1574,16 +1574,16 @@ }, { "name": "symfony/process", - "version": "v3.4.28", + "version": "v3.4.29", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "afe411c2a6084f25cff55a01d0d4e1474c97ff13" + "reference": "d129c017e8602507688ef2c3007951a16c1a8407" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/afe411c2a6084f25cff55a01d0d4e1474c97ff13", - "reference": "afe411c2a6084f25cff55a01d0d4e1474c97ff13", + "url": "https://api.github.com/repos/symfony/process/zipball/d129c017e8602507688ef2c3007951a16c1a8407", + "reference": "d129c017e8602507688ef2c3007951a16c1a8407", "shasum": "" }, "require": { @@ -1619,11 +1619,11 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2019-05-22T12:54:11+00:00" + "time": "2019-05-30T15:47:52+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.28", + "version": "v3.4.29", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", From 381d5d848ac0b1373ad3004dbfb02a0408df19fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 8 Jul 2019 14:47:53 +0200 Subject: [PATCH 7/7] Add 2.5.2 version definition --- plugin.xml | 4 ++++ setup.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 9a4df124f8..9bbbce7257 100644 --- a/plugin.xml +++ b/plugin.xml @@ -28,6 +28,10 @@ Benjamin Fontan + + 2.5.2 + 9.4 + 2.5.1 9.4 diff --git a/setup.php b/setup.php index 76791fb9f5..c50fc43b06 100644 --- a/setup.php +++ b/setup.php @@ -34,7 +34,7 @@ @since 2009 ---------------------------------------------------------------------- */ -define('PLUGIN_ORDER_VERSION', '2.5.1'); +define('PLUGIN_ORDER_VERSION', '2.5.2'); // Minimal GLPI version, inclusive define("PLUGIN_ORDER_MIN_GLPI", "9.4");