From 77d06b7a7c52a39124e6853645955051b30060a5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 9 Feb 2011 11:08:06 +0000 Subject: [PATCH] New: Show name of sales representatives if number is lower than 3 --- .../canvas/actions_card_common.class.php | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 2fcda214242..a908b7a5dcb 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -261,21 +261,30 @@ class ActionsCardCommon $this->tpl['display_rib'] = $this->object->display_rib(); // Sales representatives - // TODO move in business class - $sql = "SELECT count(sc.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sc.fk_soc =".$this->object->id; - $resql = $this->db->query($sql); - if ($resql) + $this->tpl['sales_representatives'] = ''; + $listsalesrepresentatives=$this->object->getSalesRepresentatives($user); + $nbofsalesrepresentative=sizeof($listsalesrepresentatives); + if ($nbofsalesrepresentative > 3) // We print only number { - $num = $this->db->num_rows($resql); - $obj = $this->db->fetch_object($resql); - $this->tpl['sales_representatives'] = $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected"); + $this->tpl['sales_representatives'].= ''; + $this->tpl['sales_representatives'].= $nbofsalesrepresentative; + $this->tpl['sales_representatives'].= ''; } - else + else if ($nbofsalesrepresentative > 0) { - dol_print_error($this->db); + $userstatic=new User($db); + $i=0; + foreach($listsalesrepresentatives as $val) + { + $userstatic->id=$val['id']; + $userstatic->nom=$val['name']; + $userstatic->prenom=$val['firstname']; + $this->tpl['sales_representatives'].= $userstatic->getNomUrl(1); + $i++; + if ($i < $nbofsalesrepresentative) $this->tpl['sales_representatives'].= ', '; + } } + else $this->tpl['sales_representatives'].= $langs->trans("NoSalesRepresentativeAffected"); // Linked member if ($conf->adherent->enabled)