function handle_new_order() { if (isset($_SESSION['transfer_items'])) { $_SESSION['transfer_items']->clear_items(); unset($_SESSION['transfer_items']); } $_SESSION['transfer_items'] = new items_cart(ST_LOCTRANSFER); $_POST['AdjDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['AdjDate'])) { $_POST['AdjDate'] = end_fiscalyear(); } $_SESSION['transfer_items']->tran_date = $_POST['AdjDate']; }
function create_cart($type, $trans_no) { global $Refs; if (isset($_SESSION['pay_items'])) { unset($_SESSION['pay_items']); } $cart = new items_cart($type); $cart->order_id = $trans_no; if ($trans_no) { $bank_trans = db_fetch(get_bank_trans($type, $trans_no)); $_POST['bank_account'] = $bank_trans["bank_act"]; $_POST['PayType'] = $bank_trans["person_type_id"]; if ($bank_trans["person_type_id"] == PT_CUSTOMER) { $trans = get_customer_trans($trans_no, $type); $_POST['person_id'] = $trans["debtor_no"]; $_POST['PersonDetailID'] = $trans["branch_code"]; } elseif ($bank_trans["person_type_id"] == PT_SUPPLIER) { $trans = get_supp_trans($trans_no, $type); $_POST['person_id'] = $trans["supplier_id"]; } elseif ($bank_trans["person_type_id"] == PT_MISC) { $_POST['person_id'] = $bank_trans["person_id"]; } elseif ($bank_trans["person_type_id"] == PT_QUICKENTRY) { $_POST['person_id'] = $bank_trans["person_id"]; } else { $_POST['person_id'] = $bank_trans["person_id"]; } $cart->memo_ = get_comments_string($type, $trans_no); $cart->tran_date = sql2date($bank_trans['trans_date']); $cart->reference = $Refs->get($type, $trans_no); $cart->original_amount = $bank_trans['amount']; $result = get_gl_trans($type, $trans_no); if ($result) { while ($row = db_fetch($result)) { if (is_bank_account($row['account'])) { // date exchange rate is currenly not stored in bank transaction, // so we have to restore it from original gl amounts $ex_rate = $bank_trans['amount'] / $row['amount']; } else { $date = $row['tran_date']; $cart->add_gl_item($row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']); } } } // apply exchange rate foreach ($cart->gl_items as $line_no => $line) { $cart->gl_items[$line_no]->amount *= $ex_rate; } } else { $cart->reference = $Refs->get_next($cart->trans_type); $cart->tran_date = new_doc_date(); if (!is_date_in_fiscalyear($cart->tran_date)) { $cart->tran_date = end_fiscalyear(); } } $_POST['memo_'] = $cart->memo_; $_POST['ref'] = $cart->reference; $_POST['date_'] = $cart->tran_date; $_SESSION['pay_items'] =& $cart; }
label_cells(_("Sales Type"), $_SESSION['Items']->sales_type_name, "class='tableheader2'"); end_row(); start_row(); if (!isset($_POST['Location'])) { $_POST['Location'] = $_SESSION['Items']->Location; } label_cell(_("Delivery From"), "class='tableheader2'"); locations_list_cells(null, 'Location', null, false, true); if (!isset($_POST['ship_via'])) { $_POST['ship_via'] = $_SESSION['Items']->ship_via; } label_cell(_("Shipping Company"), "class='tableheader2'"); shippers_list_cells(null, 'ship_via', $_POST['ship_via']); // set this up here cuz it's used to calc qoh if (!isset($_POST['DispatchDate']) || !is_date($_POST['DispatchDate'])) { $_POST['DispatchDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['DispatchDate'])) { $_POST['DispatchDate'] = end_fiscalyear(); } } date_cells(_("Date"), 'DispatchDate', '', $_SESSION['Items']->trans_no == 0, 0, 0, 0, "class='tableheader2'"); end_row(); end_table(); echo "</td><td>"; // outer table start_table(TABLESTYLE, "width=90%"); if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) { $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->payment, $_POST['DispatchDate']); } text_cells(_("Delivery #"), 'custom_num', '', null, "class='tableheader2'"); //moodlearning
$Ajax->activate('BranchID'); } if (isset($_POST['_DateBanked_changed'])) { $Ajax->activate('_ex_rate'); } //---------------------------------------------------------------------------------------------- if (get_post('AddPaymentItem') && can_process()) { $cust_currency = get_customer_currency($_POST['customer_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); $comp_currency = get_company_currency(); if ($comp_currency != $bank_currency && $bank_currency != $cust_currency) { $rate = 0; } else { $rate = input_num('_ex_rate'); } new_doc_date($_POST['DateBanked']); //Chaitanya : 13-OCT-2011 - To support Edit feature $payment_no = write_customer_payment($_SESSION['alloc']->trans_no, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_'], $rate, input_num('charge')); $_SESSION['alloc']->trans_no = $payment_no; $_SESSION['alloc']->write(); unset($_POST); unset($_SESSION); //Chaitanya : 13-OCT-2011 - To support Edit feature //meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_no"); meta_forward($_SERVER['PHP_SELF'], !$_SESSION['alloc']->trans_no ? "AddedID={$payment_no}" : "UpdatedID={$payment_no}"); } //---------------------------------------------------------------------------------------------- function read_customer_data() { global $Refs; $myrow = get_customer_habit($_POST['customer_id']);
function create_cart($type, $trans_no) { global $Refs; if (!$_SESSION['SysPrefs']->db_ok) { // create_cart is called before page() where the check is done return; } processing_start(); if (isset($_GET['NewQuoteToSalesOrder'])) { $trans_no = $_GET['NewQuoteToSalesOrder']; $doc = new Cart(ST_SALESQUOTE, $trans_no, true); $doc->Comments = _("Sales Quotation") . " # " . $trans_no; $_SESSION['Items'] = $doc; } elseif ($type != ST_SALESORDER && $type != ST_SALESQUOTE && $trans_no != 0) { // this is template $doc = new Cart(ST_SALESORDER, array($trans_no)); $doc->trans_type = $type; $doc->trans_no = 0; $doc->document_date = new_doc_date(); if ($type == ST_SALESINVOICE) { $doc->due_date = get_invoice_duedate($doc->payment, $doc->document_date); $doc->pos = get_sales_point(user_pos()); } else { $doc->due_date = $doc->document_date; } $doc->reference = $Refs->get_next($doc->trans_type); //$doc->Comments=''; foreach ($doc->line_items as $line_no => $line) { $doc->line_items[$line_no]->qty_done = 0; } $_SESSION['Items'] = $doc; } else { $_SESSION['Items'] = new Cart($type, array($trans_no)); } copy_from_cart(); }
return false; } if (get_post('bank_date') == '') { // new reconciliation $Ajax->activate('bank_date'); } $_POST['bank_date'] = date2sql(get_post('reconcile_date')); $reconcile_value = check_value("rec_" . $reconcile_id) ? "'" . $_POST['bank_date'] . "'" : 'NULL'; update_reconciled_values($reconcile_id, $reconcile_value, $_POST['reconcile_date'], input_num('end_balance'), $_POST['bank_account']); $Ajax->activate('reconciled'); $Ajax->activate('difference'); return true; } if (!isset($_POST['reconcile_date'])) { // init page $_POST['reconcile_date'] = new_doc_date(); // $_POST['bank_date'] = date2sql(Today()); } if (list_updated('bank_account')) { $Ajax->activate('bank_date'); update_data(); } if (list_updated('bank_date')) { $_POST['reconcile_date'] = get_post('bank_date') == '' ? Today() : sql2date($_POST['bank_date']); update_data(); } if (get_post('_reconcile_date_changed')) { $_POST['bank_date'] = check_date() ? date2sql(get_post('reconcile_date')) : ''; $Ajax->activate('bank_date'); update_data(); }
function handle_add_deposit() { new_doc_date($_POST['DatePaid']); $trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'], input_num('amount'), $_POST['ref'], $_POST['memo_'], input_num('charge'), input_num('target_amount')); meta_forward($_SERVER['PHP_SELF'], "AddedID={$trans_no}"); }
function handle_commit_order() { $cart =& $_SESSION['PO']; if (can_commit()) { copy_to_cart(); if ($cart->trans_type != ST_PURCHORDER) { // for direct grn/invoice set same dates for lines as for whole document foreach ($cart->line_items as $line_no => $line) { $cart->line_items[$line_no]->req_del_date = $cart->orig_order_date; } } if ($cart->order_no == 0) { // new po/grn/invoice /*its a new order to be inserted */ $ref = $cart->reference; if ($cart->trans_type != ST_PURCHORDER) { $cart->reference = 'auto'; begin_transaction(); // all db changes as single transaction for direct document } $order_no = add_po($cart); new_doc_date($cart->orig_order_date); $cart->order_no = $order_no; if ($cart->trans_type == ST_PURCHORDER) { unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}"); } //Direct GRN if ($cart->trans_type == ST_SUPPRECEIVE) { $cart->reference = $ref; } if ($cart->trans_type != ST_SUPPINVOICE) { $cart->Comments = $cart->reference; } //grn does not hold supp_ref foreach ($cart->line_items as $key => $line) { $cart->line_items[$key]->receive_qty = $line->quantity; } $grn_no = add_grn($cart); if ($cart->trans_type == ST_SUPPRECEIVE) { commit_transaction(); // save PO+GRN unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedGRN={$grn_no}"); } // Direct Purchase Invoice $inv = new supp_trans(ST_SUPPINVOICE); $inv->Comments = $cart->Comments; $inv->supplier_id = $cart->supplier_id; $inv->tran_date = $cart->orig_order_date; $inv->due_date = $cart->due_date; $inv->reference = $ref; $inv->supp_reference = $cart->supp_ref; $inv->tax_included = $cart->tax_included; $supp = get_supplier($cart->supplier_id); $inv->tax_group_id = $supp['tax_group_id']; $inv->ov_amount = $inv->ov_gst = $inv->ov_discount = 0; $total = 0; foreach ($cart->line_items as $key => $line) { $inv->add_grn_to_trans($line->grn_item_id, $line->po_detail_rec, $line->stock_id, $line->item_description, $line->receive_qty, 0, $line->receive_qty, $line->price, $line->price, true, get_standard_cost($line->stock_id), ''); $inv->ov_amount += round2($line->receive_qty * $line->price, user_price_dec()); } $inv->tax_overrides = $cart->tax_overrides; if (!$inv->tax_included) { $taxes = $inv->get_taxes($inv->tax_group_id, 0, false); foreach ($taxes as $taxitem) { $total += isset($taxitem['Override']) ? $taxitem['Override'] : $taxitem['Value']; } } $inv->ex_rate = $cart->ex_rate; $inv_no = add_supp_invoice($inv); commit_transaction(); // save PO+GRN+PI // FIXME payment for cash terms. (Needs cash account selection) unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedPI={$inv_no}"); } else { // order modification $order_no = update_po($cart); unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}&Updated=1"); } } }
function handle_add_payment() { $payment_id = write_supp_payment(0, $_POST['supplier_id'], $_POST['bank_account'], $_POST['DatePaid'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_'], input_num('charge'), input_num('bank_amount', input_num('amount'))); new_doc_date($_POST['DatePaid']); $_SESSION['alloc']->trans_no = $payment_id; $_SESSION['alloc']->date_ = $_POST['DatePaid']; $_SESSION['alloc']->write(); 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 create_cart($type = 0, $trans_no = 0) { global $Refs; if (isset($_SESSION['journal_items'])) { unset($_SESSION['journal_items']); } $cart = new items_cart($type); $cart->order_id = $trans_no; if ($trans_no) { $result = get_gl_trans($type, $trans_no); if ($result) { while ($row = db_fetch($result)) { if ($row['amount'] == 0) { continue; } $date = $row['tran_date']; $cart->add_gl_item($row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']); } } $cart->memo_ = get_comments_string($type, $trans_no); $cart->tran_date = sql2date($date); $cart->reference = $Refs->get($type, $trans_no); $_POST['ref_original'] = $cart->reference; // Store for comparison when updating } else { $cart->reference = $Refs->get_next(0); $cart->tran_date = new_doc_date(); if (!is_date_in_fiscalyear($cart->tran_date)) { $cart->tran_date = end_fiscalyear(); } $_POST['ref_original'] = -1; } $_POST['memo_'] = $cart->memo_; $_POST['ref'] = $cart->reference; $_POST['date_'] = $cart->tran_date; $_SESSION['journal_items'] =& $cart; }
//------------------------------------------------------------------------------------- if (isset($_POST['ADD_ITEM']) && can_process()) { if (!isset($_POST['cr_acc'])) { $_POST['cr_acc'] = ""; } if (!isset($_POST['cr_lab_acc'])) { $_POST['cr_lab_acc'] = ""; } $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['type'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_'], input_num('Costs'), $_POST['cr_acc'], input_num('Labour'), $_POST['cr_lab_acc']); new_doc_date($_POST['date_']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$id}&type=" . $_POST['type'] . "&date=" . $_POST['date_']); } //------------------------------------------------------------------------------------- if (isset($_POST['UPDATE_ITEM']) && can_process()) { update_work_order($selected_id, $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_']); new_doc_date($_POST['date_']); meta_forward($_SERVER['PHP_SELF'], "UpdatedID={$selected_id}"); } //-------------------------------------------------------------------------------------- if (isset($_POST['delete'])) { //the link to delete a selected record was clicked instead of the submit button $cancel_delete = false; // can't delete it there are productions or issues if (work_order_has_productions($selected_id) || work_order_has_issues($selected_id) || work_order_has_payments($selected_id)) { display_error(_("This work order cannot be deleted because it has already been processed.")); $cancel_delete = true; } if ($cancel_delete == false) { //ie not cancelled the delete as a result of above tests // delete the actual work order delete_work_order($selected_id);
$_POST['cart_id'] = $cart->cart_id; $_POST['ref'] = $cart->reference; $_POST['custom_num'] = $cart->custom_num; //moodlearning $_POST['bulk_dis'] = $cart->bulk_discount; //moodlearning } //----------------------------------------------------------------------------- if (isset($_POST['ProcessCredit']) && can_process()) { $new_credit = $_SESSION['Items']->trans_no == 0; if (!isset($_POST['WriteOffGLCode'])) { $_POST['WriteOffGLCode'] = 0; } copy_to_cart(); if ($new_credit) { new_doc_date($_SESSION['Items']->document_date); } $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']); if ($credit_no == -1) { display_error(_("The entered reference is already in use.")); set_focus('ref'); } elseif ($credit_no) { processing_end(); if ($new_credit) { meta_forward($_SERVER['PHP_SELF'], "AddedID={$credit_no}"); } else { meta_forward($_SERVER['PHP_SELF'], "UpdatedID={$credit_no}"); } } } //-----------------------------------------------------------------------------
if ($dim > 0) { label_cell(_("Dimension") . ":", "class='tableheader2'"); $_POST['dimension_id'] = $_SESSION['Items']->dimension_id; dimensions_list_cells(null, 'dimension_id', null, true, ' ', false, 1, false); } else { hidden('dimension_id', 0); } end_row(); start_row(); if (!isset($_POST['ship_via'])) { $_POST['ship_via'] = $_SESSION['Items']->ship_via; } label_cell(_("Shipping Company"), "class='tableheader2'"); shippers_list_cells(null, 'ship_via', $_POST['ship_via']); if (!isset($_POST['InvoiceDate']) || !is_date($_POST['InvoiceDate'])) { $_POST['InvoiceDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['InvoiceDate'])) { $_POST['InvoiceDate'] = end_fiscalyear(); } } date_cells(_("Date"), 'InvoiceDate', '', $_SESSION['Items']->trans_no == 0, 0, 0, 0, "class='tableheader2'", true); if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) { $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->payment, $_POST['InvoiceDate']); } date_cells(_("Due Date"), 'due_date', '', null, 0, 0, 0, "class='tableheader2'"); /* if ($dim > 1) label_cells(_("Dimension"). " 2", get_dimension_string($_SESSION['Items']->dimension2_id), "class='tableheader2'"); else if ($dim > 0) label_cell(" ", "colspan=2"); */
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 process_receive_po() { global $path_to_root, $Ajax; if (!can_process()) { return; } if (check_po_changed()) { display_error(_("This order has been changed or invoiced since this delivery was started to be actioned. Processing halted. To enter a delivery against this purchase order, it must be re-selected and re-read again to update the changes made by the other user.")); hyperlink_no_params("{$path_to_root}/purchasing/inquiry/po_search.php", _("Select a different purchase order for receiving goods against")); hyperlink_params("{$path_to_root}/purchasing/po_receive_items.php", _("Re-Read the updated purchase order for receiving goods against"), "PONumber=" . $_SESSION['PO']->order_no); unset($_SESSION['PO']->line_items); unset($_SESSION['PO']); unset($_POST['ProcessGoodsReceived']); $Ajax->activate('_page_body'); display_footer_exit(); } $grn =& $_SESSION['PO']; $grn->orig_order_date = $_POST['DefaultReceivedDate']; $grn->reference = $_POST['ref']; $grn->Location = $_POST['Location']; $grn->ex_rate = input_num('_ex_rate', null); $grn_no = add_grn($grn); new_doc_date($_POST['DefaultReceivedDate']); unset($_SESSION['PO']->line_items); unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$grn_no}"); }
function create_cart($type = 0, $trans_no = 0) { global $Refs; if (isset($_SESSION['disbursement_items'])) { unset($_SESSION['disbursement_items']); } $cart = new items_cart($type); $cart->order_id = $trans_no; if ($trans_no) { $result = get_gl_trans($type, $trans_no); $_POST['PayType'] = $res["person_type_id"]; if ($res["person_type_id"] == PT_CUSTOMER) { $trans = get_customer_trans($trans_no, $type); $_POST['person_id'] = $trans["debtor_no"]; $_POST['PersonDetailID'] = $trans["branch_code"]; } elseif ($res["person_type_id"] == PT_SUPPLIER) { $trans = get_supp_trans($trans_no, $type); $_POST['person_id'] = $trans["supplier_id"]; } elseif ($res["person_type_id"] == PT_MISC) { $_POST['person_id'] = $res["person_id"]; } elseif ($res["person_type_id"] == PT_QUICKENTRY) { $_POST['person_id'] = $res["person_id"]; } else { $_POST['person_id'] = $res["person_id"]; } if ($result) { while ($row = db_fetch($result)) { if ($row['amount'] == 0) { continue; } $date = $row['tran_date']; $cart->add_gl_item($row['account'], $row['dimension_id'], $row['dimension2_id'], $row['amount'], $row['memo_']); } } $cart->memo_ = get_comments_string($type, $trans_no); $cart->tran_date = sql2date($date); if ($type == ST_DISBURSEMENT) { $voucher_type = 'Check Voucher'; $cart->reference = $Refs->get(ST_DISBURSEMENT, $trans_no); } if ($type == ST_SUPPAYMENT) { $cart->reference = $Refs->get_next(ST_DISBURSEMENT); } $_POST['ref_original'] = $cart->reference; // Store for comparison when updating } else { $cart->reference = $Refs->get_next(ST_DISBURSEMENT); $cart->tran_date = new_doc_date(); if (!is_date_in_fiscalyear($cart->tran_date)) { $cart->tran_date = end_fiscalyear(); } $_POST['ref_original'] = -1; } $_POST['memo_'] = $cart->memo_; $_POST['ref'] = $cart->reference; $_POST['date_'] = $cart->tran_date; $_POST['cv_no'] = $cart->custom_no; /**========MOODLEARNING=======*/ $_POST['address'] = $cart->address; $_POST['check_num'] = $cart->check_num; $_POST['PayType'] = $cart->person_id; $_POST['person_id'] = $cart->person_detail_id; $_POST['settled_amount'] = $cart->settled_amount; $_SESSION['disbursement_items'] =& $cart; }