diff --git a/composer.json b/composer.json index 85fd8e6d03..627ec522f2 100644 --- a/composer.json +++ b/composer.json @@ -4,13 +4,7 @@ "masnathan/odtphp": "dev-teclib" }, "require-dev": { - "friendsoftwig/twigcs": "^6.1", - "glpi-project/phpstan-glpi": "^1.1", "glpi-project/tools": "^0.8", - "php-parallel-lint/php-parallel-lint": "^1.4", - "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.1", - "phpstan/phpstan-deprecation-rules": "^2.0", "squizlabs/php_codesniffer": "^3.13" }, "config": { @@ -18,10 +12,7 @@ "platform": { "php": "7.4.0" }, - "sort-packages": true, - "allow-plugins": { - "phpstan/extension-installer": true - } + "sort-packages": true }, "repositories": [ { diff --git a/composer.lock b/composer.lock index abcd1aeef2..e672077ed8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9172901f2a079edb6ea35cb50b60b965", + "content-hash": "7307de2e65e9563fc4c2c112c3169223", "packages": [ { "name": "masnathan/odtphp", @@ -66,122 +66,18 @@ } ], "packages-dev": [ - { - "name": "friendsoftwig/twigcs", - "version": "v6.1.0", - "source": { - "type": "git", - "url": "https://github.com/friendsoftwig/twigcs.git", - "reference": "3c36d606c4f19db0dd2a01b735ec7a8151b7f182" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/friendsoftwig/twigcs/zipball/3c36d606c4f19db0dd2a01b735ec7a8151b7f182", - "reference": "3c36d606c4f19db0dd2a01b735ec7a8151b7f182", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-hash": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-simplexml": "*", - "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", - "symfony/console": "^4.4 || ^5.3 || ^6.0", - "symfony/filesystem": "^4.4 || ^5.3 || ^6.0", - "symfony/finder": "^4.4 || ^5.3 || ^6.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.5.20", - "symfony/phpunit-bridge": "^6.2.3" - }, - "bin": [ - "bin/twigcs" - ], - "type": "library", - "autoload": { - "psr-4": { - "FriendsOfTwig\\Twigcs\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tristan Maindron", - "email": "tmaindron@gmail.com" - } - ], - "description": "Checkstyle automation for Twig", - "support": { - "issues": "https://github.com/friendsoftwig/twigcs/issues", - "source": "https://github.com/friendsoftwig/twigcs/tree/v6.1.0" - }, - "time": "2023-01-04T16:01:24+00:00" - }, - { - "name": "glpi-project/phpstan-glpi", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/glpi-project/phpstan-glpi.git", - "reference": "e98ef833abc1389a0cc69743db5b1f3a7dc8ccfe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/glpi-project/phpstan-glpi/zipball/e98ef833abc1389a0cc69743db5b1f3a7dc8ccfe", - "reference": "e98ef833abc1389a0cc69743db5b1f3a7dc8ccfe", - "shasum": "" - }, - "require": { - "php": ">=7.4", - "phpstan/phpstan": "^2.1", - "symfony/polyfill-php80": "^1.32" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.85", - "php-parallel-lint/php-parallel-lint": "^1.4", - "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^9.6" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStanGlpi\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan rules for GLPI.", - "support": { - "issues": "https://github.com/glpi-project/phpstan-glpi/issues", - "source": "https://github.com/glpi-project/phpstan-glpi/tree/1.1.1" - }, - "time": "2025-08-11T13:48:13+00:00" - }, { "name": "glpi-project/tools", - "version": "0.8.0", + "version": "0.8.3", "source": { "type": "git", "url": "https://github.com/glpi-project/tools.git", - "reference": "7c2dcec105ed3427183bdfd382d785363aade436" + "reference": "8ea2a7d4702a858f4b0360ba7d4f1841a5e77026" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/7c2dcec105ed3427183bdfd382d785363aade436", - "reference": "7c2dcec105ed3427183bdfd382d785363aade436", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/8ea2a7d4702a858f4b0360ba7d4f1841a5e77026", + "reference": "8ea2a7d4702a858f4b0360ba7d4f1841a5e77026", "shasum": "" }, "require": { @@ -224,221 +120,7 @@ "issues": "https://github.com/glpi-project/tools/issues", "source": "https://github.com/glpi-project/tools" }, - "time": "2025-08-26T10:18:38+00:00" - }, - { - "name": "php-parallel-lint/php-parallel-lint", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", - "reference": "6db563514f27e19595a19f45a4bf757b6401194e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e", - "reference": "6db563514f27e19595a19f45a4bf757b6401194e", - "shasum": "" - }, - "require": { - "ext-json": "*", - "php": ">=5.3.0" - }, - "replace": { - "grogy/php-parallel-lint": "*", - "jakub-onderka/php-parallel-lint": "*" - }, - "require-dev": { - "nette/tester": "^1.3 || ^2.0", - "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", - "squizlabs/php_codesniffer": "^3.6" - }, - "suggest": { - "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" - }, - "bin": [ - "parallel-lint" - ], - "type": "library", - "autoload": { - "classmap": [ - "./src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Jakub Onderka", - "email": "ahoj@jakubonderka.cz" - } - ], - "description": "This tool checks the syntax of PHP files about 20x faster than serial check.", - "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", - "keywords": [ - "lint", - "static analysis" - ], - "support": { - "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", - "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.4.0" - }, - "time": "2024-03-27T12:14:49+00:00" - }, - { - "name": "phpstan/extension-installer", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/phpstan/extension-installer.git", - "reference": "85e90b3942d06b2326fba0403ec24fe912372936" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", - "reference": "85e90b3942d06b2326fba0403ec24fe912372936", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^2.0", - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.9.0 || ^2.0" - }, - "require-dev": { - "composer/composer": "^2.0", - "php-parallel-lint/php-parallel-lint": "^1.2.0", - "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" - }, - "type": "composer-plugin", - "extra": { - "class": "PHPStan\\ExtensionInstaller\\Plugin" - }, - "autoload": { - "psr-4": { - "PHPStan\\ExtensionInstaller\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Composer plugin for automatic installation of PHPStan extensions", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpstan/extension-installer/issues", - "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" - }, - "time": "2024-09-04T20:21:43+00:00" - }, - { - "name": "phpstan/phpstan", - "version": "2.1.22", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "41600c8379eb5aee63e9413fe9e97273e25d57e4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/41600c8379eb5aee63e9413fe9e97273e25d57e4", - "reference": "41600c8379eb5aee63e9413fe9e97273e25d57e4", - "shasum": "" - }, - "require": { - "php": "^7.4|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - } - ], - "time": "2025-08-04T19:17:37+00:00" - }, - { - "name": "phpstan/phpstan-deprecation-rules", - "version": "2.0.3", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "468e02c9176891cc901143da118f09dc9505fc2f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/468e02c9176891cc901143da118f09dc9505fc2f", - "reference": "468e02c9176891cc901143da118f09dc9505fc2f", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.15" - }, - "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^9.6" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", - "support": { - "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.3" - }, - "time": "2025-05-14T10:56:57+00:00" + "time": "2025-10-14T10:26:06+00:00" }, { "name": "psr/container", @@ -490,16 +172,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.13.2", + "version": "3.13.5", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c" + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4", + "reference": "0ca86845ce43291e8f5692c7356fccf3bcf02bf4", "shasum": "" }, "require": { @@ -516,11 +198,6 @@ "bin/phpcs" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -570,7 +247,7 @@ "type": "thanks_dev" } ], - "time": "2025-06-17T22:17:01+00:00" + "time": "2025-11-04T16:30:35+00:00" }, { "name": "symfony/console", @@ -738,136 +415,6 @@ ], "time": "2024-09-25T14:11:13+00:00" }, - { - "name": "symfony/filesystem", - "version": "v5.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "57c8294ed37d4a055b77057827c67f9558c95c54" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/57c8294ed37d4a055b77057827c67f9558c95c54", - "reference": "57c8294ed37d4a055b77057827c67f9558c95c54", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" - }, - "require-dev": { - "symfony/process": "^5.4|^6.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides basic utilities for the filesystem", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-10-22T13:05:35+00:00" - }, - { - "name": "symfony/finder", - "version": "v5.4.45", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "63741784cd7b9967975eec610b256eed3ede022b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b", - "reference": "63741784cd7b9967975eec610b256eed3ede022b", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Finds files and directories via an intuitive fluent interface", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.45" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-28T13:32:08+00:00" - }, { "name": "symfony/polyfill-ctype", "version": "v1.33.0", diff --git a/inc/order.class.php b/inc/order.class.php index eef0a435c9..412d4cd7cc 100644 --- a/inc/order.class.php +++ b/inc/order.class.php @@ -52,28 +52,28 @@ class PluginOrderOrder extends CommonDBTM "PluginOrderSurveySupplier" ]; - const ORDER_DEVICE_NOT_DELIVRED = 0; - const ORDER_DEVICE_DELIVRED = 1; - - // Const Budget - const ORDER_IS_OVER_BUDGET = 1; - const ORDER_IS_EQUAL_BUDGET = 2; - const ORDER_IS_UNDER_BUDGET = 3; - - /** - * @var integer - * @deprecated 2.1.2 Useless right. Update process will remove it from profiles rights. - */ - const RIGHT_OPENTICKET = 128; - - // additionnals rights - const RIGHT_VALIDATION = 256; - const RIGHT_UNDO_VALIDATION = 512; - const RIGHT_CANCEL = 1024; - const RIGHT_GENERATEODT_WITHOUT_VALIDATION = 2048; - const RIGHT_GENERATEODT = 4096; - const RIGHT_DELIVERY = 8192; - const ALLRIGHTS = 16255; + public const ORDER_DEVICE_NOT_DELIVRED = 0; + public const ORDER_DEVICE_DELIVRED = 1; + + // Const Budget + public const ORDER_IS_OVER_BUDGET = 1; + public const ORDER_IS_EQUAL_BUDGET = 2; + public const ORDER_IS_UNDER_BUDGET = 3; + + /** + * @var integer + * @deprecated 2.1.2 Useless right. Update process will remove it from profiles rights. + */ + public const RIGHT_OPENTICKET = 128; + + // additionnals rights + public const RIGHT_VALIDATION = 256; + public const RIGHT_UNDO_VALIDATION = 512; + public const RIGHT_CANCEL = 1024; + public const RIGHT_GENERATEODT_WITHOUT_VALIDATION = 2048; + public const RIGHT_GENERATEODT = 4096; + public const RIGHT_DELIVERY = 8192; + public const ALLRIGHTS = 16255; public function getCloneRelations(): array @@ -202,7 +202,7 @@ public function canUpdateOrder() public function canDisplayValidationForm($orders_id) { - //If it's an order creation -> do not display form + //If it's an order creation -> do not display form if (!$orders_id) { return false; } else { @@ -217,18 +217,18 @@ public function canValidateOrder() { $config = PluginOrderConfig::getConfig(); - //If no validation process -> can validate if order is in draft state + //If no validation process -> can validate if order is in draft state if (!$config->useValidation()) { return $this->isDraft(); } else { - //Validation process is used + //Validation process is used - //If order is canceled, cannot validate ! + //If order is canceled, cannot validate ! if ($this->isCanceled()) { return false; } - //If no right to validate + //If no right to validate if (!self::canValidate()) { return false; } else { @@ -241,7 +241,7 @@ public function canValidateOrder() public function canCancelOrder() { - //If order is canceled or if no right to cancel! + //If order is canceled or if no right to cancel! if ( $this->isCanceled() || !self::canCancel() @@ -271,12 +271,12 @@ public function canCancelValidationRequest() public function canUndoValidation() { - //If order is canceled, cannot validate ! + //If order is canceled, cannot validate ! if ($this->isCanceled()) { return false; } - //If order is not validate, cannot undo validation ! + //If order is not validate, cannot undo validation ! if ( $this->isDraft() || $this->isWaitingForApproval() @@ -284,7 +284,7 @@ public function canUndoValidation() return false; } - //If no right to cancel + //If no right to cancel return (self::canUndo()); } @@ -300,7 +300,7 @@ public function canDisplayValidationTab() } - /** + /** * @since version 0.85 * * @see commonDBTM::getRights() @@ -673,7 +673,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item instanceof Budget) { return __("Orders", "order"); - } else if ($item instanceof self) { + } elseif ($item instanceof self) { $ong = []; $config = PluginOrderConfig::getConfig(); if ( @@ -690,7 +690,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) && ($item->getState() > PluginOrderOrderState::DRAFT || $this->canGenerateWithoutValidation()) ) { - // generation + // generation $ong[2] = __("Purchase order", "order"); } @@ -707,7 +707,7 @@ public static function displayTabContentForItem( ) { if ($item instanceof Budget) { self::showForBudget($item->getField('id')); - } else if ($item instanceof self) { + } elseif ($item instanceof self) { switch ($tabnum) { case 1: $item->showValidationForm($item->getID()); @@ -746,7 +746,7 @@ public function prepareInputForAdd($input) ) { Session::addMessageAfterRedirect(__("An order number is mandatory !", "order"), false, ERROR); return []; - } else if ( + } elseif ( !isset($input["name"]) || $input["name"] == '' ) { @@ -775,9 +775,9 @@ public function prepareInputForAdd($input) public function post_addItem() { - // Manage add from template + // Manage add from template if (isset($this->input["_oldID"])) { - // ADD Documents + // ADD Documents $docitem = new Document_Item(); $docs = getAllDataFromTable( "glpi_documents_items", @@ -916,7 +916,7 @@ public function showForm($ID, $options = []) if (isset($options['withtemplate']) && $options['withtemplate'] == 2) { $template = "newcomp"; $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"])); - } else if (isset($options['withtemplate']) && $options['withtemplate'] == 1) { + } elseif (isset($options['withtemplate']) && $options['withtemplate'] == 1) { $template = "newtemplate"; $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"])); } else { @@ -933,13 +933,13 @@ public function showForm($ID, $options = []) $this->fields['order_date'] = null; } - // Displaying OVER BUDGET ALERT + // Displaying OVER BUDGET ALERT if ($this->fields['budgets_id'] > 0) { self::displayAlertOverBudget(self::isOverBudget($ID)); } - //Display without inside table - /* title */ + //Display without inside table + /* title */ echo "" . __("Order name", "order") . "*: "; echo ""; if ($canedit) { @@ -960,7 +960,7 @@ public function showForm($ID, $options = []) echo $this->fields["name"]; } echo ""; - /* date of order */ + /* date of order */ echo "" . __("Date of order", "order") . ":"; if ($canedit) { $value = $this->fields["order_date"] == null ? date('Y-m-d') : $this->fields["order_date"]; @@ -977,7 +977,7 @@ public function showForm($ID, $options = []) } echo ""; - /* num order */ + /* num order */ echo "" . __("Order number", "order"); if ($ID > 0) { echo "*"; @@ -1019,7 +1019,7 @@ public function showForm($ID, $options = []) } echo ""; - /* state */ + /* state */ echo "" . __("Order status", "order") . ": "; echo ""; if (!$this->getID()) { @@ -1037,7 +1037,7 @@ public function showForm($ID, $options = []) } echo ""; - /* budget */ + /* budget */ echo "" . __("Budget") . ": "; echo ""; if ($canedit) { @@ -1073,7 +1073,7 @@ public function showForm($ID, $options = []) } echo ""; - /* location */ + /* location */ echo "" . __("Delivery location", "order") . ": "; echo ""; if ($canedit) { @@ -1087,7 +1087,7 @@ public function showForm($ID, $options = []) } echo ""; - /* payment */ + /* payment */ echo "" . __("Payment conditions", "order") . ": "; if ($canedit) { PluginOrderOrderPayment::Dropdown([ @@ -1103,7 +1103,7 @@ public function showForm($ID, $options = []) echo ""; echo ""; - /* ecotax price */ + /* ecotax price */ echo "" . __("Eco-responsibility fees (tax free)", "order") . ": "; echo ""; if ($canedit) { @@ -1114,7 +1114,7 @@ public function showForm($ID, $options = []) } echo ""; - /* port price */ + /* port price */ echo "" . __("Postage", "order") . ": "; echo ""; if ($canedit) { @@ -1204,7 +1204,7 @@ public function showForm($ID, $options = []) echo ""; if ($canedit) { echo ""; - // Make a select box + // Make a select box $criteria = [ 'SELECT' => ['c.id', 'c.name', 'c.firstname'], 'FROM' => 'glpi_contacts AS c', @@ -1287,7 +1287,7 @@ public function showForm($ID, $options = []) echo ""; echo ""; - /* account section */ + /* account section */ echo ""; echo ""; if (!$config->isAccountSectionDisplayed()) { @@ -1336,7 +1336,7 @@ public function showForm($ID, $options = []) echo ""; - //comments of order + //comments of order echo "" . __("Comments") . ": "; echo ""; if ($canedit) { @@ -1813,7 +1813,7 @@ public function generateOrder($params) $template = $params['template']; $signature = $params['sign']; - // Only allow filenames with .odt extension and no path traversal + // Only allow filenames with .odt extension and no path traversal if (!preg_match('/^[a-zA-Z0-9_\-\.]+\.odt$/', $template)) { throw new \RuntimeException("Invalid template name"); } @@ -2006,7 +2006,7 @@ public function generateOrder($params) $total_TTC_Article = $element['price_discounted'] * (1 + ($element['taxe'] / 100)); $articleValues['ATIPriceTotalArticle'] = Html::formatNumber($total_TTC_Article); - // Set variables in odt segment + // Set variables in odt segment foreach ($articleValues as $field => $val) { try { $article->setVars($field, $val, true, 'UTF-8'); @@ -2021,7 +2021,7 @@ public function generateOrder($params) $prices = $PluginOrderOrder_Item->getAllPrices($ID); - // total price (with postage) + // total price (with postage) $tax = new PluginOrderOrderTax(); $tax->getFromDB($this->fields["plugin_order_ordertaxes_id"]); @@ -2066,7 +2066,7 @@ public function generateOrder($params) $values['title_conditions'] = __("Payment conditions", "order"); $values['payment_conditions'] = $name; - // Set variables in odt template + // Set variables in odt template foreach ($values as $field => $val) { try { $odf->setVars($field, $val, true, 'UTF-8'); @@ -2086,7 +2086,7 @@ public function generateOrder($params) $message .= Html::convDateTime($_SESSION['glpi_currenttime']); $message = str_replace(" ", "_", $message); $outputfile = str_replace(".odt", $message . ".odt", $template); - // We export the file + // We export the file $odf->exportAsAttachedFile($outputfile); } } @@ -2182,7 +2182,7 @@ public static function showForBudget($budgets_id) //if state is cancel do not decremente total already use if ($data['plugin_order_orderstates_id'] !== PluginOrderOrderState::CANCELED) { - $total += $prices["priceHT"]; + $total += $prices["priceHT"]; } $link = Toolbox::getItemTypeFormURL(__CLASS__); @@ -2243,15 +2243,15 @@ public function canStillUseBudget($input) $budget = new Budget(); $budget->getFromDB($input['budgets_id']); - //If no begin date on a budget : do not display a warning + //If no begin date on a budget : do not display a warning if (empty($budget->fields['begin_date'])) { return true; } else { - //There's a begin date and order date is prior to it + //There's a begin date and order date is prior to it if ($input['order_date'] < $budget->getField('begin_date')) { return false; } - //There's an end date and order date is above it + //There's an end date and order date is above it if ( !empty($budget->fields['end_date']) && $input['order_date'] > $budget->getField('end_date') @@ -2305,17 +2305,17 @@ public function isOverBudget($ID) { /** @var \DBmysql $DB */ global $DB; - //Do not check if it's a template + //Do not check if it's a template if ($this->fields['is_template']) { return PluginOrderOrder::ORDER_IS_UNDER_BUDGET; } - // Compute all prices for BUDGET + // Compute all prices for BUDGET $table = $this->getTable(); $query = "SELECT * FROM `$table` WHERE `budgets_id` = '{$this->fields['budgets_id']}'"; - // Get BUDGET + // Get BUDGET $budget = new Budget(); if (!$budget->getFromDB($this->fields['budgets_id'])) { return false; @@ -2332,10 +2332,10 @@ public function isOverBudget($ID) $total_HT += $prices["priceHT"] + $data['port_price']; } - // Compare BUDGET value to TOTAL_HT value + // Compare BUDGET value to TOTAL_HT value if ($total_HT > $budget->getField('value')) { return PluginOrderOrder::ORDER_IS_OVER_BUDGET; - } else if ($total_HT == $budget->getField('value')) { + } elseif ($total_HT == $budget->getField('value')) { return PluginOrderOrder::ORDER_IS_EQUAL_BUDGET; } else { return PluginOrderOrder::ORDER_IS_UNDER_BUDGET; @@ -2442,9 +2442,9 @@ public static function cronComputeLateOrders($task) $options['orders'] = $orders; if (NotificationEvent::raiseEvent('duedate', new PluginOrderOrder(), $options)) { if ($task) { - $task->log(Dropdown::getDropdownName("glpi_entities", $entity) - . " : $message\n"); - $task->addVolume(1); + $task->log(Dropdown::getDropdownName("glpi_entities", $entity) + . " : $message\n"); + $task->addVolume(1); } else { Session::addMessageAfterRedirect(Dropdown::getDropdownName("glpi_entities", $entity) . " : $message"); @@ -2452,7 +2452,7 @@ public static function cronComputeLateOrders($task) $input["type"] = Alert::THRESHOLD; $input["itemtype"] = 'PluginOrderOrder'; - // add alerts + // add alerts foreach ($orders as $ID => $tmp) { $input["items_id"] = $ID; $alert->add($input); @@ -2493,22 +2493,22 @@ public static function addDocumentCategory(Document $document) } } - // Fomrat document name + // Fomrat document name if ( isset($document->input['itemtype']) && $document->input['itemtype'] == __CLASS__ && $document->input['documentcategories_id'] && $config->canRenameDocuments() ) { - // Get document category + // Get document category $documentCategory = new PluginOrderDocumentCategory(); if (!$documentCategory->getFromDBByCrit(['documentcategories_id' => $document->input['documentcategories_id']])) { $documentCategory->getEmpty(); } - // Get order linked to document + // Get order linked to document $document_item = new Document_Item(); if ($document_item->getFromDBByCrit(['documents_id' => $document->fields['id'], 'itemtype' => self::getType()])) { - // Update document name + // Update document name $order = new self(); $order->getFromDB($document_item->fields['items_id']); $extension = explode('.', $document->fields['filename']); @@ -2532,11 +2532,11 @@ public function getForbiddenStandardMassiveAction() } - /** - * @since version 0.85 - * - * @see CommonDBTM::showMassiveActionsSubForm() - **/ + /** + * @since version 0.85 + * + * @see CommonDBTM::showMassiveActionsSubForm() + **/ public static function showMassiveActionsSubForm(MassiveAction $ma) { switch ($ma->getAction()) { @@ -2569,11 +2569,11 @@ public function getSpecificMassiveActions($checkitem = null) } - /** - * @since version 0.85 - * - * @see CommonDBTM::processMassiveActionsForOneItemtype() - **/ + /** + * @since version 0.85 + * + * @see CommonDBTM::processMassiveActionsForOneItemtype() + **/ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { @@ -2588,7 +2588,7 @@ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, Co "entities_id" => $entities_id, "update" => __('Update'), ]); - $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); + $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } } return; @@ -2597,9 +2597,9 @@ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, Co } - //------------------------------------------------------------ - //--------------------Install / uninstall -------------------- - //------------------------------------------------------------ + //------------------------------------------------------------ + //--------------------Install / uninstall -------------------- + //------------------------------------------------------------ public static function install(Migration $migration) { @@ -2611,7 +2611,7 @@ public static function install(Migration $migration) $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); $table = self::getTable(); - //Installation + //Installation if (!$DB->tableExists($table) && !$DB->tableExists("glpi_plugin_order")) { $migration->displayMessage("Installing $table"); @@ -2672,11 +2672,11 @@ public static function install(Migration $migration) 'mode' => CronTask::MODE_EXTERNAL ]); } else { - //Upgrade + //Upgrade $migration->displayMessage("Upgrading $table"); if ($DB->tableExists('glpi_plugin_order')) { - //Update to 1.1.0 + //Update to 1.1.0 $migration->addField('glpi_plugin_order', "port_price", "FLOAT NOT NULL default '0'"); $migration->addField('glpi_plugin_order', "taxes", "FLOAT NOT NULL default '0'"); if ($DB->fieldExists("glpi_plugin_order", "numordersupplier")) { @@ -2692,7 +2692,7 @@ public static function install(Migration $migration) $migration->migrationOneTable('glpi_plugin_order'); } - //1.2.0 + //1.2.0 $domigration_itemtypes = false; if ($DB->tableExists('glpi_plugin_order')) { $migration->renameTable("glpi_plugin_order", $table); @@ -2801,7 +2801,7 @@ public static function install(Migration $migration) $migration->addKey($table, "is_deleted"); $migration->migrationOneTable($table); - //Only migrate itemtypes when it's only necessary, otherwise it breaks upgrade procedure ! + //Only migrate itemtypes when it's only necessary, otherwise it breaks upgrade procedure ! if ($domigration_itemtypes) { Plugin::migrateItemType( [3150 => 'PluginOrderOrder'], @@ -2814,7 +2814,7 @@ public static function install(Migration $migration) } if ($DB->tableExists("glpi_plugin_order_budgets")) { - //Manage budgets (here because class has been remove since 1.4.0) + //Manage budgets (here because class has been remove since 1.4.0) $migration->changeField("glpi_plugin_order_budgets", "ID", "id", " int {$default_key_sign} NOT NULL auto_increment"); $migration->changeField( "glpi_plugin_order_budgets", @@ -2871,7 +2871,7 @@ public static function install(Migration $migration) [] ); - //Manage budgets migration before dropping the table + //Manage budgets migration before dropping the table $budget = new Budget(); $matchings = [ 'budgets_id' => 'id', @@ -2893,11 +2893,11 @@ public static function install(Migration $migration) $tmp['comment'] = Toolbox::addslashes_deep($tmp['comment']); - //Budget already exists in the core: update it + //Budget already exists in the core: update it if ($budget->getFromDB($data['budgets_id'])) { $budget->update($tmp); } else { - //Budget doesn't exists in the core: create it + //Budget doesn't exists in the core: create it unset($tmp['id']); $budget->add($tmp); } @@ -2914,7 +2914,7 @@ public static function install(Migration $migration) } } - //1.3.0 + //1.3.0 $migration->addField( $table, "plugin_order_ordertypes_id", @@ -2922,7 +2922,7 @@ public static function install(Migration $migration) ); $migration->migrationOneTable($table); - //1.4.0 + //1.4.0 if ( $migration->changeField( "glpi_plugin_order_orders", @@ -2939,7 +2939,7 @@ public static function install(Migration $migration) $migration->addField($table, "duedate", "DATETIME NULL"); $migration->migrationOneTable($table); - //1.5.0 + //1.5.0 if ($DB->tableExists("glpi_dropdown_plugin_order_status")) { $DB->query("DROP TABLE `glpi_dropdown_plugin_order_status`") or die($DB->error()); } @@ -2950,7 +2950,7 @@ public static function install(Migration $migration) $migration->addField($table, 'plugin_order_billstates_id', "int {$default_key_sign} NOT NULL default 0"); - //1.5.2 + //1.5.2 $migration->addField($table, 'deliverydate', "DATETIME NULL"); $migration->addField($table, "is_late", "TINYINT NOT NULL DEFAULT '0'"); $migration->addKey($table, "is_late"); @@ -2973,15 +2973,15 @@ public static function install(Migration $migration) $migration->addField($table, "users_id_delivery", "INT {$default_key_sign} NOT NULL DEFAULT '0'"); $migration->addField($table, "groups_id_delivery", "INT {$default_key_sign} NOT NULL DEFAULT '0'"); - //1.7.0 + //1.7.0 $migration->addField($table, "date_mod", "timestamp"); $migration->addKey($table, "date_mod"); - //1.7.2 + //1.7.2 $migration->addField($table, "is_helpdesk_visible", "bool", ['value' => 1]); $migration->migrationOneTable($table); - //Displayprefs + //Displayprefs $prefs = [1 => 1, 2 => 2, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 10 => 10]; foreach ($prefs as $num => $rank) { if ( @@ -2999,19 +2999,19 @@ public static function install(Migration $migration) } } - //Remove unused notifications + //Remove unused notifications $notification = new Notification(); $notification->deleteByCriteria([ 'itemtype' => 'PluginOrderOrder_Item', ]); - //2.7.0 + //2.7.0 $migration->addField($table, "global_discount", "FLOAT NOT NULL default '0'"); - //2.7.3 + //2.7.3 $migration->changeField($table, "plugin_order_billstates_id", "plugin_order_billstates_id", "int {$default_key_sign} NOT NULL DEFAULT 0"); - // Add ecotax fields if they don't exist + // Add ecotax fields if they don't exist if (!$DB->fieldExists($table, 'ecotax_price')) { $migration->addField( $table, @@ -3033,8 +3033,7 @@ public static function install(Migration $migration) $migration->migrationOneTable($table); } - // Remove RIGHT_OPENTICKET - /** @phpstan-ignore-next-line */ + // Remove RIGHT_OPENTICKET $right_openticket = self::RIGHT_OPENTICKET; $DB->update( ProfileRight::getTable(), @@ -3062,10 +3061,10 @@ public static function uninstall() $DB->query($query); } - //Old table name + //Old table name $DB->query("DROP TABLE IF EXISTS `glpi_plugin_order`") or die($DB->error()); - //Current table name + //Current table name $DB->query("DROP TABLE IF EXISTS `" . self::getTable() . "`") or die($DB->error()); } diff --git a/phpstan.neon b/phpstan.neon index adf2db65c1..8d862b4f93 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -16,7 +16,6 @@ parameters: stubFiles: - ../../stubs/glpi_constants.php ignoreErrors: - - '#Call to deprecated method query\(\) of class DBmysql:#' - '#Path in include_once\(\) ".*?/files/_plugins/order/generate/custom\.php" is not a file or it does not exist\.#' excludePaths: - 'inc/referenceinjection.class.php'