Location: PHPKode > projects > NOLA > apchecking.php
<? include('includes/main.php'); ?>
<? include('includes/apfunctions.php'); ?>
<? include('includes/glfunctions.php'); ?>
<?
        echo texttitle('AP Checking');
        if ($paid) {
                if (!is_array($paid)) $paid=array($paid);
                foreach ($paid as $data) {
                        $conn->Execute('update chk set cashdate='.sqlprep(createtime('Y-m-d')).' where id='.sqlprep($data));
                };
                echo textsuccess('Check(s) marked as cashed.');
        };
        if ($void) {
                if (!is_array($void)) $void=array($void);
                foreach ($void as $data) {
                        if (!apvoidcheck($data)) echo texterror('Error voiding check.');
                };
                echo textsuccess('<br>Checks voided successfully.');
        };
        if ($checknumber||$invoicenumber||$vendorid) {
                if (!$checkid) {
                        if ($checknumber) $checkstr=' and chk.checknumber='.sqlprep($checknumber);
                        if ($invoicenumber) $invoicestr=' and apbill.invoicenumber='.sqlprep($invoicenumber);
                        if ($vendorid) $vendorstr=' and apbill.vendorid='.sqlprep($vendorid);
                        if ($cashed==1) $cashstr=" and chk.cashdate>'0000-00-00'";
                        if ($cashed==2) $cashstr=" and chk.cashdate='0000-00-00'";
                        if ($order==1) $orderstr=' order by checkacct.name, chk.checkdate desc, chk.checknumber';
                        if ($order==2) $orderstr=' order by company.companyname, chk.checkdate desc, chk.checknumber';
                        if ($order==3) $orderstr=' order by chk.checknumber';
                        $recordSet = &$conn->Execute('select company.companyname, chk.checknumber, chk.checkdate, chk.amount, chk.id, checkacct.name, chk.cashdate, chk.checkvoid from apbill,apbillpayment,chk,vendor,company,checkacct where apbillpayment.apbillid=apbill.id and apbill.vendorid=vendor.id and vendor.paytocompanyid=company.id and apbill.gencompanyid='.sqlprep($active_company).$checkstr.$invoicestr.$vendorstr.$cashstr.' and chk.checkvoid=0 and apbillpayment.checkid=chk.id and chk.checkaccountid=checkacct.id'.$orderstr);
                        if ($recordSet->EOF) die(texterror('No matching checks found.'));
                        echo '<form name="mainform" method="post" action="apchecking.php"><table border="1"><tr><th>Checking Account</th><th>Vendor</th><th>Check Date</th><th>Check #</th><th>Amount</th><th>Void?</th><th>Cashed?</th></tr>';
                        while (!$recordSet->EOF) {
                                echo '<tr><td>'.$recordSet->fields[5].'</td><td>'.$recordSet->fields[0].'</td><td>'.$recordSet->fields[2].'</td><td><a href="checks.php?apbill=1&endorser=&checknbr='.$recordSet->fields[4].'" target="_new">'.$recordSet->fields[1].'</a></td><td>'.CURRENCY_SYMBOL.checkdec($recordSet->fields[3],2).'</td>';
                                if ($recordSet->fields[6]=='0000-00-00'||$recordSet->fields[7]==0) { //if cashed or voided, don't show checkboxes
                                        echo '<td align="center"><input type="checkbox" name="void[]" value="'.$recordSet->fields[4].'"'.INC_TEXTBOX.'></td><td align="center"><input type="checkbox" name="paid[]" value="'.$recordSet->fields[4].'"'.INC_TEXTBOX.'>';
                                } elseif ($recordSet->fields[7]==1) { //voided, show Y under void column
                                        echo '<td align="center">Y</td><td align="center">N/A';
                                } else {
                                        echo '<td align="center">N</td><td align="center">Y';
                                };
                                echo '</td></tr>';
                                $recordSet->MoveNext();
                        };
                        echo '</table><input type="submit" value="Submit"></form>';
                };
        } else {
                echo '<form action="apchecking.php" method="post" name="mainform"><table>';
                echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Check #:</td><td><input type="text" name="checknumber" onchange="validateint(this)" size="30" maxlength="20"'.INC_TEXTBOX.'></td></tr>';
                echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Invoice #:</td><td><input type="text" name="invoicenumber" size="30" maxlength="20"'.INC_TEXTBOX.'></td></tr>';
                formapvendorselect('vendorid');
                $recordSet=&$conn->Execute('select count(*) from checkacct where ap=1 and gencompanyid='.sqlprep($active_company));
                if (!$recordSet->EOF) if ($recordSet->fields[0]==1) {
                        $recordSet=&$conn->Execute('select id from checkacct where ap=1 and gencompanyid='.sqlprep($active_company));
                        echo '<input type="hidden" name="checkacctid" value="'.$recordSet->fields[0].'">';
                } else {
                        $recordSet=&$conn->Execute('select id, name from checkacct where ap=1 and gencompanyid='.sqlprep($active_company));
                        echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Checking Account</td><td><select name="checkacctid"'.INC_TEXTBOX.'>';
                        while (!$recordSet->EOF) {
                                echo '<option value="'.$recordSet->fields[0].'">'.$recordSet->fields[1]."\n";
                                $recordSet->MoveNext();
                        };
                        echo '</select></td></tr>';
                };
                echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Cashed?:</td><td><select name="cashed"><option value="" selected>All<option value="1">Show only cashed<option value="2">Show only non-cashed</select></td></tr>';
                echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Order:</td><td><select name="order"><option value="1" selected>Checking Account, Date, Check #<option value="2">Vendor, Date, Check #<option value="3">Check #</select></td></tr>';
                echo '</table><input type="submit" value="Continue"></form>';
        };
?>
<? include('includes/footer.php'); ?>
Return current item: NOLA