forked from Wavyzz/dolibarr
Optimisation code (reduction nb requetes sql)
This commit is contained in:
@@ -162,57 +162,48 @@ class CActionComm {
|
||||
* \param id id ou code du type d'action
|
||||
* \return string libelle du type d'action
|
||||
*/
|
||||
function get_nom($id)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (! isset($this->type_actions[$id]))
|
||||
{
|
||||
// Si valeur non disponible en cache
|
||||
$sql = 'SELECT id, code, libelle';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm';
|
||||
if (is_numeric($id)) $sql.= " WHERE id=".$id;
|
||||
else $sql.= " WHERE code='".$id."'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$transcode=$langs->trans("Action".$obj->code);
|
||||
$libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle);
|
||||
|
||||
$this->type_actions[$obj->id]=$libelle; // Met en cache
|
||||
return $libelle;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// Si valeur disponible en cache
|
||||
return $this->type_actions[$id];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* \brief Renvoie le nom sous forme d'un libell<6C> traduit d'un type d'action
|
||||
* \return string Libelle du type d'action
|
||||
*/
|
||||
function getNom()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
// Check if translation available
|
||||
$transcode=$langs->trans("Action".$this->code);
|
||||
$libelle=($transcode!="Action".$this->code ? $transcode : $this->get_nom($this->code));
|
||||
return $libelle;
|
||||
if ($transcode != "Action".$this->code) return $transcode;
|
||||
|
||||
// Check if available in cach
|
||||
if (isset($this->type_actions[$this->code]))
|
||||
{
|
||||
// Si valeur disponible en cache
|
||||
return $this->type_actions[$this->code];
|
||||
}
|
||||
|
||||
// If no translation and no cache available
|
||||
$sql = 'SELECT id, code, libelle';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm';
|
||||
if (is_numeric($id)) $sql.= " WHERE id=".$this->code;
|
||||
else $sql.= " WHERE code='".$this->code."'";
|
||||
|
||||
dolibarr_syslog("CActionComm::getNom sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$transcode=$langs->trans("Action".$obj->code);
|
||||
$libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle);
|
||||
|
||||
$this->type_actions[$obj->code]=$libelle; // Put in cache
|
||||
return $libelle;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -443,7 +443,8 @@ if ($_GET["action"] == 'create')
|
||||
if ($_GET["actioncode"])
|
||||
{
|
||||
print '<input type="hidden" name="actioncode" value="'.$_GET["actioncode"].'">'."\n";
|
||||
print $caction->get_nom($_GET["actioncode"]);
|
||||
$caction->fetch($_GET["actioncode"]);
|
||||
print $caction->getNom();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -471,6 +472,14 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Si la societe est impos<6F>e, on propose ces contacts
|
||||
if ($_REQUEST["socid"])
|
||||
{
|
||||
print '<tr><td nowrap>'.$langs->trans("ActionOnContact").'</td><td>';
|
||||
$html->select_contacts($_REQUEST["socid"],'','contactid',1,1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Affecte a
|
||||
print '<tr><td nowrap>'.$langs->trans("ActionAffectedTo").'</td><td>';
|
||||
print $langs->trans("FeatureNotYetSupported");
|
||||
@@ -481,14 +490,6 @@ if ($_GET["action"] == 'create')
|
||||
print $langs->trans("FeatureNotYetSupported");
|
||||
print '</td></tr>';
|
||||
|
||||
// Si la societe est impos<6F>e, on propose ces contacts
|
||||
if ($_REQUEST["socid"])
|
||||
{
|
||||
print '<tr><td nowrap>'.$langs->trans("ActionOnContact").'</td><td>';
|
||||
$html->select_contacts($_REQUEST["socid"],'','contactid',1,1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Avancement
|
||||
if ($_GET["afaire"] == 1)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 <20>ric Seigne <erics@rycks.com>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -66,10 +66,13 @@ llxHeader();
|
||||
$sql = "SELECT s.nom as societe, s.rowid as socid, s.client,";
|
||||
$sql.= " a.id,".$db->pdate("a.datep")." as dp, a.fk_contact, a.note, a.label, a.percent as percent,";
|
||||
$sql.= " c.code as acode, c.libelle,";
|
||||
$sql.= " u.login, u.rowid as userid";
|
||||
$sql.= " u.login, u.rowid as userid,";
|
||||
$sql.= " sp.name, sp.firstname";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."user as u,";
|
||||
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON a.fk_contact = sp.rowid";
|
||||
$sql.= " WHERE a.fk_soc = s.rowid AND c.id = a.fk_action AND a.fk_user_author = u.rowid";
|
||||
if ($_GET["type"])
|
||||
{
|
||||
@@ -91,7 +94,8 @@ if ($status == 'done') { $sql.= " AND a.percent = 100"; }
|
||||
if ($status == 'todo') { $sql.= " AND a.percent < 100"; }
|
||||
$sql .= " ORDER BY $sortfield $sortorder";
|
||||
$sql .= $db->plimit( $limit + 1, $offset);
|
||||
|
||||
|
||||
dolibarr_syslog("comm/action/index.php sql=".$sql);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -126,6 +130,9 @@ if ($resql)
|
||||
print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"u.login",$param,"","",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
$contactstatic = new Contact($db);
|
||||
|
||||
$var=true;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
@@ -192,9 +199,10 @@ if ($resql)
|
||||
print '<td>';
|
||||
if ($obj->fk_contact > 0)
|
||||
{
|
||||
$cont = new Contact($db);
|
||||
$cont->fetch($obj->fk_contact);
|
||||
print $cont->getNomUrl(1);
|
||||
$contactstatic->name=$obj->name;
|
||||
$contactstatic->firstname=$obj->firstname;
|
||||
$contactstatic->id=$obj->fk_contact;
|
||||
print $contactstatic->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 <20>ric Seigne <erics@rycks.com>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,7 +18,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -29,6 +28,7 @@
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("suppliers");
|
||||
@@ -167,10 +167,13 @@ else
|
||||
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1, $offset);
|
||||
}
|
||||
|
||||
dolibarr_syslog("contact/index.php sql=".$sql);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$contactstatic=new Contact($db);
|
||||
|
||||
$begin=$_GET["begin"];
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
@@ -257,9 +260,10 @@ if ($result)
|
||||
|
||||
// Name
|
||||
print '<td valign="center">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'">';
|
||||
print img_object($langs->trans("ShowContact"),"contact");
|
||||
print ' '.$obj->name.'</a>';
|
||||
$contactstatic->name=$obj->name;
|
||||
$contactstatic->firstname='';
|
||||
$contactstatic->id=$obj->cidp;
|
||||
print $contactstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
// Firstname
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -2034,6 +2034,7 @@ function dol_delete_dir($dir)
|
||||
/**
|
||||
\brief Effacement d'un r<>pertoire $dir et de son arborescence
|
||||
\param file R<>pertoire a effacer
|
||||
\param count Compteur pour comptage nb elements supprim<69>s
|
||||
\return int Nombre de fichier+rep<65>rtoires supprim<69>s
|
||||
*/
|
||||
function dol_delete_dir_recursive($dir,$count=0)
|
||||
|
||||
Reference in New Issue
Block a user