Fix selection of fields
This commit is contained in:
parent
3dc9bc89d8
commit
7f5fd3bbc0
@ -414,148 +414,172 @@ print '</tr>';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$total = array(); $found = 0;
|
$total = array(); $found = 0; $i=0;
|
||||||
$var=true;
|
$var=true;
|
||||||
foreach ($accounts as $key=>$type)
|
foreach ($accounts as $key=>$type)
|
||||||
{
|
{
|
||||||
//if ($type == 1)
|
$found++;
|
||||||
//{
|
|
||||||
$found++;
|
|
||||||
|
|
||||||
$acc = new Account($db);
|
$acc = new Account($db);
|
||||||
$acc->fetch($key);
|
$acc->fetch($key);
|
||||||
|
|
||||||
$var = !$var;
|
$var = !$var;
|
||||||
$solde = $acc->solde(1);
|
$solde = $acc->solde(1);
|
||||||
|
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
if (! empty($arrayfields['b.ref']['checked']))
|
if (! empty($arrayfields['b.ref']['checked']))
|
||||||
{
|
{
|
||||||
print '<td class="titlefield">'.$acc->getNomUrl(1).'</td>';
|
print '<td class="titlefield">'.$acc->getNomUrl(1).'</td>';
|
||||||
}
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
// Label
|
|
||||||
if (! empty($arrayfields['b.label']['checked']))
|
// Label
|
||||||
{
|
if (! empty($arrayfields['b.label']['checked']))
|
||||||
print '<td>'.$acc->label.'</td>';
|
{
|
||||||
}
|
print '<td>'.$acc->label.'</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
// Account type
|
}
|
||||||
if (! empty($arrayfields['accountype']['checked']))
|
|
||||||
{
|
// Account type
|
||||||
print '<td>';
|
if (! empty($arrayfields['accountype']['checked']))
|
||||||
print $acc->type_lib[$acc->type];
|
{
|
||||||
print '</td>';
|
print '<td>';
|
||||||
}
|
print $acc->type_lib[$acc->type];
|
||||||
|
print '</td>';
|
||||||
// Number
|
if (! $i) $totalarray['nbfield']++;
|
||||||
if (! empty($arrayfields['b.number']['checked']))
|
}
|
||||||
{
|
|
||||||
print '<td>'.$acc->number.'</td>';
|
// Number
|
||||||
}
|
if (! empty($arrayfields['b.number']['checked']))
|
||||||
|
{
|
||||||
// Account number
|
print '<td>'.$acc->number.'</td>';
|
||||||
if (! empty($arrayfields['b.account_number']['checked']))
|
if (! $i) $totalarray['nbfield']++;
|
||||||
{
|
}
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
|
||||||
print '<td>'.length_accountg($acc->account_number).'</td>';
|
// Account number
|
||||||
}
|
if (! empty($arrayfields['b.account_number']['checked']))
|
||||||
|
{
|
||||||
// Transactions to reconcile
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||||
if (! empty($arrayfields['toreconcile']['checked']))
|
print '<td>'.length_accountg($acc->account_number).'</td>';
|
||||||
{
|
if (! $i) $totalarray['nbfield']++;
|
||||||
print '<td align="center">';
|
}
|
||||||
if ($acc->rappro)
|
|
||||||
{
|
// Transactions to reconcile
|
||||||
$result=$acc->load_board($user,$acc->id);
|
if (! empty($arrayfields['toreconcile']['checked']))
|
||||||
if ($result<0) {
|
{
|
||||||
setEventMessages($acc->error, $acc->errors, 'errors');
|
print '<td align="center">';
|
||||||
} else {
|
if ($acc->rappro)
|
||||||
print $result->nbtodo;
|
|
||||||
if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else print $langs->trans("FeatureDisabled");
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Extra fields
|
|
||||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
|
||||||
{
|
{
|
||||||
foreach($extrafields->attribute_label as $key => $val)
|
$result=$acc->load_board($user,$acc->id);
|
||||||
{
|
if ($result<0) {
|
||||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
setEventMessages($acc->error, $acc->errors, 'errors');
|
||||||
{
|
} else {
|
||||||
print '<td';
|
print $result->nbtodo;
|
||||||
$align=$extrafields->getAlignFlag($key);
|
if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
|
||||||
if ($align) print ' align="'.$align.'"';
|
}
|
||||||
print '>';
|
|
||||||
$tmpkey='options_'.$key;
|
|
||||||
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
|
||||||
print '</td>';
|
|
||||||
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 '<td align="center">';
|
|
||||||
print dol_print_date($acc->date_creation, 'dayhour');
|
|
||||||
print '</td>';
|
|
||||||
if (! $i) $totalarray['nbfield']++;
|
|
||||||
}
|
|
||||||
// Date modification
|
|
||||||
if (! empty($arrayfields['b.tms']['checked']))
|
|
||||||
{
|
|
||||||
print '<td align="center">';
|
|
||||||
print dol_print_date($acc->date_update, 'dayhour');
|
|
||||||
print '</td>';
|
|
||||||
if (! $i) $totalarray['nbfield']++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Statut
|
|
||||||
if (! empty($arrayfields['b.clos']['checked']))
|
|
||||||
{
|
|
||||||
print '<td align="center">'.$acc->getLibStatut(5).'</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Balance
|
|
||||||
if (! empty($arrayfields['balance']['checked']))
|
|
||||||
{
|
|
||||||
print '<td align="right">';
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/compta/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action column
|
|
||||||
print '<td class="nowrap" align="center">';
|
|
||||||
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 '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
|
||||||
}
|
}
|
||||||
|
else print $langs->trans("FeatureDisabled");
|
||||||
|
print '</td>';
|
||||||
|
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 '<td';
|
||||||
|
$align=$extrafields->getAlignFlag($key);
|
||||||
|
if ($align) print ' align="'.$align.'"';
|
||||||
|
print '>';
|
||||||
|
$tmpkey='options_'.$key;
|
||||||
|
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
|
||||||
|
print '</td>';
|
||||||
|
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 '<td align="center">';
|
||||||
|
print dol_print_date($acc->date_creation, 'dayhour');
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
// Date modification
|
||||||
|
if (! empty($arrayfields['b.tms']['checked']))
|
||||||
|
{
|
||||||
|
print '<td align="center">';
|
||||||
|
print dol_print_date($acc->date_update, 'dayhour');
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Statut
|
||||||
|
if (! empty($arrayfields['b.clos']['checked']))
|
||||||
|
{
|
||||||
|
print '<td align="center">'.$acc->getLibStatut(5).'</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Balance
|
||||||
|
if (! empty($arrayfields['balance']['checked']))
|
||||||
|
{
|
||||||
|
print '<td align="right">';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
|
||||||
print '</tr>';
|
$totalarray['totalbalance'] += $solde;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Action column
|
||||||
|
print '<td class="nowrap" align="center">';
|
||||||
|
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 '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
$total[$acc->currency_code] += $solde;
|
$total[$acc->currency_code] += $solde;
|
||||||
//}
|
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
if (! $found) print '<tr '.$bc[$var].'><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
|
||||||
// Total
|
if (! $found) print '<tr '.$bc[$var].'><td colspan="'.$totalarray['nbfield'].'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||||
foreach ($total as $key=>$solde)
|
|
||||||
|
// Show total line
|
||||||
|
if (isset($totalarray['totalbalancefield']))
|
||||||
{
|
{
|
||||||
print '<tr class="liste_total"><td colspan="6" class="liste_total">'.$langs->trans("Total").' '.$key.'</td><td align="right" class="liste_total">'.price($solde, 0, $langs, 0, 0, -1, $key).'</td><td></td></tr>';
|
print '<tr class="liste_total">';
|
||||||
|
$i=0;
|
||||||
|
while ($i < $totalarray['nbfield'])
|
||||||
|
{
|
||||||
|
$i++;
|
||||||
|
if ($i == 1)
|
||||||
|
{
|
||||||
|
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
|
||||||
|
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
|
||||||
|
}
|
||||||
|
elseif ($totalarray['totalbalancefield'] == $i) print '<td align="right">'.price($totalarray['totalbalance'], 0, $langs, 0, 0, -1, $key).'</td>';
|
||||||
|
else print '<td></td>';
|
||||||
|
}
|
||||||
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user