From ee01fcd49fdd9e0140fd2b09e77c94e05231ed6f Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Thu, 9 Apr 2026 15:24:51 +0200 Subject: [PATCH 1/8] Prepare for next version of plugin Reports --- report/deliveryinfos/deliveryinfos.php | 31 +++++++---- report/orderdelivery/orderdelivery.php | 71 +++++++++++++++++--------- setup.php | 8 +++ 3 files changed, 75 insertions(+), 35 deletions(-) diff --git a/report/deliveryinfos/deliveryinfos.php b/report/deliveryinfos/deliveryinfos.php index b63e36e3d8..0975351323 100644 --- a/report/deliveryinfos/deliveryinfos.php +++ b/report/deliveryinfos/deliveryinfos.php @@ -39,17 +39,24 @@ */ //Options for GLPI 0.71 and newer : need slave db to access the report +use GlpiPlugin\Reports\AutoReport; +use GlpiPlugin\Reports\ColumnInteger; +use GlpiPlugin\Reports\ColumnLink; +use GlpiPlugin\Reports\DateIntervalCriteria; +use GlpiPlugin\Reports\DropdownCriteria; +use GlpiPlugin\Reports\LocationCriteria; +use GlpiPlugin\Reports\SupplierCriteria; + $USEDBREPLICATE = 1; $DBCONNECTION_REQUIRED = 0; // Really a big SQL request -include(__DIR__ . "/../../../../inc/includes.php"); -$report = new PluginReportsAutoReport(__s("deliveryinfos_report_title", "order")); -new PluginReportsDateIntervalCriteria($report, 'order_date', __s("Date of order", "order")); -new PluginReportsDateIntervalCriteria($report, 'deliverydate', __s("Delivery date")); -new PluginReportsLocationCriteria($report, 'locations_id', __s("Delivery location", "order")); -new PluginReportsSupplierCriteria($report, 'suppliers_id', __s("Supplier")); -new PluginReportsDropdownCriteria( +$report = new AutoReport(__s("Orders delivery statistics", "order")); +new DateIntervalCriteria($report, 'order_date', __s("Date of order", "order")); +new DateIntervalCriteria($report, 'deliverydate', __s("Delivery date")); +new LocationCriteria($report, 'locations_id', __s("Delivery location", "order")); +new SupplierCriteria($report, 'suppliers_id', __s("Supplier")); +new DropdownCriteria( $report, 'plugin_order_orderstates_id', 'PluginOrderOrderState', @@ -61,18 +68,18 @@ $report->setSubNameAuto(); $report->setColumns([ - new PluginReportsColumnLink( + new ColumnLink( 'suppliers_id', __s("Supplier"), 'Supplier', ), - new PluginReportsColumnLink( + new ColumnLink( 'entities_id', __s("Entity"), 'Entity', ), - new PluginReportsColumnInteger('total', __s("Orders total", "order")), - new PluginReportsColumnInteger('late', __s("Late orders total", "order")), + new ColumnInteger('total', __s("Orders total", "order")), + new ColumnInteger('late', __s("Late orders total", "order")), ]); //TODO : ne pas chercher dans la poublelles @@ -93,4 +100,6 @@ $report->setGroupBy("suppliers_id"); $report->setSqlRequest($query); $report->execute(); + + $report->footer(); } diff --git a/report/orderdelivery/orderdelivery.php b/report/orderdelivery/orderdelivery.php index cfd9449bb9..3eaad6f0f4 100644 --- a/report/orderdelivery/orderdelivery.php +++ b/report/orderdelivery/orderdelivery.php @@ -39,17 +39,25 @@ */ //Options for GLPI 0.71 and newer : need slave db to access the report +use GlpiPlugin\Reports\AutoReport; +use GlpiPlugin\Reports\Column; +use GlpiPlugin\Reports\ColumnDateTime; +use GlpiPlugin\Reports\ColumnLink; +use GlpiPlugin\Reports\DateIntervalCriteria; +use GlpiPlugin\Reports\DropdownCriteria; +use GlpiPlugin\Reports\LocationCriteria; +use GlpiPlugin\Reports\SupplierCriteria; + $USEDBREPLICATE = 1; $DBCONNECTION_REQUIRED = 0; // Really a big SQL request -include(__DIR__ . "/../../../../inc/includes.php"); +$report = new AutoReport(__s("Orders delivery", "order")); -$report = new PluginReportsAutoReport(__s("orderdelivery_report_title", "order")); -new PluginReportsDateIntervalCriteria($report, 'order_date', __s("Date of order", "order")); -new PluginReportsDateIntervalCriteria($report, 'deliverydate', __s("Delivery date")); -new PluginReportsLocationCriteria($report, 'locations_id', __s("Delivery location", "order")); -new PluginReportsSupplierCriteria($report, 'suppliers_id', __s("Supplier")); -new PluginReportsDropdownCriteria( +new DateIntervalCriteria($report, 'order_date', __s("Date of order", "order")); +new DateIntervalCriteria($report, 'deliverydate', __s("Delivery date")); +new LocationCriteria($report, 'locations_id', __s("Delivery location", "order")); +new SupplierCriteria($report, 'suppliers_id', __s("Supplier")); +new DropdownCriteria( $report, 'plugin_order_orderstates_id', 'PluginOrderOrderState', @@ -61,12 +69,12 @@ $report->setSubNameAuto(); $report->setColumns([ - new PluginReportsColumnLink( + new ColumnLink( 'entities_id', __s("Entity"), 'Entity', ), - new PluginReportsColumnLink( + new ColumnLink( 'id', __s("Name"), 'PluginOrderOrder', @@ -75,22 +83,22 @@ 'with_navigate' => true, ], ), - new PluginReportsColumn('num_order', __s("Order number", "order")), - new PluginReportsColumnLink( + new Column('num_order', __s("Order number", "order")), + new ColumnLink( 'suppliers_id', __s("Supplier"), 'Supplier', ), - new PluginReportsColumnLink( + new ColumnLink( 'plugin_order_orderstates_id', __s("Status"), 'PluginOrderOrderState', ['with_comment' => true], ), - new PluginReportsColumnDateTime('order_date', __s("Date of order", "order")), - new PluginReportsColumnDateTime('duedate', __s("Estimated due date", "order")), - new PluginReportsColumnDateTime('deliverydate', __s("Delivery date")), - new PluginReportsColumnLink( + new ColumnDateTime('order_date', __s("Date of order", "order")), + new ColumnDateTime('duedate', __s("Estimated due date", "order")), + new ColumnDateTime('deliverydate', __s("Delivery date")), + new ColumnLink( 'locations_id', __s("Delivery location", "order"), 'Location', @@ -98,13 +106,28 @@ ), ]); - //TODO : ne pas chercher dans la poublelles - $query = "SELECT * FROM `glpi_plugin_order_orders`"; - $query .= getEntitiesRestrictRequest(" WHERE", "glpi_plugin_order_orders"); - $query .= $report->addSqlCriteriasRestriction(); - $query .= " AND `is_deleted`='0' AND `is_template`='0' "; - $query .= "GROUP BY `entities_id`, `plugin_order_orderstates_id`, `num_order`, `order_date`"; - $report->setGroupBy("entities_id", "plugin_order_orderstates_id", "num_order", "order_date"); - $report->setSqlRequest($query); + $criteria = [ + 'SELECT' => [ + '*', + ], + 'FROM' => 'glpi_plugin_order_orders', + 'WHERE' => [ + 'is_deleted' => 0, + 'is_template' => 0, + ], + 'GROUPBY' => ['entities_id', 'plugin_order_orderstates_id', 'num_order', 'order_date'], + ]; + + $criteria['WHERE'] = $criteria['WHERE'] + getEntitiesRestrictCriteria( + 'glpi_plugin_order_orders' + ); + + $criteria['WHERE'] = $criteria['WHERE'] + $report->addNewSqlCriteriasRestriction(); + + $report->setSqlRequest($criteria); + $report->execute(); } + +$report->footer(); + diff --git a/setup.php b/setup.php index 7cd7cfd6b0..3d7137ed97 100644 --- a/setup.php +++ b/setup.php @@ -29,6 +29,7 @@ */ use function Safe\define; +use GlpiPlugin\Reports\Report; define('PLUGIN_ORDER_VERSION', '2.12.6'); @@ -189,6 +190,13 @@ function plugin_init_order() $PLUGIN_HOOKS['assign_to_ticket']['order'] = true; $PLUGIN_HOOKS['use_massive_action']['order'] = 1; $PLUGIN_HOOKS['plugin_datainjection_populate']['order'] = "plugin_datainjection_populate_order"; + + if (class_exists(Report::class)) { + Report::setReportsTitles( + ["deliveryinfos" => __s("Orders delivery statistics", "order"), + "orderdelivery" => __s("Orders delivery", "order"), + ]); + } } } } From c34f126293a9060dc6a97f37fd08ea4693a70efa Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Thu, 9 Apr 2026 15:27:52 +0200 Subject: [PATCH 2/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 233952fe40..ffa27f1761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix generate associated item massive action - Update locales - +- Migration of reports to next version of plugin Reports ## [2.12.6] - 2026-02-23 From 2252b57e21bb75c0b95c4507935b8d60a0d11a5b Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Thu, 9 Apr 2026 15:50:37 +0200 Subject: [PATCH 3/8] Fix Raw Query --- hook.php | 122 ++++++++++++------------- report/deliveryinfos/deliveryinfos.php | 70 ++++++++++---- 2 files changed, 114 insertions(+), 78 deletions(-) diff --git a/hook.php b/hook.php index b28c79e1ed..1c94b7e800 100644 --- a/hook.php +++ b/hook.php @@ -40,67 +40,67 @@ */ function plugin_order_install() { - foreach (glob(PLUGIN_ORDER_DIR . '/inc/*.php') as $file) { - //Do not load datainjection files (not needed and avoid missing class error message) - if (preg_match('/injection.class.php/', $file) === 0) { - include_once($file); - } - } - - echo "
"; - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo "
" . __s("Plugin installation or upgrade", "order") . "
"; - - $migration = new Migration(PLUGIN_ORDER_VERSION); - $classes = ['PluginOrderConfig', 'PluginOrderBillState', 'PluginOrderBillType', - 'PluginOrderOrderState', 'PluginOrderOrder','PluginOrderOrder_Item', - 'PluginOrderReference', 'PluginOrderDeliverystate', - 'PluginOrderNotificationTargetOrder', - 'PluginOrderOrder_Supplier', 'PluginOrderBill', 'PluginOrderOrderPayment', - 'PluginOrderOrdertype', 'PluginOrderOther', 'PluginOrderOthertype', - 'PluginOrderPreference', 'PluginOrderProfile', 'PluginOrderReference_Supplier', - 'PluginOrderSurveySupplier', 'PluginOrderOrderTax', 'PluginOrderDocumentCategory', - 'PluginOrderReferenceFree', 'PluginOrderAccountsection', - 'PluginOrderAnalyticnature', - ]; - foreach ($classes as $class) { - if ($plug = isPluginItemType($class)) { - $plugname = strtolower((string) $plug['plugin']); - $dir = Plugin::getPhpDir($plugname) . "/inc/"; - $item = strtolower((string) $plug['class']); - if (file_exists(sprintf('%s%s.class.php', $dir, $item))) { - include_once(sprintf('%s%s.class.php', $dir, $item)); - call_user_func([$class, 'install'], $migration); - } - } - } - - echo "
"; - echo "
"; - - //Create directories for the plugin's files - $directories = [PLUGIN_ORDER_TEMPLATE_DIR => 'templates', - PLUGIN_ORDER_SIGNATURE_DIR => 'signatures', - PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR => 'generate', - PLUGIN_ORDER_TEMPLATE_LOGO_DIR => 'logo', - ]; - foreach ($directories as $new_directory => $old_directory) { - if (!is_dir($new_directory)) { - @mkdir($new_directory, 0755, true); - //Copy files from the old directories to the new ones - foreach (glob(PLUGIN_ORDER_DIR . sprintf('/%s/*', $old_directory)) as $file) { - $new_file = str_replace(PLUGIN_ORDER_DIR . ('/' . $old_directory), $new_directory, $file); - if (!file_exists($new_directory . $file)) { - copy($file, $new_file); - } - } - } - } +// foreach (glob(PLUGIN_ORDER_DIR . '/inc/*.php') as $file) { +// //Do not load datainjection files (not needed and avoid missing class error message) +// if (preg_match('/injection.class.php/', $file) === 0) { +// include_once($file); +// } +// } +// +// echo "
"; +// echo ""; +// echo ""; +// +// echo ""; +// echo ""; +// echo ""; +// echo "
" . __s("Plugin installation or upgrade", "order") . "
"; +// +// $migration = new Migration(PLUGIN_ORDER_VERSION); +// $classes = ['PluginOrderConfig', 'PluginOrderBillState', 'PluginOrderBillType', +// 'PluginOrderOrderState', 'PluginOrderOrder','PluginOrderOrder_Item', +// 'PluginOrderReference', 'PluginOrderDeliverystate', +// 'PluginOrderNotificationTargetOrder', +// 'PluginOrderOrder_Supplier', 'PluginOrderBill', 'PluginOrderOrderPayment', +// 'PluginOrderOrdertype', 'PluginOrderOther', 'PluginOrderOthertype', +// 'PluginOrderPreference', 'PluginOrderProfile', 'PluginOrderReference_Supplier', +// 'PluginOrderSurveySupplier', 'PluginOrderOrderTax', 'PluginOrderDocumentCategory', +// 'PluginOrderReferenceFree', 'PluginOrderAccountsection', +// 'PluginOrderAnalyticnature', +// ]; +// foreach ($classes as $class) { +// if ($plug = isPluginItemType($class)) { +// $plugname = strtolower((string) $plug['plugin']); +// $dir = Plugin::getPhpDir($plugname) . "/inc/"; +// $item = strtolower((string) $plug['class']); +// if (file_exists(sprintf('%s%s.class.php', $dir, $item))) { +// include_once(sprintf('%s%s.class.php', $dir, $item)); +// call_user_func([$class, 'install'], $migration); +// } +// } +// } +// +// echo "
"; +// echo "
"; +// +// //Create directories for the plugin's files +// $directories = [PLUGIN_ORDER_TEMPLATE_DIR => 'templates', +// PLUGIN_ORDER_SIGNATURE_DIR => 'signatures', +// PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR => 'generate', +// PLUGIN_ORDER_TEMPLATE_LOGO_DIR => 'logo', +// ]; +// foreach ($directories as $new_directory => $old_directory) { +// if (!is_dir($new_directory)) { +// @mkdir($new_directory, 0755, true); +// //Copy files from the old directories to the new ones +// foreach (glob(PLUGIN_ORDER_DIR . sprintf('/%s/*', $old_directory)) as $file) { +// $new_file = str_replace(PLUGIN_ORDER_DIR . ('/' . $old_directory), $new_directory, $file); +// if (!file_exists($new_directory . $file)) { +// copy($file, $new_file); +// } +// } +// } +// } return true; } diff --git a/report/deliveryinfos/deliveryinfos.php b/report/deliveryinfos/deliveryinfos.php index 0975351323..77488e3b3b 100644 --- a/report/deliveryinfos/deliveryinfos.php +++ b/report/deliveryinfos/deliveryinfos.php @@ -39,6 +39,9 @@ */ //Options for GLPI 0.71 and newer : need slave db to access the report +use Glpi\DBAL\QueryExpression; +use Glpi\DBAL\QuerySubQuery; + use GlpiPlugin\Reports\AutoReport; use GlpiPlugin\Reports\ColumnInteger; use GlpiPlugin\Reports\ColumnLink; @@ -50,7 +53,6 @@ $USEDBREPLICATE = 1; $DBCONNECTION_REQUIRED = 0; // Really a big SQL request - $report = new AutoReport(__s("Orders delivery statistics", "order")); new DateIntervalCriteria($report, 'order_date', __s("Date of order", "order")); new DateIntervalCriteria($report, 'deliverydate', __s("Delivery date")); @@ -81,25 +83,59 @@ new ColumnInteger('total', __s("Orders total", "order")), new ColumnInteger('late', __s("Late orders total", "order")), ]); - //TODO : ne pas chercher dans la poublelles - $query_total = "SELECT count(*) FROM `glpi_plugin_order_orders`"; - $query_total .= getEntitiesRestrictRequest(" WHERE", "glpi_plugin_order_orders"); - $query_total .= $report->addSqlCriteriasRestriction(); - $query_total .= "AND `glpi_plugin_order_orders`.`suppliers_id`=`suppliers`.`id`"; - $query_late = $query_total . " AND `is_late`='1' AND `is_deleted`='0' AND `is_template`='0'"; + $criteria_total = [ + 'SELECT' => [ + 'COUNT' => 'glpi_plugin_order_orders.id' + ], + 'FROM' => 'glpi_plugin_order_orders', + 'WHERE' => ['glpi_plugin_order_orders.is_deleted' => '0', + 'glpi_plugin_order_orders.is_template' => '0', + 'glpi_plugin_order_orders.suppliers_id' => new QueryExpression('suppliers.id')], + ]; - $supplier = "JOIN `glpi_suppliers`as suppliers - ON (`glpi_plugin_order_orders`.`suppliers_id` = suppliers.`id`)"; + $criteria_total['WHERE'] = $criteria_total['WHERE'] + getEntitiesRestrictCriteria( + 'glpi_plugin_order_orders' + ); + $criteria_total['WHERE'] = $criteria_total['WHERE'] + $report->addNewSqlCriteriasRestriction(); - $query = "SELECT DISTINCT `suppliers_id`, ({$query_total}) AS `total`, ({$query_late}) AS `late` - FROM `glpi_plugin_order_orders` {$supplier}"; - $query .= getEntitiesRestrictRequest(" WHERE", "glpi_plugin_order_orders"); - $query .= $report->addSqlCriteriasRestriction(); - $report->setGroupBy("suppliers_id"); - $report->setSqlRequest($query); - $report->execute(); + $criteria_late = $criteria_total; + $criteria_late['WHERE'] += [ + 'glpi_plugin_order_orders.is_late' => 1 + ]; + + $criteria = [ + 'SELECT' => [ + 'glpi_plugin_order_orders.suppliers_id', + new QuerySubQuery($criteria_total, 'total'), + new QuerySubQuery($criteria_late, 'late') + + ], + 'DISTINCT' => true, + 'FROM' => 'glpi_plugin_order_orders', + 'LEFT JOIN' => [ + 'glpi_suppliers as suppliers' => [ + 'ON' => [ + 'glpi_plugin_order_orders' => 'suppliers_id', + 'suppliers' => 'id' + ] + ] + ], + 'WHERE' => ['glpi_plugin_order_orders.is_deleted' => '0', + 'glpi_plugin_order_orders.is_template' => '0'], + 'GROUPBY' => ['suppliers_id'], + ]; - $report->footer(); + $criteria['WHERE'] = $criteria['WHERE'] + getEntitiesRestrictCriteria( + 'glpi_plugin_order_orders' + ); + + $criteria['WHERE'] = $criteria['WHERE'] + $report->addNewSqlCriteriasRestriction(); + + $report->setSqlRequest($criteria); + + $report->execute(); } + +$report->footer(); From 2f98a828868027913d6dc87dc040c52dab3e420a Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Thu, 9 Apr 2026 15:52:41 +0200 Subject: [PATCH 4/8] Clean raw queries --- report/deliveryinfos/deliveryinfos.php | 16 ++++++++-------- report/orderdelivery/orderdelivery.php | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/report/deliveryinfos/deliveryinfos.php b/report/deliveryinfos/deliveryinfos.php index 77488e3b3b..357df04ff2 100644 --- a/report/deliveryinfos/deliveryinfos.php +++ b/report/deliveryinfos/deliveryinfos.php @@ -94,11 +94,11 @@ 'glpi_plugin_order_orders.suppliers_id' => new QueryExpression('suppliers.id')], ]; - $criteria_total['WHERE'] = $criteria_total['WHERE'] + getEntitiesRestrictCriteria( - 'glpi_plugin_order_orders' - ); + $criteria_total['WHERE'] += getEntitiesRestrictCriteria( + 'glpi_plugin_order_orders' + ); - $criteria_total['WHERE'] = $criteria_total['WHERE'] + $report->addNewSqlCriteriasRestriction(); + $criteria_total['WHERE'] += $report->addNewSqlCriteriasRestriction(); $criteria_late = $criteria_total; $criteria_late['WHERE'] += [ @@ -127,11 +127,11 @@ 'GROUPBY' => ['suppliers_id'], ]; - $criteria['WHERE'] = $criteria['WHERE'] + getEntitiesRestrictCriteria( - 'glpi_plugin_order_orders' - ); + $criteria['WHERE'] += getEntitiesRestrictCriteria( + 'glpi_plugin_order_orders' + ); - $criteria['WHERE'] = $criteria['WHERE'] + $report->addNewSqlCriteriasRestriction(); + $criteria['WHERE'] += $report->addNewSqlCriteriasRestriction(); $report->setSqlRequest($criteria); diff --git a/report/orderdelivery/orderdelivery.php b/report/orderdelivery/orderdelivery.php index 3eaad6f0f4..8e029e90ad 100644 --- a/report/orderdelivery/orderdelivery.php +++ b/report/orderdelivery/orderdelivery.php @@ -118,11 +118,11 @@ 'GROUPBY' => ['entities_id', 'plugin_order_orderstates_id', 'num_order', 'order_date'], ]; - $criteria['WHERE'] = $criteria['WHERE'] + getEntitiesRestrictCriteria( - 'glpi_plugin_order_orders' - ); + $criteria['WHERE'] += getEntitiesRestrictCriteria( + 'glpi_plugin_order_orders' + ); - $criteria['WHERE'] = $criteria['WHERE'] + $report->addNewSqlCriteriasRestriction(); + $criteria['WHERE'] += $report->addNewSqlCriteriasRestriction(); $report->setSqlRequest($criteria); From c34ccf5639258cda70b6814d5deaf9b9390c2492 Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Thu, 9 Apr 2026 15:58:57 +0200 Subject: [PATCH 5/8] Revert modification --- hook.php | 122 +++++++++++++++++++++++++++---------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/hook.php b/hook.php index 1c94b7e800..b28c79e1ed 100644 --- a/hook.php +++ b/hook.php @@ -40,67 +40,67 @@ */ function plugin_order_install() { -// foreach (glob(PLUGIN_ORDER_DIR . '/inc/*.php') as $file) { -// //Do not load datainjection files (not needed and avoid missing class error message) -// if (preg_match('/injection.class.php/', $file) === 0) { -// include_once($file); -// } -// } -// -// echo "
"; -// echo ""; -// echo ""; -// -// echo ""; -// echo ""; -// echo ""; -// echo "
" . __s("Plugin installation or upgrade", "order") . "
"; -// -// $migration = new Migration(PLUGIN_ORDER_VERSION); -// $classes = ['PluginOrderConfig', 'PluginOrderBillState', 'PluginOrderBillType', -// 'PluginOrderOrderState', 'PluginOrderOrder','PluginOrderOrder_Item', -// 'PluginOrderReference', 'PluginOrderDeliverystate', -// 'PluginOrderNotificationTargetOrder', -// 'PluginOrderOrder_Supplier', 'PluginOrderBill', 'PluginOrderOrderPayment', -// 'PluginOrderOrdertype', 'PluginOrderOther', 'PluginOrderOthertype', -// 'PluginOrderPreference', 'PluginOrderProfile', 'PluginOrderReference_Supplier', -// 'PluginOrderSurveySupplier', 'PluginOrderOrderTax', 'PluginOrderDocumentCategory', -// 'PluginOrderReferenceFree', 'PluginOrderAccountsection', -// 'PluginOrderAnalyticnature', -// ]; -// foreach ($classes as $class) { -// if ($plug = isPluginItemType($class)) { -// $plugname = strtolower((string) $plug['plugin']); -// $dir = Plugin::getPhpDir($plugname) . "/inc/"; -// $item = strtolower((string) $plug['class']); -// if (file_exists(sprintf('%s%s.class.php', $dir, $item))) { -// include_once(sprintf('%s%s.class.php', $dir, $item)); -// call_user_func([$class, 'install'], $migration); -// } -// } -// } -// -// echo "
"; -// echo "
"; -// -// //Create directories for the plugin's files -// $directories = [PLUGIN_ORDER_TEMPLATE_DIR => 'templates', -// PLUGIN_ORDER_SIGNATURE_DIR => 'signatures', -// PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR => 'generate', -// PLUGIN_ORDER_TEMPLATE_LOGO_DIR => 'logo', -// ]; -// foreach ($directories as $new_directory => $old_directory) { -// if (!is_dir($new_directory)) { -// @mkdir($new_directory, 0755, true); -// //Copy files from the old directories to the new ones -// foreach (glob(PLUGIN_ORDER_DIR . sprintf('/%s/*', $old_directory)) as $file) { -// $new_file = str_replace(PLUGIN_ORDER_DIR . ('/' . $old_directory), $new_directory, $file); -// if (!file_exists($new_directory . $file)) { -// copy($file, $new_file); -// } -// } -// } -// } + foreach (glob(PLUGIN_ORDER_DIR . '/inc/*.php') as $file) { + //Do not load datainjection files (not needed and avoid missing class error message) + if (preg_match('/injection.class.php/', $file) === 0) { + include_once($file); + } + } + + echo "
"; + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo "
" . __s("Plugin installation or upgrade", "order") . "
"; + + $migration = new Migration(PLUGIN_ORDER_VERSION); + $classes = ['PluginOrderConfig', 'PluginOrderBillState', 'PluginOrderBillType', + 'PluginOrderOrderState', 'PluginOrderOrder','PluginOrderOrder_Item', + 'PluginOrderReference', 'PluginOrderDeliverystate', + 'PluginOrderNotificationTargetOrder', + 'PluginOrderOrder_Supplier', 'PluginOrderBill', 'PluginOrderOrderPayment', + 'PluginOrderOrdertype', 'PluginOrderOther', 'PluginOrderOthertype', + 'PluginOrderPreference', 'PluginOrderProfile', 'PluginOrderReference_Supplier', + 'PluginOrderSurveySupplier', 'PluginOrderOrderTax', 'PluginOrderDocumentCategory', + 'PluginOrderReferenceFree', 'PluginOrderAccountsection', + 'PluginOrderAnalyticnature', + ]; + foreach ($classes as $class) { + if ($plug = isPluginItemType($class)) { + $plugname = strtolower((string) $plug['plugin']); + $dir = Plugin::getPhpDir($plugname) . "/inc/"; + $item = strtolower((string) $plug['class']); + if (file_exists(sprintf('%s%s.class.php', $dir, $item))) { + include_once(sprintf('%s%s.class.php', $dir, $item)); + call_user_func([$class, 'install'], $migration); + } + } + } + + echo "
"; + echo "
"; + + //Create directories for the plugin's files + $directories = [PLUGIN_ORDER_TEMPLATE_DIR => 'templates', + PLUGIN_ORDER_SIGNATURE_DIR => 'signatures', + PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR => 'generate', + PLUGIN_ORDER_TEMPLATE_LOGO_DIR => 'logo', + ]; + foreach ($directories as $new_directory => $old_directory) { + if (!is_dir($new_directory)) { + @mkdir($new_directory, 0755, true); + //Copy files from the old directories to the new ones + foreach (glob(PLUGIN_ORDER_DIR . sprintf('/%s/*', $old_directory)) as $file) { + $new_file = str_replace(PLUGIN_ORDER_DIR . ('/' . $old_directory), $new_directory, $file); + if (!file_exists($new_directory . $file)) { + copy($file, $new_file); + } + } + } + } return true; } From a181bcf41acddf937318583c20ef8d9c3007a1d7 Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Thu, 9 Apr 2026 16:48:05 +0200 Subject: [PATCH 6/8] CS Fixer --- report/deliveryinfos/deliveryinfos.php | 1 - report/orderdelivery/orderdelivery.php | 1 - setup.php | 6 ++++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/report/deliveryinfos/deliveryinfos.php b/report/deliveryinfos/deliveryinfos.php index 357df04ff2..fdae05365c 100644 --- a/report/deliveryinfos/deliveryinfos.php +++ b/report/deliveryinfos/deliveryinfos.php @@ -41,7 +41,6 @@ //Options for GLPI 0.71 and newer : need slave db to access the report use Glpi\DBAL\QueryExpression; use Glpi\DBAL\QuerySubQuery; - use GlpiPlugin\Reports\AutoReport; use GlpiPlugin\Reports\ColumnInteger; use GlpiPlugin\Reports\ColumnLink; diff --git a/report/orderdelivery/orderdelivery.php b/report/orderdelivery/orderdelivery.php index 8e029e90ad..62c59a3c3b 100644 --- a/report/orderdelivery/orderdelivery.php +++ b/report/orderdelivery/orderdelivery.php @@ -130,4 +130,3 @@ } $report->footer(); - diff --git a/setup.php b/setup.php index 3d7137ed97..a64eb2e79d 100644 --- a/setup.php +++ b/setup.php @@ -28,9 +28,10 @@ * ------------------------------------------------------------------------- */ -use function Safe\define; use GlpiPlugin\Reports\Report; +use function Safe\define; + define('PLUGIN_ORDER_VERSION', '2.12.6'); // Minimal GLPI version, inclusive @@ -195,7 +196,8 @@ function plugin_init_order() Report::setReportsTitles( ["deliveryinfos" => __s("Orders delivery statistics", "order"), "orderdelivery" => __s("Orders delivery", "order"), - ]); + ], + ); } } } From 7e6273aa306f51baec35a1eeab641a44836e7154 Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Fri, 10 Apr 2026 09:29:56 +0200 Subject: [PATCH 7/8] CS fixer --- report/deliveryinfos/deliveryinfos.php | 18 +++++++++++------- report/orderdelivery/orderdelivery.php | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/report/deliveryinfos/deliveryinfos.php b/report/deliveryinfos/deliveryinfos.php index fdae05365c..efed4185cc 100644 --- a/report/deliveryinfos/deliveryinfos.php +++ b/report/deliveryinfos/deliveryinfos.php @@ -88,9 +88,11 @@ 'COUNT' => 'glpi_plugin_order_orders.id' ], 'FROM' => 'glpi_plugin_order_orders', - 'WHERE' => ['glpi_plugin_order_orders.is_deleted' => '0', + 'WHERE' => [ + 'glpi_plugin_order_orders.is_deleted' => '0', 'glpi_plugin_order_orders.is_template' => '0', - 'glpi_plugin_order_orders.suppliers_id' => new QueryExpression('suppliers.id')], + 'glpi_plugin_order_orders.suppliers_id' => new QueryExpression('suppliers.id') + ], ]; $criteria_total['WHERE'] += getEntitiesRestrictCriteria( @@ -111,18 +113,20 @@ new QuerySubQuery($criteria_late, 'late') ], - 'DISTINCT' => true, + 'DISTINCT' => true, 'FROM' => 'glpi_plugin_order_orders', - 'LEFT JOIN' => [ + 'LEFT JOIN' => [ 'glpi_suppliers as suppliers' => [ 'ON' => [ 'glpi_plugin_order_orders' => 'suppliers_id', - 'suppliers' => 'id' + 'suppliers' => 'id' ] ] ], - 'WHERE' => ['glpi_plugin_order_orders.is_deleted' => '0', - 'glpi_plugin_order_orders.is_template' => '0'], + 'WHERE' => [ + 'glpi_plugin_order_orders.is_deleted' => '0', + 'glpi_plugin_order_orders.is_template' => '0' + ], 'GROUPBY' => ['suppliers_id'], ]; diff --git a/report/orderdelivery/orderdelivery.php b/report/orderdelivery/orderdelivery.php index 62c59a3c3b..c80f81ebe9 100644 --- a/report/orderdelivery/orderdelivery.php +++ b/report/orderdelivery/orderdelivery.php @@ -79,7 +79,7 @@ __s("Name"), 'PluginOrderOrder', [ - 'with_comment' => true, + 'with_comment' => true, 'with_navigate' => true, ], ), From 1409bc1a8100daa0aa81f93b723af24e162fe400 Mon Sep 17 00:00:00 2001 From: Thetsmr Date: Fri, 10 Apr 2026 09:36:09 +0200 Subject: [PATCH 8/8] CS Fixer --- report/deliveryinfos/deliveryinfos.php | 20 ++++++++++---------- report/orderdelivery/orderdelivery.php | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/report/deliveryinfos/deliveryinfos.php b/report/deliveryinfos/deliveryinfos.php index efed4185cc..7644ec1987 100644 --- a/report/deliveryinfos/deliveryinfos.php +++ b/report/deliveryinfos/deliveryinfos.php @@ -85,32 +85,32 @@ $criteria_total = [ 'SELECT' => [ - 'COUNT' => 'glpi_plugin_order_orders.id' + 'COUNT' => 'glpi_plugin_order_orders.id', ], 'FROM' => 'glpi_plugin_order_orders', 'WHERE' => [ 'glpi_plugin_order_orders.is_deleted' => '0', 'glpi_plugin_order_orders.is_template' => '0', - 'glpi_plugin_order_orders.suppliers_id' => new QueryExpression('suppliers.id') + 'glpi_plugin_order_orders.suppliers_id' => new QueryExpression('suppliers.id'), ], ]; $criteria_total['WHERE'] += getEntitiesRestrictCriteria( - 'glpi_plugin_order_orders' + 'glpi_plugin_order_orders', ); $criteria_total['WHERE'] += $report->addNewSqlCriteriasRestriction(); $criteria_late = $criteria_total; $criteria_late['WHERE'] += [ - 'glpi_plugin_order_orders.is_late' => 1 + 'glpi_plugin_order_orders.is_late' => 1, ]; $criteria = [ 'SELECT' => [ 'glpi_plugin_order_orders.suppliers_id', new QuerySubQuery($criteria_total, 'total'), - new QuerySubQuery($criteria_late, 'late') + new QuerySubQuery($criteria_late, 'late'), ], 'DISTINCT' => true, @@ -119,19 +119,19 @@ 'glpi_suppliers as suppliers' => [ 'ON' => [ 'glpi_plugin_order_orders' => 'suppliers_id', - 'suppliers' => 'id' - ] - ] + 'suppliers' => 'id', + ], + ], ], 'WHERE' => [ 'glpi_plugin_order_orders.is_deleted' => '0', - 'glpi_plugin_order_orders.is_template' => '0' + 'glpi_plugin_order_orders.is_template' => '0', ], 'GROUPBY' => ['suppliers_id'], ]; $criteria['WHERE'] += getEntitiesRestrictCriteria( - 'glpi_plugin_order_orders' + 'glpi_plugin_order_orders', ); $criteria['WHERE'] += $report->addNewSqlCriteriasRestriction(); diff --git a/report/orderdelivery/orderdelivery.php b/report/orderdelivery/orderdelivery.php index c80f81ebe9..9a627e35ce 100644 --- a/report/orderdelivery/orderdelivery.php +++ b/report/orderdelivery/orderdelivery.php @@ -119,7 +119,7 @@ ]; $criteria['WHERE'] += getEntitiesRestrictCriteria( - 'glpi_plugin_order_orders' + 'glpi_plugin_order_orders', ); $criteria['WHERE'] += $report->addNewSqlCriteriasRestriction();