27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastcustomers";
36 public $boximg =
"object_company";
37 public $boxlabel =
"BoxLastCustomers";
38 public $depends = array(
"societe");
47 public $info_box_head = array();
48 public $info_box_contents = array();
64 if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
68 $this->hidden = !($user->hasRight(
'societe',
'read') && empty($user->socid));
79 global $user, $langs, $hookmanager;
80 $langs->load(
"boxes");
84 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
85 $thirdpartystatic =
new Client($this->
db);
87 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedCustomers", $max));
89 if ($user->hasRight(
'societe',
'lire')) {
90 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
91 $sql .=
", s.code_client, s.code_compta, s.client";
92 $sql .=
", s.logo, s.email, s.entity";
93 $sql .=
", s.datec, s.tms, s.status";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
95 if (empty($user->rights->societe->client->voir) && !$user->socid) {
96 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
98 $sql .=
" WHERE s.client IN (1, 3)";
99 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
100 if (empty($user->rights->societe->client->voir) && !$user->socid) {
101 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
104 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
105 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
106 if (empty($reshook)) {
107 if ($user->socid > 0) {
108 $sql .=
" AND s.rowid = ".((int) $user->socid);
111 $sql .= $hookmanager->resPrint;
112 $sql .=
" ORDER BY s.tms DESC";
113 $sql .= $this->
db->plimit($max, 0);
115 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
116 $result = $this->
db->query($sql);
118 $num = $this->
db->num_rows($result);
121 while ($line < $num) {
122 $objp = $this->
db->fetch_object($result);
123 $datec = $this->
db->jdate($objp->datec);
124 $datem = $this->
db->jdate($objp->tms);
126 $thirdpartystatic->id = $objp->socid;
127 $thirdpartystatic->name = $objp->name;
128 $thirdpartystatic->name_alias = $objp->name_alias;
129 $thirdpartystatic->code_client = $objp->code_client;
130 $thirdpartystatic->code_compta = $objp->code_compta;
131 $thirdpartystatic->client = $objp->client;
132 $thirdpartystatic->logo = $objp->logo;
133 $thirdpartystatic->email = $objp->email;
134 $thirdpartystatic->entity = $objp->entity;
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="tdoverflowmax150"',
138 'text' => $thirdpartystatic->getNomUrl(1),
142 $this->info_box_contents[$line][] = array(
147 $this->info_box_contents[$line][] = array(
148 'td' =>
'class="right" width="18"',
149 'text' => $thirdpartystatic->LibStatut($objp->status, 3)
156 $this->info_box_contents[$line][0] = array(
157 'td' =>
'class="center opacitymedium"',
158 'text'=>$langs->trans(
"NoRecordedCustomers")
162 $this->
db->free($result);
164 $this->info_box_contents[0][0] = array(
167 'text' => ($this->
db->error().
' sql='.$sql)
171 $this->info_box_contents[0][0] = array(
172 'td' =>
'class="nohover opacitymedium left"',
173 'text' => $langs->trans(
"ReadPermissionNotAllowed")
186 public function showBox($head =
null, $contents =
null, $nooutput = 0)
188 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage customers or prospects.
Class to manage the box to show last thirdparties.
loadBox($max=5)
Load data for box to show them later.
__construct($db, $param='')
Constructor.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.