validate PHP Class Code Examples

This page contains top rated real world PHP examples of class validate extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: tb-xls.php Project: andrecoetzee/accounting-123.com
0
function bal($id)
{
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($id, "num", 1, 20, "Invalid Trial Balance number.");
    # display errors, if any
    if ($v->isError()) {
        $theseErrors = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $theseErrors .= "<li class=err>" . $e["msg"];
        }
        $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $theseErrors;
    }
    # connect to core DB
    core_connect();
    # get the Trial Balance
    $sql = "SELECT * FROM save_trial_bal WHERE id = '{$id}' AND div = '" . USER_DIV . "'";
    $balRslt = db_exec($sql) or errDie("Unable to retrieve Trial Balance from the Database", SELF);
    if (pg_numrows($balRslt) < 1) {
        return "<center><li> Invalid Trial Balance Number.";
    }
    $bal = pg_fetch_array($balRslt);
    $balance = base64_decode($bal['output']);
    $OUTPUT = $balance;
    include "temp.xls.php";
    Stream("TB", $OUTPUT);
}
Example #2
Show file File: complogin.php Project: kumarsivarajan/accounting-123
0
function login($_POST)
{
    global $_SESSION;
    extract($_POST);
    require_lib("validate");
    $v = new validate();
    $v->isOk($code, "string", 1, 5, "Invalid company name.");
    # Display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        return slctcomp($confirm);
    }
    # Change code to lowercase
    $code = strtolower($code);
    if (!db_check("cubit_" . $code)) {
        return slctcomp("<li class='err'>Invalid Company. Select another company or<br />\n\t\t\tclick <a href='company-new.php?key=recover'>here</a> to see if Cubit can recover from this error.</li>");
    }
    # Get Company Name
    db_conn("cubit");
    $sql = "SELECT name FROM companies WHERE code = '{$code}'";
    $compRslt = db_exec($sql) or errDie("Unable to access database.", SELF);
    if (pg_numrows($compRslt) < 1) {
        $comp['name'] = "";
    } else {
        $comp = pg_fetch_array($compRslt);
    }
    $_SESSION["code"] = $code;
    $_SESSION["comp"] = $comp['name'];
    header("Location: doc-index.php");
}
Example #3
Show file File: paye-rem.php Project: andrecoetzee/accounting-123.com
0
function remPaye($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($id, "num", 1, 20, "Invalid PAYE ID.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_connect();
    # remove job
    $sql = "DELETE FROM paye WHERE id='{$id}'";
    $payeRslt = db_exec($sql) or errDie("Unable to remove PAYE bracket.", SELF);
    if (pg_cmdtuples($payeRslt) < 1) {
        return "Failed to delete PAYE bracket.";
    }
    $remPaye = "\n<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n<tr><th>PAYE bracket removed</th></tr>\n<tr class=datacell><td>PAYE bracket has been successfully removed.</td></tr>\n</table>" . mkQuickLinks(ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees"));
    return $remPaye;
}
Example #4
Show file File: email.php Project: andrecoetzee/accounting-123.com
0
function write_mail($_POST)
{
    //$date = date("Y-m-d  H:i:s");
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($email, "email", 1, 20, "Invalid email address.");
    $v->isOk($msg, "string", 0, 1000, "Invalid text of msg max is 1000.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"] . "</li>";
        }
        return enter_err($_POST, $confirmCust);
        exit;
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    /*db_conn('cubit');
    	$S1 = "INSERT INTO document(name,surname,tel,date) VALUES ('$name','$surname','$tel','$date')";
    	$Ri = db_exec($S1) or errDie("Unable to insert document.");*/
    $write_mail = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Document added</th></tr>\r\n\t<tr class=datacell><td>{$email} has been added to Cubit.</td></tr>\r\n\t</table>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t</table>\r\n\t <p><table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='tdocview.php'>View a list of the document</a></td></tr>\r\n\t</table>";
    return $write_mail;
}
Example #5
Show file File: multi-account-trans.php Project: kumarsivarajan/accounting-123
0
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;
}
Example #6
Show file File: cfe-rem.php Project: andrecoetzee/accounting-123.com
0
function con_data($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($id, "num", 0, 100, "Invalid number.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    db_conn('cubit');
    $Sql = "DELETE FROM cf WHERE id='{$id}' AND div = '" . USER_DIV . "'";
    $Rslt = db_exec($Sql) or errDie("Unable to access database.");
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\n\t<tr><th>Cash flow budget entry Removed</th></tr>\n\t<tr class=datacell><td>Entry has been deleted from the system.</td></tr>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='2' cellspacing='1'>\n\t<tr><th>Quick Links</th></tr>\n\t<tr class='bg-odd'><td><a href='cfe-add.php'>New cash flow budget entry</a></td></tr>\n\t<tr class='bg-odd'><td><a href='cfe-view.php'>View cash flow budget entries</a></td></tr>\n\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $write;
}
Example #7
Show file File: branches-add.php Project: andrecoetzee/accounting-123.com
0
function write_details($_POST)
{
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($branch_ip, "url", 1, 50, "Invalid Branch IP.");
    $v->isOk($branch_company, "url", 4, 4, "Invalid Branch Company Code.");
    $v->isOk($branch_username, "string", 1, 50, "Invalid Branch Username.");
    //	$v->isOk ($branch_password, "url", 1, 50, "Invalid Branch Password.");
    //	$v->isOk ($branch_passwordconfirm, "url", 1, 50, "Invalid Branch Password.");
    //	$v->isOk ($branch_ip, "url", 1, 50, "Invalid Branch IP.");
    if ($branch_password != $branch_passwordconfirm) {
        $v->addError($branch_password, "Passwords do not match.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        return get_details($_POST, $confirmCust);
    }
    db_connect();
    $add_sql = "\n\t\tINSERT INTO branches_data (\n\t\t\tbranch_name, branch_desc, branch_contact, branch_ip, \n\t\t\tdate_added, last_online, branch_username, branch_password, \n\t\t\tlast_login_from, branch_localuser, branch_company\n\t\t) VALUES (\n\t\t\t'{$branch_name}', '{$branch_desc}', '{$branch_contact}', '{$branch_ip}', \n\t\t\t'now', '1990-01-01', '{$branch_username}', md5('{$branch_password}'), \n\t\t\t'1990-01-01', '{$branch_localuser}', '{$branch_company}'\n\t\t)";
    $run_add = pg_exec($add_sql) or errDie("Unable to add branch information.");
    $display = "\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Branch Added</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td>Branch Has Been Added.</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t";
    return $display;
}
Example #8
Show file File: admin-branedit.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    if (isset($back)) {
        return edit($div);
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($div, "num", 1, 50, "Invalid branch id.");
    $v->isOk($brancod, "string", 0, 50, "Invalid branch code.");
    $v->isOk($branname, "string", 1, 255, "Invalid branch name.");
    $v->isOk($brandet, "string", 0, 255, "Invalid details.");
    # 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;
    }
    // Update branch
    db_connect();
    $sql = "UPDATE branches SET brancod = '{$brancod}', branname = '{$branname}', brandet = '{$brandet}' WHERE div = '{$div}'";
    $rslt = db_exec($sql) or errDie("Unable to update branch in Cubit.", SELF);
    $write = "\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Branch edited</th></tr>\r\n\t<tr class=datacell><td>Branch, {$branname} ({$brancod}) has been successfully edited.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='admin-branview.php'>View Branches</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}
Example #9
Show file File: calloutp-rem.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($calloutpid, "num", 1, 50, "Invalid Call Out Person id.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_conn("exten");
    # write to db
    $sql = "DELETE FROM calloutpeople WHERE calloutpid = '{$calloutpid}' AND div = '" . USER_DIV . "'";
    $calloutpRslt = db_exec($sql) or errDie("Unable to remove Sales Person from system.", SELF);
    if (pg_cmdtuples($calloutpRslt) < 1) {
        return "<li class=err>Unable to remove Call Out Person from database.";
    }
    $write = "\r\n\t\t\t<table border='0' cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t\t\t<tr><th>Call Out Person Removed</th></tr>\r\n\t\t\t\t<tr class=datacell><td>Call Out Person <b>{$calloutp}</b>, has been removed.</td></tr>\r\n\t\t\t</table>\r\n\t\t\t<p>\r\n\t\t\t<table border='0' cellpadding='2' cellspacing='1'>\r\n\t\t\t\t<tr><th>Quick Links</th></tr>\r\n\t\t\t\t<tr class='bg-odd'><td><a href='calloutp-view.php'>View Call Out Persons</a></td></tr>\r\n\t\t\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t\t\t</table>";
    return $write;
}
Example #10
Show file File: grpedit.php Project: andrecoetzee/accounting-123.com
0
function con_data($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    //confirm inserted data
    # validate input
    require_lib("validate");
    $v = new validate();
    # Limit field lengths as per database settings
    $v->isOk($grpname, "string", 0, 15, "Invalid  group name.");
    $v->isOk($unit, "string", 1, 15, "Invalid group unit.");
    # display errors, if any
    if ($v->isError()) {
        $theseErrors = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $theseErrors .= "<li class=err>" . $e["msg"] . "</li>";
        }
        $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $theseErrors;
    }
    $con_data = "<h3>Confirm Group Details</h3>\r\n\t\t<table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t\t<form action='" . SELF . "' method=post>\r\n\t\t<input type=hidden name=key value='write'>\r\n\t\t<input type=hidden name=grpname value='{$grpname}'>\r\n\t\t<input type=hidden name=unit value='{$unit}'>\r\n\t\t<input type=hidden name=id  value='{$id}'>\r\n\t\t\r\n\t\t<tr><th colspan=2>Group Details</th></tr>\r\n\t\t<tr class='bg-odd'><td>Group Name</td><td align=center>{$grpname}</td></tr>\r\n\t\t<tr class='bg-odd'><td>Document type</td><td align=center>{$unit}</td></tr>\r\n\t\t<tr><td colspan=2 align=left><input type=submit value='Write &raquo;'></td></tr>\r\n\t</form>\r\n\t</table>";
    return $con_data;
}
Example #11
Show file File: intbrac-edit.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($id, "num", 1, 50, "Invalid interest bracket id.");
    $v->isOk($min, "num", 1, 9, "Invalid minimum amount.");
    $v->isOk($max, "num", 1, 9, "Invalid maximum amount.");
    $v->isOk($percentage, "float", 1, 6, "Invalid interest percentage.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_connect();
    # add PAYE to db
    $sql = "UPDATE intbracs SET min = '{$min}', max = '{$max}', percentage = '{$percentage}' WHERE id = '{$id}'";
    $pRslt = db_exec($sql) or errDie("Unable to updates Interest bracket to database.", SELF);
    $write = "\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Interest bracket edited</th></tr>\r\n\t<tr class=datacell><td>Interest bracket has been successfully edited.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t<tr><th>Quick Links</th></tr>\r\n\t\t<tr bgcolor='#88BBFF'><td><a href='intbrac-view.php'>View Interest Brackets</a></td></tr>\r\n\t\t<tr bgcolor='#88BBFF'><td><a href='main.php'>Main Menu</a></td></tr>\r\n\t</tr>";
    return $write;
}
Example #12
Show file File: calloutp-add.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($calloutp, "string", 1, 255, "Invalid Call Out Person name.");
    $v->isOk($telno, "string", 1, 255, "Invalid Call Out Person Contact Number.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_conn("exten");
    # write to db
    $sql = "INSERT INTO calloutpeople(calloutp,telno,div) VALUES ('{$calloutp}','{$telno}','" . USER_DIV . "')";
    $salespRslt = db_exec($sql) or errDie("Unable to add warehouse to system.", SELF);
    if (pg_cmdtuples($salespRslt) < 1) {
        return "<li class=err>Unable to add Call Out Person to database.";
    }
    $write = "\r\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t\t\t<tr><th>Call Out Person added to system</th></tr>\r\n\t\t\t<tr class=datacell><td>New Call Out Person <b>{$calloutp}</b>, has been successfully added to the system.</td></tr>\r\n\t\t</table>\r\n\t\t<p>\r\n\t\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t\t<tr><th>Quick Links</th></tr>\r\n\t\t\t<tr class='bg-odd'><td><a href='calloutp-view.php'>View Call Out People</a></td></tr>\r\n\t\t\t<tr class='bg-odd'><td><a href='../callout-new.php'>New Call Out Document</a></td></tr>\r\n\t\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t\t</table>";
    return $write;
}
Example #13
Show file File: stockclass-rem.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($classname, "string", 1, 255, "Invalid Classification name.");
    $v->isOk($clasid, "num", 1, 50, "Invalid Classification id.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_connect();
    # write to db
    $sql = "DELETE FROM stockclass WHERE clasid = '{$clasid}' AND div = '" . USER_DIV . "'";
    $clasRslt = db_exec($sql) or errDie("Unable to remove classification from system.", SELF);
    if (pg_cmdtuples($clasRslt) < 1) {
        return "<li class=err>Unable to remove classification.";
    }
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Classification Removed</th></tr>\r\n\t<tr class=datacell><td>Classification <b> ({$classcode}) {$classname}</b>, has been removed from Cubit.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='stockclass-view.php'>View Classifications</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}
Example #14
Show file File: cat-rem.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($catid, "num", 1, 50, "Invalid category id.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_conn("exten");
    # write to db
    $sql = "DELETE FROM categories WHERE catid = '{$catid}' AND div = '" . USER_DIV . "'";
    $catRslt = db_exec($sql) or errDie("Unable to remove category from system.", SELF);
    if (pg_cmdtuples($catRslt) < 1) {
        return "<li class=err>Unable to remove category from database.";
    }
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Category Removed</th></tr>\r\n\t<tr class=datacell><td>Category <b>{$category}</b>, has been removed.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='cat-view.php'>View Categories</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}
Example #15
Show file File: scripts-add.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($name, "string", 1, 255, "Invalid script Function.");
    $v->isOk($file, "string", 1, 255, "Invalid file name.");
    # display errors, if any
    if ($v->isError()) {
        $theseErrors = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $theseErrors .= "<li class=err>" . $e["msg"];
        }
        $theseErrors .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $theseErrors;
    }
    # connect to db
    db_connect();
    # exit if script exists
    $sql = "SELECT * FROM scripts WHERE name = '{$file}'";
    $Rslt = db_exec($sql) or errDie("Unable to check database for scripts scripts.");
    if (pg_numrows($Rslt) > 0) {
        return "Script, <b> {$file} </b>, already exists in database.";
    }
    $sql = "INSERT INTO scripts (name, script) VALUES ('{$file}', '{$name}')";
    $Rslt = db_exec($sql) or errDie("Unable to add script to database.");
    # status report
    $write = "\r\n        <table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n        <tr><th>New script added to database</th></tr>\r\n        <tr class=datacell><td>New file, {$name} ({$file}), was successfully added to Cubit.</td></tr>\r\n        </table>";
    return $write;
}
Example #16
Show file File: cash-link.php Project: kumarsivarajan/accounting-123
0
function write($_POST)
{
    # get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($accid, "num", 1, 70, "Invalid Account Number.");
    # 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;
    }
    # Write the link
    core_connect();
    $sql = "SELECT * FROM bankacc WHERE name = 'Petty Cash' AND div = '" . USER_DIV . "'";
    $checkRslt = db_exec($sql) or errDie("Unable to retrieve Petty Cash Account details from database.");
    if (pg_numrows($checkRslt) > 0) {
        $link = "UPDATE bankacc SET accnum='{$accid}' WHERE name = 'Petty Cash' AND div = '" . USER_DIV . "'";
    } else {
        $link = "INSERT INTO bankacc(name, accnum, div) VALUES ('Petty Cash', '{$accid}', '" . USER_DIV . "')";
    }
    $linkRslt = db_exec($link) or errDie("Unable to add Petty Cash Account link to Database.", SELF);
    # status report
    $write = "\n\t\t<table " . TMPL_tblDflts . " width='30%'>\n\t\t\t<tr>\n\t\t\t\t<th>Petty Cash Account</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Petty Cash Account link has been created.</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<p>\n\t\t<table " . TMPL_tblDflts . " 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='" . bg_class() . "'>\n\t\t\t\t<td><a href='../main.php'>Main Menu</a></td>\n\t\t\t</tr>\n\t\t</table>";
    return $write;
}
Example #17
Show file File: stockcat-det.php Project: andrecoetzee/accounting-123.com
0
function confirm($catid)
{
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($catid, "num", 1, 50, "Invalid stock category id.");
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class=err>-" . $e["msg"] . "<br>";
        }
        return $confirm;
    }
    # Select Stock
    db_connect();
    $sql = "SELECT * FROM stockcat WHERE catid = '{$catid}' AND div = '" . USER_DIV . "'";
    $catRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
    if (pg_numrows($catRslt) < 1) {
        return "<li> Invalid Stock ID.";
    } else {
        $cat = pg_fetch_array($catRslt);
    }
    # get stock vars
    foreach ($cat as $key => $value) {
        ${$key} = $value;
    }
    // Layout
    $confirm = "<h3>Stock Category</h3>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t\t<tr><th width=40%>Field</th><th width=60%>Value</th></tr>\n\t\t\t<tr class='bg-odd'><td>Category Code</td><td>{$catcod}</td></tr>\n\t\t\t<tr class='bg-even'><td>Category Name</td></td><td>{$cat}</td></tr>\n\t\t\t<tr class='bg-odd'><td valign=top>Description</td><td><pre>{$descript}</pre></td></tr>\n\t\t</table>\n\t\t<p>\n\t\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=100>\n\t\t\t<tr><th>Quick Links</th></tr>\n\t\t\t<tr class='bg-odd'><td><a href='stockcat-edit.php?catid={$catid}'>Edit</a></td></tr>\n\t\t\t<tr class='bg-even'><td><a href='stockcat-view.php'>View Stock Category</a></td></tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $confirm;
}
Example #18
Show file File: assetgrp-edit.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($grpid, "num", 1, 50, "Invalid Asset Group id.");
    $v->isOk($grpname, "string", 1, 255, "Invalid Asset Group name or Asset Group name is too long.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_connect();
    # write to db
    $sql = "UPDATE assetgrp SET  grpname = '{$grpname}' WHERE grpid = '{$grpid}' AND div = '" . USER_DIV . "'";
    $grpRslt = db_exec($sql) or errDie("Unable to add edit Asset Group to system.", SELF);
    if (pg_cmdtuples($grpRslt) < 1) {
        return "<li class=err>Unable to edit Asset Group to database.";
    }
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Asset Group edited</th></tr>\r\n\t<tr class=datacell><td>Asset Group <b>{$grpname}</b>, has been edited.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t\t<tr><th>Quick Links</th></tr>\r\n\t\t<tr class='bg-odd'><td><a href='assetgrp-new.php'>Add Asset Group</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='assetgrp-view.php'>View Asset Groups</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}
Example #19
Show file File: nons-sales.php Project: andrecoetzee/accounting-123.com
0
function printStk($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($fday, "num", 1, 2, "Invalid from Date day.");
    $v->isOk($fmon, "num", 1, 2, "Invalid from Date month.");
    $v->isOk($fyear, "num", 1, 4, "Invalid from Date Year.");
    $v->isOk($today, "num", 1, 2, "Invalid to Date day.");
    $v->isOk($tomon, "num", 1, 2, "Invalid to Date month.");
    $v->isOk($toyear, "num", 1, 4, "Invalid to Date Year.");
    # mix dates
    $fromdate = $fyear . "-" . $fmon . "-" . $fday;
    $todate = $toyear . "-" . $tomon . "-" . $today;
    if (!checkdate($fmon, $fday, $fyear)) {
        $v->isOk($fromdate, "num", 1, 1, "Invalid from date.");
    }
    if (!checkdate($tomon, $today, $toyear)) {
        $v->isOk($todate, "num", 1, 1, "Invalid to date.");
    }
    # display errors, if any
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class=err>-" . $e["msg"] . "<br>";
        }
        return $confirm;
    }
    # connect to database
    db_connect();
    // Layout
    $report = "\n\t<h3>Non-Stock Sales Report</h3>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n    <tr><th>Invoice no.</th><th>Date</th><th>Vat</th><th>SubTotal</th><th>Total</th></tr>";
    # Get all relevant records
    db_connect();
    $sql = "SELECT * FROM salesrec WHERE edate >= '{$fromdate}' AND edate <= '{$todate}' AND typ = 'non' AND div = '" . USER_DIV . "'";
    $recRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
    $i = 0;
    $tot = 0;
    $totvat = 0;
    $totexc = 0;
    while ($rec = pg_fetch_array($recRslt)) {
        # Calculate profit
        $tot += $rec['total'];
        $totvat += $rec['vat'];
        $excvat = sprint($rec['total'] - $rec['vat']);
        $totexc += $excvat;
        $report .= "<tr class='" . bg_class() . "'><td>{$rec['invnum']}</td><td>{$rec['edate']}</td><td>" . CUR . " {$rec['vat']}</td><td>" . CUR . " {$excvat}</td><td>" . CUR . " {$rec['total']}</td></tr>";
        $i++;
    }
    $tot = sprint($tot);
    $totvat = sprint($totvat);
    $totexc = sprint($totexc);
    $report .= "<tr class='bg-even'><td colspan=2><b>Totals</b></td><td>" . CUR . " {$totvat}</td><td>" . CUR . " {$totexc}</td><td>" . CUR . " {$tot}</td></tr>\n\t</table>\n    <p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=15%>\n        <tr><td><br></td></tr>\n        <tr><th>Quick Links</th></tr>\n\t\t<tr class='bg-odd'><td><a href='sales-reports.php'>Sales Reports</a></td></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $report;
}
Example #20
Show file File: loan_apply_approve.php Project: andrecoetzee/accounting-123.com
0
function banktrans($bankacc, $trantype, $date, $name, $details, $cheqnum, $amount, $accinv)
{
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($bankacc, "num", 1, 50, "Invalid Bank Account number.");
    $v->isOk($trantype, "string", 1, 50, "Invalid Transaction type.");
    $v->isOk($date, "date", 1, 14, "Invalid Bank Transaction date.");
    $v->isOk($name, "string", 1, 50, "Invalid Name.");
    $v->isOk($details, "string", 0, 255, "Invalid Bank Transacton details.");
    $v->isOk($cheqnum, "num", 0, 50, "Invalid Bank Transacton cheque number.");
    $v->isOk($amount, "float", 1, 20, "Invalid Bank Transacton Amount.");
    $v->isOk($accinv, "num", 1, 20, "Invalid Bank Transaction account involved.");
    # display errors, if any
    if ($v->isError()) {
        $write = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $write .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $OUTPUT = $write . "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        require "../template.php";
    }
    # record the payment record
    db_connect();
    $sql = "\n\t\tINSERT INTO cashbook (\n\t\t\tbankid, trantype, date, name, descript, cheqnum, amount, banked, accinv, div\n\t\t) VALUES (\n\t\t\t'{$bankacc}', '{$trantype}', '{$date}', '{$name}', '{$details}', '{$cheqnum}', '{$amount}', 'no', '{$accinv}', '" . USER_DIV . "'\n\t\t)";
    $Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
}
Example #21
Show file File: allowance-add.php Project: andrecoetzee/accounting-123.com
0
function writeAllow($_POST)
{
    # get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($allowance, "string", 1, 100, "Invalid allowance name.");
    $v->isOk($accid, "num", 1, 20, "Invalid Account number.");
    $v->isOk($taxable, "string", 1, 3, "Invalid taxablility option.");
    $v->isOk($type, "string", 1, 15, "Invalid type.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirmCust .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_connect();
    # write to db
    $sql = "INSERT INTO allowances (allowance, add, accid, type, div) VALUES ('{$allowance}', '{$taxable}', '{$accid}', '{$type}', '" . USER_DIV . "')";
    $allowRslt = db_exec($sql) or errDie("Unable to add allowance to database.", SELF);
    if (pg_cmdtuples($allowRslt) < 1) {
        return "Unable to add allowance to database.";
    }
    $writeAllow = "\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='50%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Allowance added to system</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class='datacell'>\n\t\t\t\t\t\t\t<td>New allowance, {$allowance}, has been successfully added to Cubit.</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t<br>" . mkQuickLinks(ql("allowance-add.php", "Add Allowance"), ql("../admin-employee-add.php", "Add Employee"), ql("../admin-employee-view.php", "View Employees"));
    return $writeAllow;
}
Example #22
Show file File: salaries-staff.php Project: kumarsivarajan/accounting-123
0
function banktrans($bankacc, $trantype, $date, $name, $details, $cheqnum, $amount, $accinv, $id)
{
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($bankacc, "num", 1, 50, "Invalid Bank Account number.");
    $v->isOk($trantype, "string", 1, 50, "Invalid Transaction type.");
    $v->isOk($date, "date", 1, 14, "Invalid Bank Transaction date.");
    $v->isOk($name, "string", 1, 50, "Invalid Name.");
    $v->isOk($details, "string", 0, 255, "Invalid Bank Transacton details.");
    $v->isOk($cheqnum, "num", 0, 50, "Invalid Bank Transacton cheque number.");
    $v->isOk($amount, "float", 1, 20, "Invalid Bank Transacton Amount.");
    $v->isOk($accinv, "num", 1, 20, "Invalid Bank Transaction account involved.");
    # display errors, if any
    if ($v->isError()) {
        $write = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $write .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $OUTPUT = $write . "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        require "../template.php";
    }
    # date format
    $date = explode("-", $date);
    $date = $date[2] . "-" . $date[1] . "-" . $date[0];
    # record the payment record
    db_connect();
    $sql = "INSERT INTO cashbook(bankid, trantype, date, name, descript, cheqnum, amount, banked, accinv, div,fcid) VALUES ('{$bankacc}', '{$trantype}', '{$date}', '{$name}', '{$details}', '{$cheqnum}', '{$amount}', 'no', '{$accinv}', '" . USER_DIV . "','{$id}')";
    $Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
}
Example #23
Show file File: salesp-rem.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    # get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($salespid, "num", 1, 50, "Invalid Sales Person id.");
    # display errors, if any
    if ($v->isError()) {
        $confirmCust = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirmCust .= "<li class=err>" . $e["msg"];
        }
        $confirmCust .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirmCust;
    }
    # connect to db
    db_conn("exten");
    # write to db
    $sql = "DELETE FROM salespeople WHERE salespid = '{$salespid}' AND div = '" . USER_DIV . "'";
    $salespRslt = db_exec($sql) or errDie("Unable to remove Sales Person from system.", SELF);
    if (pg_cmdtuples($salespRslt) < 1) {
        return "<li class=err>Unable to remove Sales Person from database.";
    }
    $write = "<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='50%'>\r\n\t<tr><th>Sales Person Removed</th></tr>\r\n\t<tr class=datacell><td>Sales Person <b>{$salesp}</b>, has been removed.</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='2' cellspacing='1'>\r\n\t<tr><th>Quick Links</th></tr>\r\n\t<tr class='bg-odd'><td><a href='salesp-view.php'>View Sales Persons</a></td></tr>\r\n\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}
Example #24
Show file File: trial_bal.php Project: andrecoetzee/accounting-123.com
0
function note_save($_POST)
{
    extract($_POST);
    require_lib("validate");
    $v = new validate();
    $v->isOk($accid, "num", 1, 9, "Invalid account id.");
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>{$e['msg']}</li>";
        }
        return $confirm;
    }
    // Is the account already in the saved balance sheet table?
    db_conn("cubit");
    $sql = "SELECT * FROM saved_tb_accounts WHERE accid='{$accid}'";
    $sbsacc_rslt = db_exec($sql) or errDie("Unable to retrieve saved balance sheet accounts from Cubit.");
    if (pg_num_rows($sbsacc_rslt)) {
        db_conn("cubit");
        $sql = "UPDATE saved_tb_accounts SET note='" . base64_encode($note) . "' WHERE accid='{$accid}'";
        $note_rslt = db_exec($sql) or errDie("Unable to update note.");
        $note_data = pg_fetch_array($note_rslt);
    } else {
        db_conn("core");
        $sql = "SELECT * FROM accounts WHERE accid='{$accid}'";
        $acc_rslt = db_exec($sql) or errDie("Unable to retrieve account information from Cubit.");
        $acc_data = pg_fetch_array($acc_rslt);
        db_conn("cubit");
        $sql = "\n\t\t\tINSERT INTO saved_tb_accounts (\n\t\t\t\taccid, topacc, accnum, accname, note\n\t\t\t) VALUES (\n\t\t\t\t'{$acc_data['accid']}', '{$acc_data['topacc']}', '{$acc_data['accnum']}', '{$acc_data['accname']}', '" . base64_encode($note) . "'\n\t\t\t)";
        $sbsacc_rslt = db_exec($sql) or errDie("Unable to insert account information into the accounts list.");
    }
    return note_view($_POST, "<tr class='" . bg_class() . "'><td><li>Note has been updated.</li></td></tr>");
}
Example #25
Show file File: workshop-add.php Project: andrecoetzee/accounting-123.com
0
function receipt($_POST)
{
    extract($_POST);
    require_lib("validate");
    $v = new validate();
    $v->isOk($cusnum, "num", 0, 9, "Invalid customer number (dropdown)");
    $v->isOk($description, "string", 1, 255, "Invalid description.");
    $v->isOk($refnum, "num", 0, 255, "Invalid reference number.");
    $v->isOk($conditions, "string", 1, 255, "Invalid workshop conditions.");
    $v->isOk($serno, "string", 0, 255, "Invalid serial number.");
    // Display Errors
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>{$e['msg']}</li>";
        }
        return enter($confirm);
    }
    // Retrieve customer information
    db_conn("cubit");
    $sql = "SELECT * FROM customers WHERE cusnum='{$cusnum}'";
    $cusRslt = db_exec($sql) or errDie("Unable to retrieve customer information from Cubit.");
    $cusData = pg_fetch_array($cusRslt);
    if (!empty($cusData["init"])) {
        $customer = "{$cusData['init']}. {$cusData['title']} {$cusData['surname']}";
    } else {
        $customer = "{$cusData['surname']}";
    }
    $OUTPUT = "\n\t\t\t\t\t<center>\n\t\t\t\t\t<table border='1' cellpadding='10' cellspacing='1' width='750'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td valign='top' colspan='2' width='100%'><h1>" . COMP_NAME . "</h1></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 valign='top' width='50%'>\n\t\t\t\t\t\t\t\t<b>Workshop receipt for:</b><br>\n\t\t\t\t\t\t\t\t{$customer}<br>\n\t\t\t\t\t\t\t\t" . nl2br($cusData["addr1"]) . "<br><br>\n\t\t\t\t\t\t\t\tTel: {$cusData['tel']}<br>\n\t\t\t\t\t\t\t\tFax: {$cusData['fax']}<br>\n\t\t\t\t\t\t\t\tCell: {$cusData['cellno']}<br>\n\t\t\t\t\t\t\t\tBussiness Tel: {$cusData['bustel']}\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td valign='top' width='50%'>\n\t\t\t\t\t\t\t\t<b>Date:</b> " . date("Y-m-d") . "<br>\n\t\t\t\t\t\t\t\t<b>Reference Number:</b> {$refnum}\n\t\t\t\t\t\t\t</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 valign='top' colspan='2' width='100%'><b>Description:</b> {$description}</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 valign='top' colspan='2' width='100%'><b>Serial No:</b> {$serno}</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 valign='top' colspan='2' width='100%'>\n\t\t\t\t\t\t\t\t<b>Workshop Conditions:</b><br>\n\t\t\t\t\t\t\t\t{$conditions}\n\t\t\t\t\t\t\t</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 valign='top' colspan='2' width='100%'>Workshop Sign: _____________________</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</center>";
    require "tmpl-print.php";
}
Example #26
Show file File: quote-cancel.php Project: andrecoetzee/accounting-123.com
0
function write($_POST)
{
    #get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($quoid, "num", 1, 20, "Invalid quote number.");
    # display errors, if any
    $err = "";
    if ($v->isError()) {
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $err .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        return $err;
    }
    # Get quote info
    db_connect();
    $sql = "SELECT * FROM quotes WHERE quoid = '{$quoid}' AND accepted != 'c' AND div = '" . USER_DIV . "'";
    $quoRslt = db_exec($sql) or errDie("Unable to get quote information");
    if (pg_numrows($quoRslt) < 1) {
        return "<li class='err'>Quote Not Found</li>";
    }
    $quo = pg_fetch_array($quoRslt);
    # Get selected customer info
    db_connect();
    $sql = "SELECT * FROM customers WHERE cusnum = '{$quo['cusnum']}' AND div = '" . USER_DIV . "'";
    $custRslt = db_exec($sql) or errDie("Unable to get customer information");
    if (pg_numrows($custRslt) < 1) {
        $sql = "SELECT * FROM quo_data WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
        $custRslt = db_exec($sql) or errDie("Unable to get customer information data");
        $cust = pg_fetch_array($custRslt);
        $cust['cusname'] = $cust['customer'];
        $cust['surname'] = "";
        $cust['addr1'] = "";
    } else {
        $cust = pg_fetch_array($custRslt);
    }
    db_connect();
    /* - Start Copying - */
    pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
    # todays date (sql formatted)
    $date = date("Y-m-d");
    # get selected stock in this quote
    db_connect();
    $sql = "SELECT * FROM quote_items  WHERE quoid = '{$quoid}' AND div = '" . USER_DIV . "'";
    $stkdRslt = db_exec($sql);
    # remove the Quote
    $sql = "DELETE FROM quotes WHERE quoid = '{$quoid}' AND div = '" . USER_DIV . "'";
    $rslt = db_exec($sql) or errDie("Unable to remove Quote from Cubit.", SELF);
    #record (quoid, username, date)
    $sql = "INSERT INTO cancelled_quo(quoid, deptid, username, date, div) VALUES('{$quoid}', '{$quo['deptid']}', '" . USER_NAME . "', '{$date}', '" . USER_DIV . "')";
    $rslt = db_exec($sql) or errDie("Unable to insert Quote record to Cubit.", SELF);
    pglib_transaction("COMMIT") or errDie("Unable to commit a database transaction.", SELF);
    /* - End Copying - */
    // Final Laytout
    $write = "\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Quote canceled</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>Quote for customer <b>{$cust['cusname']} {$cust['surname']}</b> has been canceled.</td>\n\t\t</tr>\n\t</table>\n\t<p>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Quick Links</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td><a href='quote-view.php'>View Quotes</a></td>\n\t\t</tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $write;
}
Example #27
Show file File: petty-req-can.php Project: kumarsivarajan/accounting-123
0
function write($_POST)
{
    //processes
    db_connect();
    # Get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($cashid, "num", 1, 4, "Invalid Reference 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;
    }
    // Delete cashbook ID
    db_connect();
    $sql = "DELETE FROM pettycashbook WHERE cashid='{$cashid}' AND div = '" . USER_DIV . "'";
    $Rslt = db_exec($sql) or errDie("Unable to cancel cheque.", SELF);
    # status report
    $write = "\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width='30%'>\r\n\t\t\t<tr><th>Petty Cash Requisition Cancelled</th></tr>\r\n\t\t\t<tr class=datacell><td>Petty Cash Requisition has been successfully canceled .</td></tr>\r\n\t</table>\r\n\t<p>\r\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=15%>\r\n\t\t<tr><th>Quick Links</th></tr>\r\n\t\t<tr class='bg-odd'><td><a href='petty-req-add.php'>Add Petty Cash Requisition</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='pettycashbook-view.php'>View Petty Cash Requisitions</a></td></tr>\r\n\t\t<tr class='bg-odd'><td><a href='../main.php'>Main Menu</a></td></tr>\r\n\t</table>";
    return $write;
}