Qual: Reduce memory usage

This commit is contained in:
Laurent Destailleur 2008-12-03 21:17:51 +00:00
parent b063efb91e
commit 65cd4531c4
6 changed files with 35 additions and 17 deletions

View File

@ -71,6 +71,7 @@ class ActionComm
function ActionComm($db)
{
$this->db = $db;
/*
$this->societe = new Societe($db);
$this->author = new User($db);
$this->usermod = new User($db);
@ -80,6 +81,7 @@ class ActionComm
{
$this->contact = new Contact($db);
}
*/
}
/**

View File

@ -69,7 +69,7 @@ $pagenext = $page + 1;
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
/*
* Creation répertoire si n'existe pas
* Creation r<EFBFBD>pertoire si n'existe pas
*/
$upload_dir = $conf->actions->dir_output.'/'.sanitizeFileName($objectid);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
@ -83,7 +83,7 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
}
else
{
// Echec transfert (fichier dépassant la limite ?)
// Echec transfert (fichier d<EFBFBD>passant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
@ -114,10 +114,19 @@ if ($objectid > 0)
if ($act->fetch($objectid))
{
$upload_dir = $conf->actions->dir_output.'/'.sanitizeFileName($objectid);
$company=new Societe($db);
$company->fetch($act->societe->id);
$act->societe=$company;
$res=$act->societe->fetch($act->societe->id);
$res=$act->author->fetch(); // Le paramètre est le login, hors seul l'id est chargé.
$res=$act->contact->fetch($act->contact->id);
$author=new User($db);
$author->id=$act->author->id;
$author->fetch();
$act->author=$author;
$contact=new Contact($db);
$contact->fetch($act->contact->id);
$act->contact=$contact;
$h=0;

View File

@ -610,10 +610,10 @@ if ($_GET["id"])
}
$act->societe = $societe;
if ($act->author->id > 0) $res=$act->author->fetch(); // Le parametre est le login, hors seul l'id est charge.
if ($act->usermod->id > 0) $res=$act->usermod->fetch();
if ($act->usertodo->id > 0) $res=$act->usertodo->fetch();
if ($act->userdone->id > 0) $res=$act->userdone->fetch();
if ($act->author->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->author->id; $res=$tmpuser->fetch(); $act->author=$tmpuser; }
if ($act->usermod->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->usermod->id; $res=$tmpuser->fetch(); $act->usermod=$tmpuser; }
if ($act->usertodo->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->usertodo->id; $res=$tmpuser->fetch(); $act->usertodo=$tmpuser; }
if ($act->userdone->id > 0) { $tmpuser=new User($db); $tmpuser->id=$act->userdone->id; $res=$tmpuser->fetch(); $act->userdone=$tmpuser; }
$contact = new Contact($db);
if ($act->contact->id)

View File

@ -119,10 +119,10 @@ $next = dol_get_next_month($month, $year);
$next_year = $next['year'];
$next_month = $next['month'];
$max_day_in_prev_month = date("t",dolibarr_mktime(0,0,0,$prev_month,1,$prev_year));
$max_day_in_month = date("t",dolibarr_mktime(0,0,0,$month,1,$year));
$max_day_in_prev_month = date("t",dolibarr_mktime(0,0,0,$prev_month,1,$prev_year)); // Nb of days in previous month
$max_day_in_month = date("t",dolibarr_mktime(0,0,0,$month,1,$year)); // Nb of days in next month
$tmpday = -date("w",dolibarr_mktime(0,0,0,$month,1,$year))+2;
if ($tmpday > 1) $tmpday -= 7;
if ($tmpday >= 1) $tmpday -= 7;
$firstdaytoshow=dolibarr_mktime(0,0,0,$prev_month,$max_day_in_prev_month+$tmpday,$prev_year);
$next_day=7-($max_day_in_month+1-$tmpday)%7;
if ($next_day < 6) $next_day+=7;
@ -404,6 +404,8 @@ if ($_GET["action"] != 'show_day')
echo ' <td align="center">'.$langs->trans("Saturday")."</td>\n";
echo ' <td align="center">'.$langs->trans("Sunday")."</td>\n";
echo " </tr>\n";
// In loops, tmpday contains day nb in current month (can be negative for days of previous month)
for($iter_week = 0; $iter_week < 6 ; $iter_week++)
{
echo " <tr>\n";

View File

@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
$langs->load("commercial");
// Sécurité accés client
// Security check
if ($user->societe_id > 0)
{
$action = '';
@ -49,9 +49,6 @@ llxHeader();
$act = new ActionComm($db);
$act->fetch($_GET["id"]);
$act->info($_GET["id"]);
$res=$act->societe->fetch($act->societe->id);
$res=$act->author->fetch(); // Le paramètre est le login, hors seul l'id est chargé.
$res=$act->contact->fetch($act->contact->id);
$h=0;
@ -78,7 +75,7 @@ print '</td></tr></table>';
print '</div>';
// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent
// Juste pour <EFBFBD>viter bug IE qui r<>organise mal div pr<70>c<EFBFBD>dents si celui-ci absent
print '<div class="tabsAction">';
print '</div>';

View File

@ -116,6 +116,14 @@ class User extends CommonObject
return 1;
}
/* Polymorph functions not allowed in PHP
function fetch($id)
{
$this->id=$id;
$this->fetch();
}
*/
/**
* \brief Charge un objet user avec toutes ces caracteristiques depuis un id ou login