NEW Can sort customer balance summary on date
This commit is contained in:
parent
ab444ce730
commit
cc95e046e5
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
|
||||
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 '<td>'.$langs->trans("Element").'</td>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Debit").'</td>';
|
||||
@ -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 '<tr '.$bc[false].'><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
|
||||
print '<tr class="oddeven"><td colspan="7">'.$langs->trans("NoInvoice").'</td></tr>';
|
||||
} 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 '<td colspan="3"> </td>';
|
||||
print '<td align="right">'.price($totalDebit).'</td>';
|
||||
print '<td align="right">'.price($totalCredit).'</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print '<td align="right">'.price(price2num($totalDebit - $totalCredit, 'MT')).'</td>';
|
||||
print '<td></td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user