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");
59 $this->hidden = !($user->hasRight(
'societe',
'read') && empty($user->socid));
70 global $user, $langs, $hookmanager;
71 $langs->load(
"boxes");
75 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
76 $thirdpartystatic =
new Client($this->db);
78 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedCustomers", $max));
80 if ($user->hasRight(
'societe',
'lire')) {
81 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
82 $sql .=
", s.code_client, s.code_compta, s.client";
83 $sql .=
", s.logo, s.email, s.entity";
84 $sql .=
", s.datec, s.tms, s.status";
85 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
86 if (!$user->hasRight(
'societe',
'client',
'voir')) {
87 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
89 $sql .=
" WHERE s.client IN (1, 3)";
90 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
91 if (!$user->hasRight(
'societe',
'client',
'voir')) {
92 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
95 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
96 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
97 if (empty($reshook)) {
98 if ($user->socid > 0) {
99 $sql .=
" AND s.rowid = ".((int) $user->socid);
102 $sql .= $hookmanager->resPrint;
103 $sql .=
" ORDER BY s.tms DESC";
104 $sql .= $this->db->plimit($max, 0);
106 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
107 $result = $this->db->query(
$sql);
109 $num = $this->db->num_rows($result);
112 while ($line < $num) {
113 $objp = $this->db->fetch_object($result);
114 $datec = $this->db->jdate($objp->datec);
115 $datem = $this->db->jdate($objp->tms);
117 $thirdpartystatic->id = $objp->socid;
118 $thirdpartystatic->name = $objp->name;
119 $thirdpartystatic->name_alias = $objp->name_alias;
120 $thirdpartystatic->code_client = $objp->code_client;
121 $thirdpartystatic->code_compta = $objp->code_compta;
122 $thirdpartystatic->client = $objp->client;
123 $thirdpartystatic->logo = $objp->logo;
124 $thirdpartystatic->email = $objp->email;
125 $thirdpartystatic->entity = $objp->entity;
127 $this->info_box_contents[$line][] = array(
128 'td' =>
'class="tdoverflowmax150"',
129 'text' => $thirdpartystatic->getNomUrl(1),
133 $this->info_box_contents[$line][] = array(
138 $this->info_box_contents[$line][] = array(
139 'td' =>
'class="right" width="18"',
140 'text' => $thirdpartystatic->LibStatut($objp->status, 3)
147 $this->info_box_contents[$line][0] = array(
148 'td' =>
'class="center"',
149 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedCustomers").
'</span>'
153 $this->db->free($result);
155 $this->info_box_contents[0][0] = array(
158 'text' => ($this->db->error().
' sql='.
$sql)
162 $this->info_box_contents[0][0] = array(
163 'td' =>
'class="nohover left"',
164 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
177 public function showBox($head =
null, $contents =
null, $nooutput = 0)
179 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 customers.
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.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...