Fix subrequest inside a loop

This commit is contained in:
Laurent Destailleur 2023-02-10 16:14:32 +01:00
parent 457e6883e2
commit 8299501800
2 changed files with 36 additions and 20 deletions

View File

@ -1354,12 +1354,13 @@ abstract class CommonObject
* *
* @param int $statusoflink Status of links to get (-1=all). Not used. * @param int $statusoflink Status of links to get (-1=all). Not used.
* @param string $source Source of contact: 'external' or 'thirdparty' (llx_socpeople) or 'internal' (llx_user) * @param string $source Source of contact: 'external' or 'thirdparty' (llx_socpeople) or 'internal' (llx_user)
* @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param int $list 0:Returned array contains all properties, 1:Return array contains just id
* @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...)
* @param int $status Status of user or company * @param int $status Status of user or company
* @param array $arrayoftcids Array with ID of type of contacts. If we provide this, we can make a ec.fk_c_type_contact in ($arrayoftcids) to avoid link on tc table. TODO Not implemented.
* @return array|int Array of contacts, -1 if error * @return array|int Array of contacts, -1 if error
*/ */
public function liste_contact($statusoflink = -1, $source = 'external', $list = 0, $code = '', $status = -1) public function liste_contact($statusoflink = -1, $source = 'external', $list = 0, $code = '', $status = -1, $typecontectids = array())
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;

View File

@ -1331,6 +1331,7 @@ while ($i < $imaxinloop) {
$userAccess = $object->restrictedProjectArea($user); // why this ? $userAccess = $object->restrictedProjectArea($user); // why this ?
if ($userAccess >= 0) { if ($userAccess >= 0) {
// Thirdparty
$companystatic->id = $obj->socid; $companystatic->id = $obj->socid;
$companystatic->name = $obj->name; $companystatic->name = $obj->name;
$companystatic->name_alias = $obj->alias; $companystatic->name_alias = $obj->alias;
@ -1343,6 +1344,21 @@ while ($i < $imaxinloop) {
$companystatic->town = $obj->town; $companystatic->town = $obj->town;
$companystatic->country_code = $obj->country_code; $companystatic->country_code = $obj->country_code;
// Author
$userstatic->id = $obj->fk_user_creat;
$userstatic->login = $obj->login;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->user_email;
$userstatic->statut = $obj->user_statut;
$userstatic->entity = $obj->entity;
$userstatic->photo = $obj->photo;
$userstatic->office_phone = $obj->office_phone;
$userstatic->office_fax = $obj->office_fax;
$userstatic->user_mobile = $obj->user_mobile;
$userstatic->job = $obj->job;
$userstatic->gender = $obj->gender;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Action column // Action column
@ -1496,12 +1512,25 @@ while ($i < $imaxinloop) {
if (!empty($numcontact)) { if (!empty($numcontact)) {
foreach ($tab as $contactproject) { foreach ($tab as $contactproject) {
//var_dump($contacttask); //var_dump($contacttask);
$cid = $contactproject['id'];
if ($source == 'internal') { if ($source == 'internal') {
if (empty($conf->cache['user'][$cid])) {
$c = new User($db); $c = new User($db);
$c->fetch($cid);
$conf->cache['user'][$cid] = $c;
} else { } else {
$c = new Contact($db); $c = $conf->cache['user'][$cid];
} }
$c->fetch($contactproject['id']); } else {
if (empty($conf->cache['contact'][$cid])) {
$c = new Contact($db);
$c->fetch($cid);
$conf->cache['contact'][$cid] = $c;
} else {
$c = $conf->cache['contact'][$cid];
}
}
if (!empty($c->photo)) { if (!empty($c->photo)) {
if (get_class($c) == 'User') { if (get_class($c) == 'User') {
print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
@ -1703,20 +1732,6 @@ while ($i < $imaxinloop) {
$totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
} }
} }
// Author
$userstatic->id = $obj->fk_user_creat;
$userstatic->login = $obj->login;
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->user_email;
$userstatic->statut = $obj->user_statut;
$userstatic->entity = $obj->entity;
$userstatic->photo = $obj->photo;
$userstatic->office_phone = $obj->office_phone;
$userstatic->office_fax = $obj->office_fax;
$userstatic->user_mobile = $obj->user_mobile;
$userstatic->job = $obj->job;
$userstatic->gender = $obj->gender;
if (!empty($arrayfields['u.login']['checked'])) { if (!empty($arrayfields['u.login']['checked'])) {
print '<td class="center tdoverflowmax150">'; print '<td class="center tdoverflowmax150">';