diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 1aea3e27c1b..7dffc753bc4 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -7,6 +7,7 @@ * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2012-2014 Marcos GarcĂ­a * Copyright (C) 2011-2015 Alexandre Spangaro + * Copyright (C) 2015 Florian Henry * * 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 @@ -68,6 +69,15 @@ $req_desc=GETPOST("req_desc",'',3); $req_debit=GETPOST("req_debit",'',3); $req_credit=GETPOST("req_credit",'',3); +$req_stdtmonth=GETPOST('req_stdtmonth', 'int'); +$req_stdtday=GETPOST('req_stdtday', 'int'); +$req_stdtyear=GETPOST('req_stdtyear', 'int'); +$req_stdt = dol_mktime(0, 0, 0, $req_stdtmonth, $req_stdtday, $req_stdtyear); +$req_enddtmonth=GETPOST('req_enddtmonth', 'int'); +$req_enddtday=GETPOST('req_enddtday', 'int'); +$req_enddtyear=GETPOST('req_enddtyear', 'int'); +$req_enddt = dol_mktime(23, 59, 59, $req_enddtmonth, $req_enddtday, $req_enddtyear); + $vline=GETPOST("vline"); $page=GETPOST('page','int'); $negpage=GETPOST('negpage','int'); @@ -87,6 +97,14 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $req_desc=""; $req_debit=""; $req_credit=""; + $req_stdtmonth=""; + $req_stdtday=""; + $req_stdtyear=""; + $req_stdt = ""; + $req_enddtmonth=""; + $req_enddtday=""; + $req_enddtyear=""; + $req_enddt = ""; } /* @@ -158,7 +176,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->m * View */ -llxHeader(); +llxHeader('',$langs->trans("FinancialAccount").'-'.$langs->trans("Transactions")); $societestatic=new Societe($db); $userstatic=new User($db); @@ -253,6 +271,27 @@ if ($id > 0 || ! empty($ref)) $param.='&paiementtype='.urlencode($paiementtype); $mode_search = 1; } + + if ($req_stdt && $req_enddt) + { + $sql_rech.=" AND (b.datev BETWEEN '".$db->escape($db->idate($req_stdt))."' AND '".$db->escape($db->idate($req_enddt))."')"; + $param.='&req_stdtmonth='.$req_stdtmonth.'&req_stdtyear='.$req_stdtyear.'&req_stdtday='.$req_stdtday; + $param.='&req_enddtmonth='.$req_enddtmonth.'&req_enddtday='.$req_enddtday.'&req_enddtyear='.$req_enddtyear; + $mode_search = 1; + } + elseif ($req_stdt) + { + $sql_rech.=" AND b.datev >= '".$db->escape($db->idate($req_stdt))."'"; + $param.='&req_stdtmonth='.$req_stdtmonth.'&req_stdtyear='.$req_stdtyear.'&req_stdtday='.$req_stdtday; + $mode_search = 1; + } + elseif ($req_enddt) + { + $sql_rech.=" AND b.datev <= '".$db->escape($db->idate($req_enddt))."'"; + $param.='&req_enddtmonth='.$req_enddtmonth.'&req_enddtday='.$req_enddtday.'&req_enddtyear='.$req_enddtyear; + $mode_search = 1; + } + $sql = "SELECT count(*) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; @@ -398,7 +437,13 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $navig ='
'; if ($limitsql > $viewline) $navig.=''.img_previous().''; $navig.= ' "; // ' Page '; @@ -489,9 +534,12 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; + $period_filter .= $langs->trans('From').' '.$form->select_date($req_stdt,'req_stdt',0,0,1,null,1,1,1); + $period_filter .= '
'. $langs->trans('to').' '.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,1,1); + print ''; print ' '; - print ' '; + print ''.$period_filter.''; print ''; //$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...) $filtertype=''; @@ -576,7 +624,7 @@ if ($id > 0 || ! empty($ref)) $var=true; $num = $db->num_rows($result); - $i = 0; $total = 0; $sep = -1; + $i = 0; $total = 0; $sep = -1; $total_deb=0; $total_cred=0; while ($i < $num) { @@ -811,10 +859,12 @@ if ($id > 0 || ! empty($ref)) if ($objp->amount < 0) { print ''.price($objp->amount * -1).' '."\n"; + $total_deb +=$objp->amount; } else { print '  '.price($objp->amount).''."\n"; + $total_cred +=$objp->amount; } // Balance @@ -886,11 +936,23 @@ if ($id > 0 || ! empty($ref)) // Show total if ($page == 0 && ! $mode_search) { + //Real account situation print ''; if ($sep > 0) print ' '; // If we had at least one line in future else print $langs->trans("CurrentBalance"); print ' '.$object->currency_code.''; - print ''.price($total, 0, $langs, 0, 0, -1, $object->currency_code).''; + print ''.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).''; + print ' '; + print ''; + } else { + // Only total according row displays + print ''; + if ($sep > 0) print ' '; // If we had at least one line in future + else print $langs->trans("Total"); + print ' '.$object->currency_code.''; + print ''.price($total_deb*-1, 0, $langs, 0, 0, -1, $object->currency_code).''; + print ''.price($total_cred, 0, $langs, 0, 0, -1, $object->currency_code).''; + print ''.price($total_cred-($total_deb*-1), 0, $langs, 0, 0, -1, $object->currency_code).''; print ' '; print ''; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1c132502b78..e2313d157d5 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -923,7 +923,12 @@ class ExtraFields } elseif ($type == 'chkbxlst') { - $value_arr = explode(',', $value); + if (is_array($value)) { + $value_arr = $value; + } + else { + $value_arr = explode(',', $value); + } if (is_array($param['options'])) { $param_list = array_keys($param['options']);