Execute("SELECT products_id FROM " . $oostable['products'] . " WHERE products_id = " . intval($_POST['slave_product_id']) . " LIMIT 1"); if ($check_product_result->RecordCount() == 1) { $product_check = TRUE; } //checks if the product is already present $check_product_result = $dbconn->Execute("SELECT slave_id, master_id FROM " . $oostable['products_to_master'] . " WHERE slave_id = " . intval($_POST['slave_product_id']) . " AND master_id = " . intval($_GET['pID']) . " LIMIT 1"); if ($check_product_result->RecordCount() == 1) { $product_check = FALSE; } } if ($product_check === TRUE) { $sql_data_array = array('slave_id' => $_POST['slave_product_id'], 'master_id' => $_GET['pID']); oos_db_perform($oostable['products_to_master'], $sql_data_array, 'INSERT'); $messageStack->add_session(TEXT_SUCCESSFULLY_SLAVE, 'success'); } else { $messageStack->add_session(TEXT_ERROR_SLAVE, 'error'); } oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $cPath . '&pID=' . intval($_GET['pID']) . '&action=slave_products')); break; case 'slave_delete': $dbconn->Execute("DELETE FROM " . $oostable['products_to_master'] . " WHERE slave_id = " . intval($_GET['slave_id']) . " AND master_id = " . intval($_GET['master_id']) . " LIMIT 1"); $check_product_result = $dbconn->Execute("SELECT slave_id, master_id FROM " . $oostable['products_to_master'] . " WHERE slave_id = " . intval($_GET['slave_id'])); if ($check_product_result->RecordCount() == 0) { $dbconn->Execute("UPDATE " . $oostable['products'] . " SET products_slave_visible = '1' WHERE products_id = " . intval($_GET['slave_id'])); } $messageStack->add_session('Slave Deleted', 'success'); oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $cPath . '&pID=' . intval($_GET['master_id']) . '&action=slave_products')); break; case 'slave_visible': $dbconn->Execute("UPDATE " . $oostable['products'] . " SET products_slave_visible = " . intval($_GET['visible']) . " WHERE products_id = " . intval($_GET['slave_id'])); oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $cPath . '&pID=' . intval($_GET['master_id']) . '&action=slave_products')); break; case 'setflag': if ( isset($_GET['flag']) && ($_GET['flag'] == '1') || ($_GET['flag'] == '2') ) { if (isset($_GET['pID']) && is_numeric($_GET['pID'])) { oos_set_product_status($_GET['pID'], $_GET['flag']); } elseif (isset($_GET['cID']) && is_numeric($_GET['cID'])) { oos_set_categories_status($_GET['cID'], $_GET['flag']); } } oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $cPath . '&pID=' . intval($_GET['pID']) . '&cID=' . intval($cID) . '&page=' . $nPage . ((isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : ''))); break; case 'insert_category': case 'update_category': $nStatus = oos_db_prepare_input($_POST['categories_status']); $color = oos_db_prepare_input($_POST['color']); $menu_type = oos_db_prepare_input($_POST['menu_type']); $sort_order = oos_db_prepare_input($_POST['sort_order']); $nImageCounter = (!isset($_POST['image_counter']) || !is_numeric($_POST['image_counter'])) ? 0 : intval($_POST['image_counter']); if (isset($_FILES['files'])) { foreach ($_FILES['files']['name'] as $key => $name) { if (empty($name)) { // purge empty slots unset($_FILES['files']['name'][$key]); unset($_FILES['files']['type'][$key]); unset($_FILES['files']['tmp_name'][$key]); unset($_FILES['files']['error'][$key]); unset($_FILES['files']['size'][$key]); } } } if (isset($_POST['categories_id'])) $categories_id = oos_db_prepare_input($_POST['categories_id']); if ((isset($_GET['cID'])) && ($categories_id == '')) { $categories_id = intval($_GET['cID']); } $sql_data_array = array(); $sql_data_array = array('color' => oos_db_prepare_input($color), 'menu_type' => oos_db_prepare_input($menu_type), 'sort_order' => intval($sort_order)); if ($action == 'insert_category') { $insert_sql_data = array(); $insert_sql_data = array('parent_id' => intval($current_category_id), 'date_added' => 'now()', 'categories_status' => intval($nStatus)); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); oos_db_perform($oostable['categories'], $sql_data_array); $categories_id = $dbconn->Insert_ID(); } elseif ($action == 'update_category') { $update_sql_data = array('last_modified' => 'now()', 'categories_status' => intval($nStatus)); $sql_data_array = array_merge($sql_data_array, $update_sql_data); oos_db_perform($oostable['categories'], $sql_data_array, 'UPDATE', 'categories_id = \'' . $categories_id . '\''); } $aLanguages = oos_get_languages(); $nLanguages = count($aLanguages); for ($i = 0, $n = $nLanguages; $i < $n; $i++) { $language_id = $aLanguages[$i]['id']; $categories_description = oos_db_prepare_input($_POST['categories_description'][$language_id]); $categories_description_meta = oos_db_prepare_input($_POST['categories_description_meta'][$language_id]); if (empty($categories_description_meta)) { $categories_description_meta = substr(strip_tags(preg_replace('!(\r\n|\r|\n)!', '',$categories_description)),0 , 160); } $sql_data_array = array('categories_name' => oos_db_prepare_input($_POST['categories_name'][$language_id]), 'categories_page_title' => oos_db_prepare_input($_POST['categories_page_title'][$language_id]), 'categories_heading_title' => oos_db_prepare_input($_POST['categories_heading_title'][$language_id]), 'categories_description' => $categories_description, 'categories_description_meta' => $categories_description_meta); if ($action == 'insert_category') { $insert_sql_data = array('categories_id' => intval($categories_id), 'categories_languages_id' => intval($aLanguages[$i]['id'])); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); oos_db_perform($oostable['categories_description'], $sql_data_array); } elseif ($action == 'update_category') { oos_db_perform($oostable['categories_description'], $sql_data_array, 'UPDATE', 'categories_id = \'' . intval($categories_id) . '\' AND categories_languages_id = \'' . intval($language_id) . '\''); } } if ( ($_POST['remove_image'] == 'yes') && (isset($_POST['categories_previous_image'])) ) { $categories_previous_image = oos_db_prepare_input($_POST['categories_previous_image']); $categoriestable = $oostable['categories']; $dbconn->Execute("UPDATE $categoriestable SET categories_image = NULL WHERE categories_id = '" . intval($categories_id) . "'"); oos_remove_category_image($categories_previous_image); } if ( ($_POST['remove_banner'] == 'yes') && (isset($_POST['categories_previous_banner'])) ) { $categories_previous_banner = oos_db_prepare_input($_POST['categories_previous_banner']); $categoriestable = $oostable['categories']; $dbconn->Execute("UPDATE $categoriestable SET categories_banner = NULL WHERE categories_id = '" . intval($categories_id) . "'"); oos_remove_category_banner($categories_previous_banner); } for ($i = 1, $n = $nImageCounter+1; $i < $n; $i++) { if ( ($_POST['remove_category_image'][$i] == 'yes') && (isset($_POST['categories_previous_large_image'][$i])) ) { $categories_previous_large_image = oos_db_prepare_input($_POST['categories_previous_large_image'][$i]); $dbconn->Execute("DELETE FROM " . $oostable['categories_images'] . " WHERE categories_image = '" . oos_db_input($categories_previous_large_image) . "'"); oos_remove_category_image($categories_previous_large_image); } } // Banner $aBannerOptions = array( 'image_versions' => array( // The empty image version key defines options for the original image. // Keep in mind: these image manipulations are inherited by all other image versions from this point onwards. // Also note that the property 'no_cache' is not inherited, since it's not a manipulation. '' => array( // Automatically rotate images based on EXIF meta data: 'auto_orient' => TRUE ), 'large' => array( // 'auto_orient' => TRUE, // 'crop' => TRUE, // 'jpeg_quality' => 82, // 'no_cache' => TRUE, (there's a caching option, but this remembers thumbnail sizes from a previous action!) // 'strip' => TRUE, (this strips EXIF tags, such as geolocation) 'max_width' => 440, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height. 'max_height' => 500, // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width. ), 'medium' => array( // 'auto_orient' => TRUE, // 'crop' => TRUE, // 'jpeg_quality' => 82, // 'no_cache' => TRUE, (there's a caching option, but this remembers thumbnail sizes from a previous action!) // 'strip' => TRUE, (this strips EXIF tags, such as geolocation) 'max_width' => 300, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height. 'max_height' => 120 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width. ), ), ); $oCategoriesBanner = new upload('categories_banner', $aBannerOptions); $dir_fs_catalog_banner = OOS_ABSOLUTE_PATH . OOS_IMAGES . 'banners/'; $oCategoriesBanner->set_destination($dir_fs_catalog_banner); if ($oCategoriesBanner->parse() && oos_is_not_null($oCategoriesBanner->filename)) { $categoriestable = $oostable['categories']; $dbconn->Execute("UPDATE $categoriestable SET categories_banner = '" . oos_db_input($oCategoriesBanner->filename) . "' WHERE categories_id = '" . intval($categories_id) . "'"); } // Primary $options = array( 'image_versions' => array( // The empty image version key defines options for the original image. // Keep in mind: these image manipulations are inherited by all other image versions from this point onwards. // Also note that the property 'no_cache' is not inherited, since it's not a manipulation. '' => array( // Automatically rotate images based on EXIF meta data: 'auto_orient' => TRUE ), 'large' => array( // 'auto_orient' => TRUE, // 'crop' => TRUE, // 'jpeg_quality' => 82, // 'no_cache' => TRUE, (there's a caching option, but this remembers thumbnail sizes from a previous action!) // 'strip' => TRUE, (this strips EXIF tags, such as geolocation) 'max_width' => 1024, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height. 'max_height' => 1024, // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width. ), 'medium' => array( // 'auto_orient' => TRUE, // 'crop' => TRUE, // 'jpeg_quality' => 82, // 'no_cache' => TRUE, (there's a caching option, but this remembers thumbnail sizes from a previous action!) // 'strip' => TRUE, (this strips EXIF tags, such as geolocation) 'max_width' => 300, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height. 'max_height' => 300 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width. ), 'small' => array( // 'auto_orient' => TRUE, // 'crop' => TRUE, // 'jpeg_quality' => 82, // 'no_cache' => TRUE, (there's a caching option, but this remembers thumbnail sizes from a previous action!) // 'strip' => TRUE, (this strips EXIF tags, such as geolocation) 'max_width' => 150, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height. 'max_height' => 150 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width. ), ), ); $oCategoriesImage = new upload('categories_image', $options); $dir_fs_catalog_images = OOS_ABSOLUTE_PATH . OOS_IMAGES . 'category/'; $oCategoriesImage->set_destination($dir_fs_catalog_images); if ($oCategoriesImage->parse() && oos_is_not_null($oCategoriesImage->filename)) { $categoriestable = $oostable['categories']; $dbconn->Execute("UPDATE $categoriestable SET categories_image = '" . oos_db_input($oCategoriesImage->filename) . "' WHERE categories_id = '" . intval($categories_id) . "'"); } if (isset($_FILES['files'])) { $oImage = new upload('files', $options); $dir_fs_catalog_images = OOS_ABSOLUTE_PATH . OOS_IMAGES . 'category/'; $oImage->set_destination($dir_fs_catalog_images); $oImage->parse(); if (oos_is_not_null($oImage->response)) { $sort_order = 0 + $nImageCounter; foreach ($oImage->response as $index => $value) { $sort_order++; $sql_data_array = array('categories_id' => intval($categories_id), 'categories_image' => oos_db_prepare_input($value), 'sort_order' => intval($sort_order)); oos_db_perform($oostable['categories_images'], $sql_data_array); } } } oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $cPath . '&cID=' . $categories_id)); break; case 'delete_category_confirm': if (isset($_POST['categories_id']) && is_numeric($_POST['categories_id'])) { $categories_id = oos_db_prepare_input($_POST['categories_id']); $categories = oos_get_category_tree($categories_id, '', '0', '', TRUE); $products = array(); $products_delete = array(); for ($i = 0, $n = count($categories); $i < $n; $i++) { $product_ids_result = $dbconn->Execute("SELECT products_id FROM " . $oostable['products_to_categories'] . " WHERE categories_id = '" . intval($categories[$i]['id']) . "'"); while ($product_ids = $product_ids_result->fields) { $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id']; // Move that ADOdb pointer! $product_ids_result->MoveNext(); } } reset($products); foreach ($products as $key => $value) { $category_ids = ''; for ($i = 0, $n = count($value['categories']); $i < $n; $i++) { $category_ids .= '\'' . $value['categories'][$i] . '\', '; } $category_ids = substr($category_ids, 0, -2); $check_result = $dbconn->Execute("SELECT COUNT(*) AS total FROM " . $oostable['products_to_categories'] . " WHERE products_id = '" . intval($key) . "' AND categories_id not in (" . $category_ids . ")"); $check = $check_result->fields; if ($check['total'] < '1') { $products_delete[$key] = $key; } } for ($i = 0, $n = count($categories); $i < $n; $i++) { category_move_to_trash($categories[$i]['id']); } foreach($products_delete as $key) { product_move_to_trash($key); } } oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $cPath . '&page=' . $nPage)); break; case 'delete_product_confirm': if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) { $product_id = oos_db_prepare_input($_POST['products_id']); product_move_to_trash($product_id); } oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $cPath . '&page=' . $nPage)); break; case 'move_category_confirm': if (isset($_POST['categories_id']) && ($_POST['categories_id'] != $_POST['move_to_category_id'])) { $categories_id = oos_db_prepare_input($_POST['categories_id']); $new_parent_id = oos_db_prepare_input($_POST['move_to_category_id']); $dbconn->Execute("UPDATE " . $oostable['categories'] . " SET parent_id = '" . intval($new_parent_id) . "', last_modified = now() WHERE categories_id = '" . intval($categories_id) . "'"); } oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $new_parent_id . '&cID=' . $categories_id)); break; case 'move_product_confirm': $products_id = oos_db_prepare_input($_POST['products_id']); $new_parent_id = oos_db_prepare_input($_POST['move_to_category_id']); $duplicate_check_result = $dbconn->Execute("SELECT COUNT(*) AS total FROM " . $oostable['products_to_categories'] . " WHERE products_id = '" . intval($products_id) . "' and categories_id = '" . intval($new_parent_id) . "'"); $duplicate_check = $duplicate_check_result->fields; if ($duplicate_check['total'] < 1) $dbconn->Execute("UPDATE " . $oostable['products_to_categories'] . " SET categories_id = '" . intval($new_parent_id) . "' WHERE products_id = '" . intval($products_id) . "' and categories_id = '" . intval($current_category_id) . "'"); oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $new_parent_id . '&pID=' . $products_id)); break; case 'copy_to_confirm': if (isset($_POST['products_id']) && isset($_POST['categories_id'])) { $products_id = oos_db_prepare_input($_POST['products_id']); $categories_id = oos_db_prepare_input($_POST['categories_id']); if ($_POST['copy_as'] == 'link') { if ($_POST['categories_id'] != $current_category_id) { $check_result = $dbconn->Execute("SELECT COUNT(*) AS total FROM " . $oostable['products_to_categories'] . " WHERE products_id = '" . intval($products_id) . "' and categories_id = '" . intval($categories_id) . "'"); $check = $check_result->fields; if ($check['total'] < '1') { $dbconn->Execute("INSERT INTO " . $oostable['products_to_categories'] . " (products_id, categories_id) VALUES ('" . intval($products_id) . "', '" . intval($categories_id) . "')"); } } else { $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error'); } } elseif ($_POST['copy_as'] == 'duplicate') { $product_result = $dbconn->Execute("SELECT products_quantity, products_reorder_level, products_model, products_replacement_product_id, products_ean, products_image, products_price, products_base_price, products_base_unit, products_date_available, products_weight, products_status, products_setting, products_tax_class_id, products_units_id, manufacturers_id, products_price_list, products_quantity_order_min, products_quantity_order_max, products_quantity_order_units, products_discount1, products_discount2, products_discount3, products_discount4, products_discount1_qty, products_discount2_qty, products_discount3_qty, products_discount4_qty, products_discounts_id, products_slave_visible, products_sort_order FROM " . $oostable['products'] . " WHERE products_id = '" . oos_db_input($products_id) . "'"); $product = $product_result->fields; $dbconn->Execute("INSERT INTO " . $oostable['products'] . " (products_quantity, products_reorder_level, products_model, products_replacement_product_id, products_ean, products_image, products_price, products_base_price, products_base_unit, products_date_added, products_date_available, products_weight, products_status, products_setting, products_tax_class_id, products_units_id, manufacturers_id, products_price_list, products_quantity_order_min, products_quantity_order_max, products_quantity_order_units, products_discount1, products_discount2, products_discount3, products_discount4, products_discount1_qty, products_discount2_qty, products_discount3_qty, products_discount4_qty, products_discounts_id, products_slave_visible, products_sort_order) VALUES ('" . $product['products_quantity'] . "', '" . $product['products_reorder_level'] . "', '" . $product['products_model'] . "', '" . $product['products_replacement_product_id'] . "', '" . $product['products_ean'] . "', '" . $product['products_image'] . "', '" . $product['products_price'] . "', '" . $product['products_base_price'] . "', '" . $product['products_base_unit'] . "', now(), '" . (empty($product['products_date_available']) ? null : "'" . oos_db_input($product['products_date_available']) . "'") . "', '" . $product['products_weight'] . "', '" . $product['products_status'] . "', '3', '" . $product['products_tax_class_id'] . "', '" . $product['products_units_id'] . "', '" . $product['manufacturers_id'] . "', '" . $product['products_price_list'] . "', '" . $product['products_quantity_order_min'] . "', '" . $product['products_quantity_order_max'] . "', '" . $product['products_quantity_order_units'] . "', '" . $product['products_discount1'] . "', '" . $product['products_discount2'] . "', '" . $product['products_discount3'] . "', '" . $product['products_discount4'] . "', '" . $product['products_discount1_qty'] . "', '" . $product['products_discount2_qty'] . "', '" . $product['products_discount3_qty'] . "', '" . $product['products_discount4_qty'] . "', '" . $product['products_discounts_id'] . "', '" . $product['products_slave_visible'] . "', '" . $product['products_sort_order'] . "')"); $dup_products_id = $dbconn->Insert_ID(); $description_result = $dbconn->Execute("SELECT products_languages_id, products_name, products_title, products_description, products_short_description, products_essential_characteristics, products_url, products_description_meta FROM " . $oostable['products_description'] . " WHERE products_id = '" . oos_db_input($products_id) . "'"); while ($description = $description_result->fields) { $dbconn->Execute("INSERT INTO " . $oostable['products_description'] . " (products_id, products_languages_id, products_name, products_title, products_description, products_short_description, products_essential_characteristics, products_url, products_viewed, products_description_meta) VALUES ('" . $dup_products_id . "', '" . $description['products_languages_id'] . "', '" . oos_db_input($description['products_name']) . "', '" . oos_db_input($description['products_title']) . "', '" . oos_db_input($description['products_description']) . "', '" . oos_db_input($description['products_short_description']) . "', '" . oos_db_input($description['products_essential_characteristics']) . "', '" . oos_db_input($description['products_url']) . "', '0', '" . oos_db_input($description['products_description_meta']). "')"); // Move that ADOdb pointer! $description_result->MoveNext(); } $products_id_from = oos_db_input($products_id); $products_id_to = $dup_products_id; $products_id = $dup_products_id; $dbconn->Execute("INSERT INTO " . $oostable['products_to_categories'] . " (products_id, categories_id) VALUES ('" . intval($dup_products_id) . "', '" . intval($categories_id) . "')"); $products_images_copy_result= $dbconn->Execute("SELECT image_name, sort_order FROM " . $oostable['products_images'] . " WHERE products_id='" . intval($products_id_from) . "'"); while ( $products_images_copy = $products_images_copy_result->fields) { $sql = "INSERT INTO " . $oostable['products_images'] . " (products_id, image_name, sort_order) VALUES ('" . intval($products_id_to) . "', '" . $products_images_copy['image_name'] . "', '" . $products_images_copy['sort_order'] . "')"; $dbconn->Execute($sql); // Move that ADOdb pointer! $products_images_copy_result->MoveNext(); } if ( $_POST['copy_attributes']=='copy_attributes_yes' and $_POST['copy_as'] == 'duplicate' ) { $products_copy_from_result= $dbconn->Execute("SELECT options_id, options_values_id, options_values_price, price_prefix, options_sort_order FROM " . $oostable['products_attributes'] . " WHERE products_id='" . intval($products_id_from) . "'"); while ( $products_copy_from = $products_copy_from_result->fields) { $sql = "INSERT INTO " . $oostable['products_attributes'] . " (products_id, options_id, options_values_id, options_values_price, price_prefix, options_sort_order) VALUES ('" . intval($products_id_to) . "', '" . $products_copy_from['options_id'] . "', '" . $products_copy_from['options_values_id'] . "', '" . $products_copy_from['options_values_price'] . "', '" . $products_copy_from['price_prefix'] . "', '" . $products_copy_from['options_sort_order'] . "')"; $dbconn->Execute($sql); // Move that ADOdb pointer! $products_copy_from_result->MoveNext(); } } } } oos_redirect_admin(oos_href_link_admin($aContents['categories'], 'cPath=' . $categories_id . '&pID=' . $products_id)); break; } } $cPath_back = ''; if (is_array($aPath) && count($aPath) > 0) { for ($i = 0, $n = count($aPath) - 1; $i < $n; $i++) { if (empty($cPath_back)) { $cPath_back .= $aPath[$i]; } else { $cPath_back .= '_' . $aPath[$i]; } } } $cPath_back = (oos_is_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : ''; // check if the catalog image directory exists if (is_dir(OOS_ABSOLUTE_PATH . OOS_IMAGES)) { if (!is_writeable(OOS_ABSOLUTE_PATH . OOS_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error'); } else { $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error'); } require 'includes/header.php'; ?>
'' . oos_get_products_name($pInfo->products_id, $_SESSION['language_id']) . ''); $contents = array('form' => oos_draw_form('id', 'new_slave_product', $aContents['categories'], 'action=new_slave_product&cPath=' . $cPath . '&pID=' . $pInfo->products_id, 'post', FALSE, 'enctype="multipart/form-data"')); $contents[] = array('text' => ' |
|