71 global $conf, $user, $langs;
73 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
74 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
82 $savMAIN_ACTIVATE_FILECACHE =
getDolGlobalInt(
'MAIN_ACTIVATE_FILECACHE');
83 $conf->global->MAIN_ACTIVATE_FILECACHE = 1;
89 $textHead = $langs->trans(
"Activity").
' - '.$langs->trans(
"LastXMonthRolling", $nbofperiod);
90 $this->info_box_head = array(
100 if (isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
101 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
102 $propalstatic =
new Propal($this->db);
106 $sql =
"SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb";
107 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p";
108 if (!$user->hasRight(
'societe',
'client',
'voir')) {
109 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
112 $sql .=
" WHERE p.entity IN (".getEntity(
'propal').
")";
113 $sql .=
" AND p.fk_soc = s.rowid";
114 if (!$user->hasRight(
'societe',
'client',
'voir')) {
115 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
118 $sql .=
" AND s.rowid = ".((int) $user->socid);
120 $sql .=
" AND p.datep >= '".$this->db->idate($tmpdate).
"'";
121 $sql .=
" AND p.date_cloture IS NULL";
122 $sql .=
" GROUP BY p.fk_statut";
123 $sql .=
" ORDER BY p.fk_statut DESC";
125 $result = $this->db->query($sql);
127 $num = $this->db->num_rows($result);
131 $data[$j] = $this->db->fetch_object($result);
136 $this->db->free($result);
143 while ($j < count($data)) {
144 $this->info_box_contents[$line][0] = array(
145 'td' =>
'class="left" width="16"',
146 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
147 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
148 'logo' =>
'object_propal'
151 $this->info_box_contents[$line][1] = array(
153 'text' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
156 $this->info_box_contents[$line][2] = array(
157 'td' =>
'class="right"',
158 'text' => $data[$j]->nb,
159 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
160 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
162 $totalnb += $data[$j]->nb;
164 $this->info_box_contents[$line][3] = array(
165 'td' =>
'class="nowraponall right amount"',
166 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
168 $this->info_box_contents[$line][4] = array(
169 'td' =>
'class="right" width="18"',
170 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3),
176 if (count($data) == 0) {
177 $this->info_box_contents[$line][0] = array(
178 'td' =>
'class="center"',
179 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedProposals").
'</span>',
187 if (isModEnabled(
'order') && $user->hasRight(
"commande",
"lire")) {
188 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
189 $commandestatic =
new Commande($this->db);
191 $langs->load(
"orders");
195 $sql =
"SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
196 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
197 if (!$user->hasRight(
'societe',
'client',
'voir')) {
198 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
201 $sql .=
" WHERE c.entity IN (".getEntity(
'commande').
")";
202 $sql .=
" AND c.fk_soc = s.rowid";
203 if (!$user->hasRight(
'societe',
'client',
'voir')) {
204 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
207 $sql .=
" AND s.rowid = ".((int) $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);
222 $this->db->free($result);
229 while ($j < count($data)) {
230 $this->info_box_contents[$line][0] = array(
231 'td' =>
'class="left" width="16"',
232 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
233 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
234 'logo' =>
'object_order',
237 $this->info_box_contents[$line][1] = array(
239 'text' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
242 $this->info_box_contents[$line][2] = array(
243 'td' =>
'class="right"',
244 'text' => $data[$j]->nb,
245 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
246 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
248 $totalnb += $data[$j]->nb;
250 $this->info_box_contents[$line][3] = array(
251 'td' =>
'class="nowraponall right amount"',
252 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
254 $this->info_box_contents[$line][4] = array(
255 'td' =>
'class="right" width="18"',
256 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
262 if (count($data) == 0) {
263 $this->info_box_contents[$line][0] = array(
264 'td' =>
'class="center"',
265 'text' => $langs->trans(
"NoRecordedOrders"),
274 if (isModEnabled(
'invoice') && $user->hasRight(
"facture",
"lire")) {
275 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
276 $facturestatic =
new Facture($this->db);
280 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
281 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
282 if (!$user->hasRight(
'societe',
'client',
'voir')) {
283 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
286 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
287 if (!$user->hasRight(
'societe',
'client',
'voir')) {
288 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
291 $sql .=
" AND s.rowid = ".((int) $user->socid);
293 $sql .=
" AND f.fk_soc = s.rowid";
294 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=1";
295 $sql .=
" GROUP BY f.fk_statut";
296 $sql .=
" ORDER BY f.fk_statut DESC";
298 $result = $this->db->query($sql);
300 $num = $this->db->num_rows($result);
303 $data[$j] = $this->db->fetch_object($result);
307 $this->db->free($result);
314 while ($j < count($data)) {
315 $billurl =
"search_status=2&paye=1";
316 $this->info_box_contents[$line][0] = array(
317 'td' =>
'class="left" width="16"',
318 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
319 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
323 $this->info_box_contents[$line][1] = array(
325 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
328 $this->info_box_contents[$line][2] = array(
329 'td' =>
'class="right"',
330 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
331 'text' => $data[$j]->nb,
332 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
335 $this->info_box_contents[$line][3] = array(
336 'td' =>
'class="nowraponall right amount"',
337 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
341 $totalnb += $data[$j]->nb;
343 $this->info_box_contents[$line][4] = array(
344 'td' =>
'class="right" width="18"',
345 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
350 if (count($data) == 0) {
351 $this->info_box_contents[$line][0] = array(
352 'td' =>
'class="center"',
353 'text' => $langs->trans(
"NoRecordedInvoices"),
361 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
362 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
363 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
364 $sql .=
" AND f.fk_soc = s.rowid";
365 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=0";
366 $sql .=
" GROUP BY f.fk_statut";
367 $sql .=
" ORDER BY f.fk_statut DESC";
369 $result = $this->db->query($sql);
371 $num = $this->db->num_rows($result);
374 $data[$j] = $this->db->fetch_object($result);
378 $this->db->free($result);
387 while ($j < count($data)) {
388 $billurl =
"search_status=".$data[$j]->fk_statut.
"&paye=0";
389 $this->info_box_contents[$line][0] = array(
390 'td' =>
'class="left" width="16"',
391 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
392 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
396 $this->info_box_contents[$line][1] = array(
398 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
401 $this->info_box_contents[$line][2] = array(
402 'td' =>
'class="right"',
403 'text' => $data[$j]->nb,
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",
407 $totalnb += $data[$j]->nb;
408 $this->info_box_contents[$line][3] = array(
409 'td' =>
'class="nowraponall right amount"',
410 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
412 $this->info_box_contents[$line][4] = array(
413 'td' =>
'class="right" width="18"',
414 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
419 if (count($data) == 0) {
420 $this->info_box_contents[$line][0] = array(
421 'td' =>
'class="center"',
422 'text' => $langs->trans(
"NoRecordedUnpaidInvoices"),
430 $this->info_box_contents[$line][0] = array(
'tr' =>
'class="liste_total_wrap"');
431 $this->info_box_contents[$line][1] = array(
'td' =>
'class="liste_total left" ',
'text' => $langs->trans(
"Total").
" ".$textHead);
432 $this->info_box_contents[$line][2] = array(
'td' =>
'class="liste_total right" ',
'text' => $totalnb);
433 $this->info_box_contents[$line][3] = array(
'td' =>
'class="liste_total right" ',
'text' =>
'');
434 $this->info_box_contents[$line][4] = array(
'td' =>
'class="liste_total right" ',
'text' =>
"");
436 $conf->global->MAIN_ACTIVATE_FILECACHE = $savMAIN_ACTIVATE_FILECACHE;