diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 43628d0aca9..b5164d6078c 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -1032,7 +1032,7 @@ if ($object->id > 0)
*/
if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{
- $sql = 'SELECT f.rowid as id, f.titre as ref, f.amount';
+ $sql = 'SELECT f.rowid as id, f.titre as ref';
$sql .= ', f.total as total_ht';
$sql .= ', f.tva as total_tva';
$sql .= ', f.total_ttc';
@@ -1045,7 +1045,7 @@ if ($object->id > 0)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql .= " AND f.entity = ".$conf->entity;
- $sql .= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,';
+ $sql .= ' GROUP BY f.rowid, f.titre, f.total, f.tva, f.total_ttc,';
$sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
$sql .= ' f.suspended, f.date_when,';
$sql .= ' s.nom, s.rowid';
@@ -1140,7 +1140,7 @@ if ($object->id > 0)
*/
if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{
- $sql = 'SELECT f.rowid as facid, f.ref, f.type, f.amount';
+ $sql = 'SELECT f.rowid as facid, f.ref, f.type';
$sql .= ', f.total as total_ht';
$sql .= ', f.tva as total_tva';
$sql .= ', f.total_ttc';
@@ -1151,7 +1151,7 @@ if ($object->id > 0)
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql .= " AND f.entity IN (".getEntity('invoice').")";
- $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.amount, f.total, f.tva, f.total_ttc,';
+ $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.total, f.tva, f.total_ttc,';
$sql .= ' f.datef, f.datec, f.paye, f.fk_statut,';
$sql .= ' s.nom, s.rowid';
$sql .= " ORDER BY f.datef DESC, f.datec DESC";
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index 5b297eed309..fb2a3edfd9c 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -75,6 +75,8 @@ if ($facid > 0)
// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('paiementcard', 'globalcard'));
+$formquestion = array();
+
/*
* Actions
@@ -859,7 +861,7 @@ if (!GETPOST('action', 'aZ09'))
if (!$sortorder) $sortorder = 'DESC';
if (!$sortfield) $sortfield = 'p.datep';
- $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref';
+ $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql .= ', '.MAIN_DB_PREFIX.'facture as f';
@@ -882,10 +884,10 @@ if (!GETPOST('action', 'aZ09'))
print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
print '
';
print '';
- print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'ref', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'dp', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'libelle', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right ');
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
print "
\n";
diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php
index 0043cf31811..60ea008a834 100644
--- a/htdocs/compta/recap-compta.php
+++ b/htdocs/compta/recap-compta.php
@@ -117,7 +117,7 @@ if ($id > 0)
$TData = array();
- $sql = "SELECT s.nom, s.rowid as socid, f.ref, f.amount, f.datef as df,";
+ $sql = "SELECT s.nom, s.rowid as socid, f.ref, f.total_ttc, f.datef as df,";
$sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql .= " u.login, u.rowid as userid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."user as u";
diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php
index d4cb4143463..b1b108931b1 100644
--- a/htdocs/core/boxes/box_factures_fourn_imp.php
+++ b/htdocs/core/boxes/box_factures_fourn_imp.php
@@ -84,7 +84,7 @@ class box_factures_fourn_imp extends ModeleBoxes
{
$sql = "SELECT s.nom as name, s.rowid as socid,";
$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,";
- $sql.= " f.amount, f.datef as df,";
+ $sql.= " f.datef as df,";
$sql.= " f.total_ht as total_ht,";
$sql.= " f.tva as total_tva,";
$sql.= " f.total_ttc,";
diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php
index ab9dc42fca9..0a44105a853 100644
--- a/htdocs/core/boxes/box_factures_imp.php
+++ b/htdocs/core/boxes/box_factures_imp.php
@@ -93,7 +93,7 @@ class box_factures_imp extends ModeleBoxes
$sql .= " s.logo,";
$sql .= " f.ref, f.date_lim_reglement as datelimite,";
$sql .= " f.type,";
- $sql .= " f.amount, f.datef as df,";
+ $sql .= " f.datef as df,";
$sql .= " f.total as total_ht,";
$sql .= " f.tva as total_tva,";
$sql .= " f.total_ttc,";
@@ -110,7 +110,7 @@ class box_factures_imp extends ModeleBoxes
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
$sql .= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,";
- $sql .= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
+ $sql .= " f.type, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
//$sql.= " ORDER BY f.datef DESC, f.ref DESC ";
$sql .= " ORDER BY datelimite ASC, f.ref ASC ";
$sql .= $this->db->plimit($max, 0);
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index e9198ebcc91..e0a679d1321 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -370,7 +370,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$dateinvoice = ($datefacture == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datefacture);
$sql = 'SELECT s.nom as name, s.rowid as socid,';
- $sql .= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
+ $sql .= ' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -821,7 +821,7 @@ if (empty($action) || $action == 'list')
$sql .= ' c.code as paiement_type, c.libelle as paiement_libelle,';
$sql .= ' ba.rowid as bid, ba.label,';
if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,';
- $sql .= ' SUM(f.amount)';
+ $sql .= ' SUM(pf.amount)';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
@@ -1013,9 +1013,9 @@ if (empty($action) || $action == 'list')
// Amount
print ''.price($objp->pamount).' | ';
- if (!$i) $totalarray['nbfield']++;
- $totalarray['pos'][7] = 'amount';
+ $totalarray['pos'][$totalarray['nbfield']] = 'amount';
$totalarray['val']['amount'] += $objp->pamount;
+ if (!$i) $totalarray['nbfield']++;
// Ref invoice
/*$invoicesupplierstatic->ref=$objp->ref_supplier;
diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php
index 1fda453ffe4..2cd52bfeb77 100644
--- a/htdocs/fourn/recap-fourn.php
+++ b/htdocs/fourn/recap-fourn.php
@@ -72,7 +72,7 @@ if ($socid > 0)
print '';
- $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.amount, f.datef as df,";
+ $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.datef as df,";
$sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql .= " u.login, u.rowid as userid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php
index b6bc81a91e2..062b62ffb21 100644
--- a/htdocs/stripe/payment.php
+++ b/htdocs/stripe/payment.php
@@ -1087,8 +1087,8 @@ if (!GETPOST('action'))
if (!$sortorder) $sortorder = 'DESC';
if (!$sortfield) $sortfield = 'p.datep';
- $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref';
- $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
+ $sql = 'SELECT p.datep as dp, p.amount, f.ref,';
+ $sql .= ' f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c';
$sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id';
$sql .= ' AND f.entity IN ('.getEntity('invoice').")";
@@ -1109,10 +1109,10 @@ if (!GETPOST('action'))
print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
print '';
print '';
- print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'ref', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'dp', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'libelle', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.paiement_type', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right ');
$tmpobject = new Paiement($db);
$parameters = array();