Perf: Try to reduce amount of memory used to show events
This commit is contained in:
parent
8212700c41
commit
91e6087d1b
@ -477,12 +477,14 @@ class ActionComm extends CommonObject
|
||||
* @param int $fk_element Id of element action is linked to
|
||||
* @param string $elementtype Type of element action is linked to
|
||||
* @param string $filter Other filter
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @return array <0 if KO, array with actions
|
||||
*/
|
||||
function getActions($socid=0, $fk_element=0, $elementtype='', $filter='')
|
||||
static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='')
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$resarray=array();
|
||||
|
||||
$sql = "SELECT a.id";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql.= " WHERE a.entity = ".$conf->entity;
|
||||
@ -495,27 +497,27 @@ class ActionComm extends CommonObject
|
||||
if (! empty($filter)) $sql.= $filter;
|
||||
|
||||
dol_syslog(get_class($this)."::getActions sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($num)
|
||||
{
|
||||
for($i=0;$i<$num;$i++)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$actioncommstatic = new ActionComm($this->db);
|
||||
$obj = $db->fetch_object($resql);
|
||||
$actioncommstatic = new ActionComm($db);
|
||||
$actioncommstatic->fetch($obj->id);
|
||||
$this->actions[$i] = $actioncommstatic;
|
||||
$resarray[$i] = $actioncommstatic;
|
||||
}
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
$db->free($resql);
|
||||
return $resarray;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error=$db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -707,21 +709,26 @@ class ActionComm extends CommonObject
|
||||
if ($option=='birthday') $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/contact/perso.php?id='.$this->id.'">';
|
||||
else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$this->id.'">';
|
||||
$lienfin='</a>';
|
||||
//print $this->libelle;
|
||||
$label=$this->label;
|
||||
if (empty($label)) $label=$this->libelle; // Fro backward compatibility
|
||||
//print 'rrr'.$this->libelle;
|
||||
|
||||
if ($withpicto == 2)
|
||||
{
|
||||
$libelle=$langs->trans("Action".$this->type_code);
|
||||
$libelle=$label;
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code);
|
||||
$libelleshort='';
|
||||
}
|
||||
else if (empty($this->libelle))
|
||||
{
|
||||
$libelle=$langs->trans("Action".$this->type_code);
|
||||
$libelleshort=$langs->trans("Action".$this->type_code,'','','','',$maxlength);
|
||||
$libelle=$label;
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code);
|
||||
$libelleshort=dol_trunc($label, $maxlength);
|
||||
}
|
||||
else
|
||||
{
|
||||
$libelle=$this->libelle;
|
||||
$libelleshort=dol_trunc($this->libelle,$maxlength);
|
||||
{
|
||||
$libelle=$label;
|
||||
$libelleshort=dol_trunc($label,$maxlength);
|
||||
}
|
||||
|
||||
if ($withpicto)
|
||||
|
||||
@ -144,10 +144,10 @@ class FormActions
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
|
||||
$actioncomm = new ActionComm($this->db);
|
||||
$actioncomm->getActions($socid, $object->id, $typeelement);
|
||||
$listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement);
|
||||
if (is_numeric($listofactions) && $listofactions < 0) dol_print_error($this->db,'FailedToGetActions');
|
||||
|
||||
$num = count($actioncomm->actions);
|
||||
$num = count($listofactions);
|
||||
if ($num)
|
||||
{
|
||||
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
|
||||
@ -164,17 +164,29 @@ class FormActions
|
||||
|
||||
$total = 0; $var=true;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans('Ref').'</th><th class="liste_titre">'.$langs->trans('Date').'</th><th class="liste_titre">'.$langs->trans('Action').'</th><th class="liste_titre">'.$langs->trans('By').'</th></tr>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th class="liste_titre">'.$langs->trans('Ref').'</th>';
|
||||
print '<th class="liste_titre">'.$langs->trans('Action').'</th>';
|
||||
print '<th class="liste_titre">'.$langs->trans('Date').'</th>';
|
||||
print '<th class="liste_titre">'.$langs->trans('By').'</th>';
|
||||
print '</tr>';
|
||||
print "\n";
|
||||
|
||||
foreach($actioncomm->actions as $action)
|
||||
$userstatic = new User($this->db);
|
||||
|
||||
foreach($listofactions as $action)
|
||||
{
|
||||
$savlabel=$action->label;
|
||||
$action->label=$action->ref;
|
||||
$ref=$action->getNomUrl(1);
|
||||
$action->label=$savlabel;
|
||||
$label=$action->getNomUrl(0,38);
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$action->getNomUrl(1).'</td>';
|
||||
print '<td>'.$ref.'</td>';
|
||||
print '<td>'.$label.'</td>';
|
||||
print '<td>'.dol_print_date($action->datep,'day').'</td>';
|
||||
print '<td title="'.dol_escape_htmltag($action->label).'">'.dol_trunc($action->label,32).'</td>';
|
||||
$userstatic = new User($this->db);
|
||||
$userstatic->id = $action->author->id;
|
||||
$userstatic->firstname = $action->author->firstname;
|
||||
$userstatic->lastname = $action->author->lastname;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user