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 int $fk_element Id of element action is linked to
|
||||||
* @param string $elementtype Type of element action is linked to
|
* @param string $elementtype Type of element action is linked to
|
||||||
* @param string $filter Other filter
|
* @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;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$resarray=array();
|
||||||
|
|
||||||
$sql = "SELECT a.id";
|
$sql = "SELECT a.id";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||||
$sql.= " WHERE a.entity = ".$conf->entity;
|
$sql.= " WHERE a.entity = ".$conf->entity;
|
||||||
@ -495,27 +497,27 @@ class ActionComm extends CommonObject
|
|||||||
if (! empty($filter)) $sql.= $filter;
|
if (! empty($filter)) $sql.= $filter;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::getActions sql=".$sql);
|
dol_syslog(get_class($this)."::getActions sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
for($i=0;$i<$num;$i++)
|
for($i=0;$i<$num;$i++)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$actioncommstatic = new ActionComm($this->db);
|
$actioncommstatic = new ActionComm($db);
|
||||||
$actioncommstatic->fetch($obj->id);
|
$actioncommstatic->fetch($obj->id);
|
||||||
$this->actions[$i] = $actioncommstatic;
|
$resarray[$i] = $actioncommstatic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$db->free($resql);
|
||||||
return 1;
|
return $resarray;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$db->lasterror();
|
||||||
return -1;
|
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.'">';
|
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.'">';
|
else $lien = '<a '.($classname?'class="'.$classname.'" ':'').'href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$this->id.'">';
|
||||||
$lienfin='</a>';
|
$lienfin='</a>';
|
||||||
//print $this->libelle;
|
$label=$this->label;
|
||||||
|
if (empty($label)) $label=$this->libelle; // Fro backward compatibility
|
||||||
|
//print 'rrr'.$this->libelle;
|
||||||
|
|
||||||
if ($withpicto == 2)
|
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='';
|
$libelleshort='';
|
||||||
}
|
}
|
||||||
else if (empty($this->libelle))
|
else if (empty($this->libelle))
|
||||||
{
|
{
|
||||||
$libelle=$langs->trans("Action".$this->type_code);
|
$libelle=$label;
|
||||||
$libelleshort=$langs->trans("Action".$this->type_code,'','','','',$maxlength);
|
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code);
|
||||||
|
$libelleshort=dol_trunc($label, $maxlength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$libelle=$this->libelle;
|
$libelle=$label;
|
||||||
$libelleshort=dol_trunc($this->libelle,$maxlength);
|
$libelleshort=dol_trunc($label,$maxlength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($withpicto)
|
if ($withpicto)
|
||||||
|
|||||||
@ -144,10 +144,10 @@ class FormActions
|
|||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||||
|
|
||||||
$actioncomm = new ActionComm($this->db);
|
$listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement);
|
||||||
$actioncomm->getActions($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 ($num)
|
||||||
{
|
{
|
||||||
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
|
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
|
||||||
@ -164,17 +164,29 @@ class FormActions
|
|||||||
|
|
||||||
$total = 0; $var=true;
|
$total = 0; $var=true;
|
||||||
print '<table class="noborder" width="100%">';
|
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";
|
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;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$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>'.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->id = $action->author->id;
|
||||||
$userstatic->firstname = $action->author->firstname;
|
$userstatic->firstname = $action->author->firstname;
|
||||||
$userstatic->lastname = $action->author->lastname;
|
$userstatic->lastname = $action->author->lastname;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user