26 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
33 public $boxcode =
"activity";
34 public $boximg =
"object_bill";
35 public $boxlabel =
'BoxGlobalActivity';
36 public $depends = array(
"facture");
46 public $info_box_head = array();
47 public $info_box_contents = array();
63 $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL);
65 $this->hidden = !((!empty($conf->facture->enabled) && $user->rights->facture->lire)
66 || (!empty($conf->commande->enabled) && $user->rights->commande->lire)
67 || (!empty($conf->propal->enabled) && $user->rights->propale->lire)
79 global $conf, $user, $langs;
81 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
82 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
87 $fileid =
'-e'.$conf->entity.
'-u'.$user->id.
'-s'.$user->socid.
'-r'.($user->rights->societe->client->voir ?
'1' :
'0').
'.cache';
91 if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
92 $textHead = $langs->trans(
"Activity").
' - '.$langs->trans(
"LastXMonthRolling", $nbofperiod);
93 $this->info_box_head = array(
103 if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
105 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
106 $propalstatic =
new Propal($this->
db);
108 $cachedir = DOL_DATA_ROOT.
'/propale/temp';
109 $filename =
'/boxactivity-propal'.$fileid;
114 $sql =
"SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
115 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p";
116 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
118 $sql .=
" WHERE p.entity IN (".getEntity(
'propal').
")";
119 $sql .=
" AND p.fk_soc = s.rowid";
120 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
121 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
122 $sql .=
" AND p.datep >= '".$this->db->idate($tmpdate).
"'";
123 $sql .=
" AND p.date_cloture IS NULL";
124 $sql .=
" GROUP BY p.fk_statut";
125 $sql .=
" ORDER BY p.fk_statut DESC";
127 $result = $this->
db->query($sql);
130 $num = $this->
db->num_rows($result);
134 $data[$j] = $this->
db->fetch_object($result);
137 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
140 $this->
db->free($result);
151 while ($j < count($data))
153 $this->info_box_contents[$line][0] = array(
154 'td' =>
'class="left" width="16"',
155 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut,
156 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
157 'logo' =>
'object_propal'
160 $this->info_box_contents[$line][1] = array(
162 'text' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
165 $this->info_box_contents[$line][2] = array(
166 'td' =>
'class="right"',
167 'text' => $data[$j]->nb,
168 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
169 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut,
171 $totalnb += $data[$j]->nb;
173 $this->info_box_contents[$line][3] = array(
174 'td' =>
'class="nowraponall right"',
175 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
177 $this->info_box_contents[$line][4] = array(
178 'td' =>
'class="right" width="18"',
179 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3),
189 if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
190 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
193 $langs->load(
"orders");
195 $cachedir = DOL_DATA_ROOT.
'/commande/temp';
196 $filename =
'/boxactivity-order'.$fileid;
201 $sql =
"SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
202 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
203 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
205 $sql .=
" WHERE c.entity IN (".getEntity(
'commande').
")";
206 $sql .=
" AND c.fk_soc = s.rowid";
207 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
208 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
209 $sql .=
" AND c.date_commande >= '".$this->db->idate($tmpdate).
"'";
210 $sql .=
" GROUP BY c.fk_statut";
211 $sql .=
" ORDER BY c.fk_statut DESC";
213 $result = $this->
db->query($sql);
215 $num = $this->
db->num_rows($result);
218 $data[$j] = $this->
db->fetch_object($result);
221 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
224 $this->
db->free($result);
234 while ($j < count($data)) {
235 $this->info_box_contents[$line][0] = array(
236 'td' =>
'class="left" width="16"',
237 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
238 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
239 'logo' =>
'object_order',
242 $this->info_box_contents[$line][1] = array(
244 'text' =>$langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
247 $this->info_box_contents[$line][2] = array(
248 'td' =>
'class="right"',
249 'text' => $data[$j]->nb,
250 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
251 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
253 $totalnb += $data[$j]->nb;
255 $this->info_box_contents[$line][3] = array(
256 'td' =>
'class="nowraponall right"',
257 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
259 $this->info_box_contents[$line][4] = array(
260 'td' =>
'class="right" width="18"',
261 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
272 if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
274 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
278 $cachedir = DOL_DATA_ROOT.
'/facture/temp';
279 $filename =
'/boxactivity-invoice'.$fileid;
285 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
286 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
287 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
289 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
290 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
291 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
292 $sql .=
" AND f.fk_soc = s.rowid";
293 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=1";
294 $sql .=
" GROUP BY f.fk_statut";
295 $sql .=
" ORDER BY f.fk_statut DESC";
297 $result = $this->
db->query($sql);
299 $num = $this->
db->num_rows($result);
302 $data[$j] = $this->
db->fetch_object($result);
305 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
308 $this->
db->free($result);
318 while ($j < count($data)) {
319 $billurl =
"search_status=2&paye=1&year=".$data[$j]->annee;
320 $this->info_box_contents[$line][0] = array(
321 'td' =>
'class="left" width="16"',
322 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
323 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
327 $this->info_box_contents[$line][1] = array(
329 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0).
" ".$data[$j]->annee,
332 $this->info_box_contents[$line][2] = array(
333 'td' =>
'class="right"',
334 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
335 'text' => $data[$j]->nb,
336 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
339 $this->info_box_contents[$line][3] = array(
340 'td' =>
'class="nowraponall right"',
341 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
345 $totalnb += $data[$j]->nb;
347 $this->info_box_contents[$line][4] = array(
348 'td' =>
'class="right" width="18"',
349 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
354 if (count($data) == 0)
355 $this->info_box_contents[$line][0] = array(
356 'td' =>
'class="center"',
357 'text'=>$langs->trans(
"NoRecordedInvoices"),
362 $cachedir = DOL_DATA_ROOT.
'/facture/temp';
363 $filename =
'/boxactivity-invoice2'.$fileid;
369 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
370 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
371 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
372 $sql .=
" AND f.fk_soc = s.rowid";
373 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=0";
374 $sql .=
" GROUP BY f.fk_statut";
375 $sql .=
" ORDER BY f.fk_statut DESC";
377 $result = $this->
db->query($sql);
379 $num = $this->
db->num_rows($result);
382 $data[$j] = $this->
db->fetch_object($result);
385 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
388 $this->
db->free($result);
400 while ($j < count($data)) {
401 $billurl =
"search_status=".$data[$j]->fk_statut.
"&paye=0";
402 $this->info_box_contents[$line][0] = array(
403 'td' =>
'class="left" width="16"',
404 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
405 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
409 $this->info_box_contents[$line][1] = array(
411 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
414 $this->info_box_contents[$line][2] = array(
415 'td' =>
'class="right"',
416 'text' => $data[$j]->nb,
417 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
418 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
420 $totalnb += $data[$j]->nb;
421 $this->info_box_contents[$line][3] = array(
422 'td' =>
'class="nowraponall right"',
423 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
425 $this->info_box_contents[$line][4] = array(
426 'td' =>
'class="right" width="18"',
427 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
432 if (count($data) == 0) {
433 $this->info_box_contents[$line][0] = array(
434 'td' =>
'class="center"',
435 'text'=>$langs->trans(
"NoRecordedInvoices"),
442 $this->info_box_contents[$line][0] = array(
'tr' =>
'class="liste_total_wrap"');
443 $this->info_box_contents[$line][1] = array(
'td' =>
'class="liste_total left" ',
'text' => $langs->trans(
"Total").
" ".$textHead);
444 $this->info_box_contents[$line][2] = array(
'td' =>
'class="liste_total right" ',
'text' => $totalnb);
445 $this->info_box_contents[$line][3] = array(
'td' =>
'class="liste_total right" ',
'text' =>
'');
446 $this->info_box_contents[$line][4] = array(
'td' =>
'class="liste_total right" ',
'text' =>
"");
458 public function showBox($head = null, $contents = null, $nooutput = 0)
460 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
__construct($db, $param)
Constructor.
dol_cache_refresh($directory, $filename, $cachetime)
Test if Refresh needed.
dol_now($mode= 'auto')
Return date for now.
$conf db
API class for accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
Class to manage customers orders.
loadBox($max=5)
Charge les donnees en memoire pour affichage ulterieur.
Class to manage the box of customer activity (invoice, order, proposal)
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_readcachefile($directory, $filename)
Read object from cachefile.
Class to manage invoices.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
dol_filecache($directory, $filename, $object)
Store object in file.
Class to manage proposals.