function _setData() { global $osC_Database, $osC_Language, $osC_Currencies; if (!isset($osC_Currencies)) { if (!class_exists('osC_Currencies')) { include '../includes/classes/currencies.php'; } $osC_Currencies = new osC_Currencies(); } $this->_data = '<table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">' . ' <thead>' . ' <tr>' . ' <th>' . $osC_Language->get('summary_products_table_heading_products') . '</th>' . ' <th>' . $osC_Language->get('summary_products_table_heading_price') . '</th>' . ' <th>' . $osC_Language->get('summary_products_table_heading_date') . '</th>' . ' <th>' . $osC_Language->get('summary_products_table_heading_status') . '</th>' . ' </tr>' . ' </thead>' . ' <tbody>'; $Qproducts = $osC_Database->query('select products_id, greatest(products_date_added, products_last_modified) as date_last_modified from :table_products where parent_id = 0 order by date_last_modified desc limit 6'); $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->execute(); while ($Qproducts->next()) { $data = osC_Products_Admin::get($Qproducts->valueInt('products_id')); $products_icon = osc_icon('products.png'); $products_price = $data['products_price']; if (!empty($data['variants'])) { $products_icon = osc_icon('attach.png'); $products_price = null; foreach ($data['variants'] as $variant) { if ($products_price === null || $variant['data']['price'] < $products_price) { $products_price = $variant['data']['price']; } } if ($products_price === null) { $products_price = 0; } } $this->_data .= ' <tr onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);">' . ' <td>' . osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, 'products=' . (int) $data['products_id'] . '&action=save'), $products_icon . ' ' . osc_output_string_protected($data['products_name'])) . '</td>' . ' <td>' . (!empty($data['variants']) ? 'from ' : '') . $osC_Currencies->format($products_price) . '</td>' . ' <td>' . $Qproducts->value('date_last_modified') . '</td>' . ' <td align="center">' . osc_icon((int) $data['products_status'] === 1 ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif', null, null) . '</td>' . ' </tr>'; } $this->_data .= ' </tbody>' . '</table>'; $Qproducts->freeResult(); }
function saveProductsExpected() { global $toC_Json, $osC_Language, $osC_Database; $data = array('date_available' => $_REQUEST['products_date_available']); if (osC_Products_Admin::setDateAvailable($_REQUEST['products_id'], $data)) { $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed')); } else { $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed')); } echo $toC_Json->encode($response); }
public function __construct() { global $osC_Language, $osC_MessageStack; parent::__construct(); $this->_page_contents = 'delete.php'; if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { if (osC_Products_Admin::delete($_GET[$this->_module])) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID'])); } }
public static function getAll() { global $_module, $osC_Currencies; if (!isset($_GET['cID'])) { $_GET['cID'] = '0'; } if (!isset($_GET['search'])) { $_GET['search'] = ''; } if (!isset($_GET['page']) || !is_numeric($_GET['page'])) { $_GET['page'] = 1; } $osC_Currencies = new osC_Currencies(); if (!empty($_GET['search'])) { $result = osC_Products_Admin::find($_GET['search'], $_GET['cID'], $_GET['page']); } else { $result = osC_Products_Admin::getAll($_GET['cID'], $_GET['page']); } $result['rpcStatus'] = RPC_STATUS_SUCCESS; echo json_encode($result); }
function __construct() { global $osC_Database, $osC_Language, $osC_MessageStack; $this->_page_title = $osC_Language->get('heading_title'); if (!isset($_GET['action'])) { $_GET['action'] = ''; } if (!isset($_GET['page']) || isset($_GET['page']) && !is_numeric($_GET['page'])) { $_GET['page'] = 1; } $Qcheck = $osC_Database->query('select pa.* from :table_product_attributes pa, :table_templates_boxes tb where tb.code = :code and tb.modules_group = :modules_group and tb.id = pa.id and unix_timestamp(now()) > unix_timestamp(str_to_date(pa.value, "%Y-%m-%d"))'); $Qcheck->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES); $Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qcheck->bindValue(':code', 'date_available'); $Qcheck->bindValue(':modules_group', 'product_attributes'); $Qcheck->execute(); if ($Qcheck->numberOfRows()) { $Qdelete = $osC_Database->query('delete from :table_product_attributes where id = :id and products_id = :products_id'); $Qdelete->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES); $Qdelete->bindInt(':id', $Qcheck->valueInt('id')); $Qdelete->bindInt(':products_id', $Qcheck->valueInt('products_id')); $Qdelete->execute(); } if (!empty($_GET['action'])) { switch ($_GET['action']) { case 'save': $this->_page_contents = 'edit.php'; if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { $data = array('date_available' => $_POST['products_date_available']); if (osC_Products_Admin::setDateAvailable($_GET['pID'], $data)) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'])); } break; } } }
public function __construct() { Registry::get('Language')->loadIniFile('modules/Dashboard/Products.php'); $this->_title = OSCOM::getDef('admin_indexmodules_products_title'); $this->_title_link = OSCOM::getLink(null, 'Products'); if (Access::hasAccess(OSCOM::getSite(), 'Products')) { if (!isset($osC_Currencies)) { if (!class_exists('osC_Currencies')) { include 'includes/classes/currencies.php'; } $osC_Currencies = new osC_Currencies(); } $this->_data = '<table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">' . ' <thead>' . ' <tr>' . ' <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_products') . '</th>' . ' <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_price') . '</th>' . ' <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_date') . '</th>' . ' <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_status') . '</th>' . ' </tr>' . ' </thead>' . ' <tbody>'; $Qproducts = Registry::get('PDO')->query('select products_id, greatest(products_date_added, products_last_modified) as date_last_modified from :table_products where parent_id is null order by date_last_modified desc limit 6'); $Qproducts->execute(); $counter = 0; while ($Qproducts->fetch()) { $data = osC_Products_Admin::get($Qproducts->valueInt('products_id')); $products_icon = osc_icon('products.png'); $products_price = $data['products_price']; if (!empty($data['variants'])) { $products_icon = osc_icon('attach.png'); $products_price = null; foreach ($data['variants'] as $variant) { if ($products_price === null || $variant['data']['price'] < $products_price) { $products_price = $variant['data']['price']; } } if ($products_price === null) { $products_price = 0; } } $this->_data .= ' <tr onmouseover="$(this).addClass(\'mouseOver\');" onmouseout="$(this).removeClass(\'mouseOver\');"' . ($counter % 2 ? ' class="alt"' : '') . '>' . ' <td>' . osc_link_object(OSCOM::getLink(null, 'Products', 'id=' . (int) $data['products_id'] . '&action=save'), $products_icon . ' ' . osc_output_string_protected($data['products_name'])) . '</td>' . ' <td>' . (!empty($data['variants']) ? 'from ' : '') . $osC_Currencies->format($products_price) . '</td>' . ' <td>' . $Qproducts->value('date_last_modified') . '</td>' . ' <td align="center">' . osc_icon((int) $data['products_status'] === 1 ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif', null, null) . '</td>' . ' </tr>'; $counter++; } $this->_data .= ' </tbody>' . '</table>'; } }
public function __construct() { global $osC_Language, $osC_MessageStack; parent::__construct(); if (isset($_POST['batch']) && is_array($_POST['batch']) && !empty($_POST['batch'])) { $this->_page_contents = 'batch_delete.php'; if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { $error = false; foreach ($_POST['batch'] as $id) { if (!osC_Products_Admin::delete($id)) { $error = true; break; } } if ($error === false) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID'])); } } }
function batchSetStatus() { global $toC_Json, $osC_Language; $error = false; $batch = explode(',', $_REQUEST['batch']); foreach ($batch as $id) { if (!osC_Products_Admin::setStatus($id, isset($_REQUEST['status']) ? $_REQUEST['status'] : 1)) { $error = true; break; } } if ($error === false) { $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed')); } else { $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed')); } echo $toC_Json->encode($response); }
function delete($id) { global $osC_Database, $osC_CategoryTree; $error = false; if (is_numeric($id)) { $osC_CategoryTree->setBreadcrumbUsage(false); $categories = array_merge(array(array('id' => $id, 'text' => '')), $osC_CategoryTree->getTree($id)); $products = array(); $products_delete = array(); foreach ($categories as $c_entry) { $Qproducts = $osC_Database->query('select products_id from :table_products_to_categories where categories_id = :categories_id'); $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qproducts->bindInt(':categories_id', $c_entry['id']); $Qproducts->execute(); while ($Qproducts->next()) { $products[$Qproducts->valueInt('products_id')]['categories'][] = $c_entry['id']; } } foreach ($products as $key => $value) { $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id and categories_id not in :categories_id'); $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qcheck->bindInt(':products_id', $key); $Qcheck->bindRaw(':categories_id', '("' . implode('", "', $value['categories']) . '")'); $Qcheck->execute(); if ($Qcheck->valueInt('total') < 1) { $products_delete[$key] = $key; } } osc_set_time_limit(0); foreach ($categories as $c_entry) { $osC_Database->startTransaction(); $Qimage = $osC_Database->query('select categories_image from :table_categories where categories_id = :categories_id'); $Qimage->bindTable(':table_categories', TABLE_CATEGORIES); $Qimage->bindInt(':categories_id', $c_entry['id']); $Qimage->execute(); $image = $Qimage->value('categories_image'); if (!empty($image)) { $Qcheck = $osC_Database->query('select count(*) as image_count from :table_categories where categories_image = :categories_image'); $Qcheck->bindTable(':table_categories', TABLE_CATEGORIES); $Qcheck->bindValue(':categories_image', $image); $Qcheck->execute(); if ($Qcheck->valueInt('image_count') == 1) { $path = realpath('../' . DIR_WS_IMAGES . 'categories') . '\\' . $image; if (file_exists($path)) { unlink($path); } } } $Qc = $osC_Database->query('delete from :table_categories where categories_id = :categories_id'); $Qc->bindTable(':table_categories', TABLE_CATEGORIES); $Qc->bindInt(':categories_id', $c_entry['id']); $Qc->setLogging($_SESSION['module'], $id); $Qc->execute(); if ($osC_Database->isError()) { $error = true; } if ($error === false) { $Qratings = $osC_Database->query('delete from :table_categories_ratings where categories_id = :categories_id'); $Qratings->bindTable(':table_categories_ratings', TABLE_CATEGORIES_RATINGS); $Qratings->bindInt(':categories_id', $id); $Qratings->setLogging($_SESSION['module'], $id); $Qratings->execute(); if ($osC_Database->isError()) { $error = true; } } if ($error === false) { $Qcd = $osC_Database->query('delete from :table_categories_description where categories_id = :categories_id'); $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcd->bindInt(':categories_id', $c_entry['id']); $Qcd->setLogging($_SESSION['module'], $id); $Qcd->execute(); if (!$osC_Database->isError()) { $Qp2c = $osC_Database->query('delete from :table_products_to_categories where categories_id = :categories_id'); $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qp2c->bindInt(':categories_id', $c_entry['id']); $Qp2c->setLogging($_SESSION['module'], $id); $Qp2c->execute(); if (!$osC_Database->isError()) { $osC_Database->commitTransaction(); osC_Cache::clear('categories'); osC_Cache::clear('category_tree'); osC_Cache::clear('also_purchased'); osC_Cache::clear('sefu-products'); osC_Cache::clear('new_products'); if (!osc_empty($Qimage->value('categories_image'))) { $Qcheck = $osC_Database->query('select count(*) as total from :table_categories where categories_image = :categories_image'); $Qcheck->bindTable(':table_categories', TABLE_CATEGORIES); $Qcheck->bindValue(':categories_image', $Qimage->value('categories_image')); $Qcheck->execute(); if ($Qcheck->numberOfRows() === 0) { if (file_exists(realpath('../' . DIR_WS_IMAGES . 'categories/' . $Qimage->value('categories_image')))) { @unlink(realpath('../' . DIR_WS_IMAGES . 'categories/' . $Qimage->value('categories_image'))); } } } } else { $osC_Database->rollbackTransaction(); } } else { $osC_Database->rollbackTransaction(); } } else { $osC_Database->rollbackTransaction(); } } foreach ($products_delete as $id) { osC_Products_Admin::delete($id); } osC_Cache::clear('categories'); osC_Cache::clear('category_tree'); osC_Cache::clear('also_purchased'); osC_Cache::clear('sefu-products'); osC_Cache::clear('new_products'); return true; } return false; }
<?php /* $Id: $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2009 osCommerce This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 (1991) as published by the Free Software Foundation. */ $osC_ObjectInfo = new osC_ObjectInfo(osC_Products_Admin::get($_GET[$osC_Template->getModule()])); $in_categories = array(); $Qcategories = $osC_Database->query('select categories_id from :table_products_to_categories where products_id = :products_id'); $Qcategories->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qcategories->bindInt(':products_id', $osC_ObjectInfo->get('products_id')); $Qcategories->execute(); while ($Qcategories->next()) { $in_categories[] = $Qcategories->valueInt('categories_id'); } $categories_array = array(); foreach ($in_categories as $category_id) { $categories_array[] = array('id' => $category_id, 'text' => $osC_CategoryTree->getPath($category_id, 0, ' » ')); } ?> <h1><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()), $osC_Template->getPageTitle());
function delete($id, $delete_image = false, $delete_products = false) { global $osC_Database; if ($delete_image === true) { $Qimage = $osC_Database->query('select manufacturers_image from :table_manufacturers where manufacturers_id = :manufacturers_id'); $Qimage->bindTable(':table_manufacturers', TABLE_MANUFACTURERS); $Qimage->bindInt(':manufacturers_id', $id); $Qimage->execute(); if ($Qimage->numberOfRows() && !osc_empty($Qimage->value('manufacturers_image'))) { if (file_exists(realpath('../' . DIR_WS_IMAGES . 'manufacturers/' . $Qimage->value('manufacturers_image')))) { @unlink(realpath('../' . DIR_WS_IMAGES . 'manufacturers/' . $Qimage->value('manufacturers_image'))); } } } $Qm = $osC_Database->query('delete from :table_manufacturers where manufacturers_id = :manufacturers_id'); $Qm->bindTable(':table_manufacturers', TABLE_MANUFACTURERS); $Qm->bindInt(':manufacturers_id', $id); $Qm->setLogging($_SESSION['module'], $id); $Qm->execute(); $Qmi = $osC_Database->query('delete from :table_manufacturers_info where manufacturers_id = :manufacturers_id'); $Qmi->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO); $Qmi->bindInt(':manufacturers_id', $id); $Qmi->setLogging($_SESSION['module'], $id); $Qmi->execute(); if ($delete_products === true) { $Qproducts = $osC_Database->query('select products_id from :table_products where manufacturers_id = :manufacturers_id'); $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->bindInt(':manufacturers_id', $id); $Qproducts->execute(); while ($Qproducts->next()) { osC_Products_Admin::delete($Qproducts->valueInt('products_id')); } } else { $Qupdate = $osC_Database->query('update :table_products set manufacturers_id = null where manufacturers_id = :manufacturers_id'); $Qupdate->bindTable(':table_products', TABLE_PRODUCTS); $Qupdate->bindInt(':manufacturers_id', $id); $Qupdate->setLogging($_SESSION['module'], $id); $Qupdate->execute(); } osC_Cache::clear('manufacturers'); return true; }
public function __construct() { global $osC_Language, $osC_MessageStack; parent::__construct(); $this->_page_contents = 'edit.php'; if ((osc_empty(CFG_APP_IMAGEMAGICK_CONVERT) || !file_exists(CFG_APP_IMAGEMAGICK_CONVERT)) && !osC_Image_Admin::hasGDSupport()) { $osC_MessageStack->add('header', $osC_Language->get('ms_warning_image_processor_not_available'), 'warning'); } if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { $error = false; $data = array('quantity' => isset($_POST['products_quantity']) ? $_POST['products_quantity'] : 0, 'price' => is_numeric($_POST['products_price']) ? $_POST['products_price'] : 0, 'weight' => isset($_POST['products_weight']) ? $_POST['products_weight'] : 0, 'weight_class' => isset($_POST['products_weight_class']) ? $_POST['products_weight_class'] : '', 'status' => $_POST['products_status'], 'model' => isset($_POST['products_model']) ? $_POST['products_model'] : '', 'tax_class_id' => $_POST['products_tax_class_id'], 'products_name' => $_POST['products_name'], 'products_description' => $_POST['products_description'], 'products_keyword' => $_POST['products_keyword'], 'products_tags' => $_POST['products_tags'], 'products_url' => $_POST['products_url']); if (isset($_POST['attributes'])) { $data['attributes'] = $_POST['attributes']; } if (isset($_POST['categories'])) { $data['categories'] = $_POST['categories']; } if (isset($_POST['localimages'])) { $data['localimages'] = $_POST['localimages']; } if (isset($_POST['variants_tax_class_id'])) { $data['variants_tax_class_id'] = $_POST['variants_tax_class_id']; } if (isset($_POST['variants_price'])) { $data['variants_price'] = $_POST['variants_price']; } if (isset($_POST['variants_model'])) { $data['variants_model'] = $_POST['variants_model']; } if (isset($_POST['variants_quantity'])) { $data['variants_quantity'] = $_POST['variants_quantity']; } if (isset($_POST['variants_combo'])) { $data['variants_combo'] = $_POST['variants_combo']; } if (isset($_POST['variants_combo_db'])) { $data['variants_combo_db'] = $_POST['variants_combo_db']; } if (isset($_POST['variants_weight'])) { $data['variants_weight'] = $_POST['variants_weight']; } if (isset($_POST['variants_weight_class'])) { $data['variants_weight_class'] = $_POST['variants_weight_class']; } if (isset($_POST['variants_status'])) { $data['variants_status'] = $_POST['variants_status']; } if (isset($_POST['variants_default_combo'])) { $data['variants_default_combo'] = $_POST['variants_default_combo']; } foreach ($data['products_keyword'] as $value) { if (empty($value)) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_product_keyword_empty'), 'error'); $error = true; } elseif (preg_match('/^[a-z0-9_-]+$/iD', $value) !== 1) { $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_product_keyword_invalid'), osc_output_string_protected($value)), 'error'); $error = true; } if (osC_Products_Admin::getKeywordCount($value, isset($_GET[$this->_module]) && is_numeric($_GET[$this->_module]) ? $_GET[$this->_module] : null) > 0) { $osC_MessageStack->add($this->_module, sprintf($osC_Language->get('ms_error_product_keyword_exists'), osc_output_string_protected($value)), 'error'); $error = true; } } if ($error === false) { if (osC_Products_Admin::save(isset($_GET[$this->_module]) && is_numeric($_GET[$this->_module]) ? $_GET[$this->_module] : null, $data)) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID'])); } } }
<?php /* $Id: $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2009 osCommerce This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 (1991) as published by the Free Software Foundation. */ $osC_ObjectInfo = new osC_ObjectInfo(osC_Products_Admin::get($_GET['pID'])); $Qdata = $osC_Database->query('select str_to_date(pa.value, "%Y-%m-%d") as products_date_available from :table_product_attributes pa, :table_templates_boxes tb where tb.code = :code and tb.modules_group = :modules_group and tb.id = pa.id'); $Qdata->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES); $Qdata->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qdata->bindValue(':code', 'date_available'); $Qdata->bindValue(':modules_group', 'product_attributes'); $Qdata->execute(); $osC_ObjectInfo->set('products_date_available', $Qdata->value('products_date_available')); ?> <h1><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()), $osC_Template->getPageTitle()); ?> </h1> <?php if ($osC_MessageStack->exists($osC_Template->getModule())) {