$solde_c = 0.0; } if ($detail['cred_montant'] > 0) { $solde = bcsub($solde, $detail['cred_montant']); $solde_c = bcadd($solde_c, $detail['cred_montant']); } if ($detail['deb_montant'] > 0) { $solde = bcadd($solde, $detail['deb_montant']); $solde_d = bcadd($solde_d, $detail['deb_montant']); } $side = " " . $Poste->get_amount_side($solde); $letter = ""; $html_let = ""; if ($detail['letter'] != -1) { $letter = strtoupper(base_convert($detail['letter'], 10, 36)); $html_let = HtmlInput::show_reconcile("", $letter); } $i++; if ($i % 2 == 0) { $class = "odd"; } else { $class = "even"; } echo '<tr name="tr_' . $letter . '_" class="' . $class . '"> <td>' . $detail['j_date_fmt'] . '</td> <td>' . HtmlInput::detail_op($detail['jr_id'], $detail['jr_internal']) . '</td> <td>' . $detail['description'] . '</td> <td>' . $detail['jr_pj_number'] . '</td> <td align="right">' . ($detail['deb_montant'] > 0 ? nbm($detail['deb_montant']) : '') . '</td> <td align="right">' . ($detail['cred_montant'] > 0 ? nbm($detail['cred_montant']) : '') . '</td> <td align="right">' . nbm(abs($solde)) . $side . '</td>
echo td(""); } else { echo td(""); echo td(nbm($row['j_montant']), ' style="text-align:right"'); $amount_cred = bcadd($amount_cred, $row['j_montant']); $prog = bcsub($prog, $row['j_montant']); } $side = " " . $fiche->get_amount_side($prog); echo td(nbm($prog) . $side, 'style="text-align:right"'); $html_let = ""; if ($row['letter'] != -1) { $span_error = ""; if ($row['letter_diff'] != 0) { $span_error = $g_failed; } echo '<td>' . HtmlInput::show_reconcile("", $html_letter, $span_error) . '</td>'; } else { echo td(''); } echo '</tr>'; } echo '</table>'; echo '<table>'; echo '<tr>'; echo td(_('Debit')); echo td(nbm($amount_deb), ' style="font-weight:bold;text-align:right"'); echo '</tr>'; echo '<tr>'; echo td(_('Credit')); echo td(nbm($amount_cred), ' style="font-weight:bold;text-align:right"'); echo '</tr>';
function HtmlTable($p_array = null, $op_let = 0, $from_div = 1) { if ($p_array == null) { $p_array = $_REQUEST; } $progress = 0; // if from_periode is greater than to periode then swap the values if (cmpDate($p_array['from_periode'], $p_array['to_periode']) > 0) { $tmp = $p_array['from_periode']; $p_array['from_periode'] = $p_array['to_periode']; $p_array['to_periode'] = $tmp; } list($array, $tot_deb, $tot_cred) = $this->get_row_date($p_array['from_periode'], $p_array['to_periode'], $op_let); if (count($this->row) == 0) { return -1; } $rep = ""; if ($from_div == 1) { echo "<TABLE class=\"resultfooter\" style=\"margin:1%;width:98%;;border-collapse:separate;border-spacing:0px 5px\">"; } else { echo "<TABLE id=\"tb" . $from_div . "\"class=\"result\" style=\"margin:1%;width:98%;border-collapse:separate;border-spacing:0px 2px\">"; } echo '<tbody>'; echo "<TR>" . "<TH style=\"text-align:left\">" . _('Date') . "</TH>" . "<TH style=\"text-align:left\">" . _('n° pièce') . " </TH>" . "<TH style=\"text-align:left\">" . _('Code interne') . " </TH>" . "<TH style=\"text-align:left\">" . _('Description') . " </TH>" . "<TH style=\"text-align:right\">" . _('Débit') . " </TH>" . "<TH style=\"text-align:right\">" . _('Crédit') . " </TH>" . th('Prog.', 'style="text-align:right"') . th('Let.', 'style="text-align:right"'); "</TR>"; $old_exercice = ""; $sum_deb = 0; $sum_cred = 0; bcscale(2); $idx = 0; foreach ($this->row as $op) { $vw_operation = sprintf('<A class="detail" style="text-decoration:underline;color:red" HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s</A>', $op['jr_id'], dossier::id(), $op['jr_internal']); $let = ''; $html_let = ""; if ($op['letter'] != -1) { $let = strtoupper(base_convert($op['letter'], 10, 36)); $html_let = HtmlInput::show_reconcile($from_div, $let); } $tmp_diff = bcsub($op['deb_montant'], $op['cred_montant']); /* * reset prog. balance to zero if we change of exercice */ if ($old_exercice != $op['p_exercice']) { if ($old_exercice != '') { $progress = bcsub($sum_deb, $sum_cred); $side = " " . $this->get_amount_side($progress); echo "<TR class=\"highlight\">" . "<TD>{$old_exercice}</TD>" . td('') . "<TD></TD>" . "<TD>Totaux</TD>" . "<TD style=\"text-align:right\">" . nbm($sum_deb) . "</TD>" . "<TD style=\"text-align:right\">" . nbm($sum_cred) . "</TD>" . td(nbm(abs($progress)) . $side, 'style="text-align:right"') . td('') . "</TR>"; $sum_cred = 0; $sum_deb = 0; $progress = 0; } } $progress = bcadd($progress, $tmp_diff); $side = " " . $this->get_amount_side($progress); $sum_cred = bcadd($sum_cred, $op['cred_montant']); $sum_deb = bcadd($sum_deb, $op['deb_montant']); if ($idx % 2 == 0) { $class = 'class="odd"'; } else { $class = ' class="even"'; } $idx++; echo "<TR {$class} name=\"tr_" . $let . "_" . $from_div . "\">" . "<TD>" . smaller_date(format_date($op['j_date_fmt'])) . "</TD>" . td(h($op['jr_pj_number'])) . "<TD>" . $vw_operation . "</TD>" . "<TD>" . h($op['description']) . "</TD>" . "<TD style=\"text-align:right\">" . nbm($op['deb_montant']) . "</TD>" . "<TD style=\"text-align:right\">" . nbm($op['cred_montant']) . "</TD>" . td(nbm(abs($progress)) . $side, 'style="text-align:right"') . td($html_let, ' style="text-align:right"') . "</TR>"; $old_exercice = $op['p_exercice']; } $solde_type = $sum_deb > $sum_cred ? "solde débiteur" : "solde créditeur"; $diff = abs(bcsub($sum_deb, $sum_cred)); echo '<tfoot>'; echo "<TR class=\"highlight\">" . "<TD>Totaux</TD>" . "<TD ></TD>" . "<TD ></TD>" . "<TD></TD>" . "<TD style=\"text-align:right\">" . nbm($sum_deb) . "</TD>" . "<TD style=\"text-align:right\">" . nbm($sum_cred) . "</TD>" . "<TD style=\"text-align:right\">" . nbm($diff) . "</TD>" . "</TR>"; echo "<TR style=\"font-weight:bold\">" . "<TD>{$solde_type}</TD>" . "<TD style=\"text-align:right\">" . nbm($diff) . "</TD>" . "<TD></TD>" . "</TR>"; echo '</tfoot>'; echo '</tbody>'; echo "</table>"; return 0; }