[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path Zen Cart 源代码 quick_updates.php
<?php
/**
* @package admin
* @copyright Portions Copyright 2006 Paul Mathot http://www.beterelektro.nl/zen-cart
* @copyright Copyright 2006 Andrew Berezin andrew@eCommerce-service.com
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version quick_updates 2.05
*/
require('includes/application_top.php');
// to add a products column look for:
// added for QUICKUPDATES_NEW_COLUMN_1
// and use it as an example to add your own
// added for QUICKUPDATES_NEW_COLUMN_1
// note: these 3 settings have been moved to config file (extra_configures/quick_updates.php)
//define('QUICKUPDATES_MODIFY_NEW_COLUMN_1', 'true');
//define('QUICKUPDATES_NEW_COLUMN_1', 'products_artlid');
//define('TABLE_HEADING_NEW_COLUMN_1', 'artlid');
$export_products = array();
// ? without this line the taxprice will be rounded to 0 decimals
$currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] = 4;
// bof GET paramaters to/from $_SESSION array & product copy stuff
if ($_POST['quick_copy_from_id'] > 0)
$_SESSION['quick_updates']['quick_copy_from_id'] = (int)$_POST['quick_copy_from_id'];
if (!((int)$_SESSION['quick_updates']['quick_copy_from_id']) > 0)
$_SESSION['quick_updates']['quick_copy_from_id'] = (int)QUICKUPDATES_COPY_PRODUCT_ID_DEFAULT;
if (isset($_POST['quick_copy_number']))
$_SESSION['quick_updates']['quick_copy_number'] = (int)$_POST['quick_copy_number'];
if (!(isset($_SESSION['quick_updates']['quick_copy_number'])))
$_SESSION['quick_updates']['quick_copy_number'] = 0;
////
// This module changes the $_POST array! (moves import data to $_POST['quick_updates_new'])
if(is_file(DIR_WS_MODULES . 'quick_import.php')) include_once(DIR_WS_MODULES . 'quick_import.php');
if (isset($_GET['products_status']))
/// do not convert to int here! (conversion is done later anyway)
$_SESSION['quick_updates']['products_status'] = zen_db_prepare_input($_GET['products_status']);
// set the products_status view back to all (is not numeric) if a product has been copied (copied products are inactive by default)
if(!isset($_SESSION['quick_updates']['products_status']) || $_POST['quick_updates_copy'])
$_SESSION['quick_updates']['products_status'] = 'all';
if (isset($_REQUEST['categories_switch']))
$_SESSION['quick_updates']['categories_switch'] = zen_db_prepare_input($_REQUEST['categories_switch']);
if(!isset($_SESSION['quick_updates']['categories_switch']))
$_SESSION['quick_updates']['categories_switch'] = 'linked_cats'; // or master_cats
$sort_by = 'p.products_id DESC';
if (isset($_GET['sort_by']))
$_SESSION['quick_updates']['sort_by'] = zen_db_prepare_input($_GET['sort_by']);
if(isset($_SESSION['quick_updates']['sort_by']))
$sort_by = $_SESSION['quick_updates']['sort_by'];
// by default show most recent added products first
$reset_editor = 1;
if (isset($_GET['reset_editor']))
$_SESSION['quick_updates']['reset_editor'] = (int)$_GET['reset_editor'];
if(isset($_SESSION['quick_updates']['reset_editor']))
$reset_editor = $_SESSION['quick_updates']['reset_editor'];
// possible to default to the editor set in admin?
// using the stored pagenumber doesn't always make sense, reset it in that cases
if(isset($_POST['quick_updates_copy']) || isset($_REQUEST['row_by_page']) || isset($_REQUEST['products_status']) || isset($_REQUEST['sort_by']))
$_SESSION['quick_updates']['page'] = 1;
if($_REQUEST['page'])
$_SESSION['quick_updates']['page'] = (int)$_REQUEST['page'];
// define the szen for rollover lines per page
$row_bypage_array = array();
//for ($i = 10; $i <=100 ; $i=$i+5)
for ($i = 5; $i <= 320 ; $i=$i*2) {
$row_bypage_array[] = array('id' => $i,
'text' => $i);
}
// bof get tx classes
$tax_class_array = array(array('id' => '0', 'text' => NO_TAX_TEXT));
$classes = $db->Execute("select tax_class_id, tax_class_title
from " . TABLE_TAX_CLASS . "
order by tax_class_title");
while (!$classes->EOF) {
$tax_class_array[] = array('id' => $classes->fields['tax_class_id'],
'text' => $classes->fields['tax_class_title']);
$classes->MoveNext();
}
// eof get tx classes
// bof get manufacturers
$manufacturers_array = array(array('id' => '0', 'text' => NO_MANUFACTURER));
//$manufacturers_array = array(array('id' => '0', 'text' => TEXT_ALL_MANUFACTURERS));
$manufacturers = $db->Execute("select manufacturers_id, manufacturers_name
from " . TABLE_MANUFACTURERS . "
order by manufacturers_name");
while (!$manufacturers->EOF) {
$manufacturers_array[] = array('id' => $manufacturers->fields['manufacturers_id'],
'text' => $manufacturers->fields['manufacturers_name']);
$manufacturers->MoveNext();
}
// eof get manufacturers
// bof get category_tree
$quick_updates_category_tree = zen_get_category_tree();
// eof get category_tree
// bof Update database
switch ($_GET['action']) {
case 'update' :
// bof prepare al new data for database input
if(sizeof($_POST['quick_updates_new']) > 0){
foreach($_POST['quick_updates_new'] as $key => $value){
// $value is an array here (contains values like ['products_model'][$products_id] = '1' for example)
$_POST['quick_updates_new'][$key] = zen_db_prepare_input($value);
}
}
// eof prepare al new data for database input
$quick_updates_count = array();
if($_POST['quick_updates_new']['products_model']){;
foreach($_POST['quick_updates_new']['products_model'] as $products_id => $new_value) {
if (trim($_POST['quick_updates_new']['products_model'][$products_id]) != trim($_POST['quick_updates_old']['products_model'][$products_id])) {
$quick_updates_count['products_model'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_model='" . zen_db_input($new_value) . "', products_last_modified=NOW() WHERE products_id=" . (int)$products_id);
}
}
}
// added for QUICKUPDATES_NEW_COLUMN_1
if($_POST['quick_updates_new'][QUICKUPDATES_NEW_COLUMN_1]){
foreach($_POST['quick_updates_new'][QUICKUPDATES_NEW_COLUMN_1] as $products_id => $new_value) {
if ($_POST['quick_updates_new'][QUICKUPDATES_NEW_COLUMN_1][$products_id] != $_POST['quick_updates_old'][QUICKUPDATES_NEW_COLUMN_1][$products_id]) {
$quick_updates_count[QUICKUPDATES_NEW_COLUMN_1][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET " . QUICKUPDATES_NEW_COLUMN_1 . "='" . $new_value . "' WHERE products_id =" . (int)$products_id);
}
}
}
if($_POST['quick_updates_new']['products_name']){
foreach($_POST['quick_updates_new']['products_name'] as $products_id => $new_value) {
if (trim(stripslashes($_POST['quick_updates_new']['products_name'][$products_id])) != trim(stripslashes($_POST['quick_updates_old']['products_name'][$products_id]))) {
$quick_updates_count['products_name'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . " SET products_name='" . zen_db_input($new_value) . "' WHERE products_id=" . (int)$products_id . " and language_id=" . (int)$_SESSION['languages_id']);
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_last_modified=now() WHERE products_id=" . (int)$products_id);
}
}
}
if($_POST['quick_updates_new']['products_description']){
foreach($_POST['quick_updates_new']['products_description'] as $products_id => $new_value) {
if (trim(stripslashes($_POST['quick_updates_new']['products_description'][$products_id])) != trim(stripslashes($_POST['quick_updates_old']['products_description'][$products_id]))) {
$quick_updates_count['products_description'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS_DESCRIPTION . " SET products_description='" . zen_db_input($new_value) . "' WHERE products_id=" . (int)$products_id . " and language_id=" . (int)$_SESSION['languages_id']);
}
}
}
if($_POST['quick_updates_new']['products_price']){
foreach($_POST['quick_updates_new']['products_price'] as $products_id => $new_value) {
// we look if it's a price markup and if so we look if this product has been unchecked for the markup
if((!isset($_POST['flag_markup'])) || ($_POST['markup_checked'][$products_id] == true)){
// not doing markups, or this product is checked for markup
// (this saves a lot of obsolete hidden $_POST's, when not doing price markups)
$apply_price_update = true;
}else{
// doing markups, but this products is not checked
$apply_price_update = false;
}
if (($_POST['quick_updates_new']['products_price'][$products_id] != $_POST['quick_updates_old']['products_price'][$products_id]) && $apply_price_update) {
$quick_updates_count['products_price'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_price='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
// fix the sort order for prices (catalog side)
zen_update_products_price_sorter((int)$products_id);
}
}
}
if($_POST['quick_updates_new']['products_weight']){
foreach($_POST['quick_updates_new']['products_weight'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['products_weight'][$products_id] != $_POST['quick_updates_old']['products_weight'][$products_id]) {
$quick_updates_count['products_weight'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_weight='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
}
}
}
if($_POST['quick_updates_new']['products_quantity']){
foreach($_POST['quick_updates_new']['products_quantity'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['products_quantity'][$products_id] != $_POST['quick_updates_old']['products_quantity'][$products_id]) {
$quick_updates_count['products_quantity'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_quantity='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
}
}
}
if($_POST['quick_updates_new']['manufacturers_id']){
foreach($_POST['quick_updates_new']['manufacturers_id'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['manufacturers_id'][$products_id] != $_POST['quick_updates_old']['manufacturers_id'][$products_id]) {
$quick_updates_count['manufacturers_id'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET manufacturers_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
}
}
}
if($_POST['quick_updates_new']['products_sort_order']){
foreach($_POST['quick_updates_new']['products_sort_order'] as $products_id => $new_value) {
if (trim($_POST['quick_updates_new']['products_sort_order'][$products_id]) != trim($_POST['quick_updates_old']['products_sort_order'][$products_id])) {
$quick_updates_count['products_sort_order'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_sort_order='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
}
}
}
if($_POST['quick_updates_new']['products_image']){
foreach($_POST['quick_updates_new']['products_image'] as $products_id => $new_value) {
if (trim($_POST['quick_updates_new']['products_image'][$products_id]) != trim($_POST['quick_updates_old']['products_image'][$products_id])) {
$quick_updates_count['products_image'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_image='" . zen_db_input($new_value) . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
}
}
}
if($_POST['quick_updates_old']['products_status']){
foreach($_POST['quick_updates_old']['products_status'] as $products_id => $status) {
if(!isset($_POST['quick_updates_new']['products_status'][$products_id])) $_POST['quick_updates_new']['products_status'][$products_id] = '0';
if ($_POST['quick_updates_new']['products_status'][$products_id] != $_POST['quick_updates_old']['products_status'][$products_id]) {
$quick_updates_count['products_status'][$products_id] = $products_id;
zen_set_product_status((int)$products_id, (int)$_POST['quick_updates_new']['products_status'][$products_id]);
}
}
}
if($_POST['quick_updates_new']['products_tax_class_id']){
foreach($_POST['quick_updates_new']['products_tax_class_id'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['products_tax_class_id'][$products_id] != $_POST['quick_updates_old']['products_tax_class_id'][$products_id]) {
$quick_updates_count['products_tax_class_id'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_tax_class_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
}
}
}
if($_POST['quick_updates_new']['categories_id']){
foreach($_POST['quick_updates_new']['categories_id'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['categories_id'][$products_id] != $_POST['quick_updates_old']['categories_id'][$products_id]) {
if(zen_childs_in_category_count($new_value)) {
$messageStack->add(TEXT_CATEGORY_WITH_CHILDS . ' ' . zen_get_category_name($new_value, (int)$_SESSION["languages_id"]) . ' [' . $new_value . ']', 'error');
continue;
}
// if the categories_id that links the master_categories_id is updated, we update the master accordingly (to prevent invalid linked master id's)
if($_POST['quick_updates_old']['categories_id'] == $_POST['quick_updates_old']['master_categories_id']){
$quick_updates_count['master_categories_id'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET master_categories_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
zen_update_products_price_sorter((int)$products_id); // needed?
}
$quick_updates_count['categories_id'][$products_id] = $products_id;
//$db->Execute("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " SET categories_id='" . (int)$new_value . "', products_id=" . (int)$products_id . " WHERE products_id=" . (int)$products_id) . " AND categories_id=" . (int)$_POST['quick_updates_old']['categories_id'][$products_id]);
// changed INSERT INTO to UPDATE to prevent conflicts
$db->Execute("UPDATE " . TABLE_PRODUCTS_TO_CATEGORIES . " SET categories_id='" . (int)$new_value . "', products_id=" . (int)$products_id . " WHERE products_id=" . (int)$products_id . " AND categories_id=" . (int)$_POST['quick_updates_old']['categories_id'][$products_id]);
}
}
}
if($_POST['quick_updates_new']['master_categories_id']){
foreach($_POST['quick_updates_new']['master_categories_id'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['master_categories_id'][$products_id] != $_POST['quick_updates_old']['master_categories_id'][$products_id]) {
if(zen_childs_in_category_count($new_value)) {
$messageStack->add(TEXT_CATEGORY_WITH_CHILDS . ' ' . zen_get_category_name($new_value, (int)$_SESSION["languages_id"]) . ' [' . $new_value . ']', 'error');
continue;
}
// add invalid warning here?? (if the new master_cat is not linked)
$quick_updates_count['master_categories_id'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET master_categories_id='" . (int)$new_value . "', products_last_modified=now() WHERE products_id=" . (int)$products_id);
zen_update_products_price_sorter((int)$products_id); // needed?
}
}
}
// added for products_purchase_price and margin
if($_POST['quick_updates_new']['products_purchase_price']){
foreach($_POST['quick_updates_new']['products_purchase_price'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['products_purchase_price'][$products_id] != $_POST['quick_updates_old']['products_purchase_price'][$products_id]) {
$quick_updates_count['products_purchase_price'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_purchase_price='" . $new_value . "', products_last_modified=now() WHERE products_id =" . (int)$products_id);
}
}
}
// added for products_purchase_price and margin
if($_POST['quick_updates_new']['products_margin']){
foreach($_POST['quick_updates_new']['products_margin'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['products_margin'][$products_id] != $_POST['quick_updates_old']['products_margin'][$products_id]) {
$quick_updates_count['products_margin'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_margin='" . $new_value . "', products_last_modified=now() WHERE products_id =" . (int)$products_id);
}
}
}
// added for p.products_price_w
if($_POST['quick_updates_new']['products_price_w']){
foreach($_POST['quick_updates_new']['products_price_w'] as $products_id => $new_value) {
if ($_POST['quick_updates_new']['products_price_w'][$products_id] != $_POST['quick_updates_old']['products_price_w'][$products_id]) {
$quick_updates_count['products_price_w'][$products_id] = $products_id;
$db->Execute("UPDATE " . TABLE_PRODUCTS . " SET products_price_w='" . $new_value . "', products_last_modified=now() WHERE products_id =" . (int)$products_id);
}
}
}
case 'calcul' :
if ($_POST['price_markup']) $preview_markup_price = true;
break;
} // end switch ($_GET['action'])
// eof Update database
// bof get products data from db
//// control string sort page
if ($sort_by && !ereg('order by', $sort_by)){
$sort_by = 'order by ' . $sort_by ;
}else{
// added default sort order
$sort_by = 'order by ' . 'products_id DESC' ;
}
//// controle lenght (lines per page)
$split_page = $page;
if ($split_page > 1)
$rows = $split_page * MAX_DISPLAY_ROW_BY_PAGE - MAX_DISPLAY_ROW_BY_PAGE;
$extra_query = '';
// added for products_purchase_price and margin
if(QUICKUPDATES_MODIFY_PURCHASE_AND_MARGIN == 'true')
$extra_query .= ' p.products_purchase_price, p.products_margin,';
//// page splitter and display each products info
$products_split = new splitPageResults($split_page, MAX_DISPLAY_ROW_BY_PAGE, $products_query_raw, $products_query_numrows);
$products = $db->Execute($products_query_raw);
// eof get products data from db
// Let's start displaying page with forms
?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<link rel="stylesheet" type="text/css" href="includes/stylesheet_quick_updates.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/javascript/quick_updates_price_calculations.js"></script>
<script type="text/javascript">
<!--
function init()
{
cssjsmenu('navbar');
if (document.getElementById)
{
var kill = document.getElementById('hoverJS');
kill.disabled = true;
}
}
// $taxprice needs the $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] to be set (done at top of file)
// an alternative might be to use $price (i.s.o. $taxprice) and update it with updatGross('$products->fields['products_id']') for each product ?)
$tax_price = zen_add_tax($price, $tax_rate->fields['tax_rate']);
$tax_price = sprintf("%01.2f", round($tax_price, 4));
echo '</td>' . "\n";
// we need the old master_categories_id value in both cases
echo zen_draw_hidden_field('quick_updates_old[master_categories_id][' . $products->fields['products_id'] . ']', $products->fields['master_categories_id']);
echo $prod2cat_link;
echo '</td>' . "\n";