70 global $conf, $user, $langs;
72 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
73 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
81 $savMAIN_ACTIVATE_FILECACHE =
getDolGlobalInt(
'MAIN_ACTIVATE_FILECACHE');
82 $conf->global->MAIN_ACTIVATE_FILECACHE = 1;
88 $textHead = $langs->trans(
"Activity").
' - '.$langs->trans(
"LastXMonthRolling", $nbofperiod);
89 $this->info_box_head = array(
99 if (isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
100 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
101 $propalstatic =
new Propal($this->db);
105 $sql =
"SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb";
106 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p";
107 if (!$user->hasRight(
'societe',
'client',
'voir')) {
108 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
111 $sql .=
" WHERE p.entity IN (".getEntity(
'propal').
")";
112 $sql .=
" AND p.fk_soc = s.rowid";
113 if (!$user->hasRight(
'societe',
'client',
'voir')) {
114 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
117 $sql .=
" AND s.rowid = ".((int) $user->socid);
119 $sql .=
" AND p.datep >= '".$this->db->idate($tmpdate).
"'";
120 $sql .=
" AND p.date_cloture IS NULL";
121 $sql .=
" GROUP BY p.fk_statut";
122 $sql .=
" ORDER BY p.fk_statut DESC";
124 $result = $this->db->query($sql);
126 $num = $this->db->num_rows($result);
130 $data[$j] = $this->db->fetch_object($result);
135 $this->db->free($result);
142 while ($j < count($data)) {
143 $this->info_box_contents[$line][0] = array(
144 'td' =>
'class="left" width="16"',
145 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
146 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
147 'logo' =>
'object_propal'
150 $this->info_box_contents[$line][1] = array(
152 'text' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
155 $this->info_box_contents[$line][2] = array(
156 'td' =>
'class="right"',
157 'text' => $data[$j]->nb,
158 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
159 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
161 $totalnb += $data[$j]->nb;
163 $this->info_box_contents[$line][3] = array(
164 'td' =>
'class="nowraponall right amount"',
165 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
167 $this->info_box_contents[$line][4] = array(
168 'td' =>
'class="right" width="18"',
169 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3),
175 if (count($data) == 0) {
176 $this->info_box_contents[$line][0] = array(
177 'td' =>
'class="center"',
178 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedProposals").
'</span>',
186 if (isModEnabled(
'order') && $user->hasRight(
"commande",
"lire")) {
187 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
188 $commandestatic =
new Commande($this->db);
190 $langs->load(
"orders");
194 $sql =
"SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
195 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
196 if (!$user->hasRight(
'societe',
'client',
'voir')) {
197 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
200 $sql .=
" WHERE c.entity IN (".getEntity(
'commande').
")";
201 $sql .=
" AND c.fk_soc = s.rowid";
202 if (!$user->hasRight(
'societe',
'client',
'voir')) {
203 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
206 $sql .=
" AND s.rowid = ".((int) $user->socid);
208 $sql .=
" AND c.date_commande >= '".$this->db->idate($tmpdate).
"'";
209 $sql .=
" GROUP BY c.fk_statut";
210 $sql .=
" ORDER BY c.fk_statut DESC";
212 $result = $this->db->query($sql);
214 $num = $this->db->num_rows($result);
217 $data[$j] = $this->db->fetch_object($result);
221 $this->db->free($result);
228 while ($j < count($data)) {
229 $this->info_box_contents[$line][0] = array(
230 'td' =>
'class="left" width="16"',
231 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
232 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
233 'logo' =>
'object_order',
236 $this->info_box_contents[$line][1] = array(
238 'text' =>$langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
241 $this->info_box_contents[$line][2] = array(
242 'td' =>
'class="right"',
243 'text' => $data[$j]->nb,
244 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
245 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
247 $totalnb += $data[$j]->nb;
249 $this->info_box_contents[$line][3] = array(
250 'td' =>
'class="nowraponall right amount"',
251 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
253 $this->info_box_contents[$line][4] = array(
254 'td' =>
'class="right" width="18"',
255 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
261 if (count($data) == 0) {
262 $this->info_box_contents[$line][0] = array(
263 'td' =>
'class="center"',
264 'text'=>$langs->trans(
"NoRecordedOrders"),
273 if (isModEnabled(
'invoice') && $user->hasRight(
"facture",
"lire")) {
274 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
275 $facturestatic =
new Facture($this->db);
279 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
280 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
281 if (!$user->hasRight(
'societe',
'client',
'voir')) {
282 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
285 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
286 if (!$user->hasRight(
'societe',
'client',
'voir')) {
287 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
290 $sql .=
" AND s.rowid = ".((int) $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);
306 $this->db->free($result);
313 while ($j < count($data)) {
314 $billurl =
"search_status=2&paye=1";
315 $this->info_box_contents[$line][0] = array(
316 'td' =>
'class="left" width="16"',
317 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
318 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
322 $this->info_box_contents[$line][1] = array(
324 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
327 $this->info_box_contents[$line][2] = array(
328 'td' =>
'class="right"',
329 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
330 'text' => $data[$j]->nb,
331 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
334 $this->info_box_contents[$line][3] = array(
335 'td' =>
'class="nowraponall right amount"',
336 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
340 $totalnb += $data[$j]->nb;
342 $this->info_box_contents[$line][4] = array(
343 'td' =>
'class="right" width="18"',
344 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
349 if (count($data) == 0) {
350 $this->info_box_contents[$line][0] = array(
351 'td' =>
'class="center"',
352 'text'=>$langs->trans(
"NoRecordedInvoices"),
360 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
361 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
362 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
363 $sql .=
" AND f.fk_soc = s.rowid";
364 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=0";
365 $sql .=
" GROUP BY f.fk_statut";
366 $sql .=
" ORDER BY f.fk_statut DESC";
368 $result = $this->db->query($sql);
370 $num = $this->db->num_rows($result);
373 $data[$j] = $this->db->fetch_object($result);
377 $this->db->free($result);
386 while ($j < count($data)) {
387 $billurl =
"search_status=".$data[$j]->fk_statut.
"&paye=0";
388 $this->info_box_contents[$line][0] = array(
389 'td' =>
'class="left" width="16"',
390 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
391 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
395 $this->info_box_contents[$line][1] = array(
397 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
400 $this->info_box_contents[$line][2] = array(
401 'td' =>
'class="right"',
402 'text' => $data[$j]->nb,
403 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
404 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
406 $totalnb += $data[$j]->nb;
407 $this->info_box_contents[$line][3] = array(
408 'td' =>
'class="nowraponall right amount"',
409 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
411 $this->info_box_contents[$line][4] = array(
412 'td' =>
'class="right" width="18"',
413 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
418 if (count($data) == 0) {
419 $this->info_box_contents[$line][0] = array(
420 'td' =>
'class="center"',
421 'text'=>$langs->trans(
"NoRecordedUnpaidInvoices"),
429 $this->info_box_contents[$line][0] = array(
'tr' =>
'class="liste_total_wrap"');
430 $this->info_box_contents[$line][1] = array(
'td' =>
'class="liste_total left" ',
'text' => $langs->trans(
"Total").
" ".$textHead);
431 $this->info_box_contents[$line][2] = array(
'td' =>
'class="liste_total right" ',
'text' => $totalnb);
432 $this->info_box_contents[$line][3] = array(
'td' =>
'class="liste_total right" ',
'text' =>
'');
433 $this->info_box_contents[$line][4] = array(
'td' =>
'class="liste_total right" ',
'text' =>
"");
435 $conf->global->MAIN_ACTIVATE_FILECACHE = $savMAIN_ACTIVATE_FILECACHE;