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


PHP lastinvid函数代码示例

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


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

示例1: create_dummy

function create_dummy($deptid)
{
    db_connect();
    # Insert purchase to DB
    $sql = "INSERT INTO nons_invoices(cusname, cusaddr, cusvatno, chrgvat, sdate, subtot, balance, vat,\n\t\t\ttotal, done, username, prd, invnum, div)";
    $sql .= " VALUES('', '', '', 'yes', CURRENT_DATE, 0, 0, 0, 0, 'n', '" . USER_NAME . "', '" . PRD_DB . "',\n\t\t\t0,'" . USER_DIV . "')";
    $rslt = db_exec($sql) or errDie("Unable to create template Non-Stock Invoice.", SELF);
    # Get next ordnum
    $invid = lastinvid();
    return $purid;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:11,代码来源:nons-invoice-new.php

示例2: invoice

function invoice()
{
    extract($_REQUEST);
    pglib_transaction("BEGIN");
    $invnum = divlastid("inv");
    $sql = "INSERT INTO cubit.invoices(deptid, chrgvat, odate, printed, done, \n\t\t\t\tusername, prd, invnum, div, systime, pslip_sordid, cusnum, ordno)\n\t\t\tVALUES ('" . USER_DIV . "', 'inc', current_date, 'n', 'n',\n\t\t\t\t'" . USER_NAME . "', '" . PRD_DB . "', '{$invnum}', '" . USER_DIV . "',\n\t\t\t\tcurrent_date, '{$sordid}', '{$cusnum}', '{$sordid}')";
    $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoice.");
    $invid = lastinvid();
    $sql = "SELECT stock.stkid, stock.whid, qty, sorders_items.vatcode, amt, unitcost\n\t\t\tFROM cubit.sorders_items\n\t\t\t\tLEFT JOIN cubit.stock ON sorders_items.stkid=stock.stkid\n\t\t\tWHERE sordid='{$sordid}'";
    $stock_rslt = db_exec($sql) or errDie("Unable to retrieve stock.");
    while (list($stkid, $whid, $qty, $vatcode, $amt, $unitcost) = pg_fetch_array($stock_rslt)) {
        $sql = "INSERT INTO cubit.inv_items (invid, whid, stkid, qty, div,\n\t\t\t\t\tvatcode, amt, unitcost)\n\t\t\t\tVALUES ('{$invid}', '{$whid}', '{$stkid}', '{$qty}', '" . USER_DIV . "',\n\t\t\t\t\t'{$vatcode}', '{$amt}', '{$unitcost}')";
        db_exec($sql) or errDie("Unable to add inventory items.");
    }
    $OUTPUT = "\n\t<script>\n\t\tmove(\"../cust-credit-stockinv-no-neg.php?invid={$invid}&cont=true\");\n\t</script>";
    pglib_transaction("COMMIT");
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:18,代码来源:picking_slip_invoice.php

示例3: create_dummy

function create_dummy($deptid)
{
    $trans_date_setting = getCSetting("USE_TRANSACTION_DATE");
    if (isset($trans_date_setting) and $trans_date_setting == "yes") {
        $trans_date_value = getCSetting("TRANSACTION_DATE");
        $date_arr = explode("-", $trans_date_value);
        $date_year = $date_arr[0];
        $date_month = $date_arr[1];
        $date_day = $date_arr[2];
    } else {
        $date_year = date("Y");
        $date_month = date("m");
        $date_day = date("d");
    }
    $odate = "{$date_year}-{$date_month}-{$date_day}";
    db_connect();
    # Insert purchase to DB
    $sql = "\n\t\tINSERT INTO nons_invoices (\n\t\t\tcusname, cusaddr, cusvatno, chrgvat, sdate, odate, subtot, balance, vat, total, done, username, prd, invnum, \n\t\t\ttyp, div, multiline \n\t\t) VALUES (\n\t\t\t'', '', '', 'yes', CURRENT_DATE, '{$odate}', 0, 0, 0, 0, 'n', '" . USER_NAME . "', '" . PRD_DB . "', 0, \n\t\t\t'quo', '" . USER_DIV . "', 'yes'\n\t\t)";
    $rslt = db_exec($sql) or errDie("Unable to create template Non-Stock Quote.", SELF);
    return lastinvid();
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:21,代码来源:nons-multiline-quote-new.php

示例4: create_dummy

function create_dummy($deptid)
{
    db_connect();
    # Dummy Vars
    $cusnum = 0;
    $salespn = "";
    $comm = "";
    $salespn = "";
    $chrgvat = getSetting("SELAMT_VAT");
    //	$odate = date("Y-m-d");
    $ordno = "";
    $delchrg = "0.00";
    $cordno = "";
    $terms = 0;
    $traddisc = 0;
    $SUBTOT = 0;
    $vat = 0;
    $total = 0;
    $vatnum = "";
    $cusacc = "";
    $telno = "";
    $trans_date_setting = getCSetting("USE_TRANSACTION_DATE");
    if (isset($trans_date_setting) and $trans_date_setting == "yes") {
        $trans_date_value = getCSetting("TRANSACTION_DATE");
        $date_arr = explode("-", $trans_date_value);
        $date_year = $date_arr[0];
        $date_month = $date_arr[1];
        $date_day = $date_arr[2];
    } else {
        $date_year = date("Y");
        $date_month = date("m");
        $date_day = date("d");
    }
    $odate = "{$date_year}-{$date_month}-{$date_day}";
    // $invid = divlastid('pinv', USER_DIV);
    # insert invoice to DB
    $sql = "\n\t\tINSERT INTO cubit.pinvoices (\n\t\t\tdeptid, cusnum, cordno, ordno, chrgvat, terms, traddisc, salespn, odate, \n\t\t\tdelchrg, subtot, vat, total, balance, comm, username, printed, done, prd, \n\t\t\tvatnum, cusacc, telno, div\n\t\t) VALUES (\n\t\t\t'{$deptid}', '{$cusnum}',  '{$cordno}', '{$ordno}', '{$chrgvat}', '{$terms}', '{$traddisc}', '{$salespn}', '{$odate}', \n\t\t\t'{$delchrg}', '{$SUBTOT}', '{$vat}' , '{$total}', '{$total}', '{$comm}', '" . USER_NAME . "', 'n', 'n', '" . PRD_DB . "', \n\t\t\t'{$vatnum}', '{$cusacc}', '{$telno}', '" . USER_DIV . "'\n\t\t)";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice to Cubit.", SELF);
    # get next ordnum
    $invid = lastinvid();
    return $invid;
}
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:42,代码来源:pos-invoice-new.php

示例5: fintInvoice

/**
 * @ignore
 */
function fintInvoice($cusnum, $total, $rate)
{
    $ftotal = sprint($total * $rate);
    db_connect();
    $sql = "SELECT * FROM customers WHERE cusnum = '{$cusnum}' AND div = '" . USER_DIV . "'";
    $custRslt = db_exec($sql) or errDie("Unable to view customer");
    $cus = pg_fetch_array($custRslt);
    $curr = getSymbol($cus['fcid']);
    $xrate = getRate($cus['fcid']);
    # Default data
    $sdate = date("Y-m-d");
    $invnum = divlastid('inv', USER_DIV);
    db_connect();
    # Insert purchase to DB
    $sql = "\n\t\tINSERT INTO nons_invoices (\n\t\t\tcusid, cusname, cusaddr, cusvatno, chrgvat, \n\t\t\tfcid, currency, xrate, sdate, subtot, \n\t\t\tbalance, fbalance, vat, total, done, \n\t\t\tusername, prd, invnum, typ, ctyp, \n\t\t\ttval, location, descrip, div, odate\n\t\t) VALUES (\n\t\t\t'{$cus['cusnum']}', '{$cus['cusname']} {$cus['surname']}', '{$cus['addr1']}', '{$cus['vatnum']}', 'none', \n\t\t\t'{$cus['fcid']}', '{$curr['symbol']}', '{$xrate}', '{$sdate}', '{$total}', \n\t\t\t'{$ftotal}', '{$total}', 0, '{$total}', 'y', \n\t\t\t'" . USER_NAME . "', '" . PRD_DB . "', '{$invnum}', 'inv', 's', \n\t\t\t'{$cusnum}', 'int', 'Interest Charged', '" . USER_DIV . "', '{$sdate}'\n\t\t)";
    $rslt = db_exec($sql) or errDie("Unable to create Interest Invoice.", SELF);
    # Get next ordnum
    $invid = lastinvid();
    # Insert purchase items
    $sql = "\n\t\tINSERT INTO nons_inv_items (\n\t\t\tinvid, qty, amt, cunitcost, unitcost, \n\t\t\tdescription, div\n\t\t) VALUES (\n\t\t\t'{$invid}', '1', '{$total}', '{$ftotal}', '{$total}', \n\t\t\t'Interest on Outstanding Invoices.', '" . USER_DIV . "'\n\t\t)";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.", SELF);
    return $invnum;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:26,代码来源:core-settings.php

示例6: accept

function accept($_POST)
{
    extract($_POST);
    # Validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($invid, "num", 1, 20, "Invalid Sales Order number.");
    # display errors, if any
    if ($v->isError()) {
        $err = "";
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $err .= "<li class=err>" . $e["msg"];
        }
        $confirm .= "<p><input type=button onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $confirm;
    }
    # Get Sales Order info
    db_connect();
    $sql = "SELECT * FROM nons_invoices WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
    $invRslt = db_exec($sql) or errDie("Unable to get -sorder- information");
    if (pg_numrows($invRslt) < 1) {
        return "<i class=err>Not Found</i>";
    }
    $inv = pg_fetch_array($invRslt);
    db_connect();
    /* - Start Copying - */
    pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
    $sql = "INSERT INTO nons_invoices(cusname,cusaddr,cusvatno,chrgvat,sdate,odate,done,username,\n\t\t\t\tprd,invnum,div,remarks,cusid,age,typ,subtot,balance,vat,total,descrip,ctyp,\n\t\t\t\taccid,tval,docref,jobid,jobnum,labid,location,fcid,currency,xrate,fbalance,\n\t\t\t\tfsubtot)\n\tVALUES('{$inv['cusname']}','{$inv['cusaddr']}','{$inv['cusvatno']}','{$inv['chrgvat']}','{$inv['sdate']}',\n\t\t\t'{$inv['odate']}', '{$inv['done']}','{$inv['username']}','{$inv['prd']}','{$inv['invnum']}','{$inv['div']}',\n\t\t\t'{$inv['remarks']}','{$inv['cusid']}','{$inv['age']}','inv','{$inv['subtot']}','{$inv['balance']}',\n\t\t\t'{$inv['vat']}','{$inv['total']}','{$inv['descrip']}', '{$inv['ctyp']}','{$inv['accid']}','{$inv['tval']}',\n\t\t\t'{$inv['docref']}','{$inv['jobid']}','{$inv['jobnum']}','{$inv['labid']}','{$inv['location']}',\n\t\t\t'{$inv['fcid']}','{$inv['currency']}','{$inv['xrate']}','{$inv['fbalance']}', '{$inv['fsubtot']}')";
    $upRslt = db_exec($sql) or errDie("Unable to update -sorder- information");
    # get next ordnum
    $ninvid = lastinvid();
    # Get selected stock in this Sales Order
    db_connect();
    $sql = "SELECT * FROM nons_inv_items  WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
    $stkdRslt = db_exec($sql);
    while ($stkd = pg_fetch_array($stkdRslt)) {
        $stkd['cunitcost'] += 0;
        $sql = "INSERT INTO nons_inv_items(invid, qty, description, div, amt, unitcost, accid, rqty, vatex, cunitcost)\n\t\tVALUES('{$ninvid}', '{$stkd['qty']}', '{$stkd['description']}', '{$stkd['div']}', '{$stkd['amt']}', '{$stkd['unitcost']}', '{$stkd['accid']}', '{$stkd['rqty']}', '{$stkd['vatex']}', '{$stkd['cunitcost']}')";
        $upRslt = db_exec($sql) or errDie("Unable to update -sorder- information");
    }
    # Set to not serialised
    $sql = "UPDATE nons_invoices SET done = 'y' WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
    $rslt = db_exec($sql) or errDie("Unable to update -sorder-s in Cubit.", SELF);
    /* - End Copying - */
    pglib_transaction("COMMIT") or errDie("Unable to commit a database transaction.", SELF);
    header("Location: nons-invoice-new.php?invid={$ninvid}&cont=1");
    exit;
    # Final Laytout
    $write = "\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr><th>Non-Stock Sales Orders accepted</th></tr>\n\t\t<tr class='bg-even'><td>Non-Stock Sales Orders for Customer <b>{$inv['cusname']}</b> has been accepted.</td></tr>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr><th>Quick Links</th></tr>\n\t\t<tr class='bg-odd'><td><a href='nons-sorder-view.php'>View Non-Stock Sales Orders</a></td></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $write;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:52,代码来源:nons-sorder-acc.php

示例7: write

function write($_POST)
{
    # Get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($quoid, "num", 1, 20, "Invalid Quote number.");
    $v->isOk($cusnum, "num", 1, 20, "Invalid Customer number.");
    $v->isOk($cordno, "string", 0, 20, "Invalid Customer order number.");
    # display errors, if any
    $err = "";
    if ($v->isError()) {
        $errors = $v->getErrors();
        foreach ($errors as $e) {
            $err .= "<li class=err>" . $e["msg"];
        }
        return $err;
    }
    # Get quote info
    db_connect();
    $sql = "SELECT * FROM pos_quotes WHERE quoid = '{$quoid}' 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 Customer info
    db_connect();
    $sql = "SELECT * FROM customers WHERE cusnum = '{$cusnum}' AND div = '" . USER_DIV . "'";
    $cusRslt = db_exec($sql) or errDie("Unable to get customer information");
    if (pg_numrows($cusRslt) < 1) {
        return "<i class=err>Customer Not Found</i>";
    }
    $cus = pg_fetch_array($cusRslt);
    /* - Start Copying - */
    pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
    db_connect();
    # Insert invoice to DB
    $sql = "INSERT INTO pinvoices(deptid, cusnum, deptname, cusacc, cusname, surname, cusaddr, cusvatno, cordno, ordno, chrgvat, terms, traddisc, salespn, odate, delchrg, subtot, vat, total, balance, comm, printed, done, prd, div)";
    $sql .= " VALUES('{$quo['deptid']}', '{$cus['cusnum']}', '{$quo['deptname']}', '{$cus['accno']}', '{$cus['cusname']}', '{$cus['surname']}', '{$cus['addr1']}', '{$cus['vatnum']}', '{$cordno}', '{$quo['ordno']}', '{$quo['chrgvat']}', '{$quo['terms']}', '{$quo['traddisc']}', '{$quo['salespn']}', '{$quo['odate']}', '{$quo['delchrg']}', '{$quo['subtot']}', '{$quo['vat']}' , '{$quo['total']}', '{$quo['total']}', '{$quo['comm']}', 'n', 'y', '" . PRD_DB . "', '" . USER_DIV . "')";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice to Cubit.", SELF);
    # get next ordnum
    $invid = lastinvid();
    # get selected stock in this quote
    db_connect();
    $sql = "SELECT * FROM pos_quote_items  WHERE quoid = '{$quoid}' AND div = '" . USER_DIV . "'";
    $stkdRslt = db_exec($sql);
    /*
    		while($stkd = pg_fetch_array($stkdRslt)){
    			# Insert one by one per quantity
    			if(ext_isSerial("stock", "stkid", $stkd['stkid'])){
    				$stkd['amt'] = sprint($stkd['amt']/$stkd['qty']);
    
    				for($i = 0; $i < $stkd['qty']; $i++){
    					# insert invoice items
    					$sql = "INSERT INTO inv_items(invid, whid, stkid, qty, unitcost, amt, disc, discp, div) VALUES('$invid', '$stkd[whid]', '$stkd[stkid]', '1', '$stkd[unitcost]', '$stkd[amt]', '$stkd[disc]', '$stkd[discp]', '".USER_DIV."')";
    					$rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.",SELF);
    				}
    			}else{
    				# insert invoice items
    				$sql = "INSERT INTO inv_items(invid, whid, stkid, qty, unitcost, amt, disc, discp, div) VALUES('$invid', '$stkd[whid]', '$stkd[stkid]', '$stkd[qty]', '$stkd[unitcost]', '$stkd[amt]', '$stkd[disc]', '$stkd[discp]', '".USER_DIV."')";
    				$rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.",SELF);
    			}
    
    			# update stock(alloc + qty)
    			$sql = "UPDATE stock SET alloc = (alloc + '$stkd[qty]') WHERE stkid = '$stkd[stkid]' AND div = '".USER_DIV."'";
    			$rslt = db_exec($sql) or errDie("Unable to update stock to Cubit.",SELF);
    		}
    
    
    		# Get selected stock in this quote
    		db_connect();
    
    		# Remove access data
    		$sql = "DELETE FROM pos_quotes WHERE quoid = '$quoid' AND div = '".USER_DIV."'";
    		$rslt = db_exec($sql) or errDie("Unable to update quotes in Cubit.",SELF);
    
    		$sql = "DELETE FROM pos_quote_items WHERE quoid = '$quoid' AND div = '".USER_DIV."'";
    		$rslt = db_exec($sql) or errDie("Unable to update quotes in Cubit.",SELF);
    
    /* - End Copying - */
    pglib_transaction("COMMIT") or errDie("Unable to commit a database transaction.", SELF);
    // Final Laytout
    $write = "\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr><th>Quote accepted</th></tr>\n\t\t<tr class='bg-even'><td>Quote for customer <b>{$cus['cusname']} {$cus['surname']}</b> has been accepted</td></tr>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr><th>Quick Links</th></tr>\n\t\t<tr class='bg-odd'><td><a href='pos-quote-view.php'>View Pos Quotes</a></td></tr>\n\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t</table>";
    return $write;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:89,代码来源:pos-qaccept.php

示例8: write

function write($_POST)
{
    # Set mas execution time to 12 hours
    ini_set("max_execution_time", 43200);
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    foreach ($invids as $key => $invid) {
        $v->isOk($invid, "num", 1, 20, "Invalid recuring invoice number.");
        $odate[$key] = mkdate($o_year[$key], $o_month[$key], $o_day[$key]);
        $v->isOk($odate[$key], "date", 1, 1, "Invalid Invoice Date for invoice: {$invid}.");
    }
    # display errors, if any
    $err = "";
    if ($v->isError()) {
        $err = $v->genErrors();
        return $err;
    }
    pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
    $i = 0;
    $recinv = new dbSelect("rnons_invoices", "cubit");
    $recinv_i = new dbSelect("rnons_inv_items", "cubit");
    $newinv = new dbUpdate("nons_invoices", "cubit");
    $newinv_i = new dbUpdate("nons_inv_items", "cubit");
    foreach ($invids as $key => $invid) {
        /* fetch recurring invoice info */
        $recinv->setOpt(grp(m("where", "invid='{$invid}' AND div='" . USER_DIV . "'")));
        $recinv->run();
        if ($recinv->num_rows() <= 0) {
            continue;
        }
        $inv = $recinv->fetch_array();
        /* create new invoice from recurring invoice */
        $cols = grp(m("accepted", " "), m("sdate", raw("CURRENT_DATE")), m("typ", "inv"), m("cusid", $inv["cusid"]), m("cusname", $inv["cusname"]), m("cusaddr", $inv["cusaddr"]), m("cusvatno", $inv["cusvatno"]), m("cordno", $inv["cordno"]), m("chrgvat", $inv["chrgvat"]), m("terms", $inv["terms"]), m("odate", $odate[$key]), m("subtot", $inv["subtot"]), m("vat", $inv["vat"]), m("total", $inv["total"]), m("balance", $inv["total"]), m("done", "n"), m("prd", PRD_DB), m("div", USER_DIV), m("ctyp", $inv["ctyp"]), m("tval", $inv["tval"]), m("jobid", $invid), m("remarks", $inv["remarks"]));
        $newinv->setOpt($cols);
        $newinv->run(DB_INSERT);
        /* fetch last invoice id */
        $invid = lastinvid();
        /* fetch recurring invoice items */
        $recinv_i->setOpt(grp(m("where", "invid='{$inv['invid']}' AND div='" . USER_DIV . "'")));
        $recinv_i->run();
        /* add items to new non stock invoice */
        while ($stkd = $recinv_i->fetch_array()) {
            $cols = grp(m("invid", $invid), m("qty", $stkd["qty"]), m("unitcost", $stkd["unitcost"]), m("amt", $stkd["amt"]), m("accid", $stkd["account"]), m("description", $stkd["description"]), m("vatex", $stkd["vatex"]), m("div", USER_DIV));
            $newinv_i->setOpt($cols);
            $newinv_i->run(DB_INSERT);
        }
    }
    pglib_transaction("COMMIT") or errDie("Unable to commit a database transaction.", SELF);
    $OUT = "\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Recurring Non-stock Invoices Processed</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>New non-stock Invoices have been created from Recurring Invoices</td>\n\t\t\t</tr>\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<tr class='" . bg_class() . "'>\n\t\t\t\t<td><a href='rec-invoice-view.php'>View Recurring Invoices</a></td>\n\t\t\t</tr>\n\t\t\t<script>document.write(getQuicklinkSpecial());</script>\n\t\t</table>";
    return $OUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:53,代码来源:nons-rec-invoice-proc.php

示例9: create_dummy

function create_dummy($deptid)
{
    db_connect();
    # Dummy Vars
    $cusnum = 0;
    $salespn = "";
    $comm = "";
    $salespn = "";
    $chrgvat = getSetting("SELAMT_VAT");
    $odate = date("Y-m-d");
    $ordno = "";
    $delchrg = "0.00";
    $cordno = "";
    $terms = 0;
    $traddisc = 0;
    $SUBTOT = 0;
    $vat = 0;
    $total = 0;
    $branch = 0;
    $del_addr = "";
    $bankid = cust_bank_id($cusnum);
    //lock(1);
    $fcid = getDef_fcid();
    # Insert invoice to DB
    $sql = "\n\t\tINSERT INTO invoices (\n\t\t\tdeptid, cusnum, cordno, ordno, chrgvat, terms, \n\t\t\ttraddisc, salespn, odate, delchrg, subtot, vat, \n\t\t\ttotal, balance, comm, username, printed, done, \n\t\t\tprd, branch, fcid, del_addr, bankid, div\n\t\t) VALUES (\n\t\t\t'{$deptid}', '{$cusnum}',  '{$cordno}', '{$ordno}', '{$chrgvat}', '{$terms}', \n\t\t\t'{$traddisc}', '{$salespn}', '{$odate}', '{$delchrg}', '{$SUBTOT}', '{$vat}', \n\t\t\t'{$total}', '{$total}', '{$comm}', '" . USER_NAME . "', 'n', 'n', \n\t\t\t'" . PRD_DB . "','{$branch}', '{$fcid}', '{$del_addr}', '{$bankid}', '" . USER_DIV . "'\n\t\t)";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice to Cubit.", SELF);
    return lastinvid();
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:28,代码来源:cust-credit-stockinv-easy.php

示例10: invoice

function invoice()
{
    if (isset($_REQUEST["btn_back"])) {
        return enter();
    }
    extract($_REQUEST);
    // Retrieve asset
    $sql = "SELECT * FROM cubit.assets WHERE id='{$asset_id}'";
    $asset_rslt = db_exec($sql) or errDie("Unable to retrieve asset.");
    $asset_data = pg_fetch_array($asset_rslt);
    // Retrieve asset group
    $sql = "SELECT * FROM cubit.assetgrp WHERE grpid='{$asset_data['grpid']}'";
    $grp_rslt = db_exec($sql) or errDie("Unable to retrieve asset group.");
    $grp_data = pg_fetch_array($grp_rslt);
    // Retrieve customer
    $sql = "SELECT * FROM cubit.customers WHERE cusnum='{$cust_id}'";
    $cust_rslt = db_exec($sql) or errDie("Unable to retrieve customer.");
    $cust_data = pg_fetch_array($cust_rslt);
    if ($cust_id > 0) {
        $ctyp = "s";
        $tval = $cust_id;
    } else {
        if ($cust_id == "-1") {
            $ctyp = "c";
            $tval = "2";
            $cust_data["surname"] = "Cash Sale";
        } else {
            if ($cust_id == "-2") {
                $ctyp = "ac";
                $tval = "";
                $cust_data["surname"] = "Cash Sale";
            } else {
                return enter("<li class='err'>Invalid sale option selected.</li>");
            }
        }
    }
    $acc = "0";
    $vatchrg = $vatinc == "exc" ? "no" : "yes";
    $vcd = qryVatcode($vatcode);
    $va = vatcalca($price * $qty, $vatchrg, "no", 0, $vcd["vat_amount"]);
    pglib_transaction("BEGIN");
    if ($cust_data["surname"] == "Cash Sale") {
        $cust_data["paddr1"] = "";
        $cust_data["vatnum"] = "";
    }
    $sql = "INSERT INTO cubit.nons_invoices(cusname, cusaddr, cusvatno, chrgvat,\r\n\t\t\t\tsdate, odate, subtot, balance, vat, total, done, username, prd,\r\n\t\t\t\tinvnum, typ, ctyp, tval, div, accid, salespn)\r\n\t\t\tVALUES ('{$cust_data['surname']}', '{$cust_data['paddr1']}',\r\n\t\t\t\t'{$cust_data['vatnum']}', '{$vatchrg}', CURRENT_DATE, '{$date}', '{$va['subtotal']}', 0,\r\n\t\t\t\t'{$va['vat']}', '{$va['total']}', 'n', '" . USER_NAME . "', '" . extractMonth($date) . "', 0, \r\n\t\t\t\t'inv', '{$ctyp}', '{$tval}', '" . USER_DIV . "', '{$acc}', 'General')";
    db_exec($sql) or errDie("Unable to create invoice");
    $ni_id = lastinvid();
    $asset_saleacc = gethook("accnum", "salesacc", "name", "saleofassets");
    $price_all = $price * $qty;
    $sql = "INSERT INTO cubit.nons_inv_items (invid, qty, description, div,\r\n\t\t\t\tamt, unitcost, accid, rqty, vatex, cunitcost, asset_id)\r\n\t\t\tVALUES ('{$ni_id}', '{$qty}', '{$asset_data['des']}', '" . USER_DIV . "',\r\n\t\t\t\t'{$price_all}', '{$price}', '{$asset_saleacc}', '0', \r\n\t\t\t\t'{$vatcode}', '0', '{$asset_id}')";
    db_exec($sql) or errDie("Unable to create invoice.");
    pglib_transaction("COMMIT");
    header("Location: asset-invoice-print.php?invid={$ni_id}&printpage=t");
    exit;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:56,代码来源:asset-sale.php

示例11: create_dummy

function create_dummy($deptid, $cusnum)
{
    # Get selected customer info
    db_connect();
    $sql = "SELECT * FROM customers WHERE cusnum = '{$cusnum}' AND div = '" . USER_DIV . "'";
    $custRslt = db_exec($sql) or errDie("Unable to get customer information");
    $cust = pg_fetch_array($custRslt);
    $curr = getSymbol($cust['fcid']);
    $xrate = getRate($cust['fcid']);
    $trans_date_setting = getCSetting("USE_TRANSACTION_DATE");
    if (isset($trans_date_setting) and $trans_date_setting == "yes") {
        $trans_date_value = getCSetting("TRANSACTION_DATE");
        $date_arr = explode("-", $trans_date_value);
        $date_year = $date_arr[0];
        $date_month = $date_arr[1];
        $date_day = $date_arr[2];
    } else {
        $date_year = date("Y");
        $date_month = date("m");
        $date_day = date("d");
    }
    $odate = "{$date_year}-{$date_month}-{$date_day}";
    db_connect();
    # Insert purchase to DB
    $sql = "\n\t\tINSERT INTO nons_invoices (\n\t\t\tcusname, cusaddr, cusvatno, chrgvat, fcid, currency, \n\t\t\txrate, odate, sdate, subtot, balance, vat, total, done, username, prd, invnum, typ, ctyp, \n\t\t\ttval, location, div\n\t\t) VALUES (\n\t\t\t'{$cust['cusname']} {$cust['surname']}', '{$cust['addr1']}', '{$cust['vatnum']}', 'yes', '{$cust['fcid']}', '{$curr['symbol']}', \n\t\t\t'{$xrate}', '{$odate}', CURRENT_DATE, 0, 0, 0, 0, 'n', '" . USER_NAME . "', '" . PRD_DB . "', 0, 'inv', 's', \n\t\t\t'{$cusnum}', 'int', '" . USER_DIV . "'\n\t\t)";
    $rslt = db_exec($sql) or errDie("Unable to create template Non-Stock Invoice.", SELF);
    # Get next ordnum
    $invid = lastinvid();
    return $invid;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:30,代码来源:nons-intinvoice-new.php

示例12: run

function run()
{
    extract($_REQUEST);
    pglib_transaction("BEGIN");
    // Retrieve outstanding rentals
    $sql = "\n\tSELECT id, user_id, username, order_num, subtotal, vat, total, discount,\n\t\tdelivery, customers.cusnum, surname, addr1, addr2, addr3, accno,\n\t\tvatnum, tel, discount_perc, timestamp, deposit\n\tFROM cubit.hire_trans\n\t\tLEFT JOIN cubit.customers ON hire_trans.cusnum=customers.cusnum\n\t\tLEFT JOIN cubit.users ON hire_trans.user_id=users.userid\n\tWHERE user_id='{$user_id}' AND done='y'";
    $rental_rslt = db_exec($sql) or errDie("Unable to retrieve rentals.");
    $hire_nums = array();
    while ($rental_data = pg_fetch_array($rental_rslt)) {
        $deptid = 2;
        $time = strtotime($rental_data["timestamp"]);
        $sql = "SELECT deptname FROM exten.departments WHERE deptid='{$deptid}'";
        $deptname_rslt = db_exec($sql) or errDie("Unable to retrieve department.");
        $deptname = pg_fetch_result($deptname_rslt, 0);
        // Create hire note
        $sql = "\n\t\tINSERT INTO hire.hire_invoices (deptid, cusnum, cordno, ordno,\n\t\t\tchrgvat, terms, salespn, odate, printed, comm, done, username,\n\t\t\tdeptname, cusacc, cusname, surname, cusaddr, cusordno, cusvatno,\n\t\t\tprd, invnum, div, prints, disc, discp, delchrg, subtot, traddisc,\n\t\t\tbalance, vat, total, discount, delivery, nbal, rdelchrg, serd,\n\t\t\tpcash, pcheque, pcc, rounding, pchange, delvat, pcredit, vatnum,\n\t\t\ttelno, systime, deposit_type, deposit_amt, custom_txt, collection,\n\t\t\tbranch_addr, timestamp, hire_invid, revision)\n\t\tVALUES ('{$deptid}', '{$rental_data['cusnum']}', '', '', 'inc', '0', '2',\n\t\t\t'" . date("Y-m-d", $time) . "', 'y', '', 'y', '{$rental_data['username']}',\n\t\t\t'{$deptname}', '{$rental_data['accno']}', '', '{$rental_data['surname']}',\n\t\t\t'{$rental_data['addr1']}', '{$rental_data['order_num']}',\n\t\t\t'{$rental_data['vatnum']}', '" . PRD_DB . "', '{$rental_data['id']}',\n\t\t\t'" . USER_DIV . "', '0', '{$rental_data['discount']}',\n\t\t\t'{$rental_data['discount_perc']}', '{$rental_data['delivery']}',\n\t\t\t'{$rental_data['subtotal']}', '{$rental_data['discount']}', '0.00',\n\t\t\t'{$rental_data['vat']}', '{$rental_data['total']}',\n\t\t\t'{$rental_data['discount']}', '{$rental_data['delivery']}', '0.00', '0.00',\n\t\t\t'', '100', '100', '100', '100', '100', '0', '0.00',\n\t\t\t'{$rental_data['vatnum']}', '{$rental_data['tel']}',\n\t\t\t'{$rental_data['timestamp']}', 'CSH', '{$rental_data['deposit']}', '',\n\t\t\t'Client Collect', '0', current_timestamp, '0', '0')";
        db_exec($sql) or errDie("Unable to create hire note.");
        $invid = pglib_lastid("hire.hire_invoices", "invid");
        $hire_nums[$rental_data["id"]] = $invid;
        // Do deposit transaction if required
        if ($rental_data["deposit"] > 0) {
            $cash_on_hand = qryAccountsNum("7200", "000");
            $cash_on_hand = $cash_on_hand["accid"];
            $cust_control = qryAccountsNum("6400", "000");
            $cust_control = $cust_control["accid"];
            $refnum = getRefnum();
            writetrans($cash_on_hand, $cust_control, date("Y-m-d", $time), $refnum, $rental_data["deposit"], "Cash Receipt for " . CUR . "{$rental_data['deposit']} from " . "{$rental_data['surname']} for Deposit on Hire Note {$rental_data['id']}");
            $sql = "\n\t\t\tINSERT INTO hire.cash (invid, cash)\n\t\t\tVALUES ('{$invid}', '{$rental_data['deposit']}')";
            db_exec($sql) or errDie("Unable to add cash to hire.");
            // Make ledger record
            custledger($rental_data["cusnum"], $cust_control, date("Y-m-d", $time), $invid, "Cash Receipt for " . CUR . "{$rental_data['deposit']} from " . "{$rental_data['surname']} for Deposit on Hire Note {$rental_data['id']}", $rental_data["deposit"], "c");
            custCT($rental_data["deposit"], $rental_data["cusnum"], date("Y-m-d", $time));
            // Turn the amount around to a negative
            $stmnt_amt = $rental_data["deposit"] - $rental_data["deposit"] * 2;
            // Record the payment on the statement
            $sql = "\n\t\t\tINSERT INTO cubit.stmnt(cusnum, invid, docref, amount, date, type,\n\t\t\t\tdiv)\n\t\t\tVALUES('{$rental_data['cusnum']}', '{$invid}', '{$rental_data['id']}',\n\t\t\t\t'{$stmnt_amt}', '" . date("Y-m-d", $time) . "',\n\t\t\t\t'Cash Receipt for " . CUR . "{$rental_data['deposit']} from " . "{$rental_data['surname']} for Deposit on Hire Note {$rental_data['id']}',\n\t\t\t\t'" . USER_DIV . "')";
            $stmntRslt = db_exec($sql) or errDie("Unable to add deposit to statement");
            // Update customer balance
            $sql = "\n\t\t\tUPDATE cubit.customers SET balance=balance-'{$rental_data['deposit']}'\n\t\t\tWHERE cusnum='{$rental_data['cusnum']}'";
            db_exec($sql) or errDie("Unable to update customer balance.");
            $sql = "\n\t\t\tUPDATE hire.hire_invoices SET deposit_amt='0'\n\t\t\tWHERE invid='{$invid}'";
            db_exec($sql) or errDie("Unable to retrieve hire invoices.");
        }
        // Retrieve items on this invoice
        $sql = "\n\t\tSELECT asset_id, basis, from_date, to_date, half_day, qty,\n\t\t\tweekends, total_days, total\n\t\tFROM cubit.hire_trans_items\n\t\tWHERE hire_id='{$rental_data['id']}'";
        $item_rslt = db_exec($sql) or errDie("Unable to retrieve items.");
        while ($item_data = pg_fetch_array($item_rslt)) {
            $unitcost = $item_data["total"] / $item_data["qty"];
            // Decide which basis to use
            $hours = 0;
            $weeks = 0;
            $days = 0;
            $months = 0;
            $total_days = 0;
            switch ($item_data["basis"]) {
                case "per_hour":
                    $hours = $item_data["total_days"];
                    break;
                case "per_day":
                    $days = $item_data["total_days"];
                    $total_days = $item_data["total_days"];
                    break;
                case "per_week":
                    $week = $item_data["total_days"];
                    break;
                case "per_month":
                    $months = $item_data["total_days"];
                    break;
            }
            // Convert booleans into something we can use
            $half_day = $item_data["half_day"] == "t" ? 1 : 0;
            $weekends = $item_data["weekends"] == "t" ? 1 : 0;
            $sql = "\n\t\t\tINSERT INTO hire.hire_invitems (invid, qty, amt, unitcost,\n\t\t\t\tfrom_date, to_date, asset_id, basis, hours, weeks, days,\n\t\t\t\tmonths, half_day, weekends, total_days)\n\t\t\tVALUES ('{$invid}', '{$item_data['qty']}', '{$item_data['total']}',\n\t\t\t\t'{$unitcost}', '{$item_data['from_date']}', '{$item_data['to_date']}',\n\t\t\t\t'{$item_data['asset_id']}', '{$item_data['basis']}', '{$hours}',\n\t\t\t\t'{$weeks}', '{$days}', '{$months}', '{$half_day}', '{$weekends}',\n\t\t\t\t'{$total_days}')";
            db_exec($sql) or errDie("Unable to create rental items.");
            $item_id = pglib_lastid("hire.hire_invitems", "id");
            $sql = "\n\t\t\tINSERT INTO hire.assets_hired (invid, asset_id, qty, hired_time,\n\t\t\t\tcust_id, item_id, invnum, value, basis, discount, weekends)\n\t\t\tVALUES ('{$invid}', '{$item_data['asset_id']}', '{$item_data['qty']}',\n\t\t\t\t'{$rental_data['timestamp']}', '{$rental_data['cusnum']}', '{$item_id}',\n\t\t\t\t'{$rental_data['id']}', '{$item_data['total']}', '{$item_data['basis']}',\n\t\t\t\t'0.00', '{$weekends}')";
            db_exec($sql) or errDie("Unable to add to assets hired.");
        }
    }
    // Run invoices ----------------------------------------------------------
    $sql = "\n\tSELECT id, hire_id, customers.cusnum, order_num, discount_perc, discount,\n\t\tsubtotal, total, vat, timestamp, user_id, surname, addr1, vatnum,\n\t\tusername, delivery\n\tFROM cubit.hire_invoice_trans\n\t\tLEFT JOIN cubit.customers ON hire_invoice_trans.cusnum=customers.cusnum\n\t\tLEFT JOIN cubit.users ON hire_invoice_trans.user_id=users.userid\n\tWHERE done='y' AND user_id='{$user_id}' AND hire_id > 0";
    $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoices.");
    while ($inv_data = pg_fetch_array($inv_rslt)) {
        $hire_sales = qryAccountsNum("1050", "000");
        $cust_control = qryAccountsNum("6400", "000");
        $cash_on_hand = qryAccountsNum("7200", "000");
        $hire_sales = $hire_sales["accid"];
        $cust_control = $cust_control["accid"];
        $cash_on_hand = $cash_on_hand["accid"];
        $time = strtotime($inv_data["timestamp"]);
        $sql = "\n\t\tINSERT INTO cubit.nons_invoices (cusname, cusaddr, cusvatno,\n\t\t\tchrgvat, sdate, done, username, prd, invnum, div, remarks, cusid,\n\t\t\tage, typ, subtot, balance, vat, total, descrip, ctyp, accid,\n\t\t\tfbalance, fsubtot, cordno, terms, odate, systime, bankid,\n\t\t\tcusordno, ncdate, cusnum, discount, delivery, hire_invid,\n\t\t\tcash, cheque, credit)\n\t\tVALUES ('{$inv_data['surname']}', '{$inv_data['addr1']}', '{$inv_data['vatnum']}',\n\t\t\t'yes', '" . date("Y-m-d", $time) . "', 'y', '{$inv_data['username']}',\n\t\t\t'" . PRD_DB . "', '{$inv_data['id']}', '" . USER_DIV . "', '',\n\t\t\t'{$inv_data['cusnum']}', '0', 'inv', '{$inv_data['subtotal']}',\n\t\t\t'{$inv_data['total']}', '{$inv_data['vat']}', '{$inv_data['total']}', '', 's',\n\t\t\t'{$hire_sales}', '0.00', '0.00', '{$inv_data['order_num']}', '0',\n\t\t\t'" . date("Y-m-d", $time) . "', current_timestamp,\n\t\t\t'" . cust_bank_id($inv_data["cusnum"]) . "', '{$inv_data['order_num']}',\n\t\t\t'" . date("Y-m-d", $time) . "', '{$inv_data['cusnum']}',\n\t\t\t'{$inv_data['discount']}', '{$inv_data['delivery']}',\n\t\t\t'" . $hire_nums[$inv_data["hire_id"]] . "', '{$inv_data['total']}', '0', '0')";
        db_exec($sql) or errDie("Unable to create non stock invoice.");
        $invid = lastinvid();
        $sql = "\n\t\tSELECT hire_invoice_items_trans.id, asset_id, basis, from_date,\n\t\t\tto_date, half_day, qty, weekends, total_days, total,\n\t\t\tserial, des, grpid\n\t\tFROM cubit.hire_invoice_items_trans\n\t\t\tLEFT JOIN cubit.assets\n\t\t\t\tON hire_invoice_items_trans.asset_id=assets.id\n\t\tWHERE trans_id='{$inv_data['id']}'";
        $item_rslt = db_exec($sql) or errDie("Unable to retrieve items.");
        while ($item_data = pg_fetch_array($item_rslt)) {
            $unitcost = $item_data["total"] / $item_data["qty"];
            $item_id = 0;
            $sql = "\n\t\t\tSELECT {$item_data['basis']} FROM hire.basis_prices\n\t\t\tWHERE assetid='{$item_data['asset_id']}'";
            $rate_rslt = db_exec($sql) or errDie("Unable to retrieve rate.");
//.........这里部分代码省略.........
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:101,代码来源:hirepos_run.php

示例13: create_dummy

function create_dummy($deptid, $ctyp, $tval, $acc)
{
    db_connect();
    # Insert purchase to DB
    $sql = "INSERT INTO nons_invoices(cusname, cusaddr, cusvatno, chrgvat, sdate, odate, subtot,\r\n\t\t\t\tbalance, vat, total, done, username, prd, invnum, typ, ctyp, tval, div,accid)";
    $sql .= " VALUES('', '', '', 'yes', CURRENT_DATE, CURRENT_DATE, 0, 0, 0, 0, 'n', '" . USER_NAME . "', '" . PRD_DB . "',\r\n\t\t\t0, 'inv', '{$ctyp}','{$tval}','" . USER_DIV . "','{$acc}')";
    $rslt = db_exec($sql) or errDie("Unable to create template Non-Stock Invoice.", SELF);
    return lastinvid();
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:9,代码来源:hireserv-invoice-new.php

示例14: invoice

function invoice()
{
    extract($_REQUEST);
    $invnum = divlastid("inv");
    $sql = "INSERT INTO cubit.invoices(deptid, chrgvat, odate, printed, done, \n\t\t\t\tusername, prd, invnum, div, systime, barcode, pickslip_id)\n\t\t\tVALUES ('" . USER_DIV . "', 'inc', current_date, 'n', 'n',\n\t\t\t\t'" . USER_NAME . "', '" . PRD_DB . "', '{$invnum}', '" . USER_DIV . "',\n\t\t\t\tcurrent_date, '{$barcode}', '{$slip_id}')";
    $inv_rslt = db_exec($sql) or errDie("Unable to retrieve invoice.");
    $invid = lastinvid();
    $sql = "SELECT stkid, whid, qty, vatcode FROM cubit.pickslip_stk\n\t\t\t\tLEFT JOIN cubit.stock ON pickslip_stk.stock_id=stock.stkid\n\t\t\t\tLEFT JOIN cubit.vatcodes WHERE stock.vatcode=vatcodes.code\n\t\t\tWHERE pickslip_id='{$slip_id}'";
    $stock_rslt = db_exec($sql) or errDie("Unable to retrieve stock.");
    while (list($stkid, $whid, $qty, $vatcode) = pg_fetch_array($stock_rslt)) {
        $sql = "INSERT INTO cubit.inv_items (invid, whid, stkid, qty, div,\n\t\t\t\t\tvatcode)\n\t\t\t\tVALUES ('{$invid}', '{$whid}', '{$stkid}', '{$qty}', '" . USER_DIV . "',\n\t\t\t\t\t'{$vatcode}')";
        db_exec($sql) or errDie("Unable to add inventory items.");
    }
    $OUTPUT = "\n\t<script>\n\t\tpopupOpen(\"cust-credit-stockinv.php?invid={$invid}&cont=true\");\n\t\tmove(\"" . SELF . "\");\n\t</script>";
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:16,代码来源:picking_slip.php

示例15: write

function write($_POST)
{
    #get vars
    foreach ($_POST as $key => $value) {
        ${$key} = $value;
    }
    # 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"];
        }
        return $err;
    }
    # Get quote info
    db_connect();
    $sql = "SELECT * FROM quotes WHERE quoid = '{$quoid}'";
    $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);
    db_connect();
    /* - Start Copying - */
    pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
    # insert invoice to DB
    $sql = "INSERT INTO invoices(deptid, cusnum, cordno, ordno, chrgvat, terms, traddisc, salespn, odate, delchrg, subtot, vat, total, balance, comm, printed)";
    $sql .= " VALUES('{$quo['deptid']}', '{$quo['cusnum']}',  '{$quo['cordno']}', '{$quo['ordno']}', '{$quo['chrgvat']}', '{$quo['terms']}', '{$quo['traddisc']}', '{$quo['salespn']}', '{$quo['odate']}', '{$quo['delchrg']}', '{$quo['subtot']}', '{$quo['vat']}' , '{$quo['total']}', '{$quo['total']}', '{$quo['comm']}', 'n')";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice to Cubit.", SELF);
    # get next ordnum
    $invid = lastinvid();
    # get selected stock in this quote
    db_connect();
    $sql = "SELECT * FROM quote_items  WHERE quoid = '{$quoid}'";
    $stkdRslt = db_exec($sql);
    while ($stkd = pg_fetch_array($stkdRslt)) {
        # insert invoice items
        $sql = "INSERT INTO inv_items(invid, whid, stkid, qty, unitcost, amt, disc, discp) VALUES('{$invid}', '{$stkd['whid']}', '{$stkd['stkid']}', '{$stkd['qty']}', '{$stkd['unitcost']}', '{$stkd['amt']}', '{$stkd['disc']}', '{$stkd['discp']}')";
        $rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.", SELF);
        # update stock(alloc + qty)
        # $sql = "UPDATE stock SET alloc = (alloc + '$stkd[qty]') WHERE stkid = '$stkd[stkid]'";
        # $rslt = db_exec($sql) or errDie("Unable to update stock to Cubit.",SELF);
    }
    # get selected stock in this quote
    db_connect();
    $sql = "SELECT * FROM quote_data  WHERE quoid = '{$quoid}'";
    $dataRslt = db_exec($sql);
    $data = pg_fetch_array($dataRslt);
    $sql = "INSERT INTO inv_data(invid, dept, customer, addr1, addr2, addr3) VALUES('{$invid}', '{$data['dept']}', '{$data['customer']}', '{$data['addr1']}', '{$data['addr2']}', '{$data['addr3']}')";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice data to Cubit.", SELF);
    $sql = "UPDATE quotes SET accepted = 'y' WHERE quoid = '{$quoid}'";
    $rslt = db_exec($sql) or errDie("Unable to update quotes in Cubit.", SELF);
    pglib_transaction("COMMIT") or errDie("Unable to commit a database transaction.", SELF);
    /* - End Copying - */
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:60,代码来源:invoice-unf-cencel.php


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