當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sprint3函數代碼示例

本文整理匯總了PHP中sprint3函數的典型用法代碼示例。如果您正苦於以下問題:PHP sprint3函數的具體用法?PHP sprint3怎麽用?PHP sprint3使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了sprint3函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: display

function display()
{
    $sql = "SELECT * FROM cubit.stock ORDER BY stkcod ASC";
    $stock_rslt = db_exec($sql) or errDie("Unable to retrieve stock.");
    $stock_out = "";
    while ($stock_data = pg_fetch_array($stock_rslt)) {
        // Retrieve units on order
        $sql = "SELECT sum(qty) FROM cubit.sorders_items WHERE stkid='{$stock_data['stkid']}'";
        $order_rslt = db_exec($sql) or errDie("Unable to retrieve orders.");
        $order_qty = pg_fetch_result($order_rslt, 0);
        if (empty($stock_data["minlvl"])) {
            continue;
        }
        if (empty($order_qty)) {
            $order_qty = 0;
        }
        $units = $stock_data["units"] - $order_qty;
        $required = abs($units - $stock_data["minlvl"]);
        // We're not required to purchase this item
        if ($units > $stock_data["minlvl"]) {
            continue;
        }
        $stock_out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$stock_data['stkcod']}</td>\n\t\t\t\t<td>{$stock_data['stkdes']}</td>\n\t\t\t\t<td align='center'>" . sprint3($stock_data['units']) . "</td>\n\t\t\t\t<td align='center'>" . sprint3($order_qty) . "</td>\n\t\t\t\t<td align='center'>" . sprint3($stock_data['minlvl']) . "</td>\n\t\t\t\t<td align='center'><b>" . sprint3($required) . "</b></td>\n\t\t\t\t<td><a href='purchase-new.php'>Purchase</a></td>\n\t\t\t</tr>";
    }
    if (empty($stock_out)) {
        $stock_out = "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='7'>No items required for purchase.</td>\n\t\t\t</tr>";
    }
    $OUTPUT = "\n\t\t<center>\n\t\t<h3>Required Purchases</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Stock Code</th>\n\t\t\t\t<th>Stock Description</th>\n\t\t\t\t<th>Current Units</th>\n\t\t\t\t<th>Units on Order</th>\n\t\t\t\t<th>Minimum Level</th>\n\t\t\t\t<th>Minimum Required</th>\n\t\t\t\t<th>Options</th>\n\t\t\t</tr>\n\t\t\t{$stock_out}\n\t\t</table>\n\t\t</center>";
    return $OUTPUT;
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:30,代碼來源:required_purchases.php

示例2: adjust_display

function adjust_display()
{
    extract($_REQUEST);
    $fields = array();
    $fields["page"] = 1;
    extract($fields, EXTR_SKIP);
    $sql = "SELECT stock.stkid, bar, stkcod, stkdes, catname, csprice,\n\t\t\t\t(qty-units) AS adjust_qty\n\t\t\tFROM cubit.stock_take\n\t\t\t\tLEFT JOIN cubit.stock ON stock.stkid=stock_take.stkid\n\t\t\tWHERE adjusted='0' AND page='{$page}'\n\t\t\tORDER BY stkcod ASC";
    $adjust_rslt = db_exec($sql) or errDie("Unable to retrieve adjustments.");
    $adjust_out = "";
    while ($adjust_data = pg_fetch_array($adjust_rslt)) {
        if ($adjust_data["adjust_qty"] == 0) {
            continue;
        }
        $value = $adjust_data["csprice"] * $adjust_data["adjust_qty"];
        $adjust_out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$adjust_data['bar']}</td>\n\t\t\t<td>{$adjust_data['catname']}</td>\n\t\t\t<td>{$adjust_data['stkcod']}</td>\n\t\t\t<td>{$adjust_data['stkdes']}</td>\n\t\t\t<td align='center'>" . sprint3($adjust_data['adjust_qty']) . "</td>\n\t\t\t<td align='right'>" . sprint($value) . "</th>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='adjust_qty[{$adjust_data['stkid']}]'\n\t\t\t\tvalue='{$adjust_data['adjust_qty']}' />\n\t\t\t\t<input type='submit' name='update[{$adjust_data['stkid']}]'\n\t\t\t\tvalue='Adjust' />\n\t\t\t</td>\n\t\t</tr>";
    }
    if (empty($adjust_out)) {
        $adjust_out = "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='7'>\n\t\t\t\t<li>No results found for this page.</li>\n\t\t\t</td>\n\t\t</tr>";
    }
    $sql = "SELECT max(page) FROM cubit.stock_take";
    $mp_rslt = db_exec($sql) or errDie("Unable to retrieve total pages.");
    $max_page = pg_fetch_result($mp_rslt, 0);
    if ($page < $max_page) {
        $adjust_btn = "\n\t\t\t<a href='" . SELF . "?key=adjust_display&page=" . ($page + 1) . "'>\n\t\t\t\tNext &raquo\n\t\t\t</a>";
    } else {
        $adjust_btn = "";
    }
    $OUTPUT = "\n\t<center>\n\t<h3>Stock Take - Adjustments</h3>\n\t<form method='post' action='" . SELF . "'>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th colspan='2'>Page</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>\n\t\t\t\t<input type='text' name='page' value='{$page}' size='3'\n\t\t\t\tstyle='font-weight: bold; text-align: center' />\n\t\t\t</td>\n\t\t\t<td><input type='submit' value='OK' /></td>\n\t\t</tr>\n\t</table>\n\t</form>\n\t<form method='post' action='" . SELF . "'>\n\t<input type='hidden' name='key' value='adjust_update' />\n\t<input type='hidden' name='page' value='{$page}' />\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Barcode</th>\n\t\t\t<th>Category</th>\n\t\t\t<th>Stock Code</th>\n\t\t\t<th>Stock Description</th>\n\t\t\t<th>Adjustment</th>\n\t\t\t<th>Value</th>\n\t\t\t<th>&nbsp;</th>\n\t\t</tr>\n\t\t{$adjust_out}\n\t</table>\n\t<input type='submit' name='button[page_complete]' value='Adjust Page' />\n\t<br />\n\t{$adjust_btn}\n\t</center>";
    return $OUTPUT;
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:30,代碼來源:stock_take_adjust.php

示例3: manuOut

function manuOut()
{
    extract($_REQUEST);
    $fields = array();
    $fields["qty"] = 1;
    $fields["tdate_year"] = date("Y");
    $fields["tdate_month"] = date("m");
    $fields["tdate_day"] = date("d");
    extract($fields, EXTR_SKIP);
    $requirements_met = true;
    // Retrieve main stock item
    $sql = "SELECT * FROM cubit.stock WHERE stkid='{$m_stock_id}'";
    $m_stock_rslt = db_exec($sql) or errDie("Unable to retrieve main stock item.");
    $m_stock_data = pg_fetch_array($m_stock_rslt);
    // Retrieve recipe
    $sql = "SELECT * FROM cubit.recipies WHERE m_stock_id='{$m_stock_id}' ORDER BY id DESC";
    $recipe_rslt = db_exec($sql) or errDie("Unable to retrieve recipe.");
    $s_stock_out = "";
    while ($recipe_data = pg_fetch_array($recipe_rslt)) {
        // Retrieve stock item
        $sql = "SELECT * FROM cubit.stock WHERE stkid='{$recipe_data['s_stock_id']}'";
        $s_stock_rslt = db_exec($sql) or errDie("Unable to retrieve recipe.");
        $s_stock_data = pg_fetch_array($s_stock_rslt);
        $qty_item = $recipe_data["qty"] * $qty;
        // Do we have enough stock items
        if ($qty_item > $s_stock_data["units"]) {
            $qty_required = "<span class='required'>" . ($qty_item - $s_stock_data["units"]) . "</span>";
            $options = "\n\t\t\t\t<table cellpadding='1' cellspacing='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Edit Recipe</td>\n\t\t\t\t\t\t<td>Purchase</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>";
            $requirements_met = false;
        } else {
            $qty_required = 0;
            $options = "";
        }
        $s_stock_out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$s_stock_data['stkcod']}</td>\n\t\t\t\t<td align='center'>" . sprint3($qty_item) . "</td>\n\t\t\t\t<td align='center'>{$qty_required}</td>\n\t\t\t</tr>";
    }
    if ($qty) {
        if ($requirements_met) {
            $datefield = "\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='4'>Transaction Date</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td colspan='4' align='center'>" . mkDateSelect("tdate", $tdate_year, $tdate_month, $tdate_day) . "</td>\n\t\t\t\t</tr>";
            $manubtn = "<input type='submit' value='Manufacture &raquo' style='font-size: 14pt; font-weight: bold; width: 100%' />";
        } else {
            $datefield = "\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='4'>Transaction Date</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td colspan='4' align='center'>\n\t\t\t\t\t\t" . mkDateSelect("tdate", $tdate_year, $tdate_month, $tdate_day) . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>";
            $manubtn = "\n\t\t\t\t<li class='err'>\n\t\t\t\t\tUnable to manufacture not<br />\n\t\t\t\t\tenough stock available.<br />\n\t\t\t\t\t<a href='purchase-new.php'>New Purchase</a><br />\n\t\t\t\t\t<a href='manu_recipe.php?m_stock_id={$m_stock_id}'>Edit Recipe</a>\n\t\t\t\t</li>";
        }
    } else {
        $datefield = "";
        $manubtn = "";
    }
    $OUTPUT = "\n\t\t<center>\n\t\t<h3>Manufacture</h3>\n\t\t<form method='post' action='" . SELF . "'>\n\t\t\t<input type='hidden' name='m_stock_id' value='{$m_stock_id}' />\n\t\t\t<input type='hidden' name='key' value='{$key}' />\n\t\t\t<input type='hidden' name='tdate_year' value='{$tdate_year}' />\n\t\t\t<input type='hidden' name='tdate_month' value='{$tdate_month}' />\n\t\t\t<input type='hidden' name='tdate_day' value='{$tdate_day}' />\n\t\t\t<li class='err' style='width: 50%'>\n\t\t\t\tPlease remember to click update after selecting the quantity to be\n\t\t\t\tmanufactured!\n\t\t\t</li>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>New Stock Item</th>\n\t\t\t\t<th>Qty</th>\n\t\t\t\t<th colspan='2'>&nbsp;</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td><b>{$m_stock_data['stkcod']}</b></td>\n\t\t\t\t<td><input type='text' name='qty' value='{$qty}' size='3' style='text-align: center; width: 100%;' /></td>\n\t\t\t\t<td colspan='2'><input type='submit' value='Update &raquo' style='width: 100%;' /></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Stock Item</th>\n\t\t\t\t<th>Qty</th>\n\t\t\t\t<th>Required</th>\n\t\t\t</tr>\n\t\t\t{$s_stock_out}\n\t\t</form>\n\t\t<form method='post' action='" . SELF . "'>\n\t\t\t<input type='hidden' name='m_stock_id' value='{$m_stock_id}' />\n\t\t\t<input type='hidden' name='opt' value='manufacture' />\n\t\t\t<input type='hidden' name='qty' value='{$qty}' />\n\t\t\t{$datefield}\n\t\t\t<tr>\n\t\t\t\t<th colspan='4' align='center'>{$manubtn}</th>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>\n\t\t</form>\n\t\t</center>";
    return $OUTPUT;
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:50,代碼來源:manu_stock.php

示例4: display

function display()
{
    extract($_REQUEST);
    $fields = array();
    $fields["from_year"] = date("Y");
    $fields["from_month"] = date("m");
    $fields["from_day"] = "01";
    $fields["to_year"] = date("Y");
    $fields["to_month"] = date("m");
    $fields["to_day"] = date("d");
    $fields["prd"] = "daily";
    $fields["increase"] = 0;
    $fields["decrease"] = 0;
    extract($fields, EXTR_SKIP);
    $from_date = "{$from_year}-{$from_month}-{$from_day}";
    $to_date = "{$to_year}-{$to_month}-{$to_day}";
    $sql = "SELECT stkid, stkcod, stkdes, minlvl, maxlvl, units FROM cubit.stock";
    $stock_rslt = db_exec($sql) or errDie("Unable to retrieve stock.");
    $stock_out = "";
    $tot_avail = 0;
    while ($stock_data = pg_fetch_array($stock_rslt)) {
        $tmp_min = $suggested_min = averageSalesQty($stock_data["stkid"], $from_date, $to_date, $prd);
        $tmp_max = $suggested_max = maxSalesQty($stock_data["stkid"], $prd);
        $suggested_min += $tmp_min / 100 * $increase;
        $suggested_min -= $tmp_min / 100 * $decrease;
        $suggested_max += $tmp_max / 100 * $increase;
        $suggested_max -= $tmp_max / 100 * $decrease;
        $stock_out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$stock_data['stkcod']}</td>\n\t\t\t\t<td>{$stock_data['stkdes']}</td>\n\t\t\t\t<td align='center'><b>{$stock_data['minlvl']}</b></td>\n\t\t\t\t<td align='center'><b>{$stock_data['maxlvl']}</b></td>\n\t\t\t\t<td align='center'>\n\t\t\t\t\t<b>{$suggested_min}</b>\n\t\t\t\t</td>\n\t\t\t\t<td align='center'>\n\t\t\t\t\t<b>" . sprint3($suggested_max) . "</b>\n\t\t\t\t</td>\n\t\t\t\t<td align='center'><b>" . sprint3($stock_data['units']) . "</b></td>\n\t\t\t</tr>";
        if ($stock_data['units'] > 0) {
            $tot_avail += $stock_data['units'];
        }
    }
    $stock_out .= "\n\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t<td colspan='6'><b>Total: (Positive amounts only)</b></td>\n\t\t\t\t\t\t<td align='center'><b>" . sprint3($tot_avail) . "</b></td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
    $prds = array("daily", "weekly", "monthly");
    $prd_sel = "<select name='prd'>";
    foreach ($prds as $prd_val) {
        if ($prd_val == $prd) {
            $sel = "selected='selected'";
        } else {
            $sel = "";
        }
        $prd_sel .= "<option value='{$prd_val}' {$sel}>" . ucfirst($prd_val) . "</option>";
    }
    $OUTPUT = "\n\t\t<center>\n\t\t<h3>Minimum and Maximum Stock Levels</h3>\n\t\t<form method='POST' action='" . SELF . "'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th colspan='4'>Date Range</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>" . mkDateSelect("from", $from_year, $from_month, $from_day) . "</td>\n\t\t\t\t<td>&nbsp; <b> To </b> &nbsp;</td>\n\t\t\t\t<td>" . mkDateSelect("to", $to_year, $to_month, $to_day) . "</td>\n\t\t\t\t<td rowspan='2'>\n\t\t\t\t\t<input type='submit' value='Calculate' style='height: 100%; font-weight: bold' />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='3' align='center'>{$prd_sel}</td>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td colspan='4' align='center'>\n\t\t\t\t\t<table " . TMPL_tblDflts . " width='100%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Increase</th>\n\t\t\t\t\t\t\t<th>Decrease</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td width='50%' align='center'>\n\t\t\t\t\t\t\t\t<input type='text' name='increase' value='{$increase}' size='3' />%\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td width='50%' align='center'>\n\t\t\t\t\t\t\t\t<input type='text' name='decrease' value='{$decrease}' size='3' />%\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Stock Code</th>\n\t\t\t\t<th>Stock Description</th>\n\t\t\t\t<th>Current Minimum</th>\n\t\t\t\t<th>Current Maximum</th>\n\t\t\t\t<th>Suggested Minimum</th>\n\t\t\t\t<th>Suggested Maximum</th>\n\t\t\t\t<th>Currently On Hand</th>\n\t\t\t</tr>\n\t\t\t{$stock_out}\n\t\t</table>\n\t\t</center>";
    return $OUTPUT;
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:46,代碼來源:stock_minmax.php

示例5: details

function details($_GET)
{
    $showvat = TRUE;
    # get vars
    extract($_GET);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($purid, "num", 1, 20, "Invalid Order number.");
    # 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;
    }
    # Get purchase info
    db_connect();
    $sql = "SELECT * FROM purchases WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'";
    $purRslt = db_exec($sql) or errDie("Unable to get Order information");
    if (pg_numrows($purRslt) < 1) {
        return "<i class='err'>Order Not Found</i>";
    }
    $pur = pg_fetch_array($purRslt);
    $get_codes = "SELECT * FROM suppstock WHERE suppid = '{$pur['supid']}' ORDER BY stkid";
    $run_codes = db_exec($get_codes) or errDie("Unable to get supplier stock code information");
    if (pg_numrows($run_codes) > 0) {
        while ($codarr = pg_fetch_array($run_codes)) {
            if (strlen($codarr['stkcod']) > 0) {
                $stockcodes[$codarr['stkid']]['stkcod'] = $codarr['stkcod'];
            }
            if (strlen($codarr['stkdes']) > 0) {
                $stockcodes[$codarr['stkid']]['stkdes'] = $codarr['stkdes'];
            }
        }
    }
    /* --- Start Products Display --- */
    # Products layout
    $products = "\r\n\t\t<table cellpadding='5' cellspacing='0' border='1' width='100%' bordercolor='#000000'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>STORE</td>\r\n\t\t\t\t<td>ITEM NUMBER</td>\r\n\t\t\t\t<td>DESCRIPTION</td>\r\n\t\t\t\t<td>QTY OUTSTANDING</td>\r\n\t\t\t\t<td>UNIT PRICE</td>\r\n\t\t\t\t<td>DISCOUNT</td>\r\n\t\t\t\t<td>DELIVERY DATE</th>\r\n\t\t\t\t<td>AMOUNT</td>\r\n\t\t\t<tr>";
    # get selected stock in this purchase
    db_connect();
    $sql = "SELECT * FROM pur_items  WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'";
    $stkdRslt = db_exec($sql);
    while ($stkd = pg_fetch_array($stkdRslt)) {
        # get warehouse name
        db_conn("exten");
        $sql = "SELECT whname FROM warehouses WHERE whid = '{$stkd['whid']}' AND div = '" . USER_DIV . "'";
        $whRslt = db_exec($sql);
        $wh = pg_fetch_array($whRslt);
        # get selected stock in this warehouse
        db_connect();
        $sql = "SELECT * FROM stock WHERE stkid = '{$stkd['stkid']}' AND div = '" . USER_DIV . "'";
        $stkRslt = db_exec($sql);
        $stk = pg_fetch_array($stkRslt);
        if (isset($stockcodes[$stk['stkid']]['stkcod'])) {
            $stk['stkcod'] = $stockcodes[$stk['stkid']]['stkcod'];
        }
        if (isset($stockcodes[$stk['stkid']]['stkdes'])) {
            $stk['stkdes'] = $stockcodes[$stk['stkid']]['stkdes'];
        }
        # format date
        list($dyear, $dmon, $dday) = explode("-", $stkd['ddate']);
        db_conn('cubit');
        $Sl = "SELECT * FROM vatcodes WHERE id='{$stkd['vatcode']}'";
        $Ri = db_exec($Sl);
        $vd = pg_fetch_array($Ri);
        if (TAX_VAT != $vd['vat_amount'] and $vd['vat_amount'] != "0.00") {
            $showvat = FALSE;
        }
        if ($stkd['whid'] == "0") {
            $desc = $stkd['description'];
        } else {
            $desc = $stk['stkdes'];
        }
        # put in product
        $products .= "\r\n\t\t\t<tr>\r\n\t\t\t\t<td>{$wh['whname']}</td>\r\n\t\t\t\t<td>{$stk['stkcod']}</td>\r\n\t\t\t\t<td>{$desc}</td>\r\n\t\t\t\t<td>" . sprint3($stkd['qty']) . "</td>\r\n\t\t\t\t<td nowrap>" . CUR . " " . sprint($stkd['unitcost']) . "</td>\r\n\t\t\t\t<td>{$stkd['udiscount']}</td>\r\n\t\t\t\t<td>{$dday}-{$dmon}-{$dyear}</td>\r\n\t\t\t\t<td nowrap>" . CUR . " {$stkd['amt']}</td>\r\n\t\t\t</tr>";
    }
    $products .= "</table>";
    /*
    # Get supplier
    db_connect();
    $sql = "SELECT supname,supno FROM suppliers WHERE supid = '$pur[supid]' AND div = '".USER_DIV."'";
    $supRslt = db_exec($sql);
    if(pg_numrows($supRslt) < 1){
    	$sup['supname'] = "<li class=err>Supplier not found";
    	$sup['supno'] = "";
    }else{
    	$sup = pg_fetch_array($supRslt);
    }
    */
    # Get department
    db_conn("exten");
    $sql = "SELECT * FROM departments WHERE deptid = '{$pur['deptid']}' AND div = '" . USER_DIV . "'";
    $deptRslt = db_exec($sql);
    if (pg_numrows($deptRslt) < 1) {
        $dept['deptname'] = "<i class='err'>Not Found</i>";
    } else {
//.........這裏部分代碼省略.........
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:101,代碼來源:purch-print.php

示例6: printStk


//.........這裏部分代碼省略.........
        $rec['qty'] += 0;
        $rec['csprice'] += 0;
        $rec['csamt'] += 0;
        $prec['csprice'] += $inc['csprice'];
        $prec['csamt'] += $inc['csamt'];
        # zeros
        $prec['qty'] += 0;
        $prec['csprice'] += 0;
        $prec['csamt'] += 0;
        # Calculate profit
        $prof = $rec['csprice'] - $rec['csamt'];
        $totprof += $prof;
        $totcsprice += $rec['csprice'];
        $totqty += $rec['qty'];
        $totpqty += $prec['qty'];
        # Limit to 30 chars
        $stk['stkdes'] = extlib_rstr($stk['stkdes'], 30);
        $item['stkcod'] = $stk['stkcod'];
        $item['stkdes'] = $stk['stkdes'];
        $item['pqty'] = $prec['qty'];
        $item['qty'] = $rec['qty'];
        $item['inc'] = $inc['qty'];
        $item['dec'] = $dec['qty'];
        $item['csprice'] = sprint($rec['csprice']);
        $item['profit'] = sprint($prof);
        $items[] = $item;
        if (isset($r_type)) {
            if ($prec['qty'] != 0) {
                #calculate the ratio
                $ratio = $rec['qty'] / $prec['qty'] * 100;
                $ratio = round($ratio, 1);
            } else {
                $ratio = "0";
            }
            #make array for movement tracking
            $move['stkdes'] = $stk['stkdes'];
            $move['pqty'] = $prec['qty'];
            $move['qty'] = $rec['qty'];
            $move['ratio'] = $ratio;
            $movement[] = $move;
        }
    }
    # bubble sorting
    $sortarr =& $items;
    // where $out = array name to sort
    for ($j = 0; $j < count($sortarr); $j++) {
        for ($i = 0; $i < count($sortarr) - 1; $i++) {
            if ($sortarr[$i]['qty'] < $sortarr[$i + 1]['qty']) {
                $buf = $sortarr[$i];
                $sortarr[$i] = $sortarr[$i + 1];
                $sortarr[$i + 1] = $buf;
            }
        }
    }
    if (isset($r_type)) {
        # bubble sorting for movement
        $sortarr2 =& $movement;
        // where $out = array name to sort
        for ($j = 0; $j < count($sortarr2); $j++) {
            for ($i = 0; $i < count($sortarr2) - 1; $i++) {
                if (isset($r_type) and $r_type == 'fast') {
                    if ($sortarr2[$i]['qty'] < $sortarr2[$i + 1]['qty']) {
                        $buf = $sortarr2[$i];
                        $sortarr2[$i] = $sortarr2[$i + 1];
                        $sortarr2[$i + 1] = $buf;
                    }
                } else {
                    if ($sortarr2[$i]['qty'] > $sortarr2[$i + 1]['qty']) {
                        $buf = $sortarr2[$i];
                        $sortarr2[$i] = $sortarr2[$i + 1];
                        $sortarr2[$i + 1] = $buf;
                    }
                }
            }
        }
        if (isset($r_type) and $r_type == 'fast') {
            $moveheader = "Fast Moving Stock";
        } else {
            $moveheader = "Slow Moving Stock";
        }
    }
    $totprof = sprint($totprof);
    $totcsprice = sprint($totcsprice);
    // Layout
    $report = "\n\t\t<h3>Stock Movement Report</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Code</th>\n\t\t\t\t<th>Description</th>\n\t\t\t\t<th>Purchased</th>\n\t\t\t\t<th>Sold</th>\n\t\t\t\t<th>Increase</th>\n\t\t\t\t<th>Decrease</th>\n\t\t\t\t<th>Total Selling Price</th>\n\t\t\t\t<th>Gross Profit</th>\n\t\t\t</tr>";
    foreach ($items as $key => $item) {
        $report .= "\n\t\t\t<tr>\n\t\t\t\t<td>{$item['stkcod']}</td>\n\t\t\t\t<td>{$item['stkdes']}</td>\n\t\t\t\t<td align='right'>" . sprint3($item['pqty']) . "</td>\n\t\t\t\t<td align='right'>" . sprint3($item['qty']) . "</td>\n\t\t\t\t<td align='right'>" . sprint3($item['inc']) . "</td>\n\t\t\t\t<td align='right'>" . sprint3($item['dec']) . "</td>\n\t\t\t\t<td align='right'>" . CUR . " {$item['csprice']}</td>\n\t\t\t\t<td align='right'>" . CUR . " {$item['profit']}</td>\n\t\t\t</tr>";
    }
    $report .= "\n\t\t<tr><td><br></td></tr>\n\t\t<tr>\n\t\t\t<td colspan='2'><b>Totals</b></td>\n\t\t\t<td align='right'>" . sprint3($totpqty) . "</td>\n\t\t\t<td align='right'>" . sprint3($totqty) . "</td>\n\t\t\t<td align='right'>" . sprint3($totinc) . "</td>\n\t\t\t<td align='right'>" . sprint3($totdec) . "</td>\n\t\t\t<td align='right'>" . CUR . " {$totcsprice}</td>\n\t\t\t<td align='right'>" . CUR . " {$totprof}</td>\n\t\t</tr>";
    if (isset($r_type)) {
        $report .= "\n\t\t<tr><td colspan='8'><br></td></tr>\n\t\t<tr><th colspan='8'>{$moveheader}</th></tr>\n\t\t<tr>\n\t\t\t<th>Stock</th>\n\t\t\t<th>Available</th>\n\t\t\t<th>Decrease</th>\n\t\t\t<th colspan='2'>Ratio</th>\n\t\t</tr>";
        foreach ($movement as $key => $move) {
            $report .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$move['stkdes']}</td>\n\t\t\t\t\t<td align='right'>" . sprint3($move['pqty']) . "</td>\n\t\t\t\t\t<td align='right'>" . sprint3($move['qty']) . "</td>\n\t\t\t\t\t<td align='right' colspan='2'>{$move['ratio']} %</td>\n\t\t\t\t</tr>";
        }
    }
    $report .= "</table>";
    include "temp.xls.php";
    Stream("Report", $report);
    return $report;
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:101,代碼來源:stock-move-report-xls.php

示例7: details


//.........這裏部分代碼省略.........
                                $Wh = "";
                                $ria = "";
                            } else {
                                $Wh = "AND (lower(stkdes) LIKE lower('%{$ria}%')) OR (lower(stkcod) LIKE lower('%{$ria}%'))";
                                $ria = "";
                            }
                        } else {
                            $Wh = "AND FALSE";
                            $ria = "";
                        }
                        $check_setting = getCSetting("OPTIONAL_STOCK_FILTERS");
                        if (isset($check_setting) and $check_setting == "yes") {
                            if (isset($filter_class) and $filter_class != "0") {
                                $Wh .= " AND prdcls = '{$filter_class}'";
                            }
                            if (isset($filter_cat) and $filter_cat != "0") {
                                $Wh .= " AND catid = '{$filter_cat}'";
                            }
                        }
                        if (isset($filter_store) and $filter_store != "0") {
                            $Wh .= " AND whid = '{$filter_store}'";
                        }
                        $sql = "SELECT * FROM stock WHERE blocked = 'n' {$search_neg_stock} AND div = '" . USER_DIV . "' {$Wh} ORDER BY stkcod ASC";
                        $stkRslt = db_exec($sql) or errDie("Unable to retrieve stocks from database.");
                        if (pg_numrows($stkRslt) < 1) {
                            $error .= "<li class='err'>There are no stock items in the selected store.</li>";
                            continue;
                        }
                        if ($sel_frm == "stkcod") {
                            $cods = "<select name='stkidss[]' onChange='javascript:document.form.submit();'>";
                            $cods .= "<option value='-S' disabled selected>Select Number</option>";
                            $count = 0;
                            while ($stk = pg_fetch_array($stkRslt)) {
                                $cods .= "<option value='{$stk['stkid']}'>{$stk['stkcod']} (" . sprint3($stk['units'] - $stk['alloc']) . ")</option>";
                            }
                            $cods .= "</select> ";
                            $descs = "";
                        } else {
                            $descs = "<select style='width:250px' name='stkidss[]' onChange='javascript:document.form.submit();'>";
                            $descs .= "<option value='-S' disabled selected>Select Description</option>";
                            $count = 0;
                            while ($stk = pg_fetch_array($stkRslt)) {
                                $descs .= "<option value='{$stk['stkid']}'>{$stk['stkdes']} (" . sprint3($stk['units'] - $stk['alloc']) . ")</option>";
                            }
                            $descs .= "</select> ";
                            $cods = "";
                        }
                        db_conn('cubit');
                        $Sl = "SELECT * FROM vatcodes ORDER BY code";
                        $Ri = db_exec($Sl) or errDie("Unable to get vat codes");
                        $Vatcodes = "\n\t\t\t\t\t\t<select name='vatcodess[]'>\n\t\t\t\t\t\t\t<option value='0'>Select</option>";
                        while ($vd = pg_fetch_array($Ri)) {
                            if ($vd['del'] == "Yes") {
                                $sel = "selected";
                            } else {
                                $sel = "";
                            }
                            $Vatcodes .= "<option value='{$vd['id']}' {$sel}>{$vd['code']}</option>";
                        }
                        $Vatcodes .= "</select>";
                        # put in drop down and warehouse
                        $products .= "\n\t\t\t\t\t\t<input type='hidden' name='accountss[]' value='0'>\n\t\t\t\t\t\t<input type='hidden' name='descriptionss[]' value=''>\n\t\t\t\t\t\t<input type='hidden' name='whidss[]' value='{$filter_store}'>\n\t\t\t\t\t\t<input type='hidden' name='amts[]' value='0.00'>\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td>{$cods}<input type='hidden' name='vatcodess' value='0'></td>\n\t\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t\t<td>{$descs}</td>\n\t\t\t\t\t\t\t<td><input type='text' size='3' name='qtyss[]'  value='1'></td>\n\t\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t" . CUR . " <input type='text' size='4' name='discs[]' value='0'>\n\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t<input type='text' size='4' name='discps[]' value='0' maxlength='5'>%\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>" . CUR . " 0.00</td>\n\t\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t</tr>";
                    } else {
                        $Accounts = "\n\t\t\t\t\t\t<select name='accountss[]'>\n\t\t\t\t\t\t\t<option value='0'>Select Account</option>";
                        $useaccdrop = getCSetting("USE_NON_STOCK_ACCOUNTS");
                        if (isset($useaccdrop) and $useaccdrop == "yes") {
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:67,代碼來源:sorder-new.php

示例8: details

function details($_GET)
{
    # get vars
    extract($_GET);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($purid, "num", 1, 20, "Invalid Order number.");
    # 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;
    }
    # Get Order info
    db_connect();
    $sql = "SELECT * FROM purch_int WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'";
    $purRslt = db_exec($sql) or errDie("Unable to get Order information");
    if (pg_numrows($purRslt) < 1) {
        return "<i class='err'>Order Not Found</i>";
    }
    $pur = pg_fetch_array($purRslt);
    /* --- Start Products Display --- */
    # select all products
    $products = "\n\t\t<table cellpadding='2' cellspacing='0' border='1' width='100%'>\n\t\t\t<tr>\n\t\t\t\t<th>WAREHOUSE</th>\n\t\t\t\t<th>ITEM NUMBER</th>\n\t\t\t\t<th>DESCRIPTION</th>\n\t\t\t\t<th>QTY</th>\n\t\t\t\t<th>UNIT PRICE</th>\n\t\t\t\t<th>DUTY</th>\n\t\t\t\t<th>AMT</th>\n\t\t\t\t<th>TOTAL COST AMT</th>\n\t\t\t<tr>";
    # get selected stock in this Order
    db_connect();
    $sql = "SELECT * FROM purint_items  WHERE purid = '{$purid}' AND div = '" . USER_DIV . "'";
    $stkdRslt = db_exec($sql);
    $i = 0;
    $key = 0;
    while ($stkd = pg_fetch_array($stkdRslt)) {
        # keep track of selected stock amounts
        $amts[$i] = $stkd['amt'];
        $i++;
        # get warehouse name
        db_conn("exten");
        $sql = "SELECT whname FROM warehouses WHERE whid = '{$stkd['whid']}' AND div = '" . USER_DIV . "'";
        $whRslt = db_exec($sql);
        $wh = pg_fetch_array($whRslt);
        # get selected stock in this warehouse
        db_connect();
        $sql = "SELECT * FROM stock WHERE stkid = '{$stkd['stkid']}' AND div = '" . USER_DIV . "'";
        $stkRslt = db_exec($sql);
        $stk = pg_fetch_array($stkRslt);
        /* -- Calculations -- */
        # Calculate cost amount bought
        $totamt = $stkd['qty'] * $stkd['unitcost'];
        // Prevent division by zero
        if ($totamt && $pur["subtot"]) {
            # Calculate percentage from subtotal
            $perc = $totamt / $pur['subtot'] * 100;
        } else {
            $perc = 0;
        }
        # Get percentage from shipping charges
        $shipchrg = $perc / 100 * $pur['shipchrg'];
        # add shipping charges to amt
        $totamt = round($totamt + $shipchrg, 2);
        /* -- End Calculations --*/
        # put in product//<a href='#' onclick='openwindow(\"stock-amt-det.php?stkid=$stk[stkid]\")'></a>
        $products .= "\n\t\t\t<tr>\n\t\t\t\t<td>{$wh['whname']}</td>\n\t\t\t\t<td>{$stk['stkcod']}</td>\n\t\t\t\t<td>" . extlib_rstr($stk['stkdes'], 30) . "</td>\n\t\t\t\t<td>" . sprint3($stkd['qty']) . "</td>\n\t\t\t\t<td nowrap>{$pur['curr']} " . sprint($stkd['cunitcost']) . " &nbsp;&nbsp;or &nbsp;&nbsp;R " . sprint($stkd['unitcost']) . "</td>\n\t\t\t\t<td nowrap>{$pur['curr']} {$stkd['duty']} &nbsp;&nbsp; or &nbsp;&nbsp;{$stkd['dutyp']}%</td>\n\t\t\t\t<td nowrap>{$pur['curr']} " . sprint($stkd["amt"]) . "</td>\n\t\t\t\t<td align='right' nowrap>{$pur['curr']} " . sprint($totamt) . "</td>\n\t\t\t</tr>";
    }
    $products .= "</table>";
    # Get supplier
    db_connect();
    $sql = "SELECT supname,supno FROM suppliers WHERE supid = '{$pur['supid']}' AND div = '" . USER_DIV . "'";
    $supRslt = db_exec($sql);
    if (pg_numrows($supRslt) < 1) {
        $sup['supname'] = "<li class='err'>Supplier not found.</li>";
        $sup['supno'] = "";
    } else {
        $sup = pg_fetch_array($supRslt);
    }
    # Get department
    db_conn("exten");
    $sql = "SELECT * FROM departments WHERE deptid = '{$pur['deptid']}' AND div = '" . USER_DIV . "'";
    $deptRslt = db_exec($sql);
    if (pg_numrows($deptRslt) < 1) {
        $dept['deptname'] = "<i class='err'>Not Found</i>";
    } else {
        $dept = pg_fetch_array($deptRslt);
    }
    # format date
    list($pyear, $pmon, $pday) = explode("-", $pur['pdate']);
    list($dyear, $dmon, $dday) = explode("-", $pur['ddate']);
    /* -- Final Layout -- */
    $details = "\n\t\t\t\t\t<center>\n\t\t\t\t\t<h3>International Order Details</h3>\n\t\t\t\t\t<table cellpadding='0' cellspacing='4' border='0' width='95%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td valign='top'>\n\t\t\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='1'>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th colspan='2'> Supplier Details </th>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Department</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$dept['deptname']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Supplier</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$sup['supname']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Account number</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$sup['supno']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td valign='top'>Supplier Address</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>" . nl2br($pur['supaddr']) . "</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td valign='top'>\n\t\t\t\t\t\t\t\t" . COMP_NAME . "<br>\n\t\t\t\t\t\t\t\t" . COMP_ADDRESS . "<br>\n\t\t\t\t\t\t\t\t" . COMP_PADDR . "<br>\n\t\t\t\t\t\t\t\t" . COMP_TEL . "<br>\n\t\t\t\t\t\t\t\t" . COMP_FAX . "<br>\n\t\t\t\t\t\t\t\tReg No. " . COMP_REGNO . "<br>\n\t\t\t\t\t\t\t\tVAT No. " . COMP_VATNO . "<br>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td valign='top' align='right'>\n\t\t\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='1'>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th colspan='2'> Order Details </th>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Order No.</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['purnum']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Terms</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['terms']} Days</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Date</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pday}-{$pmon}-{$pyear}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Foreign Currency</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['curr']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Exchange rate</td>\n\t\t\t\t\t\t\t\t\t\t<td>" . CUR . " {$pur['xrate']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Tax</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['curr']} {$pur['tax']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Shipping Charges</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$pur['curr']} {$pur['fshipchrg']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Delivery Date</td>\n\t\t\t\t\t\t\t\t\t\t<td valign='center'>{$dday}-{$dmon}-{$dyear}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>\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><td><br></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='3'>{$products}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2'></td>\n\t\t\t\t\t\t\t<td align='right'>\n\t\t\t\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='1' width='80%'>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>SUBTOTAL</td>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>{$pur['curr']} {$pur['subtot']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Shipping Charges</td>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>{$pur['curr']} {$pur['shipchrg']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<td>Tax </td>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>{$pur['curr']} {$pur['tax']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t<th>GRAND TOTAL</th>\n\t\t\t\t\t\t\t\t\t\t<td align='right'>{$pur['curr']} {$pur['total']}</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t\t</form>\n\t\t\t\t\t</center>";
    $OUTPUT = $details;
    require "tmpl-print.php";
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:95,代碼來源:purch-int-det.php

示例9: details


//.........這裏部分代碼省略.........
                    # skip if not selected
                    if ($whid == "-S") {
                        continue;
                    }
                    # get warehouse name
                    db_conn("exten");
                    $sql = "SELECT whname FROM warehouses WHERE whid = '{$whid}' AND div = '" . USER_DIV . "'";
                    $whRslt = db_exec($sql);
                    $wh = pg_fetch_array($whRslt);
                    if (isset($ria) && $ria != "") {
                        $len = strlen($ria);
                        $Wh = "AND lower(substr(stkcod,1,'{$len}'))=lower('{$ria}')";
                    } else {
                        $Wh = "";
                        $ria = "";
                    }
                    # get stock on this warehouse
                    db_connect();
                    $sql = "SELECT * FROM stock WHERE whid = '{$whid}' AND blocked = 'n' AND div = '" . USER_DIV . "' {$Wh} ORDER BY stkcod ASC";
                    $stkRslt = db_exec($sql) or errDie("Unable to retrieve stocks from database.");
                    if (pg_numrows($stkRslt) < 1) {
                        $error .= "<li class='err'>There are no stock items in the selected warehouse.";
                        continue;
                    }
                    if (pg_numrows($stkRslt) == 1) {
                        $ex = "selected";
                    } else {
                        $ex = "";
                    }
                    $stks = "<select class='width : 15'name='stkidss[]' onChange='javascript:document.form.submit();'>";
                    $stks .= "<option value='-S' disabled selected>Select Number</option>";
                    $count = 0;
                    while ($stk = pg_fetch_array($stkRslt)) {
                        $stks .= "<option value='{$stk['stkid']}'>{$stk['stkcod']} (" . sprint3($stk['units'] - $stk['alloc']) . ")</option>";
                    }
                    $stks .= "</select> ";
                    db_conn('cubit');
                    $Sl = "SELECT * FROM vatcodes ORDER BY code";
                    $Ri = db_exec($Sl) or errDie("Unable to get vat codes");
                    $Vatcodes = "\n\t\t\t\t\t\t<select name='vatcodess[]'>\n\t\t\t\t\t\t\t<option value='0'>Select</option>";
                    while ($vd = pg_fetch_array($Ri)) {
                        if ($vd['del'] == "Yes") {
                            $sel = "selected";
                        } else {
                            $sel = "";
                        }
                        $Vatcodes .= "<option value='{$vd['id']}' {$sel}>{$vd['code']}</option>";
                    }
                    $Vatcodes .= "</select>";
                    # put in drop down and warehouse
                    $products .= "\n\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t<td><input type='hidden' name='whidss[]' value='{$whid}'>{$wh['whname']}</td>\n\t\t\t\t\t\t\t<td>{$stks}</td>\n\t\t\t\t\t\t\t<td><input type='hidden' name='vatcodess' value='0'></td>\n\t\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t\t<td><input type='hidden' size='3' name='qtyss[]'  value='1'>1</td>\n\t\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t\t<td> </td>\n\t\t\t\t\t\t\t<td>{$inv['currency']} <input type='text' size='4' name='discs[]' value='0'> OR <input type='text' size='4' name='discps[]' value='0' maxlength='5'>%</td>\n\t\t\t\t\t\t\t<td><input type='hidden' name='amts[]' value='0.00'>{$inv['currency']} 0.00</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t</tr>";
                }
            }
        }
    } else {
        if (!isset($diffwhBtn)) {
            # check if setting exists
            db_connect();
            $sql = "SELECT value FROM set WHERE label = 'DEF_WH' AND div = '" . USER_DIV . "'";
            $Rslt = db_exec($sql) or errDie("Unable to check database for existing settings.");
            if (pg_numrows($Rslt) > 0) {
                $set = pg_fetch_array($Rslt);
                $whid = $set['value'];
                if (isset($wtd)) {
                    $whid = $wtd;
                }
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:67,代碼來源:intinvoice-new.php

示例10: details


//.........這裏部分代碼省略.........
        if (pg_num_rows($Ri) < 1) {
            return "Please select the vatcode for all your stock.";
        }
        $vd = pg_fetch_array($Ri);
        $sp = "";
        # Check Tax Excempt
        if ($stk['exvat'] == 'yes' || $vd['zero'] == "Yes") {
            $taxex += $stkd['amt'];
            $ex = "#";
        } else {
            $ex = "";
        }
        # all must be excempted
        if ($inv['chrgvat'] == 'nov') {
            $ex = "#";
        }
        # Keep track of discounts
        $disc += $stkd['disc'] * $stkd['qty'];
        # Insert stock record
        $sdate = date("Y-m-d");
        $csprice = sprint($stk['csprice'] * $stkd['qty']);
        # Get amount exluding vat if including and not exempted
        $VATP = TAX_VAT;
        $amtexvat = sprint($stkd['famt']);
        if ($inv['chrgvat'] == "inc" && $stk['exvat'] != 'yes') {
            $amtexvat = sprint($stkd['famt'] * 100 / (100 + $VATP));
        }
        db_connect();
        $sql = "\n\t\t\tINSERT INTO stockrec (\n\t\t\t\tedate, stkid, stkcod, stkdes, trantype, qty, csprice, csamt, \n\t\t\t\tdetails, div\n\t\t\t) VALUES (\n\t\t\t\t'{$td}', '{$stkd['stkid']}', '{$stk['stkcod']}', '{$stk['stkdes']}', 'invoice', '{$stkd['qty']}', '{$amtexvat}', '{$csprice}', \n\t\t\t\t'Stock sold - Invoice No. {$invnum}', '" . USER_DIV . "'\n\t\t\t)";
        $recRslt = db_exec($sql);
        # Sales rep commission
        $commision = $commision + coms($inv['salespn'], $stkd['amt'], $stk['com']);
        # Put in product
        $products .= "\n\t\t\t<tr valign='top'>\n\t\t\t\t<td>{$stk['stkcod']}</td>\n\t\t\t\t<td>{$ex} {$sp} {$stk['stkdes']}</td>\n\t\t\t\t<td>" . sprint3($stkd['qty']) . "</td>\n\t\t\t\t<td>{$inv['currency']} " . sprint($stkd['unitcost']) . "</td>\n\t\t\t\t<td>{$inv['currency']} {$stkd['disc']}</td>\n\t\t\t\t<td>{$inv['currency']} {$stkd['amt']}</td>\n\t\t\t</tr>";
    }
    /* --- Start Some calculations --- */
    # Subtotal
    $SUBTOT = sprint($inv['subtot']);
    # Calculate subtotal
    $VATP = TAX_VAT;
    $SUBTOTAL = sprint($inv['subtot']);
    $VAT = sprint($inv['vat']);
    $TOTAL = sprint($inv['total']);
    $inv['delchrg'] = sprint($inv['delchrg']);
    $FSUBTOT = sprint($inv['subtot'] * $inv['xrate']);
    $FVAT = sprint($inv['vat'] * $inv['xrate']);
    $FTOTAL = sprint($inv['total'] * $inv['xrate']);
    $fdelchrg = sprint($inv['delchrg'] * $inv['xrate']);
    $ftraddiscm = sprint($inv['discount'] * $inv['xrate']);
    com_invoice($inv['salespn'], $FTOTAL, $commision * $inv['xrate'], $invnum, $td);
    /* --- End Some calculations --- */
    /* - Start Hooks - */
    $vatacc = gethook("accnum", "salesacc", "name", "VAT", "int");
    /* - End Hooks - */
    # Todays date
    $date = date("d-m-Y");
    $sdate = date("Y-m-d");
    $refnum = getrefnum();
    /*$refnum*/
    /* --- Updates ---- */
    db_connect();
    $Sql = "UPDATE invoices SET printed ='y', done ='y', invnum='{$invnum}' WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
    $upRslt = db_exec($Sql) or errDie("Unable to update invoice information");
    # Record the payment on the statement
    $sql = "\n\t\tINSERT INTO stmnt (\n\t\t\tcusnum, invid, amount, date, type, div, allocation_date\n\t\t) VALUES (\n\t\t\t'{$inv['cusnum']}','{$invnum}', '{$TOTAL}', '{$inv['odate']}', 'Invoice', '" . USER_DIV . "', '{$inv['odate']}'\n\t\t)";
    $stmntRslt = db_exec($sql) or errDie("Unable to insert statement record in Cubit.", SELF);
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:67,代碼來源:intinvoice-print.php

示例11: details

function details($_GET)
{
    # get vars
    extract($_GET);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($invid, "num", 1, 20, "Invalid invoice number.");
    # 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;
    }
    # Get invoice info
    db_connect();
    $sql = "SELECT * FROM sorders WHERE sordid = '{$invid}' 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</i>";
    }
    $inv = pg_fetch_array($invRslt);
    /* --- Start some checks --- */
    # Check if stock was selected(yes = put done button)
    db_connect();
    $sql = "SELECT stkid FROM sorders_items WHERE sordid = '{$inv['sordid']}' AND div = '" . USER_DIV . "'";
    $crslt = db_exec($sql);
    if (pg_numrows($crslt) < 1) {
        $error = "<li class='err'> Error : Consignment number <b>{$invid}</b> has no items.</li>";
        $error .= "<p><input type='button' onClick='JavaScript:history.back();' value='&laquo; Correct submission'>";
        return $error;
    }
    /* --- End some checks --- */
    /* --- Start Products Display --- */
    # Products layout
    $products = "";
    $disc = 0;
    # get selected stock in this invoice
    db_connect();
    $sql = "SELECT * FROM sorders_items  WHERE sordid = '{$invid}' AND div = '" . USER_DIV . "'";
    $stkdRslt = db_exec($sql);
    while ($stkd = pg_fetch_array($stkdRslt)) {
        # Get warehouse name
        db_conn("exten");
        $sql = "SELECT whname FROM warehouses WHERE whid = '{$stkd['whid']}' AND div = '" . USER_DIV . "'";
        $whRslt = db_exec($sql);
        $wh = pg_fetch_array($whRslt);
        # Get selected stock in this warehouse
        db_connect();
        $sql = "SELECT * FROM stock WHERE stkid = '{$stkd['stkid']}' AND div = '" . USER_DIV . "'";
        $stkRslt = db_exec($sql);
        $stk = pg_fetch_array($stkRslt);
        # Keep track of discounts
        $disc += $stkd['disc'];
        # Put in product
        $products .= "\r\n\t\t\t<tr valign=top>\r\n\t\t\t\t<td>{$stk['stkcod']}</td>\r\n\t\t\t\t<td>{$stk['stkdes']}</td>\r\n\t\t\t\t<td>" . sprint3($stkd['qty']) . "</td>\r\n\t\t\t\t<td>" . sprint($stkd['unitcost']) . "</td>\r\n\t\t\t\t<td>{$inv['currency']} {$stkd['amt']}</td>\r\n\t\t\t</tr>";
    }
    /* --- Start Some calculations --- */
    # subtotal
    $SUBTOT = sprint($inv['subtot']);
    $VATP = TAX_VAT;
    # Calculate subtotal
    $SUBTOT = sprint($inv['subtot']);
    $VAT = sprint($inv['vat']);
    $TOTAL = sprint($inv['total']);
    /* --- End Some calculations --- */
    # todays date
    $date = date("d-m-Y");
    $sdate = date("Y-m-d");
    # Avoid little box
    if (strlen($inv['comm']) > 0) {
        $inv['comm'] = "\r\n\t\t\t<table border='1' cellspacing='0' bordercolor='#000000'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>" . nl2br($inv['comm']) . "</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table>";
    }
    if ($inv['chrgvat'] == "yes") {
        $inv['chrgvat'] = "Inclusive";
    } elseif ($inv['chrgvat'] == "no") {
        $inv['chrgvat'] = "Exclusive";
    } else {
        $inv['chrgvat'] = "No vat";
    }
    /* -- Final Layout -- */
    $details = "\r\n\t\t<center>\r\n\t\t<h2>Sales Order</h2>\r\n\t\t<table cellpadding='0' cellspacing='4' border='0' width='770'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td valign='top' width='30%'>\r\n\t\t\t\t\t<table " . TMPL_tblDflts . ">\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td>{$inv['surname']}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td>" . nl2br($inv['cusaddr']) . "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td>(Vat No. {$inv['cusvatno']})</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td valign='top' width='30%'>\r\n\t\t\t\t\t" . COMP_NAME . "<br>\r\n\t\t\t\t\t" . COMP_ADDRESS . "<br>\r\n\t\t\t\t\t" . COMP_TEL . "<br>\r\n\t\t\t\t\t" . COMP_FAX . "<br>\r\n\t\t\t\t\tReg No. " . COMP_REGNO . "<br>\r\n\t                VAT No. " . COMP_VATNO . "<br>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td align='left' width='20%'><img src='compinfo/getimg.php' width='230' height='47'></td>\r\n\t\t\t\t<td valign='bottom' align='right' width='20%'>\r\n\t\t\t\t\t<table cellpadding='2' cellspacing='0' border='1' bordercolor='#000000'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>Sales Order No.</b></td>\r\n\t\t\t\t\t\t\t<td valign='center'>{$inv['sordid']}</td></tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>Order No.</b></td>\r\n\t\t\t\t\t\t\t<td valign='center'>{$inv['ordno']}</td></tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>Terms</b></td>\r\n\t\t\t\t\t\t\t<td valign='center'>{$inv['terms']} Days</td></tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>Date</b></td>\r\n\t\t\t\t\t\t\t<td valign='center'>{$inv['odate']}</td></tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>Vat</b></td>\r\n\t\t\t\t\t\t\t<td valign='center'>{$inv['chrgvat']}</td></tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='4'>\r\n\t\t\t\t\t<table cellpadding='5' cellspacing='0' border='1' width='100%' bordercolor='#000000'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<th>ITEM NUMBER</th>\r\n\t\t\t\t\t\t\t<th width='45%'>DESCRIPTION</th>\r\n\t\t\t\t\t\t\t<th>QTY</th>\r\n\t\t\t\t\t\t\t<th>UNIT PRICE</th>\r\n\t\t\t\t\t\t\t<th>AMOUNT</th>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t{$products}\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td>{$inv['comm']}</td>\r\n\t\t\t\t<td align='right' colspan='3'>\r\n\t\t\t\t\t<table cellpadding='5' cellspacing='0' border='1' width='50%' bordercolor='#000000'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>SUBTOTAL</b></td>\r\n\t\t\t\t\t\t\t<td align='right'>{$inv['currency']} {$SUBTOT}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>Trade Discount</b></td>\r\n\t\t\t\t\t\t\t<td align='right'>{$inv['currency']} {$inv['discount']}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>Delivery Charge</b></td>\r\n\t\t\t\t\t\t\t<td align='right'>{$inv['currency']} {$inv['delivery']}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td><b>VAT @ {$VATP}%</b></td>\r\n\t\t\t\t\t\t\t<td align='right'>{$inv['currency']} {$VAT}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<th><b>GRAND TOTAL<b></th>\r\n\t\t\t\t\t\t\t<td align='right'>{$inv['currency']} {$TOTAL}</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr><td><br></td></tr>\r\n\t\t</table>\r\n\t\t</center>";
    $OUTPUT = $details;
    require "tmpl-print.php";
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:89,代碼來源:intsorder-print.php

示例12: report

function report($_POST)
{
    extract($_POST);
    require_lib("validate");
    $v = new validate();
    //$v->isOk ($stkid, "num", 1, 50, "Invalid stock number.");
    $v->isOk($from_day, "num", 1, 2, "Invalid from Date day.");
    $v->isOk($from_month, "num", 1, 2, "Invalid from Date month.");
    $v->isOk($from_year, "num", 1, 4, "Invalid from Date Year.");
    $v->isOk($to_day, "num", 1, 2, "Invalid to Date day.");
    $v->isOk($to_month, "num", 1, 2, "Invalid to Date month.");
    $v->isOk($to_year, "num", 1, 4, "Invalid to Date Year.");
    $fromdate = $from_year . "-" . $from_month . "-" . $from_day;
    $todate = $to_year . "-" . $to_month . "-" . $to_day;
    if (!checkdate($from_month, $from_day, $from_year)) {
        $v->isOk($fromdate, "num", 1, 1, "Invalid from date.");
    }
    if (!checkdate($to_month, $to_day, $to_year)) {
        $v->isOk($todate, "num", 1, 1, "Invalid to date.");
    }
    if (!isset($stkids)) {
        $v->addError("", "Please select at least on stock item.");
    }
    if ($v->isError()) {
        return slct($v->genErrors());
    }
    $freport = "";
    if (in_array('all', $stkids)) {
        $stkids = $alls;
    }
    $ss = "";
    foreach ($stkids as $stkid) {
        $ss .= "<input type='hidden' name='stkids[]' value='{$stkid}'>";
        db_connect();
        $sql = "SELECT * FROM stock WHERE stkid = '{$stkid}'";
        $stkRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
        if (pg_numrows($stkRslt) < 1) {
            return "<li> Invalid Stock ID.</li>";
        } else {
            $stk = pg_fetch_array($stkRslt);
        }
        db_conn("exten");
        $sql = "SELECT whname FROM warehouses WHERE whid = '{$stk['whid']}'";
        $whRslt = db_exec($sql);
        $wh = pg_fetch_array($whRslt);
        db_connect();
        $sql = "SELECT * FROM stockrec WHERE edate >= '{$fromdate}' AND edate <= '{$todate}' AND stkid = '{$stkid}' AND (trantype = 'invoice' OR trantype='note') ORDER BY edate DESC";
        $recRslt = db_exec($sql) or errDie("Unable to access databse.", SELF);
        $records = "";
        $totprof = 0;
        $totprice = 0;
        $totqty = 0;
        while ($rec = pg_fetch_array($recRslt)) {
            $rec['edate'] = explode("-", $rec['edate']);
            $rec['edate'] = $rec['edate'][2] . "-" . $rec['edate'][1] . "-" . $rec['edate'][0];
            if ($rec['trantype'] == "note") {
                $rec['qty'] = -$rec['qty'];
                $rec['csprice'] = -$rec['csprice'];
                $rec['csamt'] = -$rec['csamt'];
            }
            $totqty += $rec['qty'];
            $prof = $rec['csprice'] - $rec['csamt'];
            $totprof += $prof;
            $totprice += $rec['csprice'];
            $records .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$rec['edate']}</td>\n\t\t\t\t<td>{$rec['details']}</td>\n\t\t\t\t<td>" . sprint3($rec['qty']) . "</td>\n\t\t\t\t<td>" . CUR . sprint($rec["csprice"]) . "</td>\n\t\t\t\t<td>" . CUR . sprint($prof) . "</td>\n\t\t\t</tr>";
        }
        $totprice = sprint($totprice);
        $totprof = sprint($totprof);
        $totqty = sprint3($totqty);
        $freport .= "\n\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th colspan='2'>Details</th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Warehouse</td>\n\t\t\t\t\t\t\t\t<td>{$wh['whname']}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Stock code</td>\n\t\t\t\t\t\t\t\t<td>{$stk['stkcod']}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Stock description</td>\n\t\t\t\t\t\t\t\t<td>" . nl2br($stk['stkdes']) . "</pre></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Category</td>\n\t\t\t\t\t\t\t\t<td>{$stk['catname']}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td>Category</td>\n\t\t\t\t\t\t\t\t<td>{$stk['classname']}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th>Date</th>\n\t\t\t\t\t\t\t\t<th>Details</th>\n\t\t\t\t\t\t\t\t<th>Quantity</th>\n\t\t\t\t\t\t\t\t<th>Selling Price</th>\n\t\t\t\t\t\t\t\t<th>Gross Profit</th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t{$records}\n\t\t\t\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t\t\t\t<td colspan='2'><b>Totals</b></td>\n\t\t\t\t\t\t\t\t<td>{$totqty}</td>\n\t\t\t\t\t\t\t\t<td>" . CUR . " {$totprice}</td>\n\t\t\t\t\t\t\t\t<td>" . CUR . " {$totprof}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t" . TBL_BR;
    }
    $report = "\n\t\t\t\t<h3>Stock Sales Report</h3>\n\t\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t\t{$freport}\n\t\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t\t<input type='hidden' name='key' value='export'>\n\t\t\t\t\t{$ss}\n\t\t\t\t\t<input type='hidden' name='fday' value='{$from_day}'>\n\t\t\t\t\t<input type='hidden' name='fmon' value='{$from_month}'>\n\t\t\t\t\t<input type='hidden' name='fyear' value='{$from_year}'>\n\t\t\t\t\t<input type='hidden' name='today' value='{$to_day}'>\n\t\t\t\t\t<input type='hidden' name='tomon' value='{$to_month}'>\n\t\t\t\t\t<input type='hidden' name='toyear' value='{$to_year}'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='2'><input type='submit' value='Export to Spreadsheet'></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>" . mkQuickLinks(ql("stock-sales-rep.php", "Sales Report"));
    return $report;
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:74,代碼來源:stock-sales-rep-stk.php

示例13: write

function write($_POST)
{
    # Get vars
    extract($_POST);
    # validate input
    require_lib("validate");
    $v = new validate();
    $v->isOk($sordid, "num", 1, 20, "Invalid Sales Order 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 Sales Order info
    db_connect();
    $sql = "SELECT * FROM sorders WHERE sordid = '{$sordid}' AND div = '" . USER_DIV . "'";
    $sordRslt = db_exec($sql) or errDie("Unable to get Sales Order information");
    if (pg_numrows($sordRslt) < 1) {
        return "<li class='err'>Sales Order Not Found</li>";
    }
    $sord = pg_fetch_array($sordRslt);
    /* - Start Copying - */
    pglib_transaction("BEGIN") or errDie("Unable to start a database transaction.", SELF);
    db_connect();
    # Insert invoice to DB
    $sql = "\n\t\tINSERT INTO invoices (\n\t\t\tdeptid, cusnum, deptname, cusacc, cusname, surname, \n\t\t\tcusaddr, cusvatno, cordno, ordno, chrgvat, terms, \n\t\t\ttraddisc, salespn, odate, delchrg, subtot, vat, \n\t\t\tdiscount, delivery, total, balance, comm, printed, \n\t\t\tdone, serd, prd, div, docref, delvat\n\t\t) VALUES (\n\t\t\t'{$sord['deptid']}', '{$sord['cusnum']}', '{$sord['deptname']}', '{$sord['cusacc']}', '{$sord['cusname']}', '{$sord['surname']}', \n\t\t\t'{$sord['cusaddr']}', '{$sord['cusvatno']}', '{$sord['cordno']}', '{$sord['ordno']}', '{$sord['chrgvat']}', '{$sord['terms']}', \n\t\t\t'{$sord['traddisc']}', '{$sord['salespn']}', '{$sord['odate']}', '{$sord['delchrg']}', '{$sord['subtot']}', '{$sord['vat']}' , \n\t\t\t'{$sord['discount']}', '{$sord['delivery']}', '{$sord['total']}', '{$sord['total']}', '{$sord['comm']}', 'n', \n\t\t\t'y', 'n', '" . PRD_DB . "', '" . USER_DIV . "', '{$sord['pinvnum']}', '{$sord['delvat']}'\n\t\t)";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice to Cubit.", SELF);
    # get next ordnum
    $invid = lastinvid();
    # get selected stock in this Sales Order
    db_connect();
    $sql = "SELECT *, qty - iqty AS rqty FROM sorders_items WHERE sordid = '{$sordid}' AND div = '" . USER_DIV . "'";
    $stkdRslt = db_exec($sql);
    $serd = "y";
    while ($stkd = pg_fetch_array($stkdRslt)) {
        $sord_itemid = $stkd['id'];
        $iqty[$sord_itemid] = sprint3($iqty[$sord_itemid]);
        if (!isset($iqty[$sord_itemid]) or $iqty[$sord_itemid] <= 0 or strlen($iqty[$sord_itemid]) < 1) {
            continue;
        }
        if ($iqty[$sord_itemid] > $stkd['rqty']) {
            pglib_transaction("ROLLBACK") or errDie("Unable to complete transaction.");
            return details(array("sordid" => $sordid), "<li class='err'>Invalid Qty To Invoice.</li>");
        }
        # Insert one by one per quantity
        if (ext_isSerial("stock", "stkid", $stkd['stkid'])) {
            $stkd['amt'] = sprint($stkd['amt'] / $stkd['qty']);
            $serd = "n";
            for ($i = 0; $i < $stkd['qty']; $i++) {
                # insert invoice items
                $stkd['vatcode'] += 0;
                $stkd['account'] += 0;
                $sql = "\n\t\t\t\t\tINSERT INTO inv_items (\n\t\t\t\t\t\tinvid, whid, stkid, qty, unitcost, amt, \n\t\t\t\t\t\tdisc, discp, div, vatcode, description, account\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t'{$invid}', '{$stkd['whid']}', '{$stkd['stkid']}', '1', '{$stkd['unitcost']}', '{$stkd['amt']}', \n\t\t\t\t\t\t'{$stkd['disc']}', '{$stkd['discp']}', '" . USER_DIV . "', '{$stkd['vatcode']}', '{$stkd['description']}', '{$stkd['account']}'\n\t\t\t\t\t)";
                $rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.", SELF);
            }
        } else {
            $stkd['vatcode'] += 0;
            $stkd['account'] += 0;
            # insert invoice items
            $sql = "\n\t\t\t\tINSERT INTO inv_items (\n\t\t\t\t\tinvid, whid, stkid, qty, unitcost, amt, \n\t\t\t\t\tdisc, discp, div, vatcode, description, account\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$invid}', '{$stkd['whid']}', '{$stkd['stkid']}', '{$iqty[$sord_itemid]}', '{$stkd['unitcost']}', '{$stkd['amt']}', \n\t\t\t\t\t'{$stkd['disc']}', '{$stkd['discp']}', '" . USER_DIV . "', '{$stkd['vatcode']}', '{$stkd['description']}', '{$stkd['account']}'\n\t\t\t\t)";
            $rslt = db_exec($sql) or errDie("Unable to insert invoice items to Cubit.", SELF);
            # update the sales order information
            $upd_sql = "UPDATE sorders_items SET iqty = iqty + '{$iqty[$sord_itemid]}' WHERE sordid = '{$stkd['sordid']}' AND id = '{$sord_itemid}'";
            $run_upd = db_exec($upd_sql) or errDie("Unable to update sales order information.");
        }
    }
    # get selected stock in this Sales Order
    db_connect();
    $sql = "SELECT * FROM sord_data  WHERE sordid = '{$sordid}' AND div = '" . USER_DIV . "'";
    $dataRslt = db_exec($sql);
    $data = pg_fetch_array($dataRslt);
    $sql = "INSERT INTO inv_data (invid, dept, customer, addr1, div) VALUES ('{$invid}', '{$data['dept']}', '{$data['customer']}', '{$data['addr1']}', '" . USER_DIV . "')";
    $rslt = db_exec($sql) or errDie("Unable to insert invoice data to Cubit.", SELF);
    # check if there is anything still left
    $get_check = "SELECT * FROM sorders_items WHERE sordid = '{$sordid}' AND (qty - iqty) > 0";
    $run_check = db_exec($get_check) or errDie("Unable to check sales order completed status.");
    if (pg_numrows($run_check) <= 0) {
        # set to accepted
        $sql = "UPDATE sorders SET accepted = 'y' WHERE sordid = '{$sordid}' AND div = '" . USER_DIV . "'";
        $rslt = db_exec($sql) or errDie("Unable to update quotes in Cubit.", SELF);
    }
    # set to not serialised
    $sql = "UPDATE invoices SET serd = '{$serd}' WHERE invid = '{$invid}' AND div = '" . USER_DIV . "'";
    $rslt = db_exec($sql) or errDie("Unable to update quotes in Cubit.", SELF);
    /* remove access data
    	$sql = "DELETE FROM sorders WHERE sordid = '$sordid' AND div = '".USER_DIV."'";
    	$rslt = db_exec($sql) or errDie("Unable to update Sales Orders on Cubit.",SELF);
    
    	$sql = "DELETE FROM sorders_items WHERE sordid = '$sordid' AND div = '".USER_DIV."'";
    	$rslt = db_exec($sql) or errDie("Unable to update Sales Orders in Cubit.",SELF);
    
    	$sql = "DELETE FROM sord_data WHERE sordid = '$sordid' AND div = '".USER_DIV."'";
    	$rslt = db_exec($sql) or errDie("Unable to update Sales Orders in Cubit.",SELF);
    	*/
    # End updates
    pglib_transaction("COMMIT") or errDie("Unable to commit a database transaction.", SELF);
//.........這裏部分代碼省略.........
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:101,代碼來源:sorder-accept.php

示例14: details


//.........這裏部分代碼省略.........
            $sql = "SELECT * FROM stock WHERE stkid = '{$stkd['stkid']}' AND div = '" . USER_DIV . "'";
            $stkRslt = db_exec($sql);
            $stk = pg_fetch_array($stkRslt);
            $tcosamt += sprint($stkd['qty'] * $stk['csprice'], 2);
        } else {
            $stk = array('stkcod' => "", 'stkdes' => $stkd['description'], 'exvat' => "");
        }
        db_conn('cubit');
        $Sl = "SELECT * FROM vatcodes WHERE id='{$stkd['vatcode']}'";
        $Ri = db_exec($Sl);
        // 		if(pg_num_rows($Ri)>0) {
        // 			$stk['exvat']="yes";
        // 		} else {
        // 			$stk['exvat']="";
        // 		}
        $vd = pg_fetch_array($Ri);
        if (TAX_VAT != $vd['vat_amount'] and $vd['vat_amount'] != "0.00") {
            $showvat = FALSE;
        }
        // Check Tax Excempt
        db_conn("cubit");
        $sql = "SELECT zero FROM vatcodes WHERE id='{$stkd['vatcode']}'";
        $zRslt = db_exec($sql) or errDie("Unable to retrieve vat code from Cubit.");
        $vatex = pg_fetch_result($zRslt, 0);
        if ($vatex == "Yes") {
            $ex = "#";
        } else {
            $ex = "";
        }
        $selamt = sprint($stkd['amt'] / $stkd['qty']);
        $selamt2 = sprint($stkd['amt']);
        $nsub += $selamt2;
        # put in product
        $products[$page][] = "\n\t\t<tr valign='top'>\n\t\t\t<td style='border-right: 2px solid #000'>{$stk['stkcod']}&nbsp;</td>\n\t\t\t<td style='border-right: 2px solid #000'>{$ex} {$stk['stkdes']}&nbsp;</td>\n\t\t\t<td style='border-right: 2px solid #000'>" . sprint3($stkd['qty']) . "&nbsp;</td>\n\t\t\t<td style='border-right: 2px solid #000' align='right' nowrap>" . CUR . " {$selamt}&nbsp;</td>\n\t\t\t<td align='right' nowrap>" . CUR . " {$stkd['amt']}&nbsp;</td>\n\t\t</tr>";
        $i++;
    }
    $blank_lines = 25;
    foreach ($products as $key => $val) {
        $bl = $blank_lines - count($products[$key]);
        for ($i = 0; $i <= $bl; $i++) {
            $products[$key][] = "\n \t\t\t<tr>\n \t\t\t\t<td style='border-right: 2px solid #000'>&nbsp;</td>\n \t\t\t\t<td style='border-right: 2px solid #000'>&nbsp;</td>\n \t\t\t\t<td style='border-right: 2px solid #000'>&nbsp;</td>\n \t\t\t\t<td style='border-right: 2px solid #000'>&nbsp;</td>\n \t\t\t\t<td>&nbsp;</td>\n \t\t\t</tr>";
        }
    }
    # Avoid little box
    if (strlen($note['comm']) > 0) {
        $note['comm'] = "\n\t\t<table border=1 cellspacing='0' bordercolor='#000000'>\n\t\t\t<tr><td>" . nl2br($note['comm']) . "</td></tr>\n\t\t</table>";
    }
    # VAT perc
    $VATP = TAX_VAT;
    # format date
    $cc = "";
    if (isset($cccc)) {
        $cc = "<script> nCostCenter('ct', 'Credit Note', '{$note['odate']}', 'Credit Note No.{$note['notenum']} for Customer {$note['cusname']} {$note['surname']}', '" . ($note['total'] - $note['vat']) . "', 'Credit Note No.{$note['notenum']}', '{$tcosamt}', ''); </script>";
    }
    $nsub = sprint($nsub);
    if (!isset($showvat)) {
        $showvat = TRUE;
    }
    if ($showvat == TRUE) {
        $vat14 = AT14;
    } else {
        $vat14 = "";
    }
    // Retrieve the company information
    db_conn("cubit");
    $sql = "SELECT * FROM compinfo";
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:67,代碼來源:invoice-note-reprint.php

示例15: export

function export()
{
    # Set up table to display in
    $printStk = "\n\t\t<center>\n\t\t<h3>Available Stock</h3>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<th>Store</th>\n\t\t\t\t<th>Category</th>\n\t\t\t\t<th>Stock Code</th>\n\t\t\t\t<th>Stock Description</th>\n\t\t\t\t<th>Product class</th>\n\t\t\t\t<th>Available units</th>\n\t\t\t\t<th>Cost Amount</th>\n\t\t\t\t<th>Minimun Level</th>\n\t\t\t\t<th>Maximum Level</th>\n\t\t\t\t<th>Selling Price</th>\n\t\t\t</tr>";
    # connect to database
    db_connect();
    # Query server
    $i = 0;
    $tot_avail = 0;
    $tot_cost = 0;
    $tot_sell = 0;
    $sql = "SELECT * FROM stock WHERE units > 0 AND div = '" . USER_DIV . "' ORDER BY stkdes ASC";
    $stkRslt = db_exec($sql) or errDie("Unable to retrieve stocks from database.");
    if (pg_numrows($stkRslt) < 1) {
        return "\n\t\t\t<li>There are no available stock found in Cubit.\n\t\t\t<p>\n\t\t\t<table " . TMPL_tblDflts . " width='15%'>\n\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Quick Links</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td><a href='main.php'>Main Menu</a></td>\n\t\t\t\t</tr>\n\t\t\t</table>";
    }
    while ($stk = pg_fetch_array($stkRslt)) {
        $stk['units'] = $stk['units'] - $stk['alloc'];
        # alternate bgcolor
        # get warehouse
        db_conn("exten");
        $sql = "SELECT whname FROM warehouses WHERE whid = '{$stk['whid']}'";
        $whRslt = db_exec($sql);
        $wh = pg_fetch_array($whRslt);
        $printStk .= "\n\t\t\t<tr>\n\t\t\t\t<td>{$wh['whname']}</td>\n\t\t\t\t<td>{$stk['catname']}</td>\n\t\t\t\t<td>{$stk['stkcod']}</td>\n\t\t\t\t<td align='center'>{$stk['stkdes']}</td>\n\t\t\t\t<td>{$stk['prdcls']}</td>\n\t\t\t\t<td align='right'>" . sprint3($stk['units']) . "</td>\n\t\t\t\t<td align='right'>" . CUR . " " . sprint($stk['csamt']) . "</td>\n\t\t\t\t<td align='right'>{$stk['minlvl']}</td>\n\t\t\t\t<td align='right'>{$stk['maxlvl']}</td>\n\t\t\t\t<td align='left'>" . CUR . " " . sprint($stk['selamt'] * $stk['units']) . " (" . CUR . " {$stk['selamt']} each)</td>\n\t\t\t</tr>";
        #handle totals
        if ($stk['units'] > 0) {
            $tot_avail += $stk['units'];
        }
        if ($stk['csamt'] > 0) {
            $tot_cost += $stk['csamt'];
        }
        if ($stk['selamt'] > 0) {
            $tot_sell += $stk['selamt'] * $stk['units'];
        }
    }
    $printStk .= "\n\t\t<tr>\n\t\t\t<td colspan='5'>Totals:</td>\n\t\t\t<td align='right'>" . sprint3($tot_avail) . "</td>\n\t\t\t<td align='right'>" . CUR . " " . sprint($tot_cost) . "</td>\n\t\t\t<td colspan='2'></td>\n\t\t\t<td align='left'>" . CUR . " " . sprint($tot_sell) . "</td>\n\t\t</tr>\n\t\t</table>";
    $OUTPUT = $printStk;
    include "xls/temp.xls.php";
    Stream("Report", $OUTPUT);
    return $printStk;
}
開發者ID:andrecoetzee,項目名稱:accounting-123.com,代碼行數:42,代碼來源:stock-avail.php


注:本文中的sprint3函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。