当前位置: 首页>>代码示例>>PHP>>正文


PHP slctacc函数代码示例

本文整理汇总了PHP中slctacc函数的典型用法代码示例。如果您正苦于以下问题:PHP slctacc函数的具体用法?PHP slctacc怎么用?PHP slctacc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了slctacc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: confirm

function confirm($_POST)
{
    # Get vars
    extract($_POST);
    if (isset($back)) {
        return slctacc($_POST);
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($supid, "num", 1, 50, "Invalid Supplier number.");
    $v->isOk($accid, "num", 1, 50, "Invalid Contra Account.");
    $v->isOk($refnum, "num", 1, 10, "Invalid Reference number.");
    $v->isOk($amount, "float", 1, 20, "Invalid Amount.");
    $v->isOk($details, "string", 0, 255, "Invalid Details.");
    $v->isOk($author, "string", 1, 30, "Invalid Authorising person name.");
    $datea = explode("-", $date);
    if (count($datea) == 3) {
        if (!checkdate($datea[1], $datea[0], $datea[2])) {
            $v->isOk($date, "num", 1, 1, "Invalid date.");
        }
    } else {
        $v->isOk($date, "num", 1, 1, "Invalid date.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # Get contra account details
    $accRs = get("core", "*", "accounts", "accid", $accid);
    $acc = pg_fetch_array($accRs);
    # Select supplier
    db_connect();
    $sql = "SELECT * FROM suppliers WHERE supid = '{$supid}' AND div = '" . USER_DIV . "'";
    $suppRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
    if (pg_numrows($suppRslt) < 1) {
        return "<li class='err'>Invalid supplier ID, or supplier has been blocked</li>";
    } else {
        $supp = pg_fetch_array($suppRslt);
    }
    # Probe tran type
    if ($entry == "CT") {
        $tran = "\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</td>\n\t\t\t\t\t\t\t<td>{$supp['supno']} - {$supp['supname']}</td>\n\t\t\t\t\t\t</tr>";
    } else {
        $tran = "\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>{$supp['supno']} - {$supp['supname']}</td>\n\t\t\t\t\t\t\t<td>{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}</td>\n\t\t\t\t\t\t</tr>";
    }
    // Layout
    $confirm = "\n\t\t\t<h3>Record Journal transaction</h3>\n\t\t\t<h4>Confirm entry</h4>\n\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t\t<input type='hidden' name='supid' value='{$supid}'>\n\t\t\t\t<input type='hidden' name='accid' value='{$accid}'>\n\t\t\t\t<input type='hidden' name='accname' value='{$acc['accname']}'>\n\t\t\t\t<input type='hidden' name='date' value='{$date}'>\n\t\t\t\t<input type='hidden' name='refnum' value='{$refnum}'>\n\t\t\t\t<input type='hidden' name='entry' value='{$entry}'>\n\t\t\t\t<input type='hidden' name='amount' value='{$amount}'>\n\t\t\t\t<input type='hidden' name='details' value='{$details}'>\n\t\t\t\t<input type='hidden' name='author' value='{$author}'>\n\t\t\t\t<input type='hidden' name='date_day' value='{$date_day}'>\n\t\t\t\t<input type='hidden' name='date_month' value='{$date_month}'>\n\t\t\t\t<input type='hidden' name='date_year' value='{$date_year}'>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<td width='50%'><h3>Debit</h3></td>\n\t\t\t\t\t<td width='50%'><h3>Credit</h3></td>\n\t\t\t\t</tr>\n\t\t\t\t{$tran}\n\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Date</td>\n\t\t\t\t\t<td>{$date}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Referance number</td>\n\t\t\t\t\t<td>{$refnum}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Amount</td>\n\t\t\t\t\t<td>" . CUR . " {$amount}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Details</td>\n\t\t\t\t\t<td>{$details}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>Authorising Person</td>\n\t\t\t\t\t<td>{$author}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><input type='submit' name='back' value='&laquo; Correction'></td>\n\t\t\t\t\t<td align='right'><input type='submit' value='Write &raquo'></td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</form>\n\t\t\t<p>\n\t\t\t<table border='0' cellpadding='2' cellspacing='1' width='15%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t<td align='center'><a href='../core/trans-new.php'>Journal Transactions</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td align='center'><a href='../supp-view.php'>View Suppliers</a></td>\n\t\t\t\t</tr>\n\t\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t\t</table>";
    return $confirm;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:56,代码来源:record-creditor-trans.php

示例2: write

function write($_POST)
{
    # Get vars
    extract($_POST);
    if (isset($back)) {
        return slctacc($_POST);
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $date = $date_year . "-" . $date_month . "-" . $date_day;
    if (!checkdate($date_month, $date_day, $date_year)) {
        $v->isOk($date, "num", 1, 1, "Invalid date.");
    }
    foreach ($accid as $key => $value) {
        $dtamount[$key] += 0;
        $ctamount[$key] += 0;
        if ($dtamount[$key] > 0 || $ctamount[$key] > 0) {
            $v->isOk($accid[$key], "num", 1, 50, "Invalid Account to be Debited.[{$key}]");
            $v->isOk($dtamount[$key], "float", 1, 20, "Invalid Debit Amount.[{$key}]");
            $v->isOk($ctamount[$key], "float", 1, 20, "Invalid Credit Amount.[{$key}]");
            $v->isOk($descript[$key], "string", 0, 255, "Invalid Details.[{$key}]");
        }
    }
    # display errors, if any
    if ($v->isError()) {
        $write = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $write .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $write .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $write;
    }
    foreach ($accid as $key => $value) {
        # begin sql transaction
        pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
        if ($dtamount[$key] > 0) {
            writetrans($accid[$key], $account, $date, $refnum, $dtamount[$key], $descript[$key]);
        } elseif ($ctamount[$key] > 0) {
            writetrans($account, $accid[$key], $date, $refnum, $ctamount[$key], $descript[$key]);
        }
        pglib_transaction("COMMIT") or errDie("Unable to finish a database transaction.", SELF);
    }
    // Start layout
    $write = "\n\t\t<center>\n\t\t<h3>Journal transactions have been recorded.</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Account</th>\n\t\t\t\t<th>Description</th>\n\t\t\t\t<th>Debit</th>\n\t\t\t\t<th>Credit</th>\n\t\t\t</tr>";
    foreach ($accid as $key => $value) {
        if ($dtamount[$key] > 0 || $ctamount[$key] > 0) {
            core_connect();
            $accRss = get("core", "*", "accounts", "accid", $accid[$key]);
            if (pg_numrows($accRss) < 1) {
                return "<li> Accounts to be debited does not exist.</li>";
            }
            $acc_each[$key] = pg_fetch_array($accRss);
            $write .= "\n\t\t\t\t<tr bgcolor=" . bgcolorg() . ">\n\t\t\t\t\t<td valign='center'>" . $acc_each[$key]['accname'] . "</td>\n\t\t\t\t\t<td>{$descript[$key]}</td>\n\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($dtamount[$key]) . "</td>\n\t\t\t\t\t<td nowrap>" . CUR . " " . sprint($ctamount[$key]) . "</td>\n\t\t\t\t</tr>";
        }
    }
    $write .= "\n\t\t</table>\n\t\t<br>\n\t\t<table " . TMPL_tblDflts . " width='25%'>\n\t\t\t<tr>\n\t\t\t\t<th>Quick Links</th>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='../reporting/index-reports.php'>Financials</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='trans-new.php'>Journal Transaction</td>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='batch-view.php'>View batch file</td>\n\t\t\t</tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $write;
}
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:60,代码来源:multi-account-trans.php

示例3: viewtran

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($accnt)) {
        if ($accnt == 'slct') {
            if (isset($cusnums)) {
                foreach ($cusnums as $key => $cusnum) {
                    $v->isOk($cusnum, "num", 1, 20, "Invalid Customer number.");
                }
            } else {
                return "<li class=err>Please select at least one Debtor.</li>" . slctacc();
            }
        }
    } else {
        $v->isOk("###", "num", 0, 0, "ERROR : Invalid Accounts Selection.");
    }
    # 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;
    }
    # Get the ids
    if ($accnt == 'all') {
        $cusnums = array();
        db_connect();
        $sql = "SELECT cusnum FROM customers WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $cusnums[] = $ac['cusnum'];
            }
        } else {
            return "<li calss=err> There are no customers yet in Cubit.";
        }
    }
    # Period name
    $prdname = prdname($prd);
    $hide = "";
    $trans = "";
    foreach ($cusnums as $key => $cusnum) {
        $cusRs = get("cubit", "cusname, surname, accno, balance", "customers", "cusnum", $cusnum);
        $cus = pg_fetch_array($cusRs);
        $idRs = get($prd, "min(id)", "custledger", "cusnum", $cusnum);
        $id = pg_fetch_array($idRs);
        if ($id['min'] != 0) {
            $balRs = get($prd, "(cbalance-credit) AS cbalance,(dbalance-debit) AS dbalance", "custledger", "id", $id['min']);
            $bal = pg_fetch_array($balRs);
            $bal['cbalance'] += 0;
            $bal['dbalance'] += 0;
        } else {
            $balRs = get("cubit", "balance", "customers", "cusnum", $cusnum);
            $bal = pg_fetch_array($balRs);
            $bal['balance'] += 0;
            if ($bal['balance'] > 0) {
                $bal['dbalance'] = $bal['balance'];
                $bal['cbalance'] = 0;
            } else {
                $bal['cbalance'] = $bal['balance'] * -1;
                $bal['dbalance'] = 0;
            }
            //$bal['dbalance'] += $amount;
        }
        # Total balance changes
        if ($bal['dbalance'] > $bal['cbalance']) {
            $bal['dbalance'] = $bal['dbalance'] - $bal['cbalance'];
            $bal['cbalance'] = 0;
        } elseif ($bal['cbalance'] > $bal['dbalance']) {
            $bal['cbalance'] = $bal['cbalance'] - $bal['dbalance'];
            $bal['dbalance'] = 0;
        } else {
            $bal['cbalance'] = 0;
            $bal['dbalance'] = 0;
        }
        $bal['credit'] = sprint($bal['cbalance']);
        $bal['debit'] = sprint($bal['dbalance']);
        $balance = sprint($bal['dbalance'] - $bal['cbalance']);
        $hide .= "<input type=hidden name=cusnums[] value='{$cusnum}'>";
        $trans .= "<tr><td colspan=8><b>{$cus['accno']} - {$cus['cusname']} {$cus['surname']}</b></td></tr>";
        $trans .= "<tr><td colspan=2><br></td><td>Br/Forwd</td><td>Brought Forward</td><td align=right>{$bal['debit']}</td><td align=right>{$bal['credit']}</td><td align=right>{$balance}</td><td> </td></tr>";
        # --> Transaction reading comes here <--- #
        $dbal['debit'] = 0;
        $dbal['credit'] = 0;
        if ($t == "s") {
            $tranRs = get($prd, "*", "custledger", "cusnum", $cusnum, "ORDER BY id");
        } else {
            $tranRs = get($prd, "*", "custledger", "cusnum", $cusnum, "ORDER BY edate,id");
        }
        while ($tran = pg_fetch_array($tranRs)) {
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:cust-ledger-xls.php

示例4: import_csv_file

function import_csv_file($_POST)
{
    extract($_POST);
    $file = file($_FILES['import_file']['tmp_name']);
    if (!is_array($file) or count($file) < 1) {
        return slctacc(array(), "<li class='err'>Please Ensure File Format Is Correct.</li><br>");
    }
    $refnum = getrefnum();
    foreach ($file as $line) {
        $cleanline = trim($line);
        if (strlen($cleanline) < 8) {
            continue;
        }
        $line_arr = explode(",", $cleanline);
        db_connect();
        $get_cusnum = "SELECT cusnum FROM customers WHERE accno = '{$line_arr['0']}' LIMIT 1";
        $run_cusnum = db_exec($get_cusnum) or errDie("Unable to get customer information.");
        $cusnum = pg_fetch_result($run_cusnum, 0, 0);
        // 		$refnum = $line_arr[3];
        // 		$cusnum = $line_arr[0];
        $darr = explode("/", $line_arr[7]);
        $date_day = $darr[1];
        $date_month = $darr[0];
        $date_year = "20" . $darr[2];
        $date = "{$date_year}-{$date_month}-{$date_day}";
        $aarr = explode("/", $line_arr[2]);
        $acc_topacc = $aarr[0];
        $acc_accnum = $aarr[1];
        $get_vatcode = "SELECT id FROM vatcodes WHERE code = '{$line_arr['4']}' LIMIT 1";
        $run_vatcode = db_exec($get_vatcode) or errDie("Unable to get vat code information.");
        $vatcode = pg_fetch_result($run_vatcode, 0, 0);
        core_connect();
        $get_acc = "SELECT accid FROM accounts WHERE topacc = '{$acc_topacc}' AND accnum = '{$acc_accnum}' LIMIT 1";
        $run_acc = db_exec($get_acc) or errDie("Unable to get contra account information.");
        $accid = pg_fetch_result($run_acc, 0, 0);
        db_connect();
        $ins_sql = "\n\t\t\tINSERT INTO cust_trans_batch (\n\t\t\t\tcusnum, proc_date, ref_num, entry_type, contra_account, chrg_vat, vatcode, amount, description\n\t\t\t) VALUES (\n\t\t\t\t'{$cusnum}', '{$date}', '{$refnum}', '{$line_arr['5']}', '{$accid}', '{$line_arr['6']}', '{$vatcode}','{$line_arr['9']}', '{$line_arr['8']}'\n\t\t\t)";
        $run_sql = db_exec($ins_sql) or errDie("Unable to record customer transaction.");
        $refnum++;
    }
    return slctacc(array(), "<li class='yay'>{$numtrans} Transaction(s) Has Been Imported.</li><br>");
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:42,代码来源:multi-cust-trans.php

示例5: viewtran

function viewtran($_POST)
{
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($prd, "string", 1, 14, "Invalid Period number.");
    $v->isOk($accnt, "string", 1, 5, "Invalid Accounts Selection.");
    $v->isOk($year, "string", 1, 10, "Invalid year.");
    if ($accnt == 'slct') {
        if (isset($stkids)) {
            foreach ($stkids as $key => $stkid) {
                $v->isOk($stkid, "num", 1, 20, "Invalid Stock code.");
            }
        } else {
            return "<li class='err'>ERROR : Please select at least one Stock Item.</li>" . slctacc();
        }
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # Get the ids
    if ($accnt == 'all') {
        $stkids = array();
        db_connect();
        $sql = "SELECT stkid FROM stock WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $stkids[] = $ac['stkid'];
            }
        } else {
            return "<li calss='err'> There are no Stock Items yet in Cubit.</li>";
        }
    }
    $hide = "";
    # Period name
    $prds = array();
    if ($tprd < $fprd) {
        for ($i = $fprd; $i <= 12; ++$i) {
            $prds[] = $i;
        }
        for ($i = 1; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    } else {
        for ($i = $fprd; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    }
    $trans = "";
    foreach ($stkids as $key => $stkid) {
        $stkRs = get("cubit", "*", "stock", "stkid", $stkid);
        $stk = pg_fetch_array($stkRs);
        $trans .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='8' align='center'><h3>{$stk['stkcod']} - {$stk['stkdes']}</h3></td>\n\t\t\t</tr>";
        $hide .= "<input type='hidden' name='stkids[]' value='{$stkid}'>";
        foreach ($prds as $prd) {
            # Period name
            $prdname = prdname($prd);
            # Get balances
            $idRs = get($prd, "max(id), min(id)", "stkledger", "yrdb='{$year}' AND stkid", $stkid);
            $id = pg_fetch_array($idRs);
            if ($id['min'] != 0) {
                $balRs = get($prd, "qty, (bqty - qty) as bqty, trantype, (balance - csamt) as balance", "stkledger", "id", $id['min']);
                $bal = pg_fetch_array($balRs);
                $cbalRs = get($prd, "balance", "stkledger", "id", $id['max']);
                $cbal = pg_fetch_array($cbalRs);
                /*
                if($bal['trantype'] == 'dt'){
                	$bal['bqty'] =  ($bal['bqty'] + $bal['qty']);
                }else{
                	$bal['bqty'] =  ($bal['bqty'] - $bal['qty']);
                }
                */
            } else {
                if ($prd != PRD_DB) {
                    continue;
                }
                $balRs = get("cubit", "csamt as balance, units as bqty", "stock", "stkid", $stkid);
                $bal = pg_fetch_array($balRs);
                $cbal['balance'] = 0;
                $cbal['bqty'] = 0;
            }
            $balance = sprint($bal['balance']);
            $get_yr = "SELECT yrname FROM core.year WHERE yrdb = '{$year}' LIMIT 1";
            $run_yr = db_exec($get_yr) or errDie("Unable to get year information.");
            if (pg_numrows($run_yr) > 0) {
                $yarr = pg_fetch_array($run_yr);
                $tmpyear = substr($yarr['yrname'], 1);
            } else {
                $tmpyear = date("Y") - 1;
            }
            $get_last_prdmap = "SELECT period FROM core.prdmap WHERE month = '12'";
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:stock-ledger-audit-xls.php

示例6: viewtran

function viewtran($_POST)
{
    # Get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($fprd, "string", 1, 14, "Invalid from period number.");
    $v->isOk($tprd, "string", 1, 14, "Invalid to period number.");
    $v->isOk($year, "string", 3, 4, "Invalid year.");
    if (isset($accnt)) {
        if ($accnt == 'slct') {
            if (isset($supids)) {
                foreach ($supids as $key => $supid) {
                    $v->isOk($supid, "num", 1, 20, "Invalid Supplier number.");
                }
            } else {
                return "<li class='err'>Please select at least one Creditor.</li>" . slctacc();
            }
        }
    } else {
        $v->isOk("###", "num", 0, 0, "ERROR : Invalid Accounts Selection.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # Get the ids
    if ($accnt == 'all') {
        $supids = array();
        db_connect();
        $sql = "SELECT supid FROM suppliers WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $supids[] = $ac['supid'];
            }
        } else {
            return "<li calss='err'> There are no suppliers yet in Cubit.</li>";
        }
    }
    $prds = array();
    if ($tprd < $fprd) {
        for ($i = $fprd; $i <= 12; ++$i) {
            $prds[] = $i;
        }
        for ($i = 1; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    } else {
        for ($i = $fprd; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    }
    db_conn('core');
    $Sl = "SELECT yrname FROM year WHERE yrdb='{$year}'";
    $Ri = db_exec($Sl) or errDie("Unable to get data.");
    $yrname = pg_fetch_result($Ri, 0);
    $auditdb = "{$yrname}_audit";
    # Period name
    $hide = "";
    global $MONPRD, $PRDMON;
    $sp = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    $trans = "";
    foreach ($supids as $key => $supid) {
        $supRs = get("cubit", "supname, supno, balance", "suppliers", "supid", $supid);
        $sup = pg_fetch_array($supRs);
        $trans .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='8' align='center'><h3>{$sup['supname']}</h3></td>\n\t\t\t</tr>";
        $hide .= "<input type='hidden' name='supids[]' value='{$supid}'>";
        foreach ($prds as $prd) {
            $prdname = prdname($prd);
            $trans .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='8'>{$prdname}</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{$sp}</th>\n\t\t\t\t\t<th>Date</th>\n\t\t\t\t\t<th>Reference</th>\n\t\t\t\t\t<th>Description</th>\n\t\t\t\t\t<th>Debit</th>\n\t\t\t\t\t<th>Credit</th>\n\t\t\t\t\t<th>Balance</th>\n\t\t\t\t\t<th>Contra Acc</th>\n\t\t\t\t</tr>";
            $idRs = get($auditdb, "min(id)", "{$prdname}_suppledger", "supid", $supid);
            $id = pg_fetch_array($idRs);
            if ($id['min'] != 0) {
                $balRs = get($auditdb, "(cbalance-credit) AS cbalance,(dbalance-debit) AS dbalance", "{$prdname}_suppledger", "id", $id['min']);
                $bal = pg_fetch_array($balRs);
                $bal['cbalance'] += 0;
                $bal['dbalance'] += 0;
            } else {
                $sql = array();
                for ($i = $MONPRD[$prd] - 1; $i >= 1; --$i) {
                    $pprdname = getMonthName($PRDMON[$i]);
                    $sql[] = "SELECT id,cbalance,dbalance FROM {$auditdb}.{$pprdname}_suppledger WHERE supid='{$supid}'";
                }
                if (count($sql) > 0) {
                    $sql = "SELECT * FROM (" . implode(" UNION ", $sql) . ") AS sl ORDER BY id DESC LIMIT 1";
                    $balRs = db_exec($sql);
                    $bal = pg_fetch_array($balRs);
                }
            }
            if (!isset($bal['dbalance'])) {
                $bal['dbalance'] = "";
            }
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:supp-ledger-audit.php

示例7: viewtran

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.");
    $v->isOk($year, "string", 1, 10, "Invalid year.");
    if (isset($accnt)) {
        if ($accnt == 'slct') {
            if (isset($supids)) {
                foreach ($supids as $key => $supid) {
                    $v->isOk($supid, "num", 1, 20, "Invalid Supplier number.");
                }
            } else {
                return "<li class=err>Please select at least one Creditor.</li>" . slctacc();
            }
        }
    } else {
        $v->isOk("###", "num", 0, 0, "ERROR : Invalid Accounts Selection.");
    }
    # 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;
    }
    # Get the ids
    if ($accnt == 'all') {
        $supids = array();
        db_connect();
        $sql = "SELECT supid FROM suppliers WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $supids[] = $ac['supid'];
            }
        } else {
            return "<li calss=err> There are no suppliers yet in Cubit.";
        }
    }
    # Period name
    $prdname = prdname($prd);
    db_conn('core');
    $Sl = "SELECT * FROM year WHERE yrdb='{$year}'";
    $Ri = db_exec($Sl) or errDie("Unable to get data.");
    $yd = pg_fetch_array($Ri);
    $trans = "";
    foreach ($supids as $key => $supid) {
        $supRs = get("cubit", "supname, supno, balance", "suppliers", "supid", $supid);
        $sup = pg_fetch_array($supRs);
        $idRs = get($yd['yrname'] . "_audit", "min(id)", $prdname . "_suppledger", "supid", $supid);
        $id = pg_fetch_array($idRs);
        if ($id['min'] != 0) {
            $balRs = get($yd['yrname'] . "_audit", "(cbalance-credit) AS cbalance,(dbalance-debit) AS dbalance", $prdname . "_suppledger", "id", $id['min']);
            $bal = pg_fetch_array($balRs);
            $bal['cbalance'] += 0;
            $bal['dbalance'] += 0;
        } else {
            $balRs = get("cubit", "balance", "suppliers", "supid", $supid);
            $bal = pg_fetch_array($balRs);
            $bal['balance'] += 0;
            if ($bal['balance'] < 0) {
                $bal['dbalance'] = $bal['balance'] * -1;
                $bal['cbalance'] = 0;
            } else {
                $bal['cbalance'] = $bal['balance'];
                $bal['dbalance'] = 0;
            }
            //$bal['dbalance'] += $amount;
        }
        # Total balance changes
        if ($bal['dbalance'] > $bal['cbalance']) {
            $bal['dbalance'] = $bal['dbalance'] - $bal['cbalance'];
            $bal['cbalance'] = 0;
        } elseif ($bal['cbalance'] > $bal['dbalance']) {
            $bal['cbalance'] = $bal['cbalance'] - $bal['dbalance'];
            $bal['dbalance'] = 0;
        } else {
            $bal['cbalance'] = 0;
            $bal['dbalance'] = 0;
        }
        $bal['credit'] = $bal['cbalance'];
        $bal['debit'] = $bal['dbalance'];
        $balance = sprint($bal['cbalance'] - $bal['dbalance']);
        $trans .= "<tr class='bg-even'><td colspan=8><b>{$sup['supno']} - {$sup['supname']} </b></td></tr>";
        $trans .= "<tr class='bg-even'><td colspan=2><br></td><td>Br/Forwd</td><td>Brought Forward</td><td align=right>{$bal['debit']}</td><td align=right>{$bal['credit']}</td><td align=right>{$balance}</td><td> </td></tr>";
        # --> Transaction reading comes here <--- #
        $dbal['debit'] = 0;
        $dbal['credit'] = 0;
        $tranRs = get($yd['yrname'] . "_audit", "*", $prdname . "_suppledger", "supid", $supid);
        while ($tran = pg_fetch_array($tranRs)) {
            $caccRs = get("core", "accname, accid, topacc, accnum", "accounts", "accid", $tran['contra']);
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:supp-ledger-prd.php

示例8: confirm

function confirm($_POST)
{
    # Get vars
    extract($_POST);
    # Redirect if must chrgvat
    if ($chrgvat == 'yes' && !isset($vataccid)) {
        return slctVatAcc($_POST);
    }
    if (isset($vatcode)) {
        $vatcode += 0;
    } else {
        $vatcode = 0;
    }
    if (isb($dtaccid)) {
        return "<li class='err'>You selected a main account.</li>" . slctacc($_POST);
    }
    if (isb($ctaccid)) {
        return "<li class='err'>You selected a main account.</li>" . slctacc($_POST);
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($ctaccid, "num", 1, 50, "Invalid Account to be Credited.");
    $v->isOk($dtaccid, "num", 1, 50, "Invalid Account to be Debited.");
    $v->isOk($refnum, "num", 1, 10, "Invalid Reference number.");
    $v->isOk($amount, "float", 1, 20, "Invalid Amount.");
    $v->isOk($details, "string", 0, 255, "Invalid Details.");
    $v->isOk($author, "string", 1, 30, "Invalid Authorising person name.");
    $datea = explode("-", $date);
    if (count($datea) == 3) {
        if (!checkdate($datea[1], $datea[0], $datea[2])) {
            $v->isOk($date, "num", 1, 1, "Invalid date.");
        }
    } else {
        $v->isOk($date, "num", 1, 1, "Invalid date.");
    }
    if ($chrgvat == 'yes') {
        $v->isOk($vataccid, "num", 1, 50, "Invalid VAT Account number.");
        $v->isOk($vatdedacc, "num", 1, 50, "Invalid VAT Deductable Account number.");
        $v->isOk($vatinc, "string", 1, 3, "Invalid vat inclusive selection.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        return details($_POST, $confirm);
    }
    if ($amount <= 0) {
        return details($_POST, "<li class='err'>Invalid Amount To Process.</li>");
    }
    $dtaccRs = get("core", "*", "accounts", "accid", $dtaccid);
    $dtacc = pg_fetch_array($dtaccRs);
    $ctaccRs = get("core", "*", "accounts", "accid", $ctaccid);
    $ctacc = pg_fetch_array($ctaccRs);
    # show vat account if vat is charged
    if ($chrgvat == 'yes') {
        $vataccRs = get("core", "*", "accounts", "accid", $vataccid);
        $vatacc = pg_fetch_array($vataccRs);
        $vatin = ucwords($vatinc);
        $vataccnum = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>VAT Account</td>\n\t\t\t\t<td><input type='hidden' name='vataccid' value='{$vataccid}'><input type='hidden' name='vatdedacc' value='{$vatdedacc}'>{$vatacc['topacc']}/{$vatacc['accnum']} - {$vatacc['accname']}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>VAT Inclusive</td>\n\t\t\t\t<td><input type='hidden' name='vatinc' value='{$vatinc}'>{$vatin}</td>\n\t\t\t</tr>";
    } else {
        $vataccnum = "";
    }
    $vat = ucwords($chrgvat);
    if ($vatcode > 0) {
        db_conn('cubit');
        $Sl = "SELECT * FROM vatcodes WHERE id='{$vatcode}'";
        $Ri = db_exec($Sl) or errDie("unable to get data.");
        $va = pg_fetch_array($Ri);
        $vd = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>VAT Code</td>\n\t\t\t\t<td>{$va['code']}</td>\n\t\t\t</tr>";
    } else {
        $vd = "";
    }
    $confirm = "\n\t\t<h3>Record Recurring Transaction</h3>\n\t\t<h4>Confirm entry</h4>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t<input type='hidden' name='vatcode' value='{$vatcode}'>\n\t\t\t<input type='hidden' name='dtaccid' value='{$dtaccid}'>\n\t\t\t<input type='hidden' name='ctaccid' value='{$ctaccid}'>\n\t\t\t<input type='hidden' name='dtaccname' value='{$dtacc['accname']}'>\n\t\t\t<input type='hidden' name='ctaccname' value='{$ctacc['accname']}'>\n\t\t\t<input type='hidden' name='date' value='{$date}'>\n\t\t\t<input type='hidden' name='date_day' value='{$date_day}'>\n\t\t\t<input type='hidden' name='date_month' value='{$date_month}'>\n\t\t\t<input type='hidden' name='date_year' value='{$date_year}'>\n\t\t\t<input type='hidden' name='refnum' value='{$refnum}'>\n\t\t\t<input type='hidden' name='amount' value='{$amount}'>\n\t\t\t<input type='hidden' name='chrgvat' value='{$chrgvat}'>\n\t\t\t<input type='hidden' name='details' value='{$details}'>\n\t\t\t<input type='hidden' name='author' value='{$author}'>\n\t\t<table " . TMPL_tblDflts . " width='500'>\n\t\t\t<tr>\n\t\t\t\t<td width='50%'><h3>Debit</h3></td>\n\t\t\t\t<td width='50%'><h3>Credit</h3></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$dtacc['topacc']}/{$dtacc['accnum']} - {$dtacc['accname']}</td>\n\t\t\t\t<td>{$ctacc['topacc']}/{$ctacc['accnum']} - {$ctacc['accname']}</td>\n\t\t\t</tr>\n\t\t\t<tr><td><br></td></tr>\n\t\t\t<tr><td><br></td></tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Date</td>\n\t\t\t\t<td>{$date}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Reference number</td>\n\t\t\t\t<td>{$refnum}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Amount</td>\n\t\t\t\t<td>" . CUR . " {$amount}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Charge VAT </td>\n\t\t\t\t<td>{$vat}</td>\n\t\t\t</tr>\n\t\t\t{$vataccnum}\n\t\t\t{$vd}\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Details</td>\n\t\t\t\t<td>{$details}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Authorising Person</td>\n\t\t\t\t<td>{$author}</td>\n\t\t\t</tr>\n\t\t\t<tr><td><br></td></tr>\n\t\t\t<tr>\n\t\t\t\t<td align='right'><input type='button' value='&laquo Back' onClick='javascript:history.back()'></td>\n\t\t\t\t<td align='right'><input type='submit' value='Confirm Transaction &raquo'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>\n\t\t<p>\n\t\t<table border=0 cellpadding='2' cellspacing='1' width=15%>\n\t\t\t<tr>\n\t\t\t\t<th>Quick Links</th>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='../reporting/index-reports.php'>Financials</a></td>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='rectrans-view.php'>View Recurring Transactions</td>\n\t\t\t</tr>\n\t\t\t<tr class='datacell'>\n\t\t\t\t<td align='center'><a href='trans-new.php'>Journal Transactions</td>\n\t\t\t</tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $confirm;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:79,代码来源:rectrans-new.php

示例9: viewtran

function viewtran($_POST)
{
    extract($_POST);
    require_lib("validate");
    $v = new validate();
    $v->isOk($prd, "string", 1, 14, "Invalid Period number.");
    $v->isOk($accnt, "string", 1, 10, "Invalid Accounts Selection.");
    $v->isOk($acc_first, "string", 1, 20, "Invalid accounts display selection");
    if ($accnt == 'slct') {
        if (isset($accids)) {
            foreach ($accids as $key => $accid) {
                $v->isOk($accid, "num", 1, 20, "Invalid Account number.");
            }
        } else {
            return "<li class='err'>Please select at least one account.</li>" . slctacc();
        }
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    // Was the 'All Accounts' option selected?
    if ($accnt == 'all') {
        $accids = array();
        // Retrieve the main accounts
        db_conn("core");
        $sql = "SELECT * FROM accounts WHERE div='" . USER_DIV . "' AND accnum='000' ORDER BY topacc ASC";
        $macc_rslt = db_exec($sql) or errDie("Unable to retrieve main accounts from Cubit.");
        while ($macc_data = pg_fetch_array($macc_rslt)) {
            // Retrieve sub accounts from Cubit
            $sql = "SELECT * FROM accounts WHERE div='" . USER_DIV . "' AND topacc='{$macc_data['topacc']}' AND accnum!='000' ORDER BY topacc ASC";
            $sacc_rslt = db_exec($sql) or errDie("Unable to retrieve sub accounts from Cubit.");
            // List the main accounts without any sub accounts
            if (!pg_num_rows($sacc_rslt)) {
                $accids[] = $macc_data["accid"];
                // List the sub accounts
            } else {
                while ($sacc_data = pg_fetch_array($sacc_rslt)) {
                    $accids[] = $sacc_data["accid"];
                }
            }
        }
    } else {
        if ($accnt == "allactive") {
            $accids = array();
            $sql = "SELECT accid FROM core.trial_bal\n\t\t\t\tWHERE (debit!=0 OR credit!=0) AND div='" . USER_DIV . "' AND month='{$prd}'";
            $rslt = db_exec($sql) or errDie("Error fetching active account list.");
            while ($macc_data = pg_fetch_array($rslt)) {
                $accids[] = $macc_data["accid"];
            }
        }
    }
    # Period name
    $prdname = prdname($prd);
    $trans = "";
    $hide = "";
    $i = 0;
    $curr_topacc = "";
    foreach ($accids as $key => $accid) {
        $accRs = get("core", "accname, accid, topacc, accnum", "accounts", "accid", $accid);
        $acc = pg_fetch_array($accRs);
        # Get balances
        $idRs = get($prd, "max(id), min(id)", "ledger", "acc", $accid);
        $id = pg_fetch_array($idRs);
        if ($id['min'] != 0) {
            $balRs = get($prd, "(cbalance-credit) as cbalance,(dbalance-debit) as dbalance", "ledger", "id", $id['min']);
            $bal = pg_fetch_array($balRs);
            $cbalRs = get($prd, "cbalance,dbalance", "ledger", "id", $id['max']);
            $cbal = pg_fetch_array($cbalRs);
        } else {
            db_conn("core");
            $balSql = "SELECT credit as cbalance, debit as dbalance FROM trial_bal WHERE accid='{$acc['accid']}' AND period='{$prd}'";
            $balRs = db_exec($balSql) or errDie("Error reading trial balance.");
            $bal = pg_fetch_array($balRs);
            $cbal['cbalance'] = 0;
            $cbal['dbalance'] = 0;
        }
        if ($bal['dbalance'] > $bal['cbalance']) {
            $bal['dbalance'] = sprint($bal['dbalance'] - $bal['cbalance']);
            $bal['cbalance'] = "";
            $balance = $bal['dbalance'];
            $fl = "DR";
        } elseif ($bal['cbalance'] > $bal['dbalance']) {
            $bal['cbalance'] = sprint($bal['cbalance'] - $bal['dbalance']);
            $bal['dbalance'] = "";
            $balance = $bal['cbalance'];
            $fl = "CR";
        } else {
            $bal['cbalance'] = "";
            $bal['dbalance'] = "";
            $balance = "0.00";
            $fl = "";
        }
        $balance = sprint($balance);
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:ledger.php

示例10: viewtran

function viewtran($_POST)
{
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($prd, "string", 1, 14, "Invalid Period number.");
    if (isset($accnt)) {
        if ($accnt == 'slct') {
            if (isset($supids)) {
                foreach ($supids as $key => $supid) {
                    $v->isOk($supid, "num", 1, 20, "Invalid Supplier number.");
                }
            } else {
                return "<li class='err'>Please select at least one Creditor.</li>" . slctacc();
            }
        }
    } else {
        $v->isOk("###", "num", 0, 0, "ERROR : Invalid Accounts Selection.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # Get the ids
    if ($accnt == 'all') {
        $supids = array();
        db_connect();
        $sql = "SELECT supid FROM suppliers WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $supids[] = $ac['supid'];
            }
        } else {
            return "<li calss='err'> There are no suppliers yet in Cubit.</li>";
        }
    }
    db_conn('core');
    $Sl = "SELECT yrname FROM year WHERE yrdb='{$year}'";
    $Ri = db_exec($Sl) or errDie("Unable to get data.");
    $yrname = pg_fetch_result($Ri, 0);
    $auditdb = "{$yrname}_audit";
    $prds = array();
    if ($tprd < $fprd) {
        for ($i = $fprd; $i <= 12; ++$i) {
            $prds[] = $i;
        }
        for ($i = 1; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    } else {
        for ($i = $fprd; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    }
    # Period name
    $prdname = prdname($prd);
    $trans = "";
    foreach ($supids as $key => $supid) {
        $supRs = get("cubit", "supname, supno, balance", "suppliers", "supid", $supid);
        $sup = pg_fetch_array($supRs);
        $trans .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='8' align='center'><h3>{$sup['supname']}</h3></td>\n\t\t\t</tr>";
        foreach ($prds as $prd) {
            $prdname = prdname($prd);
            $trans .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='8'>{$prdname}</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{$sp}</th>\n\t\t\t\t\t<th>Date</th>\n\t\t\t\t\t<th>Reference</th>\n\t\t\t\t\t<th>Description</th>\n\t\t\t\t\t<th>Debit</th>\n\t\t\t\t\t<th>Credit</th>\n\t\t\t\t\t<th>Balance</th>\n\t\t\t\t\t<th>Contra Acc</th>\n\t\t\t\t</tr>";
            // 			if($id['min'] <> 0){
            // 				$balRs = get($prd, "(cbalance-credit) AS cbalance,(dbalance-debit) AS dbalance", "suppledger", "id", $id['min']);
            // 				$bal = pg_fetch_array($balRs);
            // 				$bal['cbalance'] += 0;
            // 				$bal['dbalance'] += 0;
            // 			}else{
            // 				$balRs = get("cubit", "balance", "suppliers", "supid", $supid);
            // 				$bal = pg_fetch_array($balRs);
            // 				$bal['balance']+=0;
            //
            // 				if($bal['balance']<0) {
            // 					$bal['dbalance'] = $bal['balance'];
            // 					$bal['cbalance'] = 0;
            // 				} else {
            // 					$bal['cbalance'] = $bal['balance'];
            // 					$bal['dbalance'] = 0;
            // 				}
            // 				//$bal['dbalance'] += $amount;
            // 			}
            // 			$idRs = get($prd, "min(id)", "suppledger", "supid", $supid);
            // 			$id = pg_fetch_array($idRs);
            $idRs = get($auditdb, "min(id)", "{$prdname}_suppledger", "supid", $supid);
            $id = pg_fetch_array($idRs);
            if ($id['min'] != 0) {
                $balRs = get($auditdb, "(cbalance-credit) AS cbalance,(dbalance-debit) AS dbalance", "{$prdname}_suppledger", "id", $id['min']);
                $bal = pg_fetch_array($balRs);
                $bal['cbalance'] += 0;
                $bal['dbalance'] += 0;
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:supp-ledger-xls.php

示例11: details

function details($_POST)
{
    # Get vars
    extract($_POST);
    #redirect if must chrgvat
    if ($chrgvat == 'yes' && !isset($vataccid)) {
        return slctacc($_POST);
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($lname, "string", 1, 255, "Invalid Ledger Name.");
    $v->isOk($dtaccid, "num", 1, 50, "Invalid Account to be Debited.");
    $v->isOk($ctaccid, "num", 1, 50, "Invalid Account to be Credited.");
    $v->isOk($chrgvat, "string", 1, 4, "Invalid charge vat option.");
    $v->isOk($numtran, "num", 1, 20, "Invalid Number on entries.");
    $v->isOk($dateopt, "string", 1, 10, "Invalid date entry option.");
    $v->isOk($desopt, "string", 1, 5, "Invalid Description option.");
    if ($desopt == 'once') {
        $v->isOk($descript, "string", 1, 255, "Invalid Description.");
    } else {
        $v->isOk($descript, "string", 0, 255, "Invalid Description.");
    }
    $v->isOk($refopt, "string", 1, 5, "Invalid Reference number option.");
    if ($refopt == 'once') {
        $v->isOk($refnum, "string", 1, 255, "Invalid Reference number.");
    } else {
        $v->isOk($refnum, "string", 0, 255, "Invalid Reference number.");
    }
    if ($chrgvat == 'yes') {
        $v->isOk($vataccid, "num", 1, 50, "Invalid Vat Account number.");
        $v->isOk($vatdedacc, "num", 1, 50, "Invalid Vat Deductable Account number.");
        $v->isOk($vatinc, "string", 1, 3, "Invalid vat inclusive selection.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class=err>" . $e["msg"] . "</li>";
        }
        return error($_POST, $confirm);
        # $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        # return $confirm;
    }
    # Account numbers
    $dtaccRs = get("core", "*", "accounts", "accid", $dtaccid);
    $dtacc = pg_fetch_array($dtaccRs);
    $ctaccRs = get("core", "*", "accounts", "accid", $ctaccid);
    $ctacc = pg_fetch_array($ctaccRs);
    if ($chrgvat == 'yes') {
        $vataccRs = get("core", "*", "accounts", "accid", $vataccid);
        $vatacc = pg_fetch_array($vataccRs);
        $vatin = ucwords($vatinc);
        $vataccnum = "\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Vat Account</td>\r\n\t\t\t\t<td><input type='hidden' name='vataccid' value='{$vataccid}'><input type='hidden' name='vatdedacc' value='{$vatdedacc}'>{$vatacc['topacc']}/{$vatacc['accnum']} - {$vatacc['accname']}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Vat Inclusive</td>\r\n\t\t\t\t<td><input type='hidden' name='vatinc' value='{$vatinc}'>{$vatin}</td>\r\n\t\t\t</tr>";
    } else {
        $vataccnum = "";
    }
    /* Toggle Options */
    # Charge Vat Option
    $vat = ucwords($chrgvat);
    # Date Option
    if ($dateopt == 'system') {
        $date = 'System Date';
    } elseif ($dateopt == 'user') {
        $date = 'User Input Date';
    }
    # Description and Refnum Option
    $options = array("num" => "Auto Number", "emp" => "Empty Input Box", "once" => "Once Only Setting", "edit" => "Default Editable Input");
    $descriptopt = $options[$desopt];
    $refnumopt = $options[$refopt];
    # put auto number if its auto number
    if ($refopt == 'num') {
        $refnums = $options[$refopt];
    } else {
        $refnums = $refnum;
    }
    /* End Toggle Options */
    # uppercase first letter of name
    $lname = ucfirst($lname);
    // Details
    $details = "\r\n\t\t<center>\r\n\t\t<h3> New High Speed Input Ledger </h3>\r\n\t\t<form action='" . SELF . "' method='POST' name='form'>\r\n\t\t\t<input type='hidden' name='key' value='write'>\r\n\t\t\t<input type='hidden' name='lname' value='{$lname}'>\r\n\t\t\t<input type='hidden' name='dtaccid' value='{$dtaccid}'>\r\n\t\t\t<input type='hidden' name='ctaccid' value='{$ctaccid}'>\r\n\t\t\t<input type='hidden' name='chrgvat' value='{$chrgvat}'>\r\n\t\t\t<input type='hidden' name='numtran' value='{$numtran}'>\r\n\t\t\t<input type='hidden' name='dateopt' value='{$dateopt}'>\r\n\t\t\t<input type='hidden' name='descript' value='{$descript}'>\r\n\t\t\t<input type='hidden' name='desopt' value='{$desopt}'>\r\n\t\t\t<input type='hidden' name='refnum' value='{$refnum}'>\r\n\t\t\t<input type='hidden' name='refopt' value='{$refopt}'>\r\n\t\t<table " . TMPL_tblDflts . " align='center'>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Option</th>\r\n\t\t\t\t<th>Value</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Ledger Name</td>\r\n\t\t\t\t<td>{$lname}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th><h4>Debit</h4></th>\r\n\t\t\t\t<th><h4>Credit</h4></th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td align='center'>{$dtacc['topacc']}/{$dtacc['accnum']} - {$dtacc['accname']}</td>\r\n\t\t\t\t<td align='center'>{$ctacc['topacc']}/{$ctacc['accnum']} - {$ctacc['accname']}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='3'>Options</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Number of Entries</td>\r\n\t\t\t\t<td>{$numtran}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Date Entry</td>\r\n\t\t\t\t<td>{$date}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Charge Vat </td>\r\n\t\t\t\t<td>{$vat}</td>\r\n\t\t\t</tr>\r\n\t\t\t{$vataccnum}\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='3'>Description</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Description</td>\r\n\t\t\t\t<td>{$descript}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Option</td>\r\n\t\t\t\t<td>{$descriptopt}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='3'>Reference Number</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Reference Number</td>\r\n\t\t\t\t<td>{$refnums}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>Option</td>\r\n\t\t\t\t<td>{$refnumopt}</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td align='right'><input type='button' value='&laquo Back' onClick='javascript:history.back()'></td>\r\n\t\t\t\t<td align='right'><input type='submit' value='Continue &raquo'></td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t</form>\r\n\t\t<p>\r\n\t\t<table border=0 cellpadding='2' cellspacing='1' width=15%>\r\n\t\t\t<tr>\r\n\t\t\t\t<th>Quick Links</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td align='center'><a href='ledger-new.php'>New High Speed Input Ledger</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td align='center'><a href='ledger-view.php'>View High Speed Input Ledgers</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td align='center'><a href='../main.php'>Main Menu</td>\r\n\t\t\t</tr>\r\n\t\t</table>";
    return $details;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:84,代码来源:ledger-new.php

示例12: viewtran

function viewtran($_POST, $pure = false)
{
    # Get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($fprd, "string", 1, 14, "Invalid from period number.");
    $v->isOk($tprd, "string", 1, 14, "Invalid to period number.");
    if (isset($accnt)) {
        if ($accnt == 'slct') {
            if (isset($cusnums)) {
                foreach ($cusnums as $key => $cusnum) {
                    $v->isOk($cusnum, "num", 1, 20, "Invalid Customer number.");
                }
            } else {
                return "<li class='err'>Please select at least one Debtor.</li>" . slctacc();
            }
        }
    } else {
        $v->isOk("###", "num", 0, 0, "ERROR : Invalid Accounts Selection.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # Get the ids
    if ($accnt == 'all') {
        $cusnums = array();
        db_connect();
        $sql = "SELECT cusnum FROM customers WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $cusnums[] = $ac['cusnum'];
            }
        } else {
            return "<li calss='err'> There are no customers yet in Cubit.</li>";
        }
    }
    $prds = array();
    if ($tprd < $fprd) {
        for ($i = $fprd; $i <= 12; ++$i) {
            $prds[] = $i;
        }
        for ($i = 1; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    } else {
        for ($i = $fprd; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    }
    # Period name
    $hide = "";
    $sp = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    $trans = "";
    foreach ($cusnums as $key => $cusnum) {
        $cusRs = get("cubit", "cusname, surname, accno, balance", "customers", "cusnum", $cusnum);
        $cus = pg_fetch_array($cusRs);
        $trans .= "\n\t\t<tr>\n\t\t\t<td colspan='8' align='center'><h3>{$cus['surname']}</h3></td>\n\t\t</tr>";
        $hide .= "<input type='hidden' name='cusnums[]' value='{$cusnum}'>";
        foreach ($prds as $prd) {
            $prdname = prdname($prd);
            $trans .= "\n\t\t\t<tr>\n\t\t\t\t<th colspan='8'>{$prdname}</th>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>{$sp}</th>\n\t\t\t\t<th>Date</th>\n\t\t\t\t<th>Reference</th>\n\t\t\t\t<th>Description</th>\n\t\t\t\t<th>Debit</th>\n\t\t\t\t<th>Credit</th>\n\t\t\t\t<th>Balance</th>\n\t\t\t\t<th>Contra Acc</th>\n\t\t\t</tr>";
            $idRs = get($prd, "min(id)", "custledger", "cusnum", $cusnum);
            $id = pg_fetch_array($idRs);
            if ($id['min'] != 0) {
                $balRs = get($prd, "(cbalance-credit) AS cbalance,(dbalance-debit) AS dbalance", "custledger", "id", $id['min']);
                $bal = pg_fetch_array($balRs);
                $bal['cbalance'] += 0;
                $bal['dbalance'] += 0;
            } else {
                $balRs = get("cubit", "balance", "customers", "cusnum", $cusnum);
                $bal = pg_fetch_array($balRs);
                $bal['balance'] += 0;
                if ($bal['balance'] > 0) {
                    $bal['dbalance'] = $bal['balance'];
                    $bal['cbalance'] = 0;
                } else {
                    $bal['cbalance'] = $bal['balance'] * -1;
                    $bal['dbalance'] = 0;
                }
                //$bal['dbalance'] += $amount;
            }
            # Total balance changes
            if ($bal['dbalance'] > $bal['cbalance']) {
                $bal['dbalance'] = $bal['dbalance'] - $bal['cbalance'];
                $bal['cbalance'] = 0;
            } else {
                if ($bal['cbalance'] > $bal['dbalance']) {
                    $bal['cbalance'] = $bal['cbalance'] - $bal['dbalance'];
                    $bal['dbalance'] = 0;
                } else {
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:cust-ledger.php

示例13: details

function details($_POST, $err = "")
{
    # Get vars
    extract($_POST);
    if (isset($back) and isStock($accid)) {
        return get_stock_items($_POST);
    } elseif (isset($back)) {
        return slctacc($_POST);
    }
    $accid += 0;
    $amount = $amount + 0;
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($refnum, "num", 1, 10, "Invalid Reference number.");
    $v->isOk($ct_day, "num", 1, 2, "Invalid to Date ct_day.");
    $v->isOk($ct_month, "num", 1, 2, "Invalid to Date ct_monthth.");
    $v->isOk($ct_year, "num", 1, 4, "Invalid to Date Year.");
    $date = $ct_day . "-" . $ct_month . "-" . $ct_year;
    if (!checkdate($ct_month, $ct_day, $ct_year)) {
        $v->isOk($date, "num", 1, 1, "Invalid date.");
    }
    $v->isOk($accid, "num", 1, 50, "Invalid Contra Account.");
    $v->isOk($cusnum, "num", 1, 50, "Invalid Customer number.");
    $v->isOk($vatinc, "string", 1, 6, "Invalid Transaction VAT Option.");
    if (sprint($amount) <= 0) {
        $v->addError($amount, "Invalid Or Too Small Amount Entered.");
    }
    if ($accid == "0") {
        $v->addError($accid, "No Allowed Accounts Found. <a href='settings/credit-note-accounts.php'>Please Add One First</a>");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        return slctacc($_POST, $confirm . "<br>");
    }
    # CHECK IF THIS DATE IS IN THE BLOCKED RANGE
    $blocked_date_from = getCSetting("BLOCKED_FROM");
    $blocked_date_to = getCSetting("BLOCKED_TO");
    if (strtotime($date) >= strtotime($blocked_date_from) and strtotime($date) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
        return slctacc($_POST, "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li><br>");
    }
    #if stock returned is selected ... override the setting
    if (isset($gotstock) and strlen($gotstock) > 0) {
        #get a stock id
        db_conn('exten');
        $get_stkid = "SELECT stkacc FROM warehouses ORDER BY whid ASC LIMIT 1";
        $run_stkid = db_exec($get_stkid) or errDie("Unable to get inventory account information.");
        if (pg_numrows($run_stkid) < 1) {
            return "<li class='err'>No Inventory Account Found.</li>";
        } else {
            $accid = pg_fetch_result($run_stkid, 0, 0);
        }
    }
    # get contra account details
    $accRs = get("core", "*", "accounts", "accid", $accid);
    $acc = pg_fetch_array($accRs);
    #### handle the stock we selected
    if ((isStock($accid) or isset($gotstock)) and !isset($stockcontinue)) {
        #for whatever reason ... we need to get stock ...
        return get_stock_items($_POST);
    }
    db_connect();
    # Select customer
    $sql = "SELECT * FROM customers WHERE cusnum = '{$cusnum}' AND div = '" . USER_DIV . "'";
    $custRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
    if (pg_numrows($custRslt) < 1) {
        return "<li class='err'>Invalid customer ID, or customer has been blocked.</li>";
    } else {
        $cust = pg_fetch_array($custRslt);
    }
    db_conn("exten");
    $sql = "SELECT * FROM departments WHERE deptid = '{$cust['deptid']}' AND div = '" . USER_DIV . "'";
    $deptRslt = db_exec($sql);
    if (pg_numrows($deptRslt) < 1) {
        return "<i class='err'>Customer Department Not Found</i>";
    } else {
        $dept = pg_fetch_array($deptRslt);
    }
    #get a stock total
    $stock_total = 0;
    if (isset($stock_items) and is_array($stock_items)) {
        foreach ($stock_items as $each => $own) {
            $stock_total = $stock_total + $stock_cost[$each] * $own;
        }
    }
    $stkamount = 0;
    $send_stock = "";
    $show_stock = "";
    if (isset($stock_items) and is_array($stock_items)) {
        $unit_total = array_sum($stock_items);
        if ($unit_total == 0) {
            $stock_unit_avg_cost = 0;
        } else {
            $stock_unit_avg_cost = sprint(($amount - $stock_total) / $unit_total);
        }
//.........这里部分代码省略.........
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:101,代码来源:general-creditnote.php

示例14: viewtran

function viewtran($_POST, $pure = false)
{
    extract($_POST);
    require_lib("validate");
    $v = new validate();
    $v->isOk($fprd, "string", 1, 14, "Invalid from period number.");
    $v->isOk($tprd, "string", 1, 14, "Invalid to period number.");
    $v->isOk($accnt, "string", 1, 5, "Invalid Accounts Selection.");
    if ($accnt == 'slct') {
        if (isset($stkids)) {
            foreach ($stkids as $key => $stkid) {
                $v->isOk($stkid, "num", 1, 20, "Invalid Stock code.");
            }
        } else {
            return "<li class='err'>ERROR : Please select at least one Stock Item.</li>" . slctacc($_POST);
        }
    }
    if ($v->isError()) {
        return $v->genErrors();
    }
    if ($accnt == 'all') {
        $stkids = array();
        db_connect();
        $sql = "SELECT stkid FROM stock WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $stkids[] = $ac['stkid'];
            }
        } else {
            return "<li calss='err'> There are no Stock Items yet in Cubit.</li>";
        }
    }
    # Period name
    $prds = array();
    if ($tprd < $fprd) {
        for ($i = $fprd; $i <= 12; ++$i) {
            $prds[] = $i;
        }
        for ($i = 1; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    } else {
        for ($i = $fprd; $i <= $tprd; ++$i) {
            $prds[] = $i;
        }
    }
    $hide = "";
    $sp = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    $trans = "";
    foreach ($stkids as $key => $stkid) {
        $stkRs = get("cubit", "*", "stock", "stkid", $stkid);
        $stk = pg_fetch_array($stkRs);
        $trans .= "\n\t\t<tr>\n\t\t\t<td colspan='8' align='center'><h3>{$stk['stkcod']} - {$stk['stkdes']}</h3></td>\n\t\t</tr>";
        $hide .= "<input type='hidden' name='stkids[]' value='{$stkid}'>";
        foreach ($prds as $prd) {
            $prdname = getMonthName($prd);
            $trans .= "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th colspan='8'>{$prdname}</th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>DATE</th>\n\t\t\t\t\t\t\t\t<th>DETAILS</th>\n\t\t\t\t\t\t\t\t<th>QTY</th>\n\t\t\t\t\t\t\t\t<th>COST AMOUNT</th>\n\t\t\t\t\t\t\t\t<th>BALANCE</th>\n\t\t\t\t\t\t\t</tr>";
            $idRs = get($prd, "max(id), min(id)", "stkledger", "yrdb='" . YR_DB . "' AND stkid", $stkid);
            $id = pg_fetch_array($idRs);
            if ($id['min'] != 0) {
                $balRs = get($prd, "qty, (bqty - qty) as bqty, trantype, (balance - csamt) as balance", "stkledger", "id", $id['min']);
                $bal = pg_fetch_array($balRs);
                $cbalRs = get($prd, "balance", "stkledger", "id", $id['max']);
                $cbal = pg_fetch_array($cbalRs);
                /*
                if($bal['trantype'] == 'dt'){
                	$bal['bqty'] =  ($bal['bqty'] + $bal['qty']);
                }else{
                	$bal['bqty'] =  ($bal['bqty'] - $bal['qty']);
                }
                */
            } else {
                $balRs = get("cubit", "csamt as balance, units as bqty", "stock", "stkid", $stkid);
                $bal = pg_fetch_array($balRs);
                $cbal['balance'] = 0;
                $cbal['bqty'] = 0;
            }
            $balance = sprint($bal['balance']);
            $trans .= "\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td colspan='5'><b>({$stk['stkcod']}) {$stk['stkdes']}</b></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t\t\t<td>Balance Brought Forward</td>\n\t\t\t\t\t\t\t\t<td align='right'>" . sprint3($bal['bqty']) . "</td>\n\t\t\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t\t\t<td align='right'>" . sprint($balance) . "</td>\n\t\t\t\t\t\t\t</tr>";
            $dbal['balance'] = 0;
            $dbal['bqty'] = 0;
            $qtytotal = 0;
            $tranRs = nget($prd, "*", "stkledger", "yrdb='" . YR_DB . "' AND stkid", $stkid . " ORDER BY edate,id ASC");
            while ($tran = pg_fetch_array($tranRs)) {
                $dbal['balance'] += $tran['csamt'];
                $dbal['bqty'] = $tran['bqty'];
                $qtytotal += $tran['qty'];
                # sprinting
                $tran['csamt'] = sprint($tran['csamt']);
                $tran['balance'] = sprint($tran['balance']);
                # Format date
                $tran['edate'] = explode("-", $tran['edate']);
                $tran['edate'] = $tran['edate'][2] . "-" . $tran['edate'][1] . "-" . $tran['edate'][0];
                $balance += $tran["csamt"];
                $trans .= "\n\t\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t\t<td>{$tran['edate']}</td>\n\t\t\t\t\t\t\t\t\t<td>{$tran['details']}</td>\n\t\t\t\t\t\t\t\t\t<td align='right'>" . sprint3($tran['qty']) . "</td>\n\t\t\t\t\t\t\t\t\t<td align='right'>{$tran['csamt']}</td>\n\t\t\t\t\t\t\t\t\t<td align='right'>" . sprint($balance) . "</td>\n\t\t\t\t\t\t\t\t</tr>";
            }
            $dbal['balance'] = sprint($dbal['balance']);
            //$qtytotal was $dbal[bqty]
            $trans .= "\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t\t\t<td>Total for period {$prdname} to Date :</td>\n\t\t\t\t\t\t\t\t<td align='right'>" . sprint3($qtytotal) . "</td>\n\t\t\t\t\t\t\t\t<td align='right'>{$dbal['balance']}</td>\n\t\t\t\t\t\t\t\t<td align='right'>{$dbal['balance']}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t" . TBL_BR;
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:stock-ledger.php

示例15: viewtran

function viewtran($_POST)
{
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($prd, "string", 1, 14, "Invalid Period number.");
    $v->isOk($year, "string", 1, 10, "Invalid year.");
    if (isset($accnt)) {
        if ($accnt == 'slct') {
            if (isset($emps)) {
                foreach ($emps as $key => $emp) {
                    $v->isOk($emp, "num", 1, 20, "Invalid employee number.");
                }
            } else {
                return "<li class='err'>Please select at least one Emloyee.</li>" . slctacc($_POST);
            }
        }
    } else {
        $v->isOk("###", "num", 0, 0, "ERROR : Invalid Accounts Selection.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # Get the ids
    if ($accnt == 'all') {
        $supids = array();
        db_connect();
        $sql = "SELECT empnum FROM employees WHERE div = '" . USER_DIV . "'";
        $rs = db_exec($sql);
        if (pg_num_rows($rs) > 0) {
            while ($ac = pg_fetch_array($rs)) {
                $emps[] = $ac['empnum'];
            }
        } else {
            return "<li calss='err'> There are no employees yet in Cubit.";
        }
    }
    # Period name
    $prdname = prdname($prd);
    $hide = "";
    db_conn('core');
    $Sl = "SELECT * FROM year WHERE yrdb='{$year}'";
    $Ri = db_exec($Sl) or errDie("Unable to get data.");
    $yd = pg_fetch_array($Ri);
    $trans = "";
    foreach ($emps as $key => $emp) {
        $supRs = get("cubit", "sname,fnames, balance", "employees", "empnum", $emp);
        $sup = pg_fetch_array($supRs);
        $idRs = get($yd['yrname'] . "_audit", "min(id)", $prdname . "_empledger", "empid", $emp);
        $id = pg_fetch_array($idRs);
        if ($id['min'] != 0) {
            $balRs = get($yd['yrname'] . "_audit", "(cbalance-credit) AS cbalance,(dbalance-debit) AS dbalance", $prdname . "_empledger", "id", $id['min']);
            $bal = pg_fetch_array($balRs);
            $bal['cbalance'] += 0;
            $bal['dbalance'] += 0;
        } else {
            $balRs = get("cubit", "balance", "employees", "empnum", $emp);
            $bal = pg_fetch_array($balRs);
            $bal['balance'] += 0;
            if ($bal['balance'] < 0) {
                $bal['dbalance'] = $bal['balance'] * -1;
                $bal['cbalance'] = 0;
            } else {
                $bal['cbalance'] = $bal['balance'];
                $bal['dbalance'] = 0;
            }
            //$bal['dbalance'] += $amount;
        }
        # Total balance changes
        if ($bal['dbalance'] > $bal['cbalance']) {
            $bal['dbalance'] = $bal['dbalance'] - $bal['cbalance'];
            $bal['cbalance'] = 0;
        } elseif ($bal['cbalance'] > $bal['dbalance']) {
            $bal['cbalance'] = $bal['cbalance'] - $bal['dbalance'];
            $bal['dbalance'] = 0;
        } else {
            $bal['cbalance'] = 0;
            $bal['dbalance'] = 0;
        }
        $bal['credit'] = $bal['cbalance'];
        $bal['debit'] = $bal['dbalance'];
        $balance = sprint($bal['cbalance'] - $bal['dbalance']);
        $hide .= "<input type='hidden' name='emps[]' value='{$emp}'>";
        $trans .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='8'><b>{$sup['sname']}, {$sup['fnames']} </b></td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='2'><br></td>\n\t\t\t\t<td>Br/Forwd</td>\n\t\t\t\t<td>Brought Forward</td>\n\t\t\t\t<td align='right'>{$bal['debit']}</td>\n\t\t\t\t<td align='right'>{$bal['credit']}</td>\n\t\t\t\t<td align='right'>{$balance}</td>\n\t\t\t\t<td> </td>\n\t\t\t</tr>";
        # --> Transaction reading comes here <--- #
        $dbal['debit'] = 0;
        $dbal['credit'] = 0;
        $tranRs = get($yd['yrname'] . "_audit", "*", $prdname . "_empledger", "empid", $emp, "ORDER BY id");
        while ($tran = pg_fetch_array($tranRs)) {
            $caccRs = get("core", "accname, accid, topacc, accnum", "accounts", "accid", $tran['contra']);
            $cacc = pg_fetch_array($caccRs);
            $dbal['debit'] += $tran['debit'];
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:emp-ledger-audit.php


注:本文中的slctacc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。