From 831281f4ff46143f519081595329e80ed501c5e7 Mon Sep 17 00:00:00 2001
From: "kevin.dezaphi" <kevin.dezaphi@maarch.org>
Date: Fri, 26 Oct 2018 17:17:08 +0200
Subject: [PATCH] fix count arr_order empty

---
 apps/maarch_entreprise/documents_list_copies.php           | 4 ++--
 apps/maarch_entreprise/documents_list_with_attachments.php | 4 ++--
 modules/avis/documents_list_with_avis.php                  | 2 +-
 modules/visa/documents_list_with_signatory.php             | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/apps/maarch_entreprise/documents_list_copies.php b/apps/maarch_entreprise/documents_list_copies.php
index 09389aff4bd..b9bafcd33c3 100755
--- a/apps/maarch_entreprise/documents_list_copies.php
+++ b/apps/maarch_entreprise/documents_list_copies.php
@@ -130,7 +130,7 @@ $where = implode(' and ', $where_tab);
 
 $order = $order_field = '';
 $arr_order = explode(', ', $_SESSION['current_basket']['basket_res_order']);
-if (count($arr_order) == 1) {
+if (!empty($arr_order) && count($arr_order) == 1) {
     $order = $list->getOrder();
     $order_field = $list->getOrderField();
 }
@@ -158,7 +158,7 @@ if (!empty($order_field) && !empty($order)) {
     $_SESSION['last_order_basket'] = $orderstr;
 } else {
     if (!empty($_SESSION['current_basket']['basket_res_order'])) {
-        if (count($arr_order) == 1) {
+        if (!empty($arr_order) && count($arr_order) == 1) {
             $orders = explode(' ', $arr_order[0]);
             if (!empty($orders[1])) {
                 $list->setOrder($orders[1]);
diff --git a/apps/maarch_entreprise/documents_list_with_attachments.php b/apps/maarch_entreprise/documents_list_with_attachments.php
index 03062f1fbea..2ab880a34ee 100755
--- a/apps/maarch_entreprise/documents_list_with_attachments.php
+++ b/apps/maarch_entreprise/documents_list_with_attachments.php
@@ -129,7 +129,7 @@ $where = implode(' and ', $where_tab);
 
 $order = $order_field = '';
 $arr_order = explode(', ', $_SESSION['current_basket']['basket_res_order']);
-if (count($arr_order) == 1) {
+if (!empty($arr_order) && count($arr_order) == 1) {
     $order = $list->getOrder();
     $order_field = $list->getOrderField();
 }
@@ -157,7 +157,7 @@ if (!empty($order_field) && !empty($order)) {
     $_SESSION['last_order_basket'] = $orderstr;
 } else {
     if (!empty($_SESSION['current_basket']['basket_res_order'])) {
-        if (count($arr_order) == 1) {
+        if (!empty($arr_order) && count($arr_order) == 1) {
             $orders = explode(' ', $arr_order[0]);
             if (!empty($orders[1])) {
                 $list->setOrder($orders[1]);
diff --git a/modules/avis/documents_list_with_avis.php b/modules/avis/documents_list_with_avis.php
index 5ab2239ebff..070ec1446ea 100755
--- a/modules/avis/documents_list_with_avis.php
+++ b/modules/avis/documents_list_with_avis.php
@@ -153,7 +153,7 @@ if (!empty($order_field) && !empty($order)) {
     $_SESSION['last_order_basket'] = $orderstr;
 } else {
     if (!empty($_SESSION['current_basket']['basket_res_order'])) {
-        if (count($arr_order) == 1) {
+        if (!empty($arr_order) && count($arr_order) == 1) {
             $orders = explode(' ', $arr_order[0]);
             if (!empty($orders[1])) {
                 $list->setOrder($orders[1]);
diff --git a/modules/visa/documents_list_with_signatory.php b/modules/visa/documents_list_with_signatory.php
index 87bfc7c1c09..127821f3e4b 100755
--- a/modules/visa/documents_list_with_signatory.php
+++ b/modules/visa/documents_list_with_signatory.php
@@ -125,7 +125,7 @@ $where = implode(' and ', $where_tab);
 //Order
 $order = $order_field = '';
 $arr_order = explode(', ', $_SESSION['current_basket']['basket_res_order']);
-if (count($arr_order) == 1) {
+if (!empty($arr_order) && count($arr_order) == 1) {
     $order = $list->getOrder();
     $order_field = $list->getOrderField();
 }
@@ -153,7 +153,7 @@ if (!empty($order_field) && !empty($order)) {
     $_SESSION['last_order_basket'] = $orderstr;
 } else {
     if (!empty($_SESSION['current_basket']['basket_res_order'])) {
-        if (count($arr_order) == 1) {
+        if (!empty($arr_order) && count($arr_order) == 1) {
             $orders = explode(' ', $arr_order[0]);
             if (!empty($orders[1])) {
                 $list->setOrder($orders[1]);
-- 
GitLab