prefix . "foxypress_inventory_categories SET category_name='" . foxypress_FixPostVar('foxypress_new_category') . "'"; $wpdb->query($sql); header("location: " . foxypress_GetCurrentPageURL(false) . "?post_type=" . FOXYPRESS_CUSTOM_POST_TYPE . "&page=inventory-category"); } else if(isset($_POST['foxy_cat_save'])) //updating { $Category_Name = foxypress_FixPostVar('foxy_cat_name'); $Category_ID = foxypress_FixPostVar('foxy_cat_id'); $sql = "UPDATE " . $wpdb->prefix . "foxypress_inventory_categories SET category_name='" . $Category_Name . "' WHERE category_id=" . $Category_ID; $wpdb->query($sql); header("location: " . foxypress_GetCurrentPageURL(false) . "?post_type=" . FOXYPRESS_CUSTOM_POST_TYPE . "&page=inventory-category"); } else if($mode == "delete" && foxypress_FixGetVar('category_id') != "") //deleting { $category_id = foxypress_FixGetVar('category_id'); //before we delete, we need to default items to the general category unless they are already apart of that category $sql = "INSERT INTO " . $wpdb->prefix . "foxypress_inventory_to_category (inventory_id, category_id) SELECT i.inventory_id, '1' FROM " . $wpdb->prefix . "posts as i INNER JOIN " . $wpdb->prefix . "foxypress_inventory_to_category as itc on i.ID = itc.inventory_id AND itc.category_id = '" . foxypress_FixGetVar('category_id') . "' LEFT JOIN " . $wpdb->prefix . "foxypress_inventory_to_category as ltc on i.ID = ltc.inventory_id and ltc.category_id = '1' WHERE ltc.itc_id is null AND i.post_type='" . FOXYPRESS_CUSTOM_POST_TYPE . "'"; $wpdb->query($sql); //delete image associated $directory = ABSPATH . INVENTORY_IMAGE_LOCAL_DIR; $data = $wpdb->get_row("select category_image from " . $wpdb->prefix . "foxypress_inventory_categories where category_id = '" . mysql_escape_string($category_id) . "'"); if (!empty($data)) { foxypress_DeleteItem($directory . $data->category_image); } //delete from categories $sql = "DELETE FROM " . $wpdb->prefix . "foxypress_inventory_categories WHERE category_id=" . $category_id; $wpdb->query($sql); //delete from inventory to categories $sql = "DELETE FROM " . $wpdb->prefix . "foxypress_inventory_to_category WHERE category_id=" . $category_id; $wpdb->query($sql); header("location: " . foxypress_GetCurrentPageURL(false) . "?post_type=" . FOXYPRESS_CUSTOM_POST_TYPE. "&page=inventory-category"); } else if(isset($_POST['foxy_order_items_save'])) { $categoryID = foxypress_FixGetVar('categoryid'); $OrderArray = explode(",", foxypress_FixPostVar('hdn_foxy_items_order')); $counter = 1; foreach ($OrderArray as $itc_id) { $wpdb->query("UPDATE " . $wpdb->prefix . "foxypress_inventory_to_category SET sort_order = '$counter' WHERE itc_id='" . $itc_id . "'"); $counter++; } header("location: " . foxypress_GetCurrentPageURL(false) . "?post_type=" . FOXYPRESS_CUSTOM_POST_TYPE . "&page=inventory-category&view=sort&categoryid=" . $categoryID); } else if(isset($_POST['foxy_cat_image_submit'])) { //attempt to upload the image $category_id = foxypress_FixPostVar('hdn_category_id'); if(!empty($_FILES["fp_cat_image"])) { $image = isset($_FILES["fp_cat_image"]["name"]) ? $_FILES["fp_cat_image"]["name"] : ""; if ($image) { $imgname = foxypress_UploadImage("fp_cat_image", $category_id); } //if the upload succeeded, insert into database if ($imgname) { $imgquery = "UPDATE " . $wpdb->prefix . "foxypress_inventory_categories SET category_image = '" . mysql_escape_string($imgname) . "' WHERE category_id = '" . $category_id . "'"; $wpdb->query($imgquery); } } header("location: " . foxypress_GetCurrentPageURL(false) . "?post_type=" . FOXYPRESS_CUSTOM_POST_TYPE . "&page=inventory-category"); } else if($mode == "delete_image" && foxypress_FixGetVar('category_id') != "") { $category_id = foxypress_FixGetVar('category_id'); $directory = ABSPATH . INVENTORY_IMAGE_LOCAL_DIR; $data = $wpdb->get_row("select category_image from " . $wpdb->prefix . "foxypress_inventory_categories where category_id = '" . mysql_escape_string($category_id) . "'"); if (!empty($data)) { foxypress_DeleteItem($directory . $data->category_image); $wpdb->query("UPDATE " . $wpdb->prefix . "foxypress_inventory_categories SET category_image = NULL where category_id = '" . mysql_escape_string($category_id) . "'"); } header("location: " . foxypress_GetCurrentPageURL(false) . "?post_type=" . FOXYPRESS_CUSTOM_POST_TYPE . "&page=inventory-category"); } } } //page load function foxypress_inventory_category_page_load() { $page_view = foxypress_FixGetVar('view'); if($page_view == "sort") { foxypress_inventory_category_sort(); } else { foxypress_inventory_category_view_categories(); } } //sort items in specific categories function foxypress_inventory_category_sort() { global $wpdb; $category_id = foxypress_FixGetVar('categoryid'); ?>

get_results("SELECT i.*, itc.itc_id FROM " . $wpdb->prefix . "posts as i INNER JOIN " . $wpdb->prefix . "foxypress_inventory_to_category AS itc on i.ID = itc.inventory_id WHERE post_type='" . FOXYPRESS_CUSTOM_POST_TYPE . "' and post_status='publish' and itc.category_id = '" . $category_id . "' ORDER BY itc.sort_order"); if(!empty($items)) { echo(""); foreach($items as $i) { $current_item_order .= ($current_item_order == "") ? $i->itc_id : "," . $i->itc_id; echo("itc_id . "\"> "); } echo("
Sort Item Code Item Name
" . get_post_meta($i->ID, "_code", true) . "   " . $i->post_title . "
"); ?>

:
 
get_row("select count(category_id) as RowCount from " . $wpdb->prefix . "foxypress_inventory_categories"); $pageNumber = foxypress_FixGetVar('fp_pn'); $start = ($pageNumber != "" && $pageNumber != "0") ? $start = ($pageNumber - 1) * $limit : 0; $categories = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "foxypress_inventory_categories ORDER BY category_id ASC LIMIT $start, $limit"); if ( !empty($categories) ) { ?> "; if ($category->category_id == 1) { echo ""; } else { echo ""; } $ImageOutput = ""; if($category->category_image != "") { $ImageOutput = "
View Image   category_id . "\">\"\"
"; } else { $ImageOutput = "category_id . "\" /> "; } echo(""); if ($category->category_id == 1) { echo ""; } else { echo ""; } echo ""; } ?>
" . $category->category_id . "" . stripslashes($category->category_name) . "
category_name) . "\" /> category_id\" />
" . $ImageOutput . " category_id . "\">Sort Inventory Items " . __("N/A","inventory") . " category_id . "\" class=\"delete\" onclick=\"return confirm('" . __('Are you sure you want to delete this category?','inventory') . "');\">" . __("Delete","inventory") . "
RowCount > $limit) { $Pagination = foxypress_GetPagination($pageNumber, $drRows->RowCount, $limit, $targetpage, 'fp_pn'); echo ("
" . $Pagination); } } else { echo '

There are currently no categories

'; } echo '
'; //end wrap } ?>