Jump to content
Sign in to follow this  
digicammad

Specials valid from

Recommended Posts

I have just installed the above contribution, which lets you set a date from which the specials are valid.

 

I have just added a special with a valid from date of April 1 2006, but it became active immediately. Does the code expect me to manually set the initial status of the special to inactive, or is there some sort of problem?

 

Cheers

Share this post


Link to post
Share on other sites

I've also just noticed that if you amend the dates of a special offer they don't get saved, although inserts and deletes work okay.

Share this post


Link to post
Share on other sites

1. If the date is in the future, the offer should be disabled from the start (no manual intervention).

2. Most users of this contribution are using other contributions and failed to adapt some of my modifications to match their setup.

3. Can you please tell me how the product record looks like before and afterwards? (you may mail them to me directly if you do not want to disclose the connected information).

4. For debugging purposes I would suggest that you surround the sql clauses from my contribution with echo and post them here so you can see what is done in the database.

 

fs

Share this post


Link to post
Share on other sites

I'm just wondering if any-one's using this contribution successfully (http://www.oscommerce.com/community/contributions,2520/category,all/search,specials+valid+from)? It's a great idea, but I'm having a fair bit of trouble implementing it in a store with SPPC installed. At the moment, when a special is modified, it doesn't save the modification and it enters a new special into the database with products_id = 0. This means that everything in my store changes it's price to this new special's.

 

Any one out there with some hints?

 

Thanks,

~Barbara~

Edited by bobsi18

Share this post


Link to post
Share on other sites
I have just installed the above contribution, which lets you set a date from which the specials are valid.

 

I have just added a special with a valid from date of April 1 2006, but it became active immediately. Does the code expect me to manually set the initial status of the special to inactive, or is there some sort of problem?

 

Cheers

I'm having the same problem. Any ideas?

Share this post


Link to post
Share on other sites

Hi,

 

I have just installed this - but I am getting:

"Your specials.php was patched incorrectly. Look especially for all calls of showCalendar and if they have at least 6 parameters."

 

I have checked and rechecked and all the changes have been made - but it is not working for some reason.

 

here is my specials.php

 

<?php
/*
 $Id: specials.php,v 1.41 2003/06/29 22:50:52 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 if (tep_not_null($action)) {
switch ($action) {
  case 'setflag':
	tep_set_specials_status($HTTP_GET_VARS['id'], $HTTP_GET_VARS['flag']);

	tep_redirect(tep_href_link(FILENAME_SPECIALS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'sID=' . $HTTP_GET_VARS['id'], 'NONSSL'));
	break;
  case 'insert':
	$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
	$products_price = tep_db_prepare_input($HTTP_POST_VARS['products_price']);
	$specials_price = tep_db_prepare_input($HTTP_POST_VARS['specials_price']);
// added for specials valid from:
//		$day = tep_db_prepare_input($HTTP_POST_VARS['day']);
//		$month = tep_db_prepare_input($HTTP_POST_VARS['month']);
//		$year = tep_db_prepare_input($HTTP_POST_VARS['year']);

	$day = tep_db_prepare_input($HTTP_POST_VARS['day']);
	$month = tep_db_prepare_input($HTTP_POST_VARS['month']);
	$year = tep_db_prepare_input($HTTP_POST_VARS['year']);
	$vday = tep_db_prepare_input($HTTP_POST_VARS['vday']);
	$vmonth = tep_db_prepare_input($HTTP_POST_VARS['vmonth']);
	$vyear = tep_db_prepare_input($HTTP_POST_VARS['vyear']);

	// check if valid from date is later than expires date
	if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year) &&
		tep_not_null($vday) && tep_not_null($vmonth) && tep_not_null($vyear)) {

		if (($vyear > $year) ||
			($vmonth > $month && $vyear == $year) ||
			($vday > $day && $vmonth == $month && $vyear == $year))
			{
				// if so, swap the dates
				$tempdate = $vyear; $vyear = $year; $year = $tempdate;
				$tempdate = $month; $vmonth = $month; $month = $tempdate;
				$tempdate = $vday; $vday = $day; $day = $tempdate;
			}
	}

// end specials valid from
	if (substr($specials_price, -1) == '%') {
	  $new_special_insert_query = tep_db_query("select products_id, products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	  $new_special_insert = tep_db_fetch_array($new_special_insert_query);

	  $products_price = $new_special_insert['products_price'];
	  $specials_price = ($products_price - (($specials_price / 100) * $products_price));
	}

	$expires_date = '';
	if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year)) {
	  $expires_date = $year;
	  $expires_date .= (strlen($month) == 1) ? '0' . $month : $month;
	  $expires_date .= (strlen($day) == 1) ? '0' . $day : $day;
	}

	$validfrom_date = '';
	if (tep_not_null($vday) && tep_not_null($vmonth) && tep_not_null($vyear)) {
	  $validfrom_date = $vyear;
	  $validfrom_date .= (strlen($vmonth) == 1) ? '0' . $vmonth : $vmonth;
	  $validfrom_date .= (strlen($vday) == 1) ? '0' . $vday : $vday;
	}

//		tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', now(), '" . tep_db_input($expires_date) . "', '1')");

	$result = tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status, valid_from_date) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', now(), '" . tep_db_input($expires_date) . "', '1', '".  tep_db_input($validfrom_date)  ."')");

	// maybe the special product must be deactivated or actived (depending on wether the valid from/expires dates had been changed)
	if ($result == 1) {
		$new_specials_id = tep_db_insert_id();
		tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where (now() < valid_from_date) and specials_id = '" . (int)$new_specials_id . "'");
		tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where ((expires_date < now()) and expires_date > 0) and specials_id = '" . (int)$new_specials_id . "'");
		tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (now() >= valid_from_date and now() < expires_date) and specials_id = '" . (int)$new_specials_id . "'");
	}

	tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page']));
	break;
  case 'update':
	$specials_id = tep_db_prepare_input($HTTP_POST_VARS['specials_id']);
	$products_price = tep_db_prepare_input($HTTP_POST_VARS['products_price']);
	$specials_price = tep_db_prepare_input($HTTP_POST_VARS['specials_price']);
	$day = tep_db_prepare_input($HTTP_POST_VARS['day']);
	$month = tep_db_prepare_input($HTTP_POST_VARS['month']);
	$year = tep_db_prepare_input($HTTP_POST_VARS['year']);
	$vday = tep_db_prepare_input($HTTP_POST_VARS['vday']);
	$vmonth = tep_db_prepare_input($HTTP_POST_VARS['vmonth']);
	$vyear = tep_db_prepare_input($HTTP_POST_VARS['vyear']);

	// check if valid from date is later than expires date
	if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year) &&
		tep_not_null($vday) && tep_not_null($vmonth) && tep_not_null($vyear)) {

		if (($vyear > $year) ||
			($vmonth > $month && $vyear == $year) ||
			($vday > $day && $vmonth == $month && $vyear == $year))
			{
				// if so, swap the dates
				$tempdate = $vyear; $vyear = $year; $year = $tempdate;
				$tempdate = $month; $vmonth = $month; $month = $tempdate;
				$tempdate = $vday; $vday = $day; $day = $tempdate;
			}
	}

	if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price));

	$expires_date = '';
	if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year)) {
	  $expires_date = $year;
	  $expires_date .= (strlen($month) == 1) ? '0' . $month : $month;
	  $expires_date .= (strlen($day) == 1) ? '0' . $day : $day;
	}

	$validfrom_date = '';
	if (tep_not_null($vday) && tep_not_null($vmonth) && tep_not_null($vyear)) {
	  $validfrom_date = $vyear;
	  $validfrom_date .= (strlen($vmonth) == 1) ? '0' . $vmonth : $vmonth;
	  $validfrom_date .= (strlen($vday) == 1) ? '0' . $vday : $vday;
	}

//		tep_db_query("update " . TABLE_SPECIALS . " set specials_new_products_price = '" . tep_db_input($specials_price) . "', specials_last_modified = now(), expires_date = '" . tep_db_input($expires_date) . "' where specials_id = '" . (int)$specials_id . "'");

	$result = tep_db_query("update " . TABLE_SPECIALS . " set specials_new_products_price = '" . tep_db_input($specials_price) . "', specials_last_modified = now(), expires_date = '" . tep_db_input($expires_date) . "', valid_from_date = '" . tep_db_input($validfrom_date) . "'  where specials_id = '" . (int)$specials_id . "'");

	// maybe the special product must be deactivated or actived (depending on wether the valid from/expires dates had been changed)
if ($result == 1) {
		$new_specials_id = tep_db_insert_id();
		tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where (now() < valid_from_date) and specials_id = '" . (int)$new_specials_id . "'");
		tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where ((expires_date < now()) and expires_date > 0) and specials_id = '" . (int)$new_specials_id . "'");
		tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (now() >= valid_from_date and now() < expires_date) and specials_id = '" . (int)$new_specials_id . "'");
	}

	tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials_id));
	break;
  case 'deleteconfirm':
	$specials_id = tep_db_prepare_input($HTTP_GET_VARS['sID']);

	tep_db_query("delete from " . TABLE_SPECIALS . " where specials_id = '" . (int)$specials_id . "'");

	tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page']));
	break;
}
 }
?>
<!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">
<script language="javascript" src="includes/general.js"></script>
<?php
 if ( ($action == 'new') || ($action == 'edit') ) {
?>
<link rel="stylesheet" type="text/css" href="includes/javascript/calendar.css">
<script language="JavaScript" src="includes/javascript/calendarcode.js"></script>
<?php
 }
?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="popupcalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
	<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
	  </tr>
	</table></td>
  </tr>
<?php
 if ( ($action == 'new') || ($action == 'edit') ) {
$form_action = 'insert';
if ( ($action == 'edit') && isset($HTTP_GET_VARS['sID']) ) {
  $form_action = 'update';

//	  $product_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, s.specials_new_products_price, s.expires_date from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id and s.specials_id = '" . (int)$HTTP_GET_VARS['sID'] . "'");

  $product_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, s.specials_new_products_price, s.expires_date, s.valid_from_date from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id and s.specials_id = '" . (int)$HTTP_GET_VARS['sID'] . "'");

  $product = tep_db_fetch_array($product_query);

  $sInfo = new objectInfo($product);
} else {
  $sInfo = new objectInfo(array());

// create an array of products on special, which will be excluded from the pull down menu of products
// (when creating a new product on special)
  $specials_array = array();
  $specials_query = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s where s.products_id = p.products_id");
  while ($specials = tep_db_fetch_array($specials_query)) {
	$specials_array[] = $specials['products_id'];
  }
}
?>
  <tr><form name="new_special" <?php echo 'action="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action', 'info', 'sID')) . 'action=' . $form_action, 'NONSSL') . '"'; ?> method="post"><?php if ($form_action == 'update') echo tep_draw_hidden_field('specials_id', $HTTP_GET_VARS['sID']); ?>
	<td><br><table border="0" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><?php echo TEXT_SPECIALS_PRODUCT; ?> </td>
		<td class="main"><?php echo (isset($sInfo->products_name)) ? $sInfo->products_name . ' <small>(' . $currencies->format($sInfo->products_price) . ')</small>' : tep_draw_products_pull_down('products_id', 'style="font-size:10px"', $specials_array); echo tep_draw_hidden_field('products_price', (isset($sInfo->products_price) ? $sInfo->products_price : '')); ?></td>
	  </tr>
	  <tr>
		<td class="main"><?php echo TEXT_SPECIALS_SPECIAL_PRICE; ?> </td>
		<td class="main"><?php echo tep_draw_input_field('specials_price', (isset($sInfo->specials_new_products_price) ? $sInfo->specials_new_products_price : '')); ?></td>
	  </tr>
	  <tr>
		<td class="main"><?php echo TEXT_SPECIALS_VALIDFROM_DATE; ?> </td>
		<td class="main"><?php echo tep_draw_input_field('vday', (isset($sInfo->valid_from_date) ? substr($sInfo->valid_from_date, 8, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('vmonth', (isset($sInfo->valid_from_date) ? substr($sInfo->valid_from_date, 5, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('vyear', (isset($sInfo->valid_from_date) ? substr($sInfo->valid_from_date, 0, 4) : ''), 'size="4" maxlength="4" class="cal-TextBox"'); ?><a class="so-BtnLink" href="java script:calClick();return false;" onmouseover="calSwapImg('BTN_valid_date', 'img_Date_OVER',true);" onmouseout="calSwapImg('BTN_valid_date', 'img_Date_UP',true);" onclick="calSwapImg('BTN_valid_date', 'img_Date_DOWN');showCalendar('new_special','vday', 'vmonth', 'vyear','dte_valid_When','BTN_valid_date');return false;"><?php echo tep_image(DIR_WS_IMAGES . 'cal_date_up.gif', 'Calendar', '22', '17', 'align="absmiddle" name="BTN_valid_date"'); ?></a>
	  </tr>
	  <tr>
		<td class="main"><?php echo TEXT_SPECIALS_EXPIRES_DATE; ?> </td>
		<td class="main"><?php echo tep_draw_input_field('day', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 8, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('month', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 5, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('year', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 0, 4) : ''), 'size="4" maxlength="4" class="cal-TextBox"'); ?><a class="so-BtnLink" href="java script:calClick();return false;" onmouseover="calSwapImg('BTN_date', 'img_Date_OVER',true);" onmouseout="calSwapImg('BTN_date', 'img_Date_UP',true);" onclick="calSwapImg('BTN_date', 'img_Date_DOWN');showCalendar('new_special', 'day', 'month','year', 'dteWhen','BTN_date');return false;"><?php echo tep_image(DIR_WS_IMAGES . 'cal_date_up.gif', 'Calendar', '22', '17', 'align="absmiddle" name="BTN_date"'); ?></a></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>
		<td class="main" align="right" valign="top"><br><?php echo (($form_action == 'insert') ? tep_image_submit('button_insert.gif', IMAGE_INSERT) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). '   <a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . (isset($HTTP_GET_VARS['sID']) ? '&sID=' . $HTTP_GET_VARS['sID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
	  </tr>
	</table></td>
  </form></tr>
<?php
 } else {
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr class="dataTableHeadingRow">
			<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRODUCTS_PRICE; ?></td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
		  </tr>
<?php
//	$specials_query_raw = "select p.products_id, pd.products_name, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id order by pd.products_name";

$specials_query_raw = "select p.products_id, pd.products_name, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status, s.valid_from_date from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id order by pd.products_name";

$specials_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $specials_query_raw, $specials_query_numrows);
$specials_query = tep_db_query($specials_query_raw);
while ($specials = tep_db_fetch_array($specials_query)) {
  if ((!isset($HTTP_GET_VARS['sID']) || (isset($HTTP_GET_VARS['sID']) && ($HTTP_GET_VARS['sID'] == $specials['specials_id']))) && !isset($sInfo)) {
	$products_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$specials['products_id'] . "'");
	$products = tep_db_fetch_array($products_query);
	$sInfo_array = array_merge($specials, $products);
	$sInfo = new objectInfo($sInfo_array);
  }

  if (isset($sInfo) && is_object($sInfo) && ($specials['specials_id'] == $sInfo->specials_id)) {
	echo '				  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '\'">' . "\n";
  } else {
	echo '				  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials['specials_id']) . '\'">' . "\n";
  }
?>
			<td  class="dataTableContent"><?php echo $specials['products_name']; ?></td>
			<td  class="dataTableContent" align="right"><span class="oldPrice"><?php echo $currencies->format($specials['products_price']); ?></span> <span class="specialPrice"><?php echo $currencies->format($specials['specials_new_products_price']); ?></span></td>
			<td  class="dataTableContent" align="right">
<?php
  if ($specials['status'] == '1') {
	echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '  <a href="' . tep_href_link(FILENAME_SPECIALS, 'action=setflag&flag=0&id=' . $specials['specials_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
  } else {
	echo '<a href="' . tep_href_link(FILENAME_SPECIALS, 'action=setflag&flag=1&id=' . $specials['specials_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
  }
?></td>
			<td class="dataTableContent" align="right"><?php if (isset($sInfo) && is_object($sInfo) && ($specials['specials_id'] == $sInfo->specials_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials['specials_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
  </tr>
<?php
}
?>
		  <tr>
			<td colspan="4"><table border="0" width="100%" cellpadding="0"cellspacing="2">
			  <tr>
				<td class="smallText" valign="top"><?php echo $specials_split->display_count($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
				<td class="smallText" align="right"><?php echo $specials_split->display_links($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
			  </tr>
<?php
 if (empty($action)) {
?>
			  <tr>
				<td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?></td>
			  </tr>
<?php
 }
?>
			</table></td>
		  </tr>
		</table></td>
<?php
 $heading = array();
 $contents = array();

 switch ($action) {
case 'delete':
  $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_SPECIALS . '</b>');

  $contents = array('form' => tep_draw_form('specials', FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=deleteconfirm'));
  $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
  $contents[] = array('text' => '<br><b>' . $sInfo->products_name . '</b>');
  $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  break;
default:
  if (is_object($sInfo)) {
	$heading[] = array('text' => '<b>' . $sInfo->products_name . '</b>');

	$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
	$contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($sInfo->specials_date_added));
	$contents[] = array('text' => '' . TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($sInfo->specials_last_modified));
	$contents[] = array('align' => 'center', 'text' => '<br>' . tep_info_image($sInfo->products_image, $sInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT));
	$contents[] = array('text' => '<br>' . TEXT_INFO_ORIGINAL_PRICE . ' ' . $currencies->format($sInfo->products_price));
	$contents[] = array('text' => '' . TEXT_INFO_NEW_PRICE . ' ' . $currencies->format($sInfo->specials_new_products_price));
	$contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');

//		$contents[] = array('text' => '<br>' . TEXT_INFO_EXPIRES_DATE . ' <b>' . tep_date_short($sInfo->expires_date) . '</b>');

	$contents[] = array('text' => '<br>' . TEXT_INFO_VALIDFROM_DATE . ' <b>' . tep_date_short($sInfo->valid_from_date) . '</b>');
	$contents[] = array('text' => '' . TEXT_INFO_EXPIRES_DATE . ' <b>' . tep_date_short($sInfo->expires_date) . '</b>');

	$contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . tep_date_short($sInfo->date_status_change));
  }
  break;
 }
 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo '			<td width="25%" valign="top">' . "\n";

$box = new box;
echo $box->infoBox($heading, $contents);

echo '			</td>' . "\n";
 }
}
?>
	  </tr>
	</table></td>
  </tr>
</table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Thanks,

Philip

Share this post


Link to post
Share on other sites
...

</tr>

<tr>

<td class="main"><?php echo TEXT_SPECIALS_SPECIAL_PRICE; ?> </td>

<td class="main"><?php echo tep_draw_input_field('specials_price', (isset($sInfo->specials_new_products_price) ? $sInfo->specials_new_products_price : '')); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_SPECIALS_VALIDFROM_DATE; ?> </td>

<td class="main"><?php echo tep_draw_input_field('vday', (isset($sInfo->valid_from_date) ? substr($sInfo->valid_from_date, 8, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('vmonth', (isset($sInfo->valid_from_date) ? substr($sInfo->valid_from_date, 5, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('vyear', (isset($sInfo->valid_from_date) ? substr($sInfo->valid_from_date, 0, 4) : ''), 'size="4" maxlength="4" class="cal-TextBox"'); ?><a class="so-BtnLink" href="java script:calClick();return false;" onmouseover="calSwapImg('BTN_valid_date', 'img_Date_OVER',true);" onmouseout="calSwapImg('BTN_valid_date', 'img_Date_UP',true);" onclick="calSwapImg('BTN_valid_date', 'img_Date_DOWN');showCalendar('new_special','vday', 'vmonth', 'vyear','dte_valid_When','BTN_valid_date');return false;"><?php echo tep_image(DIR_WS_IMAGES . 'cal_date_up.gif', 'Calendar', '22', '17', 'align="absmiddle" name="BTN_valid_date"'); ?></a>

</tr>

<tr>

<td class="main"><?php echo TEXT_SPECIALS_EXPIRES_DATE; ?> </td>

<td class="main"><?php echo tep_draw_input_field('day', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 8, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('month', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 5, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('year', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 0, 4) : ''), 'size="4" maxlength="4" class="cal-TextBox"'); ?><a class="so-BtnLink" href="java script:calClick();return false;" onmouseover="calSwapImg('BTN_date', 'img_Date_OVER',true);" onmouseout="calSwapImg('BTN_date', 'img_Date_UP',true);" onclick="calSwapImg('BTN_date', 'img_Date_DOWN');showCalendar('new_special', 'day', 'month','year', 'dteWhen','BTN_date');return false;"><?php echo tep_image(DIR_WS_IMAGES . 'cal_date_up.gif', 'Calendar', '22', '17', 'align="absmiddle" name="BTN_date"'); ?></a></td>

</tr>

</table></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>

<td class="main" align="right" valign="top"><br><?php echo (($form_action == 'insert') ? tep_image_submit('button_insert.gif', IMAGE_INSERT) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). '   <a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . (isset($HTTP_GET_VARS['sID']) ? '&sID=' . $HTTP_GET_VARS['sID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>

</tr>

</table></td>

</form></tr>...

 

Try checking it once more ---> I noticed that you have some code with errors in it - I highlighted t in red above - In the instructions, it says 'javascript', but in your code it says 'java script', with a space in it. I don't know if that's where the error is, but its a start.

 

HTH

~bobsi18~

Edited by bobsi18

Share this post


Link to post
Share on other sites
That fixed it. Those two places of java script changed to javascript. Thanks - so much!

 

I was wondering if there is a way to intergrate this into Admin Specials by Categories for SPPC

 

Thanks,

Philip

 

I don't know about that particular contribution, but I have managed to [almost] get it working with a similar contribution - Category Specials [http://www.oscommerce.com/community/contributions,3831]. A lot of work required, but not toooooo bad in the end. Maybe some-one has integrated it with the SPPC version.

 

~bobsi18~

Share this post


Link to post
Share on other sites
I don't know about that particular contribution, but I have managed to [almost] get it working with a similar contribution - Category Specials [http://www.oscommerce.com/community/contributions,3831]. A lot of work required, but not toooooo bad in the end. Maybe some-one has integrated it with the SPPC version.

 

~bobsi18~

 

Hi there

 

Did you ever get these 2 contribs working together. I haven't installed yet but I will be installing the category specials soon and could really do with this contrib as well.

 

Cheers

Rob


This post was by Rob

 

I'm never lost - I just don't know how to get to where I want to be.

Share this post


Link to post
Share on other sites

I don't understand, even with the latest mod by Barbara they get immediately activated even if the valid date is a few day ahead. Does it work for you?

Share this post


Link to post
Share on other sites

after installing this contribution, I'm getting the following error when trying to create a category special from the admin area:

 

1054 - Unknown column 'A.products_id' in 'on clause'

 

select A.products_id, B.products_price from products_to_categories A, products B left join specials C on C.products_id = A.products_id where A.categories_id = 30 and B.products_id = A.products_id and C.products_id IS NULL

 

[TEP STOP]

 

Does anyone know what is causing this? Thanks for you help!

Share this post


Link to post
Share on other sites

I've installed V1.0.4 of this and it works fine for me - however note the following:

 

1) If you do not set an expiry date for the Special then it will not display in the store front as the new code in catalog/specials.php will exclude any specials where the expiry date = 0

2) In the admin you may have to apply a Register Globals fix to the file specials.php as this apeared to prevent us from editing the dates for existing specials

3) If you change the status of a special from 'on' to 'off' and then back to 'on' this will wipe the expiry date from your special (and it will not display in the storefront for the reason stated in (1)). To stop this happening you will have to edit the file catalog/admin/includes/functions/general.php at around line 739 find

 

////
// Sets the status of a product on special
 function tep_set_specials_status($specials_id, $status) {
  if ($status == '1') {
    return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");
   } elseif ($status == '0') {
     return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");
   } else {
     return -1;
   }
 }

change to:

////
// Sets the status of a product on special
 function tep_set_specials_status($specials_id, $status) {
//    if ($status == '1') {
//      return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");
   if ($status == '1') {
     return tep_db_query("update " . TABLE_SPECIALS . " set status = '1',  date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

   } elseif ($status == '0') {
     return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");
   } else {
     return -1;
   }
 }

Graeme

Share this post


Link to post
Share on other sites

I have installed this contribution version: (http://addons.oscommerce.com/info/2520) specials_valid_from_1.0.4

I am using oscommerce rc2.

 

There are two problems, one, the date picker doesn't show up in IE8, it does in Google-Chrome and in Firefox

But in the compatebility mode date picker does show up in IE8

 

The other problem, it still doesn't save any changes made to a special, it will put the expire date on 000000 and therefor doesn't show up anymore.

I have to manualy remove and ad the special product again.

I tried the fix profided by frimipiso as below.

****************************************

#Search in admin/specials.php for the following code

 

// maybe the special product must be deactivated or actived (depending on wether the valid from/expires dates had been changed)

if ($result == 1) {

$new_specials_id = tep_db_insert_id();

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where (now() < valid_from_date) and specials_id = '" . (int)$new_specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where ((expires_date < now()) and expires_date > 0) and specials_id = '" . (int)$new_specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (now() >= valid_from_date and now() < expires_date) and specials_id = '" . (int)$new_specials_id . "'");

}

 

#and replace with the following code

 

 

// maybe the special product must be deactivated or actived (depending on wether the valid from/expires dates had been changed)

if ($result == 1) {

$dbg->add_message('update done');

$new_specials_id = tep_db_insert_id();

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where (now() < valid_from_date) and specials_id = '" . (int)$specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where ((expires_date < now()) and expires_date > 0) and specials_id = '" . (int)$specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (now() >= valid_from_date and now() < expires_date) and specials_id = '" . (int)$specials_id . "'");

}

 

******************************************

The code shows twice in the catalog/admin/specials.php not only one time.

I changed the top one, the bottom one, and both of them, but all changes do give a failure in php at point of updating the date.

 

Cannot redeclare tep_set_specials_status() (previously declared in....................catalog/admin/includes/functions/general.php:722) in /home/users/.../.../catalog/admin/specials.php on line 129

 

******************************************

 

Tried another fix I found to change in catalog/admin/includes/functions/general.php (this is around line 129 as the problem above)

But both of them don't solve my problem

*************************************************************************

 

Change the below code:

////

// Sets the status of a product on special

function tep_set_specials_status($specials_id, $status) {

if ($status == '1') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");

} elseif ($status == '0') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

} else {

return -1;

}

}

 

INTO:

////

// Sets the status of a product on special

function tep_set_specials_status($specials_id, $status) {

// if ($status == '1') {

// return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");

if ($status == '1') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

 

} elseif ($status == '0') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

} else {

return -1;

}

}

*******************************************************

 

 

Any one any help???

Thank you!! Harold

Share this post


Link to post
Share on other sites

I have installed this contribution version: (http://addons.oscommerce.com/info/2520) specials_valid_from_1.0.4

I am using oscommerce rc2.

 

There are two problems, one, the date picker doesn't show up in IE8, it does in Google-Chrome and in Firefox

But in the compatebility mode date picker does show up in IE8

 

The other problem, it still doesn't save any changes made to a special, it will put the expire date on 000000 and therefor doesn't show up anymore.

I have to manualy remove and ad the special product again.

I tried the fix profided by frimipiso as below.

****************************************

#Search in admin/specials.php for the following code

 

// maybe the special product must be deactivated or actived (depending on wether the valid from/expires dates had been changed)

if ($result == 1) {

$new_specials_id = tep_db_insert_id();

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where (now() < valid_from_date) and specials_id = '" . (int)$new_specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where ((expires_date < now()) and expires_date > 0) and specials_id = '" . (int)$new_specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (now() >= valid_from_date and now() < expires_date) and specials_id = '" . (int)$new_specials_id . "'");

}

 

#and replace with the following code

 

 

// maybe the special product must be deactivated or actived (depending on wether the valid from/expires dates had been changed)

if ($result == 1) {

$dbg->add_message('update done');

$new_specials_id = tep_db_insert_id();

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where (now() < valid_from_date) and specials_id = '" . (int)$specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where ((expires_date < now()) and expires_date > 0) and specials_id = '" . (int)$specials_id . "'");

tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (now() >= valid_from_date and now() < expires_date) and specials_id = '" . (int)$specials_id . "'");

}

 

******************************************

The code shows twice in the catalog/admin/specials.php not only one time.

I changed the top one, the bottom one, and both of them, but all changes do give a failure in php at point of updating the date.

 

Cannot redeclare tep_set_specials_status() (previously declared in....................catalog/admin/includes/functions/general.php:722) in /home/users/.../.../catalog/admin/specials.php on line 129

 

******************************************

 

Tried another fix I found to change in catalog/admin/includes/functions/general.php (this is around line 129 as the problem above)

But both of them don't solve my problem

*************************************************************************

 

Change the below code:

////

// Sets the status of a product on special

function tep_set_specials_status($specials_id, $status) {

if ($status == '1') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");

} elseif ($status == '0') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

} else {

return -1;

}

}

 

INTO:

////

// Sets the status of a product on special

function tep_set_specials_status($specials_id, $status) {

// if ($status == '1') {

// return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");

if ($status == '1') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

 

} elseif ($status == '0') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

} else {

return -1;

}

}

*******************************************************

 

 

Any one any help???

Thank you!! Harold

 

The date picker (calendar.js) works again, no idea why it din't work in the first place, must have been sommething with IE.

So that one is solved.

Only the save changes problem remains, I find it strange that my save changes problem was not there before the install of this component. Therfore I would thing it has to be solved easily, but where?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×