diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 2a1234fccc1..a383f841a47 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * * 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 @@ -39,6 +39,30 @@ $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); if ($id > 0) $object->fetch($id); +// Load variable for pagination +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield="f.datef"; // Set here default search field +if (! $sortorder) $sortorder="DESC"; + + +$arrayfields=array( + 'f.datef'=>array('label'=>"Date", 'checked'=>1), + //... +); + +/* + * Actions + */ + +// None + /* * View @@ -55,10 +79,10 @@ llxHeader('',$title,$help_url); if ($id > 0) { - /* - * Affichage onglets - */ - $head = societe_prepare_head($object); + $param=''; + if ($id > 0) $param.='&socid='.$id; + + $head = societe_prepare_head($object); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 1); @@ -71,7 +95,7 @@ if ($id > 0) print ''; print ''; - print ''; + if (! empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'],$_SERVER["PHP_SELF"],"f.datef","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); print ''; print ''; print ''; @@ -90,7 +114,7 @@ if ($id > 0) $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.fk_user_valid = u.rowid"; - $sql.= " ORDER BY f.datef ASC"; + $sql.= $db->order($sortfield, $sortorder); $resql=$db->query($sql); if ($resql) @@ -177,13 +201,13 @@ if ($id > 0) } if(empty($TData)) { - print ''; + print ''; } else { - + // Sort array by date asort($TDataSort); array_multisort($TData,$TDataSort); - + // Balance calculation foreach($TData as &$data1) { $balance += $data1['amount']; @@ -191,7 +215,8 @@ if ($id > 0) } // Reverse array to have last elements on top - $TData = array_reverse($TData); + $TData = dol_sort_array($TData, 'date', $sortorder); + $totalDebit = 0; $totalCredit = 0; @@ -223,7 +248,8 @@ if ($id > 0) print ''; print ''; print ''; - print ''; + print ''; + print ''; print "\n"; }
'.$langs->trans("Date").''.$langs->trans("Element").''.$langs->trans("Status").''.$langs->trans("Debit").'
'.$langs->trans("NoInvoice").'
'.$langs->trans("NoInvoice").'
 '.price($totalDebit).''.price($totalCredit).' '.price(price2num($totalDebit - $totalCredit, 'MT')).'