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


PHP user_is_admin函数代码示例

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


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

示例1: enter

function enter()
{
    extract($_REQUEST);
    $fields = array();
    $fields["user_id"] = USER_ID;
    extract($fields, EXTR_SKIP);
    // Retrieve users
    $users_out = "";
    if (user_is_admin(USER_NAME)) {
        $sql = "\r\n\t\tSELECT DISTINCT user_id, username FROM cubit.hire_trans\r\n\t\t\tLEFT JOIN cubit.users ON hire_trans.user_id=users.userid\r\n\t\tWHERE done='t' AND processed='0'\r\n\t\tORDER BY username ASC";
        $user_rslt = db_exec($sql) or errDie("Unable to retrieve users.");
        $user_sel = "<select name='user_id'>";
        while ($user_data = pg_fetch_array($user_rslt)) {
            $sel = $user_id == $user_data["user_id"] ? "selected" : "";
            $user_sel .= "\r\n\t\t\t<option value='{$user_data['user_id']}' {$sel}>\r\n\t\t\t\t{$user_data['username']}\r\n\t\t\t</option>";
        }
        $user_sel .= "</select>";
        $users_out = "\r\n\t\t<form method='post' action='" . SELF . "'>\r\n\t\t<input type='hidden' name='key' value='enter' />\r\n\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t<tr>\r\n\t\t\t\t<th colspan='2'>User</th>\r\n\t\t\t</tr>\r\n\t\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t\t<td>{$user_sel}</td>\r\n\t\t\t\t<td><input type='submit' value='Select' /></td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t</form>";
    }
    // Get outstanding rentals count
    $sql = "\r\n\tSELECT count(id) FROM cubit.hire_trans\r\n\tWHERE user_id='{$user_id}' AND done='t' AND processed='0'";
    $trans_rslt = db_exec($sql) or errDie("Unable to retrieve transactions.");
    $trans_count = pg_fetch_result($trans_rslt, 0);
    $sql = "\r\n\tSELECT count(id) FROM cubit.hire_trans_returned\r\n\tWHERE processed='f'";
    $rtrans_rslt = db_exec($sql) or errDie("Unable to retrieve returns.");
    $trans_count += pg_fetch_result($rtrans_rslt, 0);
    $OUTPUT = "\r\n\t<center>\r\n\t<h3>Video POS Cashup</h3>\r\n\t{$users_out}\r\n\t<table " . TMPL_tblDflts . ">\r\n\t\t<tr>\r\n\t\t\t<th>Type</th>\r\n\t\t\t<th>Total Outstanding</th>\r\n\t\t</tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td>Video Rentals</td>\r\n\t\t\t<td>{$trans_count}</td>\r\n\t\t</tr>\r\n\t\t<tr class='" . bg_class() . "'>\r\n\t\t\t<td colspan='2' align='center'>\r\n\t\t\t\t<a href='" . SELF . "?key=run&user_id={$user_id}'\r\n\t\t\t\tstyle='font-size: 1.6em'>Run</a>\r\n\t\t\t</td>\r\n\t\t</tr>\r\n\t</table>";
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:29,代码来源:videoposrun.php

示例2: enter

function enter()
{
    extract($_REQUEST);
    $fields = array();
    $fields["user_id"] = USER_ID;
    extract($fields, EXTR_SKIP);
    $users_out = "";
    if (user_is_admin(USER_NAME)) {
        $sql = "SELECT DISTINCT user_id FROM cubit.hire_trans";
        $user_rslt = db_exec($sql) or errDie("Unable to retrieve user ids.");
        $users_sel = "<select name='user_id'>";
        while ($user_data = pg_fetch_array($user_rslt)) {
            $sql = "\n\t\t\tSELECT username FROM cubit.users\n\t\t\tWHERE userid='{$user_data['user_id']}'";
            $username_rslt = db_exec($sql) or errDie("Unable to retrieve user.");
            $username = pg_fetch_result($username_rslt, 0);
            $sel = $user_data["user_id"] == $user_id ? "selected='t'" : "";
            $users_sel .= "\n\t\t\t<option value='{$user_data['user_id']}' {$sel}>\n\t\t\t\t{$username}\n\t\t\t</option";
        }
        $users_sel .= "</select>";
        $users_out = "\n\t\t<form method='post' action='" . SELF . "'>\n\t\t<input type='hidden' name='key' value='enter' />\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th colspan='2'>User</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$users_sel}</td>\n\t\t\t\t<td><input type='submit' value='Select' /></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>";
    }
    // Get outstanding rentals count
    $sql = "\n\tSELECT count(id) FROM cubit.hire_trans\n\tWHERE user_id='{$user_id}' AND done='y'";
    $rental_rslt = db_exec($sql) or errDie("Unable to retrieve outstanding rentals");
    $rental_count = pg_fetch_result($rental_rslt, 0);
    // Get outstanding invoices count
    $sql = "\n\tSELECT count(id) FROM cubit.hire_invoice_trans\n\tWHERE user_id='" . $user_id . "' AND done='t' AND hire_id > 0";
    $invoice_rslt = db_exec($sql) or errDie("Unable to retrieve outstanding invoices.");
    $invoice_count = pg_fetch_result($invoice_rslt, 0);
    $OUTPUT = "\n\t<center>\n\t<h3>Rental POS Cash Up</h3>\n\t{$users_out}\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Type</th>\n\t\t\t<th>Total Outstanding</th>\n<!--\n\t\t\t<th colspan='2'>Options</th>\n-->\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>Rentals</td>\n\t\t\t<td>{$rental_count}</td>\n<!--\n\t\t\t<td>\n\t\t\t\t<a href='" . SELF . "?key=run&type=rental&user_id={$user_id}'>\n\t\t\t\t\tRun\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<a href='" . SELF . "?key=view_rental&type=rental&user_id={$user_id}'>\n\t\t\t\t\tView\n\t\t\t\t</a>\n\t\t\t</td>\n-->\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>Invoices</td>\n\t\t\t<td>{$invoice_count}</td>\n<!--\t\t\t\n\t\t\t<td>\n\t\t\t\t<a href='" . SELF . "?key=run&type=invoice&user_id={$user_id}'>\n\t\t\t\t\tRun\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<a href='" . SELF . "?key=view&type=invoice&user_id={$user_id}'>\n\t\t\t\t\tView\n\t\t\t\t</a>\n\t\t\t</td>\n-->\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='4' align='center'>\n\t\t\t\t<a href='" . SELF . "?key=run&user_id={$user_id}'\n\t\t\t\tstyle='font-size: 1.6em'>Run</a>\n\t\t\t</td>\n\t\t</tr>\n\t</table>\n\t</center>";
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:32,代码来源:hirepos_run.php

示例3: tweet_delete

function tweet_delete()
{
    include_once 'login.php';
    include_once 'sinaoauth.inc.php';
    $id = get_current_user_id();
    $args = func_get_args();
    $key = $args[2];
    if (!$key) {
        die('Invalid Argument!');
    }
    connect_db();
    $view = "SELECT tweets.* FROM tweets, (SELECT user_id, user_site_id, site_id FROM accountbindings) AS ac WHERE tweets.user_site_id = ac.user_site_id AND ac.user_id='{$id}' AND ac.site_id = tweets.site_id AND tweets.tweet_id='{$key}' AND tweets.deleted='0'";
    $list = mysql_query($view);
    $row = mysql_fetch_array($list);
    if ($row or user_is_admin()) {
        if ($row) {
            $c = new WeiboClient(SINA_AKEY, SINA_SKEY, $GLOBALS['user']['sinakey']['oauth_token'], $GLOBALS['user']['sinakey']['oauth_token_secret']);
            $msg = $c->destroy($row['tweet_site_id']);
        }
        $view = "UPDATE tweets SET deleted='1' WHERE tweet_id='{$key}'";
        $list = mysql_query($view) or die("Delete error!");
    } else {
        print $key;
        die(": Non-exist Error!");
    }
}
开发者ID:soross,项目名称:0f523140-f3b3-4653-89b0-eb08c39940ad,代码行数:26,代码来源:tweet.inc.php

示例4: display

function display()
{
    extract($_REQUEST);
    if (user_is_admin(USER_ID)) {
        $user_id = $_REQUEST["user_id"];
    } else {
        $user_id = USER_ID;
    }
    // Retrieve user information
    $sql = "SELECT * FROM cubit.users WHERE userid='{$user_id}'";
    $user_rslt = db_exec($sql) or errDie("Unable to retrieve user.");
    $user_data = pg_fetch_array($user_rslt);
    define("SECONDS_IN_7_DAYS", 604800);
    $seven_days = date("Y-m-d", time() + SECONDS_IN_7_DAYS);
    // Retrieve orders for expired orders and orders that will expire within
    // 7 days
    $sql = "SELECT * FROM cubit.sorders\n\t\t\tWHERE ddate<'{$seven_days}' AND accepted='n' AND done='y'\n\t\t\t\tAND username='{$user_data['username']}'\n\t\t\tORDER BY ddate DESC";
    $sorder_rslt = db_exec($sql) or errDie("Unable to retrieve sales orders.");
    $sorder_out = "";
    while ($sorder_data = pg_fetch_array($sorder_rslt)) {
        $sorder_out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$sorder_data['ddate']}</td>\n\t\t\t\t<td>{$sorder_data['odate']}</td>\n\t\t\t\t<td>{$sorder_data['cusname']} {$sorder_data['surname']}</td>\n\t\t\t\t<td>{$sorder_data['ordno']}</td>\n\t\t\t\t<td>{$sorder_data['cusname']}</td>\n\t\t\t\t<td>" . CUR . "{$sorder_data['discount']}</td>\n\t\t\t\t<td>" . CUR . "{$sorder_data['total']}</td>\n\t\t\t</tr>";
    }
    if (empty($sorder_out)) {
        $sorder_out = "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='7'>No items found</td>\n\t\t</tr>";
    }
    $OUTPUT = "\n\t\t<center>\n\t\t<h3>Sales Orders Past Due/Delivery Date</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Due Date</th>\n\t\t\t\t<th>Sales Order Date</th>\n\t\t\t\t<th>Customer</th>\n\t\t\t\t<th>Sales Order No</th>\n\t\t\t\t<th>Customer Order No</th>\n\t\t\t\t<th>Discount</th>\n\t\t\t\t<th>Total</th>\n\t\t\t</tr>\n\t\t\t{$sorder_out}\n\t\t</table>\n\t\t</center>";
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:28,代码来源:sorder-due.php

示例5: user_ensure_admin

function user_ensure_admin()
{
    user_ensure_authenticated();
    if (!user_is_admin()) {
        header("Location: " . BASE_URL . "?errormsg=" . urlencode("不要做坏事哟^o^"));
        die("Access denied");
    }
}
开发者ID:soross,项目名称:0f523140-f3b3-4653-89b0-eb08c39940ad,代码行数:8,代码来源:login.inc.php

示例6: user_in_store_team

 function user_in_store_team($whid, $user_id)
 {
     if (user_is_admin($user_id)) {
         return true;
     }
     $sql = "SELECT team_id FROM exten.warehouses WHERE whid='{$whid}'";
     $wh_rslt = db_exec($sql) or errDie("Unable to retrieve stores.");
     $team_id = pg_fetch_result($wh_rslt, 0);
     return user_in_team($team_id, $user_id);
 }
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:10,代码来源:user.lib.php

示例7: __construct

 public function __construct()
 {
     parent::__construct();
     $this->load->library(array('session', 'form_validation'));
     $this->load->helper('string');
     $this->load->database();
     $this->load->model('user_model');
     if (!logged_in() or !user_is_admin()) {
         redirect('user/login');
     }
 }
开发者ID:Roky994,项目名称:ep-webstore,代码行数:11,代码来源:Admin.php

示例8: write

function write($_POST)
{
    extract($_POST);
    if (isset($back)) {
        unset($_POST["back"]);
        return enter($_POST);
    }
    # CHECK IF THIS DATE IS IN THE BLOCKED RANGE
    $blocked_date_from = getCSetting("BLOCKED_FROM");
    $blocked_date_to = getCSetting("BLOCKED_TO");
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($bankid, "num", 1, 20, "Invalid Bank ID.");
    foreach ($amount as $key => $value) {
        # check all vars
        $v->isOk($to[$key], "string", 1, 255, "Invalid receipient/depositor.");
        $v->isOk($trantype[$key], "string", 1, 20, "Invalid transaction type.");
        $v->isOk($descript[$key], "string", 0, 255, "Invalid description.");
        $v->isOk($ref[$key], "string", 0, 255, "Invalid reference <b>[{$key}]</b>.");
        $v->isOk($cheqnum[$key], "num", 0, 20, "Invalid cheque number <b>[{$key}]</b>.");
        $v->isOk($amount[$key], "float", 1, 8, "Invalid amount <b>[{$key}]</b>.");
        $v->isOk($accinv[$key], "num", 1, 20, "Invalid account involved <b>[{$key}]</b>.");
        $v->isOk($date[$key], "date", 1, 15, "Invalid date <b>[{$key}]</b>.");
        if (strtotime($date[$key]) >= strtotime($blocked_date_from) and strtotime($date[$key]) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
            return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
        }
    }
    # 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;
    }
    # Processes
    db_connect();
    # Begin Transaction
    pglib_transaction("BEGIN");
    # Some info
    $bankacc = getbankaccid($bankid);
    $vatacc = gethook("accnum", "salesacc", "name", "VAT");
    foreach ($amount as $key => $amt) {
        $totamt = $amount[$key];
        if ($chrgvat[$key] == "exc") {
            $totamt += $vat[$key];
        } elseif ($chrgvat[$key] == "inc") {
            $amount[$key] -= $vat[$key];
        } else {
            $vat[$key] = "No VAT";
        }
        if ($cheqnum[$key] == '') {
            $cheqnum[$key] = 0;
        }
        if (!isset($batch)) {
            $refnum = getrefnum();
            if (strtolower($trantype[$key]) == 'deposit') {
                $vatacc = gethook("accnum", "salesacc", "name", "VAT", "1");
                writetrans($bankacc, $accinv[$key], $date[$key], $refnum, $amount[$key], $descript[$key]);
                if ($vat[$key] != 0) {
                    # DT(Bank), CT(VAT)
                    $vat[$key] += 0;
                    writetrans($bankacc, $vatacc, $date[$key], $refnum, $vat[$key], $descript[$key] . " VAT");
                    db_conn('cubit');
                    $Sl = "SELECT * FROM vatcodes WHERE id='{$vatcode[$key]}'";
                    $Rt = db_exec($Sl) or errDie("Unable to get data.");
                    $vd = pg_fetch_array($Rt);
                    vatr($vatcode[$key], $date[$key], "OUTPUT", $vd['code'], $refnum, $descript[$key] . " VAT", $totamt, $vat[$key]);
                }
            } else {
                $vatacc = gethook("accnum", "salesacc", "name", "VAT");
                writetrans($accinv[$key], $bankacc, $date[$key], $refnum, $amount[$key], $descript[$key]);
                if ($vat[$key] != 0) {
                    # DT(Bank), CT(VAT)
                    $vat[$key] += 0;
                    writetrans($vatacc, $bankacc, $date[$key], $refnum, $vat[$key], $descript[$key] . " VAT");
                    db_conn('cubit');
                    $Sl = "SELECT * FROM vatcodes WHERE id='{$vatcode[$key]}'";
                    $Rt = db_exec($Sl) or errDie("Unable to get data.");
                    $vd = pg_fetch_array($Rt);
                    vatr($vatcode[$key], $date[$key], "INPUT", $vd['code'], $refnum, $descript[$key] . " VAT", -$totamt, -$vat[$key]);
                }
            }
            $vat[$key] += 0;
            db_connect();
            $sql = "\n\t\t\t\tINSERT INTO cashbook (\n\t\t\t\t\tbankid, trantype, date, name, descript, cheqnum, \n\t\t\t\t\tamount, banked, accinv, div,chrgvat,vat,reference\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$bankid}', lower('{$trantype[$key]}'), '{$date[$key]}', '{$to[$key]}', '{$descript[$key]}', '{$cheqnum[$key]}', \n\t\t\t\t\t'{$totamt}', 'no', '{$accinv[$key]}', '" . USER_DIV . "','{$chrgvat[$key]}', '{$vat[$key]}','{$ref[$key]}'\n\t\t\t\t)";
            $Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
        } else {
            db_connect();
            $vat[$key] += 0;
            $sql = "\n\t\t\t\tINSERT INTO batch_cashbook (\n\t\t\t\t\tbankid, trantype, date, name, descript, cheqnum, \n\t\t\t\t\tamount, banked, accinv, div, chrgvat, vat, vatcode, \n\t\t\t\t\treference\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$bankid}', lower('{$trantype[$key]}'), '{$date[$key]}', '{$to[$key]}', '{$descript[$key]}', '{$cheqnum[$key]}', \n\t\t\t\t\t'{$totamt}', 'no', '{$accinv[$key]}', '" . USER_DIV . "','{$chrgvat[$key]}','{$vat[$key]}','{$vatcode[$key]}', \n\t\t\t\t\t'{$ref[$key]}'\n\t\t\t\t)";
            $Rslt = db_exec($sql) or errDie("Unable to add bank payment to database.", SELF);
        }
    }
    # Get bank details
    $bankAccRslt = get("cubit", "*", "bankacct", "bankid", $bankid);
    $bankacc = pg_fetch_array($bankAccRslt);
//.........这里部分代码省略.........
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:101,代码来源:bank-stmnt.php

示例9: printSord

function printSord()
{
    extract($_REQUEST);
    if (isset($key)) {
        $key = strtolower($key);
        switch ($key) {
            case "export to spreadsheet":
            case "print":
            case "save":
                $pure = true;
                break;
            case "view":
            default:
                $pure = false;
        }
    } else {
        $pure = false;
    }
    if (!isset($from_year)) {
        explodeDate(false, $from_year, $from_month, $from_day);
        explodeDate(false, $to_year, $to_month, $to_day);
    }
    $printSord = "";
    if (!$pure) {
        $printSord .= "\n\t\t<form method='post' action='" . SELF . "'>\n\t    <table " . TMPL_tblDflts . ">\n\t    <tr>\n\t    \t<th colspan='2'>View Options</th>\n\t    </tr>\n\t    <tr class='" . bg_class() . "'>\n\t    \t<td>Begin Date:</td>\n\t    \t<td>" . mkDateSelect("from", $from_year, $from_month, $from_day) . "</td>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t    \t<td>End Date:</td>\n\t    \t<td>" . mkDateSelect("to", $to_year, $to_month, $to_day) . "</td>\n\t    </tr>\n\t    <tr>\n\t    \t<td colspan='2' align='right'><input type='submit' value='Filter' /></td>\n\t    </tr>\n\t    </table>";
    }
    if (!isset($key)) {
        $printSord .= "</form>";
        return $printSord;
    }
    $printSord .= "\n\t<table " . TMPL_tblDflts . ">\n\t<tr>\n\t\t<th>Department</th>\n\t\t<th>Sales Person</th>\n\t\t<th>Sales Order No.</th>\n\t\t<th>Sales Order Date</th>\n\t\t<th>Customer Name</th>\n\t\t<th>Order No</th>\n\t\t" . ($pure ? "" : "<th colspan=6>Options</th>") . "\n\t</tr>";
    $i = 0;
    $sql = "SELECT * FROM cubit.sorders\n    \t\tWHERE accepted = 'n' AND done = 'y' AND div = '" . USER_DIV . "' AND\n    \t\t\todate BETWEEN '{$from_year}-{$from_month}-{$from_day}' AND \n    \t\t\t\t'{$to_year}-{$to_month}-{$to_day}' AND slip_done='n'\n    \t\tORDER BY sordid DESC";
    $sordRslt = db_exec($sql) or errDie("Unable to retrieve Sales Orders.");
    if (pg_numrows($sordRslt) < 1) {
        $printSord .= "\n\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t<td colspan='13'>No Sales Orders matching criteria.</td>\n\t\t</tr>";
    } else {
        while ($sord = pg_fetch_array($sordRslt)) {
            # alternate bgcolor
            $bgColor = bgcolor($i);
            # format date
            $sord['odate'] = explode("-", $sord['odate']);
            $sord['odate'] = $sord['odate'][2] . "-" . $sord['odate'][1] . "-" . $sord['odate'][0];
            $det = "sorder-details.php";
            $cancel = "sorder-cancel.php";
            $accept = "sorder-accept.php";
            $print = "sorder-print.php";
            $edit = "sorder-new.php";
            if ($sord['location'] == 'int') {
                $det = "intsorder-details.php";
                $cancel = "intsorder-cancel.php";
                $accept = "intsorder-accept.php";
                $print = "intsorder-print.php";
                $edit = "intsorder-new.php";
            }
            $sp4 = "&nbsp;&nbsp;&nbsp;&nbsp;";
            $bcurr = CUR;
            if ($sord['location'] == 'int') {
                $bcurr = $sord['currency'];
            }
            if ($sord["username"] == USER_NAME || user_is_admin(USER_NAME)) {
                $done = "\n\t\t\t\t<a href='picking_slip_done.php?sordid={$sord['sordid']}'>\n\t\t\t\t\tCancel\n\t\t\t\t</a>";
            } else {
                $done = "";
            }
            $printSord .= "<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$sord['deptname']}</td>\n\t\t\t\t<td>{$sord['salespn']}</td>\n\t\t\t\t<td>{$sord['sordid']}</td>\n\t\t\t\t<td align=center>{$sord['odate']}</td>\n\t\t\t\t<td>{$sord['cusname']} {$sord['surname']}</td>\n\t\t\t\t<td align=right>{$sord['ordno']}</td>\n\t\t\t\t<td>\n\t\t\t\t\t<a href='javascript:printer(\"picking_slips/picking_slip_print.php?sordid={$sord['sordid']}\")'>\n\t\t\t\t\t\tPrint Picking Slip\n\t\t\t\t\t</a>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<a href='" . SELF . "?key=invoice&sordid={$sord['sordid']}'>\n\t\t\t\t\t\tInvoice\n\t\t\t\t\t</a>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<a href='" . SELF . "?key=pos_invoice&sordid={$sord['sordid']}'>\n\t\t\t\t\t\tPOS Invoice\n\t\t\t\t\t</a>\n\t\t\t\t</td>\n\t\t\t\t<td>{$done}</td>";
        }
    }
    if (!$pure) {
        $printSord .= "\n\t\t</table>\n\t\t</form>";
    } else {
        $printSord .= "\n\t\t</table>";
        $OUTPUT = clean_html($printSord);
        switch ($key) {
            case "export to spreadsheet":
                require_lib("xls");
                StreamXLS("sorders", $OUTPUT);
                break;
            case "print":
                $OUTPUT = "<h3>Sales Orders</h3>{$OUTPUT}";
                require "tmpl-print.php";
                break;
            case "save":
                $pure = true;
                break;
        }
    }
    return $printSord;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:89,代码来源:sorder-view.php

示例10: write

function write($_GET)
{
    # get vars
    extract($_GET);
    # validate input
    require_lib("validate");
    $v = new validate();
    $prd += 0;
    $v->isOk($purid, "num", 1, 20, "Invalid Invoice number.");
    $sndate = $p_year . "-" . $p_month . "-" . $p_day;
    if (!checkdate($p_month, $p_day, $p_year)) {
        $v->addError($sdate, "Invalid Date.");
    }
    $td = $sndate;
    foreach ($ids as $key => $id) {
        $v->isOk($id, "num", 1, 20, "Invalid Item number.");
        $v->isOk($qtys[$key], "num", 1, 20, "Invalid Item quantity.");
        //$v->isOk ($amts[$key], "float", 1, 20, "Invalid Item amount.");
    }
    //$v->isOk ($subtot, "float", 1, 20, "Invalid sub-total amount.");
    //$v->isOk ($vat, "float", 1, 20, "Invalid vat amount.");
    //$v->isOk ($total, "float", 1, 20, "Invalid total amount.");
    # display errors, if any
    if ($v->isError()) {
        $err = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $err .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $confirm .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # CHECK IF THIS DATE IS IN THE BLOCKED RANGE
    $blocked_date_from = getCSetting("BLOCKED_FROM");
    $blocked_date_to = getCSetting("BLOCKED_TO");
    if (strtotime($sndate) >= strtotime($blocked_date_from) and strtotime($sndate) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
        return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
    }
    $cvacc = gethook("accnum", "pchsacc", "name", "Cost Variance");
    db_conn($prd);
    # Get invoice info
    $sql = "SELECT * FROM nons_purchases WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'";
    $invRslt = db_exec($sql) or errDie("Unable to get invoice information");
    if (pg_numrows($invRslt) < 1) {
        return "<i class='err'>Not Found{$sql}</i>";
    }
    $inv = pg_fetch_array($invRslt);
    db_conn("cubit");
    $sql = "SELECT * FROM nons_purchasesn";
    $purRslt = db_exec($sql) or errDie("Unable to get Non-Stock Order information");
    if (pg_numrows($purRslt) < 1) {
        $noteid = 2;
    } else {
        $noteid = pglib_lastid("nons_purchasesn", "id");
        $noteid++;
    }
    $refnum = getrefnum();
    db_conn("cubit");
    if ($inv['spurnum'] > 0) {
        if ($inv['ctyp'] == "sup") {
            $inv['ctyp'] = 's';
            $inv['supid'] = $inv['typeid'];
        } elseif ($inv['ctyp'] == "led") {
            $inv['ctyp'] = 'c';
            $inv['deptid'] = $inv['typeid'];
        } else {
            $inv['ctyp'] = 'p';
        }
    }
    # Begin updates
    pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
    if ($inv['ctyp'] == 's') {
        $sql = "SELECT * FROM suppliers WHERE supid = '{$inv['supid']}' AND div = '" . USER_DIV . "'";
        $custRslt = db_exec($sql) or errDie("Unable to view customer");
        $cus = pg_fetch_array($custRslt);
        # Get department
        db_conn("exten");
        $sql = "SELECT * FROM departments WHERE deptid = '{$cus['deptid']}' AND div = '" . USER_DIV . "'";
        $deptRslt = db_exec($sql) or errDie("Unable to get details.");
        if (pg_numrows($deptRslt) < 1) {
            $dept['deptname'] = "<li class=err>Department not Found.";
        } else {
            $dept = pg_fetch_array($deptRslt);
        }
    } elseif ($inv['ctyp'] == 'c') {
        # Get department
        db_conn("exten");
        $sql = "SELECT * FROM departments WHERE deptid = '{$inv['deptid']}' AND div = '" . USER_DIV . "'";
        $deptRslt = db_exec($sql) or errDie("Unable to get details.");
        if (pg_numrows($deptRslt) < 1) {
            $dept['deptname'] = "<li class=err>Department not Found.";
        } else {
            $dept = pg_fetch_array($deptRslt);
        }
        $dept['credacc'] = $dept['pca'];
    } elseif ($inv['ctyp'] == 'cb') {
        $bankid = $inv['supid'];
        $bankid += 0;
        db_conn("cubit");
        $sql = "SELECT * FROM bankacct WHERE bankid = '{$bankid}'";
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:nons-purch-return.php

示例11: input_check

function input_check()
{
    $numargs = func_num_args();
    $arg_list = func_get_args();
    if (!validate_request_checksum()) {
        perihelion_die("Refresh Error", "You can only submit this form once.");
    }
    if (!isset($_REQUEST['cmd'])) {
        perihelion_die("", "No command requested.");
        return "";
    }
    // Command is needed. If not present... whooops.
    $cmd = decrypt_get_vars($_REQUEST['cmd']);
    // Browse through all numargs, check the command, if it is ours, decrypt all vars EXCEPT
    // the ne_* vars
    $i = 0;
    for (;;) {
        $tmp_cmd = $arg_list[$i];
        $i++;
        if ($tmp_cmd != $cmd) {
            while ($arg_list[$i] != "0") {
                $i++;
            }
        } else {
            while ($arg_list[$i] != "0") {
                $tmp_var = $arg_list[$i];
                $GLOBALS[$tmp_var] = "";
                // Error if we can't find a mandatory var
                if (substr($tmp_var, 0, 1) == "!") {
                    $tmp_var = substr($tmp_var, 1, 255);
                    if (!isset($_REQUEST[$tmp_var])) {
                        perihelion_die("Internal Error", "Mandatory var not found: " . $tmp_var);
                    }
                }
                if (isset($_REQUEST[$tmp_var])) {
                    // Check if we need decrypting or not
                    if (substr($tmp_var, 0, 3) == "ne_") {
                        $GLOBALS[$tmp_var] = $_REQUEST[$tmp_var];
                    } else {
                        $GLOBALS[$tmp_var] = decrypt_get_vars($_REQUEST[$tmp_var]);
                    }
                }
                $i++;
            }
            return $tmp_cmd;
        }
        $i++;
        if ($i >= $numargs) {
            break;
        }
    }
    // No command found :(
    if (user_is_admin(user_ourself())) {
        $str = "Illegal or no command requested.<br>Command issued: '{$cmd}'";
    } else {
        $str = "Illegal or no command requested.";
    }
    perihelion_die("Internal Error", $str);
}
开发者ID:jaytaph,项目名称:perihelion-oldcode,代码行数:59,代码来源:general_encrypt.inc.php

示例12: confirm

function confirm($_POST)
{
    # Get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($cashacc, "num", 1, 30, "Invalid Petty Cash Account.");
    $v->isOk($date_day, "num", 1, 2, "Invalid Date day.");
    $v->isOk($date_month, "num", 1, 2, "Invalid Date month.");
    $v->isOk($date_year, "num", 1, 4, "Invalid Date Year.");
    if (strlen($date_year) != 4) {
        $v->isOk($bankname, "num", 1, 1, "Invalid Date year.");
    }
    if ($amount > $max) {
        $v->isOk("##", "num", 1, 1, "ERROR : amount is more than available petty cash funds.");
    }
    $v->isOk($descript, "string", 0, 255, "Invalid Description.");
    $v->isOk($amount, "float", 1, 10, "Invalid amount.");
    $v->isOk($supid, "num", 1, 20, "Invalid Supplier account.");
    $date = $date_day . "-" . $date_month . "-" . $date_year;
    if (!checkdate($date_month, $date_day, $date_year)) {
        $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;
    }
    # 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 "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
    }
    # Get account name
    $supRslt = get("cubit", "*", "suppliers", "supid", $supid);
    $sup = pg_fetch_array($supRslt);
    # Get account name for thy lame User's Sake
    $accRslt = get("core", "*", "accounts", "accid", $cashacc);
    if (pg_numrows($accRslt) < 1) {
        return "<li class='err'> Petty Cash Account not found.</li>";
    }
    $acc = pg_fetch_array($accRslt);
    # Check available funds
    core_connect();
    $sql = "SELECT (debit - credit) as bal FROM trial_bal WHERE month='" . PRD_DB . "' AND accid = '{$cashacc}' AND div = '" . USER_DIV . "'";
    $accbRslt = db_exec($sql);
    if (pg_numrows($accbRslt) < 1) {
        return "<li class='err'> Petty Cash Account not found.</li>";
    }
    $accb = pg_fetch_array($accbRslt);
    $accb['bal'] = sprint($accb['bal']);
    $confirm = "\n\t\t<center>\n\t\t<h3>New Petty Cash Payment</h3>\n\t\t<h4>Confirm entry (Please check the details)</h4>\n\t\t<table " . TMPL_tblDflts . " width=60%>\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='cashacc' value='{$cashacc}'>\n\t\t\t<input type='hidden' name='date' value='{$date}'>\n\t\t\t<input type='hidden' name='descript' value='{$descript}'>\n\t\t\t<input type='hidden' name='amount' value='{$amount}'>\n\t\t\t<input type='hidden' name='supid' value='{$supid}'>\n\t\t\t<tr>\n\t\t\t\t<th>Field</th>\n\t\t\t\t<th>Value</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Petty Cash Account</td>\n\t\t\t\t<td>{$acc['topacc']}/{$acc['accnum']} {$acc['accname']}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Available Funds</td>\n\t\t\t\t<td>" . CUR . " {$accb['bal']}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Date</td>\n\t\t\t\t<td valign='center'>{$date}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Paid from</td>\n\t\t\t\t<td valign='center'>{$sup['supno']} - {$sup['supname']}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>Description</td>\n\t\t\t\t<td valign='center'>{$descript}</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 valign='center'>" . CUR . " {$amount}</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 &raquo'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>\n\t\t<p>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Quick Links</th>\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,代码行数:61,代码来源:petty-pay-supp.php

示例13: confirm

function confirm($_POST)
{
    # Get vars
    extract($_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.");
    }
    $v->isOk($account, "num", 1, 50, "Invalid Account to be used as contra.[{$key}]");
    $v->isOk($refnum, "num", 1, 10, "Invalid Reference number.");
    # 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 "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
    }
    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()) {
        $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
    $accRs = get("core", "*", "accounts", "accid", $account);
    if (pg_numrows($accRs) < 1) {
        return "<li> Accounts to be debited does not exist.</li>";
    }
    $account_info = pg_fetch_array($accRs);
    # accnums
    foreach ($accid as $key => $value) {
        if ($dtamount[$key] > 0 || $ctamount[$key] > 0) {
            # get account to be debited
            $accRss = get("core", "*", "accounts", "accid", $accid[$key]);
            if (pg_numrows($accRs) < 1) {
                return "<li> Accounts to be debited does not exist.</li>";
            }
            $accs[$key] = pg_fetch_array($accRss);
        }
    }
    $confirm = "\n\t\t<center>\n\t\t<h3>Add Multiple Journal transactions to batch</h3>\n\t\t<h4>Confirm entry</h4>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='date_year' value='{$date_year}'>\n\t\t\t<input type='hidden' name='date_month' value='{$date_month}'>\n\t\t\t<input type='hidden' name='date_day' value='{$date_day}'>\n\t\t\t<input type='hidden' name='refnum' value='{$refnum}'>\n\t\t\t<input type='hidden' name='account' value='{$account}'>\n\t\t\t<input type='hidden' name='total' value='{$total}'>\n\t\t\t<input type='hidden' name='key' value='write'>\n\t\t<table " . TMPL_tblDflts . " width='590'>\n\t\t\t<tr>\n\t\t\t\t<th>Transaction Date</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$date_year}-{$date_month}-{$date_day}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Select Contra Account</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$account_info['accname']}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Reference Number</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$refnum}</td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t</table>\n\t\t<table " . TMPL_tblDflts . " width='590'>\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>";
    $trans = "";
    foreach ($accid as $key => $value) {
        if ($dtamount[$key] > 0 || $ctamount[$key] > 0) {
            $accRss = get("core", "*", "accounts", "accid", $accid[$key]);
            if (pg_numrows($accRs) < 1) {
                return "<li> Accounts to be debited does not exist.</li>";
            }
            $acc_each[$key] = pg_fetch_array($accRss);
            $trans .= "\n\t\t\t\t<input type='hidden' name='accid[]' value='{$accid[$key]}'>\n\t\t\t\t<input type='hidden' name='descript[]' value ='{$descript[$key]}'>\n\t\t\t\t<input type='hidden' name='dtamount[]' value='{$dtamount[$key]}'>\n\t\t\t\t<input type='hidden' name='ctamount[]' value='{$ctamount[$key]}'>\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>";
        }
    }
    if (strlen($trans) < 5) {
        return slctacc($_POST, "<li class='err'>Please enter full transaction details</li><br>");
    }
    $confirm .= "\n\t\t\t{$trans}\n\t\t\t<tr><td><br></td></tr>\n\t\t\t<tr>\n\t\t\t\t<td align='right'><input type='submit' name='back' value='&laquo; Correction'></td>\n\t\t\t\t<td align='right' colspan='3'><input type='submit' value='Write &raquo'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>\n\t\t<table border='0' cellpadding='2' cellspacing='1' width=15%>\n\t\t\t<tr><td><br></td></tr>\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='batch-view.php'>View batch file</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<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $confirm;
}
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:74,代码来源:multi-account-trans.php

示例14: write

function write($_POST)
{
    extract($_POST);
    if (isset($back)) {
        unset($_POST["back"]);
        return alloc($_POST);
    }
    # CHECK IF THIS DATE IS IN THE BLOCKED RANGE
    $blocked_date_from = getCSetting("BLOCKED_FROM");
    $blocked_date_to = getCSetting("BLOCKED_TO");
    require_lib("validate");
    $v = new validate();
    $v->isOk($all, "num", 1, 1, "Invalid allocation.");
    $v->isOk($rec_amount, "num", 1, 5, "Invalid amount of entries.");
    for ($t = 0; $t < $rec_amount; $t++) {
        if (!isset($descript[$t]) or !isset($reference[$t]) or !isset($setamt[$t]) or empty($descript[$t]) or empty($reference[$t]) or empty($setamt[$t])) {
            continue;
        }
        $v->isOk($bankid[$t], "num", 1, 30, "Invalid Bank Account.");
        $v->isOk($date[$t], "date", 1, 14, "Invalid Date.");
        $v->isOk($out[$t], "float", 1, 40, "Invalid out amount.");
        $v->isOk($descript[$t], "string", 0, 255, "Invalid Description.");
        $v->isOk($reference[$t], "string", 0, 50, "Invalid Reference Name/Number.");
        $v->isOk($cheqnum[$t], "num", 0, 30, "Invalid Cheque number.");
        $v->isOk($amt[$t], "float", 1, 40, "Invalid amount.");
        $v->isOk($setamt[$t], "float", 1, 40, "Invalid Settlement amount.");
        $v->isOk($setvat[$t], "string", 1, 10, "Invalid Settlement VAT Option.");
        $v->isOk($setvatcode[$t], "string", 1, 40, "Invalid Settlement VAT code");
        $v->isOk($cusid[$t], "num", 1, 40, "Invalid customer number.");
        $v->isOk($out1[$t], "float", 0, 40, "Invalid paid amount(currant).");
        $v->isOk($out2[$t], "float", 0, 40, "Invalid paid amount(30).");
        $v->isOk($out3[$t], "float", 0, 40, "Invalid paid amount(60).");
        $v->isOk($out4[$t], "float", 0, 40, "Invalid paid amount(90).");
        $v->isOk($out5[$t], "float", 0, 40, "Invalid paid amount(120).");
        if (isset($invids[$t])) {
            foreach ($invids[$t] as $key => $value) {
                $v->isOk($invids[$t][$key], "num", 1, 50, "Invalid Invoice No.");
                $v->isOk($paidamt[$t][$key], "float", 1, 40, "Invalid amount to be paid.");
            }
        }
        if (strtotime($date[$t]) >= strtotime($blocked_date_from) and strtotime($date[$t]) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
            return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
        }
    }
    if ($v->isError()) {
        $confirm = $v->genErrors();
        return $confirm . confirm($_POST);
    }
    for ($t = 0; $t < $rec_amount; $t++) {
        if (!isset($descript[$t]) or !isset($reference[$t]) or !isset($setamt[$t]) or empty($descript[$t]) or empty($reference[$t]) or empty($setamt[$t])) {
            continue;
        }
        /* get bank account id */
        if (($bank_acc[$t] = getbankaccid($bankid[$t])) === false) {
            $sql = "SELECT accid FROM core.accounts WHERE accname='Cash on Hand'";
            $rslt = db_exec($sql);
            if (pg_num_rows($rslt) < 1) {
                if ($bankid[$t] == 0) {
                    return "There is no 'Cash on Hand' account, there was one, but\n\t\t\t\t\t\tits not there now, you mudst have deleted it, if you want\n\t\t\t\t\t\tto use cash functionality please create a 'Cash on Hand' account.";
                } else {
                    return "Invalid bank acc.";
                }
            }
            $bank_acc[$t] = pg_fetch_result($rslt, 0);
        }
        $cus = qryCustomer($cusid[$t], "cusnum, deptid, cusname, surname");
        $dept = qryDepartment($cus["deptid"], "debtacc");
        $refnum = getrefnum();
        pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
        # date format
        $sdate[$t] = explode("-", $date[$t]);
        $sdate[$t] = $sdate[$t][2] . "-" . $sdate[$t][1] . "-" . $sdate[$t][0];
        $cheqnum[$t] = 0 + $cheqnum[$t];
        $pay = "";
        $accdate[$t] = $sdate[$t];
        /* Paid invoices */
        $invidsers = "";
        $rinvids = "";
        $amounts = "";
        $invprds = "";
        $rages = "";
        /* OPTION 1 : AUTO ALLOCATE (write) */
        if ($all == 0) {
            # update the customer (make balance less)
            $sql = "UPDATE cubit.customers SET balance = (balance - '{$amt[$t]}'::numeric(13,2))\n\t\t\t\t\tWHERE cusnum = '{$cus['cusnum']}' AND div = '" . USER_DIV . "'";
            $rslt = db_exec($sql) or errDie("Unable to update invoice in Cubit.", SELF);
            if (isset($invids[$t])) {
                foreach ($invids[$t] as $key => $value) {
                    $ii = $invids[$t][$key];
                    $pp = $paidamt[$t][$key];
                    /* OPTION 1: STOCK INVOICES */
                    if (!isset($itype[$t][$ii]) && !isset($ptype[$t][$ii])) {
                        $sql = "SELECT prd,invnum,odate FROM cubit.invoices\n\t\t\t\t\t\t\t\tWHERE invid ='{$ii}' AND div = '" . USER_DIV . "'";
                        $invRslt = db_exec($sql) or errDie("Unable to retrieve invoice details from database.");
                        if (pg_numrows($invRslt) < 1) {
                            return "<li class='err'>Invalid Invoice Number.</li>";
                        }
                        $inv = pg_fetch_array($invRslt);
                        $inv['invnum'] += 0;
                        // reduce invoice balance
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:multi-bank-recpt-inv.php

示例15: confirm

function confirm($_POST)
{
    extract($_POST);
    if (isset($back)) {
        return method($cusid);
    }
    //	$date = "$date_day-$date_month-$date_year";
    $amt = sprint(array_sum($paidamt));
    $setamt = sprint(array_sum($stock_setamt));
    if (!isset($print_recpt)) {
        $print_recpt = "";
    }
    if (!isset($descript) or strlen($descript) < 1) {
        $descript = $reference;
    }
    if (!isset($out1)) {
        $out1 = '';
    }
    if (!isset($out2)) {
        $out2 = '';
    }
    if (!isset($out3)) {
        $out3 = '';
    }
    if (!isset($out4)) {
        $out4 = '';
    }
    if (!isset($out5)) {
        $out5 = '';
    }
    $date = "{$date_year}-{$date_month}-{$date_day}";
    require_lib("validate");
    $v = new validate();
    $v->isOk($all, "num", 1, 1, "Invalid allocation.");
    $v->isOk($bankid, "num", 1, 30, "Invalid Bank Account.");
    $v->isOk($date, "date", 1, 14, "Invalid Date.");
    $v->isOk($descript, "string", 1, 255, "Invalid Description.");
    $v->isOk($reference, "string", 1, 50, "Invalid Reference Name/Number.");
    $v->isOk($cheqnum, "num", 0, 30, "Invalid Cheque number.");
    $v->isOk($amt, "float", 1, 40, "Invalid amount.");
    $v->isOk($setamt, "float", 1, 40, "Invalid Settlement Amount.");
    $v->isOk($setvat, "string", 1, 10, "Invalid Settlement VAT Option.");
    $v->isOk($setvatcode, "string", 1, 40, "Invalid Settlement VAT code");
    //	$v->isOk($out, "float", 1, 40, "Invalid out amount.");
    $v->isOk($out1, "float", 0, 40, "Invalid paid amount(currant).");
    $v->isOk($out2, "float", 0, 40, "Invalid paid amount(30).");
    $v->isOk($out3, "float", 0, 40, "Invalid paid amount(60).");
    $v->isOk($out4, "float", 0, 40, "Invalid paid amount(90).");
    $v->isOk($out5, "float", 0, 40, "Invalid paid amount(120).");
    $v->isOk($cusid, "num", 1, 10, "Invalid customer number.");
    $v->isOk($overpay, "float", 1, 40, "Invalid Unallocated Amount.");
    $v->isOk($print_recpt, "string", 0, 10, "Invalid Print Receipt Setting.");
    if ($amt + $overpay <= 0) {
        $v->addError(0, "Invalid Amount Allocated To Receipt.");
    }
    if (isset($invids)) {
        foreach ($invids as $key => $value) {
            if ($paidamt[$key] < 0.01) {
                continue;
            }
            if (!isset($stock_setamt[$key]) or strlen($stock_setamt[$key]) < 1) {
                $stock_setamt[$key] = 0;
            }
            $v->isOk($invids[$key], "num", 1, 50, "Invalid Invoice No. [{$key}]");
            $v->isOk($paidamt[$key], "float", 1, 40, "Invalid amount to be paid. [{$key}]");
            $v->isOk($stock_setamt[$key], "float", 1, 40, "Invalid Settlement Discount Amount");
        }
    }
    if ($v->isError()) {
        $confirm = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $confirm .= "<li class='err'>" . $e["msg"] . "</li>";
        }
        $_POST['OUT1'] = $out1 + 0;
        $_POST['OUT2'] = $out2 + 0;
        $_POST['OUT3'] = $out3 + 0;
        $_POST['OUT4'] = $out4 + 0;
        $_POST['OUT5'] = $out5 + 0;
        return $confirm . alloc($_POST);
    }
    $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 "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
    }
    $out += 0;
    $OUT1 = $out1 + 0;
    $OUT2 = $out2 + 0;
    $OUT3 = $out3 + 0;
    $OUT4 = $out4 + 0;
    $OUT5 = $out5 + 0;
    $tot = 0;
    if (isset($invids)) {
        foreach ($invids as $key => $value) {
            if ($paidamt[$key] < 0.01) {
                continue;
            }
            $tot += $paidamt[$key];
        }
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:bank-recpt-inv.php


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