Skip to content
Snippets Groups Projects
Commit b186fa87 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix pgsql compatibility

parent 658fe93d
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* \file htdocs/accountancy/customer/index.php * \file htdocs/accountancy/customer/index.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Home customer ventilation * \brief Home customer journalization page
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
...@@ -58,7 +58,7 @@ if ($year == 0) { ...@@ -58,7 +58,7 @@ if ($year == 0) {
} }
// Validate History // Validate History
$action = GETPOST('action','alpha'); $action = GETPOST('action','aZ09');
...@@ -97,7 +97,7 @@ if ($action == 'validatehistory') { ...@@ -97,7 +97,7 @@ if ($action == 'validatehistory') {
$sql1 .= " AND fd.fk_code_ventilation = 0"; $sql1 .= " AND fd.fk_code_ventilation = 0";
} }
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); dol_syslog('htdocs/accountancy/customer/index.php');
$resql1 = $db->query($sql1); $resql1 = $db->query($sql1);
if (! $resql1) { if (! $resql1) {
...@@ -173,7 +173,7 @@ print $langs->trans("DescVentilCustomer") . '<br>'; ...@@ -173,7 +173,7 @@ print $langs->trans("DescVentilCustomer") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>'; print '<br>';
//print '<div class="inline-block divButAction">'; //print '<div class="inline-block divButAction">';
// TODO Remove this. Should be done into the repair.php script // 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>'; 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>'; //print '</div>';
...@@ -189,7 +189,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { ...@@ -189,7 +189,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} }
$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); dol_syslog('htdocs/accountancy/customer/index.php');
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$row = $db->fetch_row($result); $row = $db->fetch_row($result);
...@@ -233,7 +233,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { ...@@ -233,7 +233,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} }
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); dol_syslog('htdocs/accountancy/customer/index.php sql=' . $sql, LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
...@@ -289,7 +289,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { ...@@ -289,7 +289,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY fd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog("htdocs/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
...@@ -347,7 +347,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. ...@@ -347,7 +347,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
dol_syslog('htdocs/accountancy/customer/index.php'); dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
...@@ -357,7 +356,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. ...@@ -357,7 +356,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
} }
print '<td align="right"><b>' . price($row[13]) . '</b></td>'; print '<td align="right"><b>' . price($row[13]) . '</b></td>';
print '</tr>'; print '</tr>';
$i ++;
} }
$db->free($resql); $db->free($resql);
} else { } else {
...@@ -365,6 +363,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. ...@@ -365,6 +363,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
} }
print "</table>\n"; print "</table>\n";
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled)) {
print "<br>\n"; print "<br>\n";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
...@@ -390,7 +389,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. ...@@ -390,7 +389,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; $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); dol_syslog('htdocs/accountancy/customer/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
......
...@@ -69,7 +69,7 @@ if ($action == 'validatehistory') { ...@@ -69,7 +69,7 @@ if ($action == 'validatehistory') {
// First clean corrupted data // First clean corrupted data
$sqlclean = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sqlclean = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sqlclean .= " SET erd.fk_code_ventilation = 0"; $sqlclean .= " SET fk_code_ventilation = 0";
$sqlclean .= ' WHERE erd.fk_code_ventilation NOT IN '; $sqlclean .= ' WHERE erd.fk_code_ventilation NOT IN ';
$sqlclean .= ' (SELECT accnt.rowid '; $sqlclean .= ' (SELECT accnt.rowid ';
$sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sqlclean .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
...@@ -93,6 +93,8 @@ if ($action == 'validatehistory') { ...@@ -93,6 +93,8 @@ if ($action == 'validatehistory') {
$sql1 .= " AND erd.fk_code_ventilation = 0"; $sql1 .= " AND erd.fk_code_ventilation = 0";
} }
dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql1 = $db->query($sql1); $resql1 = $db->query($sql1);
if (! $resql1) { if (! $resql1) {
$error ++; $error ++;
...@@ -107,7 +109,7 @@ if ($action == 'validatehistory') { ...@@ -107,7 +109,7 @@ if ($action == 'validatehistory') {
$db->begin(); $db->begin();
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1 .= " SET erd.fk_code_ventilation = 0"; $sql1 .= " SET fk_code_ventilation = 0";
$sql1 .= ' WHERE erd.fk_code_ventilation NOT IN '; $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN ';
$sql1 .= ' (SELECT accnt.rowid '; $sql1 .= ' (SELECT accnt.rowid ';
$sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt';
...@@ -129,8 +131,9 @@ if ($action == 'validatehistory') { ...@@ -129,8 +131,9 @@ if ($action == 'validatehistory') {
$error = 0; $error = 0;
$db->begin(); $db->begin();
// Now clean
$sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql1.= " SET erd.fk_code_ventilation = 0"; $sql1.= " SET fk_code_ventilation = 0";
$sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er"; $sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er";
$sql1.= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; $sql1.= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'";
$sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; $sql1.= " AND er.date_debut <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'";
...@@ -166,25 +169,25 @@ print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv ...@@ -166,25 +169,25 @@ print $langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv
print '<br>'; print '<br>';
//print '<div class="inline-block divButAction">'; //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>'; 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>'; //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; $y = $year_current;
print '<br>'; $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_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<table class="noborder" width="100%">'; 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>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { 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>';
...@@ -196,7 +199,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", ...@@ -196,7 +199,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(er.date_debut)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(erd.total_ht),2) as total"; $sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
...@@ -237,7 +240,7 @@ print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ' ...@@ -237,7 +240,7 @@ print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, '
print '<table class="noborder" width="100%">'; 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>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { 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>';
...@@ -260,7 +263,7 @@ $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We d ...@@ -260,7 +263,7 @@ $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We d
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
...@@ -304,7 +307,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. ...@@ -304,7 +307,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
$sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; $sql .= " SUM(" . $db->ifsql('MONTH(er.date_create)=' . $i, 'erd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ",";
} }
$sql .= " ROUND(SUM(erd.total_ht),2) as total"; $sql .= " SUM(erd.total_ht) as total";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
$sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $sql .= " WHERE er.date_debut >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
...@@ -312,14 +315,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. ...@@ -312,14 +315,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql .= " AND er.fk_statut > 0 "; $sql .= " AND er.fk_statut > 0 ";
$sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
dol_syslog('/accountancy/expensereport/index.php:: sql=' . $sql); dol_syslog('htdocs/accountancy/expensereport/index.php');
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ( $row = $db->fetch_row($resql)) { while ( $row = $db->fetch_row($resql)) {
print '<tr><td>' . $row[0] . '</td>'; print '<tr><td>' . $row[0] . '</td>';
for($i = 1; $i <= 12; $i ++) { for($i = 1; $i <= 12; $i ++) {
print '<td align="right">' . price($row[$i]) . '</td>'; print '<td align="right">' . price($row[$i]) . '</td>';
......
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
/** /**
* \file htdocs/accountancy/supplier/index.php * \file htdocs/accountancy/supplier/index.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Home supplier ventilation * \brief Home supplier journalization page
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.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 . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
// Langs // Langs
$langs->load("compta"); $langs->load("compta");
...@@ -55,7 +56,7 @@ if ($year == 0) { ...@@ -55,7 +56,7 @@ if ($year == 0) {
} }
// Validate History // Validate History
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'aZ09');
/* /*
...@@ -93,6 +94,8 @@ if ($action == 'validatehistory') { ...@@ -93,6 +94,8 @@ if ($action == 'validatehistory') {
$sql1 .= " AND fd.fk_code_ventilation = 0"; $sql1 .= " AND fd.fk_code_ventilation = 0";
} }
dol_syslog('htdocs/accountancy/supplier/index.php');
$resql1 = $db->query($sql1); $resql1 = $db->query($sql1);
if (! $resql1) { if (! $resql1) {
$error ++; $error ++;
...@@ -159,33 +162,28 @@ llxHeader('', $langs->trans("SuppliersVentilation")); ...@@ -159,33 +162,28 @@ llxHeader('', $langs->trans("SuppliersVentilation"));
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>'; $textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>'; $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
print load_fiche_titre($langs->trans("SuppliersVentilation") . "&nbsp;" . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy'); print load_fiche_titre($langs->trans("SuppliersVentilation") . " " . $textprevyear . "&nbsp;" . $langs->trans("Year") . "&nbsp;" . $year_start . "&nbsp;" . $textnextyear, '', 'title_accountancy');
print $langs->trans("DescVentilSupplier") . '<br>'; print $langs->trans("DescVentilSupplier") . '<br>';
print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>'; print $langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")) . '<br>';
print '<br>'; print '<br>';
//print '<div class="inline-block divButAction">'; //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>'; 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>'; //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; $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_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print '<table class="noborder" width="100%">'; 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>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { 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>';
...@@ -197,7 +195,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", ...@@ -197,7 +195,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
for($i = 1; $i <= 12; $i ++) { 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 .= " 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 .= " 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 . "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"; $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 ...@@ -208,7 +206,7 @@ $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We d
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; $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); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
...@@ -239,7 +237,7 @@ print '<br>'; ...@@ -239,7 +237,7 @@ print '<br>';
print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, '');
print '<table class="noborder" width="100%">'; 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>'; print '<td width="200" align="left">' . $langs->trans("Label") . '</td>';
for($i = 1; $i <= 12; $i ++) { 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>';
...@@ -251,7 +249,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'", ...@@ -251,7 +249,7 @@ $sql .= " " . $db->ifsql('aa.label IS NULL', "'".$langs->trans('NotMatch')."'",
for($i = 1; $i <= 12; $i ++) { 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 .= " 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 .= " 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 . "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"; $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 ...@@ -262,7 +260,7 @@ $sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We d
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label"; $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); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
...@@ -306,7 +304,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. ...@@ -306,7 +304,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
for($i = 1; $i <= 12; $i ++) { 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 .= " 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 .= " 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 . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
$sql .= " WHERE ff.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; $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. ...@@ -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.fk_statut > 0 ";
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy $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); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
......
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