26include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
37 public $next_prev_filter =
"te.client in (1,2,3)";
42 public $cacheprospectstatus = array();
55 $this->fournisseur = 0;
78 public function fetch($rowid, $ref =
'', $ref_ext =
'', $barcode =
'', $idprof1 =
'', $idprof2 =
'', $idprof3 =
'', $idprof4 =
'', $idprof5 =
'', $idprof6 =
'', $email =
'', $ref_alias =
'', $is_client = 1, $is_supplier = 0)
80 return parent::fetch($rowid, $ref, $ref_ext, $barcode, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias, $is_client, $is_supplier);
91 global $user, $hookmanager;
93 $this->nb = array(
"prospects" => 0,
"customers" => 0);
96 $sql =
"SELECT count(s.rowid) as nb, s.client";
97 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
98 if (!$user->hasRight(
'societe',
'client',
'voir')) {
99 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
100 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
103 $sql .=
" ".$clause.
" s.client IN (1,2,3)";
104 $sql .=
' AND s.entity IN ('.getEntity($this->element).
')';
106 if (is_object($hookmanager)) {
107 $parameters = array();
108 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
109 $sql .= $hookmanager->resPrint;
111 $sql .=
" GROUP BY s.client";
113 $resql = $this->db->query($sql);
115 while ($obj = $this->db->fetch_object($resql)) {
116 if ($obj->client == 1 || $obj->client == 3) {
117 $this->nb[
"customers"] += $obj->nb;
119 if ($obj->client == 2 || $obj->client == 3) {
120 $this->nb[
"prospects"] += $obj->nb;
123 $this->db->free($resql);
127 $this->error = $this->db->lasterror();
142 $sql =
"SELECT id, code, libelle as label, picto, sortorder";
143 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_stcomm";
145 $sql .=
" WHERE active = ".((int) $active);
147 $sql .= $this->db->order(
'sortorder,id',
'ASC,ASC');
149 $resql = $this->db->query($sql);
150 $num = $this->db->num_rows($resql);
153 $obj = $this->db->fetch_object($resql);
154 $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);
Class to manage customers or prospects.
fetch($rowid, $ref='', $ref_ext='', $barcode='', $idprof1='', $idprof2='', $idprof3='', $idprof4='', $idprof5='', $idprof6='', $email='', $ref_alias='', $is_client=1, $is_supplier=0)
Load a third party from database into memory.
loadStateBoard()
Load indicators into this->nb for board.
loadCacheOfProspStatus($active=1)
Load array of prospect status.
__construct($db)
Constructor.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...