コード例 #1
0
function view()
{
    // main layout
    $view = "\n        <h3>Outstanding Bank Account Entries</h3>\n        <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=350>\n        <form action='" . SELF . "' method=post name=form>\n        <input type=hidden name=key value=out>\n        <tr><th>Field</th><th>Value</th></tr>\n        <tr class='bg-odd'><td>Bank Account</td>\n        <td valign=center><select name=bankid>";
    db_connect();
    $sql = "SELECT * FROM bankacct";
    $banks = db_exec($sql);
    if (pg_numrows($banks) < 1) {
        return "<li class=err> There are no bank accounts yet in Cubit.";
    }
    while ($acc = pg_fetch_array($banks)) {
        $branname = branname($acc['div']);
        $view .= "<option value={$acc['bankid']}>{$acc['accname']} - {$acc['bankname']} - {$branname}</option>";
    }
    $view .= "</select></td></tr>\n\t\t<tr><td align=right><input type=button value='&laquo Back' onClick='javascript:history.back()'></td><td align=right><input type=submit value='View &raquo'></td></tr>\n\t\t</table>\n\t\t<p>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $view;
}
コード例 #2
0
function view()
{
    $banksel = "<select name=bankid>";
    db_connect();
    $sql = "SELECT * FROM bankacct";
    $banks = db_exec($sql);
    if (pg_numrows($banks) < 1) {
        return "<li class=err> There are no bank accounts yet in Cubit.";
    }
    while ($acc = pg_fetch_array($banks)) {
        $branname = branname($acc['div']);
        $banksel .= "<option value={$acc['bankid']}>{$acc['accname']} - {$acc['bankname']} - {$branname}</option>";
    }
    $banksel .= "</select>";
    // main layout
    $view = "<h3>View Cash Book Analysis</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t<form action='" . SELF . "' method=post name=form>\n\t<input type=hidden name=key value=viewcash>\n\t<tr><th>Field</th><th>Value</th></tr>\n\t<tr class='bg-odd'><td>Bank Account</td><td valign=center>{$banksel}</td></tr>\n\t<tr class='bg-even'><td>From :</td><td align=center><input type=text size=2 name=fday maxlength=2 value='1'>-<input type=text size=2 name=fmonth maxlength=2  value='" . date("m") . "'>-<input type=text size=4 name=fyear maxlength=4 value='" . date("Y") . "'></td></tr>\n\t<tr class='bg-odd'><td>To :</td><td align=center><input type=text size=2 name=lday maxlength=2 value='" . date("d") . "'>-<input type=text size=2 name=lmonth maxlength=2 value='" . date("m") . "'>-<input type=text size=4 name=lyear maxlength=4 value='" . date("Y") . "'></td></tr>\n\t<tr><td align=right><input type=button value='&laquo Back' onClick='javascript:history.back()'></td><td align=right><input type=submit value='View &raquo'></td></tr>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr><th>Quick Links</th></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $view;
}
コード例 #3
0
function viewCat($type)
{
    // get table name
    core_connect();
    switch ($type) {
        case "I":
            $tab = "Income";
            $name = "Income";
            break;
        case "E":
            $tab = "Expenditure";
            $name = "Expenditure";
            break;
        case "B":
            $tab = "Balance";
            $name = "Balance";
            break;
        default:
            return "<li>Invalid Category type";
    }
    // Set up table to display in
    $view = "<p><h3>{$name}</h3>";
    // get categories
    $sql = "SELECT * FROM {$tab} ORDER BY div ASC";
    $catRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve account category details from database.", SELF);
    $numrows = pg_numrows($catRslt);
    if ($numrows < 1) {
        $view = "<br><h3>{$name}</h3>\n\t\t\t<li>There are no Categories under <b>{$tab}</b>.<br><p><p>";
        return $view;
    }
    # display all categories
    for ($i = 0; $i < $numrows; $i++) {
        $cat = pg_fetch_array($catRslt, $i);
        #get vars from acc as the are in db
        foreach ($cat as $key => $value) {
            ${$key} = $value;
        }
        # alternate bgcolor
        $branname = branname($div);
        $view .= viewacc($type, $catid, $catname, $branname);
    }
    return $view;
}
コード例 #4
0
function view()
{
    # dates drop downs
    $months = array("1" => "January", "2" => "February", "3" => "March", "4" => "April", "5" => "May", "6" => "June", "7" => "July", "8" => "August", "9" => "September", "10" => "October", "11" => "November", "12" => "December");
    $fmonth = extlib_cpsel("fmonth", $months, date("m"));
    $lmonth = extlib_cpsel("lmonth", $months, date("m"));
    // Layout
    $view = "\n        <h3>View Saved Bank Reconciliations</h3>\n        <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=350>\n        <form action='" . SELF . "' method=post name=form>\n        <input type=hidden name=key value=viewsaved>\n        <tr><th>Field</th><th>Value</th></tr>\n        <tr class='bg-odd'><td>Bank Account</td>\n        <td valign=center><select name=bankid>";
    db_connect();
    $sql = "SELECT * FROM bankacct";
    $banks = db_exec($sql);
    $numrows = pg_numrows($banks);
    if (empty($numrows)) {
        return "<li class=err> There are no accounts held at the selected Bank.\n                <p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct Selection'>";
    }
    while ($acc = pg_fetch_array($banks)) {
        $branname = branname($acc['div']);
        $view .= "<option value={$acc['bankid']}>{$acc['accname']} - {$acc['bankname']} - {$branname}</option>";
    }
    $view .= "</select></td></tr>\n\t\t<tr class='bg-odd'><td>From :</td><td valign=center><input type=text name=fday size=2 maxlength=2 value='1'> - {$fmonth} - <input type=text name=fyear size=4 maxlength=4 value=" . date("Y") . "></td></tr>\n\t\t<tr class='bg-even'><td>To :</td><td valign=center><input type=text name=lday size=2 maxlength=2 value='" . date("d") . "'> - {$lmonth} - <input type=text name=lyear size=4 maxlength=4 value=" . date("Y") . "></td></tr>\n\t\t<tr><td><br></td></tr>\n\t\t<tr><td align=right><input type=button value='&laquo Back' onClick='javascript:history.back()'></td><td align=right><input type=submit value='View &raquo'></td></tr>\n        </table>\n        <p>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t        <tr><th>Quick Links</th></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $view;
}
コード例 #5
0
function viewtran($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($prd, "string", 1, 14, "Invalid Period number.");
    if (isset($details)) {
        $v->isOk($accid, "string", 1, 20, "Invalid Account number.");
        $hide = "\n\t\t<input type=hidden name=prd value='{$prd}'>\n\t\t<input type=hidden name=details value='{$details}'>\n\t\t<input type=hidden name=accid value='{$accid}'>";
    } else {
        $v->isOk($topacc, "num", 1, 20, "Invalid Account number.");
        $v->isOk($accnum, "num", 0, 20, "Invalid Account number.");
        $hide = "\n\t\t<input type=hidden name=prd value='{$prd}'>\n\t\t<input type=hidden name=topacc value='{$topacc}'>\n\t\t<input type=hidden name=accnum value='{$accnum}'>";
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class=err>" . $e["msg"];
        }
        $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    if (isset($details)) {
        $accRs = undget("core", "accname, accid, topacc, accnum", "accounts", "accid", $accid);
        $acc = pg_fetch_array($accRs);
    } else {
        if (strlen($accnum) < 2) {
            // account numbers
            $accRs = undget("core", "accname, accid, topacc, accnum", "accounts", "topacc", "{$topacc}' AND accnum = '000");
            if (pg_numrows($accRs) < 1) {
                return "<li> Accounts number : {$accnum} does not exist";
            }
            $acc = pg_fetch_array($accRs);
        } else {
            // account numbers
            $accRs = undget("core", "accname, accid, topacc, accnum", "accounts", "topacc", "{$topacc}' AND accnum = '{$accnum}");
            if (pg_numrows($accRs) < 1) {
                return "<li> Accounts number : {$topacc}/{$accnum} does not exist";
            }
            $acc = pg_fetch_array($accRs);
        }
    }
    db_conn($prd);
    // Set up table to display in
    $OUTPUT = "<center>\n\t<h3>Journal Entries for Account : {$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='80%'>\n\t<tr><th>Date</th><th>Reference</th><th>Contra Acc</th><th>Description</th><th>Debit</th><th>Credit</th><th>User</th></tr>";
    # Get Transactions
    $sql = "SELECT * FROM transect WHERE debit = '{$acc['accid']}' OR credit = '{$acc['accid']}'";
    $tranRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve Transaction details from database.", SELF);
    if (pg_numrows($tranRslt) < 1) {
        $OUTPUT .= "<tr class='bg-odd'><td colspan=10>No Transactions found</td></tr>";
        # counts
        $credtot = 0;
        $debtot = 0;
    } else {
        # counts
        $credtot = 0;
        $debtot = 0;
        # display all transactions
        while ($tran = pg_fetch_array($tranRslt)) {
            #get vars from tran as the are in db
            foreach ($tran as $key => $value) {
                ${$key} = $value;
            }
            if ($debit == $acc['accid']) {
                $cacc = $credit;
                $debitamt = "R " . $amount;
                $debtot += $amount;
                $creditamt = "";
            } else {
                $debitamt = "";
                $creditamt = "R " . $amount;
                $credtot += $amount;
                $cacc = $debit;
            }
            # format date
            $date = explode("-", $date);
            $date = $date[2] . "-" . $date[1] . "-" . $date[0];
            # get contra account name
            $caccRs = undget("core", "div, accname,topacc,accnum", "accounts", "accid", $cacc);
            $cacc = pg_fetch_array($caccRs);
            $branname = branname($cacc['div']);
            $OUTPUT .= "<tr class='bg-odd'><td>{$date}</td><td>{$refnum}</td><td>{$cacc['topacc']}/{$cacc['accnum']} - {$cacc['accname']} - {$branname}</td><td>{$details}</td><td>{$debitamt}</td><td>{$creditamt}</td><td>{$author}</td></tr>";
        }
    }
    $OUTPUT .= "<tr class='bg-even'><td colspan=4><b>Total</b></td><td><b>" . CUR . " {$debtot}</b></td><td><b>" . CUR . " {$credtot}</b></td><td></td></tr>\n\t<tr><td><br></td></tr>\n\n\t<!--\n\t<tr><td align=center colspan=10>\n\t\t\t<form action='../xls/acc-trans-xls.php' method=post name=form>\n\t\t\t<input type=hidden name=key value=viewtran>\n\t\t\t{$hide}\n\t\t\t<input type=submit name=xls value='Export to spreadsheet'>\n\t\t\t</form>\n\t</td></tr>\n\t-->\n\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=25%>\n\t\t<tr><td><br></td></tr>\n\t\t<tr><th>Quick Links</th></tr>\n\t\t<tr class=datacell><td align=center><a target=_blank href='../core/acc-new2.php'>Add account (New Window)</a></td></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $OUTPUT;
}
コード例 #6
0
function print_saveacc($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    // Set up table to display in
    $OUTPUT = "\n        <center>\n        <h3>Trial Balance as at : " . date("d M Y") . "</h3>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=450>\n        <tr><th>Account Number</th><th>Account Name</th><th>Debit</th><th>Credit</th></tr>";
    // Connect to database
    core_connect();
    $sql = "SELECT * FROM trial_bal ORDER BY topacc, accnum ASC";
    $accRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve account details from database.", SELF);
    $numrows = pg_numrows($accRslt);
    if ($numrows < 1) {
        $OUTPUT = "There are no Accounts yet in Cubit.";
        require "../template.php";
    }
    # display all Accounts
    $i = 0;
    $tldebit = 0;
    $tlcredit = 0;
    if ($zero == "no") {
        while ($acc = pg_fetch_array($accRslt)) {
            $i++;
            if (intval($acc['debit']) == 0 && intval($acc['credit']) == 0) {
                $i++;
                continue;
            }
            $branname = branname($acc['div']);
            $OUTPUT .= "<tr class='" . bg_class() . "'><td>{$acc['div']} - {$acc['topacc']}/{$acc['accnum']}</td><td>{$branname} - {$acc['accname']}</td>";
            if (intval($acc['debit']) == 0) {
                $OUTPUT .= "<td align=center> - </td>";
            } else {
                $OUTPUT .= "<td align=center>" . CUR . " {$acc['debit']}</td>";
            }
            if (intval($acc['credit']) == 0) {
                $OUTPUT .= "<td align=center> - </td>";
            } else {
                $OUTPUT .= "<td align=center>" . CUR . " {$acc['credit']}</td>";
            }
            $OUTPUT .= "</tr>";
            $tldebit += $acc['debit'];
            $tlcredit += $acc['credit'];
        }
    } elseif ($zero == "yes") {
        while ($acc = pg_fetch_array($accRslt)) {
            $i++;
            $branname = branname($acc['div']);
            $OUTPUT .= "<tr class='" . bg_class() . "'><td>{$acc['div']} - {$acc['topacc']}/{$acc['accnum']}</td><td>{$branname} - {$acc['accname']}</td>";
            if (intval($acc['debit']) == 0) {
                $OUTPUT .= "<td align=center> - </td>";
            } else {
                $OUTPUT .= "<td align=center>" . CUR . " {$acc['debit']}</td>";
            }
            if (intval($acc['credit']) == 0) {
                $OUTPUT .= "<td align=center> - </td>";
            } else {
                $OUTPUT .= "<td align=center>" . CUR . " {$acc['credit']}</td>";
            }
            $OUTPUT .= "</tr>";
            $tldebit += $acc['debit'];
            $tlcredit += $acc['credit'];
        }
    }
    $OUTPUT .= "<tr class='" . bg_class() . "'><td colspan=2><b>Total</b></td><td align=center><b>" . CUR . " {$tldebit}</b></td><td align=center><b>" . CUR . " {$tlcredit}</b></td></tr>\n\t\t</table><br>";
    $output = base64_encode($OUTPUT);
    core_connect();
    $sql = "INSERT INTO save_trial_bal(gendate, output, div) VALUES('" . date("Y-m-d") . "', '{$output}', '" . USER_DIV . "')";
    $Rs = db_exec($sql) or errdie("Unable to save the Trial Balance.");
    $OUTPUT .= "\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=25%>\n\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $OUTPUT;
}
コード例 #7
0
function viewtrans($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    # Search by date
    if ($search == "date") {
        $v->isOk($from_day, "num", 1, 2, "Invalid from Date day.");
        $v->isOk($from_month, "num", 1, 2, "Invalid from Date month.");
        $v->isOk($from_year, "num", 1, 4, "Invalid from Date Year.");
        $v->isOk($to_day, "num", 1, 2, "Invalid to Date day.");
        $v->isOk($to_month, "num", 1, 2, "Invalid to Date month.");
        $v->isOk($to_year, "num", 1, 4, "Invalid to Date Year.");
        # mix dates
        $fromdate = $from_year . "-" . $from_month . "-" . $from_day;
        $todate = $to_year . "-" . $to_month . "-" . $to_day;
        if (!checkdate($from_month, $from_day, $from_year)) {
            $v->isOk($fromdate, "num", 1, 1, "Invalid from date.");
        }
        if (!checkdate($to_month, $to_day, $to_year)) {
            $v->isOk($todate, "num", 1, 1, "Invalid to date.");
        }
        $hide = "\n\t\t\t<input type=hidden name=prd value='{$prd}'>\n\t\t\t<input type=hidden name=search value='{$search}'>\n\t\t\t<input type=hidden name=fday value='{$fday}'>\n\t\t\t<input type=hidden name=fmon value='{$fmon}'>\n\t\t\t<input type=hidden name=fyear value='{$fyear}'>\n\t\t\t<input type=hidden name=today value='{$today}'>\n\t\t\t<input type=hidden name=tomon value='{$tomon}'>\n\t\t\t<input type=hidden name=toyear value='{$toyear}'>";
        # Create the Search SQL
        $search = "SELECT * FROM transect WHERE date >= '{$fromdate}' AND date <= '{$todate}' ORDER BY refnum ASC";
    }
    # Search by refnum
    if ($search == "refnum") {
        $v->isOk($fromnum, "num", 1, 20, "Invalid 'from' ref  number.");
        $v->isOk($tonum, "num", 1, 20, "Invalid 'to' ref  number.");
        $hide = "\n\t\t\t<input type=hidden name=prd value='{$prd}'>\n\t\t\t<input type=hidden name=search value='{$search}'>\n\t\t\t<input type=hidden name=fromnum value='{$fromnum}'>\n\t\t\t<input type=hidden name=tonum value='{$tonum}'>";
        # Create the Search SQL
        $search = "SELECT * FROM transect WHERE refnum >= {$fromnum} AND refnum <= {$tonum} ORDER BY refnum ASC";
    }
    # View all
    if ($search == "all") {
        $hide = "\n\t\t\t<input type=hidden name=prd value='{$prd}'>\n\t\t\t<input type=hidden name=search value='{$search}'>";
        # Create the Search SQL
        $search = "SELECT * FROM transect ORDER BY refnum ASC";
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class=err>" . $e["msg"];
        }
        $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    // Layout
    $OUTPUT = "<center>\n\t\t<h3>Journal Entries Report</h3>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='100%'>\n        <tr><th>Date</th><th>Debit</th><th>Credit</th><th>Ref No</th><th>Amount</th><th>Details</th><th>Authorised By</th></tr>";
    db_conn($prd);
    $tranRslt = db_exec($search) or errDie("ERROR: Unable to retrieve Transaction details from database.", SELF);
    if (pg_numrows($tranRslt) < 1) {
        return "<li> There are no Transactions in the selected Period.<br><br>\n\t\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=25%>\n\t\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t\t<tr class=datacell><td align=center><a target=_blank href='../core/acc-new2.php'>Add account (New Window)</a></td></tr>\n\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t</table>";
    }
    # display all transaction
    while ($tran = pg_fetch_array($tranRslt)) {
        # get vars from tran as the are in db
        foreach ($tran as $key => $value) {
            ${$key} = $value;
        }
        # format date
        $date = explode("-", $date);
        $date = $date[2] . "-" . $date[1] . "-" . $date[0];
        # Get account names
        $deb = undget("core", "div,accname, topacc, accnum", "accounts", "accid", $debit);
        $debacc = pg_fetch_array($deb);
        $ct = undget("core", "div,accname, topacc,accnum", "accounts", "accid", $credit);
        $ctacc = pg_fetch_array($ct);
        $dtbranname = branname($debacc['div']);
        $ctbranname = branname($ctacc['div']);
        $OUTPUT .= "<tr class='bg-odd'><td>{$date}</td><td>{$debacc['topacc']}/{$debacc['accnum']}&nbsp;&nbsp;&nbsp;{$debacc['accname']} - {$dtbranname}</td><td>{$ctacc['topacc']}/{$ctacc['accnum']}&nbsp;&nbsp;&nbsp;{$ctacc['accname']} - {$ctbranname}</td><td>{$refnum}</td><td>" . CUR . " {$amount}</td><td>{$details}</td><td>{$author}</td></tr>";
    }
    $OUTPUT .= "\n\t\t<tr><td><br></td></tr>\n\n\t\t<!--\n\t\t<tr><td align=center colspan=10>\n\t\t\t<form action='../xls/alltrans-xls.php' method=post name=form>\n\t\t\t<input type=hidden name=key value=viewtrans>\n\t\t\t{$hide}\n\t\t\t<input type=submit name=xls value='Export to spreadsheet'>\n\t\t\t</form>\n\t\t</td></tr>\n\t\t-->\n\n\t\t</table>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=25%>\n\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t<tr class=datacell><td align=center><a target=_blank href='../core/acc-new2.php'>Add account (New Window)</a></td></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n        </table>";
    return $OUTPUT;
}
コード例 #8
0
function viewtran($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($fprd, "string", 1, 14, "Invalid Starting Period number.");
    $v->isOk($tprd, "string", 1, 14, "Invalid Ending Period number.");
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class=err>" . $e["msg"];
        }
        $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # dates drop downs
    $months = array("1" => "January", "2" => "February", "3" => "March", "4" => "April", "5" => "May", "6" => "June", "7" => "July", "8" => "August", "9" => "September", "10" => "October", "11" => "November", "12" => "December");
    if ($tprd < $fprd) {
        return "<li class=err> Invalid Period range : {$months[$fprd]} to {$months[$tprd]}";
    }
    // Set up table to display in
    $OUTPUT = "<center>\n\t<h3>Journal Entries : {$months[$fprd]} - {$months[$tprd]}</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='100%'>\n\t<tr><th>Date</th><th>Debit</th><th>Credit</th><th>Ref No</th><th>Amount</th><th>Details</th><th>User</th></tr>";
    # counts
    $credtot = 0;
    $debtot = 0;
    # Get Transactions
    for ($i = $fprd; $i <= $tprd; $i++) {
        db_conn($i);
        $sql = "SELECT * FROM transect";
        $tranRslt = db_exec($sql) or errDie("ERROR: Unable to retrieve Transaction details from database.", SELF);
        if (pg_numrows($tranRslt) < 1) {
            continue;
        } else {
            # display all transactions
            while ($tran = pg_fetch_array($tranRslt)) {
                #get vars from tran as the are in db
                foreach ($tran as $key => $value) {
                    ${$key} = $value;
                }
                # format date
                $date = explode("-", $date);
                $date = $date[2] . "-" . $date[1] . "-" . $date[0];
                // get account names
                $deb = undget("core", "div, accname, topacc, accnum", "accounts", "accid", $debit);
                $debacc = pg_fetch_array($deb);
                $ct = undget("core", "div, accname, topacc,accnum", "accounts", "accid", $credit);
                $ctacc = pg_fetch_array($ct);
                $dtbranname = branname($debacc['div']);
                $ctbranname = branname($ctacc['div']);
                $OUTPUT .= "<tr class='bg-odd'><td>{$date}</td><td>{$debacc['topacc']}/{$debacc['accnum']} - {$debacc['accname']} - {$dtbranname}</td><td>{$ctacc['topacc']}/{$ctacc['accnum']} - {$ctacc['accname']} - {$ctbranname}</td><td>{$refnum}</td><td>" . CUR . " {$amount}</td><td>{$details}</td><td>{$author}</td></tr>";
            }
        }
    }
    $OUTPUT .= "\n\t<tr><td><br></td></tr>\n\n\t<!--\n\t<tr><td align=center colspan=10>\n\t\t<form action='../xls/alltrans-prd-xls.php' method=post name=form>\n\t\t<input type=hidden name=key value=viewtran>\n\t\t<input type=hidden name=fprd value='{$fprd}'>\n\t\t<input type=hidden name=tprd value='{$tprd}'>\n\t\t<input type=submit name=xls value='Export to spreadsheet'>\n\t\t</form>\n\t</td></tr>\n\t-->\n\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=25%>\n\t\t<tr><td><br></td></tr>\n\t\t<tr><th>Quick Links</th></tr>\n\t\t<tr class=datacell><td align=center><a target=_blank href='../core/acc-new2.php'>Add account (New Window)</a></td></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $OUTPUT;
}
コード例 #9
0
function save_inc($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # connect to core DB
    core_connect();
    # get the income statement settings
    $sql = "SELECT accid FROM accounts WHERE acctype = 'I' ORDER BY accname ASC";
    $incRslt = db_exec($sql) or errDie("Unable to retrieve income statement settings from the Database", SELF);
    if (pg_numrows($incRslt) < 1) {
        return "<center>There are no accounts under income on the income statement Settings table.<br>Please Set the Income Statement";
    }
    // Set up the Table to display in
    $income = "<center><h3>Income Statement as at : " . date("d M Y") . "</h3>\n\t\t<table cellpadding='3' cellspacing='0' border=1 bordercolor='#000000' width=750>\n        <tr><th width=70%>Account Name</th><th>Amount</th></tr>\n        <tr><td colspan=3><h3>Income</h3></td></tr>";
    # get account Balances
    $tlinc = 0;
    // total income credit
    $i = 0;
    while ($inc = pg_fetch_array($incRslt)) {
        core_connect();
        # get the balances (debit nad credit) from trial Balance
        $sql = "SELECT * FROM trial_bal WHERE accid = '{$inc['accid']}' ORDER BY accname ASC";
        $balRslt = db_exec($sql) or errDie("Unable to retrieve Account Balance information from the Database.", SELF);
        $bal = pg_fetch_array($balRslt);
        $total = $bal['credit'] - $bal['debit'];
        if ($zero == "no") {
            if (intval($total == 0)) {
                $i++;
                continue;
            }
        }
        $tlinc += $total;
        $branname = branname($bal['div']);
        $income .= "<tr><td>{$branname} - {$bal['accname']}</td><td align=center>" . CUR . " {$total}</td></tr>";
        $i++;
    }
    $tlinc = sprint($tlinc);
    # Write totals for income
    $income .= "<tr><td><b>Total<b></td><td align=center><b>" . CUR . " {$tlinc}</b></td></tr>";
    core_connect();
    # Get the income statement settings
    $sql = "SELECT accid FROM accounts WHERE acctype='E' ORDER BY accname ASC";
    $expRslt = db_exec($sql) or errDie("Unable to retrieve income statement Settings from the Database", SELF);
    if (pg_numrows($expRslt) < 1) {
        return "<center>There are no accounts under Expenditures on the income statement Settings table.<br>Please Set the Income Statement";
    }
    $income .= "<tr><td colspan=3><h3>Expenditure</h3></td></tr>";
    # get account Balances for Expenditure
    $tlexp = 0;
    // total expenditures
    $i = 0;
    while ($exp = pg_fetch_array($expRslt)) {
        core_connect();
        # get the balances (debit nad credit) from trial Balance
        $sql = "SELECT * FROM trial_bal WHERE accid = '{$exp['accid']}' ORDER BY accname ASC";
        $balRslt = db_exec($sql) or errDie("Unable to retrieve Account Balance information from the Database.", SELF);
        $bal = pg_fetch_array($balRslt);
        $total = $bal['debit'] - $bal['credit'];
        if ($zero == "no") {
            if (intval($total == 0)) {
                $i++;
                continue;
            }
        }
        $tlexp += $total;
        // And increment the balance for expenditure
        $branname = branname($bal['div']);
        $income .= "<tr><td>{$branname} - {$bal['accname']}</td><td align=center>" . CUR . " {$total}</td></tr>";
        $i++;
    }
    $tlexp = sprint($tlexp);
    $income .= "<tr><td><b>Total<b></td><td align=center><b>" . CUR . " {$tlexp}</b></td></tr>\n\t\t<tr><td colspan=3><br></td></tr>";
    # Calculate Profit/Loss
    $income .= "<tr><td><b>Nett Profit Carried Forward<b></td><td align=center colspan=2><b>" . CUR . " " . sprint($tlinc - $tlexp) . "</b></td></tr>\n\t\t<tr><td><br></td></tr>\n\t\t</table>";
    $output = base64_encode($income);
    core_connect();
    $sql = "INSERT INTO save_income_stmnt(gendate, output, div) VALUES('" . date("Y-m-d") . "', '{$output}', '" . USER_DIV . "')";
    $Rs = db_exec($sql) or errdie("Unable to save the Income Statement.");
    $income .= "\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=20%>\n\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t<tr class=datacell><td align=center><a target=_blank href='../core/acc-new2.php'>Add account (New Window)</a></td></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $income;
}