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;
}
function check_data()
{
    $total_allocated = 0;
    for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++) {
        if (!check_num('amount' . $counter)) {
            display_error(tr("The entry for one or more amounts is invalid."));
            set_focus('amount' . $counter);
            return false;
        }
        if (!check_num('amount' . $counter, 0)) {
            display_error(tr("The entry for an amount to allocate was negative. A positive allocation amount is expected."));
            set_focus('amount' . $counter);
            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;
}
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;
}
function can_process()
{
    if (count($_SESSION['PO']->line_items) <= 0) {
        display_error(tr("There is nothing to process. Please enter valid quantities greater than zero."));
        return false;
    }
    if (!is_date($_POST['DefaultReceivedDate'])) {
        display_error(tr("The entered date is invalid."));
        set_focus('DefaultReceivedDate');
        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'], 25)) {
        display_error(tr("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    $something_received = 0;
    foreach ($_SESSION['PO']->line_items as $order_line) {
        if ($order_line->receive_qty > 0) {
            $something_received = 1;
            break;
        }
    }
    // Check whether trying to deliver more items than are recorded on the actual purchase order (+ overreceive allowance)
    $delivery_qty_too_large = 0;
    foreach ($_SESSION['PO']->line_items as $order_line) {
        if ($order_line->receive_qty + $order_line->qty_received > $order_line->quantity * (1 + sys_prefs::over_receive_allowance() / 100)) {
            $delivery_qty_too_large = 1;
            break;
        }
    }
    if ($something_received == 0) {
        /*Then dont bother proceeding cos nothing to do ! */
        display_error(tr("There is nothing to process. Please enter valid quantities greater than zero."));
        return false;
    } elseif ($delivery_qty_too_large == 1) {
        display_error(tr("Entered quantities cannot be greater than the quantity entered on the purchase order including the allowed over-receive percentage") . " (" . sys_prefs::over_receive_allowance() . "%)." . "<br>" . tr("Modify the ordered items on the purchase order if you wish to increase the quantities."));
        return false;
    }
    return true;
}
Exemple #5
0
echo "<br>";
start_table($table_style2, 7, 6);
echo "<tr valign=top><td>";
// outer table
start_table("class='tablestyle_noborder'");
if (isset($_POST['New'])) {
    hidden('New', 'Yes');
    $_POST['CustName'] = $_POST['address'] = $_POST['tax_id'] = '';
    $_POST['dimension_id'] = 0;
    $_POST['dimension2_id'] = 0;
    $_POST['sales_type'] = -1;
    $_POST['curr_code'] = get_company_currency();
    $_POST['credit_status'] = -1;
    $_POST['payment_terms'] = '';
    $_POST['discount'] = $_POST['pymt_discount'] = percent_format(0);
    $_POST['credit_limit'] = price_format(sys_prefs::default_credit_limit());
} else {
    $sql = "SELECT * FROM debtors_master WHERE debtor_no = '" . $_POST['customer_id'] . "'";
    $result = db_query($sql, "check failed");
    $myrow = db_fetch($result);
    $_POST['CustName'] = $myrow["name"];
    $_POST['address'] = $myrow["address"];
    $_POST['tax_id'] = $myrow["tax_id"];
    $_POST['email'] = $myrow["email"];
    $_POST['dimension_id'] = $myrow["dimension_id"];
    $_POST['dimension2_id'] = $myrow["dimension2_id"];
    $_POST['sales_type'] = $myrow["sales_type"];
    $_POST['curr_code'] = $myrow["curr_code"];
    $_POST['credit_status'] = $myrow["credit_status"];
    $_POST['payment_terms'] = $myrow["payment_terms"];
    $_POST['discount'] = percent_format($myrow["discount"] * 100);
function can_process()
{
    global $selected_id;
    if (!isset($selected_id)) {
        if (!references::is_valid($_POST['wo_ref'])) {
            display_error(tr("You must enter a reference."));
            set_focus('wo_ref');
            return false;
        }
        if (!is_new_reference($_POST['wo_ref'], systypes::work_order())) {
            display_error(tr("The entered reference is already in use."));
            set_focus('wo_ref');
            return false;
        }
    }
    if (!check_num('quantity', 0)) {
        display_error(tr("The quantity entered is invalid or less than zero."));
        set_focus('quantity');
        return false;
    }
    if (!is_date($_POST['date_'])) {
        display_error(tr("The date entered is in an invalid format."));
        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;
    }
    // only check bom and quantites if quick assembly
    if (!($_POST['type'] == wo_types::advanced())) {
        if (!has_bom($_POST['stock_id'])) {
            display_error(tr("The selected item to manufacture does not have a bom."));
            set_focus('stock_id');
            return false;
        }
        if ($_POST['Costs'] == "") {
            $_POST['Costs'] = price_format(0);
        }
        if (!check_num('Costs', 0)) {
            display_error(tr("The cost entered is invalid or less than zero."));
            set_focus('Costs');
            return false;
        }
        if (!sys_prefs::allow_negative_stock()) {
            if ($_POST['type'] == wo_types::assemble()) {
                // check bom if assembling
                $result = get_bom($_POST['stock_id']);
                while ($bom_item = db_fetch($result)) {
                    if (has_stock_holding($bom_item["ResourceType"])) {
                        $quantity = $bom_item["quantity"] * input_num('quantity');
                        $qoh = get_qoh_on_date($bom_item["component"], $bom_item["loc_code"], $_POST['date_']);
                        if (-$quantity + $qoh < 0) {
                            display_error(tr("The work order cannot be processed because there is an insufficient quantity for component:") . " " . $bom_item["component"] . " - " . $bom_item["description"] . ".  " . tr("Location:") . " " . $bom_item["location_name"]);
                            set_focus('quantity');
                            return false;
                        }
                    }
                }
            } elseif ($_POST['type'] == wo_types::unassemble()) {
                // if unassembling, check item to unassemble
                $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['StockLocation'], $_POST['date_']);
                if (-input_num('quantity') + $qoh < 0) {
                    display_error(tr("The selected item cannot be unassembled because there is insufficient stock."));
                    return false;
                }
            }
        }
    } else {
        if (!is_date($_POST['RequDate'])) {
            set_focus('RequDate');
            display_error(tr("The date entered is in an invalid format."));
            return false;
        }
        //elseif (!is_date_in_fiscalyear($_POST['RequDate']))
        //{
        //	display_error(tr("The entered date is not in fiscal year."));
        //	return false;
        //}
        if (isset($selected_id)) {
            $myrow = get_work_order($selected_id, true);
            if ($_POST['units_issued'] > input_num('quantity')) {
                set_focus('quantity');
                display_error(tr("The quantity cannot be changed to be less than the quantity already manufactured for this order."));
                return false;
            }
        }
    }
    return true;
}
Exemple #7
0
        exit;
    }
    $_POST['ref'] = $myrow["reference"];
    $_POST['closed'] = $myrow["closed"];
    $_POST['name'] = $myrow["name"];
    $_POST['type_'] = $myrow["type_"];
    $_POST['date_'] = sql2date($myrow["date_"]);
    $_POST['due_date'] = sql2date($myrow["due_date"]);
    $_POST['memo_'] = get_comments_string(systypes::dimension(), $selected_id);
    hidden('ref', $_POST['ref']);
    label_row(tr("Dimension Reference:"), $_POST['ref']);
    hidden('selected_id', $selected_id);
} else {
    ref_row(tr("Dimension Reference:"), 'ref', references::get_next(systypes::dimension()));
}
text_row_ex(tr("Name") . ":", 'name', 50, 75);
$dim = get_company_pref('use_dimension');
number_list_row(tr("Type"), 'type_', null, 1, $dim);
date_row(tr("Start Date") . ":", 'date_');
date_row(tr("Date Required By") . ":", 'due_date', null, sys_prefs::default_dimension_required_by());
textarea_row(tr("Memo:"), 'memo_', null, 40, 5);
end_table(1);
submit_add_or_update_center($selected_id == -1);
if ($selected_id != -1) {
    echo "<br>";
    submit_center_first('close', tr("Close This Dimension"));
    submit_center_last('delete', tr("Delete This Dimension"));
}
end_form();
//--------------------------------------------------------------------------------------------
end_page();
     $result = db_query($sql, "item code could not be retrieved");
     $row = db_fetch_row($result);
     if (!$row) {
         add_item_code($code, $id, $description, $cat, $qty, $foreign);
     } else {
         update_item_code($row[0], $code, $id, $description, $cat, $qty, $foreign);
     }
     $k++;
 }
 if ($type == 'ITEM') {
     $dim = 0;
     if ($qty != '') {
         $dim = get_dimension_by_name($qty);
         if ($dim == -1) {
             $date = Today();
             $due = add_days($date, sys_prefs::default_dimension_required_by());
             $ref = references::get_next(systypes::dimension());
             $dim = add_dimension($ref, $qty, 1, $date, $due, "Added due to Item Import");
             $dim_n++;
         }
     }
     $sql = "SELECT stock_id FROM " . TB_PREF . "stock_master WHERE stock_id='{$id}'";
     $result = db_query($sql, "item could not be retrieved");
     $row = db_fetch_row($result);
     if (!$row) {
         $sql = "INSERT INTO " . TB_PREF . "stock_master (stock_id, description, long_description, category_id,\n\t\t\t\t\t    tax_type_id, units, mb_flag, sales_account, inventory_account, cogs_account,\n\t\t\t\t\t    adjustment_account, assembly_account, dimension_id, dimension2_id)\n\t\t\t\t\t    VALUES ('{$id}', " . db_escape($description) . ", '',\n\t\t\t\t\t    '{$cat}', {$_POST['tax_type_id']}, '{$units}', '{$mb_flag}',\n\t\t\t\t\t    '{$_POST['sales_account']}', '{$_POST['inventory_account']}', '{$_POST['cogs_account']}',\n\t\t\t\t\t    '{$_POST['adjustment_account']}', '{$_POST['assembly_account']}', {$dim}, 0)";
         db_query($sql, "The item could not be added");
         if ($mb_flag == "M" || $mb_flag == "B") {
             $sql = "INSERT INTO " . TB_PREF . "loc_stock (loc_code, stock_id) VALUES ('{$_POST['location']}', '{$id}')";
             db_query($sql, "The item locstock could not be added");
         }
function check_qoh()
{
    if (!sys_prefs::allow_negative_stock()) {
        foreach ($_SESSION['Items']->line_items as $itm) {
            if ($itm->qty_dispatched && has_stock_holding($itm->mb_flag)) {
                $qoh = get_qoh_on_date($itm->stock_id, $_POST['Location'], $_POST['DispatchDate']);
                if ($itm->qty_dispatched > $qoh) {
                    display_error(tr("The delivery cannot be processed because there is an insufficient quantity for item:") . " " . $itm->stock_id . " - " . $itm->item_description);
                    return false;
                }
            }
        }
    }
    return true;
}