From 7f5fd3bbc05ef7515acfe7e2d002870b9a5d2894 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Nov 2016 21:24:51 +0100 Subject: [PATCH] Fix selection of fields --- htdocs/compta/bank/index.php | 280 +++++++++++++++++++---------------- 1 file changed, 152 insertions(+), 128 deletions(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 17650605d04..ca1b2cfdaa1 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -414,148 +414,172 @@ print ''; -$total = array(); $found = 0; +$total = array(); $found = 0; $i=0; $var=true; foreach ($accounts as $key=>$type) { - //if ($type == 1) - //{ - $found++; + $found++; - $acc = new Account($db); - $acc->fetch($key); + $acc = new Account($db); + $acc->fetch($key); - $var = !$var; - $solde = $acc->solde(1); + $var = !$var; + $solde = $acc->solde(1); - print ''; + print ''; - // Ref - if (! empty($arrayfields['b.ref']['checked'])) - { - print ''.$acc->getNomUrl(1).''; - } - - // Label - if (! empty($arrayfields['b.label']['checked'])) - { - print ''.$acc->label.''; - } - - // Account type - if (! empty($arrayfields['accountype']['checked'])) - { - print ''; - print $acc->type_lib[$acc->type]; - print ''; - } - - // Number - if (! empty($arrayfields['b.number']['checked'])) - { - print ''.$acc->number.''; - } - - // Account number - if (! empty($arrayfields['b.account_number']['checked'])) - { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - print ''.length_accountg($acc->account_number).''; - } - - // Transactions to reconcile - if (! empty($arrayfields['toreconcile']['checked'])) - { - print ''; - if ($acc->rappro) - { - $result=$acc->load_board($user,$acc->id); - if ($result<0) { - setEventMessages($acc->error, $acc->errors, 'errors'); - } else { - print $result->nbtodo; - if ($result->nbtodolate) print '   ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; - } - } - else print $langs->trans("FeatureDisabled"); - print ''; - } - - - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + // Ref + if (! empty($arrayfields['b.ref']['checked'])) + { + print ''.$acc->getNomUrl(1).''; + if (! $i) $totalarray['nbfield']++; + } + + // Label + if (! empty($arrayfields['b.label']['checked'])) + { + print ''.$acc->label.''; + if (! $i) $totalarray['nbfield']++; + } + + // Account type + if (! empty($arrayfields['accountype']['checked'])) + { + print ''; + print $acc->type_lib[$acc->type]; + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Number + if (! empty($arrayfields['b.number']['checked'])) + { + print ''.$acc->number.''; + if (! $i) $totalarray['nbfield']++; + } + + // Account number + if (! empty($arrayfields['b.account_number']['checked'])) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + print ''.length_accountg($acc->account_number).''; + if (! $i) $totalarray['nbfield']++; + } + + // Transactions to reconcile + if (! empty($arrayfields['toreconcile']['checked'])) + { + print ''; + if ($acc->rappro) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['b.datec']['checked'])) - { - print ''; - print dol_print_date($acc->date_creation, 'dayhour'); - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['b.tms']['checked'])) - { - print ''; - print dol_print_date($acc->date_update, 'dayhour'); - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Statut - if (! empty($arrayfields['b.clos']['checked'])) - { - print ''.$acc->getLibStatut(5).''; - } - - // Balance - if (! empty($arrayfields['balance']['checked'])) - { - print ''; - print ''.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).''; - print ''; - } - - // Action column - print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $result=$acc->load_board($user,$acc->id); + if ($result<0) { + setEventMessages($acc->error, $acc->errors, 'errors'); + } else { + print $result->nbtodo; + if ($result->nbtodolate) print '   ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; + } } + else print $langs->trans("FeatureDisabled"); + print ''; + if (! $i) $totalarray['nbfield']++; + } + + + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['b.datec']['checked'])) + { + print ''; + print dol_print_date($acc->date_creation, 'dayhour'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['b.tms']['checked'])) + { + print ''; + print dol_print_date($acc->date_update, 'dayhour'); + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Statut + if (! empty($arrayfields['b.clos']['checked'])) + { + print ''.$acc->getLibStatut(5).''; + if (! $i) $totalarray['nbfield']++; + } + + // Balance + if (! empty($arrayfields['balance']['checked'])) + { + print ''; + print ''.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).''; print ''; if (! $i) $totalarray['nbfield']++; - - print ''; + if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield']; + $totalarray['totalbalance'] += $solde; + } + + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; - $total[$acc->currency_code] += $solde; - //} + $total[$acc->currency_code] += $solde; + + $i++; } -if (! $found) print ''.$langs->trans("None").''; -// Total -foreach ($total as $key=>$solde) + +if (! $found) print ''.$langs->trans("None").''; + +// Show total line +if (isset($totalarray['totalbalancefield'])) { - print ''.$langs->trans("Total").' '.$key.''.price($solde, 0, $langs, 0, 0, -1, $key).''; + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + } + elseif ($totalarray['totalbalancefield'] == $i) print ''.price($totalarray['totalbalance'], 0, $langs, 0, 0, -1, $key).''; + else print ''; + } + print ''; } print '';