Fix not working sorting in contact view
This commit is contained in:
parent
904bf71588
commit
41c0575a5d
@ -162,72 +162,74 @@ print "</div>";
|
||||
|
||||
// TODO: replace this with direct SQL string to use $db->sort($sortfield, $sortorder)
|
||||
$list = array();
|
||||
foreach (array('internal', 'external') as $source)
|
||||
foreach(array('internal', 'external') as $source)
|
||||
{
|
||||
$tmpobject = $object;
|
||||
|
||||
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc))
|
||||
{
|
||||
$tmpobject = $objectsrc;
|
||||
$contactlist = $objectsrc->liste_contact(-1, $source);
|
||||
}
|
||||
else
|
||||
{
|
||||
$contactlist = $object->liste_contact(-1, $source);
|
||||
}
|
||||
|
||||
$tab = $tmpobject->liste_contact(-1, $source);
|
||||
$num = count($tab);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
foreach ($contactlist as $contact)
|
||||
{
|
||||
$entry = new stdClass();
|
||||
$entry->id = $contact['rowid'];
|
||||
$entry->type = $contact['libelle'];
|
||||
$entry->nature = "";
|
||||
$entry->thirdparty_html = "";
|
||||
$entry->thirdparty_name = "";
|
||||
$entry->contact_html = "";
|
||||
$entry->contact_name = "";
|
||||
$entry->status = "";
|
||||
|
||||
$entry->id = $tab[$i]['rowid'];
|
||||
$entry->type = $tab[$i]['libelle'];
|
||||
|
||||
if ($tab[$i]['source'] == 'internal')
|
||||
if ($contact['source'] == 'internal')
|
||||
{
|
||||
$entry->nature = $langs->trans("User");
|
||||
}
|
||||
elseif ($tab[$i]['source'] == 'external')
|
||||
else if ($contact['source'] == 'external')
|
||||
{
|
||||
$entry->nature = $langs->trans("ThirdPartyContact");
|
||||
}
|
||||
|
||||
if ($tab[$i]['socid'] > 0)
|
||||
if ($contact['socid'] > 0)
|
||||
{
|
||||
$companystatic->fetch($tab[$i]['socid']);
|
||||
$entry->thirdparty = $companystatic->getNomUrl(1);
|
||||
$companystatic->fetch($contact['socid']);
|
||||
$entry->thirdparty_html = $companystatic->getNomUrl(1);
|
||||
$entry->thirdparty_name = strtolower($companystatic->getFullName($langs));
|
||||
}
|
||||
elseif ($tab[$i]['socid'] < 0)
|
||||
else if ($contact['socid'] < 0)
|
||||
{
|
||||
$entry->thirdparty = $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
}
|
||||
elseif (!$tab[$i]['socid'])
|
||||
{
|
||||
$entry->thirdparty = "";
|
||||
$entry->thirdparty_html = $conf->global->MAIN_INFO_SOCIETE_NOM;
|
||||
$entry->thirdparty_name = strtolower($conf->global->MAIN_INFO_SOCIETE_NOM);
|
||||
}
|
||||
|
||||
if ($tab[$i]['source'] == 'internal')
|
||||
if ($contact['source'] == 'internal')
|
||||
{
|
||||
$userstatic->fetch($tab[$i]['id']);
|
||||
$entry->contact = $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle');
|
||||
$userstatic->fetch($contact['id']);
|
||||
$entry->contact_html = $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle');
|
||||
$entry->contact_name = strtolower($userstatic->getFullName($langs));
|
||||
}
|
||||
elseif ($tab[$i]['source'] == 'external')
|
||||
else if ($contact['source'] == 'external')
|
||||
{
|
||||
$contactstatic->fetch($tab[$i]['id']);
|
||||
$entry->contact = $contactstatic->getNomUrl(1, '', 0, '', 0, 0);
|
||||
$contactstatic->fetch($contact['id']);
|
||||
$entry->contact_html = $contactstatic->getNomUrl(1, '', 0, '', 0, 0);
|
||||
$entry->contact_name = strtolower($contactstatic->getFullName($langs));
|
||||
}
|
||||
|
||||
if ($tab[$i]['source'] == 'internal')
|
||||
if ($contact['source'] == 'internal')
|
||||
{
|
||||
$entry->status = $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
|
||||
$entry->status = $userstatic->LibStatut($contact['statuscontact'], 3);
|
||||
}
|
||||
elseif ($tab[$i]['source'] == 'external')
|
||||
else if ($contact['source'] == 'external')
|
||||
{
|
||||
$entry->status = $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
|
||||
$entry->status = $contactstatic->LibStatut($contact['statuscontact'], 3);
|
||||
}
|
||||
|
||||
$i++;
|
||||
$list[] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -255,9 +257,6 @@ $param = 'id='.$object->id.'&mainmenu=home';
|
||||
/**
|
||||
* Show list
|
||||
*/
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
@ -272,10 +271,10 @@ print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($arrayfields['nature']['label'], $_SERVER["PHP_SELF"], "nature", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($arrayfields['thirdparty']['label'], $_SERVER["PHP_SELF"], "thirdparty", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($arrayfields['contact']['label'], $_SERVER["PHP_SELF"], "contact", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($arrayfields['thirdparty']['label'], $_SERVER["PHP_SELF"], "thirdparty_name", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($arrayfields['contact']['label'], $_SERVER["PHP_SELF"], "contact_name", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "statut", "", $param, "", $sortfield, $sortorder, 'center ');
|
||||
print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "statut", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre($arrayfields['link']['label'], $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>";
|
||||
|
||||
@ -284,10 +283,10 @@ foreach ($list as $entry)
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
print '<td class="nowrap">'.$entry->nature.'</td>';
|
||||
print '<td class="tdoverflowmax200">'.$entry->thirdparty.'</td>';
|
||||
print '<td class="tdoverflowmax200">'.$entry->contact.'</td>';
|
||||
print '<td class="tdoverflowmax200">'.$entry->thirdparty_html.'</td>';
|
||||
print '<td class="tdoverflowmax200">'.$entry->contact_html.'</td>';
|
||||
print '<td class="tdoverflowmax200">'.$entry->type.'</td>';
|
||||
print '<td class="tdoverflowmax200 center">'.$entry->status.'</td>';
|
||||
print '<td class="tdoverflowmax200">'.$entry->status.'</td>';
|
||||
|
||||
if ($permission)
|
||||
{
|
||||
@ -307,7 +306,6 @@ foreach ($list as $entry)
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print "</div>";
|
||||
print "</form>";
|
||||
print "</div>";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user