Fix repeated logs and fetch

This commit is contained in:
Laurent Destailleur 2019-06-13 22:48:31 +02:00
parent ff1adb3934
commit e8b139d1c6
4 changed files with 34 additions and 26 deletions

View File

@ -120,7 +120,7 @@ class ActionComm extends CommonObject
* Object user that create action
* @var User
* @deprecated
* @see authorid
* @see $authorid
*/
public $author;
@ -128,7 +128,7 @@ class ActionComm extends CommonObject
* Object user that modified action
* @var User
* @deprecated
* @see usermodid
* @see $usermodid
*/
public $usermod;
@ -1010,7 +1010,7 @@ class ActionComm extends CommonObject
/**
* Load all objects with filters.
* WARNING: This make a fetch on all records instead of making one request with a join.
* @TODO WARNING: This make a fetch on all records instead of making one request with a join.
*
* @param DoliDb $db Database handler
* @param int $socid Filter by thirdparty
@ -1020,7 +1020,7 @@ class ActionComm extends CommonObject
* @param string $sortfield Sort on this field
* @param string $sortorder ASC or DESC
* @param string $limit Limit number of answers
* @return array or string Error string if KO, array with actions if OK
* @return array|string Error string if KO, array with actions if OK
*/
public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0)
{
@ -1028,6 +1028,8 @@ class ActionComm extends CommonObject
$resarray=array();
dol_syslog(get_class()."::getActions", LOG_DEBUG);
$sql = "SELECT a.id";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " WHERE a.entity IN (".getEntity('agenda').")";
@ -1041,7 +1043,6 @@ class ActionComm extends CommonObject
if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder);
$sql.=$db->plimit($limit, 0);
dol_syslog(get_class()."::getActions", LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
@ -1285,7 +1286,7 @@ class ActionComm extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id))
if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id))
$option = 'nolink';
$label = $this->label;

View File

@ -497,8 +497,9 @@ class DiscountAbsolute
{
global $conf;
dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG);
$sql = "SELECT SUM(rc.amount_ttc) as amount";
//$sql = "SELECT rc.amount_ttc as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql.= " WHERE rc.entity = " . $conf->entity;
$sql.= " AND rc.discount_type=".intval($discount_type);
@ -512,7 +513,6 @@ class DiscountAbsolute
if ($filter) $sql.=' AND ('.$filter.')';
if ($maxvalue) $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue);
dol_syslog(get_class($this)."::getAvailableDiscounts", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{

View File

@ -213,24 +213,22 @@ class FormActions
$page=0; $param='';
$total = 0;
print '<div class="div-table-responsive-no-min">';
print '<table class="centpercent noborder'.($morecss?' '.$morecss:'').'">';
print '<tr class="liste_titre">';
print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
print '</tr>';
print "\n";
$userstatic = new User($this->db);
if (count($listofactions))
if (is_array($listofactions) && count($listofactions))
{
$cacheusers=array();
$cursorevent = 0;
foreach($listofactions as $action)
{
@ -246,8 +244,20 @@ class FormActions
print '<td>';
if (! empty($action->userownerid))
{
$userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched
print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
if (is_object($cacheusers[$action->userownerid]))
{
$tmpuser = $cacheusers[$action->userownerid];
}
else
{
$tmpuser = new User($this->db);
$tmpuser->fetch($action->userownerid);
$cacheusers[$action->userownerid] = $tmpuser;
}
if ($tmpuser->id > 0)
{
print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
}
}
print '</td>';
// Type
@ -284,10 +294,7 @@ class FormActions
}
print '</td>';
print '<td class="right">';
if (! empty($action->author->id))
{
print $action->getLibStatut(3);
}
print $action->getLibStatut(3);
print '</td>';
print '</tr>';

View File

@ -184,6 +184,8 @@ class mod_facture_terre extends ModeleNumRefFactures
{
global $db;
dol_syslog(get_class($this)."::getNextValue mode=".$mode, LOG_DEBUG);
if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
elseif ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice;
@ -195,7 +197,6 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
if ($resql)
{
$obj = $db->fetch_object($resql);
@ -219,7 +220,6 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$sql.= " ORDER BY ref DESC";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{