From d0a599a1d85e23b6d940f65ec347d903952e6f35 Mon Sep 17 00:00:00 2001
From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com>
Date: Tue, 22 Oct 2019 15:51:30 +0200
Subject: [PATCH 1/5] Reduce the $companystatic calls
---
htdocs/commande/list.php | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 115bc46813a..470509aa50a 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -236,7 +236,6 @@ $now=dol_now();
$form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
-$companystatic = new Societe($db);
$formcompany=new FormCompany($db);
$projectstatic=new Project($db);
@@ -771,6 +770,9 @@ if ($resql)
$generic_commande = new Commande($db);
$generic_product = new Product($db);
+
+ $companystatic = array();
+ $getNomUrl = array();
$i=0;
$totalarray=array();
@@ -783,12 +785,16 @@ if ($resql)
$text_info='';
$text_warning='';
$nbprod=0;
-
- $companystatic->id=$obj->socid;
- $companystatic->code_client = $obj->code_client;
- $companystatic->name=$obj->name;
- $companystatic->client=$obj->client;
- $companystatic->email=$obj->email;
+
+ if (!isset($companystatic[$obj->socid])) {
+ $companystatic[$obj->socid] = new Societe($db);
+ $companystatic[$obj->socid]->id = $obj->socid;
+ $companystatic[$obj->socid]->code_client = $obj->code_client;
+ $companystatic[$obj->socid]->name = $obj->name;
+ $companystatic[$obj->socid]->client = $obj->client;
+ $companystatic[$obj->socid]->email = $obj->email;
+ $getNomUrl[$obj->socid] = $companystatic[$obj->socid]->getNomUrl(1, 'customer');
+ }
$generic_commande->id=$obj->rowid;
$generic_commande->ref=$obj->ref;
@@ -973,7 +979,7 @@ if ($resql)
if (! empty($arrayfields['s.nom']['checked']))
{
print '
';
- print $companystatic->getNomUrl(1, 'customer');
+ print $getNomUrl[$obj->socid];
// If module invoices enabled and user with invoice creation permissions
if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER))
@@ -982,8 +988,8 @@ if ($resql)
{
if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0))
{
- print ' ';
- print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'';
+ print ' ';
+ print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic[$obj->socid]->name, 'object_bill', 'hideonsmartphone').'';
}
}
}
From e807cb6b036c6931bbfe7ad1375e5587e039d340 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Tue, 22 Oct 2019 15:00:58 +0000
Subject: [PATCH 2/5] Fixing style errors.
---
htdocs/commande/list.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 470509aa50a..7f98733ba94 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -770,7 +770,7 @@ if ($resql)
$generic_commande = new Commande($db);
$generic_product = new Product($db);
-
+
$companystatic = array();
$getNomUrl = array();
@@ -785,7 +785,7 @@ if ($resql)
$text_info='';
$text_warning='';
$nbprod=0;
-
+
if (!isset($companystatic[$obj->socid])) {
$companystatic[$obj->socid] = new Societe($db);
$companystatic[$obj->socid]->id = $obj->socid;
From da136ef641ddfbcea91547f33f83dc8dae45aa3c Mon Sep 17 00:00:00 2001
From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com>
Date: Wed, 23 Oct 2019 08:57:07 +0200
Subject: [PATCH 3/5] Reduce the $companystatic calls
Store $companystatic->getNomUrl() in $getNomUrl_cache[];
---
htdocs/commande/list.php | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 7f98733ba94..f548f7682cc 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -236,6 +236,7 @@ $now=dol_now();
$form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
+$companystatic = new Societe($db);
$formcompany=new FormCompany($db);
$projectstatic=new Project($db);
@@ -767,13 +768,11 @@ if ($resql)
$total=0;
$subtotal=0;
$productstat_cache=array();
+ $getNomUrl_cache=array();
$generic_commande = new Commande($db);
$generic_product = new Product($db);
- $companystatic = array();
- $getNomUrl = array();
-
$i=0;
$totalarray=array();
while ($i < min($num, $limit))
@@ -785,16 +784,15 @@ if ($resql)
$text_info='';
$text_warning='';
$nbprod=0;
-
- if (!isset($companystatic[$obj->socid])) {
- $companystatic[$obj->socid] = new Societe($db);
- $companystatic[$obj->socid]->id = $obj->socid;
- $companystatic[$obj->socid]->code_client = $obj->code_client;
- $companystatic[$obj->socid]->name = $obj->name;
- $companystatic[$obj->socid]->client = $obj->client;
- $companystatic[$obj->socid]->email = $obj->email;
- $getNomUrl[$obj->socid] = $companystatic[$obj->socid]->getNomUrl(1, 'customer');
- }
+
+ $companystatic->id = $obj->socid;
+ $companystatic->code_client = $obj->code_client;
+ $companystatic->name = $obj->name;
+ $companystatic->client = $obj->client;
+ $companystatic->email = $obj->email;
+ if (!isset($cacheGetNomUrl[$obj->socid])) {
+ $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
+ }
$generic_commande->id=$obj->rowid;
$generic_commande->ref=$obj->ref;
@@ -979,7 +977,7 @@ if ($resql)
if (! empty($arrayfields['s.nom']['checked']))
{
print '| ';
- print $getNomUrl[$obj->socid];
+ print $getNomUrl_cache[$obj->socid];
// If module invoices enabled and user with invoice creation permissions
if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER))
@@ -988,8 +986,8 @@ if ($resql)
{
if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0))
{
- print ' ';
- print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic[$obj->socid]->name, 'object_bill', 'hideonsmartphone').'';
+ print ' ';
+ print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'';
}
}
}
From 393c671b268c5ae48a08e5c2e3fdcc0af40271e8 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Wed, 23 Oct 2019 06:59:14 +0000
Subject: [PATCH 4/5] Fixing style errors.
---
htdocs/commande/list.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index f548f7682cc..a428b25481d 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -784,15 +784,15 @@ if ($resql)
$text_info='';
$text_warning='';
$nbprod=0;
-
+
$companystatic->id = $obj->socid;
$companystatic->code_client = $obj->code_client;
$companystatic->name = $obj->name;
$companystatic->client = $obj->client;
$companystatic->email = $obj->email;
if (!isset($cacheGetNomUrl[$obj->socid])) {
- $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
- }
+ $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
+ }
$generic_commande->id=$obj->rowid;
$generic_commande->ref=$obj->ref;
From 5b57bf1f6133283a5b2bba12370277efdb549339 Mon Sep 17 00:00:00 2001
From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com>
Date: Wed, 30 Oct 2019 08:42:43 +0100
Subject: [PATCH 5/5] array name error
---
htdocs/commande/list.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index a428b25481d..2351fb7885e 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -790,7 +790,7 @@ if ($resql)
$companystatic->name = $obj->name;
$companystatic->client = $obj->client;
$companystatic->email = $obj->email;
- if (!isset($cacheGetNomUrl[$obj->socid])) {
+ if (!isset($getNomUrl_cache[$obj->socid])) {
$getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
}
| |