function handle_submit(&$selected_id) { global $path_to_root, $Ajax, $auto_create_branch; if (!can_process()) { return; } if ($selected_id) { update_customer($_POST['customer_id'], $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']); update_record_status($_POST['customer_id'], $_POST['inactive'], 'debtors_master', 'debtor_no'); $Ajax->activate('customer_id'); // in case of status change display_notification(_("Customer has been updated.")); } else { //it is a new customer begin_transaction(); add_customer($_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']); $selected_id = $_POST['customer_id'] = db_insert_id(); if (isset($auto_create_branch) && $auto_create_branch == 1) { add_branch($selected_id, $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $_POST['location'], $_POST['address'], 0, 0, $_POST['ship_via'], $_POST['notes']); $selected_branch = db_insert_id(); add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', ''); add_crm_contact('cust_branch', 'general', $selected_branch, db_insert_id()); } commit_transaction(); display_notification(_("A new customer has been added.")); if (isset($auto_create_branch) && $auto_create_branch == 1) { display_notification(_("A default Branch has been automatically created, please check default Branch values by using link below.")); } $Ajax->activate('_page_body'); } }
function handle_report() { global $Ajax; if (can_process()) { $from = $_POST['TransFromDate']; $to = $_POST['TransToDate']; $typeId = $_POST['typeId']; $accountId = $_POST['accountId']; display_notification(_('Report successfully generated.')); $arr = array($from, $to, $typeId, $accountId); $trans_type = ST_SUBSIDIARY; display_note(print_document_link($arr, _("&Print Report"), true, $trans_type)); } else { display_notification(_('Report not generated, please contact the administrator.')); } $Ajax->activate('_page_body'); return; }
function handle_submit() { global $path_to_root; if (!can_process()) { return; } if (!isset($_POST['New'])) { $sql = "UPDATE debtors_master SET name=" . db_escape($_POST['CustName']) . ", \n\t\t\taddress=" . db_escape($_POST['address']) . ", \n\t\t\ttax_id=" . db_escape($_POST['tax_id']) . ", \n\t\t\tcurr_code=" . db_escape($_POST['curr_code']) . ", \n\t\t\temail=" . db_escape($_POST['email']) . ", \n\t\t\tdimension_id=" . db_escape($_POST['dimension_id']) . ", \n\t\t\tdimension2_id=" . db_escape($_POST['dimension2_id']) . ", \n credit_status=" . db_escape($_POST['credit_status']) . ", \n payment_terms=" . db_escape($_POST['payment_terms']) . ", \n discount=" . input_num('discount') / 100 . ", \n pymt_discount=" . input_num('pymt_discount') / 100 . ", \n credit_limit=" . input_num('credit_limit') . ", \n sales_type = " . db_escape($_POST['sales_type']) . " \n WHERE debtor_no = '" . $_POST['customer_id'] . "'"; db_query($sql, "The customer could not be updated"); display_notification(tr("Customer has been updated.")); clear_fields(); } else { //it is a new customer begin_transaction(); $sql = "INSERT INTO debtors_master (name, address, tax_id, email, dimension_id, dimension2_id, \n\t\t\tcurr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit, \n\t\t\tsales_type) VALUES (" . db_escape($_POST['CustName']) . ", " . db_escape($_POST['address']) . ", " . db_escape($_POST['tax_id']) . "," . db_escape($_POST['email']) . ", " . db_escape($_POST['dimension_id']) . ", " . db_escape($_POST['dimension2_id']) . ", " . db_escape($_POST['curr_code']) . ", \n\t\t\t" . db_escape($_POST['credit_status']) . ", " . db_escape($_POST['payment_terms']) . ", " . input_num('discount') / 100 . ", \n\t\t\t" . input_num('pymt_discount') / 100 . ", " . input_num('credit_limit') . ", " . db_escape($_POST['sales_type']) . ")"; db_query($sql, "The customer could not be added"); $new_customer_id = db_insert_id(); commit_transaction(); display_notification(tr("A new customer has been added.")); hyperlink_params($path_to_root . "/sales/manage/customer_branches.php", tr("Add branches for this customer"), "debtor_no={$new_customer_id}"); clear_fields(); } }
} if (!db_has_currency_rates($_SESSION['Items']->customer_currency, $_POST['OrderDate'])) { return false; } if ($_SESSION['Items']->get_items_total() < 0) { display_error("Invoice total amount cannot be less than zero."); return false; } return true; } //----------------------------------------------------------------------------- if (isset($_POST['update'])) { copy_to_cart(); $Ajax->activate('items_table'); } if (isset($_POST['ProcessOrder']) && can_process()) { $modified = $_SESSION['Items']->trans_no != 0; $so_type = $_SESSION['Items']->so_type; $ret = $_SESSION['Items']->write(1); if ($ret == -1) { display_error(_("The entered reference is already in use.")); $ref = get_next_reference($_SESSION['Items']->trans_type); if ($ref != $_SESSION['Items']->reference) { display_error(_("The reference number field has been increased. Please save the document again.")); $_POST['ref'] = $_SESSION['Items']->reference = $ref; $Ajax->activate('ref'); } set_focus('ref'); } else { if (count($messages)) { // abort on failure or error messages are lost
{ if (strlen($_POST['reason_description']) == 0) { display_error(_("The credit status description cannot be empty.")); set_focus('reason_description'); return false; } return true; } //----------------------------------------------------------------------------------- if ($Mode == 'ADD_ITEM' && can_process()) { add_credit_status($_POST['reason_description'], $_POST['DisallowInvoices']); display_notification(_('New credit status has been added')); $Mode = 'RESET'; } //----------------------------------------------------------------------------------- if ($Mode == 'UPDATE_ITEM' && can_process()) { display_notification(_('Selected credit status has been updated')); update_credit_status($selected_id, $_POST['reason_description'], $_POST['DisallowInvoices']); $Mode = 'RESET'; } //----------------------------------------------------------------------------------- function can_delete($selected_id) { if (key_in_foreign_table($selected_id, 'debtors_master', 'credit_status')) { display_error(_("Cannot delete this credit status because customer accounts have been created referring to it.")); return false; } return true; } //----------------------------------------------------------------------------------- if ($Mode == 'Delete') {
function process_receive_po() { global $path_to_root; if (!can_process()) { return; } if (check_po_changed()) { echo "<br> " . tr("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.") . "<BR>"; echo "<center><a href='{$path_to_root}/purchasing/inquiry/po_search.php?" . SID . "'>" . tr("Select a different purchase order for receiving goods against") . "</a></center>"; echo "<center><a href='{$path_to_root}/po_receive_items.php?" . SID . "PONumber=" . $_SESSION['PO']->OrderNumber . "'>" . tr("Re-Read the updated purchase order for receiving goods against") . "</a></center>"; unset($_SESSION['PO']->line_items); unset($_SESSION['PO']); unset($_POST['ProcessGoodsReceived']); exit; } $grn = add_grn($_SESSION['PO'], $_POST['DefaultReceivedDate'], $_POST['ref'], $_POST['Location']); unset($_SESSION['PO']->line_items); unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$grn}"); }
} $grn_act = get_company_pref('grn_clearing_act'); if (get_post('grn_clearing_act') != $grn_act && db_num_rows(get_grn_items(0, '', true))) { display_error(_("Before GRN Clearing Account can be changed all GRNs have to be invoiced")); $_POST['grn_clearing_act'] = $grn_act; set_focus('grn_clearing_account'); return false; } if (!is_account_balancesheet(get_post('retained_earnings_act')) || is_account_balancesheet(get_post('profit_loss_year_act'))) { display_error(_("The Retained Earnings Account should be a Balance Account or the Profit and Loss Year Account should be an Expense Account (preferred the last one in the Expense Class)")); return false; } return true; } //------------------------------------------------------------------------------------------------- if (isset($_POST['submit']) && can_process()) { update_company_prefs(get_post(array('retained_earnings_act', 'profit_loss_year_act', 'debtors_act', 'pyt_discount_act', 'creditors_act', 'freight_act', 'exchange_diff_act', 'bank_charge_act', 'default_sales_act', 'default_sales_discount_act', 'default_prompt_payment_act', 'default_inventory_act', 'default_cogs_act', 'default_adj_act', 'default_inv_sales_act', 'default_assembly_act', 'legal_text', 'past_due_days', 'default_workorder_required', 'default_dim_required', 'default_delivery_required', 'grn_clearing_act', 'allow_negative_stock' => 0, 'accumulate_shipping' => 0, 'po_over_receive' => 0.0, 'po_over_charge' => 0.0, 'default_credit_limit' => 0.0))); display_notification(_("The general GL setup has been updated.")); } /* end of if submit */ //------------------------------------------------------------------------------------------------- start_form(); start_outer_table(TABLESTYLE2); table_section(1); if (get_company_pref('grn_clearing_act') === null) { // available from 2.3.1, can be not defined on pre-2.4 installations set_company_pref('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, 0); refresh_sys_prefs(); } $myrow = get_company_prefs(); $_POST['retained_earnings_act'] = $myrow["retained_earnings_act"];
copy_to_cart($customer_id, $branchNo, $sales_type_name, $reference, $date, $payment_id, $dimension_id, $dimension2_id, $freightcost = 0, $delfrom, $deldate, $delto, $deladdress, $contactphone, $email, $custref, $shipvia, $comments, $exrate = null); $firstlinecopied = true; } if ($prev_ref == $reference) { $docline = $docline + 1; $com = get_customer_details_to_order($_SESSION['Items'], $customer_id, $branchNo); display_notification_centered($com); if ($com != "") { display_notification_centered("Error"); $error = true; } copy_to_cart($customer_id, $branchNo, $sales_type_name, $reference, $date, $payment_id, $dimension_id, $dimension2_id, $freightcost = 0, $delfrom, $deldate, $delto, $deladdress, $contactphone, $email, $custref, $shipvia, $comments, $exrate = null); } import_add_to_order($_SESSION['Items'], $item_code, $quantity, $price, $discountpercentage, $item_description); $_SESSION['Items']->cust_ref = $reference; if (!check_import_item_data($line_no = $docline, $item_code, $item_description, $quantity, $unit, $price, $discountpercentage) || !can_process($line, $customer_id, $branchNo, $reference, $date, $dimension_id, $dimension2_id, $freightcost = 0, $delfrom, $deldate, $delto, $deladdress, $contactphone, $email, $custref, $shipvia, $comments, $exrate)) { display_notification_centered("Error"); $error = true; } } if ($prev_ref != $reference && $type < 4) { init_entry_part_2($entry, $date, $reference); } if ($type == 0) { list($error, $input_id, $total_debit_positive, $total_credit_negative) = journal_id($prev_date, $date, $amt, $input_id = 0, $total_debit_positive, $total_credit_negative, $line); } if ($type == ST_BANKDEPOSIT || $type == ST_BANKPAYMENT || $type == ST_JOURNAL) { list($error, $memo) = check_customer_supplier($code_id, $person_id, $person_type_id, $line, $memo, $error); if (check_code_id($code_id)) { } else { display_notification_centered("Error: Account code {$code_id} does not exist");
$type = get_account_type(trim($_POST['id'])); if ($type && $type['id'] != $selected_id) { display_error(_("This account group id is already in use.")); set_focus('id'); return false; } //if (strcmp($_POST['id'], $_POST['parent']) == 0) if ($_POST['id'] === $_POST['parent']) { display_error(_("You cannot set an account group to be a subgroup of itself.")); return false; } return true; } //----------------------------------------------------------------------------------- if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') { if (can_process($selected_id)) { if ($selected_id != "") { if (update_account_type($_POST['id'], $_POST['name'], $_POST['class_id'], $_POST['parent'], $_POST['old_id'])) { display_notification(_('Selected account type has been updated')); } } else { if (add_account_type($_POST['id'], $_POST['name'], $_POST['class_id'], $_POST['parent'])) { display_notification(_('New account type has been added')); } } $Mode = 'RESET'; } } //----------------------------------------------------------------------------------- function can_delete($type) {
if (strlen($_POST['password']) < 4) { display_error(_("The password entered must be at least 4 characters long.")); set_focus('password'); return false; } if (strstr($_POST['password'], $_POST['user_id']) != false) { display_error(_("The password cannot contain the user login.")); set_focus('password'); return false; } } return true; } //------------------------------------------------------------------------------------------------- if (($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') && check_csrf_token()) { if (can_process()) { if ($selected_id != -1) { update_user_prefs($selected_id, get_post(array('user_id', 'real_name', 'phone', 'email', 'role_id', 'language', 'print_profile', 'rep_popup' => 0, 'pos'))); if ($_POST['password'] != "") { update_user_password($selected_id, $_POST['user_id'], md5($_POST['password'])); } display_notification_centered(_("The selected user has been updated.")); } else { add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']), $_POST['phone'], $_POST['email'], $_POST['role_id'], $_POST['language'], $_POST['print_profile'], check_value('rep_popup'), $_POST['pos']); $id = db_insert_id(); // use current user display preferences as start point for new user $prefs = $_SESSION['wa_current_user']->prefs->get_all(); update_user_prefs($id, array_merge($prefs, get_post(array('print_profile', 'rep_popup' => 0, 'language')))); display_notification_centered(_("A new user has been added.")); } $Mode = 'RESET';
if (!check_num('discount')) { display_error(tr("The entered discount is not a valid number.")); set_focus('discount'); return false; } if (input_num('amount') - input_num('discount') <= 0) { display_error(tr("The balance of the amount and discout is zero or negative. Please enter valid amounts.")); set_focus('discount'); return false; } return true; } //---------------------------------------------------------------------------------------------- // validate inputs if (isset($_POST['AddPaymentItem'])) { if (!can_process()) { unset($_POST['AddPaymentItem']); } } //---------------------------------------------------------------------------------------------- if (isset($_POST['AddPaymentItem'])) { $payment_no = write_customer_payment(0, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ReceiptType'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$payment_no}"); } //---------------------------------------------------------------------------------------------- function read_customer_data() { $sql = "SELECT debtors_master.pymt_discount,\n\t\tcredit_status.dissallow_invoices\n\t\tFROM debtors_master, credit_status\n\t\tWHERE debtors_master.credit_status = credit_status.id\n\t\t\tAND debtors_master.debtor_no = '" . $_POST['customer_id'] . "'"; $result = db_query($sql, "could not query customers"); $myrow = db_fetch($result); $_POST['HoldAccount'] = $myrow["dissallow_invoices"];
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}"); }
set_focus('stock_id'); return false; } return true; } //------------------------------------------------------------------------------------ if (isset($_POST['release'])) { release_work_order($selected_id, $_POST['released_date'], $_POST['memo_']); display_note(tr("The work order has been released to manufacturing.")); hyperlink_no_params("search_work_orders.php", tr("Select another work order")); end_page(); exit; } //------------------------------------------------------------------------------------ start_form(); $myrow = get_work_order($selected_id); $_POST['released'] = $myrow["released"]; $_POST['memo_'] = ""; if (can_process($myrow)) { start_table($table_style2); label_row(tr("Work Order #:"), $selected_id); label_row(tr("Work Order Reference:"), $myrow["wo_ref"]); date_row(tr("Released Date") . ":", 'released_date'); textarea_row(tr("Memo:"), 'memo_', $_POST['memo_'], 40, 5); end_table(1); submit_center('release', tr("Release Work Order")); hidden('selected_id', $selected_id); hidden('stock_id', $myrow['stock_id']); } end_form(); end_page();
set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('date_'); return false; } if (date_diff2(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) { display_error(_("The additional cost date cannot be before the release date of the work order.")); set_focus('date_'); return false; } return true; } //-------------------------------------------------------------------------------------------------- if (isset($_POST['process']) && can_process() == true) { $date = $_POST['date_']; begin_transaction(); add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['cr_acc'], 0, 0, $date . ": " . $wo_cost_types[$_POST['PaymentType']], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType']); $is_bank_to = is_bank_account($_POST['cr_acc']); if ($is_bank_to) { add_bank_trans(ST_WORKORDER, $_POST['selected_id'], $is_bank_to, "", $_POST['date_'], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType'], get_company_currency(), "Cannot insert a destination bank transaction"); } add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['db_acc'], $_POST['dim1'], $_POST['dim2'], $date . ": " . $wo_cost_types[$_POST['PaymentType']], input_num('costs'), PT_WORKORDER, $_POST['PaymentType']); //Chaitanya : Apply the costs to manfuctured stock item as adjustement $wo = get_work_order($_POST['selected_id']); if ($_POST['PaymentType'] == 0) { add_labour_cost($wo['stock_id'], 0, $_POST['date_'], input_num('costs'), true); } else { add_overhead_cost($wo['stock_id'], 0, $_POST['date_'], input_num('costs'), true); }
if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } } //---------------------------------------------------------------------------------------------- if (isset($_POST['_customer_id_button'])) { // unset($_POST['branch_id']); $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);
$input_error = 1; } } if (!is_date($_POST['OrderDate'])) { display_error(tr("The entered date for the credit note is invalid.")); set_focus('OrderDate'); $input_error = 1; } elseif (!is_date_in_fiscalyear($_POST['OrderDate'])) { display_error(tr("The entered date is not in fiscal year.")); set_focus('OrderDate'); $input_error = 1; } return $input_error == 0; } //----------------------------------------------------------------------------- if (isset($_POST['ProcessCredit']) && can_process()) { if ($_POST['CreditType'] == "WriteOff" && (!isset($_POST['WriteOffGLCode']) || $_POST['WriteOffGLCode'] == '')) { display_note(tr("For credit notes created to write off the stock, a general ledger account is required to be selected."), 1, 0); display_note(tr("Please select an account to write the cost of the stock off to, then click on Process again."), 1, 0); exit; } if (!isset($_POST['WriteOffGLCode'])) { $_POST['WriteOffGLCode'] = 0; } $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']); processing_end(); meta_forward($_SERVER['PHP_SELF'], "AddedID={$credit_no}"); } /*end of process credit note */ //----------------------------------------------------------------------------- function check_item_data()
return true; } //------------------------------------------------------------------------------------- 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
return false; } // if unassembling we need to check the qoh if ($_POST['ProductionType'] == 0 && !sys_prefs::allow_negative_stock()) { $wo_details = get_work_order($_POST['selected_id']); $qoh = get_qoh_on_date($wo_details["stock_id"], $wo_details["loc_code"], $date_); if (-$_POST['quantity'] + $qoh < 0) { display_error(tr("The unassembling cannot be processed because there is insufficient stock.")); set_focus('quantity'); return false; } } return true; } //-------------------------------------------------------------------------------------------------- if (isset($_POST['Process']) || isset($_POST['ProcessAndClose']) && can_process() == true) { $close_wo = 0; if (isset($_POST['ProcessAndClose']) && $_POST['ProcessAndClose'] != "") { $close_wo = 1; } // if unassembling, negate quantity if ($_POST['ProductionType'] == 0) { $_POST['quantity'] = -$_POST['quantity']; } $id = work_order_produce($_POST['selected_id'], $_POST['ref'], $_POST['quantity'], $_POST['date_'], $_POST['memo_'], $close_wo); meta_forward($_SERVER['PHP_SELF'], "AddedID={$id}"); } //------------------------------------------------------------------------------------- display_wo_details($_POST['selected_id']); //------------------------------------------------------------------------------------- start_form();
if (strlen($_POST['password']) < 4) { display_error(_("The password entered must be at least 4 characters long.")); set_focus('password'); return false; } if (strstr($_POST['password'], $_POST['user_id']) != false) { display_error(_("The password cannot contain the user login.")); set_focus('password'); return false; } } return true; } //------------------------------------------------------------------------------------------------- if (($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') && check_csrf_token()) { if (can_process($Mode == 'ADD_ITEM')) { if ($selected_id != -1) { update_user_prefs($selected_id, get_post(array('user_id', 'real_name', 'phone', 'email', 'role_id', 'language', 'print_profile', 'rep_popup' => 0, 'pos'))); if ($_POST['password'] != "") { update_user_password($selected_id, $_POST['user_id'], md5($_POST['password'])); } display_notification_centered(_("The selected user has been updated.")); } else { add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']), $_POST['phone'], $_POST['email'], $_POST['role_id'], $_POST['language'], $_POST['print_profile'], check_value('rep_popup'), $_POST['pos']); $id = db_insert_id(); // use current user display preferences as start point for new user $prefs = $_SESSION['wa_current_user']->prefs->get_all(); update_user_prefs($id, array_merge($prefs, get_post(array('print_profile', 'rep_popup' => 0, 'language')))); display_notification_centered(_("A new user has been added.")); } $Mode = 'RESET';