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 = !((
isModEnabled(
'facture') && $user->hasRight(
'facture',
'read'))
66 || (
isModEnabled(
'commande') && $user->hasRight(
'commande',
'read'))
67 || (
isModEnabled(
'propal') && $user->hasRight(
'propal',
'read'))
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->hasRight(
"societe",
"client",
"voir") ?
'1' :
'0').
'.cache';
91 if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) {
92 $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
94 $textHead = $langs->trans(
"Activity").
' - '.$langs->trans(
"LastXMonthRolling", $nbofperiod);
95 $this->info_box_head = array(
105 if (
isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
106 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
107 $propalstatic =
new Propal($this->
db);
109 $cachedir = DOL_DATA_ROOT.
'/propale/temp';
110 $filename =
'/boxactivity-propal'.$fileid;
114 $sql =
"SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb";
115 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p";
116 if (empty($user->rights->societe->client->voir) && !$user->socid) {
117 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
120 $sql .=
" WHERE p.entity IN (".getEntity(
'propal').
")";
121 $sql .=
" AND p.fk_soc = s.rowid";
122 if (empty($user->rights->societe->client->voir) && !$user->socid) {
123 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
126 $sql .=
" AND s.rowid = ".((int) $user->socid);
128 $sql .=
" AND p.datep >= '".$this->db->idate($tmpdate).
"'";
129 $sql .=
" AND p.date_cloture IS NULL";
130 $sql .=
" GROUP BY p.fk_statut";
131 $sql .=
" ORDER BY p.fk_statut DESC";
133 $result = $this->
db->query($sql);
135 $num = $this->
db->num_rows($result);
139 $data[$j] = $this->
db->fetch_object($result);
142 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
145 $this->
db->free($result);
155 while ($j < count($data)) {
156 $this->info_box_contents[$line][0] = array(
157 'td' =>
'class="left" width="16"',
158 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
159 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
160 'logo' =>
'object_propal'
163 $this->info_box_contents[$line][1] = array(
165 'text' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
168 $this->info_box_contents[$line][2] = array(
169 'td' =>
'class="right"',
170 'text' => $data[$j]->nb,
171 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
172 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
174 $totalnb += $data[$j]->nb;
176 $this->info_box_contents[$line][3] = array(
177 'td' =>
'class="nowraponall right amount"',
178 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
180 $this->info_box_contents[$line][4] = array(
181 'td' =>
'class="right" width="18"',
182 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3),
188 if (count($data) == 0) {
189 $this->info_box_contents[$line][0] = array(
190 'td' =>
'class="center"',
191 'text'=>$langs->trans(
"NoRecordedProposals"),
199 if (
isModEnabled(
'commande') && $user->hasRight(
"commande",
"lire")) {
200 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
203 $langs->load(
"orders");
205 $cachedir = DOL_DATA_ROOT.
'/commande/temp';
206 $filename =
'/boxactivity-order'.$fileid;
211 $sql =
"SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
212 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
213 if (empty($user->rights->societe->client->voir) && !$user->socid) {
214 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
217 $sql .=
" WHERE c.entity IN (".getEntity(
'commande').
")";
218 $sql .=
" AND c.fk_soc = s.rowid";
219 if (empty($user->rights->societe->client->voir) && !$user->socid) {
220 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
223 $sql .=
" AND s.rowid = ".((int) $user->socid);
225 $sql .=
" AND c.date_commande >= '".$this->db->idate($tmpdate).
"'";
226 $sql .=
" GROUP BY c.fk_statut";
227 $sql .=
" ORDER BY c.fk_statut DESC";
229 $result = $this->
db->query($sql);
231 $num = $this->
db->num_rows($result);
234 $data[$j] = $this->
db->fetch_object($result);
237 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
240 $this->
db->free($result);
250 while ($j < count($data)) {
251 $this->info_box_contents[$line][0] = array(
252 'td' =>
'class="left" width="16"',
253 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
254 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
255 'logo' =>
'object_order',
258 $this->info_box_contents[$line][1] = array(
260 'text' =>$langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
263 $this->info_box_contents[$line][2] = array(
264 'td' =>
'class="right"',
265 'text' => $data[$j]->nb,
266 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
267 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
269 $totalnb += $data[$j]->nb;
271 $this->info_box_contents[$line][3] = array(
272 'td' =>
'class="nowraponall right amount"',
273 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
275 $this->info_box_contents[$line][4] = array(
276 'td' =>
'class="right" width="18"',
277 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
283 if (count($data) == 0) {
284 $this->info_box_contents[$line][0] = array(
285 'td' =>
'class="center"',
286 'text'=>$langs->trans(
"NoRecordedOrders"),
295 if (
isModEnabled(
'facture') && $user->hasRight(
"facture",
"lire")) {
296 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
300 $cachedir = DOL_DATA_ROOT.
'/facture/temp';
301 $filename =
'/boxactivity-invoice'.$fileid;
306 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
307 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
308 if (empty($user->rights->societe->client->voir) && !$user->socid) {
309 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
312 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
313 if (empty($user->rights->societe->client->voir) && !$user->socid) {
314 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
317 $sql .=
" AND s.rowid = ".((int) $user->socid);
319 $sql .=
" AND f.fk_soc = s.rowid";
320 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=1";
321 $sql .=
" GROUP BY f.fk_statut";
322 $sql .=
" ORDER BY f.fk_statut DESC";
324 $result = $this->
db->query($sql);
326 $num = $this->
db->num_rows($result);
329 $data[$j] = $this->
db->fetch_object($result);
332 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
335 $this->
db->free($result);
345 while ($j < count($data)) {
346 $billurl =
"search_status=2&paye=1";
347 $this->info_box_contents[$line][0] = array(
348 'td' =>
'class="left" width="16"',
349 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
350 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
354 $this->info_box_contents[$line][1] = array(
356 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
359 $this->info_box_contents[$line][2] = array(
360 'td' =>
'class="right"',
361 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
362 'text' => $data[$j]->nb,
363 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
366 $this->info_box_contents[$line][3] = array(
367 'td' =>
'class="nowraponall right amount"',
368 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
372 $totalnb += $data[$j]->nb;
374 $this->info_box_contents[$line][4] = array(
375 'td' =>
'class="right" width="18"',
376 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
381 if (count($data) == 0) {
382 $this->info_box_contents[$line][0] = array(
383 'td' =>
'class="center"',
384 'text'=>$langs->trans(
"NoRecordedInvoices"),
391 $cachedir = DOL_DATA_ROOT.
'/facture/temp';
392 $filename =
'/boxactivity-invoice2'.$fileid;
398 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
399 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
400 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
401 $sql .=
" AND f.fk_soc = s.rowid";
402 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=0";
403 $sql .=
" GROUP BY f.fk_statut";
404 $sql .=
" ORDER BY f.fk_statut DESC";
406 $result = $this->
db->query($sql);
408 $num = $this->
db->num_rows($result);
411 $data[$j] = $this->
db->fetch_object($result);
414 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
417 $this->
db->free($result);
429 while ($j < count($data)) {
430 $billurl =
"search_status=".$data[$j]->fk_statut.
"&paye=0";
431 $this->info_box_contents[$line][0] = array(
432 'td' =>
'class="left" width="16"',
433 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
434 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
438 $this->info_box_contents[$line][1] = array(
440 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
443 $this->info_box_contents[$line][2] = array(
444 'td' =>
'class="right"',
445 'text' => $data[$j]->nb,
446 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
447 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
449 $totalnb += $data[$j]->nb;
450 $this->info_box_contents[$line][3] = array(
451 'td' =>
'class="nowraponall right amount"',
452 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
454 $this->info_box_contents[$line][4] = array(
455 'td' =>
'class="right" width="18"',
456 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
461 if (count($data) == 0) {
462 $this->info_box_contents[$line][0] = array(
463 'td' =>
'class="center"',
464 'text'=>$langs->trans(
"NoRecordedUnpaidInvoices"),
472 $this->info_box_contents[$line][0] = array(
'tr' =>
'class="liste_total_wrap"');
473 $this->info_box_contents[$line][1] = array(
'td' =>
'class="liste_total left" ',
'text' => $langs->trans(
"Total").
" ".$textHead);
474 $this->info_box_contents[$line][2] = array(
'td' =>
'class="liste_total right" ',
'text' => $totalnb);
475 $this->info_box_contents[$line][3] = array(
'td' =>
'class="liste_total right" ',
'text' =>
'');
476 $this->info_box_contents[$line][4] = array(
'td' =>
'class="liste_total right" ',
'text' =>
"");
488 public function showBox($head =
null, $contents =
null, $nooutput = 0)
490 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage customers orders.
Class to manage invoices.
Class to manage proposals.
Class to manage the box of customer activity (invoice, order, proposal)
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param)
Constructor.
loadBox($max=5)
Charge les donnees en memoire pour affichage ulterieur.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_filecache($directory, $filename, $object)
Store object in file.
dol_readcachefile($directory, $filename)
Read object from cachefile.
dol_cache_refresh($directory, $filename, $cachetime)
Test if Refresh needed.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
dol_now($mode='auto')
Return date for now.
isModEnabled($module)
Is Dolibarr module enabled.
$conf db
API class for accounts.