コード例 #1
0
function print_entries($_POST)
{
    extract($_POST);
    if (!isset($print_entry) or !is_array($print_entry)) {
        return show_entries($_POST, "<li class='err'>Please select at least 1 entry to print.</li><br>");
    }
    db_connect();
    $listing = "";
    foreach ($print_entry as $each => $own) {
        #get this entry
        $get_entry = "SELECT * FROM supp_payment_cheques WHERE id = '{$own}' LIMIT 1";
        $run_entry = db_exec($get_entry) or errDie("Unable to get payment information.");
        if (pg_numrows($run_entry) < 1) {
            $listing .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Unable to get payment information. ({$own})</td>\n\t\t\t\t</tr>";
        } else {
            $parr = pg_fetch_array($run_entry);
            #now figure out what to output ...
            $pay_type = getCSetting("SUPP_PAY_TYPE");
            if (!isset($pay_type) or strlen($pay_type) < 1) {
                $pay_type = "cheq_man";
            }
            $do_auto = FALSE;
            $do_manu = FALSE;
            if ($pay_type == "cheq_man") {
                $do_manu = TRUE;
            } else {
                $do_auto = TRUE;
            }
            $supname = $parr['supname'];
            $cheqnum = $parr['cheqnum'];
            $amt = $parr['amt'];
            $date = $parr['date'];
            if ($do_auto) {
                $proc_amt = str_pad($amt, 8, "0", "PAD_LEFT");
                $val1 = substr($proc_amt, 0, 2);
                $val2 = substr($proc_amt, 2, 1);
                $val3 = substr($proc_amt, 3, 1);
                $val4 = substr($proc_amt, 4, 1);
                $val5 = substr($proc_amt, 5, 1);
                $val6 = substr($proc_amt, 6, 1);
                $val7 = substr($proc_amt, 7, 1);
                $val8 = substr($proc_amt, 9, 2);
                #lets calculate the stars to show on the cheque
                $star_mils = calc_stars($val1);
                $star_hundred_thou = calc_stars($val2);
                $star_ten_thou = calc_stars($val3);
                $star_thou = calc_stars($val4);
                $star_hundreds = calc_stars($val5);
                $star_tens = calc_stars($val6);
                $star_units = calc_stars($val7);
                $star_cents = calc_stars($val8, TRUE);
                #print the cheque ...
                $listing .= "\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='60%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width='40%' colspan='7'>{$supname}</td>\n\t\t\t\t\t\t\t<td>{$date}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width='40'>{$star_mils}</td>\n\t\t\t\t\t\t\t<td width='40'>{$star_hundred_thou}</td>\n\t\t\t\t\t\t\t<td width='40'>{$star_ten_thou}</td>\n\t\t\t\t\t\t\t<td width='40'>{$star_thou}</td>\n\t\t\t\t\t\t\t<td width='40'>{$star_hundreds}</td>\n\t\t\t\t\t\t\t<td width='40'>{$star_tens}</td>\n\t\t\t\t\t\t\t<td width='40'>{$star_units}</td>\n\t\t\t\t\t\t\t<td width='40'>{$star_cents}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='5'></td>\n\t\t\t\t\t\t\t<td colspan='3' nowrap>" . CUR . " " . sprint($amt) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t</table>";
            } elseif ($do_manu) {
                #show the details for the cheque ...
                $listing .= "\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='60%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>{$cheqnum}</td>\n\t\t\t\t\t\t\t<td>{$supname}</td>\n\t\t\t\t\t\t\t<td>{$date}</td>\n\t\t\t\t\t\t\t<td>" . CUR . " {$amt}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>";
            }
        }
    }
    $OUTPUT = "\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t{$listing}\n\t\t</table>";
    require "../tmpl-print.php";
    //	return $display;
}
コード例 #2
0
function get_process($_POST)
{
    extract($_POST);
    if (!isset($runids) or !is_array($runids)) {
        return printSupp($_POST, "<li class='err'>Please Select At Least 1 Creditor To Process</li");
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    foreach ($runids as $each => $own) {
        $v->isOk($amt[$each], "float", 1, 10, "Invalid payment amount.({$amt[$each]})");
        $v->isOk($own, "num", 1, 10, "Invalid supplier number.({$own})");
        if (isset($amt[$each]) and $amt[$each] < 0.01) {
            $v->addError($amt[$each], "Payment Amount is too small.");
        }
    }
    # 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 printSupp($_POST, $confirm);
    }
    if (!isset($bankid)) {
        $bankid = 0;
    }
    #handle the first cheque number
    $cheq_start = $cheq_start + 0;
    // layout
    $add = "<table " . TMPL_tblDflts . ">";
    $i = 0;
    #generate a unique entry for this run ...
    $run_id = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
    //print "$run_id<br>";
    foreach ($runids as $each) {
        db_connect();
        # Supplier name
        $sql = "SELECT supno,supname,balance FROM suppliers WHERE supid = '{$supno[$each]}' AND div = '" . USER_DIV . "'";
        $supRslt = db_exec($sql);
        $sup = pg_fetch_array($supRslt);
        if (!isset($amt)) {
            $amt = "";
            $descript = "";
            $cheqnum = "";
            $reference = "";
        }
        if (!isset($date_day)) {
            $date_year = date("Y");
            $date_month = date("m");
            $date_day = date("d");
        }
        $proc_amt = str_pad($amt[$each], 8, "0", "PAD_LEFT");
        $val1 = substr($proc_amt, 0, 2);
        $val2 = substr($proc_amt, 2, 1);
        $val3 = substr($proc_amt, 3, 1);
        $val4 = substr($proc_amt, 4, 1);
        $val5 = substr($proc_amt, 5, 1);
        $val6 = substr($proc_amt, 6, 1);
        $val7 = substr($proc_amt, 7, 1);
        $val8 = substr($proc_amt, 9, 2);
        #lets calculate the stars to show on the cheque
        $star_mils = calc_stars($val1);
        $star_hundred_thou = calc_stars($val2);
        $star_ten_thou = calc_stars($val3);
        $star_thou = calc_stars($val4);
        $star_hundreds = calc_stars($val5);
        $star_tens = calc_stars($val6);
        $star_units = calc_stars($val7);
        $star_cents = calc_stars($val8, TRUE);
        #display this cheque
        $add .= "\n\t\t\t\t\t<input type='hidden' name='supid[]' value='{$supno[$each]}'>\n\t\t\t\t\t<input type='hidden' size='5' name='pur' value=''>\n\t\t\t\t\t<input type='hidden' size='5' name='inv' value=''>\n\t\t\t\t\t<input type='hidden' name='all' value='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='center'> {$sup['supname']}</td>\n\t\t\t\t\t\t<td colspan='8'></td>\n\t\t\t\t\t\t<td align='right'>{$date_year}/{$date_month}/{$date_day}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t<td width='40'>{$star_mils}</td>\n\t\t\t\t\t\t<td width='40'>{$star_hundred_thou}</td>\n\t\t\t\t\t\t<td width='40'>{$star_ten_thou}</td>\n\t\t\t\t\t\t<td width='40'>{$star_thou}</td>\n\t\t\t\t\t\t<td width='40'>{$star_hundreds}</td>\n\t\t\t\t\t\t<td width='40'>{$star_tens}</td>\n\t\t\t\t\t\t<td width='40'>{$star_units}</td>\n\t\t\t\t\t\t<td width='40'>{$star_cents}</td>\n\t\t\t\t\t\t<td align='left'>R " . sprint($amt[$each]) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t" . TBL_BR . "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='10'><hr></td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
        db_conn('contract');
        ##PTH/CUBIT
        #store this cheque as having been printed...
        /*		$cheq_sql = "INSERT INTO supp_creditor_run_cheques (supid,bankid,amount,cheq_num,proc_date,printed,handed_over,received,conid,remit) VALUES 
        				('$supno[$each]','$bankid','$amt[$each]','$cheq_start','$date_year-$date_month-$date_day','yes','no','no','$conid[$each]','$remit[$each]')";*/
        $cheq_sql = "INSERT INTO supp_creditor_run_cheques (supid,bankid,amount,cheq_num,proc_date,printed,handed_over,received,remit,remarks) VALUES \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t('{$supno[$each]}','{$bankid}','{$amt[$each]}','{$cheq_start}','{$date_year}-{$date_month}-{$date_day}','yes','no','no','{$remit[$each]}','{$remarks[$each]}')";
        $run_cheq = db_exec($cheq_sql) or errDie("Unable to store cheque information.");
        $entry_id = pglib_lastid("supp_creditor_run_cheques", "id");
        #also store this as a run ...
        $run_sql = "\n\t\t\t\t\t\tINSERT INTO credit_runs \n\t\t\t\t\t\t\t(run_id,entry_id,supid,bankid,amount,cheq_num,proc_date,printed,handed_over,received,remit,remarks) \n\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t\t('{$run_id}','{$entry_id}','{$supno[$each]}','{$bankid}','{$amt[$each]}','{$cheq_start}','{$date_year}-{$date_month}-{$date_day}','yes','no','no','{$remit[$each]}','{$remarks[$each]}')";
        $run_run = db_exec($run_sql) or errDie("");
        $cheq_start++;
        $i++;
    }
    ##PTH/CUBIT
    //	db_conn ('contract');
    //	foreach ($conid AS $each => $own){
    //		if ($own != "0"){
    //			$get_upd = "UPDATE contract_recs SET remarks = '$remarks[$each]' WHERE conid = '$own' AND remit = '$remit[$each]'";
    //			$run_upd = db_exec($get_upd) or errDie("Unable to get previous remittance information.");
    //		}
    //	}
    $add .= "</table>";
    $OUTPUT = "\n\t\t\t<table border='0' width='100%'>\n\t\t\t<form action='" . SELF . "' method='POST' name='form'>\n\t\t\t\t<input type='hidden' name='key' value='alloc'>\n\t\t\t\t{$add}\n\t\t\t</form>\n\t\t\t</table>\n    \t\t";
    //       return $OUTPUT;
    require "tmpl-print.php";
}