示例#1
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');
}
示例#2
0
if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') {
    $input_error = 0;
    if ($_POST['stock_id'] == "" || !isset($_POST['stock_id'])) {
        $input_error = 1;
        display_error(_("There is no item selected."));
        set_focus('stock_id');
    } elseif (!input_num('quantity')) {
        $input_error = 1;
        display_error(_("The price entered was not positive number."));
        set_focus('quantity');
    } elseif ($_POST['description'] == '') {
        $input_error = 1;
        display_error(_("Item code description cannot be empty."));
        set_focus('description');
    } elseif ($selected_id == -1) {
        $kit = get_item_kit($_POST['item_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('item_code');
        }
    }
    if ($input_error == 0) {
        if ($Mode == 'ADD_ITEM') {
            add_item_code($_POST['item_code'], $_POST['stock_id'], $_POST['description'], $_POST['category_id'], $_POST['quantity'], 1);
            display_notification(_("New item code has been added."));
        } else {
            update_item_code($selected_id, $_POST['item_code'], $_POST['stock_id'], $_POST['description'], $_POST['category_id'], $_POST['quantity'], 1);
            display_notification(_("Item code has been updated."));
        }
        $Mode = 'RESET';
示例#3
0
 if ($upload_file == 'No') {
     $input_error = 1;
 }
 if (strlen($_POST['description']) == 0) {
     $input_error = 1;
     display_error(_('The item name must be entered.'));
     set_focus('description');
 } elseif (strlen($_POST['NewStockID']) == 0) {
     $input_error = 1;
     display_error(_('The item code cannot be empty'));
     set_focus('NewStockID');
 } elseif (strstr($_POST['NewStockID'], " ") || strstr($_POST['NewStockID'], "'") || strstr($_POST['NewStockID'], "+") || strstr($_POST['NewStockID'], "\"") || strstr($_POST['NewStockID'], "&") || strstr($_POST['NewStockID'], "\t")) {
     $input_error = 1;
     display_error(_('The item code cannot contain any of the following characters -  & + OR a space OR quotes'));
     set_focus('NewStockID');
 } elseif ($new_item && db_num_rows(get_item_kit($_POST['NewStockID']))) {
     $input_error = 1;
     display_error(_("This item code is already assigned to stock item or sale kit."));
     set_focus('NewStockID');
 }
 if ($input_error != 1) {
     if (check_value('del_image')) {
         $filename = company_path() . '/images/' . item_img_name($_POST['NewStockID']) . ".jpg";
         if (file_exists($filename)) {
             unlink($filename);
         }
     }
     if (!$new_item) {
         /*so its an existing one */
         update_item($_POST['NewStockID'], $_POST['description'], $_POST['long_description'], $_POST['category_id'], $_POST['level_id'], $_POST['tax_type_id'], get_post('units'), get_post('mb_flag'), $_POST['sales_account'], $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id'], check_value('no_sale'), check_value('editable'));
         update_record_status($_POST['NewStockID'], $_POST['inactive'], 'stock_master', 'stock_id');