Ejemplo n.º 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');
}
Ejemplo n.º 2
0
        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';
    }
}
//--------------------------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    delete_item_code($selected_id);
    display_notification(_("Item code has been sucessfully deleted."));
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
Ejemplo n.º 3
0
         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");
         }
         $i++;
     } else {
         $sql = "UPDATE " . TB_PREF . "stock_master SET long_description='',\n\t\t\t\t\t    description=" . db_escape($description) . ",\n\t\t\t\t\t    category_id='{$cat}',\n\t\t\t\t\t    sales_account='{$_POST['sales_account']}',\n\t\t\t\t\t    inventory_account='{$_POST['inventory_account']}',\n\t\t\t\t\t    cogs_account='{$_POST['cogs_account']}',\n\t\t\t\t\t    adjustment_account='{$_POST['adjustment_account']}',\n\t\t\t\t\t    assembly_account='{$_POST['assembly_account']}',\n\t\t\t\t\t    dimension_id={$dim},\n\t\t\t\t\t    dimension2_id=0,\n\t\t\t\t\t    units='{$units}',\n\t\t\t\t\t    mb_flag='{$mb_flag}',\n\t\t\t\t\t    tax_type_id={$_POST['tax_type_id']}\n\t\t\t\t\t    WHERE stock_id='{$id}'";
         db_query($sql, "The item could not be updated");
         display_notification("Line {$lines}: Update {$id} {$descriptiont}");
         $j++;
     }
     $sql = "SELECT id from " . TB_PREF . "item_codes WHERE item_code='{$code}' AND stock_id = '{$id}'";
     $result = db_query($sql, "item code could not be retrieved");
     $row = db_fetch_row($result);
     if (!$row) {
         add_item_code($code, $id, $description, $cat, 1);
     } else {
         update_item_code($row[0], $code, $id, $description, $cat, 1);
     }
 }
 if ($type == 'ITEM' || $type == 'KIT' || $type == 'PRICE') {
     if (isset($price) && $price != "") {
         if ($currency == "") {
             $currency = get_company_pref("curr_default");
         } else {
             $row = get_currency($currency);
             if (!$row) {
                 add_currency($currency, "", "", "", "");
             }
         }
         $sql = "SELECT * FROM " . TB_PREF . "prices\tWHERE stock_id='{$code}' AND sales_type_id={$_POST['sales_type_id']} AND\n\t\t\t\t\tcurr_abrev='{$currency}'";