|
@@ -1,9 +1,9 @@
|
|
|
<?php
|
|
|
-/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
|
|
+/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
|
|
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
|
|
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
|
|
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
|
|
- * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
|
|
+ * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
|
|
*
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
@@ -40,7 +40,7 @@ $langs->load("accountancy");
|
|
|
|
|
|
// Security check
|
|
|
if (empty($conf->accounting->enabled)) {
|
|
|
- accessforbidden();
|
|
|
+ accessforbidden();
|
|
|
}
|
|
|
if ($user->societe_id > 0)
|
|
|
accessforbidden();
|
|
@@ -187,7 +187,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
|
} else {
|
|
|
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
|
|
}
|
|
|
-$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
|
|
+$sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
|
|
|
|
|
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
|
|
$result = $db->query($sql);
|
|
@@ -203,10 +203,6 @@ $buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' .
|
|
|
$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-$var = true;
|
|
|
-
|
|
|
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
@@ -269,14 +265,14 @@ print '<table class="noborder" width="100%">';
|
|
|
print '<tr class="liste_titre"><td width="200">' . $langs->trans("Account") . '</td>';
|
|
|
print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
|
|
|
for($i = 1; $i <= 12; $i ++) {
|
|
|
- print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
|
|
+ print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
|
|
}
|
|
|
print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
|
|
|
|
|
$sql = "SELECT " . $db->ifsql('aa.account_number IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.account_number') . " AS codecomptable,";
|
|
|
$sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", 'aa.label') . " AS intitule,";
|
|
|
for($i = 1; $i <= 12; $i ++) {
|
|
|
- $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
+ $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
}
|
|
|
$sql .= " SUM(fd.total_ht) as total";
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
|
@@ -296,22 +292,22 @@ $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
|
|
|
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG);
|
|
|
$resql = $db->query($sql);
|
|
|
if ($resql) {
|
|
|
- $num = $db->num_rows($resql);
|
|
|
-
|
|
|
- while ( $row = $db->fetch_row($resql)) {
|
|
|
-
|
|
|
- print '<tr class="oddeven"><td>' . length_accountg($row[0]) . '</td>';
|
|
|
- print '<td align="left">' . $row[1] . '</td>';
|
|
|
- for($i = 2; $i <= 12; $i ++) {
|
|
|
- print '<td align="right">' . price($row[$i]) . '</td>';
|
|
|
- }
|
|
|
- print '<td align="right">' . price($row[13]) . '</td>';
|
|
|
- print '<td align="right"><b>' . price($row[14]) . '</b></td>';
|
|
|
- print '</tr>';
|
|
|
- }
|
|
|
- $db->free($resql);
|
|
|
+ $num = $db->num_rows($resql);
|
|
|
+
|
|
|
+ while ( $row = $db->fetch_row($resql)) {
|
|
|
+
|
|
|
+ print '<tr class="oddeven"><td>' . length_accountg($row[0]) . '</td>';
|
|
|
+ print '<td align="left">' . $row[1] . '</td>';
|
|
|
+ for($i = 2; $i <= 12; $i ++) {
|
|
|
+ print '<td align="right">' . price($row[$i]) . '</td>';
|
|
|
+ }
|
|
|
+ print '<td align="right">' . price($row[13]) . '</td>';
|
|
|
+ print '<td align="right"><b>' . price($row[14]) . '</b></td>';
|
|
|
+ print '</tr>';
|
|
|
+ }
|
|
|
+ $db->free($resql);
|
|
|
} else {
|
|
|
- print $db->lasterror(); // Show last sql error
|
|
|
+ print $db->lasterror(); // Show last sql error
|
|
|
}
|
|
|
print "</table>\n";
|
|
|
|
|
@@ -319,101 +315,101 @@ print "</table>\n";
|
|
|
|
|
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
|
|
|
{
|
|
|
- print '<br>';
|
|
|
- print '<br>';
|
|
|
-
|
|
|
- print_fiche_titre($langs->trans("OtherInfo"), '', '');
|
|
|
-
|
|
|
- print "<br>\n";
|
|
|
- print '<table class="noborder" width="100%">';
|
|
|
- print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
|
|
|
- for($i = 1; $i <= 12; $i ++) {
|
|
|
- print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
|
|
- }
|
|
|
- print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
|
|
-
|
|
|
- $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
|
|
|
- for($i = 1; $i <= 12; $i ++) {
|
|
|
- $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
- }
|
|
|
- $sql .= " SUM(fd.total_ht) as total";
|
|
|
- $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
|
|
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
|
|
- $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
|
|
- $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
|
|
- $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
|
|
- if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
|
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
|
|
- } else {
|
|
|
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
|
|
- }
|
|
|
-
|
|
|
- dol_syslog('htdocs/accountancy/customer/index.php');
|
|
|
- $resql = $db->query($sql);
|
|
|
- if ($resql) {
|
|
|
- $i = 0;
|
|
|
- $num = $db->num_rows($resql);
|
|
|
-
|
|
|
- while ($row = $db->fetch_row($resql)) {
|
|
|
- print '<tr><td>' . $row[0] . '</td>';
|
|
|
- for($i = 1; $i <= 12; $i ++) {
|
|
|
- print '<td align="right">' . price($row[$i]) . '</td>';
|
|
|
- }
|
|
|
- print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
|
|
- print '</tr>';
|
|
|
- $i ++;
|
|
|
- }
|
|
|
- $db->free($resql);
|
|
|
- } else {
|
|
|
- print $db->lasterror(); // Show last sql error
|
|
|
- }
|
|
|
- print "</table>\n";
|
|
|
-
|
|
|
- if (! empty($conf->margin->enabled)) {
|
|
|
- print "<br>\n";
|
|
|
- print '<table class="noborder" width="100%">';
|
|
|
- print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
|
|
|
- for($i = 1; $i <= 12; $i ++) {
|
|
|
- print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
|
|
- }
|
|
|
- print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
|
|
-
|
|
|
- $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
|
|
|
- for($i = 1; $i <= 12; $i ++) {
|
|
|
- $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
- }
|
|
|
- $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
|
|
|
- $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
|
|
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
|
|
- $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
|
|
- $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
|
|
- $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
|
|
- if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
|
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
|
|
- } else {
|
|
|
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
|
|
- }
|
|
|
-
|
|
|
- dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
|
|
|
- $resql = $db->query($sql);
|
|
|
- if ($resql) {
|
|
|
- $num = $db->num_rows($resql);
|
|
|
-
|
|
|
- while ($row = $db->fetch_row($resql)) {
|
|
|
-
|
|
|
- print '<tr><td>' . $row[0] . '</td>';
|
|
|
- for($i = 1; $i <= 12; $i ++) {
|
|
|
- print '<td align="right">' . price(price2num($row[$i])) . '</td>';
|
|
|
- }
|
|
|
- print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>';
|
|
|
- print '</tr>';
|
|
|
- }
|
|
|
- $db->free($resql);
|
|
|
- } else {
|
|
|
- print $db->lasterror(); // Show last sql error
|
|
|
- }
|
|
|
- print "</table>\n";
|
|
|
- }
|
|
|
+ print '<br>';
|
|
|
+ print '<br>';
|
|
|
+
|
|
|
+ print_fiche_titre($langs->trans("OtherInfo"), '', '');
|
|
|
+
|
|
|
+ print "<br>\n";
|
|
|
+ print '<table class="noborder" width="100%">';
|
|
|
+ print '<tr class="liste_titre"><td width="400" align="left">' . $langs->trans("TotalVente") . '</td>';
|
|
|
+ for($i = 1; $i <= 12; $i ++) {
|
|
|
+ print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
|
|
+ }
|
|
|
+ print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
|
|
+
|
|
|
+ $sql = "SELECT '" . $langs->trans("TotalVente") . "' AS total,";
|
|
|
+ for($i = 1; $i <= 12; $i ++) {
|
|
|
+ $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
+ }
|
|
|
+ $sql .= " SUM(fd.total_ht) as total";
|
|
|
+ $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
|
|
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
|
|
+ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
|
|
+ $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
|
|
+ $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
|
|
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
|
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
|
|
+ } else {
|
|
|
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ dol_syslog('htdocs/accountancy/customer/index.php');
|
|
|
+ $resql = $db->query($sql);
|
|
|
+ if ($resql) {
|
|
|
+ $i = 0;
|
|
|
+ $num = $db->num_rows($resql);
|
|
|
+
|
|
|
+ while ($row = $db->fetch_row($resql)) {
|
|
|
+ print '<tr><td>' . $row[0] . '</td>';
|
|
|
+ for($i = 1; $i <= 12; $i ++) {
|
|
|
+ print '<td align="right">' . price($row[$i]) . '</td>';
|
|
|
+ }
|
|
|
+ print '<td align="right"><b>' . price($row[13]) . '</b></td>';
|
|
|
+ print '</tr>';
|
|
|
+ $i ++;
|
|
|
+ }
|
|
|
+ $db->free($resql);
|
|
|
+ } else {
|
|
|
+ print $db->lasterror(); // Show last sql error
|
|
|
+ }
|
|
|
+ print "</table>\n";
|
|
|
+
|
|
|
+ if (! empty($conf->margin->enabled)) {
|
|
|
+ print "<br>\n";
|
|
|
+ print '<table class="noborder" width="100%">';
|
|
|
+ print '<tr class="liste_titre"><td width="400">' . $langs->trans("TotalMarge") . '</td>';
|
|
|
+ for($i = 1; $i <= 12; $i ++) {
|
|
|
+ print '<td width="60" align="right">' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '</td>';
|
|
|
+ }
|
|
|
+ print '<td width="60" align="right"><b>' . $langs->trans("Total") . '</b></td></tr>';
|
|
|
+
|
|
|
+ $sql = "SELECT '" . $langs->trans("Vide") . "' AS marge,";
|
|
|
+ for($i = 1; $i <= 12; $i ++) {
|
|
|
+ $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
+ }
|
|
|
+ $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
|
|
|
+ $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
|
|
|
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
|
|
|
+ $sql .= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
|
|
+ $sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
|
|
|
+ $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
|
|
|
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
|
|
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
|
|
+ } else {
|
|
|
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ dol_syslog('htdocs/accountancy/customer/index.php:: $sql=' . $sql);
|
|
|
+ $resql = $db->query($sql);
|
|
|
+ if ($resql) {
|
|
|
+ $num = $db->num_rows($resql);
|
|
|
+
|
|
|
+ while ($row = $db->fetch_row($resql)) {
|
|
|
+
|
|
|
+ print '<tr><td>' . $row[0] . '</td>';
|
|
|
+ for($i = 1; $i <= 12; $i ++) {
|
|
|
+ print '<td align="right">' . price(price2num($row[$i])) . '</td>';
|
|
|
+ }
|
|
|
+ print '<td align="right"><b>' . price(price2num($row[13])) . '</b></td>';
|
|
|
+ print '</tr>';
|
|
|
+ }
|
|
|
+ $db->free($resql);
|
|
|
+ } else {
|
|
|
+ print $db->lasterror(); // Show last sql error
|
|
|
+ }
|
|
|
+ print "</table>\n";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|