28 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
29 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
37 public $boxcode =
"lastprospects";
38 public $boximg =
"object_company";
39 public $boxlabel =
"BoxLastProspects";
40 public $depends = array(
"societe");
61 $this->hidden = !($user->hasRight(
'societe',
'read') && empty($user->socid));
72 global $user, $langs, $hookmanager;
76 $thirdpartystatic =
new Client($this->db);
78 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedProspects", $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.fk_stcomm";
85 $sql .=
", s.datec, s.tms, s.status";
86 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
87 if (!$user->hasRight(
'societe',
'client',
'voir')) {
88 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
90 $sql .=
" WHERE s.client IN (2, 3)";
91 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
92 if (!$user->hasRight(
'societe',
'client',
'voir')) {
93 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
96 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
97 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
98 if (empty($reshook)) {
99 if ($user->socid > 0) {
100 $sql .=
" AND s.rowid = ".((int) $user->socid);
103 $sql .= $hookmanager->resPrint;
104 $sql .=
" ORDER BY s.tms DESC";
105 $sql .= $this->db->plimit($max, 0);
107 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
108 $resql = $this->db->query(
$sql);
110 $num = $this->db->num_rows($resql);
113 while ($line < $num) {
114 $objp = $this->db->fetch_object($resql);
115 $datec = $this->db->jdate($objp->datec);
116 $datem = $this->db->jdate($objp->tms);
118 $thirdpartystatic->id = $objp->socid;
119 $thirdpartystatic->name = $objp->name;
120 $thirdpartystatic->name_alias = $objp->name_alias;
121 $thirdpartystatic->code_client = $objp->code_client;
122 $thirdpartystatic->code_compta = $objp->code_compta;
123 $thirdpartystatic->client = $objp->client;
124 $thirdpartystatic->logo = $objp->logo;
125 $thirdpartystatic->email = $objp->email;
126 $thirdpartystatic->entity = $objp->entity;
128 $this->info_box_contents[$line][] = array(
129 'td' =>
'class="tdoverflowmax150"',
130 'text' => $thirdpartystatic->getNomUrl(1),
134 $this->info_box_contents[$line][] = array(
139 $this->info_box_contents[$line][] = array(
140 'td' =>
'class="right" width="18"',
141 'text' => str_replace(
'img ',
'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)),
144 $this->info_box_contents[$line][] = array(
145 'td' =>
'class="right" width="18"',
146 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
153 $this->info_box_contents[$line][0] = array(
154 'td' =>
'class="center"',
155 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedProspects").
'</span>'
159 $this->db->free($resql);
161 $this->info_box_contents[0][0] = array(
164 'text' => ($this->db->error().
' sql='.
$sql),
168 $this->info_box_contents[0][0] = array(
169 'td' =>
'class="nohover left"',
170 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
183 public function showBox($head =
null, $contents =
null, $nooutput = 0)
185 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 prospects.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param='')
Constructor.
loadBox($max=5)
Load data into info_box_contents array to show array later.
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...