Logo Search packages:      
Sourcecode: fibusql version File versions  Download package

ledger-account.inc

<?php
/*
    FibuSQL 0.4.1  -  (c) 2003 Martin Pitt <martin@piware.de>

    This software is protected by the GNU General Public License (see
    file COPYING).

    This file gets included from ledger.php.
*/

$myurl = $HTTP_SERVER_VARS['PHP_SELF'];

if( $account != 0 ) {
    echo "<p>$LANG_subaccof <a href=\"$myurl?account=$accdata[0]";
    if( $showcumul ) echo '&amp;cumulative=yes';
    if( $sort ) echo '&amp;order=', $HTTP_GET_VARS['order'];
    echo "\">$accdata[0] - $parentname</a></p>\n";
}

$l = ledger_account( $account, $sort );
check_res( $l, $LANG_err_balsubaccs );

echo '<p>', $LANG_clicksort, "</p>\n";


$sortlink = '&amp;account='.$account;
if( $showcumul ) $sortlink .= '&amp;cumulative=yes';
?>

  <table class="booktbl">
    <tr>
      <th class="num"><a href="<?php echo $myurl ?>?order=debcred<?php echo $sortlink, '">', $LANG_debit ?></a></th>
      <th class="num"><a href="<?php echo $myurl ?>?order=debcred<?php echo $sortlink, '">', $LANG_credit ?></a></th>
      <th><a href="<?php echo $myurl ?>?order=desc<?php echo $sortlink, '">', $LANG_desc ?></a></th>
      <th><a href="<?php echo $myurl ?>?order=time<?php echo $sortlink, '">', $LANG_time ?></a>
          <a href="<?php echo $myurl ?>?order=rtime<?php echo $sortlink, '">[', $LANG_rtime ?>]</a></th>
      <th><a href="<?php echo $myurl ?>?order=receipt<?php echo $sortlink, '">', $LANG_receipt ?></a></th>
      <?php if( $showcumul ) 
        echo '      <th class="num">', $LANG_cumulativebalcolheader, "</th>\n";
      ?>
    </tr>
<?php
    
    $cumul = 0;
    for( $row = reset( $l ); $row != FALSE; $row = next( $l ) ) {
      if( $accdata[1] == 0 || $accdata[1] == 1 )
          $cumul += $row[0];
      else
          $cumul -= $row[0];
      if( $row[5] == -1 ) { # account balance
          if( $account == 0 ) continue; # skip balance on balance sheet
          if( $row[4] == 2 || $row[4] == 3 ) {
            if( $row[0] >= 0 )
                echo '<tr><td class="num"><strong>', formatval( $row[0] ), '</strong></td><td></td>';
            else
                echo '<tr><td></td><td class="negnum"><strong>', formatval( -$row[0] ), '</strong></td>';
          } else {
            if( $row[0] <= 0 )
                echo '<tr><td></td><td class="num"><strong>', formatval( -$row[0] ), '</strong></td>';
            else
                echo '<tr><td class="negnum"><strong>', formatval( $row[0] ), '</strong></td><td></td>';
          }

          echo '<td colspan="', $showcumul ? 4 : 3, '"><strong>', $LANG_balance, "</strong></td></tr>\n";
      } else {
          if( $row[4] == 1 || $row[4] == 4 ) {
            if( $row[0] >= 0 )
                echo '<tr><td class="num">', formatval( $row[0] ), '</td><td></td>';
            else
                echo '<tr><td></td><td class="negnum">', formatval( -$row[0] ), '</td>';
          } else {
            if( $row[0] <= 0 )
                echo '<tr><td></td><td class="num">', formatval( -$row[0] ), '</td>';
            else
                echo '<tr><td class="negnum">', formatval( $row[0] ), '</td><td></td>';
          }

          if( $row[5] ) {
            echo '<td colspan="3"><a href="', $myurl, '?account=', $row[5];
            if( $showcumul ) echo '&amp;cumulative=yes';
            if( $sort ) echo '&amp;order=', $HTTP_GET_VARS['order'];
            echo '">(', $row[5], ') ', htmlq( $row[1] ), '</a></td>';
          } else
            echo '<td><a href="booking.php?id=', $row[6], '">', 
                htmlq( $row[1] ), "</a></td><td>$row[2]</td><td>$row[3]</td>";

          if( $showcumul ) echo '<td class="num">', formatval( $cumul ), '</td>';
          echo "</tr>\n";
      }
    }
?>
  </table>


Generated by  Doxygen 1.6.0   Back to index