<?php
/**
 * @package admin
 * @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 $Id: copy_to_confirm.php 3380 2006-04-06 05:12:45Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
   
function install_quick_updates() {
	global $db;
	$project = PROJECT_VERSION_MAJOR.'.'.PROJECT_VERSION_MINOR;
	if ( (substr($project,0,5) == "1.3.8") || (substr($project,0,5) == "1.3.9") ) {
		$db->Execute("INSERT INTO ".TABLE_CONFIGURATION_GROUP." VALUES ('', 'Szybka aktualizacja produktów', 'Szybka aktualizacja produktów - konfiguracja', '1', '1')");
		$group_id = mysql_insert_id();
		$db->Execute("UPDATE ".TABLE_CONFIGURATION_GROUP." SET sort_order = ".$group_id." WHERE configuration_group_id = ".$group_id);
		$db->Execute("INSERT INTO ".TABLE_CONFIGURATION."  VALUES 
		(NULL, 'ID produktu','QUICKUPDATES_DISPLAY_ID', 'true','true = pokazuj<br />false = ukryj',".$group_id.", '1', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'), 
		(NULL, 'Obrazek produktu','QUICKUPDATES_DISPLAY_THUMBNAIL',   'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '2', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Kod/Model produktu',                        'QUICKUPDATES_MODIFY_MODEL','true','true = pokazuj<br />false = ukryj', ".$group_id.", '3', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Nazwa produktu','QUICKUPDATES_MODIFY_NAME','true', 'true = pokazuj<br />false = ukryj', ".$group_id.", '4', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Opis produktu','QUICKUPDATES_MODIFY_DESCRIPTION', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '5', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Status produktu','QUICKUPDATES_MODIFY_STATUS', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '6',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Waga produktu', 'QUICKUPDATES_MODIFY_WEIGHT', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '7',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Stan magazynowy produktu','QUICKUPDATES_MODIFY_QUANTITY', 'true',  'true = pokazuj<br />false = ukryj',".$group_id.", '8',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Producent', 'QUICKUPDATES_MODIFY_MANUFACTURER', 'false', 'true = pokazuj<br />false = ukryj', ".$group_id.", '9',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Stawka podatku', 'QUICKUPDATES_MODIFY_TAX','false', 'true = pokazuj<br />false = ukryj', ".$group_id.", '10', NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Kategorie', 'QUICKUPDATES_MODIFY_CATEGORY','true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '11', NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Ceny brutto',  'QUICKUPDATES_DISPLAY_TVA_OVER',    'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '20', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Link do podglądu strony produktu',                       'QUICKUPDATES_DISPLAY_PREVIEW', 'false', 'true = pokazuj<br />false = ukryj ',                      ".$group_id.", '30', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Link do strony edycji produktu', 'QUICKUPDATES_DISPLAY_EDIT',               'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '31', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Masowa zmiana cen produktów', 'QUICKUPDATES_ACTIVATE_COMMERCIAL_MARGIN', 'true','true = pokazuj<br />false = ukryj',".$group_id.", '40', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Przyciski sortowania wyników', 'QUICKUPDATES_MODIFY_SORT_ORDER', 'true', 'true = pokazuj<br />false = ukryj', ".$group_id.", '12', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Szybka edycja opisu produktu', 'QUICKUPDATES_MODIFY_DESCRIPTION_POPUP', 'true', 'true = pokazuj<br />false = ukryj', ".$group_id.", '13', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),') ");
	} elseif (substr($project,0,3) == "1.5") {
		$db->Execute("INSERT INTO ".TABLE_CONFIGURATION_GROUP." VALUES ('', 'Szybka aktualizacja produktów', 'Szybka aktualizacja produktów - konfiguracja', '1', '1')");
		$group_id = mysql_insert_id();
		$db->Execute("UPDATE ".TABLE_CONFIGURATION_GROUP." SET sort_order = ".$group_id." WHERE configuration_group_id = ".$group_id);
        zen_register_admin_page('quick_updates_config', 'BOX_CATALOG_QUICK_UPDATES','FILENAME_CONFIGURATION', 'gID='.$group_id, 'configuration', 'Y', 103);
		$db->Execute("INSERT INTO ".TABLE_CONFIGURATION."  VALUES 
		(NULL, 'ID produktu', 'QUICKUPDATES_DISPLAY_ID', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '1', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'), 
		(NULL, 'Obrazek produktu', 'QUICKUPDATES_DISPLAY_THUMBNAIL',   'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '2', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Kod/Model produktu', 'QUICKUPDATES_MODIFY_MODEL', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '3', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Nazwa produktu', 'QUICKUPDATES_MODIFY_NAME', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '4', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Opis produktu', 'QUICKUPDATES_MODIFY_DESCRIPTION', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '5', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Status produktu', 'QUICKUPDATES_MODIFY_STATUS', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '6',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Waga produktu', 'QUICKUPDATES_MODIFY_WEIGHT', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '7',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Stan magazynowy produktu', 'QUICKUPDATES_MODIFY_QUANTITY', 'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '8',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Producent', 'QUICKUPDATES_MODIFY_MANUFACTURER', 'false', 'true = pokazuj<br />false = ukryj', ".$group_id.", '9',  NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Stawka podatku', 'QUICKUPDATES_MODIFY_TAX', 'false', 'true = pokazuj<br />false = ukryj', ".$group_id.", '10', NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Kategoria produktu', 'QUICKUPDATES_MODIFY_CATEGORY', 'true', 'true = pokazuj<br />false = ukryj', ".$group_id.", '11', NULL, NOW(), NULL,  'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Cena brutto',  'QUICKUPDATES_DISPLAY_TVA_OVER',    'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '20', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Link do strony informacyjnej produktu w sklepie',                       'QUICKUPDATES_DISPLAY_PREVIEW', 'false', 'true = pokazuj<br />false = ukryj ', ".$group_id.", '30', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Link do strony pełnej edycji produktu', 'QUICKUPDATES_DISPLAY_EDIT',               'true',  'true = pokazuj<br />false = ukryj', ".$group_id.", '31', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Masowa zmiana cen produktów',                                'QUICKUPDATES_ACTIVATE_COMMERCIAL_MARGIN', 'true',  'true = pokazuj<br />false = ukryj',".$group_id.", '40', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Przyciski sortowania wyników',                   'QUICKUPDATES_MODIFY_SORT_ORDER', 'true', 'true = pokazuj<br />false = ukryj',               ".$group_id.", '12', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),'),
		(NULL, 'Szybka edycja opisu produktu w oknie pop-up',                          'QUICKUPDATES_MODIFY_DESCRIPTION_POPUP', 'true', 'true = pokazuj<br />false = ukryj', ".$group_id.", '13', NULL, NOW(), NULL, 'zen_cfg_select_option(array(\"true\", \"false\"),') ");
	} else { // unsupported version 
		// i should do something here!
	} 
}

function remove_quick_updates() {
	global $db;
	$project = PROJECT_VERSION_MAJOR.'.'.PROJECT_VERSION_MINOR;
	if ( (substr($project,0,5) == "1.3.8") || (substr($project,0,5) == "1.3.9") ) {
		$sql = "SELECT configuration_group_id FROM ".TABLE_CONFIGURATION_GROUP." WHERE configuration_group_title = 'Szybka aktualizacja produktów' LIMIT 1";
		$result = mysql_query($sql);;
		if (mysql_num_rows($result)) { 
			$group_id =  mysql_fetch_array($result);
			$db->Execute("DELETE FROM ".TABLE_CONFIGURATION." WHERE configuration_group_id = ".$group_id[0]);
			$db->Execute("DELETE FROM ".TABLE_CONFIGURATION_GROUP." WHERE configuration_group_id = ".$group_id[0]);
		}
	} elseif (substr($project,0,3) == "1.5") {
		$sql = "SELECT configuration_group_id FROM ".TABLE_CONFIGURATION_GROUP." WHERE configuration_group_title = 'Szybka aktualizacja produktów' LIMIT 1";
		$result = mysql_query($sql);;
		if (mysql_num_rows($result)) { 
			$group_id =  mysql_fetch_array($result);
			$db->Execute("DELETE FROM ".TABLE_CONFIGURATION." WHERE configuration_group_id = ".$group_id[0]);
			$db->Execute("DELETE FROM ".TABLE_CONFIGURATION_GROUP." WHERE configuration_group_id = ".$group_id[0]);
			$db->Execute("DELETE FROM ".TABLE_ADMIN_PAGES." WHERE page_key = 'quick_updates'");
			$db->Execute("DELETE FROM ".TABLE_ADMIN_PAGES." WHERE page_key = 'quick_updates_config'");
		}
	} else { // unsupported version 
	} 
}
?>