Reduce the $companystatic calls

Store $companystatic->getNomUrl() in $getNomUrl_cache[];
This commit is contained in:
dolibarr95 2019-10-23 08:57:07 +02:00 committed by GitHub
parent e807cb6b03
commit da136ef641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -236,6 +236,7 @@ $now=dol_now();
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$companystatic = new Societe($db);
$formcompany=new FormCompany($db); $formcompany=new FormCompany($db);
$projectstatic=new Project($db); $projectstatic=new Project($db);
@ -767,13 +768,11 @@ if ($resql)
$total=0; $total=0;
$subtotal=0; $subtotal=0;
$productstat_cache=array(); $productstat_cache=array();
$getNomUrl_cache=array();
$generic_commande = new Commande($db); $generic_commande = new Commande($db);
$generic_product = new Product($db); $generic_product = new Product($db);
$companystatic = array();
$getNomUrl = array();
$i=0; $i=0;
$totalarray=array(); $totalarray=array();
while ($i < min($num, $limit)) while ($i < min($num, $limit))
@ -785,16 +784,15 @@ if ($resql)
$text_info=''; $text_info='';
$text_warning=''; $text_warning='';
$nbprod=0; $nbprod=0;
if (!isset($companystatic[$obj->socid])) { $companystatic->id = $obj->socid;
$companystatic[$obj->socid] = new Societe($db); $companystatic->code_client = $obj->code_client;
$companystatic[$obj->socid]->id = $obj->socid; $companystatic->name = $obj->name;
$companystatic[$obj->socid]->code_client = $obj->code_client; $companystatic->client = $obj->client;
$companystatic[$obj->socid]->name = $obj->name; $companystatic->email = $obj->email;
$companystatic[$obj->socid]->client = $obj->client; if (!isset($cacheGetNomUrl[$obj->socid])) {
$companystatic[$obj->socid]->email = $obj->email; $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
$getNomUrl[$obj->socid] = $companystatic[$obj->socid]->getNomUrl(1, 'customer'); }
}
$generic_commande->id=$obj->rowid; $generic_commande->id=$obj->rowid;
$generic_commande->ref=$obj->ref; $generic_commande->ref=$obj->ref;
@ -979,7 +977,7 @@ if ($resql)
if (! empty($arrayfields['s.nom']['checked'])) if (! empty($arrayfields['s.nom']['checked']))
{ {
print '<td class="tdoverflowmax200">'; print '<td class="tdoverflowmax200">';
print $getNomUrl[$obj->socid]; print $getNomUrl_cache[$obj->socid];
// If module invoices enabled and user with invoice creation permissions // If module invoices enabled and user with invoice creation permissions
if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) 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)) if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0))
{ {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$companystatic[$obj->socid]->id.'">'; print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/orderstoinvoice.php?socid='.$companystatic->id.'">';
print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic[$obj->socid]->name, 'object_bill', 'hideonsmartphone').'</a>'; print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').'</a>';
} }
} }
} }