示例#1
0
function handle_add_new_item()
{
    $allow_update = check_data();
    if ($allow_update == true) {
        if (count($_SESSION['PO']->line_items) > 0) {
            foreach ($_SESSION['PO']->line_items as $order_item) {
                /* do a loop round the items on the order to see that the item
                			is not already on this order */
                if ($order_item->stock_id == $_POST['stock_id'] && $order_item->Deleted == False) {
                    $allow_update = False;
                    display_error(tr("The selected item is already on this order."));
                }
            }
            /* end of the foreach loop to look for pre-existing items of the same code */
        }
        if ($allow_update == true) {
            $sql = "SELECT description, units, mb_flag\n\t\t\t\tFROM stock_master WHERE stock_id = '" . $_POST['stock_id'] . "'";
            $result = db_query($sql, "The stock details for " . $_POST['stock_id'] . " could not be retrieved");
            if (db_num_rows($result) == 0) {
                $allow_update = False;
            }
            if ($allow_update) {
                $myrow = db_fetch($result);
                $_SESSION['PO']->add_to_order($_POST['line_no'], $_POST['stock_id'], input_num('qty'), $myrow["description"], input_num('price'), $myrow["units"], $_POST['req_del_date'], 0, 0);
                unset_form_variables();
                $_POST['StockID2'] = $_POST['stock_id'] = "";
            } else {
                display_error(tr("The selected item does not exist or it is a kit part and therefore cannot be purchased."));
            }
        }
        /* end of if not already on the order and allow input was true*/
    }
}
示例#2
0
function handle_add_new_item()
{
    $allow_update = check_data();
    if ($allow_update == true) {
        if (count($_SESSION['PO']->line_items) > 0) {
            foreach ($_SESSION['PO']->line_items as $order_item) {
                /* do a loop round the items on the order to see that the item
                			is not already on this order */
                if ($order_item->stock_id == $_POST['stock_id']) {
                    display_warning(_("The selected item is already on this order."));
                }
            }
            /* end of the foreach loop to look for pre-existing items of the same code */
        }
        if ($allow_update == true) {
            $result = get_short_info($_POST['stock_id']);
            if (db_num_rows($result) == 0) {
                $allow_update = false;
            }
            if ($allow_update) {
                $myrow = db_fetch($result);
                $_SESSION['PO']->add_to_order(count($_SESSION['PO']->line_items), $_POST['stock_id'], input_num('qty'), get_post('stock_id_text'), input_num('price'), '', $_SESSION['PO']->trans_type == ST_PURCHORDER ? $_POST['req_del_date'] : '', 0, 0);
                unset_form_variables();
                $_POST['stock_id'] = "";
            } else {
                display_error(_("The selected item does not exist or it is a kit part and therefore cannot be purchased."));
            }
        }
        /* end of if not already on the order and allow input was true*/
    }
    line_start_focus();
}