Ejemplo n.º 1
0
function on_submit($selected_parent, $selected_component = null)
{
    if (!check_num('quantity', 0)) {
        display_error(tr("The quantity entered must be numeric and greater than zero."));
        set_focus('quantity');
        return;
    }
    if (isset($selected_parent) && isset($selected_component)) {
        $sql = "UPDATE bom SET workcentre_added='" . $_POST['workcentre_added'] . "',\n\t\t\tloc_code='" . $_POST['loc_code'] . "',\n\t\t\tquantity= " . input_num('quantity') . "\n\t\t\tWHERE parent='" . $selected_parent . "'\n\t\t\tAND id='" . $selected_component . "'";
        check_db_error("Could not update this bom component", $sql);
        db_query($sql, "could not update bom");
    } elseif (!isset($selected_component) && isset($selected_parent)) {
        /*Selected component is null cos no item selected on first time round 
        		so must be adding a record must be Submitting new entries in the new 
        		component form */
        //need to check not recursive bom component of itself!
        if (!check_for_recursive_bom($selected_parent, $_POST['component'])) {
            /*Now check to see that the component is not already on the bom */
            $sql = "SELECT component FROM bom\n\t\t\t\tWHERE parent='{$selected_parent}'\n\t\t\t\tAND component='" . $_POST['component'] . "'\n\t\t\t\tAND workcentre_added='" . $_POST['workcentre_added'] . "'\n\t\t\t\tAND loc_code='" . $_POST['loc_code'] . "'";
            $result = db_query($sql, "check failed");
            if (db_num_rows($result) == 0) {
                $sql = "INSERT INTO bom (parent, component, workcentre_added, loc_code, quantity)\n\t\t\t\t\tVALUES ('{$selected_parent}', '" . $_POST['component'] . "', '" . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', " . input_num('quantity') . ")";
                db_query($sql, "check failed");
                //$msg = tr("A new component part has been added to the bill of material for this item.");
            } else {
                /*The component must already be on the bom */
                display_error(tr("The selected component is already on this bom. You can modify it's quantity but it cannot appear more than once on the same bom."));
            }
        } else {
            display_error(tr("The selected component is a parent of the current item. Recursive BOMs are not allowed."));
        }
    }
}
Ejemplo n.º 2
0
function can_process()
{
    if (!check_num('po_over_receive', 0, 100)) {
        display_error(_("The delivery over-receive allowance must be between 0 and 100."));
        set_focus('po_over_receive');
        return false;
    }
    if (!check_num('po_over_charge', 0, 100)) {
        display_error(_("The invoice over-charge allowance must be between 0 and 100."));
        set_focus('po_over_charge');
        return false;
    }
    if (!check_num('past_due_days', 0, 100)) {
        display_error(_("The past due days interval allowance must be between 0 and 100."));
        set_focus('past_due_days');
        return false;
    }
    $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;
}
Ejemplo n.º 3
0
function check_data()
{
    $total_allocated = 0;
    for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++) {
        if (!check_num('amount' . $counter, 0)) {
            display_error(tr("The entry for one or more amounts is invalid or negative."));
            set_focus('amount');
            return false;
        }
        /*Now check to see that the AllocAmt is no greater than the
        	 amount left to be allocated against the transaction under review */
        if (input_num('amount' . $counter) > $_POST['un_allocated' . $counter]) {
            //$_POST['amount' . $counter] = $_POST['un_allocated' . $counter];
        }
        $_SESSION['alloc']->allocs[$counter]->current_allocated = input_num('amount' . $counter);
        $total_allocated += input_num('amount' . $counter);
    }
    if ($total_allocated + $_SESSION['alloc']->amount > sys_prefs::allocation_settled_allowance()) {
        display_error(tr("These allocations cannot be processed because the amount allocated is more than the total amount left to allocate."));
        //echo  tr("Total allocated:") . " " . $total_allocated ;
        //echo "  " . tr("Total amount that can be allocated:") . " " . -$_SESSION['alloc']->TransAmt . "<BR>";
        return false;
    }
    return true;
}
Ejemplo n.º 4
0
function check_valid_entries()
{
    if (!is_date($_POST['DatePaid'])) {
        display_error(tr("The entered date is invalid."));
        set_focus('DatePaid');
        return false;
    }
    if (!is_date_in_fiscalyear($_POST['DatePaid'])) {
        display_error(tr("The entered date is not in fiscal year."));
        set_focus('DatePaid');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(tr("The entered amount is invalid or less than zero."));
        set_focus('amount');
        return false;
    }
    if (!references::is_valid($_POST['ref'])) {
        display_error(tr("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!is_new_reference($_POST['ref'], systypes::bank_transfer())) {
        display_error(tr("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if ($_POST['FromBankAccount'] == $_POST['ToBankAccount']) {
        display_error(tr("The source and destination bank accouts cannot be the same."));
        set_focus('ToBankAccount');
        return false;
    }
    return true;
}
Ejemplo n.º 5
0
function can_process()
{
    if (strlen($_POST['CustName']) == 0) {
        display_error(_("The customer name cannot be empty."));
        set_focus('CustName');
        return false;
    }
    if (strlen($_POST['cust_ref']) == 0) {
        display_error(_("The customer short name cannot be empty."));
        set_focus('cust_ref');
        return false;
    }
    if (!check_num('credit_limit', 0)) {
        display_error(_("The credit limit must be numeric and not less than zero."));
        set_focus('credit_limit');
        return false;
    }
    if (!check_num('pymt_discount', 0, 100)) {
        display_error(_("The payment discount must be numeric and is expected to be less than 100% and greater than or equal to 0."));
        set_focus('pymt_discount');
        return false;
    }
    if (!check_num('discount', 0, 100)) {
        display_error(_("The discount percentage must be numeric and is expected to be less than 100% and greater than or equal to 0."));
        set_focus('discount');
        return false;
    }
    return true;
}
Ejemplo n.º 6
0
function check_data()
{
    global $check_price_charged_vs_order_price, $check_qty_charged_vs_del_qty;
    if (!check_num('this_quantity_inv', 0) || input_num('this_quantity_inv') == 0) {
        display_error(tr("The quantity to invoice must be numeric and greater than zero."));
        set_focus('this_quantity_inv');
        return false;
    }
    if (!check_num('ChgPrice')) {
        display_error(tr("The price is not numeric."));
        set_focus('ChgPrice');
        return false;
    }
    if ($check_price_charged_vs_order_price == True) {
        if ($_POST['order_price'] != input_num('ChgPrice')) {
            if ($_POST['order_price'] == 0 || input_num('ChgPrice') / $_POST['order_price'] > 1 + sys_prefs::over_charge_allowance() / 100) {
                display_error(tr("The price being invoiced is more than the purchase order price by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . tr("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
                set_focus('ChgPrice');
                return false;
            }
        }
    }
    if ($check_qty_charged_vs_del_qty == True) {
        if (input_num('this_quantity_inv') / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) > 1 + sys_prefs::over_charge_allowance() / 100) {
            display_error(tr("The quantity being invoiced is more than the outstanding quantity by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . tr("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
            set_focus('this_quantity_inv');
            return false;
        }
    }
    return true;
}
Ejemplo n.º 7
0
function on_submit($selected_parent, $selected_component = -1)
{
    if (!check_num('quantity', 0)) {
        display_error(_("The quantity entered must be numeric and greater than zero."));
        set_focus('quantity');
        return;
    }
    if ($selected_component != -1) {
        update_bom($selected_parent, $selected_component, $_POST['workcentre_added'], $_POST['loc_code'], input_num('quantity'));
        display_notification(_('Selected component has been updated'));
        $Mode = 'RESET';
    } else {
        /*Selected component is null cos no item selected on first time round
        		so must be adding a record must be Submitting new entries in the new
        		component form */
        //need to check not recursive bom component of itself!
        if (!check_for_recursive_bom($selected_parent, $_POST['component'])) {
            /*Now check to see that the component is not already on the bom */
            if (!is_component_already_on_bom($_POST['component'], $_POST['workcentre_added'], $_POST['loc_code'], $selected_parent)) {
                add_bom($selected_parent, $_POST['component'], $_POST['workcentre_added'], $_POST['loc_code'], input_num('quantity'));
                display_notification(_("A new component part has been added to the bill of material for this item."));
                $Mode = 'RESET';
            } else {
                /*The component must already be on the bom */
                display_error(_("The selected component is already on this bom. You can modify it's quantity but it cannot appear more than once on the same bom."));
            }
        } else {
            display_error(_("The selected component is a parent of the current item. Recursive BOMs are not allowed."));
        }
    }
}
Ejemplo n.º 8
0
function update_component($kit_code, $selected_item)
{
    global $Mode, $Ajax, $selected_kit;
    if (!check_num('quantity', 0)) {
        display_error(_("The quantity entered must be numeric and greater than zero."));
        set_focus('quantity');
        return;
    } elseif ($_POST['description'] == '') {
        display_error(_("Item code description cannot be empty."));
        set_focus('description');
        return;
    } elseif ($selected_item == -1) {
        if (get_post('item_code') == '') {
            // New kit/alias definition
            $kit = get_item_kit($_POST['kit_code']);
            if (db_num_rows($kit)) {
                $input_error = 1;
                display_error(_("This item code is already assigned to stock item or sale kit."));
                set_focus('kit_code');
                return;
            }
            if (get_post('kit_code') == '') {
                display_error(_("Kit/alias code cannot be empty."));
                set_focus('kit_code');
                return;
            }
        }
    }
    if (check_item_in_kit($selected_item, $kit_code, $_POST['component'], true)) {
        display_error(_("The selected component contains directly or on any lower level the kit under edition. Recursive kits are not allowed."));
        set_focus('component');
        return;
    }
    /*Now check to see that the component is not already in the kit */
    if (check_item_in_kit($selected_item, $kit_code, $_POST['component'])) {
        display_error(_("The selected component is already in this kit. You can modify it's quantity but it cannot appear more than once in the same kit."));
        set_focus('component');
        return;
    }
    if ($selected_item == -1) {
        // new item alias/kit
        if ($_POST['item_code'] == '') {
            $kit_code = $_POST['kit_code'];
            $selected_kit = $_POST['item_code'] = $kit_code;
            $msg = _("New alias code has been created.");
        } else {
            $msg = _("New component has been added to selected kit.");
        }
        add_item_code($kit_code, get_post('component'), get_post('description'), get_post('category'), input_num('quantity'), 0);
        display_notification($msg);
    } else {
        $props = get_kit_props($_POST['item_code']);
        update_item_code($selected_item, $kit_code, get_post('component'), $props['description'], $props['category_id'], input_num('quantity'), 0);
        display_notification(_("Component of selected kit has been updated."));
    }
    $Mode = 'RESET';
    $Ajax->activate('_page_body');
}
Ejemplo n.º 9
0
function can_process()
{
    if (strlen($_POST['name']) == 0) {
        display_error(tr("The tax type name cannot be empty."));
        set_focus('name');
        return false;
    } elseif (!check_num('rate', 0)) {
        display_error(tr("The default tax rate must be numeric and not less than zero."));
        set_focus('rate');
        return false;
    }
    return true;
}
Ejemplo n.º 10
0
function can_process()
{
    if (strlen($_POST['sales_type']) == 0) {
        display_error(_("The sales type description cannot be empty."));
        set_focus('sales_type');
        return false;
    }
    if (!check_num('factor', 0)) {
        display_error(_("Calculation factor must be valid positive number."));
        set_focus('factor');
        return false;
    }
    return true;
}
Ejemplo n.º 11
0
function check_data()
{
    if (!check_num('This_QuantityCredited', 0)) {
        display_error(tr("The quantity to credit must be numeric and greater than zero."));
        set_focus('This_QuantityCredited');
        return false;
    }
    if (!check_num('ChgPrice', 0)) {
        display_error(tr("The price is either not numeric or negative."));
        set_focus('ChgPrice');
        return false;
    }
    return true;
}
Ejemplo n.º 12
0
function can_process()
{
    global $wo_details;
    if (!references::is_valid($_POST['ref'])) {
        display_error(tr("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!is_new_reference($_POST['ref'], 29)) {
        display_error(tr("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('quantity', 0)) {
        display_error(tr("The quantity entered is not a valid number or less then zero."));
        set_focus('quantity');
        return false;
    }
    if (!is_date($_POST['date_'])) {
        display_error(tr("The entered date is invalid."));
        set_focus('date_');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['date_'])) {
        display_error(tr("The entered date is not in fiscal year."));
        set_focus('date_');
        return false;
    }
    if (date_diff(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) {
        display_error(tr("The production date cannot be before the release date of the work order."));
        set_focus('date_');
        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;
}
Ejemplo n.º 13
0
function can_process()
{
    if (!check_num('po_over_receive', 0, 100)) {
        display_error(tr("The delivery over-receive allowance must be between 0 and 100."));
        set_focus('po_over_receive');
        return false;
    }
    if (!check_num('po_over_charge', 0, 100)) {
        display_error(tr("The invoice over-charge allowance must be between 0 and 100."));
        set_focus('po_over_charge');
        return false;
    }
    if (!check_num('past_due_days', 0, 100)) {
        display_error(tr("The past due days interval allowance must be between 0 and 100."));
        set_focus('past_due_days');
        return false;
    }
    return true;
}
Ejemplo n.º 14
0
function check_data()
{
    if (!is_date($_POST['date_'])) {
        display_error(tr("The entered date is invalid."));
        set_focus('date_');
        return false;
    }
    if (!check_num('BuyRate', 0)) {
        display_error(tr("The exchange rate must be numeric and greater than zero."));
        set_focus('BuyRate');
        return false;
    }
    if ($_POST['BuyRate'] <= 0) {
        display_error(tr("The exchange rate cannot be zero or a negative number."));
        set_focus('BuyRate');
        return false;
    }
    return true;
}
Ejemplo n.º 15
0
function can_process()
{
    global $selected_id;
    if (strlen($_POST['name']) == 0) {
        display_error(_("The tax type name cannot be empty."));
        set_focus('name');
        return false;
    } elseif (!check_num('rate', 0)) {
        display_error(_("The default tax rate must be numeric and not less than zero."));
        set_focus('rate');
        return false;
    }
    if (!is_tax_gl_unique(get_post('sales_gl_code'), get_post('purchasing_gl_code'), $selected_id)) {
        display_error(_("Selected GL Accounts cannot be used by another tax type."));
        set_focus('sales_gl_code');
        return false;
    }
    return true;
}
Ejemplo n.º 16
0
function can_process()
{
    if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) {
        display_error(tr("The entered date is invalid. Please enter a valid date for the payment."));
        set_focus('DateBanked');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) {
        display_error(tr("The entered date is not in fiscal year."));
        set_focus('DateBanked');
        return false;
    }
    if (!references::is_valid($_POST['ref'])) {
        display_error(tr("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!is_new_reference($_POST['ref'], 12)) {
        display_error(tr("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(tr("The entered amount is invalid or negative and cannot be processed."));
        set_focus('amount');
        return false;
    }
    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;
}
Ejemplo n.º 17
0
function check_num($data, $check)
{
    $explode_or = explode("|", $data);
    if (count($explode_or) > 1) {
        foreach ($explode_or as $val) {
            if (check_num($val, $check)) {
                return true;
            }
        }
    }
    $explode_mod = explode(",", $data);
    if (count($explode_mod) >= 2) {
        foreach ($explode_mod as $val) {
            if (check_num($val, $check)) {
                return true;
            }
        }
    }
    $explode_mod = explode("&", $data);
    if (count($explode_mod) >= 2) {
        foreach ($explode_mod as $val) {
            if (!check_num($val, $check)) {
                return false;
            }
        }
    }
    $explode_between = explode("-", $data);
    if (count($explode_between) >= 2) {
        $min = $explode_between[0];
        $max = $explode_between[1];
        return $check >= $min && $check <= $max;
    }
    $explode_mod = explode("%", $data);
    if (count($explode_mod) >= 2) {
        return $explode_mod[0] % $explode_mod[1] == 0;
    }
    return $data == $check;
}
Ejemplo n.º 18
0
function can_process()
{
    global $wo_details;
    if (!check_num('costs', 0)) {
        display_error(_("The amount entered is not a valid number or less then zero."));
        set_focus('costs');
        return false;
    }
    if (!is_date($_POST['date_'])) {
        display_error(_("The entered date is invalid."));
        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;
}
function can_process()
{
    if ($_POST['mail_type'] == 'MAIL') {
        return true;
    }
    $errors = 0;
    if (empty($_POST['smtp_host']) && $_POST['mail_type'] == 'SMTP') {
        $errors++;
        display_error(_("The SMTP host must be entered."));
    }
    if (!check_num('smtp_port', 1) && $_POST['mail_type'] == 'SMTP') {
        $errors++;
        display_error(_("The SMTP port must be a positive number."));
    }
    if (empty($_POST['smtp_username']) && $_POST['mail_type'] == 'SMTP') {
        $errors++;
        display_error(_("The SMTP username must be entered."));
    }
    if (empty($_POST['smtp_password']) && $_POST['mail_type'] == 'SMTP') {
        $errors++;
        display_error(_("The SMTP password must be entered."));
    }
    return $errors == 0;
}
Ejemplo n.º 20
0
function check_data()
{
    if (!check_num('qty', 0)) {
        display_error(tr("The quantity of the order item must be numeric and not less than zero."));
        set_focus('qty');
        return false;
    }
    if (!check_num('price', 0)) {
        display_error(tr("The price entered must be numeric and not less than zero."));
        set_focus('price');
        return false;
    }
    if (!is_date($_POST['req_del_date'])) {
        display_error(tr("The date entered is in an invalid format."));
        set_focus('req_del_date');
        return false;
    }
    return true;
}
Ejemplo n.º 21
0
function check_item_data()
{
    if (!check_num('amount', 0)) {
        display_error(_("The amount entered is not a valid number or is less than zero."));
        set_focus('amount');
        return false;
    }
    if (isset($_POST['_ex_rate']) && input_num('_ex_rate') <= 0) {
        display_error(_("The exchange rate cannot be zero or a negative number."));
        set_focus('_ex_rate');
        return false;
    }
    return true;
}
Ejemplo n.º 22
0
}
//------------------------------------------------------------------------------------------------
if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) {
    //initialise no input errors assumed initially before we test
    $input_error = 0;
    if (strlen($_POST['salesman_name']) == 0) {
        $input_error = 1;
        display_error(tr("The sales person name cannot be empty."));
    }
    $pr1 = check_num('provision', 0, 100);
    if (!$pr1 || !check_num('provision2', 0, 100)) {
        $input_error = 1;
        display_error(tr("Salesman provision cannot be less than 0 or more than 100%."));
        set_focus(!$pr1 ? 'provision' : 'provision2');
    }
    if (!check_num('break_pt', 0)) {
        $input_error = 1;
        display_error(tr("Salesman provision breakpoint must be numeric and not less than 0."));
        set_focus('break_pt');
    }
    if ($input_error != 1) {
        if (isset($selected_id)) {
            /*selected_id could also exist if submit had not been clicked this code would not run in this case cos submit is false of course  see the delete code below*/
            $sql = "UPDATE salesman SET salesman_name=" . db_escape($_POST['salesman_name']) . ",\n    \t\t\tsalesman_phone=" . db_escape($_POST['salesman_phone']) . ",\n    \t\t\tsalesman_fax=" . db_escape($_POST['salesman_fax']) . ",\n    \t\t\tsalesman_email=" . db_escape($_POST['salesman_email']) . ",\n    \t\t\tprovision=" . input_num('provision') . ",\n    \t\t\tbreak_pt=" . input_num('break_pt') . ",\n    \t\t\tprovision2=" . input_num('provision2') . "\n    \t\t\tWHERE salesman_code = '{$selected_id}'";
        } else {
            /*Selected group is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new Sales-person form */
            $sql = "INSERT INTO salesman (salesman_name, salesman_phone, salesman_fax, salesman_email,\n    \t\t\tprovision, break_pt, provision2)\n    \t\t\tVALUES (" . db_escape($_POST['salesman_name']) . ", " . db_escape($_POST['salesman_phone']) . ", " . db_escape($_POST['salesman_fax']) . ", " . db_escape($_POST['salesman_email']) . ", " . input_num('provision') . ", " . input_num('break_pt') . ", " . input_num('provision2') . ")";
        }
        //run the sql from either of the above possibilites
        db_query($sql, "The insert or update of the salesperson failed");
        meta_forward($_SERVER['PHP_SELF']);
Ejemplo n.º 23
0
function check_quantities()
{
    $ok = 1;
    // Update cart delivery quantities/descriptions
    foreach ($_SESSION['Items']->line_items as $line => $itm) {
        if (isset($_POST['Line' . $line])) {
            if ($_SESSION['Items']->trans_no) {
                $min = $itm->qty_done;
                $max = $itm->quantity;
            } else {
                $min = 0;
                $max = $itm->quantity - $itm->qty_done;
            }
            if (check_num('Line' . $line, $min, $max)) {
                $_SESSION['Items']->line_items[$line]->qty_dispatched = input_num('Line' . $line);
            } else {
                set_focus('Line' . $line);
                $ok = 0;
            }
        }
        if (isset($_POST['Line' . $line . 'Desc'])) {
            $line_desc = $_POST['Line' . $line . 'Desc'];
            if (strlen($line_desc) > 0) {
                $_SESSION['Items']->line_items[$line]->item_description = $line_desc;
            }
        }
    }
    // ...
    //	else
    //	  $_SESSION['Items']->freight_cost = input_num('ChargeFreightCost');
    return $ok;
}
Ejemplo n.º 24
0
function can_process()
{
    global $Refs;
    if (!get_post('customer_id')) {
        display_error(_("There is no customer selected."));
        set_focus('customer_id');
        return false;
    }
    if (!get_post('BranchID')) {
        display_error(_("This customer has no branch defined."));
        set_focus('BranchID');
        return false;
    }
    if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) {
        display_error(_("The entered date is invalid. Please enter a valid date for the payment."));
        set_focus('DateBanked');
        return false;
    } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('DateBanked');
        return false;
    }
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    //Chaitanya : 13-OCT-2011 - To support Edit feature
    if (isset($_POST['trans_no']) && $_POST['trans_no'] == 0 && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    } elseif ($_POST['ref'] != $_POST['old_ref'] && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(_("The entered amount is invalid or negative and cannot be processed."));
        set_focus('amount');
        return false;
    }
    if (isset($_POST['charge']) && !check_num('charge', 0)) {
        display_error(_("The entered amount is invalid or negative and cannot be processed."));
        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 (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 1.0E-6)) {
        display_error(_("The exchange rate must be numeric and greater than zero."));
        set_focus('_ex_rate');
        return false;
    }
    if ($_POST['discount'] == "") {
        $_POST['discount'] = 0;
    }
    if (!check_num('discount')) {
        display_error(_("The entered discount is not a valid number."));
        set_focus('discount');
        return false;
    }
    //if ((input_num('amount') - input_num('discount') <= 0)) {
    if (input_num('amount') <= 0) {
        display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts."));
        set_focus('discount');
        return false;
    }
    if (!db_has_currency_rates(get_customer_currency($_POST['customer_id']), $_POST['DateBanked'], true)) {
        return false;
    }
    $_SESSION['alloc']->amount = input_num('amount');
    if (isset($_POST["TotalNumberOfAllocs"])) {
        return check_allocations();
    } else {
        return true;
    }
}
Ejemplo n.º 25
0
function check_item_data()
{
    if (!check_num('qty', 0)) {
        display_error(_("The quantity entered must be a positive number."));
        set_focus('qty');
        return false;
    }
    return true;
}
Ejemplo n.º 26
0
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;
    }
}
Ejemplo n.º 27
0
function check_item_data()
{
    global $SysPrefs, $allow_negative_prices;
    $is_inventory_item = is_inventory_item(get_post('stock_id'));
    if (!get_post('stock_id_text', true)) {
        display_error(_("Item description cannot be empty."));
        set_focus('stock_id_edit');
        return false;
    } elseif (!check_num('qty', 0) || !check_num('Disc', 0, 100)) {
        display_error(_("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100."));
        set_focus('qty');
        return false;
    } elseif (!check_num('price', 0) && (!$allow_negative_prices || $is_inventory_item)) {
        display_error(_("Price for inventory item must be entered and can not be less than 0"));
        set_focus('price');
        return false;
    } elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']]) && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) {
        set_focus('qty');
        display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively."));
        return false;
    }
    $cost_home = get_standard_cost(get_post('stock_id'));
    // Added 2011-03-27 Joe Hunt
    $cost = $cost_home / get_exchange_rate_from_home_currency($_SESSION['Items']->customer_currency, $_SESSION['Items']->document_date);
    if (input_num('price') < $cost) {
        $dec = user_price_dec();
        $curr = $_SESSION['Items']->customer_currency;
        $price = number_format2(input_num('price'), $dec);
        if ($cost_home == $cost) {
            $std_cost = number_format2($cost_home, $dec);
        } else {
            $price = $curr . " " . $price;
            $std_cost = $curr . " " . number_format2($cost, $dec);
        }
        display_warning(sprintf(_("Price %s is below Standard Cost %s"), $price, $std_cost));
    }
    return true;
}
Ejemplo n.º 28
0
function check_valid_entries()
{
    global $Refs;
    if (!is_date($_POST['DatePaid'])) {
        display_error(_("The entered date is invalid."));
        set_focus('DatePaid');
        return false;
    }
    if (!is_date_in_fiscalyear($_POST['DatePaid'])) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('DatePaid');
        return false;
    }
    if (!check_num('amount', 0)) {
        display_error(_("The entered amount is invalid or less than zero."));
        set_focus('amount');
        return false;
    }
    if (input_num('amount') == 0) {
        display_error(_("The total bank amount cannot be 0."));
        set_focus('amount');
        return false;
    }
    $limit = get_bank_account_limit($_POST['FromBankAccount'], $_POST['DatePaid']);
    $amnt_tr = input_num('charge') + input_num('amount');
    if ($limit !== null && floatcmp($limit, $amnt_tr) < 0) {
        display_error(sprintf(_("The total bank amount exceeds allowed limit (%s) for source account."), price_format($limit)));
        set_focus('amount');
        return false;
    }
    if ($trans = check_bank_account_history(-$amnt_tr, $_POST['FromBankAccount'], $_POST['DatePaid'])) {
        display_error(sprintf(_("The bank transaction would result in exceed of authorized overdraft limit for transaction: %s #%s on %s."), $systypes_array[$trans['type']], $trans['trans_no'], sql2date($trans['trans_date'])));
        set_focus('amount');
        $input_error = 1;
    }
    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 && get_company_pref('bank_charge_act') == '') {
        display_error(_("The Bank Charge Account has not been set in System and General GL Setup."));
        set_focus('charge');
        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_BANKTRANSFER)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if ($_POST['FromBankAccount'] == $_POST['ToBankAccount']) {
        display_error(_("The source and destination bank accouts cannot be the same."));
        set_focus('ToBankAccount');
        return false;
    }
    if (isset($_POST['target_amount']) && !check_num('target_amount', 0)) {
        display_error(_("The entered amount is invalid or less than zero."));
        set_focus('target_amount');
        return false;
    }
    if (isset($_POST['target_amount']) && input_num('target_amount') == 0) {
        display_error(_("The incomming bank amount cannot be 0."));
        set_focus('target_amount');
        return false;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['FromBankAccount']), $_POST['DatePaid'])) {
        return false;
    }
    if (!db_has_currency_rates(get_bank_account_currency($_POST['ToBankAccount']), $_POST['DatePaid'])) {
        return false;
    }
    return true;
}
Ejemplo n.º 29
0
    unset($_SESSION['PO']);
    meta_forward($_SERVER['PHP_SELF'], "AddedID={$grn}");
}
//--------------------------------------------------------------------------------------------------
if (isset($_GET['PONumber']) && $_GET['PONumber'] > 0 && !isset($_POST['Update'])) {
    create_new_po();
    /*read in all the selected order into the Items cart  */
    read_po($_GET['PONumber'], $_SESSION['PO']);
}
//--------------------------------------------------------------------------------------------------
if (isset($_POST['Update']) || isset($_POST['ProcessGoodsReceived'])) {
    /* if update quantities button is hit page has been called and ${$line->line_no} would have be
     	set from the post to the quantity to be received in this receival*/
    foreach ($_SESSION['PO']->line_items as $line) {
        $_POST[$line->line_no] = max($_POST[$line->line_no], 0);
        if (!check_num($line->line_no)) {
            $_POST[$line->line_no] = qty_format(0);
        }
        if (!isset($_POST['DefaultReceivedDate']) || $_POST['DefaultReceivedDate'] == "") {
            $_POST['DefaultReceivedDate'] = Today();
        }
        $_SESSION['PO']->line_items[$line->line_no]->receive_qty = input_num($line->line_no);
        if (isset($_POST[$line->stock_id . "Desc"]) && strlen($_POST[$line->stock_id . "Desc"]) > 0) {
            $_SESSION['PO']->line_items[$line->line_no]->item_description = $_POST[$line->stock_id . "Desc"];
        }
    }
}
//--------------------------------------------------------------------------------------------------
if (isset($_POST['ProcessGoodsReceived'])) {
    process_receive_po();
}
Ejemplo n.º 30
0
function edit_allocations_for_transaction($type, $trans_no)
{
    global $table_style;
    start_form(false, true);
    display_heading(sprintf(tr("Allocation of %s # %d"), systypes::name($_SESSION['alloc']->type), $_SESSION['alloc']->trans_no));
    display_heading($_SESSION['alloc']->person_name);
    display_heading2(tr("Date:") . " <b>" . $_SESSION['alloc']->date_ . "</b>");
    display_heading2(tr("Total:") . " <b>" . price_format($_SESSION['alloc']->amount) . "</b>");
    echo "<br>";
    if (count($_SESSION['alloc']->allocs) > 0) {
        start_table($table_style);
        $th = array(tr("Transaction Type"), tr("#"), tr("Date"), tr("Due Date"), tr("Amount"), tr("Other Allocations"), tr("This Allocation"), tr("Left to Allocate"), "", "");
        table_header($th);
        $k = $counter = $total_allocated = 0;
        foreach ($_SESSION['alloc']->allocs as $allocn_item) {
            alt_table_row_color($k);
            label_cell(systypes::name($allocn_item->type));
            label_cell(get_trans_view_str($allocn_item->type, $allocn_item->type_no));
            label_cell($allocn_item->date_, "align=right");
            label_cell($allocn_item->due_date, "align=right");
            amount_cell($allocn_item->amount);
            amount_cell($allocn_item->amount_allocated);
            if (!check_num('amount' . $counter)) {
                $_POST['amount' . $counter] = price_format($allocn_item->current_allocated);
            }
            amount_cells(null, 'amount' . $counter, $_POST['amount' . $counter]);
            $un_allocated = round($allocn_item->amount - $allocn_item->amount_allocated, 6);
            hidden("un_allocated" . $counter, $un_allocated);
            amount_cell($un_allocated);
            label_cell("<a href='#' name=Alloc{$counter} onclick='allocate_all(this.name.substr(5));return true;'>" . tr("All") . "</a>");
            label_cell("<a href='#' name=DeAll{$counter} onclick='allocate_none(this.name.substr(5));return true;'>" . tr("None") . "</a>");
            end_row();
            $total_allocated += input_num('amount' . $counter);
            $counter++;
        }
        label_row(tr("Total Allocated"), price_format($total_allocated), "colspan=6 align=right", "nowrap align=right id='total_allocated'");
        if ($_SESSION['alloc']->amount - $total_allocated < 0) {
            $font1 = "<font color=red>";
            $font2 = "</font>";
        } else {
            $font1 = $font2 = "";
        }
        $left_to_allocate = $_SESSION['alloc']->amount - $total_allocated;
        $left_to_allocate = price_format($left_to_allocate);
        label_row(tr("Left to Allocate"), $font1 . $left_to_allocate . $font2, "colspan=6 align=right ", "nowrap align=right id='left_to_allocate'");
        end_table(1);
        hidden('TotalNumberOfAllocs', $counter);
        //		hidden('left_to_allocate', $left_to_allocate);
        submit_center_first('UpdateDisplay', tr("Update"));
        submit('Process', tr("Process"));
    } else {
        display_note(tr("There are no unsettled transactions to allocate."), 0, 1);
    }
    submit_center_last('Cancel', tr("Back to Allocations"));
    end_form();
}