From 7da9e4532de261ed32d05b41044a3b146f828635 Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Thu, 28 Mar 2019 16:06:56 +0100
Subject: [PATCH] refactor: code performance

---
 ajax/address/create.php                       |  4 +-
 ajax/invoices/createCreditNote.php            |  4 +-
 ajax/invoices/get.php                         |  2 +-
 ajax/invoices/getHistory.php                  | 10 +--
 ajax/invoices/getTransactions.php             |  2 +-
 ajax/invoices/list.php                        |  4 +-
 ajax/invoices/payments/format.php             |  2 +-
 ajax/invoices/search.php                      |  6 +-
 ajax/invoices/temporary/calc.php              |  4 +-
 ajax/invoices/temporary/html.php              |  2 +-
 ajax/invoices/temporary/list.php              |  6 +-
 ajax/invoices/temporary/previewhtml.php       |  2 +-
 ajax/invoices/temporary/product/calc.php      |  4 +-
 .../temporary/product/getProductEdit.php      |  2 +-
 .../product/hasProductCustomFields.php        |  2 +-
 .../product/parseProductToArticle.php         | 10 +--
 ajax/invoices/temporary/product/summary.php   |  2 +-
 ajax/invoices/temporary/save.php              |  2 +-
 ajax/processingStatus/create.php              |  2 +-
 ajax/processingStatus/list.php                |  7 ++-
 ajax/processingStatus/update.php              |  4 +-
 .../Accounting/Invoice/Articles/Article.php   |  4 +-
 .../ERP/Accounting/Invoice/Articles/Text.php  |  4 +-
 .../ERP/Accounting/Invoice/EventHandler.php   |  4 +-
 .../Invoice/FrontendUsers/UserInvoices.php    |  4 +-
 src/QUI/ERP/Accounting/Invoice/Handler.php    | 18 +++---
 src/QUI/ERP/Accounting/Invoice/Invoice.php    | 62 +++++++++----------
 .../Accounting/Invoice/InvoiceTemporary.php   | 60 +++++++++---------
 .../ERP/Accounting/Invoice/InvoiceView.php    | 16 ++---
 .../Invoice/NumberRanges/Invoice.php          |  2 +-
 .../Invoice/NumberRanges/TemporaryInvoice.php |  2 +-
 src/QUI/ERP/Accounting/Invoice/Payment.php    |  4 +-
 .../Invoice/ProcessingStatus/Factory.php      |  6 +-
 .../Invoice/ProcessingStatus/Handler.php      | 21 +++++--
 .../Invoice/Search/InvoiceSearch.php          | 34 +++++-----
 src/QUI/ERP/Accounting/Invoice/Settings.php   | 10 +--
 .../ERP/Accounting/Invoice/Utils/Invoice.php  | 48 +++++++-------
 .../ERP/Accounting/Invoice/Utils/Template.php | 18 +++---
 38 files changed, 207 insertions(+), 193 deletions(-)

diff --git a/ajax/address/create.php b/ajax/address/create.php
index 92531a9..2441a63 100644
--- a/ajax/address/create.php
+++ b/ajax/address/create.php
@@ -17,12 +17,12 @@ function ($userId, $data) {
         $User = QUI::getUsers()->get($userId);
 
         $Address = $User->addAddress(
-            json_decode($data, true)
+            \json_decode($data, true)
         );
 
         $User->setAttribute('quiqqer.erp.address', $Address->getId());
         $User->save();
     },
-    array('userId', 'data'),
+    ['userId', 'data'],
     'Permission::checkAdminUser'
 );
diff --git a/ajax/invoices/createCreditNote.php b/ajax/invoices/createCreditNote.php
index f02edd4..4303d74 100644
--- a/ajax/invoices/createCreditNote.php
+++ b/ajax/invoices/createCreditNote.php
@@ -18,9 +18,9 @@ function ($invoiceId, $invoiceData) {
             $invoiceData = '';
         }
 
-        $invoiceData = json_decode($invoiceData, true);
+        $invoiceData = \json_decode($invoiceData, true);
 
-        if (!is_array($invoiceData)) {
+        if (!\is_array($invoiceData)) {
             $invoiceData = [];
         }
 
diff --git a/ajax/invoices/get.php b/ajax/invoices/get.php
index a54e0f0..8692b1b 100644
--- a/ajax/invoices/get.php
+++ b/ajax/invoices/get.php
@@ -37,7 +37,7 @@ function ($invoiceId) {
 
         if (!empty($attributes['time_for_payment'])) {
             $attributes['time_for_payment'] = $DateFormatter->format(
-                strtotime($attributes['time_for_payment'])
+                \strtotime($attributes['time_for_payment'])
             );
         }
 
diff --git a/ajax/invoices/getHistory.php b/ajax/invoices/getHistory.php
index 527056d..ef1f9ca 100644
--- a/ajax/invoices/getHistory.php
+++ b/ajax/invoices/getHistory.php
@@ -26,20 +26,20 @@ function ($invoiceId) {
         QUI\ERP\Accounting\Calc::calculatePayments($Invoice);
 
         $History = $Invoice->getHistory();
-        $history = array_map(function ($history) {
+        $history = \array_map(function ($history) {
             $history['type'] = 'history';
 
             return $history;
         }, $History->toArray());
 
         $Comments = $Invoice->getComments();
-        $comments = array_map(function ($comment) {
+        $comments = \array_map(function ($comment) {
             $comment['type'] = 'comment';
 
             return $comment;
         }, $Comments->toArray());
 
-        $history = array_merge($history, $comments);
+        $history = \array_merge($history, $comments);
 
         // transactions
         $Transactions = QUI\ERP\Accounting\Payments\Transactions\Handler::getInstance();
@@ -49,13 +49,13 @@ function ($invoiceId) {
             /* @var $Tx \QUI\ERP\Accounting\Payments\Transactions\Transaction */
             $history[] = [
                 'message' => $Tx->parseToText(),
-                'time'    => strtotime($Tx->getDate()),
+                'time'    => \strtotime($Tx->getDate()),
                 'type'    => 'transaction',
             ];
         }
 
         // sort
-        usort($history, function ($a, $b) {
+        \usort($history, function ($a, $b) {
             if ($a['time'] == $b['time']) {
                 return 0;
             }
diff --git a/ajax/invoices/getTransactions.php b/ajax/invoices/getTransactions.php
index a40a190..4bfd75c 100644
--- a/ajax/invoices/getTransactions.php
+++ b/ajax/invoices/getTransactions.php
@@ -17,7 +17,7 @@
     function ($invoiceId) {
         $transactions = QUI\ERP\Accounting\Invoice\Utils\Invoice::getTransactionsByInvoice($invoiceId);
 
-        return array_map(function ($Transaction) {
+        return \array_map(function ($Transaction) {
             /* @var $Transaction \QUI\ERP\Accounting\Payments\Transactions\Transaction */
             return $Transaction->getAttributes();
         }, $transactions);
diff --git a/ajax/invoices/list.php b/ajax/invoices/list.php
index 47fb718..9a95297 100644
--- a/ajax/invoices/list.php
+++ b/ajax/invoices/list.php
@@ -20,10 +20,10 @@ function ($params) {
         $Grid   = new QUI\Utils\Grid();
 
         // query params
-        $query = $Grid->parseDBParams(json_decode($params, true));
+        $query = $Grid->parseDBParams(\json_decode($params, true));
 
         if (isset($query['limit'])) {
-            $limit = explode(',', $query['limit']);
+            $limit = \explode(',', $query['limit']);
 
             $Search->limit($limit[0], $limit[1]);
         }
diff --git a/ajax/invoices/payments/format.php b/ajax/invoices/payments/format.php
index 579c692..7ada08c 100644
--- a/ajax/invoices/payments/format.php
+++ b/ajax/invoices/payments/format.php
@@ -12,7 +12,7 @@
 QUI::$Ajax->registerFunction(
     'package_quiqqer_invoice_ajax_invoices_payments_format',
     function ($payments) {
-        $payments = json_decode($payments, true);
+        $payments = \json_decode($payments, true);
         $result   = [];
 
         $Locale   = QUI::getLocale();
diff --git a/ajax/invoices/search.php b/ajax/invoices/search.php
index 9e215b5..184fb89 100644
--- a/ajax/invoices/search.php
+++ b/ajax/invoices/search.php
@@ -21,17 +21,17 @@ function ($params, $filter) {
         $Grid   = new QUI\Utils\Grid();
 
         // filter
-        $filter = json_decode($filter);
+        $filter = \json_decode($filter);
 
         foreach ($filter as $entry => $value) {
             $Search->setFilter($entry, $value);
         }
 
         // query params
-        $query = $Grid->parseDBParams(json_decode($params, true));
+        $query = $Grid->parseDBParams(\json_decode($params, true));
 
         if (isset($query['limit'])) {
-            $limit = explode(',', $query['limit']);
+            $limit = \explode(',', $query['limit']);
 
             $Search->limit($limit[0], $limit[1]);
         }
diff --git a/ajax/invoices/temporary/calc.php b/ajax/invoices/temporary/calc.php
index dda54dc..1c3f840 100644
--- a/ajax/invoices/temporary/calc.php
+++ b/ajax/invoices/temporary/calc.php
@@ -15,8 +15,8 @@
 QUI::$Ajax->registerFunction(
     'package_quiqqer_invoice_ajax_invoices_temporary_calc',
     function ($articles, $user) {
-        $articles = json_decode($articles, true);
-        $user     = json_decode($user, true);
+        $articles = \json_decode($articles, true);
+        $user     = \json_decode($user, true);
         $List     = new ArticleList();
 
         try {
diff --git a/ajax/invoices/temporary/html.php b/ajax/invoices/temporary/html.php
index 5be2979..aeb883a 100644
--- a/ajax/invoices/temporary/html.php
+++ b/ajax/invoices/temporary/html.php
@@ -14,7 +14,7 @@
     function ($invoiceId, $data) {
         $Invoices = QUI\ERP\Accounting\Invoice\Handler::getInstance();
         $Invoice  = $Invoices->getTemporaryInvoice($invoiceId);
-        $data     = json_decode($data, true);
+        $data     = \json_decode($data, true);
 
         $Invoice->clearArticles();
 
diff --git a/ajax/invoices/temporary/list.php b/ajax/invoices/temporary/list.php
index 29d9bf6..f7af842 100644
--- a/ajax/invoices/temporary/list.php
+++ b/ajax/invoices/temporary/list.php
@@ -27,7 +27,7 @@ function ($params) {
         $Locale   = QUI::getLocale();
 
         $data = $Invoices->searchTemporaryInvoices(
-            $Grid->parseDBParams(json_decode($params, true))
+            $Grid->parseDBParams(\json_decode($params, true))
         );
 
         $localeCode = QUI::getLocale()->getLocalesByLang(
@@ -118,7 +118,7 @@ function ($params) {
                             $customer .= ' ';
                             $customer .= $Address->getAttribute('lastname');
 
-                            $customer = trim($customer);
+                            $customer = \trim($customer);
                         }
 
                         if ($Customer->isCompany() && $Address && !empty($Address->getAttribute('company'))) {
@@ -146,7 +146,7 @@ function ($params) {
 
             // format
             $data[$key]['date'] = $DateFormatter->format(
-                strtotime($TemporaryInvoice->getAttribute('date'))
+                \strtotime($TemporaryInvoice->getAttribute('date'))
             );
 
             //$vatTextArray = InvoiceUtils::getVatTextArrayFromVatArray($invoiceData['vat_array'], $Currency);
diff --git a/ajax/invoices/temporary/previewhtml.php b/ajax/invoices/temporary/previewhtml.php
index ef23ac4..1085a1b 100644
--- a/ajax/invoices/temporary/previewhtml.php
+++ b/ajax/invoices/temporary/previewhtml.php
@@ -14,7 +14,7 @@
     function ($invoiceId, $data) {
         $Invoices = QUI\ERP\Accounting\Invoice\Handler::getInstance();
         $Invoice  = $Invoices->getTemporaryInvoice($invoiceId);
-        $data     = json_decode($data, true);
+        $data     = \json_decode($data, true);
 
         $Invoice->clearArticles();
 
diff --git a/ajax/invoices/temporary/product/calc.php b/ajax/invoices/temporary/product/calc.php
index 2d05142..8bb46b3 100644
--- a/ajax/invoices/temporary/product/calc.php
+++ b/ajax/invoices/temporary/product/calc.php
@@ -12,8 +12,8 @@
 QUI::$Ajax->registerFunction(
     'package_quiqqer_invoice_ajax_invoices_temporary_product_calc',
     function ($params, $user) {
-        $params = json_decode($params, true);
-        $user   = json_decode($user, true);
+        $params = \json_decode($params, true);
+        $user   = \json_decode($user, true);
 
         if (!empty($user)) {
             try {
diff --git a/ajax/invoices/temporary/product/getProductEdit.php b/ajax/invoices/temporary/product/getProductEdit.php
index bb0b724..7e842a3 100644
--- a/ajax/invoices/temporary/product/getProductEdit.php
+++ b/ajax/invoices/temporary/product/getProductEdit.php
@@ -14,7 +14,7 @@
     'package_quiqqer_invoice_ajax_invoices_temporary_product_getProductEdit',
     function ($productId, $user) {
         $Product = Products::getProduct($productId);
-        $user    = json_encode($user, true);
+        $user    = \json_encode($user, true);
 
         $Control = new ProductEdit([
             'Product' => $Product
diff --git a/ajax/invoices/temporary/product/hasProductCustomFields.php b/ajax/invoices/temporary/product/hasProductCustomFields.php
index 2c6f350..02d459e 100644
--- a/ajax/invoices/temporary/product/hasProductCustomFields.php
+++ b/ajax/invoices/temporary/product/hasProductCustomFields.php
@@ -15,7 +15,7 @@ function ($productId) {
         $Product = Products::getProduct($productId);
         $fields  = $Product->createUniqueProduct()->getCustomFields();
 
-        return count($fields);
+        return \count($fields);
     },
     ['productId'],
     'Permission::checkAdminUser'
diff --git a/ajax/invoices/temporary/product/parseProductToArticle.php b/ajax/invoices/temporary/product/parseProductToArticle.php
index 4382ec8..248c98c 100644
--- a/ajax/invoices/temporary/product/parseProductToArticle.php
+++ b/ajax/invoices/temporary/product/parseProductToArticle.php
@@ -13,8 +13,8 @@
 QUI::$Ajax->registerFunction(
     'package_quiqqer_invoice_ajax_invoices_temporary_product_parseProductToArticle',
     function ($productId, $attributes, $user) {
-        $user       = json_decode($user, true);
-        $attributes = json_decode($attributes, true);
+        $user       = \json_decode($user, true);
+        $attributes = \json_decode($attributes, true);
         $User       = null;
         $Locale     = QUI::getLocale();
 
@@ -27,11 +27,11 @@ function ($productId, $attributes, $user) {
             $Product = Products::getProduct((int)$productId);
 
             foreach ($attributes as $field => $value) {
-                if (strpos($field, 'field-') === false) {
+                if (\strpos($field, 'field-') === false) {
                     continue;
                 }
 
-                $field = str_replace('field-', '', $field);
+                $field = \str_replace('field-', '', $field);
                 $Field = $Product->getField((int)$field);
 
                 $Field->setValue($value);
@@ -48,7 +48,7 @@ function ($productId, $attributes, $user) {
                     $Description->setValue($InvoiceText->getValue());
                 }
             } catch (QUI\Exception $Exception) {
-                \QUI\System\Log::addNotice($Exception->getMessage());
+                QUI\System\Log::addNotice($Exception->getMessage());
             }
 
 
diff --git a/ajax/invoices/temporary/product/summary.php b/ajax/invoices/temporary/product/summary.php
index ef5991f..2bac328 100644
--- a/ajax/invoices/temporary/product/summary.php
+++ b/ajax/invoices/temporary/product/summary.php
@@ -13,7 +13,7 @@
 QUI::$Ajax->registerFunction(
     'package_quiqqer_invoice_ajax_invoices_temporary_product_summary',
     function ($article) {
-        $article = json_decode($article, true);
+        $article = \json_decode($article, true);
 
         $Brutto = new QUI\ERP\User([
             'id'        => 'BRUTTO',
diff --git a/ajax/invoices/temporary/save.php b/ajax/invoices/temporary/save.php
index 7c49dd3..c70cd98 100644
--- a/ajax/invoices/temporary/save.php
+++ b/ajax/invoices/temporary/save.php
@@ -15,7 +15,7 @@
     function ($invoiceId, $data) {
         $Invoices = QUI\ERP\Accounting\Invoice\Handler::getInstance();
         $Invoice  = $Invoices->getTemporaryInvoice($invoiceId);
-        $data     = json_decode($data, true);
+        $data     = \json_decode($data, true);
 
         if (empty($data['customer_id'])) {
             $data['invoice_address_id'] = '';
diff --git a/ajax/processingStatus/create.php b/ajax/processingStatus/create.php
index 7869f7b..8438caa 100644
--- a/ajax/processingStatus/create.php
+++ b/ajax/processingStatus/create.php
@@ -15,7 +15,7 @@ function ($id, $color, $title) {
         Factory::getInstance()->createProcessingStatus(
             $id,
             $color,
-            json_decode($title, true)
+            \json_decode($title, true)
         );
     },
     array('id', 'color', 'title'),
diff --git a/ajax/processingStatus/list.php b/ajax/processingStatus/list.php
index 004edfe..db96c28 100644
--- a/ajax/processingStatus/list.php
+++ b/ajax/processingStatus/list.php
@@ -18,19 +18,20 @@ function () {
         $Handler = Handler::getInstance();
 
         $list   = $Handler->getProcessingStatusList();
-        $result = array_map(function ($Status) {
+        $result = \array_map(function ($Status) {
             /* @var $Status \QUI\ERP\Accounting\Invoice\ProcessingStatus\Status */
             return $Status->toArray(QUI::getLocale());
         }, $list);
 
-        usort($result, function ($a, $b) {
+        \usort($result, function ($a, $b) {
             if ($a['id'] == $b['id']) {
                 return 0;
             }
+
             return $a['id'] > $b['id'] ? 1 : -1;
         });
 
-        return $Grid->parseResult($result, count($result));
+        return $Grid->parseResult($result, \count($result));
     },
     false,
     'Permission::checkAdminUser'
diff --git a/ajax/processingStatus/update.php b/ajax/processingStatus/update.php
index 9b65bde..9542cb5 100644
--- a/ajax/processingStatus/update.php
+++ b/ajax/processingStatus/update.php
@@ -15,9 +15,9 @@ function ($id, $color, $title) {
         Handler::getInstance()->updateProcessingStatus(
             $id,
             $color,
-            json_decode($title, true)
+            \json_decode($title, true)
         );
     },
-    array('id', 'color', 'title'),
+    ['id', 'color', 'title'],
     'Permission::checkAdminUser'
 );
diff --git a/src/QUI/ERP/Accounting/Invoice/Articles/Article.php b/src/QUI/ERP/Accounting/Invoice/Articles/Article.php
index 3aa36ca..68b82ad 100644
--- a/src/QUI/ERP/Accounting/Invoice/Articles/Article.php
+++ b/src/QUI/ERP/Accounting/Invoice/Articles/Article.php
@@ -24,8 +24,8 @@ class Article extends QUI\ERP\Accounting\Article
      */
     public function toArray()
     {
-        return array_merge(parent::toArray(), [
-            'class'   => get_class($this),
+        return \array_merge(parent::toArray(), [
+            'class'   => \get_class($this),
             'control' => 'package/quiqqer/invoice/bin/backend/controls/articles/Article'
         ]);
     }
diff --git a/src/QUI/ERP/Accounting/Invoice/Articles/Text.php b/src/QUI/ERP/Accounting/Invoice/Articles/Text.php
index 4e9366d..3807c70 100644
--- a/src/QUI/ERP/Accounting/Invoice/Articles/Text.php
+++ b/src/QUI/ERP/Accounting/Invoice/Articles/Text.php
@@ -67,8 +67,8 @@ public function displayPrice()
      */
     public function toArray()
     {
-        return array_merge(parent::toArray(), [
-            'class'        => get_class($this),
+        return \array_merge(parent::toArray(), [
+            'class'        => \get_class($this),
             'control'      => 'package/quiqqer/invoice/bin/backend/controls/articles/Text',
             'displayPrice' => $this->displayPrice()
         ]);
diff --git a/src/QUI/ERP/Accounting/Invoice/EventHandler.php b/src/QUI/ERP/Accounting/Invoice/EventHandler.php
index 17f1b91..e996dbd 100644
--- a/src/QUI/ERP/Accounting/Invoice/EventHandler.php
+++ b/src/QUI/ERP/Accounting/Invoice/EventHandler.php
@@ -183,9 +183,9 @@ public static function onFrontendUsersAddressTop(Collector $Collector, QUI\Users
 
         $result = '';
         $result .= '<style>';
-        $result .= file_get_contents(dirname(__FILE__).'/FrontendUsers/userProfileAddressSelect.css');
+        $result .= \file_get_contents(\dirname(__FILE__).'/FrontendUsers/userProfileAddressSelect.css');
         $result .= '</style>';
-        $result .= $Engine->fetch(dirname(__FILE__).'/FrontendUsers/userProfileAddressSelect.html');
+        $result .= $Engine->fetch(\dirname(__FILE__).'/FrontendUsers/userProfileAddressSelect.html');
 
         $Collector->append($result);
     }
diff --git a/src/QUI/ERP/Accounting/Invoice/FrontendUsers/UserInvoices.php b/src/QUI/ERP/Accounting/Invoice/FrontendUsers/UserInvoices.php
index 838e4ab..de8044b 100644
--- a/src/QUI/ERP/Accounting/Invoice/FrontendUsers/UserInvoices.php
+++ b/src/QUI/ERP/Accounting/Invoice/FrontendUsers/UserInvoices.php
@@ -26,7 +26,7 @@ class UserInvoices extends Control implements ControlInterface
     public function __construct(array $attributes = [])
     {
         $this->addCSSClass('quiqqer-invoice-profile-invoices');
-        $this->addCSSFile(dirname(__FILE__).'/UserInvoices.css');
+        $this->addCSSFile(\dirname(__FILE__).'/UserInvoices.css');
 
         $this->setAttributes([
             // 'data-qui' => 'package/quiqqer/order/bin/frontend/controls/frontendusers/Orders',
@@ -79,7 +79,7 @@ public function getBody()
             'invoices' => $invoices
         ]);
 
-        return $Engine->fetch(dirname(__FILE__).'/UserInvoices.html');
+        return $Engine->fetch(\dirname(__FILE__).'/UserInvoices.html');
     }
 
     /**
diff --git a/src/QUI/ERP/Accounting/Invoice/Handler.php b/src/QUI/ERP/Accounting/Invoice/Handler.php
index df66272..1e4687a 100644
--- a/src/QUI/ERP/Accounting/Invoice/Handler.php
+++ b/src/QUI/ERP/Accounting/Invoice/Handler.php
@@ -266,7 +266,7 @@ public function get($id)
     {
         $prefix = Settings::getInstance()->getTemporaryInvoicePrefix();
 
-        if (strpos($id, $prefix) !== false) {
+        if (\strpos($id, $prefix) !== false) {
             return $this->getTemporaryInvoice($id);
         }
 
@@ -330,7 +330,7 @@ public function getInvoiceData($id)
     {
         $prefix = Settings::getInstance()->getInvoicePrefix();
 
-        if (!is_numeric(str_replace($prefix, '', $id))) {
+        if (!\is_numeric(\str_replace($prefix, '', $id))) {
             throw new Exception(
                 ['quiqqer/invoice', 'exception.invoice.not.found'],
                 404
@@ -340,7 +340,7 @@ public function getInvoiceData($id)
         $result = QUI::getDataBase()->fetch([
             'from'  => self::invoiceTable(),
             'where' => [
-                'id' => (int)str_replace($prefix, '', $id)
+                'id' => (int)\str_replace($prefix, '', $id)
             ],
             'limit' => 1
         ]);
@@ -427,7 +427,7 @@ public function getTemporaryInvoiceData($id)
         $result = QUI::getDataBase()->fetch([
             'from'  => self::temporaryInvoiceTable(),
             'where' => [
-                'id' => (int)str_replace($prefix, '', $id)
+                'id' => (int)\str_replace($prefix, '', $id)
             ],
             'limit' => 1
         ]);
@@ -547,12 +547,12 @@ protected function getOrderGroupFields()
      */
     protected function canBeUseAsOrderField($str)
     {
-        if (!is_string($str)) {
+        if (!\is_string($str)) {
             return false;
         }
 
-        $fields = array_flip($this->getOrderGroupFields());
-        $str    = explode(' ', $str);
+        $fields = \array_flip($this->getOrderGroupFields());
+        $str    = \explode(' ', $str);
 
         if (!isset($fields[$str[0]])) {
             return false;
@@ -562,8 +562,8 @@ protected function canBeUseAsOrderField($str)
             return true;
         }
 
-        if (mb_strtoupper($fields[$str[1]]) === 'DESC' ||
-            mb_strtoupper($fields[$str[1]]) === 'ASC') {
+        if (\mb_strtoupper($fields[$str[1]]) === 'DESC' ||
+            \mb_strtoupper($fields[$str[1]]) === 'ASC') {
             return true;
         }
 
diff --git a/src/QUI/ERP/Accounting/Invoice/Invoice.php b/src/QUI/ERP/Accounting/Invoice/Invoice.php
index 1c8aab6..7df2a4d 100644
--- a/src/QUI/ERP/Accounting/Invoice/Invoice.php
+++ b/src/QUI/ERP/Accounting/Invoice/Invoice.php
@@ -90,7 +90,7 @@ public function __construct($id, Handler $Handler)
             $this->prefix = Settings::getInstance()->getInvoicePrefix();
         }
 
-        $this->id   = (int)str_replace($this->prefix, '', $id);
+        $this->id   = (int)\str_replace($this->prefix, '', $id);
         $this->type = Handler::TYPE_INVOICE;
 
         switch ((int)$this->getAttribute('type')) {
@@ -103,7 +103,7 @@ public function __construct($id, Handler $Handler)
         }
 
         if ($this->getAttribute('data')) {
-            $this->data = json_decode($this->getAttribute('data'), true);
+            $this->data = \json_decode($this->getAttribute('data'), true);
         }
 
         if ($this->getAttribute('global_process_id')) {
@@ -113,9 +113,9 @@ public function __construct($id, Handler $Handler)
         // invoice payment data
         if ($this->getAttribute('payment_data')) {
             $paymentData = QUI\Security\Encryption::decrypt($this->getAttribute('payment_data'));
-            $paymentData = json_decode($paymentData, true);
+            $paymentData = \json_decode($paymentData, true);
 
-            if (is_array($paymentData)) {
+            if (\is_array($paymentData)) {
                 $this->paymentData = $paymentData;
             }
         }
@@ -159,7 +159,7 @@ public function getGlobalProcessId()
      */
     public function getCleanId()
     {
-        return (int)str_replace($this->prefix, '', $this->getId());
+        return (int)\str_replace($this->prefix, '', $this->getId());
     }
 
     /**
@@ -185,8 +185,8 @@ public function getArticles()
     {
         $articles = $this->getAttribute('articles');
 
-        if (is_string($articles)) {
-            $articles = json_decode($articles, true);
+        if (\is_string($articles)) {
+            $articles = \json_decode($articles, true);
         }
 
         return new ArticleListUnique($articles);
@@ -207,8 +207,8 @@ public function getCurrency()
             return QUI\ERP\Defaults::getCurrency();
         }
 
-        if (is_string($currency)) {
-            $currency = json_decode($currency, true);
+        if (\is_string($currency)) {
+            $currency = \json_decode($currency, true);
         }
 
         if (!$currency || !isset($currency['code'])) {
@@ -228,13 +228,13 @@ public function getCustomer()
         $invoiceAddress = $this->getAttribute('invoice_address');
         $customerData   = $this->getAttribute('customer_data');
 
-        if (is_string($customerData)) {
-            $customerData = json_decode($customerData, true);
+        if (\is_string($customerData)) {
+            $customerData = \json_decode($customerData, true);
         }
 
         // address
-        if (is_string($invoiceAddress)) {
-            $invoiceAddress = json_decode($invoiceAddress, true);
+        if (\is_string($invoiceAddress)) {
+            $invoiceAddress = \json_decode($invoiceAddress, true);
         }
 
         $userData = $customerData;
@@ -311,7 +311,7 @@ public function getPaidStatusInformation()
      */
     public function getPaymentDataEntry($key)
     {
-        if (array_key_exists($key, $this->paymentData)) {
+        if (\array_key_exists($key, $this->paymentData)) {
             return $this->paymentData[$key];
         }
 
@@ -365,8 +365,8 @@ public function getPayment()
             return new Payment([]);
         }
 
-        if (is_string($data)) {
-            $data = json_decode($data, true);
+        if (\is_string($data)) {
+            $data = \json_decode($data, true);
         }
 
         return new Payment($data);
@@ -492,7 +492,7 @@ public function reversal($reason, $PermissionUser = null)
             Handler::getInstance()->invoiceTable(),
             [
                 'type'        => $this->type,
-                'data'        => json_encode($this->data),
+                'data'        => \json_encode($this->data),
                 'paid_status' => self::PAYMENT_STATUS_CANCELED
             ],
             ['id' => $this->getCleanId()]
@@ -706,9 +706,9 @@ public function createCreditNote($PermissionUser = null, $globalProcessId = fals
         $currentDate = $this->getAttribute('date');
 
         if (!$currentDate) {
-            $currentDate = time();
+            $currentDate = \time();
         } else {
-            $currentDate = strtotime($currentDate);
+            $currentDate = \strtotime($currentDate);
         }
 
         $message = QUI::getLocale()->get(
@@ -730,7 +730,7 @@ public function createCreditNote($PermissionUser = null, $globalProcessId = fals
 
         // saving copy
         $Copy->setData('originalId', $this->getCleanId());
-        $Copy->setAttribute('date', date('Y-m-d H:i:s'));
+        $Copy->setAttribute('date', \date('Y-m-d H:i:s'));
         $Copy->setAttribute('additional_invoice_text', $additionalText);
         $Copy->setInvoiceType(Handler::TYPE_INVOICE_CREDIT_NOTE);
         $Copy->save(QUI::getUsers()->getSystemUser());
@@ -788,8 +788,8 @@ public function addTransaction(Transaction $Transaction)
             return;
         }
 
-        if (!is_array($paidData)) {
-            $paidData = json_decode($paidData, true);
+        if (!\is_array($paidData)) {
+            $paidData = \json_decode($paidData, true);
         }
 
         if ($date === false) {
@@ -823,10 +823,10 @@ function isTxAlreadyAdded($txid, $paidData)
         };
 
         if ($isValidTimeStamp($date) === false) {
-            $date = strtotime($date);
+            $date = \strtotime($date);
 
             if ($isValidTimeStamp($date) === false) {
-                $date = time();
+                $date = \time();
             }
         }
 
@@ -937,17 +937,17 @@ public function sendTo($recipient, $template = false)
         $Mailer->addRecipient($recipient);
 
         // invoice pdf file
-        $dir     = dirname($pdfFile);
+        $dir     = \dirname($pdfFile);
         $newFile = $dir.'/'.InvoiceUtils::getInvoiceFilename($this).'.pdf';
 
-        if ($newFile !== $pdfFile && file_exists($newFile)) {
-            unlink($newFile);
+        if ($newFile !== $pdfFile && \file_exists($newFile)) {
+            \unlink($newFile);
         }
 
-        rename($pdfFile, $newFile);
+        \rename($pdfFile, $newFile);
 
         $user = $this->getCustomer()->getName();
-        $user = trim($user);
+        $user = \trim($user);
 
         if (empty($user)) {
             $user = $this->getCustomer()->getAddress()->getName();
@@ -979,8 +979,8 @@ public function sendTo($recipient, $template = false)
             ])
         );
 
-        if (file_exists($pdfFile)) {
-            unlink($pdfFile);
+        if (\file_exists($pdfFile)) {
+            \unlink($pdfFile);
         }
     }
 
diff --git a/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php b/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php
index 9b59b34..098a6e3 100644
--- a/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php
+++ b/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php
@@ -86,14 +86,14 @@ public function __construct($id, Handler $Handler)
         $data = $Handler->getTemporaryInvoiceData($id);
 
         $this->prefix = Settings::getInstance()->getTemporaryInvoicePrefix();
-        $this->id     = (int)str_replace($this->prefix, '', $id);
+        $this->id     = (int)\str_replace($this->prefix, '', $id);
 
         $this->Articles = new ArticleList();
         $this->History  = new QUI\ERP\Comments();
         $this->Comments = new QUI\ERP\Comments();
 
         if (isset($data['articles'])) {
-            $articles = json_decode($data['articles'], true);
+            $articles = \json_decode($data['articles'], true);
 
             if ($articles) {
                 try {
@@ -122,17 +122,17 @@ public function __construct($id, Handler $Handler)
 
 
         // invoice extra data
-        $this->data = json_decode($data['data'], true);
+        $this->data = \json_decode($data['data'], true);
 
-        if (!is_array($this->data)) {
+        if (!\is_array($this->data)) {
             $this->data = [];
         }
 
         // invoice payment data
         $paymentData = QUI\Security\Encryption::decrypt($data['payment_data']);
-        $paymentData = json_decode($paymentData, true);
+        $paymentData = \json_decode($paymentData, true);
 
-        if (is_array($paymentData)) {
+        if (\is_array($paymentData)) {
             $this->paymentData = $paymentData;
         }
 
@@ -181,7 +181,7 @@ public function getId()
      */
     public function getCleanId()
     {
-        return (int)str_replace($this->prefix, '', $this->getId());
+        return (int)\str_replace($this->prefix, '', $this->getId());
     }
 
     /**
@@ -254,8 +254,8 @@ public function getCustomer()
 
 
         // address
-        if (is_string($invoiceAddress)) {
-            $invoiceAddress = json_decode($invoiceAddress, true);
+        if (\is_string($invoiceAddress)) {
+            $invoiceAddress = \json_decode($invoiceAddress, true);
         }
 
         if (!isset($userData['isCompany'])) {
@@ -306,8 +306,8 @@ public function getCurrency()
             return QUI\ERP\Defaults::getCurrency();
         }
 
-        if (is_string($currency)) {
-            $currency = json_decode($currency, true);
+        if (\is_string($currency)) {
+            $currency = \json_decode($currency, true);
         }
 
         if (!$currency || !isset($currency['code'])) {
@@ -590,8 +590,8 @@ public function update($PermissionUser = null)
             $invoiceAddress      = $this->getAttribute('invoice_address');
             $invoiceAddressCheck = false;
 
-            if (is_string($invoiceAddress)) {
-                $invoiceAddressCheck = json_decode($invoiceAddress, true);
+            if (\is_string($invoiceAddress)) {
+                $invoiceAddressCheck = \json_decode($invoiceAddress, true);
             }
 
             if (!$invoiceAddressCheck) {
@@ -686,7 +686,7 @@ public function update($PermissionUser = null)
 
                 // payments
                 'payment_method'          => $paymentMethod,
-                'payment_data'            => QUI\Security\Encryption::encrypt(json_encode($this->paymentData)),
+                'payment_data'            => QUI\Security\Encryption::encrypt(\json_encode($this->paymentData)),
                 'payment_time'            => null,
 
                 // address
@@ -705,7 +705,7 @@ public function update($PermissionUser = null)
 
                 // invoice data
                 'date'                    => $date,
-                'data'                    => json_encode($this->data),
+                'data'                    => \json_encode($this->data),
                 'articles'                => $this->Articles->toJSON(),
                 'history'                 => $this->History->toJSON(),
                 'comments'                => $this->Comments->toJSON(),
@@ -714,12 +714,12 @@ public function update($PermissionUser = null)
 
                 // Calc data
                 'isbrutto'                => $isBrutto,
-                'currency_data'           => json_encode($listCalculations['currencyData']),
+                'currency_data'           => \json_encode($listCalculations['currencyData']),
                 'currency'                => $listCalculations['currencyData']['code'],
                 'nettosum'                => $listCalculations['nettoSum'],
                 'subsum'                  => InvoiceUtils::roundInvoiceSum($listCalculations['subSum']),
                 'sum'                     => InvoiceUtils::roundInvoiceSum($listCalculations['sum']),
-                'vat_array'               => json_encode($listCalculations['vatArray'])
+                'vat_array'               => \json_encode($listCalculations['vatArray'])
             ],
             [
                 'id' => $this->getCleanId()
@@ -863,7 +863,7 @@ public function post($PermissionUser = null)
 
         // data
         $User     = QUI::getUserBySession();
-        $date     = date('Y-m-d H:i:s');
+        $date     = \date('Y-m-d H:i:s');
         $isBrutto = QUI\ERP\Defaults::getBruttoNettoStatus();
         $Customer = $this->getCustomer();
         $Handler  = Handler::getInstance();
@@ -948,8 +948,8 @@ public function post($PermissionUser = null)
             $paymentTime = 0;
         }
 
-        $timeForPayment = strtotime(date('Y-m-d').' 00:00 + '.$paymentTime.' days');
-        $timeForPayment = date('Y-m-d', $timeForPayment);
+        $timeForPayment = \strtotime(\date('Y-m-d').' 00:00 + '.$paymentTime.' days');
+        $timeForPayment = \date('Y-m-d', $timeForPayment);
         $timeForPayment .= ' 23:59:59';
 
 
@@ -974,7 +974,7 @@ public function post($PermissionUser = null)
 
         $uniqueList['calculations']['sum']    = InvoiceUtils::roundInvoiceSum($uniqueList['calculations']['sum']);
         $uniqueList['calculations']['subSum'] = InvoiceUtils::roundInvoiceSum($uniqueList['calculations']['subSum']);
-        $uniqueList                           = json_encode($uniqueList);
+        $uniqueList                           = \json_encode($uniqueList);
 
         // create invoice
         QUI::getDataBase()->insert(
@@ -993,7 +993,7 @@ public function post($PermissionUser = null)
                 'ordered_by'              => $orderedBy,
                 'ordered_by_name'         => $orderedByName,
                 'customer_id'             => $this->getCustomer()->getId(),
-                'customer_data'           => json_encode($customerData),
+                'customer_data'           => \json_encode($customerData),
 
                 // addresses
                 'invoice_address'         => $invoiceAddress,
@@ -1001,8 +1001,8 @@ public function post($PermissionUser = null)
 
                 // payments
                 'payment_method'          => $this->getAttribute('payment_method'),
-                'payment_method_data'     => json_encode($paymentMethodData),
-                'payment_data'            => QUI\Security\Encryption::encrypt(json_encode($this->paymentData)),
+                'payment_method_data'     => \json_encode($paymentMethodData),
+                'payment_data'            => QUI\Security\Encryption::encrypt(\json_encode($this->paymentData)),
                 'payment_time'            => null,
                 'time_for_payment'        => $timeForPayment,
 
@@ -1015,7 +1015,7 @@ public function post($PermissionUser = null)
                 'hash'                    => $this->getAttribute('hash'),
                 'project_name'            => $this->getAttribute('project_name'),
                 'date'                    => $date,
-                'data'                    => json_encode($this->data),
+                'data'                    => \json_encode($this->data),
                 'additional_invoice_text' => $this->getAttribute('additional_invoice_text'),
                 'articles'                => $uniqueList,
                 'history'                 => $this->getHistory()->toJSON(),
@@ -1023,13 +1023,13 @@ public function post($PermissionUser = null)
 
                 // calculation data
                 'isbrutto'                => $isBrutto,
-                'currency_data'           => json_encode($listCalculations['currencyData']),
+                'currency_data'           => \json_encode($listCalculations['currencyData']),
                 'currency'                => $listCalculations['currencyData']['code'],
                 'nettosum'                => $listCalculations['nettoSum'],
                 'nettosubsum'             => $listCalculations['nettoSubSum'],
                 'subsum'                  => InvoiceUtils::roundInvoiceSum($listCalculations['subSum']),
                 'sum'                     => InvoiceUtils::roundInvoiceSum($listCalculations['sum']),
-                'vat_array'               => json_encode($listCalculations['vatArray'])
+                'vat_array'               => \json_encode($listCalculations['vatArray'])
             ]
         );
 
@@ -1071,7 +1071,7 @@ public function post($PermissionUser = null)
             QUI::getDataBase()->update(
                 $Handler->invoiceTable(),
                 [
-                    'paid_data'   => json_encode($calculation['paidData']),
+                    'paid_data'   => \json_encode($calculation['paidData']),
                     'paid_date'   => (int)$calculation['paidDate'],
                     'paid_status' => (int)$calculation['paidStatus']
                 ],
@@ -1202,7 +1202,7 @@ public function clearArticles()
      */
     public function importArticles($articles = [])
     {
-        if (!is_array($articles)) {
+        if (!\is_array($articles)) {
             $articles = [];
         }
 
@@ -1214,7 +1214,7 @@ public function importArticles($articles = [])
 
         foreach ($articles as $article) {
             try {
-                if (isset($article['class']) && class_exists($article['class'])) {
+                if (isset($article['class']) && \class_exists($article['class'])) {
                     $Article = new $article['class']($article);
 
                     if ($Article instanceof QUI\ERP\Accounting\Article) {
diff --git a/src/QUI/ERP/Accounting/Invoice/InvoiceView.php b/src/QUI/ERP/Accounting/Invoice/InvoiceView.php
index 7f5b2b1..3fb8550 100644
--- a/src/QUI/ERP/Accounting/Invoice/InvoiceView.php
+++ b/src/QUI/ERP/Accounting/Invoice/InvoiceView.php
@@ -101,7 +101,7 @@ public function getDate($Locale = null)
         $date      = $this->Invoice->getAttribute('date');
         $Formatter = $Locale->getDateFormatter();
 
-        return $Formatter->format(strtotime($date));
+        return $Formatter->format(\strtotime($date));
     }
 
     /**
@@ -271,7 +271,7 @@ public function getTemplate()
         $address   = [];
 
         if ($this->Invoice->getAttribute('invoice_address')) {
-            $address = json_decode($this->Invoice->getAttribute('invoice_address'), true);
+            $address = \json_decode($this->Invoice->getAttribute('invoice_address'), true);
         }
 
         $Engine = $Template->getEngine();
@@ -296,7 +296,7 @@ public function getTemplate()
         // list calculation
         $Articles = $this->Invoice->getArticles();
 
-        if (get_class($Articles) !== QUI\ERP\Accounting\ArticleListUnique::class) {
+        if (\get_class($Articles) !== QUI\ERP\Accounting\ArticleListUnique::class) {
             $Articles->setUser($Customer);
             $Articles = $Articles->toUniqueList();
         }
@@ -315,15 +315,15 @@ public function getTemplate()
             }
 
             if ($timeForPayment) {
-                $timeForPayment = strtotime('+'.$timeForPayment.' day');
+                $timeForPayment = \strtotime('+'.$timeForPayment.' day');
                 $timeForPayment = $Formatter->format($timeForPayment);
             } else {
                 $timeForPayment = $Locale->get('quiqqer/invoice', 'additional.invoice.text.timeForPayment.0');
             }
         } else {
-            $timeForPayment = strtotime($timeForPayment);
+            $timeForPayment = \strtotime($timeForPayment);
 
-            if (date('Y-m-d') === date('Y-m-d', $timeForPayment)) {
+            if (\date('Y-m-d') === \date('Y-m-d', $timeForPayment)) {
                 $timeForPayment = $Locale->get('quiqqer/invoice', 'additional.invoice.text.timeForPayment.0');
             } else {
                 $timeForPayment = $Formatter->format($timeForPayment);
@@ -336,7 +336,7 @@ public function getTemplate()
 
         if (!empty($transactions)) {
             /* @var $Transaction QUI\ERP\Accounting\Payments\Transactions\Transaction */
-            $Transaction = array_pop($transactions);
+            $Transaction = \array_pop($transactions);
             $Payment     = $Transaction->getPayment(); // payment method
             $PaymentType = $this->getPayment(); // payment method
 
@@ -348,7 +348,7 @@ public function getTemplate()
             }
 
             $transactionText = $Locale->get('quiqqer/invoice', 'invoice.view.payment.transaction.text', [
-                'date'    => $Formatter->format(strtotime($Transaction->getDate())),
+                'date'    => $Formatter->format(\strtotime($Transaction->getDate())),
                 'payment' => $payment
             ]);
         }
diff --git a/src/QUI/ERP/Accounting/Invoice/NumberRanges/Invoice.php b/src/QUI/ERP/Accounting/Invoice/NumberRanges/Invoice.php
index 574ac4e..8fd3132 100644
--- a/src/QUI/ERP/Accounting/Invoice/NumberRanges/Invoice.php
+++ b/src/QUI/ERP/Accounting/Invoice/NumberRanges/Invoice.php
@@ -50,7 +50,7 @@ public function getRange()
      */
     public function setRange($range)
     {
-        if (!is_numeric($range)) {
+        if (!\is_numeric($range)) {
             return;
         }
 
diff --git a/src/QUI/ERP/Accounting/Invoice/NumberRanges/TemporaryInvoice.php b/src/QUI/ERP/Accounting/Invoice/NumberRanges/TemporaryInvoice.php
index 33c6089..5497128 100644
--- a/src/QUI/ERP/Accounting/Invoice/NumberRanges/TemporaryInvoice.php
+++ b/src/QUI/ERP/Accounting/Invoice/NumberRanges/TemporaryInvoice.php
@@ -50,7 +50,7 @@ public function getRange()
      */
     public function setRange($range)
     {
-        if (!is_numeric($range)) {
+        if (!\is_numeric($range)) {
             return;
         }
 
diff --git a/src/QUI/ERP/Accounting/Invoice/Payment.php b/src/QUI/ERP/Accounting/Invoice/Payment.php
index e50c587..7e68690 100644
--- a/src/QUI/ERP/Accounting/Invoice/Payment.php
+++ b/src/QUI/ERP/Accounting/Invoice/Payment.php
@@ -78,7 +78,7 @@ public function getTitle($Locale = null)
             return $this->attributes['title'][$current];
         }
 
-        return reset($this->attributes['title']);
+        return \reset($this->attributes['title']);
     }
 
     /**
@@ -103,7 +103,7 @@ public function getDescription($Locale = null)
             return $this->attributes['description'][$current];
         }
 
-        return reset($this->attributes['description']);
+        return \reset($this->attributes['description']);
     }
 
     /**
diff --git a/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Factory.php b/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Factory.php
index 18b4aff..8ff5639 100644
--- a/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Factory.php
+++ b/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Factory.php
@@ -46,7 +46,7 @@ public function createProcessingStatus($id, $color, array $title)
         $Config->save();
 
         // translations
-        if (is_array($title)) {
+        if (\is_array($title)) {
             $languages = QUI::availableLanguages();
 
             foreach ($languages as $language) {
@@ -78,11 +78,11 @@ public function getNextId()
     {
         $list = Handler::getInstance()->getList();
 
-        if (!count($list)) {
+        if (!\count($list)) {
             return 1;
         }
 
-        $max = max(array_keys($list));
+        $max = \max(\array_keys($list));
 
         return $max + 1;
     }
diff --git a/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Handler.php b/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Handler.php
index 96aface..9e2c0c2 100644
--- a/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Handler.php
+++ b/src/QUI/ERP/Accounting/Invoice/ProcessingStatus/Handler.php
@@ -34,11 +34,16 @@ public function getList()
             return $this->list;
         }
 
-        $Package = QUI::getPackage('quiqqer/invoice');
-        $Config  = $Package->getConfig();
-        $result  = $Config->getSection('processing_status');
+        try {
+            $Package = QUI::getPackage('quiqqer/invoice');
+            $Config  = $Package->getConfig();
+        } catch (QUI\Exception $Exception) {
+            return [];
+        }
+
+        $result = $Config->getSection('processing_status');
 
-        if (!$result || !is_array($result)) {
+        if (!$result || !\is_array($result)) {
             $this->list = [];
 
             return $this->list;
@@ -74,6 +79,8 @@ public function getProcessingStatusList()
      *
      * @param $id
      * @return Status
+     *
+     * @throws Exception
      */
     public function getProcessingStatus($id)
     {
@@ -85,6 +92,9 @@ public function getProcessingStatus($id)
      *
      * @param string|int $id
      *
+     * @throws Exception
+     * @throws QUI\Exception
+     *
      * @todo permissions
      */
     public function deleteProcessingStatus($id)
@@ -114,6 +124,9 @@ public function deleteProcessingStatus($id)
      * @param int|string $color
      * @param array $title
      *
+     * @throws Exception
+     * @throws QUI\Exception
+     *
      * @todo permissions
      */
     public function updateProcessingStatus($id, $color, array $title)
diff --git a/src/QUI/ERP/Accounting/Invoice/Search/InvoiceSearch.php b/src/QUI/ERP/Accounting/Invoice/Search/InvoiceSearch.php
index 023589d..e8b1748 100644
--- a/src/QUI/ERP/Accounting/Invoice/Search/InvoiceSearch.php
+++ b/src/QUI/ERP/Accounting/Invoice/Search/InvoiceSearch.php
@@ -66,13 +66,13 @@ public function setFilter($filter, $value)
             return;
         }
 
-        $keys = array_flip($this->getAllowedFields());
+        $keys = \array_flip($this->getAllowedFields());
 
         if (!isset($keys[$filter]) && $filter !== 'from' && $filter !== 'to') {
             return;
         }
 
-        if (!is_array($value)) {
+        if (!\is_array($value)) {
             $value = [$value];
         }
 
@@ -102,12 +102,12 @@ public function setFilter($filter, $value)
                 continue;
             }
 
-            if ($filter === 'from' && is_numeric($val)) {
-                $val = date('Y-m-d 00:00:00', $val);
+            if ($filter === 'from' && \is_numeric($val)) {
+                $val = \date('Y-m-d 00:00:00', $val);
             }
 
-            if ($filter === 'to' && is_numeric($val)) {
-                $val = date('Y-m-d 23:59:59', $val);
+            if ($filter === 'to' && \is_numeric($val)) {
+                $val = \date('Y-m-d 23:59:59', $val);
             }
 
             $this->filter[] = [
@@ -153,8 +153,8 @@ public function order($order)
             $allowed[] = $field.' desc';
         }
 
-        $order   = trim($order);
-        $allowed = array_flip($allowed);
+        $order   = \trim($order);
+        $allowed = \array_flip($allowed);
 
         if (isset($allowed[$order])) {
             $this->order = $order;
@@ -374,9 +374,9 @@ protected function getQuery($count = false)
             ];
         }
 
-        $whereQuery = 'WHERE '.implode(' AND ', $where);
+        $whereQuery = 'WHERE '.\implode(' AND ', $where);
 
-        if (!count($where)) {
+        if (!\count($where)) {
             $whereQuery = '';
         }
 
@@ -513,7 +513,7 @@ protected function parseListForGrid($data)
             $fillFields($invoiceData);
 
             try {
-                $currency = json_decode($Invoice->getAttribute('currency_data'), true);
+                $currency = \json_decode($Invoice->getAttribute('currency_data'), true);
                 $Currency = Currencies::getCurrency($currency['code']);
             } catch (QUI\Exception $Exception) {
                 $Currency = QUI\ERP\Defaults::getCurrency();
@@ -538,14 +538,14 @@ protected function parseListForGrid($data)
             }
 
 
-            $timeForPayment = strtotime($Invoice->getAttribute('time_for_payment'));
+            $timeForPayment = \strtotime($Invoice->getAttribute('time_for_payment'));
 
             $invoiceData['globalProcessId']  = $Invoice->getGlobalProcessId();
-            $invoiceData['date']             = $DateFormatter->format(strtotime($Invoice->getAttribute('date')));
+            $invoiceData['date']             = $DateFormatter->format(\strtotime($Invoice->getAttribute('date')));
             $invoiceData['time_for_payment'] = $DateFormatter->format($timeForPayment);
 
             if ($Invoice->getAttribute('paid_date')) {
-                $invoiceData['paid_date'] = date('Y-m-d', $Invoice->getAttribute('paid_date'));
+                $invoiceData['paid_date'] = \date('Y-m-d', $Invoice->getAttribute('paid_date'));
             } else {
                 $invoiceData['paid_date'] = Handler::EMPTY_VALUE;
             }
@@ -574,7 +574,7 @@ protected function parseListForGrid($data)
             }
 
             $invoiceData['id'] = $invoiceData['id_prefix'].$invoiceData['id'];
-            $invoiceAddress    = json_decode($invoiceData['invoice_address'], true);
+            $invoiceAddress    = \json_decode($invoiceData['invoice_address'], true);
 
             $invoiceData['customer_name'] = $invoiceAddress['salutation'].' '.
                                             $invoiceAddress['firstname'].' '.
@@ -609,7 +609,7 @@ protected function parseListForGrid($data)
             $invoiceData['calculated_vatsum'] = $vatSum;
 
             // customer data
-            $customerData = json_decode($invoiceData['customer_data'], true);
+            $customerData = \json_decode($invoiceData['customer_data'], true);
 
             if (empty($customerData['erp.taxId'])) {
                 $customerData['erp.taxId'] = Handler::EMPTY_VALUE;
@@ -618,7 +618,7 @@ protected function parseListForGrid($data)
             $invoiceData['taxId'] = $customerData['erp.taxId'];
 
             // overdue check
-            if (time() > $timeForPayment &&
+            if (\time() > $timeForPayment &&
                 $Invoice->getAttribute('paid_status') != Invoice::PAYMENT_STATUS_PAID &&
                 $Invoice->getAttribute('paid_status') != Invoice::PAYMENT_STATUS_CANCELED
             ) {
diff --git a/src/QUI/ERP/Accounting/Invoice/Settings.php b/src/QUI/ERP/Accounting/Invoice/Settings.php
index c48d9d0..a43bd09 100644
--- a/src/QUI/ERP/Accounting/Invoice/Settings.php
+++ b/src/QUI/ERP/Accounting/Invoice/Settings.php
@@ -107,7 +107,7 @@ public function sendMailAtInvoiceCreation()
     public function getInvoicePrefix()
     {
         if ($this->invoicePrefix !== null) {
-            return strftime($this->invoicePrefix);
+            return \strftime($this->invoicePrefix);
         }
 
         $Package = QUI::getPackage('quiqqer/invoice');
@@ -120,7 +120,7 @@ public function getInvoicePrefix()
             $this->invoicePrefix = $setting;
         }
 
-        return strftime($this->invoicePrefix);
+        return \strftime($this->invoicePrefix);
     }
 
     /**
@@ -134,7 +134,7 @@ public function getInvoicePrefix()
     public function getTemporaryInvoicePrefix()
     {
         if ($this->temporaryInvoicePrefix !== null) {
-            return strftime($this->temporaryInvoicePrefix);
+            return \strftime($this->temporaryInvoicePrefix);
         }
 
         $Package = QUI::getPackage('quiqqer/invoice');
@@ -147,7 +147,7 @@ public function getTemporaryInvoicePrefix()
             $this->temporaryInvoicePrefix = $setting;
         }
 
-        return strftime($this->temporaryInvoicePrefix);
+        return \strftime($this->temporaryInvoicePrefix);
     }
 
     /**
@@ -215,7 +215,7 @@ public function getDefaultTemplate()
             return '';
         }
 
-        $first = reset($available);
+        $first = \reset($available);
 
         return $first['name'];
     }
diff --git a/src/QUI/ERP/Accounting/Invoice/Utils/Invoice.php b/src/QUI/ERP/Accounting/Invoice/Utils/Invoice.php
index 0259cc6..1a61631 100644
--- a/src/QUI/ERP/Accounting/Invoice/Utils/Invoice.php
+++ b/src/QUI/ERP/Accounting/Invoice/Utils/Invoice.php
@@ -78,7 +78,7 @@ public static function getMissingAttributes(InvoiceTemporary $Invoice)
         $missing = [];
 
         // address / customer fields
-        $missing = array_merge(
+        $missing = \array_merge(
             $missing,
             self::getMissingAddressFields($Invoice)
         );
@@ -96,7 +96,7 @@ public static function getMissingAttributes(InvoiceTemporary $Invoice)
             $missing[] = 'payment';
         }
 
-        $missing = array_unique($missing);
+        $missing = \array_unique($missing);
 
         return $missing;
     }
@@ -126,7 +126,7 @@ protected static function getMissingAddressFields(InvoiceTemporary $Invoice)
         ];
 
         if (!empty($address)) {
-            $address = json_decode($address, true);
+            $address = \json_decode($address, true);
 
             foreach ($addressNeedles as $addressNeedle) {
                 if (!isset($address[$addressNeedle])) {
@@ -193,8 +193,8 @@ protected static function getMissingAddressFields(InvoiceTemporary $Invoice)
 
         // company check
         // @todo better company check
-        if ($Customer && $Customer->isCompany() && in_array('invoice_address_lastname', $missing)) {
-            unset($missing[array_search('invoice_address_lastname', $missing)]);
+        if ($Customer && $Customer->isCompany() && \in_array('invoice_address_lastname', $missing)) {
+            unset($missing[\array_search('invoice_address_lastname', $missing)]);
         }
 
         return $missing;
@@ -253,10 +253,10 @@ public static function getMissingAttributeMessage($missingAttribute)
      */
     public static function formatArticlesArray($articles)
     {
-        $isString = is_string($articles);
+        $isString = \is_string($articles);
 
         if ($isString) {
-            $articles = json_decode($articles, true);
+            $articles = \json_decode($articles, true);
         }
 
         try {
@@ -287,7 +287,7 @@ public static function formatArticlesArray($articles)
         }
 
         if ($isString) {
-            return json_encode($articles);
+            return \json_encode($articles);
         }
 
         return $articles;
@@ -337,11 +337,11 @@ public static function getInvoiceFilename($Invoice, $Locale = null)
         );
 
         $date = $Invoice->getAttribute('date');
-        $date = strtotime($date);
+        $date = \strtotime($date);
 
-        $year  = date('Y', $date);
-        $month = date('m', $date);
-        $day   = date('d', $date);
+        $year  = \date('Y', $date);
+        $month = \date('m', $date);
+        $day   = \date('d', $date);
 
         $placeholders = [
             '%HASH%'  => $Invoice->getHash(),
@@ -368,7 +368,7 @@ public static function getInvoiceFilename($Invoice, $Locale = null)
         $fileName = $Locale->get('quiqqer/invoice', 'pdf.download.name');
 
         foreach ($placeholders as $placeholder => $value) {
-            $fileName = str_replace($placeholder, $value, $fileName);
+            $fileName = \str_replace($placeholder, $value, $fileName);
         }
 
         $fileName = QUI\Utils\Security\Orthos::clearFilename($fileName);
@@ -402,10 +402,10 @@ public static function getInvoiceTimeForPaymentDate($Invoice)
             $timeForPayment = (int)$timeForPayment;
 
             if ($timeForPayment) {
-                $timeForPayment = strtotime('+'.$timeForPayment.' day');
+                $timeForPayment = \strtotime('+'.$timeForPayment.' day');
             }
         } else {
-            $timeForPayment = strtotime($timeForPayment);
+            $timeForPayment = \strtotime($timeForPayment);
         }
 
         return $timeForPayment;
@@ -418,15 +418,15 @@ public static function getInvoiceTimeForPaymentDate($Invoice)
      */
     public static function getVatTextArrayFromVatArray($vatArray, QUI\ERP\Currency\Currency $Currency)
     {
-        if (is_string($vatArray)) {
-            $vatArray = json_decode($vatArray, true);
+        if (\is_string($vatArray)) {
+            $vatArray = \json_decode($vatArray, true);
         }
 
-        if (!is_array($vatArray)) {
+        if (!\is_array($vatArray)) {
             $vatArray = [];
         }
 
-        return array_map(function ($data) use ($Currency) {
+        return \array_map(function ($data) use ($Currency) {
             return $data['text'].': '.$Currency->format($data['sum']);
         }, $vatArray);
     }
@@ -437,15 +437,15 @@ public static function getVatTextArrayFromVatArray($vatArray, QUI\ERP\Currency\C
      */
     public static function getVatSumArrayFromVatArray($vatArray)
     {
-        if (is_string($vatArray)) {
-            $vatArray = json_decode($vatArray, true);
+        if (\is_string($vatArray)) {
+            $vatArray = \json_decode($vatArray, true);
         }
 
-        if (!is_array($vatArray)) {
+        if (!\is_array($vatArray)) {
             $vatArray = [];
         }
 
-        return array_map(function ($data) {
+        return \array_map(function ($data) {
             return $data['sum'];
         }, $vatArray);
     }
@@ -458,7 +458,7 @@ public static function getVatSumArrayFromVatArray($vatArray)
      */
     public static function getVatSumFromVatArray($vatArray)
     {
-        return array_sum(
+        return \array_sum(
             self::getVatSumArrayFromVatArray($vatArray)
         );
     }
diff --git a/src/QUI/ERP/Accounting/Invoice/Utils/Template.php b/src/QUI/ERP/Accounting/Invoice/Utils/Template.php
index f9ebe43..74b3367 100644
--- a/src/QUI/ERP/Accounting/Invoice/Utils/Template.php
+++ b/src/QUI/ERP/Accounting/Invoice/Utils/Template.php
@@ -79,7 +79,7 @@ public function renderPreview()
     {
         $output = '';
         $output .= '<style>';
-        $output .= file_get_contents(dirname(__FILE__).'/Template.Preview.css');
+        $output .= \file_get_contents(\dirname(__FILE__).'/Template.Preview.css');
         $output .= '</style>';
         $output .= $this->render();
 
@@ -163,15 +163,15 @@ protected function getTemplate($template)
         $Engine = $this->getEngine();
         $output = '';
 
-        if (file_exists($phpFile)) {
+        if (\file_exists($phpFile)) {
             include $phpFile;
         }
 
-        if (file_exists($cssFile)) {
-            $output .= '<style>'.file_get_contents($cssFile).'</style>';
+        if (\file_exists($cssFile)) {
+            $output .= '<style>'.\file_get_contents($cssFile).'</style>';
         }
 
-        if (file_exists($htmlFile)) {
+        if (\file_exists($htmlFile)) {
             $output .= $Engine->fetch($htmlFile);
         }
 
@@ -191,22 +191,22 @@ public function getFile($wanted)
         $usrPath = USR_DIR.$package.'/template/';
         $type    = $this->getTemplateType();
 
-        if (file_exists($usrPath.$type.'/'.$wanted)) {
+        if (\file_exists($usrPath.$type.'/'.$wanted)) {
             return $usrPath.$type.'/'.$wanted;
         }
 
-        if (file_exists($usrPath.$wanted)) {
+        if (\file_exists($usrPath.$wanted)) {
             return $usrPath.$wanted;
         }
 
 
         $optPath = OPT_DIR.$package.'/template/';
 
-        if (file_exists($optPath.$type.'/'.$wanted)) {
+        if (\file_exists($optPath.$type.'/'.$wanted)) {
             return $optPath.$type.'/'.$wanted;
         }
 
-        if (file_exists($optPath.$wanted)) {
+        if (\file_exists($optPath.$wanted)) {
             return $optPath.$wanted;
         }
 
-- 
GitLab