forked from Wavyzz/dolibarr
Debug reporting
This commit is contained in:
@@ -28,12 +28,17 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/chargesociales.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
|
||||
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
if (!$user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
// Security check
|
||||
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire)
|
||||
accessforbidden();
|
||||
|
||||
// Date range
|
||||
$year=$_REQUEST["year"];
|
||||
@@ -50,7 +55,12 @@ $date_end=dol_mktime($_REQUEST["date_endhour"],$_REQUEST["date_endmin"],$_REQUES
|
||||
// Quarter
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:1; // TODO Set current quarter
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
|
||||
if ($q==0)
|
||||
{
|
||||
if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"]); $date_end=dol_get_last_day($year_start,$_REQUEST["month"]); }
|
||||
else { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,12); }
|
||||
}
|
||||
if ($q==1) { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,3); }
|
||||
if ($q==2) { $date_start=dol_get_first_day($year_start,4); $date_end=dol_get_last_day($year_start,6); }
|
||||
if ($q==3) { $date_start=dol_get_first_day($year_start,7); $date_end=dol_get_last_day($year_start,9); }
|
||||
@@ -68,6 +78,10 @@ if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$html=new Form($db);
|
||||
@@ -77,8 +91,9 @@ if ($modecompta=="CREANCES-DETTES")
|
||||
{
|
||||
$nom=$langs->trans("AnnualByCompaniesDueDebtMode");
|
||||
$nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=RECETTES-DEPENSES">','</a>').')';
|
||||
$period=$langs->trans("Year")." ".$year;
|
||||
$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
//$period=$langs->trans("Year")." ".$year;
|
||||
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
$description=$langs->trans("RulesResultDue");
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@@ -86,27 +101,27 @@ if ($modecompta=="CREANCES-DETTES")
|
||||
else {
|
||||
$nom=$langs->trans("AnnualByCompaniesInputOutputMode");
|
||||
$nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=CREANCES-DETTES">','</a>').')';
|
||||
$period=$langs->trans("Year")." ".$year;
|
||||
$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
//$period=$langs->trans("Year")." ".$year;
|
||||
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
$description=$langs->trans("RulesResultInOut");
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
}
|
||||
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
|
||||
|
||||
// Affiche rapport
|
||||
// Show report array
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="10%"> </td><td>'.$langs->trans("Element").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES') print "<td align=\"right\">".$langs->trans("AmountHT")."</td>";
|
||||
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td>";
|
||||
print "</tr>\n";
|
||||
print '<tr><td colspan="4"> </td></tr>';
|
||||
|
||||
/*
|
||||
* Factures clients
|
||||
*/
|
||||
print '<tr><td colspan="4">Facturation clients</td></tr>';
|
||||
print '<tr><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>';
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql = "SELECT s.nom, s.rowid as socid, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc";
|
||||
@@ -114,7 +129,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.fk_statut in (1,2)";
|
||||
if ($year) $sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
} else {
|
||||
/*
|
||||
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
|
||||
@@ -128,7 +143,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql.= " WHERE p.rowid = pf.fk_paiement";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
if ($year) $sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
@@ -173,7 +188,7 @@ if ($modecompta != 'CREANCES-DETTES')
|
||||
$sql.= " AND p.fk_bank = b.rowid";
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity = ".$conf->entity;
|
||||
if ($year) $sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
$sql.= " GROUP BY nom";
|
||||
$sql.= " ORDER BY nom";
|
||||
|
||||
@@ -229,9 +244,7 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND f.fk_statut in (1,2)";
|
||||
if ($year) {
|
||||
$sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
} else {
|
||||
$sql = "SELECT s.nom, s.rowid as socid, date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
|
||||
@@ -241,16 +254,14 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " ON f.fk_soc = s.rowid";
|
||||
$sql .= " WHERE p.rowid = pf.fk_paiementfourn ";
|
||||
if ($year) {
|
||||
$sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
$sql .= " GROUP BY nom, s.rowid";
|
||||
$sql .= " ORDER BY nom, s.rowid";
|
||||
|
||||
print '<tr><td colspan="4">Facturation fournisseurs</td></tr>';
|
||||
print '<tr><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>';
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
$result = $db->query($sql);
|
||||
@@ -307,9 +318,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as s";
|
||||
$sql.= " WHERE s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 0";
|
||||
if ($year) {
|
||||
$sql.= " AND s.date_ech between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND s.date_ech >= '".$db->idate($date_start)."' AND s.date_ech <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT c.libelle as nom, sum(p.amount) as amount";
|
||||
@@ -319,9 +328,7 @@ else {
|
||||
$sql.= " WHERE p.fk_charge = s.rowid";
|
||||
$sql.= " AND s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 0";
|
||||
if ($year) {
|
||||
$sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY c.libelle";
|
||||
@@ -378,9 +385,7 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as s";
|
||||
$sql.= " WHERE s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 1";
|
||||
if ($year) {
|
||||
$sql.= " AND s.date_ech between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND s.date_ech >= '".$db->idate($date_start)."' AND s.date_ech <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY c.libelle DESC";
|
||||
}
|
||||
@@ -392,9 +397,7 @@ else {
|
||||
$sql .= " WHERE p.fk_charge = s.rowid";
|
||||
$sql.= " AND s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 1";
|
||||
if ($year) {
|
||||
$sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY c.libelle";
|
||||
}
|
||||
@@ -470,9 +473,7 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " WHERE f.fk_statut in (1,2)";
|
||||
if ($year) {
|
||||
$sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= " ORDER BY dm DESC";
|
||||
@@ -508,9 +509,7 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql = "SELECT sum(f.total_tva) as amount, date_format(f.datef,'%Y-%m') as dm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
$sql.= " WHERE f.fk_statut in (1,2)";
|
||||
if ($year) {
|
||||
$sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= " ORDER BY dm DESC";
|
||||
@@ -549,9 +548,7 @@ else
|
||||
$sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
|
||||
$sql.= " WHERE amount > 0";
|
||||
if ($year) {
|
||||
$sql.= " AND t.datev between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND t.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= " ORDER BY dm DESC";
|
||||
@@ -589,9 +586,7 @@ else
|
||||
$sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
|
||||
$sql.= " WHERE amount < 0";
|
||||
if ($year) {
|
||||
$sql.= " AND t.datev between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
if ($date_start && $date_end) $sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
|
||||
$sql.= " AND t.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= " ORDER BY dm DESC";
|
||||
@@ -637,7 +632,7 @@ if ($mysoc->tva_assuj != 'franchise') // Assujeti
|
||||
|
||||
if ($mysoc->tva_assuj != 'franchise') // Assujeti
|
||||
{
|
||||
// Total
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@@ -39,19 +39,22 @@ else {
|
||||
$year_end=$year_start + ($nbofyear-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Securite acces client
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
// Security check
|
||||
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire)
|
||||
accessforbidden();
|
||||
|
||||
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||
$modecompta = $conf->compta->mode;
|
||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$html=new Form($db);
|
||||
@@ -151,13 +154,6 @@ if ($modecompta != 'CREANCES-DETTES') {
|
||||
$encaiss[$row->dm] += $row->amount_ht;
|
||||
$encaiss_ttc[$row->dm] += $row->amount_ttc;
|
||||
|
||||
// For DEBUG Only
|
||||
if (preg_match('/^2007/',$row->dm))
|
||||
{
|
||||
$subtotal_ht = $subtotal_ht + $row->amount_ht;
|
||||
$subtotal_ttc = $subtotal_ttc + $row->amount_ttc;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -165,16 +161,7 @@ if ($modecompta != 'CREANCES-DETTES') {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
/*
|
||||
print "<br>Facture clients: subtotal_ht=".$subtotal_ht.' - subtotal_ttc='.$subtotal_ttc."<br>\n";
|
||||
for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
{
|
||||
$annee = 2007;
|
||||
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois,1,$annee));
|
||||
print 'Mois '.$mois.': '.$decaiss_ttc[$case].' ';
|
||||
print 'Mois '.$mois.': '.$encaiss_ttc[$case].' ';
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Frais, factures fournisseurs.
|
||||
@@ -210,13 +197,6 @@ if ($result)
|
||||
$decaiss[$row->dm] = $row->amount_ht;
|
||||
$decaiss_ttc[$row->dm] = $row->amount_ttc;
|
||||
|
||||
// For DEBUG Only
|
||||
if (preg_match('/^2007/',$row->dm))
|
||||
{
|
||||
$subtotal_ht = $subtotal_ht + $row->amount_ht;
|
||||
$subtotal_ttc = $subtotal_ttc + $row->amount_ttc;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
@@ -224,16 +204,7 @@ if ($result)
|
||||
else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
/*
|
||||
print "<br>Facture fournisseurs: subtotal_ht=".$subtotal_ht.' - subtotal_ttc='.$subtotal_ttc."<br>\n";
|
||||
for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
{
|
||||
$annee = 2007;
|
||||
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois,1,$annee));
|
||||
print 'Mois '.$mois.': '.$decaiss_ttc[$case].' ';
|
||||
print 'Mois '.$mois.': '.$encaiss_ttc[$case].' ';
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* TVA
|
||||
@@ -311,12 +282,6 @@ else {
|
||||
|
||||
$decaiss[$obj->dm] += $obj->amount;
|
||||
$decaiss_ttc[$obj->dm] += $obj->amount;
|
||||
// For DEBUG Only
|
||||
if (preg_match('/^2007/',$obj->dm))
|
||||
{
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
@@ -342,12 +307,6 @@ else {
|
||||
|
||||
$encaiss[$obj->dm] += $obj->amount;
|
||||
$encaiss_ttc[$obj->dm] += $obj->amount;
|
||||
// For DEBUG Only
|
||||
if (preg_match('/^2007/',$obj->dm))
|
||||
{
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
@@ -356,16 +315,6 @@ else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
/*
|
||||
print "<br>TVA: subtotal_ht=".$subtotal_ht.' - subtotal_ttc='.$subtotal_ttc."<br>\n";
|
||||
for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
{
|
||||
$annee = 2007;
|
||||
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois,1,$annee));
|
||||
print 'Mois '.$mois.': '.$decaiss_ttc[$case].' ';
|
||||
print 'Mois '.$mois.': '.$encaiss_ttc[$case].' ';
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Charges sociales non deductibles
|
||||
@@ -378,9 +327,6 @@ if ($modecompta == 'CREANCES-DETTES') {
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as s";
|
||||
$sql.= " WHERE s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 0";
|
||||
if ($year) {
|
||||
$sql.= " AND s.date_ech between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount_ht, sum(p.amount) as amount_ttc";
|
||||
@@ -390,9 +336,6 @@ else {
|
||||
$sql.= " WHERE p.fk_charge = s.rowid";
|
||||
$sql.= " AND s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 0";
|
||||
if ($year) {
|
||||
$sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
}
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY c.libelle, dm";
|
||||
@@ -410,33 +353,17 @@ if ($result) {
|
||||
$decaiss[$obj->dm] += $obj->amount_ht;
|
||||
$decaiss_ttc[$obj->dm] += $obj->amount_ttc;
|
||||
|
||||
// For DEBUG Only
|
||||
if (preg_match('/^2007/',$obj->dm))
|
||||
{
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount_ht;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount_ttc;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
/*
|
||||
print "<br>Charges sociales non deduc: subtotal_ht=".$subtotal_ht.' - subtotal_ttc='.$subtotal_ttc."<br>\n";
|
||||
for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
{
|
||||
$annee = 2007;
|
||||
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois,1,$annee));
|
||||
print 'Mois '.$mois.': '.$decaiss_ttc[$case].' ';
|
||||
print 'Mois '.$mois.': '.$encaiss_ttc[$case].' ';
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Charges sociales deductibles
|
||||
*/
|
||||
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
@@ -446,9 +373,6 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as s";
|
||||
$sql.= " WHERE s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 1";
|
||||
if ($year) {
|
||||
$sql.= " AND s.date_ech between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -459,9 +383,6 @@ else
|
||||
$sql.= " WHERE p.fk_charge = s.rowid";
|
||||
$sql.= " AND s.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 1";
|
||||
if ($year) {
|
||||
$sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
}
|
||||
}
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY c.libelle, dm";
|
||||
@@ -478,34 +399,19 @@ if ($result) {
|
||||
$decaiss[$obj->dm] += $obj->amount_ht;
|
||||
$decaiss_ttc[$obj->dm] += $obj->amount_ttc;
|
||||
|
||||
// For DEBUG Only
|
||||
if (preg_match('/^2007/',$obj->dm))
|
||||
{
|
||||
$subtotal_ht = $subtotal_ht + $obj->amount_ht;
|
||||
$subtotal_ttc = $subtotal_ttc + $obj->amount_ttc;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
/*
|
||||
print "<br>Charges sociales deduc: subtotal_ht=".$subtotal_ht.' - subtotal_ttc='.$subtotal_ttc."<br>\n";
|
||||
for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
{
|
||||
$annee = 2007;
|
||||
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois,1,$annee));
|
||||
print 'Mois '.$mois.': '.$decaiss_ttc[$case].' ';
|
||||
print 'Mois '.$mois.': '.$encaiss_ttc[$case].' ';
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Affiche tableau
|
||||
* Show result array
|
||||
*/
|
||||
|
||||
$totentrees=array();
|
||||
$totsorties=array();
|
||||
|
||||
@@ -526,11 +432,12 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
print '</tr>';
|
||||
|
||||
$var=True;
|
||||
// Loop on each month
|
||||
for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print "<td>".dol_print_date(dol_mktime(12,0,0,$mois,1,$annee),"%b")."</td>";
|
||||
print "<td>".dol_print_date(dol_mktime(12,0,0,$mois,1,$annee),"%B")."</td>";
|
||||
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
{
|
||||
$case = strftime("%Y-%m",dol_mktime(12,0,0,$mois,1,$annee));
|
||||
@@ -538,7 +445,7 @@ for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
print '<td align="right"> ';
|
||||
if ($decaiss_ttc[$case] != 0)
|
||||
{
|
||||
print price($decaiss_ttc[$case]);
|
||||
print '<a href="clientfourn.php?year='.$annee.'&month='.$mois.'">'.price($decaiss_ttc[$case]).'</a>';
|
||||
$totsorties[$annee]+=$decaiss_ttc[$case];
|
||||
}
|
||||
print "</td>";
|
||||
@@ -546,7 +453,7 @@ for ($mois = 1 ; $mois <= 12 ; $mois++)
|
||||
print '<td align="right"> ';
|
||||
if ($encaiss_ttc[$case] != 0)
|
||||
{
|
||||
print price($encaiss_ttc[$case]);
|
||||
print '<a href="clientfourn.php?year='.$annee.'&month='.$mois.'">'.price($encaiss_ttc[$case]).'</a>';
|
||||
$totentrees[$annee]+=$encaiss_ttc[$case];
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -19,19 +19,22 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/stats/cabyuser.php
|
||||
\brief Page reporting CA par utilisateur
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/compta/stats/cabyuser.php
|
||||
* \brief Page reporting Salesover by user
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
|
||||
|
||||
if (!$user->rights->compta->resultat->lire)
|
||||
accessforbidden();
|
||||
// Security check
|
||||
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire)
|
||||
accessforbidden();
|
||||
|
||||
$year=$_GET["year"];
|
||||
if (! $year) { $year = strftime("%Y", time()); }
|
||||
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||
$modecompta = $conf->compta->mode;
|
||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||
@@ -41,8 +44,37 @@ $sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
|
||||
if (! $sortorder) $sortorder="asc";
|
||||
if (! $sortfield) $sortfield="name";
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
// Date range
|
||||
$year=$_REQUEST["year"];
|
||||
if (empty($year))
|
||||
{
|
||||
$year_current = strftime("%Y",dol_now());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
$date_start=dol_mktime($_REQUEST["date_starthour"],$_REQUEST["date_startmin"],$_REQUEST["date_startsec"],$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
|
||||
$date_end=dol_mktime($_REQUEST["date_endhour"],$_REQUEST["date_endmin"],$_REQUEST["date_endsec"],$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
|
||||
// Quarter
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
|
||||
if ($q==0)
|
||||
{
|
||||
if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"]); $date_end=dol_get_last_day($year_start,$_REQUEST["month"]); }
|
||||
else { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,12); }
|
||||
}
|
||||
if ($q==1) { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,3); }
|
||||
if ($q==2) { $date_start=dol_get_first_day($year_start,4); $date_end=dol_get_last_day($year_start,6); }
|
||||
if ($q==3) { $date_start=dol_get_first_day($year_start,7); $date_end=dol_get_last_day($year_start,9); }
|
||||
if ($q==4) { $date_start=dol_get_first_day($year_start,10); $date_end=dol_get_last_day($year_start,12); }
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO We define q
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -59,8 +91,9 @@ if ($modecompta=="CREANCES-DETTES")
|
||||
{
|
||||
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
|
||||
$nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=RECETTES-DEPENSES">','</a>').')';
|
||||
$period=$langs->trans("Year")." $year";
|
||||
$periodlink="<a href='".$_SERVER["PHP_SELF"]."?year=".($year-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year+1)."&modecompta=".$modecompta."'>".img_next()."</a>";
|
||||
//$period=$langs->trans("Year")." $year";
|
||||
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink="<a href='".$_SERVER["PHP_SELF"]."?year=".($year-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year+1)."&modecompta=".$modecompta."'>".img_next()."</a>";
|
||||
$description=$langs->trans("RulesCADue");
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@@ -68,8 +101,9 @@ if ($modecompta=="CREANCES-DETTES")
|
||||
else {
|
||||
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice");
|
||||
$nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=CREANCES-DETTES">','</a>').')';
|
||||
$period=$langs->trans("Year")." $year";
|
||||
$periodlink="<a href='".$_SERVER["PHP_SELF"]."?year=".($year-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year+1)."&modecompta=".$modecompta."'>".img_next()."</a>";
|
||||
//$period=$langs->trans("Year")." $year";
|
||||
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink="<a href='".$_SERVER["PHP_SELF"]."?year=".($year-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year+1)."&modecompta=".$modecompta."'>".img_next()."</a>";
|
||||
$description=$langs->trans("RulesCAIn");
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@@ -85,7 +119,7 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.fk_user_author = u.rowid";
|
||||
$sql.= " WHERE f.fk_statut in (1,2) ";
|
||||
if ($year) $sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -99,11 +133,11 @@ else
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_facture = f.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.rowid = pf.fk_paiement";
|
||||
$sql.= " WHERE 1=1";
|
||||
if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
$sql .= " GROUP BY rowid";
|
||||
$sql .= " GROUP BY rowid, name, firstname";
|
||||
$sql .= " ORDER BY rowid";
|
||||
|
||||
$result = $db->query($sql);
|
||||
@@ -136,7 +170,7 @@ if ($modecompta != 'CREANCES-DETTES')
|
||||
$sql.= " AND p.fk_bank = b.rowid";
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity = ".$conf->entity;
|
||||
if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
$sql.= " GROUP BY rowid";
|
||||
$sql.= " ORDER BY rowid";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||
*
|
||||
@@ -27,11 +27,11 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
|
||||
|
||||
$langs->load("companies");
|
||||
|
||||
$year=$_GET["year"];
|
||||
if (! $year) { $year = strftime("%Y", time()); }
|
||||
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||
$modecompta = $conf->compta->mode;
|
||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||
@@ -41,9 +41,49 @@ $sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
|
||||
if (! $sortorder) $sortorder="asc";
|
||||
if (! $sortfield) $sortfield="nom";
|
||||
|
||||
// Securite acces client
|
||||
// Security check
|
||||
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire)
|
||||
accessforbidden();
|
||||
|
||||
// Date range
|
||||
$year=$_REQUEST["year"];
|
||||
if (empty($year))
|
||||
{
|
||||
$year_current = strftime("%Y",dol_now());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
$date_start=dol_mktime($_REQUEST["date_starthour"],$_REQUEST["date_startmin"],$_REQUEST["date_startsec"],$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
|
||||
$date_end=dol_mktime($_REQUEST["date_endhour"],$_REQUEST["date_endmin"],$_REQUEST["date_endsec"],$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
|
||||
// Quarter
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
|
||||
if ($q==0)
|
||||
{
|
||||
if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"]); $date_end=dol_get_last_day($year_start,$_REQUEST["month"]); }
|
||||
else { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,12); }
|
||||
}
|
||||
if ($q==1) { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,3); }
|
||||
if ($q==2) { $date_start=dol_get_first_day($year_start,4); $date_end=dol_get_last_day($year_start,6); }
|
||||
if ($q==3) { $date_start=dol_get_first_day($year_start,7); $date_end=dol_get_last_day($year_start,9); }
|
||||
if ($q==4) { $date_start=dol_get_first_day($year_start,10); $date_end=dol_get_last_day($year_start,12); }
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO We define q
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
@@ -54,8 +94,9 @@ if ($modecompta=="CREANCES-DETTES")
|
||||
{
|
||||
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties");
|
||||
$nom.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=RECETTES-DEPENSES">','</a>').')';
|
||||
$period=$langs->trans("Year")." ".$year;
|
||||
$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
//$period=$langs->trans("Year")." ".$year;
|
||||
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
$description=$langs->trans("RulesCADue");
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@@ -63,8 +104,9 @@ if ($modecompta=="CREANCES-DETTES")
|
||||
else {
|
||||
$nom=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties");
|
||||
$nom.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=CREANCES-DETTES">','</a>').')';
|
||||
$period=$langs->trans("Year")." ".$year;
|
||||
$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
//$period=$langs->trans("Year")." ".$year;
|
||||
$period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
|
||||
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
|
||||
$description=$langs->trans("RulesCAIn");
|
||||
$builddate=time();
|
||||
$exportlink=$langs->trans("NotYetAvailable");
|
||||
@@ -81,7 +123,7 @@ if ($modecompta == 'CREANCES-DETTES')
|
||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " WHERE f.fk_statut in (1,2)";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
if ($year) $sql.= " AND f.datef between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,7 +139,7 @@ else
|
||||
$sql .= " WHERE p.rowid = pf.fk_paiement";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
$sql.= " AND f.fk_soc = s.rowid";
|
||||
if ($year) $sql.= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql.= " AND f.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||
@@ -134,7 +176,7 @@ if ($modecompta != 'CREANCES-DETTES')
|
||||
$sql.= " AND p.fk_bank = b.rowid";
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity = ".$conf->entity;
|
||||
if ($year) $sql .= " AND p.datep between '".$year."-01-01 00:00:00' and '".$year."-12-31 23:59:59'";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
$sql.= " GROUP BY nom";
|
||||
$sql.= " ORDER BY nom";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -19,10 +19,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/stats/index.php
|
||||
\brief Page reporting CA
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/compta/stats/index.php
|
||||
* \brief Page reporting CA
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
|
||||
@@ -38,23 +38,25 @@ else {
|
||||
$year_end=$year_start + 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* Securite acces client
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
// Security check
|
||||
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->comptarapport->lire)
|
||||
accessforbidden();
|
||||
|
||||
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
|
||||
$modecompta = $conf->compta->mode;
|
||||
if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
$html=new Form($db);
|
||||
|
||||
// Affiche en-t<EFBFBD>te du rapport
|
||||
// Affiche en-tete du rapport
|
||||
if ($modecompta=="CREANCES-DETTES")
|
||||
{
|
||||
$nom=$langs->trans("SalesTurnover");
|
||||
@@ -119,7 +121,7 @@ else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
// On ajoute les paiements anciennes version, non li<EFBFBD>s par paiement_facture
|
||||
// On ajoute les paiements anciennes version, non lies par paiement_facture
|
||||
if ($modecompta != 'CREANCES-DETTES') {
|
||||
$sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
@@ -187,7 +189,7 @@ for ($mois = 1 ; $mois < 13 ; $mois++)
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print "<td>".dol_print_date(dol_mktime(12,0,0,$mois,1,2000),"%b")."</td>";
|
||||
print "<td>".dol_print_date(dol_mktime(12,0,0,$mois,1,2000),"%B")."</td>";
|
||||
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
|
||||
{
|
||||
$casenow = dol_print_date(mktime(),"%Y-%m");
|
||||
@@ -202,8 +204,8 @@ for ($mois = 1 ; $mois < 13 ; $mois++)
|
||||
print '<td align="right">';
|
||||
if ($cum[$case])
|
||||
{
|
||||
$now_show_delta=1; // On a trouv<EFBFBD> le premier mois de la premi<EFBFBD>re ann<EFBFBD>e g<EFBFBD>n<EFBFBD>rant du chiffre.
|
||||
print price($cum[$case],1);
|
||||
$now_show_delta=1; // On a trouve le premier mois de la premiere annee generant du chiffre.
|
||||
print '<a href="casoc.php?year='.$annee.'&month='.$mois.'">'.price($cum[$case],1).'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -297,23 +299,23 @@ print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* En mode recettes/d<EFBFBD>penses, on compl<EFBFBD>te avec les montants factur<EFBFBD>s non r<EFBFBD>gl<EFBFBD>s
|
||||
* et les propales sign<EFBFBD>es mais pas factur<EFBFBD>es. En effet, en recettes-d<EFBFBD>penses,
|
||||
* on comptabilise lorsque le montant est sur le compte donc il est int<EFBFBD>ressant
|
||||
* En mode recettes/depenses, on complete avec les montants factures non regles
|
||||
* et les propales signees mais pas facturees. En effet, en recettes-depenses,
|
||||
* on comptabilise lorsque le montant est sur le compte donc il est interessant
|
||||
* d'avoir une vision de ce qui va arriver.
|
||||
*/
|
||||
|
||||
/*
|
||||
Je commente toute cette partie car les chiffres affich<EFBFBD>es sont faux - Eldy.
|
||||
En attendant correction.
|
||||
Je commente toute cette partie car les chiffres affichees sont faux - Eldy.
|
||||
En attendant correction.
|
||||
|
||||
if ($modecompta != 'CREANCES-DETTES')
|
||||
{
|
||||
if ($modecompta != 'CREANCES-DETTES')
|
||||
{
|
||||
|
||||
print '<br><table width="100%" class="noborder">';
|
||||
|
||||
// Factures non r<EFBFBD>gl<EFBFBD>es
|
||||
// \todo Y a bug ici. Il faut prendre le reste <EFBFBD> payer et non le total des factures non r<EFBFBD>gl<EFBFBD>es !
|
||||
// Factures non reglees
|
||||
// \todo Y a bug ici. Il faut prendre le reste a payer et non le total des factures non reglees !
|
||||
|
||||
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.rowid as socid, f.total_ttc, sum(pf.amount) as am";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
|
||||
@@ -341,7 +343,7 @@ if ($modecompta != 'CREANCES-DETTES')
|
||||
$i++;
|
||||
}
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]><td align=\"right\" colspan=\"5\"><i>Factur<EFBFBD> <20> encaisser : </i></td><td align=\"right\"><i>".price($total_ttc_Rac)."</i></td><td colspan=\"5\"><-- bug ici car n'exclut pas le deja r<>gl<67> des factures partiellement r<>gl<67>es</td></tr>";
|
||||
print "<tr $bc[$var]><td align=\"right\" colspan=\"5\"><i>Facture a encaisser : </i></td><td align=\"right\"><i>".price($total_ttc_Rac)."</i></td><td colspan=\"5\"><-- bug ici car n'exclut pas le deja r<>gl<67> des factures partiellement r<>gl<67>es</td></tr>";
|
||||
$total_CA +=$total_ttc_Rac;
|
||||
}
|
||||
$db->free();
|
||||
@@ -350,17 +352,17 @@ if ($modecompta != 'CREANCES-DETTES')
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Propales sign<EFBFBD>es, et non factur<EFBFBD>es
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Propales signees, et non facturees
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Je commente toute cette partie car les chiffres affich<EFBFBD>es sont faux - Eldy.
|
||||
En attendant correction.
|
||||
Je commente toute cette partie car les chiffres affichees sont faux - Eldy.
|
||||
En attendant correction.
|
||||
|
||||
$sql = "SELECT sum(f.total) as tot_fht,sum(f.total_ttc) as tot_fttc, p.rowid, p.ref, s.nom, s.rowid as socid, p.total_ht, p.total_ttc
|
||||
FROM ".MAIN_DB_PREFIX."commande AS p, llx_societe AS s
|
||||
@@ -391,7 +393,7 @@ En attendant correction.
|
||||
$i++;
|
||||
}
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]><td align=\"right\" colspan=\"5\"><i>Sign<EFBFBD> et non factur<EFBFBD>:</i></td><td align=\"right\"><i>".price($total_pr)."</i></td><td colspan=\"5\"><-- bug ici, ca devrait exclure le d<EFBFBD>j<EFBFBD> factur<EFBFBD></td></tr>";
|
||||
print "<tr $bc[$var]><td align=\"right\" colspan=\"5\"><i>Signe et non facture:</i></td><td align=\"right\"><i>".price($total_pr)."</i></td><td colspan=\"5\"><-- bug ici, ca devrait exclure le deja facture</td></tr>";
|
||||
$total_CA += $total_pr;
|
||||
}
|
||||
$db->free();
|
||||
@@ -400,11 +402,11 @@ En attendant correction.
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
print "<tr $bc[$var]><td align=\"right\" colspan=\"5\"><i>Total CA pr<EFBFBD>visionnel : </i></td><td align=\"right\"><i>".price($total_CA)."</i></td><td colspan=\"3\"><-- bug ici car bug sur les 2 pr<EFBFBD>c<EFBFBD>dents</td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
print "<tr $bc[$var]><td align=\"right\" colspan=\"5\"><i>Total CA previsionnel : </i></td><td align=\"right\"><i>".price($total_CA)."</i></td><td colspan=\"3\"><-- bug ici car bug sur les 2 precedents</td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@@ -52,7 +52,12 @@ $date_end=dol_mktime($_REQUEST["date_endhour"],$_REQUEST["date_endmin"],$_REQUES
|
||||
// Quarter
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:1; // TODO Set current quarter
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
|
||||
if ($q==0)
|
||||
{
|
||||
if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"]); $date_end=dol_get_last_day($year_start,$_REQUEST["month"]); }
|
||||
else $q=1;
|
||||
}
|
||||
if ($q==1) { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,3); }
|
||||
if ($q==2) { $date_start=dol_get_first_day($year_start,4); $date_end=dol_get_last_day($year_start,6); }
|
||||
if ($q==3) { $date_start=dol_get_first_day($year_start,7); $date_end=dol_get_last_day($year_start,9); }
|
||||
|
||||
@@ -58,7 +58,12 @@ $date_end=dol_mktime($_REQUEST["date_endhour"],$_REQUEST["date_endmin"],$_REQUES
|
||||
// Quarter
|
||||
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
|
||||
{
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:1; // TODO Set current quarter
|
||||
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:0;
|
||||
if ($q==0)
|
||||
{
|
||||
if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"]); $date_end=dol_get_last_day($year_start,$_REQUEST["month"]); }
|
||||
else $q=1;
|
||||
}
|
||||
if ($q==1) { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,3); }
|
||||
if ($q==2) { $date_start=dol_get_first_day($year_start,4); $date_end=dol_get_last_day($year_start,6); }
|
||||
if ($q==3) { $date_start=dol_get_first_day($year_start,7); $date_end=dol_get_last_day($year_start,9); }
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/** \defgroup comptabilite Module comptabilite
|
||||
\brief Module pour inclure des fonctions de comptabilit<EFBFBD> (gestion de comptes comptables et rapports)
|
||||
\brief Module pour inclure des fonctions de comptabilite (gestion de comptes comptables et rapports)
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ Size=Size
|
||||
Received=Received
|
||||
Paid=Paid
|
||||
Topic=Sujet
|
||||
ByCompanies=By companies
|
||||
ByCompanies=By third parties
|
||||
ByUsers=By users
|
||||
Links=Links
|
||||
Link=Link
|
||||
|
||||
@@ -358,7 +358,7 @@ Size=Taille
|
||||
Received=Reçu
|
||||
Paid=Payé
|
||||
Topic=Sujet
|
||||
ByCompanies=Par société
|
||||
ByCompanies=Par tiers
|
||||
ByUsers=Par utilisateur
|
||||
Links=Liens
|
||||
Link=Lien
|
||||
|
||||
@@ -154,7 +154,7 @@ function dol_get_last_day($year,$month=12)
|
||||
}
|
||||
|
||||
// On se deplace au debut du mois suivant, et on retire un jour
|
||||
$datelim=dol_mktime(0,0,0,$month,1,$year,1);
|
||||
$datelim=dol_mktime(23,59,59,$month,1,$year,1);
|
||||
$datelim -= (3600 * 24);
|
||||
|
||||
return $datelim;
|
||||
|
||||
Reference in New Issue
Block a user