80 global $conf, $user, $langs;
82 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
83 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
91 $savMAIN_ACTIVATE_FILECACHE =
getDolGlobalInt(
'MAIN_ACTIVATE_FILECACHE');
92 $conf->global->MAIN_ACTIVATE_FILECACHE = 1;
95 $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
98 $textHead = $langs->trans(
"Activity").
' - '.$langs->trans(
"LastXMonthRolling", $nbofperiod);
99 $this->info_box_head = array(
109 if (isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
110 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
111 $propalstatic =
new Propal($this->db);
115 $sql =
"SELECT p.fk_statut, SUM(p.total_ttc) as Mnttot, COUNT(*) as nb";
116 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"propal as p";
117 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
118 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
121 $sql .=
" WHERE p.entity IN (".getEntity(
'propal').
")";
122 $sql .=
" AND p.fk_soc = s.rowid";
123 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
124 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
127 $sql .=
" AND s.rowid = ".((int) $user->socid);
129 $sql .=
" AND p.datep >= '".$this->db->idate($tmpdate).
"'";
130 $sql .=
" AND p.date_cloture IS NULL";
131 $sql .=
" GROUP BY p.fk_statut";
132 $sql .=
" ORDER BY p.fk_statut DESC";
134 $result = $this->db->query($sql);
136 $num = $this->db->num_rows($result);
140 $data[$j] = $this->db->fetch_object($result);
145 $this->db->free($result);
152 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=".((
int) $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=".((
int) $data[$j]->fk_statut),
171 $totalnb += $data[$j]->nb;
173 $this->info_box_contents[$line][3] = array(
174 'td' =>
'class="nowraponall right amount"',
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),
185 if (count($data) == 0) {
186 $this->info_box_contents[$line][0] = array(
187 'td' =>
'class="center"',
188 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedProposals").
'</span>',
196 if (isModEnabled(
'commande') && $user->hasRight(
"commande",
"lire")) {
197 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
198 $commandestatic =
new Commande($this->db);
200 $langs->load(
"orders");
204 $sql =
"SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
205 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
206 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
207 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
210 $sql .=
" WHERE c.entity IN (".getEntity(
'commande').
")";
211 $sql .=
" AND c.fk_soc = s.rowid";
212 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
213 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
216 $sql .=
" AND s.rowid = ".((int) $user->socid);
218 $sql .=
" AND c.date_commande >= '".$this->db->idate($tmpdate).
"'";
219 $sql .=
" GROUP BY c.fk_statut";
220 $sql .=
" ORDER BY c.fk_statut DESC";
222 $result = $this->db->query($sql);
224 $num = $this->db->num_rows($result);
227 $data[$j] = $this->db->fetch_object($result);
231 $this->db->free($result);
238 while ($j < count($data)) {
239 $this->info_box_contents[$line][0] = array(
240 'td' =>
'class="left" width="16"',
241 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
242 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
243 'logo' =>
'object_order',
246 $this->info_box_contents[$line][1] = array(
248 'text' =>$langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
251 $this->info_box_contents[$line][2] = array(
252 'td' =>
'class="right"',
253 'text' => $data[$j]->nb,
254 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
255 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
257 $totalnb += $data[$j]->nb;
259 $this->info_box_contents[$line][3] = array(
260 'td' =>
'class="nowraponall right amount"',
261 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
263 $this->info_box_contents[$line][4] = array(
264 'td' =>
'class="right" width="18"',
265 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
271 if (count($data) == 0) {
272 $this->info_box_contents[$line][0] = array(
273 'td' =>
'class="center"',
274 'text'=>$langs->trans(
"NoRecordedOrders"),
283 if (isModEnabled(
'facture') && $user->hasRight(
"facture",
"lire")) {
284 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
285 $facturestatic =
new Facture($this->db);
289 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
290 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
291 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
292 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
295 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
296 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
297 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
300 $sql .=
" AND s.rowid = ".((int) $user->socid);
302 $sql .=
" AND f.fk_soc = s.rowid";
303 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=1";
304 $sql .=
" GROUP BY f.fk_statut";
305 $sql .=
" ORDER BY f.fk_statut DESC";
307 $result = $this->db->query($sql);
309 $num = $this->db->num_rows($result);
312 $data[$j] = $this->db->fetch_object($result);
316 $this->db->free($result);
323 while ($j < count($data)) {
324 $billurl =
"search_status=2&paye=1";
325 $this->info_box_contents[$line][0] = array(
326 'td' =>
'class="left" width="16"',
327 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
328 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
332 $this->info_box_contents[$line][1] = array(
334 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
337 $this->info_box_contents[$line][2] = array(
338 'td' =>
'class="right"',
339 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
340 'text' => $data[$j]->nb,
341 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
344 $this->info_box_contents[$line][3] = array(
345 'td' =>
'class="nowraponall right amount"',
346 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
350 $totalnb += $data[$j]->nb;
352 $this->info_box_contents[$line][4] = array(
353 'td' =>
'class="right" width="18"',
354 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
359 if (count($data) == 0) {
360 $this->info_box_contents[$line][0] = array(
361 'td' =>
'class="center"',
362 'text'=>$langs->trans(
"NoRecordedInvoices"),
370 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
371 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
372 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
373 $sql .=
" AND f.fk_soc = s.rowid";
374 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=0";
375 $sql .=
" GROUP BY f.fk_statut";
376 $sql .=
" ORDER BY f.fk_statut DESC";
378 $result = $this->db->query($sql);
380 $num = $this->db->num_rows($result);
383 $data[$j] = $this->db->fetch_object($result);
387 $this->db->free($result);
396 while ($j < count($data)) {
397 $billurl =
"search_status=".$data[$j]->fk_statut.
"&paye=0";
398 $this->info_box_contents[$line][0] = array(
399 'td' =>
'class="left" width="16"',
400 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
401 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
405 $this->info_box_contents[$line][1] = array(
407 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
410 $this->info_box_contents[$line][2] = array(
411 'td' =>
'class="right"',
412 'text' => $data[$j]->nb,
413 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
414 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
416 $totalnb += $data[$j]->nb;
417 $this->info_box_contents[$line][3] = array(
418 'td' =>
'class="nowraponall right amount"',
419 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
421 $this->info_box_contents[$line][4] = array(
422 'td' =>
'class="right" width="18"',
423 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
428 if (count($data) == 0) {
429 $this->info_box_contents[$line][0] = array(
430 'td' =>
'class="center"',
431 'text'=>$langs->trans(
"NoRecordedUnpaidInvoices"),
439 $this->info_box_contents[$line][0] = array(
'tr' =>
'class="liste_total_wrap"');
440 $this->info_box_contents[$line][1] = array(
'td' =>
'class="liste_total left" ',
'text' => $langs->trans(
"Total").
" ".$textHead);
441 $this->info_box_contents[$line][2] = array(
'td' =>
'class="liste_total right" ',
'text' => $totalnb);
442 $this->info_box_contents[$line][3] = array(
'td' =>
'class="liste_total right" ',
'text' =>
'');
443 $this->info_box_contents[$line][4] = array(
'td' =>
'class="liste_total right" ',
'text' =>
"");
445 $conf->global->MAIN_ACTIVATE_FILECACHE = $savMAIN_ACTIVATE_FILECACHE;