Example #1
0
            update_item_category($selected_id, $_POST['description'], $_POST['tax_type_id'], $_POST['sales_account'], $_POST['cogs_account'], $_POST['inventory_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['units'], $_POST['mb_flag'], $_POST['dim1'], $_POST['dim2'], check_value('no_sale'));
            display_notification(_('Selected item category has been updated'));
        } else {
            add_item_category($_POST['description'], $_POST['tax_type_id'], $_POST['sales_account'], $_POST['cogs_account'], $_POST['inventory_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['units'], $_POST['mb_flag'], $_POST['dim1'], $_POST['dim2'], check_value('no_sale'));
            display_notification(_('New item category has been added'));
        }
        $Mode = 'RESET';
    }
}
//----------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'stock_master'
    if (key_in_foreign_table($selected_id, 'stock_master', 'category_id')) {
        display_error(_("Cannot delete this item category because items have been created using this item category."));
    } else {
        delete_item_category($selected_id);
        display_notification(_('Selected item category has been deleted'));
    }
    $Mode = 'RESET';
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);
    $_POST['show_inactive'] = $sav;
}
if (list_updated('mb_flag')) {
    $Ajax->activate('details');
}
//----------------------------------------------------------------------------------
$result = get_item_categories(check_value('show_inactive'));
 public function delete($rest, $id)
 {
     $req = $rest->request();
     $info = $req->post();
     $catego = get_item_category($id);
     if ($catego == null) {
         api_error(400, 'Invalid Category ID');
     }
     delete_item_category($id);
     $catego = get_item_category($id);
     if ($catego != null) {
         api_error(500, 'Could Not Delete from Database: ');
     } else {
         api_success_response("Category has been deleted");
     }
 }