|
@@ -21,12 +21,13 @@
|
|
|
/**
|
|
|
* \file htdocs/accountancy/supplier/index.php
|
|
|
* \ingroup Advanced accountancy
|
|
|
- * \brief Home supplier ventilation
|
|
|
+ * \brief Home supplier journalization page
|
|
|
*/
|
|
|
|
|
|
require '../../main.inc.php';
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
|
|
+require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
|
|
|
|
|
// Langs
|
|
|
$langs->load("compta");
|
|
@@ -55,7 +56,7 @@ if ($year == 0) {
|
|
|
}
|
|
|
|
|
|
// Validate History
|
|
|
-$action = GETPOST('action', 'alpha');
|
|
|
+$action = GETPOST('action', 'aZ09');
|
|
|
|
|
|
|
|
|
/*
|
|
@@ -93,6 +94,8 @@ if ($action == 'validatehistory') {
|
|
|
$sql1 .= " AND fd.fk_code_ventilation = 0";
|
|
|
}
|
|
|
|
|
|
+ dol_syslog('htdocs/accountancy/supplier/index.php');
|
|
|
+
|
|
|
$resql1 = $db->query($sql1);
|
|
|
if (! $resql1) {
|
|
|
$error ++;
|
|
@@ -159,33 +162,28 @@ llxHeader('', $langs->trans("SuppliersVentilation"));
|
|
|
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
|
|
|
$textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
|
|
|
|
|
|
-print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
|
|
|
+print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, '', 'title_accountancy');
|
|
|
|
|
|
print $langs->trans("DescVentilSupplier") . '<br>';
|
|
|
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
|
|
|
print '<br>';
|
|
|
|
|
|
//print '<div class="inline-block divButAction">';
|
|
|
-// TODO Remove this. Should be done always.
|
|
|
+// TODO Remove this. Should be done always or into the repair.php script.
|
|
|
if ($conf->global->MAIN_FEATURES_LEVEL > 1) print '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=fixaccountancycode">' . $langs->trans("CleanFixHistory", $year_current) . '</a>';
|
|
|
//print '</div>';
|
|
|
|
|
|
-$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
|
|
|
-$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
|
|
-
|
|
|
-
|
|
|
|
|
|
$y = $year_current;
|
|
|
|
|
|
-$var = true;
|
|
|
-
|
|
|
+$buttonbind = '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=validatehistory">' . $langs->trans("ValidateHistory") . '</a>';
|
|
|
+$buttonreset = '<a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '?year=' . $year_current . '&action=cleanaccountancycode">' . $langs->trans("CleanHistory", $year_current) . '</a>';
|
|
|
|
|
|
-print '<br>';
|
|
|
|
|
|
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
-print '<tr class="liste_titre"><td width="200" align="left">' . $langs->trans("Account") . '</td>';
|
|
|
+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>';
|
|
@@ -197,7 +195,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
|
|
|
for($i = 1; $i <= 12; $i ++) {
|
|
|
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
}
|
|
|
-$sql .= " ROUND(SUM(ffd.total_ht),2) as total";
|
|
|
+$sql .= " SUM(ffd.total_ht) as total";
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
|
|
@@ -208,7 +206,7 @@ $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We d
|
|
|
$sql .= " AND aa.account_number IS NULL";
|
|
|
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
|
|
|
|
|
-dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
|
|
+dol_syslog('htdocs/accountancy/supplier/index.php');
|
|
|
$resql = $db->query($sql);
|
|
|
if ($resql) {
|
|
|
$num = $db->num_rows($resql);
|
|
@@ -239,7 +237,7 @@ print '<br>';
|
|
|
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, '');
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
-print '<tr class="liste_titre"><td width="200" align="left">' . $langs->trans("Account") . '</td>';
|
|
|
+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>';
|
|
@@ -251,7 +249,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
|
|
|
for($i = 1; $i <= 12; $i ++) {
|
|
|
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
}
|
|
|
-$sql .= " ROUND(SUM(ffd.total_ht),2) as total";
|
|
|
+$sql .= " SUM(ffd.total_ht) as total";
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
|
|
@@ -262,7 +260,7 @@ $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We d
|
|
|
$sql .= " AND aa.account_number IS NOT NULL";
|
|
|
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
|
|
|
|
|
-dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
|
|
+dol_syslog('htdocs/accountancy/supplier/index.php');
|
|
|
$resql = $db->query($sql);
|
|
|
if ($resql) {
|
|
|
$num = $db->num_rows($resql);
|
|
@@ -306,7 +304,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
|
|
for($i = 1; $i <= 12; $i ++) {
|
|
|
$sql .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
|
|
|
}
|
|
|
- $sql .= " ROUND(SUM(ffd.total_ht),2) as total";
|
|
|
+ $sql .= " SUM(ffd.total_ht) as total";
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd";
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
|
|
|
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
|
|
@@ -314,7 +312,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
|
|
$sql .= " AND ff.fk_statut > 0 ";
|
|
|
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
|
|
|
|
|
- dol_syslog('/accountancy/supplier/index.php:: sql=' . $sql);
|
|
|
+ dol_syslog('htdocs/accountancy/supplier/index.php');
|
|
|
$resql = $db->query($sql);
|
|
|
if ($resql) {
|
|
|
$num = $db->num_rows($resql);
|