Execute("SELECT manufacturers_url FROM $manufacturers_infotable WHERE manufacturers_id = '" . intval($manufacturer_id) . "' AND manufacturers_languages_id = '" . intval($language_id) . "'"); return $manufacturer->fields['manufacturers_url']; } $nPage = (!isset($_GET['page']) || !is_numeric($_GET['page'])) ? 1 : intval($_GET['page']); $action = (isset($_GET['action']) ? $_GET['action'] : ''); if (!empty($action)) { switch ($action) { case 'insert': case 'save': if (isset($_GET['mID'])) $manufacturers_id = oos_db_prepare_input($_GET['mID']); $manufacturers_name = oos_db_prepare_input($_POST['manufacturers_name']); $sql_data_array = array('manufacturers_name' => $manufacturers_name); if ($action == 'insert') { $insert_sql_data = array('date_added' => 'now()'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); oos_db_perform($oostable['manufacturers'], $sql_data_array); $manufacturers_id = $dbconn->Insert_ID(); } elseif ($action == 'save') { $update_sql_data = array('last_modified' => 'now()'); $sql_data_array = array_merge($sql_data_array, $update_sql_data); oos_db_perform($oostable['manufacturers'], $sql_data_array, 'UPDATE', "manufacturers_id = '" . intval($manufacturers_id) . "'"); } $aLanguages = oos_get_languages(); $nLanguages = count($aLanguages); for ($i = 0, $n = $nLanguages; $i < $n; $i++) { $manufacturers_url_array = oos_db_prepare_input($_POST['manufacturers_url']); $language_id = $aLanguages[$i]['id']; $sql_data_array = array('manufacturers_url' => oos_db_prepare_input($manufacturers_url_array[$language_id])); if ($action == 'insert') { $insert_sql_data = array('manufacturers_id' => intval($manufacturers_id), 'manufacturers_languages_id' => intval($language_id)); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); oos_db_perform($oostable['manufacturers_info'], $sql_data_array); } elseif ($action == 'save') { oos_db_perform($oostable['manufacturers_info'], $sql_data_array, 'UPDATE', "manufacturers_id = '" . intval($manufacturers_id) . "' AND manufacturers_languages_id = '" . intval($language_id) . "'"); } } $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 ), '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. ), ), ); $oManufacturersImage = new upload('manufacturers_image', $options); $dir_fs_catalog_images = OOS_ABSOLUTE_PATH . OOS_IMAGES . 'brands/'; $oManufacturersImage->set_destination($dir_fs_catalog_images); $oManufacturersImage->parse(); if (oos_is_not_null($oManufacturersImage->filename)) { $manufacturerstable = $oostable['manufacturers']; $dbconn->Execute("UPDATE $manufacturerstable SET manufacturers_image = '" . oos_db_input($oManufacturersImage->filename) . "' WHERE manufacturers_id = '" . intval($manufacturers_id) . "'"); } oos_redirect_admin(oos_href_link_admin($aContents['manufacturers'], 'page=' . $nPage . '&mID=' . $manufacturers_id)); break; case 'deleteconfirm': $manufacturers_id = oos_db_prepare_input($_GET['mID']); if (isset($_POST['delete_image']) && ($_POST['delete_image'] == 'on')) { $manufacturerstable = $oostable['manufacturers']; $manufacturer_result = $dbconn->Execute("SELECT manufacturers_image FROM $manufacturerstable WHERE manufacturers_id = '" . intval($manufacturers_id) . "'"); $manufacturer = $manufacturer_result->fields; $image_location_originals = OOS_ABSOLUTE_PATH . OOS_IMAGES . 'brands/originals/'. $manufacturer['manufacturers_image']; if (file_exists($image_location_originals)) @unlink($image_location_originals); $image_location_medium = OOS_ABSOLUTE_PATH . OOS_IMAGES . 'brands/medium/'. $manufacturer['manufacturers_image']; if (file_exists($image_location_medium)) @unlink($image_location_medium); $image_location_small = OOS_ABSOLUTE_PATH . OOS_IMAGES . 'brands/small/'. $manufacturer['manufacturers_image']; if (file_exists($image_location_small)) @unlink($image_location_small); } $manufacturerstable = $oostable['manufacturers']; $dbconn->Execute("DELETE FROM $manufacturerstable WHERE manufacturers_id = '" . intval($manufacturers_id) . "'"); $manufacturers_infotable = $oostable['manufacturers_info']; $dbconn->Execute("DELETE FROM $manufacturers_infotable WHERE manufacturers_id = '" . intval($manufacturers_id) . "'"); if (isset($_POST['delete_products']) && ($_POST['delete_products'] == 'on')) { $productstable = $oostable['products']; $products_result = $dbconn->Execute("SELECT products_id FROM $productstable WHERE manufacturers_id = '" . intval($manufacturers_id) . "'"); while ($products = $products_result->fields) { oos_remove_product($products['products_id']); // Move that ADOdb pointer! $products_result->MoveNext(); } } else { $productstable = $oostable['products']; $dbconn->Execute("UPDATE $productstable SET manufacturers_id = '' WHERE manufacturers_id = '" . intval($manufacturers_id) . "'"); } oos_redirect_admin(oos_href_link_admin($aContents['manufacturers'], 'page=' . $nPage)); break; } } require 'includes/header.php'; ?>
'' . TEXT_HEADING_NEW_MANUFACTURER . ''); $contents = array('form' => oos_draw_form('id', 'manufacturers', $aContents['manufacturers'], 'action=insert', 'post', FALSE, 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_NEW_INTRO); $contents[] = array('text' => ' |
|