function display_controls() { global $table_style2; start_form(false, true); if (!isset($_POST['supplier_id'])) { $_POST['supplier_id'] = get_global_supplier(false); } if (!isset($_POST['DatePaid'])) { $_POST['DatePaid'] = Today(); if (!is_date_in_fiscalyear($_POST['DatePaid'])) { $_POST['DatePaid'] = end_fiscalyear(); } } start_table($table_style2, 5, 7); echo "<tr><td valign=top>"; // outer table echo "<table>"; bank_accounts_list_row(tr("From Bank Account:"), 'bank_account', null, true); amount_row(tr("Amount of Payment:"), 'amount'); amount_row(tr("Amount of Discount:"), 'discount'); date_row(tr("Date Paid") . ":", 'DatePaid'); echo "</table>"; echo "</td><td valign=top class='tableseparator'>"; // outer table echo "<table>"; supplier_list_row(tr("Payment To:"), 'supplier_id', null, false, true); set_global_supplier($_POST['supplier_id']); $supplier_currency = get_supplier_currency($_POST['supplier_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); if ($bank_currency != $supplier_currency) { exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid']); } bank_trans_types_list_row(tr("Payment Type:"), 'PaymentType', null); ref_row(tr("Reference:"), 'ref', references::get_next(22)); text_row(tr("Memo:"), 'memo_', null, 52, 50); echo "</table>"; echo "</td></tr>"; end_table(1); // outer table submit_center('ProcessSuppPayment', tr("Enter Payment")); if ($bank_currency != $supplier_currency) { display_note(tr("The amount and discount are in the bank account's currency."), 2, 0); } end_form(); }
$trans_no = $_POST["trans_no"]; } $supp_trans = new supp_trans(ST_SUPPCREDIT); read_supp_invoice($trans_no, ST_SUPPCREDIT, $supp_trans); display_heading("<font color=red>" . _("SUPPLIER CREDIT NOTE") . " # " . $trans_no . "</font>"); echo "<br>"; start_table(TABLESTYLE, "width=95%"); start_row(); label_cells(_("Supplier"), $supp_trans->supplier_name, "class='tableheader2'"); label_cells(_("Reference"), $supp_trans->reference, "class='tableheader2'"); label_cells(_("Supplier's Reference"), $supp_trans->supp_reference, "class='tableheader2'"); end_row(); start_row(); label_cells(_("Invoice Date"), $supp_trans->tran_date, "class='tableheader2'"); label_cells(_("Due Date"), $supp_trans->due_date, "class='tableheader2'"); label_cells(_("Currency"), get_supplier_currency($supp_trans->supplier_id), "class='tableheader2'"); end_row(); comments_display_row(ST_SUPPCREDIT, $trans_no); end_table(1); $total_gl = display_gl_items($supp_trans, 3); $total_grn = display_grn_items($supp_trans, 2); $display_sub_tot = number_format2($total_gl + $total_grn, user_price_dec()); start_table(TABLESTYLE, "width=95%"); label_row(_("Sub Total"), $display_sub_tot, "align=right", "nowrap align=right width=17%"); $tax_items = get_trans_tax_details(ST_SUPPCREDIT, $trans_no); display_supp_trans_tax_details($tax_items, 1); $display_total = number_format2(-($supp_trans->ov_amount + $supp_trans->ov_gst), user_price_dec()); label_row("<font color=red>" . _("TOTAL CREDIT NOTE") . "</font", "<font color=red>{$display_total}</font>", "colspan=1 align=right", "nowrap align=right"); end_table(1); $voided = is_voided_display(ST_SUPPCREDIT, $trans_no, _("This credit note has been voided.")); if (!$voided) {
function check_inputs() { global $Refs; if (!get_post('supplier_id')) { display_error(_("There is no supplier selected.")); set_focus('supplier_id'); return false; } if (@$_POST['amount'] == "") { $_POST['amount'] = price_format(0); } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('amount'); return false; } if (isset($_POST['charge']) && !check_num('charge', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('charge'); return false; } if (isset($_POST['charge']) && input_num('charge') > 0) { $charge_acct = get_company_pref('bank_charge_act'); if (get_gl_account($charge_acct) == false) { display_error(_("The Bank Charge Account has not been set in System and General GL Setup.")); set_focus('charge'); return false; } } if (@$_POST['discount'] == "") { $_POST['discount'] = 0; } if (!check_num('discount', 0)) { display_error(_("The entered discount is invalid or less than zero.")); set_focus('amount'); return false; } //if (input_num('amount') - input_num('discount') <= 0) if (input_num('amount') <= 0) { display_error(_("The total of the amount and the discount is zero or negative. Please enter positive values.")); set_focus('amount'); return false; } if (isset($_POST['bank_amount']) && input_num('bank_amount') <= 0) { display_error(_("The entered bank amount is zero or negative.")); set_focus('bank_amount'); return false; } if (!is_date($_POST['DatePaid'])) { display_error(_("The entered date is invalid.")); set_focus('DatePaid'); return false; } elseif (!is_date_in_fiscalyear($_POST['DatePaid'])) { display_error(_("The entered date is out of fiscal year or is closed for further data entry.")); set_focus('DatePaid'); return false; } $limit = get_bank_account_limit($_POST['bank_account'], $_POST['DatePaid']); if ($limit !== null && floatcmp($limit, input_num('amount')) < 0) { display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit))); set_focus('amount'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], ST_SUPPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!db_has_currency_rates(get_supplier_currency($_POST['supplier_id']), $_POST['DatePaid'], true)) { return false; } $_SESSION['alloc']->amount = -input_num('amount'); if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } }
$_POST['suppliers_uom'] = $myrow["suppliers_uom"]; $_POST['supplier_description'] = $myrow["supplier_description"]; $_POST['conversion_factor'] = maxprec_format($myrow["conversion_factor"]); } br(); hidden('selected_id', $selected_id); if (@$_GET['popup']) { hidden('_tabs_sel', get_post('_tabs_sel')); hidden('popup', @$_GET['popup']); } start_table(TABLESTYLE2); if ($Mode == 'Edit') { hidden('supplier_id'); label_row(_("Supplier:"), $supp_name); } else { supplier_list_row(_("Supplier:"), 'supplier_id', null, false, true); $_POST['price'] = $_POST['suppliers_uom'] = $_POST['conversion_factor'] = $_POST['supplier_description'] = ""; } amount_row(_("Price:"), 'price', null, '', get_supplier_currency($selected_id), $dec2); text_row(_("Suppliers Unit of Measure:"), 'suppliers_uom', null, 50, 51); if (!isset($_POST['conversion_factor']) || $_POST['conversion_factor'] == "") { $_POST['conversion_factor'] = maxprec_format(1); } amount_row(_("Conversion Factor (to our UOM):"), 'conversion_factor', maxprec_format($_POST['conversion_factor']), null, null, 'max'); text_row(_("Supplier's Code or Description:"), 'supplier_description', null, 50, 51); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); if (!@$_GET['popup']) { end_form(); end_page(@$_GET['popup'], false, false); }
function handle_add_payment() { $supp_currency = get_supplier_currency($_POST['supplier_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); $comp_currency = get_company_currency(); if ($comp_currency != $bank_currency && $bank_currency != $supp_currency) { $rate = 0; } else { $rate = input_num('_ex_rate'); } $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'], $_POST['bank_account'], input_num('amount'), input_num('discount'), $_POST['ref'], $_POST['memo_'], $rate, input_num('charge')); new_doc_date($_POST['DatePaid']); $_SESSION['alloc']->trans_no = $payment_id; $_SESSION['alloc']->write(); //unset($_POST['supplier_id']); unset($_POST['bank_account']); unset($_POST['DatePaid']); unset($_POST['currency']); unset($_POST['memo_']); unset($_POST['amount']); unset($_POST['discount']); unset($_POST['ProcessSuppPayment']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$payment_id}&supplier_id=" . $_POST['supplier_id']); }
function print_inventory_purchase() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $category = $_POST['PARAM_2']; $location = $_POST['PARAM_3']; $fromsupp = $_POST['PARAM_4']; $item = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } if ($location == '') { $loc = _('All'); } else { $loc = get_location_name($location); } if ($fromsupp == '') { $froms = _('All'); } else { $froms = get_supplier_name($fromsupp); } if ($item == '') { $itm = _('All'); } else { $itm = $item; } $cols = array(0, 60, 180, 225, 275, 400, 420, 465, 520); $headers = array(_('Category'), _('Description'), _('Date'), _('#'), _('Supplier'), _('Qty'), _('Unit Price'), _('Total')); if ($fromsupp != '') { $headers[4] = ''; } $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => _('Supplier'), 'from' => $froms, 'to' => ''), 5 => array('text' => _('Item'), 'from' => $itm, 'to' => '')); $rep = new FrontReport(_('Inventory Purchasing Report'), "InventoryPurchasingReport", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($category, $location, $fromsupp, $item, $from, $to); $total = $total_supp = $grandtotal = 0.0; $total_qty = 0.0; $catt = $stock_description = $stock_id = $supplier_name = ''; while ($trans = db_fetch($res)) { if ($stock_description != $trans['description']) { if ($stock_description != '') { if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $total_supp = $total_qty = 0.0; $supplier_name = $trans['supplier_name']; } } $stock_id = $trans['stock_id']; $stock_description = $trans['description']; } if ($supplier_name != $trans['supplier_name']) { if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $total_supp = $total_qty = 0.0; } $supplier_name = $trans['supplier_name']; } if ($catt != $trans['cat_description']) { if ($catt != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 7, $catt); $rep->AmountCol(7, 8, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(); $total = 0.0; } $rep->TextCol(0, 1, $trans['category_id']); $rep->TextCol(1, 6, $trans['cat_description']); $catt = $trans['cat_description']; $rep->NewLine(); } $curr = get_supplier_currency($trans['supplier_id']); $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['tran_date'])); $trans['price'] *= $rate; $rep->NewLine(); $trans['supp_reference'] = get_supp_inv_reference($trans['supplier_id'], $trans['stock_id'], $trans['tran_date']); $rep->fontSize -= 2; $rep->TextCol(0, 1, $trans['stock_id']); if ($fromsupp == ALL_TEXT) { $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1); $rep->TextCol(2, 3, sql2date($trans['tran_date'])); $rep->TextCol(3, 4, $trans['supp_reference']); $rep->TextCol(4, 5, $trans['supplier_name']); } else { $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1); $rep->TextCol(2, 3, sql2date($trans['tran_date'])); $rep->TextCol(3, 4, $trans['supp_reference']); } $rep->AmountCol(5, 6, $trans['qty'], get_qty_dec($trans['stock_id'])); $rep->AmountCol(6, 7, $trans['price'], $dec); $amt = $trans['qty'] * $trans['price']; $rep->AmountCol(7, 8, $amt, $dec); $rep->fontSize += 2; $total += $amt; $total_supp += $amt; $grandtotal += $amt; $total_qty += $trans['qty']; } if ($stock_description != '') { if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(); $total_supp = $total_qty = 0.0; $supplier_name = $trans['supplier_name']; } } if ($supplier_name != '') { $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 4, $stock_description); $rep->TextCol(4, 5, $supplier_name); $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id)); $rep->AmountCol(7, 8, $total_supp, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(); } $rep->NewLine(2, 3); $rep->TextCol(0, 1, _('Total')); $rep->TextCol(1, 7, $catt); $rep->AmountCol(7, 8, $total, $dec); $rep->Line($rep->row - 2); $rep->NewLine(); $rep->NewLine(2, 1); $rep->TextCol(0, 7, _('Grand Total')); $rep->AmountCol(7, 8, $grandtotal, $dec); $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_grn_valuation() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 75, 225, 260, 295, 330, 370, 410, 455, 515); $headers = array(_('Stock ID'), _('Description'), _('PO No'), _('GRN') . "#", _('Inv') . "#", _('Qty'), _('Inv Price'), _('PO Price'), _('Total')); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to)); $rep = new FrontReport(_('GRN Valuation Report'), "GRNValuationReport", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($from, $to); $total = $qtotal = $grandtotal = 0.0; $stock_id = ''; while ($trans = db_fetch($res)) { if ($stock_id != $trans['item_code']) { if ($stock_id != '') { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $qtotal, $qdec); $rep->AmountCol(8, 9, $total, $dec); $rep->NewLine(); $total = $qtotal = 0; } $stock_id = $trans['item_code']; } $curr = get_supplier_currency($trans['supplier_id']); $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['delivery_date'])); $trans['std_cost_unit'] *= $rate; $rep->NewLine(); $rep->TextCol(0, 1, $trans['item_code']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, $trans['order_no']); $qdec = get_qty_dec($trans['item_code']); $rep->TextCol(3, 4, $trans['batch_no']); if ($trans['quantity_inv']) { $suppinv = getSuppInvDetails($trans['grn_item_id']); while ($inv = db_fetch($suppinv)) { $inv['inv_price'] *= $rate; $rep->TextCol(4, 5, $inv['inv_no']); $rep->AmountCol(5, 6, $inv['inv_qty'], $qdec); $rep->AmountCol(6, 7, $inv['inv_price'], $dec); $rep->AmountCol(7, 8, $trans['std_cost_unit'], $dec); $amt = round2($inv['inv_qty'] * $inv['inv_price'], $dec); $rep->AmountCol(8, 9, $amt, $dec); $rep->NewLine(); $total += $amt; $qtotal += $inv['inv_qty']; $grandtotal += $amt; } } if ($trans['qty_recd'] - $trans['quantity_inv'] != 0) { $rep->TextCol(4, 5, "--"); $rep->AmountCol(5, 6, $trans['qty_recd'] - $trans['quantity_inv'], $qdec); $rep->AmountCol(7, 8, $trans['unit_price'], $dec); $amt = round2(($trans['qty_recd'] - $trans['quantity_inv']) * $trans['unit_price'], $dec); $rep->AmountCol(8, 9, $amt, $dec); $total += $amt; $qtotal += $trans['qty_recd'] - $trans['quantity_inv']; $grandtotal += $amt; } else { $rep->NewLine(-1); } } if ($stock_id != '') { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $qtotal, $qdec); $rep->AmountCol(8, 9, $total, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 7, _('Grand Total')); $rep->AmountCol(8, 9, $grandtotal, $dec); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
include_once $path_to_root . "/purchasing/includes/purchasing_db.inc"; include_once $path_to_root . "/includes/session.inc"; include_once $path_to_root . "/purchasing/includes/purchasing_ui.inc"; $js = ""; if ($use_popup_windows) { $js .= get_js_open_window(900, 500); } page(_($help_context = "View Supplier Invoice"), true, false, "", $js); if (isset($_GET["trans_no"])) { $trans_no = $_GET["trans_no"]; } elseif (isset($_POST["trans_no"])) { $trans_no = $_POST["trans_no"]; } $supp_trans = new supp_trans(ST_SUPPINVOICE); read_supp_invoice($trans_no, ST_SUPPINVOICE, $supp_trans); $supplier_curr_code = get_supplier_currency($supp_trans->supplier_id); display_heading(_("SUPPLIER INVOICE") . " # " . $trans_no); echo "<br>"; start_table(TABLESTYLE, "width=95%"); start_row(); label_cells(_("Supplier"), $supp_trans->supplier_name, "class='tableheader2'"); label_cells(_("Reference"), $supp_trans->reference, "class='tableheader2'"); label_cells(_("Supplier's Reference"), $supp_trans->supp_reference, "class='tableheader2'"); end_row(); start_row(); label_cells(_("Invoice Date"), $supp_trans->tran_date, "class='tableheader2'"); label_cells(_("Due Date"), $supp_trans->due_date, "class='tableheader2'"); if (!is_company_currency($supplier_curr_code)) { label_cells(_("Currency"), $supplier_curr_code, "class='tableheader2'"); } end_row();
$myrow = db_fetch($result); $supp_name = $myrow["supp_name"]; $_POST['price'] = price_format($myrow["price"]); $_POST['suppliers_uom'] = $myrow["suppliers_uom"]; $_POST['supplier_description'] = $myrow["supplier_description"]; $_POST['conversion_factor'] = exrate_format($myrow["conversion_factor"]); } echo "<br>"; start_table($table_style2); if (isset($_GET['Edit'])) { hidden('supplier_id', $supplier_id); label_row(tr("Supplier:"), $supp_name); } else { supplier_list_row(tr("Supplier:"), 'supplier_id', null, false, true); $supplier_id = $_POST['supplier_id']; } amount_row(tr("Price:"), 'price', null, '', get_supplier_currency($supplier_id)); text_row(tr("Suppliers Unit of Measure:"), 'suppliers_uom', null, 50, 51); if (!isset($_POST['conversion_factor']) || $_POST['conversion_factor'] == "") { $_POST['conversion_factor'] = exrate_format(1); } amount_row(tr("Conversion Factor (to our UOM):"), 'conversion_factor', exrate_format($_POST['conversion_factor']), null, null, user_exrate_dec()); text_row(tr("Supplier's Code or Description:"), 'supplier_description', null, 50, 51); end_table(1); if (isset($_GET['Edit'])) { submit_center('UpdateRecord', tr("Update Purchasing Data")); } else { submit_center('AddRecord', tr("Add Purchasing Data")); } end_form(); end_page();