60 global $user, $hookmanager;
62 $this->nb = array(
"prospects" => 0,
"customers" => 0);
65 $sql =
"SELECT count(s.rowid) as nb, s.client";
66 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
67 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
68 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
69 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
72 $sql .=
" ".$clause.
" s.client IN (1,2,3)";
73 $sql .=
' AND s.entity IN ('.getEntity($this->element).
')';
75 if (is_object($hookmanager)) {
76 $parameters = array();
77 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
78 $sql .= $hookmanager->resPrint;
80 $sql .=
" GROUP BY s.client";
82 $resql = $this->db->query($sql);
84 while ($obj = $this->db->fetch_object($resql)) {
85 if ($obj->client == 1 || $obj->client == 3) {
86 $this->nb[
"customers"] += $obj->nb;
88 if ($obj->client == 2 || $obj->client == 3) {
89 $this->nb[
"prospects"] += $obj->nb;
92 $this->db->free($resql);
96 $this->error = $this->db->lasterror();
111 $sql =
"SELECT id, code, libelle as label, picto, sortorder";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_stcomm";
114 $sql .=
" WHERE active = ".((int) $active);
116 $sql .= $this->db->order(
'sortorder,id',
'ASC,ASC');
118 $resql = $this->db->query($sql);
119 $num = $this->db->num_rows($resql);
122 $obj = $this->db->fetch_object($resql);
123 $this->cacheprospectstatus[$obj->id] = array(
'id'=>$obj->id,
'code'=>$obj->code,
'label'=>($langs->trans(
"ST_".strtoupper($obj->code)) ==
"ST_".strtoupper($obj->code)) ? $obj->label : $langs->trans(
"ST_".strtoupper($obj->code)),
'picto'=>$obj->picto);