Skip to content
Snippets Groups Projects
Commit 4eab7b00 authored by Charles Benke's avatar Charles Benke
Browse files

Update htdocs/core/boxes/box_activity.php

new release with "last 2 year bills" 
parent 4fe1ba33
No related branches found
No related tags found
No related merge requests found
......@@ -73,26 +73,69 @@ class box_activity extends ModeleBoxes
$propalstatic=new Propal($db);
$commandestatic=new Commande($db);
$textHead = $langs->trans("Activity")." ".date("Y");
$textHead = $langs->trans("Activity");
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
// list the summary of the bills
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
{
// compute the year limit to show
$tmpdate= dol_time_plus_duree(time(), -2, "y");
// we select only the payed bill grouped by years
$sql = "SELECT DATE_FORMAT(f.datef,'%Y') as annee, f.paye, f.fk_statut, sum(f.total_ttc) as Mnttot, count(*) as nb";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f)";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND DATE_FORMAT(f.datef,'%Y') >= ".date('Y',$tmpdate)." and paye=1";
$sql.= " GROUP BY f.paye, f.fk_statut ";
$sql.= " ORDER BY f.fk_statut DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill');
$objp = $db->fetch_object($result);
$this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut($objp->paye,$objp->fk_statut,0)." ".$objp->annee);
$billurl="viewstatut=2&paye=1&year=".$objp->annee;
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/liste.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills"
);
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)."&nbsp;".$langs->trans("Currency".$conf->currency)
);
// We add only for the current year
if ($objp->annee == date("Y"))
{
$totalnb += $objp->nb;
$totalMnt += $objp->Mnttot;
}
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3) );
$i++;
}
if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices"));
}
$sql = "SELECT f.paye, f.fk_statut, sum(f.total_ttc) as Mnttot, count(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND (DATE_FORMAT(f.datef,'%Y') = ".date("Y")." or paye=0)";
$sql.= " AND paye=0";
$sql.= " GROUP BY f.paye, f.fk_statut ";
$sql.= " ORDER BY f.fk_statut DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$num = $db->num_rows($result)+$i;
$now=dol_now();
$i = 0;
while ($i < $num)
{
......@@ -103,16 +146,7 @@ class box_activity extends ModeleBoxes
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' => $langs->trans("Bills")."&nbsp;".$facturestatic->LibStatut($objp->paye,$objp->fk_statut,0));
if($objp->fk_statut==0)
{ // draft
$billurl="viewstatut=0&paye=0";
} elseif($objp->fk_statut==1)
{ // unpaid
$billurl="viewstatut=1&paye=0";
} else
{ // paid for current year
$billurl="viewstatut=2&paye=1";
}
$billurl="viewstatut=".$objp->fk_statut."&paye=0";
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => $objp->nb, 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills"
);
......@@ -135,6 +169,7 @@ class box_activity extends ModeleBoxes
// list the summary of the orders
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
{
$sql = "SELECT c.fk_statut,c.facture, sum(c.total_ttc) as Mnttot, count(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
$sql.= " WHERE c.entity = ".$conf->entity;
......@@ -181,7 +216,6 @@ class box_activity extends ModeleBoxes
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.fk_soc = s.rowid";
$sql.= " AND DATE_FORMAT(p.datep,'%Y') = ".date("Y");
$sql.= " AND p.date_cloture IS NULL "; // just unclosed
$sql.= " GROUP BY p.fk_statut";
$sql.= " ORDER BY p.fk_statut DESC";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment