dolibarr
25.0.0-alpha
Main Page
Related Pages
Topics
Classes
Files
Examples
File List
File Members
dolibarr_dev
htdocs
societe
class
client.class.php
Go to the documentation of this file.
1
<?php
2
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
5
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6
* Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
*/
21
27
include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php'
;
28
29
33
class
Client
extends
Societe
34
{
38
public
$next_prev_filter =
"(te.client:in:1,2,3)"
;
39
43
public
$cacheprospectstatus = array();
44
45
51
public
function
__construct
($db)
52
{
53
$this->db = $db;
54
55
$this->client = 3;
56
$this->fournisseur = 0;
57
}
58
59
79
public
function
fetch
($rowid, $ref =
''
, $ref_ext =
''
, $barcode =
''
, $idprof1 =
''
, $idprof2 =
''
, $idprof3 =
''
, $idprof4 =
''
, $idprof5 =
''
, $idprof6 =
''
, $email =
''
, $ref_alias =
''
, $is_client = 1, $is_supplier = 0)
80
{
81
return
parent::fetch($rowid, $ref, $ref_ext, $barcode, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias, $is_client, $is_supplier);
82
}
83
84
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
90
public
function
loadStateBoard
()
91
{
92
global $user, $hookmanager;
93
94
$this->nb = array(
"prospects"
=> 0,
"customers"
=> 0);
95
$clause =
"WHERE"
;
96
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);
102
$clause =
"AND"
;
103
}
104
$sql .=
" "
.$clause.
" s.client IN (1,2,3)"
;
105
$sql .=
' AND s.entity IN ('
.getEntity($this->element).
')'
;
106
// Add where from hooks
107
if
(is_object($hookmanager)) {
108
$parameters = array();
109
$reshook = $hookmanager->executeHooks(
'printFieldListWhere'
, $parameters, $this);
// Note that $action and $object may have been modified by hook
110
$sql .= $hookmanager->resPrint;
111
}
112
$sql .=
" GROUP BY s.client"
;
113
114
$resql = $this->db->query($sql);
115
if
($resql) {
116
while
($obj = $this->db->fetch_object($resql)) {
117
if
($obj->client == 1 || $obj->client == 3) {
118
$this->nb[
"customers"
] += (int) $obj->nb;
119
}
120
if
($obj->client == 2 || $obj->client == 3) {
121
$this->nb[
"prospects"
] += (int) $obj->nb;
122
}
123
}
124
$this->db->free($resql);
125
return
1;
126
}
else
{
127
dol_print_error($this->db);
128
$this->error = $this->db->lasterror();
129
return
-1;
130
}
131
}
132
139
public
function
loadCacheOfProspStatus
($active = 1)
140
{
141
global $langs;
142
143
$sql =
"SELECT id, code, libelle as label, picto, sortorder"
;
144
$sql .=
" FROM "
.MAIN_DB_PREFIX.
"c_stcomm"
;
145
if
($active >= 0) {
146
$sql .=
" WHERE active = "
.((int) $active);
147
}
148
$sql .= $this->db->order(
'sortorder,id'
,
'ASC,ASC'
);
149
150
$resql = $this->db->query($sql);
151
$num = $this->db->num_rows($resql);
152
$i = 0;
153
while
($i < $num) {
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);
156
$i++;
157
}
158
return
1;
159
}
160
}
Client
Class to manage customers or prospects.
Definition
client.class.php:34
Client\fetch
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.
Definition
client.class.php:79
Client\loadStateBoard
loadStateBoard()
Load indicators into this->nb for board.
Definition
client.class.php:90
Client\loadCacheOfProspStatus
loadCacheOfProspStatus($active=1)
Load array of prospect status.
Definition
client.class.php:139
Client\__construct
__construct($db)
Constructor.
Definition
client.class.php:51
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition
societe.class.php:57
Generated on Thu Oct 1 2026 01:00:29 for
dolibarr
by Doxygen 1.11.0