27include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
38 public $next_prev_filter =
"(te.client:in:1,2,3)";
43 public $cacheprospectstatus = array();
56 $this->fournisseur = 0;
79 public function fetch($rowid, $ref =
'', $ref_ext =
'', $barcode =
'', $idprof1 =
'', $idprof2 =
'', $idprof3 =
'', $idprof4 =
'', $idprof5 =
'', $idprof6 =
'', $email =
'', $ref_alias =
'', $is_client = 1, $is_supplier = 0)
81 return parent::fetch($rowid, $ref, $ref_ext, $barcode, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias, $is_client, $is_supplier);
92 global $user, $hookmanager;
94 $this->nb = array(
"prospects" => 0,
"customers" => 0);
97 $sql =
"SELECT count(s.rowid) as nb, s.client";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
99 if (!$user->hasRight(
'societe',
'client',
'voir')) {
100 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON s.rowid = sc.fk_soc";
101 $sql .=
" WHERE sc.fk_user = ".((int) $user->id);
104 $sql .=
" ".$clause.
" s.client IN (1,2,3)";
105 $sql .=
' AND s.entity IN ('.getEntity($this->element).
')';
107 if (is_object($hookmanager)) {
108 $parameters = array();
109 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $this);
110 $sql .= $hookmanager->resPrint;
112 $sql .=
" GROUP BY s.client";
114 $resql = $this->db->query($sql);
116 while ($obj = $this->db->fetch_object($resql)) {
117 if ($obj->client == 1 || $obj->client == 3) {
118 $this->nb[
"customers"] += (int) $obj->nb;
120 if ($obj->client == 2 || $obj->client == 3) {
121 $this->nb[
"prospects"] += (int) $obj->nb;
124 $this->db->free($resql);
128 $this->error = $this->db->lasterror();
143 $sql =
"SELECT id, code, libelle as label, picto, sortorder";
144 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_stcomm";
146 $sql .=
" WHERE active = ".((int) $active);
148 $sql .= $this->db->order(
'sortorder,id',
'ASC,ASC');
150 $resql = $this->db->query($sql);
151 $num = $this->db->num_rows($resql);
154 $obj = $this->db->fetch_object($resql);
155 $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...