diff --git a/htdocs/cactioncomm.class.php b/htdocs/cactioncomm.class.php index d60582fb8eb..5dbe808135a 100644 --- a/htdocs/cactioncomm.class.php +++ b/htdocs/cactioncomm.class.php @@ -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é 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); + } } - + } ?> diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 79e124a275a..1c019f89da3 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -443,7 +443,8 @@ if ($_GET["action"] == 'create') if ($_GET["actioncode"]) { print ''."\n"; - print $caction->get_nom($_GET["actioncode"]); + $caction->fetch($_GET["actioncode"]); + print $caction->getNom(); } else { @@ -471,6 +472,14 @@ if ($_GET["action"] == 'create') } print ''; + // Si la societe est imposée, on propose ces contacts + if ($_REQUEST["socid"]) + { + print ''.$langs->trans("ActionOnContact").''; + $html->select_contacts($_REQUEST["socid"],'','contactid',1,1); + print ''; + } + // Affecte a print ''.$langs->trans("ActionAffectedTo").''; print $langs->trans("FeatureNotYetSupported"); @@ -481,14 +490,6 @@ if ($_GET["action"] == 'create') print $langs->trans("FeatureNotYetSupported"); print ''; - // Si la societe est imposée, on propose ces contacts - if ($_REQUEST["socid"]) - { - print ''.$langs->trans("ActionOnContact").''; - $html->select_contacts($_REQUEST["socid"],'','contactid',1,1); - print ''; - } - // Avancement if ($_GET["afaire"] == 1) { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index f481bf621b5..d63086053f3 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Éric Seigne - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * * 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 "\n"; + + $contactstatic = new Contact($db); + $var=true; while ($i < min($num,$limit)) { @@ -192,9 +199,10 @@ if ($resql) print ''; 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 { diff --git a/htdocs/contact/index.php b/htdocs/contact/index.php index d7b412d5eb9..88abcff8af0 100644 --- a/htdocs/contact/index.php +++ b/htdocs/contact/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Éric Seigne - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * * 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 ''; - print ''; - print img_object($langs->trans("ShowContact"),"contact"); - print ' '.$obj->name.''; + $contactstatic->name=$obj->name; + $contactstatic->firstname=''; + $contactstatic->id=$obj->cidp; + print $contactstatic->getNomUrl(1); print ''; // Firstname diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 6a4584f24a4..74baf05f534 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 33cae35a21c..feab80cad4c 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -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és \return int Nombre de fichier+repértoires supprimés */ function dol_delete_dir_recursive($dir,$count=0)