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");
49 public $info_box_head = array();
50 public $info_box_contents = array();
66 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
70 $this->hidden = !($user->hasRight(
'societe',
'read') && empty($user->socid));
81 global $user, $langs, $hookmanager;
85 $thirdpartystatic =
new Client($this->
db);
87 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedProspects", $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.fk_stcomm";
94 $sql .=
", s.datec, s.tms, s.status";
95 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
96 if (empty($user->rights->societe->client->voir) && !$user->socid) {
97 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
99 $sql .=
" WHERE s.client IN (2, 3)";
100 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
101 if (empty($user->rights->societe->client->voir) && !$user->socid) {
102 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
105 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
106 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
107 if (empty($reshook)) {
108 if ($user->socid > 0) {
109 $sql .=
" AND s.rowid = ".((int) $user->socid);
112 $sql .= $hookmanager->resPrint;
113 $sql .=
" ORDER BY s.tms DESC";
114 $sql .= $this->
db->plimit($max, 0);
116 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
122 while ($line < $num) {
123 $objp = $this->
db->fetch_object(
$resql);
124 $datec = $this->
db->jdate($objp->datec);
125 $datem = $this->
db->jdate($objp->tms);
127 $thirdpartystatic->id = $objp->socid;
128 $thirdpartystatic->name = $objp->name;
129 $thirdpartystatic->name_alias = $objp->name_alias;
130 $thirdpartystatic->code_client = $objp->code_client;
131 $thirdpartystatic->code_compta = $objp->code_compta;
132 $thirdpartystatic->client = $objp->client;
133 $thirdpartystatic->logo = $objp->logo;
134 $thirdpartystatic->email = $objp->email;
135 $thirdpartystatic->entity = $objp->entity;
137 $this->info_box_contents[$line][] = array(
138 'td' =>
'class="tdoverflowmax150"',
139 'text' => $thirdpartystatic->getNomUrl(1),
143 $this->info_box_contents[$line][] = array(
148 $this->info_box_contents[$line][] = array(
149 'td' =>
'class="right" width="18"',
150 'text' => str_replace(
'img ',
'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)),
153 $this->info_box_contents[$line][] = array(
154 'td' =>
'class="right" width="18"',
155 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
162 $this->info_box_contents[$line][0] = array(
163 'td' =>
'class="center opacitymedium"',
164 'text'=> $langs->trans(
"NoRecordedProspects"),
170 $this->info_box_contents[0][0] = array(
173 'text' => ($this->
db->error().
' sql='.$sql),
177 $this->info_box_contents[0][0] = array(
178 'td' =>
'class="nohover opacitymedium left"',
179 'text' => $langs->trans(
"ReadPermissionNotAllowed")
192 public function showBox($head =
null, $contents =
null, $nooutput = 0)
194 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('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.