diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index cb40b7b361b..663e763a9d3 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2013 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Juanjo Menent * * 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 @@ -26,7 +26,7 @@ */ require '../../main.inc.php'; - + // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -43,7 +43,7 @@ if ($user->societe_id > 0) accessforbidden(); if (! $user->rights->accounting->ventilation->read) accessforbidden(); - + // Filter $year = $_GET["year"]; if ($year == 0) { @@ -57,10 +57,10 @@ if ($year == 0) { // Validate History $action = GETPOST('action'); if ($action == 'validatehistory') { - + $error = 0; $db->begin(); - + if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; $sql1 .= " SET fd.fk_code_ventilation = accnt.rowid"; @@ -75,8 +75,7 @@ if ($action == 'validatehistory') { $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; } - - dol_syslog("/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); + $resql1 = $db->query($sql1); if (! $resql1) { $error ++; @@ -106,7 +105,6 @@ $sql .= " , " . MAIN_DB_PREFIX . "facture as f"; $sql .= " WHERE fd.fk_code_ventilation = 0"; $sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;"; -dol_syslog("/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { $row = $db->fetch_row($result); @@ -162,15 +160,14 @@ if (! empty($conf->multicompany->enabled)) { $sql .= " GROUP BY fd.fk_code_ventilation"; -dol_syslog("/accountancy/customer/index.php sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); - + while ( $i < $num ) { $row = $db->fetch_row($resql); - + print '' . length_accountg($row[0]) . ''; print '' . $row[1] . ''; print '' . price($row[2]) . ''; @@ -235,15 +232,14 @@ if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity = '" . $conf->entity . "'"; } -dol_syslog('accountancy/customer/index.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); - + while ( $i < $num ) { $row = $db->fetch_row($resql); - + print '' . $row[0] . ''; print '' . price($row[1]) . ''; print '' . price($row[2]) . ''; @@ -284,7 +280,7 @@ if (! empty($conf->margin->enabled)) { print '' . $langs->trans("NovemberMin") . ''; print '' . $langs->trans("DecemberMin") . ''; print '' . $langs->trans("Total") . ''; - + $sql = "SELECT '" . $langs->trans("Vide") . "' AS 'Marge',"; $sql .= " ROUND(SUM(IF(MONTH(f.datef)=1,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Janvier',"; $sql .= " ROUND(SUM(IF(MONTH(f.datef)=2,(fd.total_ht-(fd.qty * fd.buy_price_ht)),0)),2) AS 'Fevrier',"; @@ -303,20 +299,19 @@ if (! empty($conf->margin->enabled)) { $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)) . "'"; - + if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity = '" . $conf->entity . "'"; } - - dol_syslog('accountancy/customer/index.php:: $sql=' . $sql); + $resql = $db->query($sql); if ($resql) { $i = 0; $num = $db->num_rows($resql); - + while ( $i < $num ) { $row = $db->fetch_row($resql); - + print '' . $row[0] . ''; print '' . price($row[1]) . ''; print '' . price($row[2]) . '';