Пример #1
0
 if (isset($_POST['_Location_update']) || isset($_POST['clear_quantity']) || isset($_POST['reset_quantity'])) {
     // reset quantity
     $ln_itm->qty_dispatched = $ln_itm->quantity - $ln_itm->qty_done;
 }
 // if it's a non-stock item (eg. service) don't show qoh
 $row_classes = null;
 if (has_stock_holding($ln_itm->mb_flag) && $ln_itm->qty_dispatched) {
     // It's a stock : call get_dispatchable_quantity hook  to get which quantity to preset in the
     // quantity input box. This allows for example a hook to modify the default quantity to what's dispatchable
     // (if there is not enough in hand), check at other location or other order people etc ...
     // This hook also returns a 'reason' (css classes) which can be used to theme the row.
     //
     // FIXME: hook_get_dispatchable definition does not allow qoh checks on transaction level
     // (but anyway dispatch is checked again later before transaction is saved)
     $qty = $ln_itm->qty_dispatched;
     if ($check = check_negative_stock($ln_itm->stock_id, -$ln_itm->qty_dispatched, $_POST['Location'], $_POST['DispatchDate'])) {
         $qty = $check['qty'];
     }
     $q_class = hook_get_dispatchable_quantity($ln_itm, $_POST['Location'], $_POST['DispatchDate'], $qty);
     // Skip line if needed
     if ($q_class === 'skip') {
         continue;
     }
     if (is_array($q_class)) {
         list($ln_itm->qty_dispatched, $row_classes) = $q_class;
         $has_marked = true;
     }
 }
 alt_table_row_color($k, $row_classes);
 view_stock_status_cell($ln_itm->stock_id);
 if ($ln_itm->descr_editable) {
function check_data()
{
    global $total_grn_value, $total_gl_value, $Refs, $SysPrefs;
    if (!$_SESSION['supp_trans']->is_valid_trans_to_post()) {
        display_error(_("The credit note cannot be processed because the there are no items or values on the invoice.  Credit notes are expected to have a charge."));
        set_focus('');
        return false;
    }
    if (!$Refs->is_valid($_SESSION['supp_trans']->reference)) {
        display_error(_("You must enter an credit note reference."));
        set_focus('reference');
        return false;
    }
    if (!is_new_reference($_SESSION['supp_trans']->reference, ST_SUPPCREDIT)) {
        display_error(_("The entered reference is already in use."));
        set_focus('reference');
        return false;
    }
    if (!$Refs->is_valid($_SESSION['supp_trans']->supp_reference)) {
        display_error(_("You must enter a supplier's credit note reference."));
        set_focus('supp_reference');
        return false;
    }
    if (!is_date($_SESSION['supp_trans']->tran_date)) {
        display_error(_("The credit note as entered cannot be processed because the date entered is not valid."));
        set_focus('tran_date');
        return false;
    } elseif (!is_date_in_fiscalyear($_SESSION['supp_trans']->tran_date)) {
        display_error(_("The entered date is not in fiscal year."));
        set_focus('tran_date');
        return false;
    }
    if (!is_date($_SESSION['supp_trans']->due_date)) {
        display_error(_("The invoice as entered cannot be processed because the due date is in an incorrect format."));
        set_focus('due_date');
        return false;
    }
    if ($_SESSION['supp_trans']->ov_amount < $total_gl_value + $total_grn_value) {
        display_error(_("The credit note total as entered is less than the sum of the the general ledger entires (if any) and the charges for goods received. There must be a mistake somewhere, the credit note as entered will not be processed."));
        return false;
    }
    if (!$SysPrefs->allow_negative_stock()) {
        foreach ($_SESSION['supp_trans']->grn_items as $n => $item) {
            if (is_inventory_item($item->item_code)) {
                if (check_negative_stock($item->item_code, -$item->this_quantity_inv, null, $_SESSION['supp_trans']->tran_date)) {
                    $stock = get_item($item->item_code);
                    display_error(_("The return cannot be processed because there is an insufficient quantity for item:") . " " . $stock['stock_id'] . " - " . $stock['description'] . " - " . _("Quantity On Hand") . " = " . number_format2($qoh, get_qty_dec($stock['stock_id'])));
                    return false;
                }
            }
        }
    }
    return true;
}
Пример #3
0
function can_process()
{
    global $selected_id, $SysPrefs, $Refs;
    if (!isset($selected_id)) {
        if (!$Refs->is_valid($_POST['wo_ref'])) {
            display_error(_("You must enter a reference."));
            set_focus('wo_ref');
            return false;
        }
        if (!is_new_reference($_POST['wo_ref'], ST_WORKORDER)) {
            display_error(_("The entered reference is already in use."));
            set_focus('wo_ref');
            return false;
        }
    }
    if (!check_num('quantity', 0)) {
        display_error(_("The quantity entered is invalid or less than zero."));
        set_focus('quantity');
        return false;
    }
    if (!is_date($_POST['date_'])) {
        display_error(_("The date entered is in an invalid format."));
        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;
    }
    // only check bom and quantites if quick assembly
    if (!($_POST['type'] == WO_ADVANCED)) {
        if (!has_bom($_POST['stock_id'])) {
            display_error(_("The selected item to manufacture does not have a bom."));
            set_focus('stock_id');
            return false;
        }
        if ($_POST['Labour'] == "") {
            $_POST['Labour'] = price_format(0);
        }
        if (!check_num('Labour', 0)) {
            display_error(_("The labour cost entered is invalid or less than zero."));
            set_focus('Labour');
            return false;
        }
        if ($_POST['Costs'] == "") {
            $_POST['Costs'] = price_format(0);
        }
        if (!check_num('Costs', 0)) {
            display_error(_("The cost entered is invalid or less than zero."));
            set_focus('Costs');
            return false;
        }
        if (!$SysPrefs->allow_negative_stock()) {
            if ($_POST['type'] == WO_ASSEMBLY) {
                // 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');
                        if (check_negative_stock($bom_item["component"], -$quantity, $bom_item["loc_code"], $_POST['date_'])) {
                            display_error(_("The work order cannot be processed because there is an insufficient quantity for component:") . " " . $bom_item["component"] . " - " . $bom_item["description"] . ".  " . _("Location:") . " " . $bom_item["location_name"]);
                            set_focus('quantity');
                            return false;
                        }
                    }
                }
            } elseif ($_POST['type'] == WO_UNASSEMBLY) {
                // if unassembling, check item to unassemble
                if (check_negative_stock($_POST['stock_id'], -input_num('quantity'), $_POST['StockLocation'], $_POST['date_'])) {
                    display_error(_("The selected item cannot be unassembled because there is insufficient stock."));
                    return false;
                }
            }
        }
    } else {
        if (!is_date($_POST['RequDate'])) {
            set_focus('RequDate');
            display_error(_("The date entered is in an invalid format."));
            return false;
        }
        //elseif (!is_date_in_fiscalyear($_POST['RequDate']))
        //{
        //	display_error(_("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(_("The quantity cannot be changed to be less than the quantity already manufactured for this order."));
                return false;
            }
        }
    }
    return true;
}
Пример #4
0
function can_process()
{
    global $wo_details, $SysPrefs, $Refs;
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!is_new_reference($_POST['ref'], 29)) {
        display_error(_("The entered reference is already in use."));
        set_focus('ref');
        return false;
    }
    if (!check_num('quantity', 0)) {
        display_error(_("The quantity entered is not a valid number or less then zero."));
        set_focus('quantity');
        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 production date cannot be before the release date of the work order."));
        set_focus('date_');
        return false;
    }
    // don't produce more that required. Otherwise change the Work Order.
    if (input_num('quantity') > $wo_details["units_reqd"] - $wo_details["units_issued"]) {
        display_error(_("The production exceeds the quantity needed. Please change the Work Order."));
        set_focus('quantity');
        return false;
    }
    // if unassembling we need to check the qoh
    if ($_POST['ProductionType'] == 0 && !$SysPrefs->allow_negative_stock()) {
        if (check_negative_stock($wo_details["stock_id"], -input_num('quantity'), $wo_details["loc_code"], $_POST['date_'])) {
            display_error(_("The unassembling cannot be processed because there is insufficient stock."));
            set_focus('quantity');
            return false;
        }
    }
    // if production we need to check the qoh of the wo requirements
    if ($_POST['ProductionType'] == 1 && !$SysPrefs->allow_negative_stock()) {
        $err = false;
        $result = get_wo_requirements($_POST['selected_id']);
        while ($row = db_fetch($result)) {
            if ($row['mb_flag'] == 'D') {
                // service, non stock
                continue;
            }
            if (check_negative_stock($row["stock_id"], -$row['units_req'] * input_num('quantity'), $row["loc_code"], $_POST['date_'])) {
                display_error(_("The production cannot be processed because a required item would cause a negative inventory balance :") . " " . $row['stock_id'] . " - " . $row['description']);
                $err = true;
            }
        }
        if ($err) {
            set_focus('quantity');
            return false;
        }
    }
    return true;
}