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';
90 $savMAIN_ACTIVATE_FILECACHE =
getDolGlobalInt(
'MAIN_ACTIVATE_FILECACHE');
91 $conf->global->MAIN_ACTIVATE_FILECACHE = 1;
93 if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) {
94 $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
97 $textHead = $langs->trans(
"Activity").
' - '.$langs->trans(
"LastXMonthRolling", $nbofperiod);
98 $this->info_box_head = array(
108 if (isModEnabled(
"propal") && $user->hasRight(
"propal",
"lire")) {
109 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
110 $propalstatic =
new Propal($this->db);
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);
144 $this->db->free($result);
151 while ($j < count($data)) {
152 $this->info_box_contents[$line][0] = array(
153 'td' =>
'class="left" width="16"',
154 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
155 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
156 'logo' =>
'object_propal'
159 $this->info_box_contents[$line][1] = array(
161 'text' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
164 $this->info_box_contents[$line][2] = array(
165 'td' =>
'class="right"',
166 'text' => $data[$j]->nb,
167 'tooltip' => $langs->trans(
"Proposals").
" ".$propalstatic->LibStatut($data[$j]->fk_statut, 0),
168 'url' => DOL_URL_ROOT.
"/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((
int) $data[$j]->fk_statut),
170 $totalnb += $data[$j]->nb;
172 $this->info_box_contents[$line][3] = array(
173 'td' =>
'class="nowraponall right amount"',
174 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
176 $this->info_box_contents[$line][4] = array(
177 'td' =>
'class="right" width="18"',
178 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3),
184 if (count($data) == 0) {
185 $this->info_box_contents[$line][0] = array(
186 'td' =>
'class="center"',
187 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedProposals").
'</span>',
195 if (isModEnabled(
'commande') && $user->hasRight(
"commande",
"lire")) {
196 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
197 $commandestatic =
new Commande($this->db);
199 $langs->load(
"orders");
203 $sql =
"SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
204 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"commande as c";
205 if (empty($user->rights->societe->client->voir) && !$user->socid) {
206 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
209 $sql .=
" WHERE c.entity IN (".getEntity(
'commande').
")";
210 $sql .=
" AND c.fk_soc = s.rowid";
211 if (empty($user->rights->societe->client->voir) && !$user->socid) {
212 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
215 $sql .=
" AND s.rowid = ".((int) $user->socid);
217 $sql .=
" AND c.date_commande >= '".$this->db->idate($tmpdate).
"'";
218 $sql .=
" GROUP BY c.fk_statut";
219 $sql .=
" ORDER BY c.fk_statut DESC";
221 $result = $this->db->query($sql);
223 $num = $this->db->num_rows($result);
226 $data[$j] = $this->db->fetch_object($result);
230 $this->db->free($result);
237 while ($j < count($data)) {
238 $this->info_box_contents[$line][0] = array(
239 'td' =>
'class="left" width="16"',
240 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
241 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
242 'logo' =>
'object_order',
245 $this->info_box_contents[$line][1] = array(
247 'text' =>$langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
250 $this->info_box_contents[$line][2] = array(
251 'td' =>
'class="right"',
252 'text' => $data[$j]->nb,
253 'tooltip' => $langs->trans(
"Orders").
" ".$commandestatic->LibStatut($data[$j]->fk_statut, 0, 0),
254 'url' => DOL_URL_ROOT.
"/commande/list.php?mainmenu=commercial&leftmenu=orders&search_status=".$data[$j]->fk_statut,
256 $totalnb += $data[$j]->nb;
258 $this->info_box_contents[$line][3] = array(
259 'td' =>
'class="nowraponall right amount"',
260 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
262 $this->info_box_contents[$line][4] = array(
263 'td' =>
'class="right" width="18"',
264 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3),
270 if (count($data) == 0) {
271 $this->info_box_contents[$line][0] = array(
272 'td' =>
'class="center"',
273 'text'=>$langs->trans(
"NoRecordedOrders"),
282 if (isModEnabled(
'facture') && $user->hasRight(
"facture",
"lire")) {
283 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
284 $facturestatic =
new Facture($this->db);
288 $sql =
"SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
289 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f";
290 if (empty($user->rights->societe->client->voir) && !$user->socid) {
291 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
294 $sql .=
" WHERE f.entity IN (".getEntity(
'invoice').
')';
295 if (empty($user->rights->societe->client->voir) && !$user->socid) {
296 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
299 $sql .=
" AND s.rowid = ".((int) $user->socid);
301 $sql .=
" AND f.fk_soc = s.rowid";
302 $sql .=
" AND f.datef >= '".$this->db->idate($tmpdate).
"' AND f.paye=1";
303 $sql .=
" GROUP BY f.fk_statut";
304 $sql .=
" ORDER BY f.fk_statut DESC";
306 $result = $this->db->query($sql);
308 $num = $this->db->num_rows($result);
311 $data[$j] = $this->db->fetch_object($result);
315 $this->db->free($result);
322 while ($j < count($data)) {
323 $billurl =
"search_status=2&paye=1";
324 $this->info_box_contents[$line][0] = array(
325 'td' =>
'class="left" width="16"',
326 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
327 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
331 $this->info_box_contents[$line][1] = array(
333 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
336 $this->info_box_contents[$line][2] = array(
337 'td' =>
'class="right"',
338 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0),
339 'text' => $data[$j]->nb,
340 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
343 $this->info_box_contents[$line][3] = array(
344 'td' =>
'class="nowraponall right amount"',
345 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency)
349 $totalnb += $data[$j]->nb;
351 $this->info_box_contents[$line][4] = array(
352 'td' =>
'class="right" width="18"',
353 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3),
358 if (count($data) == 0) {
359 $this->info_box_contents[$line][0] = array(
360 'td' =>
'class="center"',
361 'text'=>$langs->trans(
"NoRecordedInvoices"),
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);
386 $this->db->free($result);
395 while ($j < count($data)) {
396 $billurl =
"search_status=".$data[$j]->fk_statut.
"&paye=0";
397 $this->info_box_contents[$line][0] = array(
398 'td' =>
'class="left" width="16"',
399 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
400 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
404 $this->info_box_contents[$line][1] = array(
406 'text' => $langs->trans(
"Bills").
" ".$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
409 $this->info_box_contents[$line][2] = array(
410 'td' =>
'class="right"',
411 'text' => $data[$j]->nb,
412 'tooltip' => $langs->trans(
'Bills').
' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0),
413 'url' => DOL_URL_ROOT.
"/compta/facture/list.php?".$billurl.
"&mainmenu=accountancy&leftmenu=customers_bills",
415 $totalnb += $data[$j]->nb;
416 $this->info_box_contents[$line][3] = array(
417 'td' =>
'class="nowraponall right amount"',
418 'text' =>
price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency),
420 $this->info_box_contents[$line][4] = array(
421 'td' =>
'class="right" width="18"',
422 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3, $alreadypaid),
427 if (count($data) == 0) {
428 $this->info_box_contents[$line][0] = array(
429 'td' =>
'class="center"',
430 'text'=>$langs->trans(
"NoRecordedUnpaidInvoices"),
438 $this->info_box_contents[$line][0] = array(
'tr' =>
'class="liste_total_wrap"');
439 $this->info_box_contents[$line][1] = array(
'td' =>
'class="liste_total left" ',
'text' => $langs->trans(
"Total").
" ".$textHead);
440 $this->info_box_contents[$line][2] = array(
'td' =>
'class="liste_total right" ',
'text' => $totalnb);
441 $this->info_box_contents[$line][3] = array(
'td' =>
'class="liste_total right" ',
'text' =>
'');
442 $this->info_box_contents[$line][4] = array(
'td' =>
'class="liste_total right" ',
'text' =>
"");
444 $conf->global->MAIN_ACTIVATE_FILECACHE = $savMAIN_ACTIVATE_FILECACHE;