Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

I have uploaded admin/customers_groups.php but I saw nothing different in the customers section of the admin, that's why I looked at the Newsletter section. Then I realized I didn't have the customers.php modified. When I added the SCPC code and uploaded the file I hoped to see the new entries in the admin area, but instead when I clicked on the customers tab I saw a blank screen with the message:

 

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /hsphere/local/home/.../.../catalog/admin/customers.php on line 172

 

This is the line 172, in red:

 

// BOF Separate Pricing per Customer

'customers_group_id' => $customers_group_id,

'customers_group_ra' => $customers_group_ra);

// EOF Separate Pricing per Customer

 

I cannot see anything wrong, though. Any ideas?

Please forget my previous posting, I uploaded the original SPPC file instead of the one with the SPPC code and the code from another contribution, and I saw a brand new customers section! It is just what I wanted, now I will try to combine some more files with the coupons contribution by Burt that I already use, and I hope to get these groups created at last!

If anything goes wrong I'll get back to you. Thank you for this wonderful contribution! :)

Link to comment
Share on other sites

Please forget my previous posting, I uploaded the original SPPC file instead of the one with the SPPC code and the code from another contribution, and I saw a brand new customers section! It is just what I wanted, now I will try to combine some more files with the coupons contribution by Burt that I already use, and I hope to get these groups created at last!

If anything goes wrong I'll get back to you. Thank you for this wonderful contribution! :)

 

It works like a charm! At last I have the mail functions I always wanted! Thanks!

Link to comment
Share on other sites

First of all, Thank you for making this contribution. I'm planning to install this contribution and Quantity Price Break for SPPC v2 on my site. I currently have STS 4.5.8 with product_info template enabled, Easy Populate, More Pics6 1.4.3, and lightbox installed. From what I've read on the forum, it seems as though this contribution has some compatibility issues with STS's product_info template and this would be a difficult installation. Can any kind soul give me some insight into the installation and it's difficulty? What pitfalls should I be avoiding? Any suggestions are greatly appreciated. Thank you.

 

Best Regards,

 

Jack

Link to comment
Share on other sites

Hi, I have had this contribution for years, but now my problem is that the product info page started to display the retail price even if the customer is logged in for wholesale. When he puts the product into his cart, the price is OK again (i.e. wholesale price).

Here his the code, please can someone tell me where is the error? Please, please I don't want to reinstall the entire contrib

Thanks in advance,

joe

<?php
/*
 $Id: product_info.php,v 1.97 2003/07/01 14:34:54 hpdl Exp $
 adapted for Separate Pricing Per Customer v3.6 2005/01/26

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);

 $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 $product_check = tep_db_fetch_array($product_check_query);
?>
<!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>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le
ft=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
 if ($product_check['total'] < 1) {
  // BOF Separate Price per Customer
    if(!tep_session_is_registered('sppc_customer_group_id')) { 
    $customer_group_id = '0';
    } else {
     $customer_group_id = $sppc_customer_group_id;
    }
  // EOF Separate Price per Customer
?>
     <tr>
       <td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
<?php
 } else {
   $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
   $product_info = tep_db_fetch_array($product_info_query);

   tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

   if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
// BOF Separate Price per Customer

       $scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
       if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
       $product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
// EOF Separate Price per Customer

     $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
   } else {
// BOF Separate Price per Customer
       $scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
       if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
       $product_info['products_price']= $scustomer_group_price['customers_group_price'];
}
// EOF Separate Price per Customer

     $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
   }

   if (tep_not_null($product_info['products_model'])) {
     $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
   } else {
     $products_name = $product_info['products_name'];
   }
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
           <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="main">
<?php
   if (tep_not_null($product_info['products_image'])) {
?>
         <table border="0" cellspacing="0" cellpadding="2" align="right">
           <tr>
             <td align="center" class="smallText">
<script language="javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
             </td>
           </tr>
         </table>
<?php
   }
?>
       <table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main"><?php //echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
               <td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table>
<?php
   $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
?>
         <table border="0" cellspacing="0" cellpadding="2">
           <tr>
             <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>
           </tr>
<?php
     $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
       $products_options_array = array();
       $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
       while ($products_options = tep_db_fetch_array($products_options_query)) {
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }

       if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }
?>
           <tr>
             <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
             <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
           </tr>
<?php
     }
?>
         </table>
<?php
   }
?>

         <p><?php echo stripslashes($product_info['products_description']); ?></p>
       </td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
   $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
   $reviews = tep_db_fetch_array($reviews_query);
   if ($reviews['count'] > 0) {
?>
     <tr>
       <td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
   }

   if (tep_not_null($product_info['products_url'])) {
?>
     <tr>
       <td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false)); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
   }

   if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
     <tr>
       <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></td>
     </tr>
<?php
   } else {
?>
     <tr>
       <td align="center" class="smallText"><?php //echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
     </tr>
<?php
   }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main"><?php //echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
               <td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td>
<?php
   if ((USE_CACHE == 'true') && empty($SID)) {
     echo tep_cache_also_purchased(3600);
   } else {
     include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
   }
 }
?>
       </td>
     </tr>
   </table></form></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

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

Link to comment
Share on other sites

Hi, I have had this contribution for years, but now my problem is that the product info page started to display the retail price even if the customer is logged in for wholesale. When he puts the product into his cart, the price is OK again (i.e. wholesale price).

Here his the code, please can someone tell me where is the error? Please, please I don't want to reinstall the entire contrib

Because of a problem in one page you think you need to reinstall a complete contribution? I hope the mechanics at my garage don't take my car apart if a light is broken :)

 

You added the code to check for the customer group id in a piece of code that is only used when there are no products to show:

<?php
 if ($product_check['total'] < 1) {
  // BOF Separate Price per Customer
 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }
  // EOF Separate Price per Customer
?>
  <tr>
	<td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td>

You will need to put it higher (and using super globals like $_SESSION doesn't hurt either):

  $product_check = tep_db_fetch_array($product_check_query);
// BOF Separate Pricing per Customer
 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
$customer_group_id = '0';
 }
// EOF Separate Pricing per Customer

Link to comment
Share on other sites

First of all thank you for this contribution...

 

i successfully installed the sppc in my Osc.v2.2RC2 and everything looks ok exept this one!

 

in customers_groups.php some headings is missing

 

HEADING_TITLE_MODULES_PAYMENT

HEADING_TITLE_MODULES_SHIPPING

HEADING_TITLE_MODULES_ORDER_TOTAL

 

any ideas? is this happen because of the version of my osc?

 

if this happend because of my osc, should i check somewhere else for more errors?

 

Thank you all in advance

Link to comment
Share on other sites

in customers_groups.php some headings is missing

 

HEADING_TITLE_MODULES_PAYMENT

HEADING_TITLE_MODULES_SHIPPING

HEADING_TITLE_MODULES_ORDER_TOTAL

I guess you use WooWoo as your language in the admin and you didn't copy one of the other language files (like the English one) for admin/customers_groups.php in that directory (admin/includes/languages/WooWoo/customers_groups.php)?

Link to comment
Share on other sites

I guess you use WooWoo as your language in the admin and you didn't copy one of the other language files (like the English one) for admin/customers_groups.php in that directory (admin/includes/languages/WooWoo/customers_groups.php)?

 

yeah...you were right... stupid mistake, sorry

evrything is fine now

 

 

something more sophisticated now...

 

is there any way to ask users to choose if they are wholsale or retail uppon their registration?

 

and if they choose wholesale the approval will be necessery but if they choose retail the registration to the site will be instant

 

anyone something similar?

Link to comment
Share on other sites

is there any way to ask users to choose if they are wholsale or retail uppon their registration?

 

and if they choose wholesale the approval will be necessery but if they choose retail the registration to the site will be instant

 

anyone something similar?

This has come up in this thread a number of times certainly though of course it might not easy to find it back. At the moment you get an alert in the admin when someone enters a tax id number. You can use your own field in the HTML of the create_account.php page to trigger the same thing (even trigger an email).

Link to comment
Share on other sites

I'm running osC 2.2-MS2. I have a number of contributions installed, including Easy Populate, Related Products, Wishlist, etc.

 

I'm most of the way through an install of SPPC 4.2.2 and have come across some difference/error in the install instructions while trying to make the edits to /catalog/includes/classes/shopping_cart.php

 

Step 4: reads...

 

Line 101-104 [151-155] (this piece of code was added in the August 17, 2006 update)

**REPLACE**

 

		$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	$check_product = tep_db_fetch_array($check_product_query);

	if (($check_product !== false) && ($check_product['products_status'] == '1')) {

 

Unfortunately, I can't find this portion of code in my file - in fact this is the only section of code the install instructions mention that I can't find, in this file and others.

That is because you never updated your site. That piece of code was added in the August 17, 2006 update. The simplest solution would be to download the latest 2.2 version, find the file update-20060817.txt in it and add the changes mentioned for includes/classes/shopping_cart.php (starts around line 151 in that file).

 

You do realize you will get trouble with not updating one day? Even with adding SPPC because the way prices with tax are calculated was changed in one of the updates (a new function in the class currencies). You will likely hit that error.

 

Contribution for upgrading: #6654.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I have order editor, attributes file manager and would like to get these working with sppc.

 

The rest of sppc appears to be working including with the msrp mod, I dont have the specials working with the sppc this as i upgraded the specials module and found it difficult to transklate accross, although I will give this another go before posting the files.

 

I did find an order editor sppc mod, but its so old I could bearly recognise the files involved.

I could find a mod for attrbutes sppc but not one the included the attribute manager.

 

Can anyone help stear me in the right direction.

 

The order editor does get the right information when I place an order online, whether its as sppc customer or a retail customer, I just cant modify the order for the right pricing for the products.

 

 

Thanks

Johnny

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

I actaully back tracked and found the order editor just needed to have the setting switched on for sppc in admin configuration now all I need is to get the specials and attrbutes sorted.

 

Thanks

 

johnny

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

I could find a mod for attrbutes sppc but not one the included the attribute manager.

The attributes code for group prices is merely a button in the attribute page that triggers a pop-up window (a separate page really). Shouldn't be to hard to get that button into an attribute manager I would guess.

Link to comment
Share on other sites

I am looking at it its taking some getting my head around.

 

Anyway specials problem in admin.

 

When I select retail, I get two entries, when I select other sppcspecial I get one retail and one sppc price set at the same value.

 

I can then edit both entries to whatever I like, whilst its not a major issue its a little confusing, and would it not be better if we could just select the one pricegroup at a time?

 

heres my admin code:-

 

<?php
/*
 $Id: specials.php 1739 2007-12-20 00:52:16Z hpdl $
 adapted for Separate Pricing Per Customer v4.0 2007/08/05
 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();
// BOF Separate Pricing Per Customer
  $customers_groups_query = tep_db_query("select customers_group_name, customers_group_id from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id ");
while ($existing_groups = tep_db_fetch_array($customers_groups_query)) {
	 $input_groups[] = array("id" => $existing_groups['customers_group_id'], "text" => $existing_groups['customers_group_name']);
	$all_groups[$existing_groups['customers_group_id']] = $existing_groups['customers_group_name'];
}
// EOF Separate Pricing Per Customer
 $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']);
	$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;
			}
	}
// BOF Separate Pricing Per Customer
	$customers_group = tep_db_prepare_input($_POST['customers_group']);
	$price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS. " WHERE products_id = ".(int)$products_id . " AND customers_group_id  = ".(int)$customers_group);
	while ($gprices = tep_db_fetch_array($price_query)) {
		$products_price = $gprices['customers_group_price'];
	}
   if (substr($specials_price, -1) == '%' && $customers_group == '0') {
	  $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));
   } elseif (substr($specials_price, -1) == '%' && $customers_group != '0') {
				$specials_price = ($products_price - (($specials_price / 100) * $products_price));
	}
// EOF Separate Pricing Per Customer
	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;
	}
// BOF Separate Pricing Per Customer
tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status, customers_group_id) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', now(), '" . tep_db_input($expires_date) . "', '1', ".(int)$customers_group.")");
// EOF Separate Pricing Per Customer
	$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;
	}
	$result = 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')");
	// 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() >= expires_date and expires_date > 0) and specials_id = '" . (int)$specials_id . "'");
		tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (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 . "'");
	// maybe the special product must be deactivated or actived (depending on wether the valid from/expires dates had been changed)
	tep_db_query("update " . TABLE_SPECIALS . " set status = '0' where (now() >= expires_date and expires_date > 0) and specials_id = '" . (int)$specials_id . "'");
	tep_db_query("update " . TABLE_SPECIALS . " set status = '1' where (now() < expires_date) and specials_id = '" . (int)$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';
// BOF Separate Pricing Per Customer
  $product_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, s.specials_new_products_price, s.expires_date, s.customers_group_id 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);
// EOF Separate Pricing Per Customer
		$sInfo = new objectInfo($product);
} else {
  if ( ($action == 'new') && isset($HTTP_GET_VARS['prodID']) ) {
	  $product_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = '". (int) $HTTP_GET_VARS['prodID']. "'");
	  $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'];
  }}
// 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)
// BOF Separate Pricing Per Customer
/*	  $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'];
  }
} */$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $product['products_id']. "' and customers_group_id =  '" . $product['customers_group_id'] . "'");
	 if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
		$product['products_price']= $customer_group_price['customers_group_price'];
	 }
$specials_array = array();
$specials_query = tep_db_query("select p.products_id, s.customers_group_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[] = (int)$specials['products_id'].":".(int)$specials['customers_group_id'];
}
if(isset($HTTP_GET_VARS['sID']) && $sInfo->customers_group_id!= '0') {
	$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $sInfo->products_id . "' and customers_group_id =  '" . $sInfo->customers_group_id . "'");
	  if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
		$sInfo->products_price = $customer_group_price['customers_group_price'];
	  }
   }
}
?>
  <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
if ( ($action == 'new') && isset($HTTP_GET_VARS['prodID']) ) {
			echo tep_draw_hidden_field('products_id', $HTTP_GET_VARS['prodID']);
		echo $sInfo->products_name . ' <small>(' . $currencies->format($sInfo->products_price) . ')</small>';
	}
	else
		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>
<!-- BOF Separate Pricing per Customer -->
	  <tr>
		<td class="main"><?php echo TEXT_SPECIALS_GROUPS; ?> </td>
		<td class="main"><?php if (isset($sInfo->customers_group_id)) {
		for ($x=0; $x<count($input_groups); $x++) {
		  if ($input_groups[$x]['id'] == $sInfo->customers_group_id) {
		echo $input_groups[$x]['text'];
		  }
		} // end for loop
		} else {
	 echo tep_draw_pull_down_menu('customers_group', $input_groups, (isset($sInfo->customers_group_id)? $sInfo->customers_group_id:''));
	 } ?> </td>
<!-- EOF Separate Pricing per Customer -->
	  </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_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','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
// BOF Separate Pricing Per Customer
$all_groups = array();
$customers_groups_query = tep_db_query("select customers_group_name, customers_group_id from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id ");
while ($existing_groups =  tep_db_fetch_array($customers_groups_query)) {
  $all_groups[$existing_groups['customers_group_id']] = $existing_groups['customers_group_name'];
}
  $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, s.specials_id, s.customers_group_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";
  $customers_group_prices_query = tep_db_query("select s.products_id, s.customers_group_id, pg.customers_group_price from " . TABLE_SPECIALS . " s LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using (products_id, customers_group_id) ");
while ($_customers_group_prices = tep_db_fetch_array($customers_group_prices_query)) {
$customers_group_prices[] = $_customers_group_prices;
}
$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);
// BOF Separate Pricing Per Customer
$no_of_rows_in_specials = tep_db_num_rows($specials_query);
while ($specials = tep_db_fetch_array($specials_query)) {
for ($y = 0; $y < $no_of_rows_in_specials; $y++) {
if ( tep_not_null($customers_group_prices[$y]['customers_group_price']) && $customers_group_prices[$y]['products_id'] == $specials['products_id'] && $customers_group_prices[$y]['customers_group_id'] == $specials['customers_group_id']) {
$specials['products_price'] = $customers_group_prices[$y]['customers_group_price'];
} // end if (tep_not_null($customers_group_prices[$y]['customers_group_price'] etcetera
} // end for loop
// EOF Separate Pricing Per Customer
  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>
<!-- BOF Separate Pricing Per Customer -->
			<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']) . " (".  $all_groups[$specials['customers_group_id']] . ")"; ?></span></td>
<!-- EOF Separate Pricing per Customer -->
			<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_SELECT_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));
// BOF edited for SPPC where a product price can be 0 if there is no group price, gives a warning divison by zero
	$contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / ($sInfo->products_price == 0 ? $sInfo->specials_new_products_price : $sInfo->products_price)) * 100)) . '%');
// EOF edited for SPPC
	$contents[] = array('text' => '<br>' . 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'); ?>

 

tell you what the the brackets arent half been giving me grief, but its amazing when you start checking things section by section of code to find out which part causes the error then work out how to put it right.

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

Okay next problem....

 

I have added upcomming products so that it displays with images left to right and has an infobox style header.

 

It will also display specials and non special priced products.

 

The problem I have with this is, I can have up and comming products easily enough, but when it comes to customer groups, I have the following issue:-

 

1. no customer group filter, I get all upcoming products displayed, and also upcoming products different product groups, so I can have repeated upcomming products displayed all with different prices.

 

2. I put in the customer filter, I appear only to be able to do this for specials, so it works great in the respect my duplicates are no longer available, but if its not a special it wont be displayed either.

 

can someone help me with this, its lines surrounded by //////////////////////// in the folowing code that I think are the issue.

 

Thanks

Johnny

 

 

<?php
/*
$Id: upcoming_products.php,v 1.34 2005/01/28 19:02:55 hpdl Exp $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
 by Infobroker
 [email protected]
*/
?>
<!-- upcoming_products //-->
<?php
 //////////////////////////////////////////////////////////////////////////////////////////////////////////

 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
$customer_group_id = '0';
 }
 if ( (!isset($expected_category_id)) || ($expected_category_id == '0') ) {
$expected_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, products_date_available as date_expected, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where to_days(products_date_available) >= to_days(now()) and products_status = '1' and s.customers_group_id = '" . (int)$customer_group_id . "' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS);
 } else {
$expected_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, products_date_available as date_expected, if(s.status, s.specials_new_products_price, p.products_price)  as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where to_days(products_date_available) >= to_days(now()) and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$expected_category_id . "' and p.products_status = '1' and s.customers_group_id = '" . (int)$customer_group_id . "' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 }
$expected_rows = tep_db_num_rows($expected_query);
if ($expected_rows > 0) {
	  $info_box_contents = array();
 $info_box_contents[] = array('text' => TABLE_HEADING_UPCOMING_PRODUCTS);
 new contentBoxHeading($info_box_contents);
 $row = 0;
 $col = 0;
 $info_box_contents = array();
 while ($expected = tep_db_fetch_array($expected_query)) {
$expected['products_name'] = tep_get_products_name($expected['products_id']);
$info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $expected['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $expected['products_image'], $expected['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $expected['products_id']) . '">' . $expected['products_name'] . '</a><br>' . $currencies->display_price($expected['products_price'], tep_get_tax_rate($expected['products_tax_class_id'])));
$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
 }
 new contentBox($info_box_contents);
 }
?>
<!-- upcoming_products_eof //-->

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

I have added upcomming products so that it displays with images left to right and has an infobox style header.

It looks pretty similar to the includes/modules/new_products.php. You can't include the table specials for example in the query.

Link to comment
Share on other sites

It looks pretty similar to the includes/modules/new_products.php. You can't include the table specials for example in the query.

 

 

Hi can you give an example of what it should look like I have edited changed and think I have tried nearly all combinations, mind you I have been at this for about 7 hours today.

 

Will have another look

 

Thanks

Johnny

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

Okay so now with the following query I have the expected products only, with the normal selling price.

 

now need to get it to show the correct price for the sppc and specials per sppc, lets see how I get on, anyone that wants to post a solution please feel free.

 

Thanks

Johnny

 

  // $expected_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, products_date_available as date_expected, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where to_days(products_date_available) >= to_days(now()) and products_status = '1' and s.customers_group_id = '" . (int)$customer_group_id . "' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS);
$expected_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, products_date_available as date_expected from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where to_days(products_date_available) >= to_days(now()) and products_status = '1' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 } else {
 //  $expected_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, products_date_available as date_expected, if(s.status, s.specials_new_products_price, p.products_price)  as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where to_days(products_date_available) >= to_days(now()) and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$expected_category_id . "' and p.products_status = '1' and s.customers_group_id = '" . (int)$customer_group_id . "' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS);
 $expected_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, products_date_available as date_expected from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on pd.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c using(categories_id) where c.parent_id = '" . (int)$new_products_category_id . "' where to_days(products_date_available) >= to_days(now()) and products_status = '1' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

It looks pretty similar to the includes/modules/new_products.php. You can't include the table specials for example in the query.

Something like this should look more like it (you can't include the table specials in those queries!).

<?php
/*
$Id: upcoming_products.php,v 1.34 2005/01/28 19:02:55 hpdl Exp $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
 by Infobroker
 [email protected]
*/
?>
<!-- upcoming_products //-->
<?php
 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
$customer_group_id = '0';
 }
 if ( (!isset($expected_category_id)) || ($expected_category_id == '0') ) {
$expected_query = tep_db_query("select p.products_id, p.products_image, p.products_price, p.products_tax_class_id, products_date_available as date_expected, null as specials_new_products_price from " . TABLE_PRODUCTS . " p where to_days(products_date_available) >= to_days(now()) and products_status = '1' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS);
 } else {
$expected_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_price, p.products_tax_class_id, products_date_available as date_expected, null as specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where to_days(products_date_available) >= to_days(now()) and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$expected_category_id . "' and p.products_status = '1' order by " . EXPECTED_PRODUCTS_FIELD . " " . EXPECTED_PRODUCTS_SORT . " limit " . MAX_DISPLAY_UPCOMING_PRODUCTS);
 }

 if (($no_of_exp_products = tep_db_num_rows($expected_query)) > 0) {
  while ($_exp_products = tep_db_fetch_array($expected_query)) {
$expected_products[] = $_exp_products;
$list_of_prdct_ids[] = $_exp_products['products_id'];
}

 if ($exp_products_with_name = tep_add_product_names($list_of_prdct_ids, $expected_products)) {
$expected_products = $exp_products_with_name;
unset($exp_products_with_name);
 }

$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_exp_products > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";
  }
}
// get all customers_group_prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
 $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."'");
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '');
}

  for ($x = 0; $x < $no_of_exp_products; $x++) {
// replace products prices with those from customers_group table
 if(!empty($new_prices)) {
	 for ($i = 0; $i < count($new_prices); $i++) {
		 if( $expected_products[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
			 $expected_products[$x]['products_price'] = $new_prices[$i]['products_price'];
		 }
	 }
   } // end if(!empty($new_prices)
  } // end for ($x = 0; $x < $no_of_exp_products; $x++)
} // end if ($customer_group_id != '0')

// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

// replace products_price with the correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_exp_products; $x++) {
for ($i = 0; $i < count($new_s_prices); $i++) {
  if( $expected_products[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	$expected_products[$x]['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
  }
}
 }
} // // end if(!empty($new_s_prices)

 $info_box_contents = array();
 $info_box_contents[] = array('text' => TABLE_HEADING_UPCOMING_PRODUCTS);
 new contentBoxHeading($info_box_contents);
 $row = 0;
 $col = 0;
 $info_box_contents = array();
 for ($x = 0; $x < $no_of_exp_products; $x++) {
$info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $expected[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $expected[$x]['products_image'], $expected[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $expected[$x]['products_id']) . '">' . $expected[$x]['products_name'] . '</a><br>' . $currencies->display_price($expected[$x]['products_price'], tep_get_tax_rate($expected[$x]['products_tax_class_id'])));
$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
 }
 new contentBox($info_box_contents);
 } // end   if (($no_of_exp_products = tep_db_num_rows($expected_query)) > 0)
?>
<!-- upcoming_products_eof //-->
<?php
// general function to add products name to an array instead of querying one by one
function tep_add_product_names ($products_id_array, $query_result_array) {
 global $languages_id;

 if (!is_array($products_id_array) || !is_array($query_result_array)) {
  return false;
 }
 foreach ($products_id_array as $key => $products_id) {
$products_id_array[$key] = tep_get_prid($products_id);
 }
 $products_id_array = array_unique($products_id_array);

 $product_names_query = tep_db_query("select products_id, products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id in (" . implode(',', $products_id_array) . ") and language_id = '" . (int)$languages_id . "'");
 while ($_product_names = tep_db_fetch_array($product_names_query)) { 
  $product_names[] = array('products_id' => $_product_names['products_id'], 'products_name' => $_product_names['products_name']);  
 }

 $no_of_products = count($query_result_array);
 $no_of_product_names = count($product_names);
 for ($x = 0; $x < $no_of_products; $x++) {
if (!empty($product_names)) {
  for ($i = 0; $i < $no_of_product_names; $i++) {
	if ($query_result_array[$x]['products_id'] == $product_names[$i]['products_id']) {
	  $query_result_array[$x]['products_name'] = $product_names[$i]['products_name'];
	}
  }	
}
 } // end for ($x = 0; $x < $no_of_products; $x++)
 return $query_result_array;
}
?>

Can't test it, you will have to do the bug testing :)

Link to comment
Share on other sites

Like a silly arse I do everything the long way round duh.

 

changed the new products to use the upcomming queries(i.e to use expected dates etc to filter it out).

 

tidied it up a bit I suspect the code you just posted is similar to what I have now. but its been good to learn how to dthings if nothing else.

 

The attribute manager would be the next thing to tackle and then we are well sorted.

 

 

the following code has been tested on my system and is fully functional.

<?php
/*
 $Id: upcoming_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $
 adapted for Separate Pricing Per Customer v4.2 2008/07/13

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- upcoming_products //-->
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_UPCOMING_PRODUCTS, strftime('%B')));

 new contentBoxHeading($info_box_contents);

 if ( (!isset($expected_category_id)) || ($expected_category_id == '0') ) {
// BOF Separate Pricing Per Customer
$expected_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, products_date_available as date_expected from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where to_days(products_date_available) >= to_days(now()) and p.products_status = '1' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
} else {
$expected_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, products_date_available as date_expected from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on pd.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c using(categories_id) where c.parent_id = '" . (int)$expected_category_id . "' and here to_days(products_date_available) >= to_days(now()) and p.products_status = '1' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  }

// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
$customer_group_id = '0';
 }

 if (($no_of_expected_products = tep_db_num_rows($expected_query)) > 0) {
  while ($_expected_products = tep_db_fetch_array($expected_query)) {
$expected[] = $_expected_products;
$list_of_prdct_ids[] = $_expected_products['products_id'];
}

$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_expected_products > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";
  }
}
// get all customers_group_prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
 $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."'");
while ($pg_array = tep_db_fetch_array($pg_query)) {
$expected_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '');
}

  for ($x = 0; $x < $no_of_expected_products; $x++) {
// replace products prices with those from customers_group table
 if(!empty($expected_prices)) {
	 for ($i = 0; $i < count($expected_prices); $i++) {
		 if( $expected[$x]['products_id'] == $expected_prices[$i]['products_id'] ) {
			 $expected[$x]['products_price'] = $expected_prices[$i]['products_price'];
		 }
	 }
   } // end if(!empty($expected_prices)
  } // end for ($x = 0; $x < $no_of_products_new; $x++)
} // end if ($customer_group_id != '0')

// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

// replace products_price with the correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_expected_products; $x++) {
for ($i = 0; $i < count($new_s_prices); $i++) {
  if( $expected[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
	$expected[$x]['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
  }
}
 }
} // // end if(!empty($new_s_prices)

 $row = 0;
 $col = 0;

 $info_box_contents = array();

//  while ($expected = tep_db_fetch_array($expected_query)) {
for ($x = 0; $x < $no_of_expected_products; $x++) {
// getting products_name added to the $expected_query above so we can skip this
//	$expected[$x]['products_name'] = tep_get_products_name($expected[$x]['products_id']);

$info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $expected[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $expected[$x]['products_image'], $expected[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $expected[$x]['products_id']) . '">' . $expected[$x]['products_name'] . '</a><br>' . $currencies->display_price($expected[$x]['products_price'], tep_get_tax_rate($expected[$x]['products_tax_class_id'])));

$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
  } // end for ($x = 0; $x < $no_of_expected_products; $x++)
} //  end if (($no_of_expected_products = tep_db_num_rows($expected_query)) > 0)
// EOF Separate Pricing Per Customer
new contentBox($info_box_contents);
?>
<!-- upcoming_products_eof //-->

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

I suspect the code you just posted is similar to what I have now.

Yes, I only left out the join to table products_description and moved that to a separate function/query. In a shop with a lot of products this would speed up things because the queries are lighter. No big deal for the majority of shops I expect.

Link to comment
Share on other sites

Yes, I only left out the join to table products_description and moved that to a separate function/query. In a shop with a lot of products this would speed up things because the queries are lighter. No big deal for the majority of shops I expect.

 

 

I will change that I think, as when I have tens of thousands of products it maybe an issue

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

Hi I am just doing my e-mail section. Currently have a problem with my pdf invoices working with sppc, the file process checkout has a line with the pdf invoice in and its saying it doesnt recognise the strung or something, so I will be comming back to this in a minute after I have done the e-mail optional section.

 

I also have ultimate html emails installed. the admin newsletter script I have appears to work. so I have included the code below just in case anyone else is looking for it.

 

<?php
/*
 $Id: newsletters.php 1751 2007-12-21 05:26:09Z hpdl $

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

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');
// BOF Separate Pricing Per Customer
 $customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id");
 $cg_array = array();
 while ($customers_group = tep_db_fetch_array($customers_group_query)) {
$cg_array[] = array('id' => $customers_group['customers_group_id'], 'customers_group_name' => $customers_group['customers_group_name']);
 }
// this is now defined as a global variable since we need it everywhere
global $cg_array;
// EOF Separate Pricing Per Customer
 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 if (tep_not_null($action)) {
switch ($action) {
// BOF Separate Pricing Per Customer
case 'update_cgs':
$customer_groups_chosen = '';
if (isset($_POST['send_to_cgs'])) {
	foreach ($_POST['send_to_cgs'] as $key => $value) {
		$customer_groups_chosen .= tep_db_prepare_input($value).',';
	}
	// remove last comma
	$customer_groups_chosen = substr($customer_groups_chosen,0,strlen($customer_groups_chosen)-1);
} // end if (isset($HTTP_POST['send_to_cgs']))		
	$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);

	tep_db_query("update " . TABLE_NEWSLETTERS . " set send_to_customer_groups = '" . $customer_groups_chosen . "' where newsletters_id = '" . (int)$newsletter_id . "'");

	tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
	break;
// EOF Separate Pricing Per Customer	
//---  Beginning of addition: Ultimate HTML Emails  ---//
  case 'preview':
	  if (EMAIL_USE_HTML == 'true') {
		  $newsletter_query = tep_db_query("select content from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$HTTP_GET_VARS['nID']. "'");
		  $newsletter = tep_db_fetch_array($newsletter_query);
		  $HTMLNewsletterContents = $newsletter['content'];
		  require(DIR_FS_CATALOG_MODULES . 'UHtmlEmails/'. ULTIMATE_HTML_EMAIL_LAYOUT .'/newsletters.php');
		  print $html_email;
		  exit();
	}

	break;
//---  End of addition: Ultimate HTML Emails  ---//
  case 'lock':
  case 'unlock':
	$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);
	$status = (($action == 'lock') ? '1' : '0');

	tep_db_query("update " . TABLE_NEWSLETTERS . " set locked = '" . $status . "' where newsletters_id = '" . (int)$newsletter_id . "'");

	tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
	break;
  case 'insert':
  case 'update':
	if (isset($HTTP_POST_VARS['newsletter_id'])) $newsletter_id = tep_db_prepare_input($HTTP_POST_VARS['newsletter_id']);
	$newsletter_module = tep_db_prepare_input($HTTP_POST_VARS['module']);
	$title = tep_db_prepare_input($HTTP_POST_VARS['title']);
	$content = tep_db_prepare_input($HTTP_POST_VARS['content']);

	$newsletter_error = false;
	if (empty($title)) {
	  $messageStack->add(ERROR_NEWSLETTER_TITLE, 'error');
	  $newsletter_error = true;
	}

	if (empty($newsletter_module)) {
	  $messageStack->add(ERROR_NEWSLETTER_MODULE, 'error');
	  $newsletter_error = true;
	}

	if ($newsletter_error == false) {
	  $sql_data_array = array('title' => $title,
							  'content' => $content,
							  'module' => $newsletter_module);

	  if ($action == 'insert') {
		$sql_data_array['date_added'] = 'now()';
		$sql_data_array['status'] = '0';
		$sql_data_array['locked'] = '0';

		tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array);
		$newsletter_id = tep_db_insert_id();
	  } elseif ($action == 'update') {
		tep_db_perform(TABLE_NEWSLETTERS, $sql_data_array, 'update', "newsletters_id = '" . (int)$newsletter_id . "'");
	  }

	  tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'nID=' . $newsletter_id));
	} else {
	  $action = 'new';
	}
	break;
  case 'deleteconfirm':
	$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);

	tep_db_query("delete from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");

	tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page']));
	break;
  case 'delete':
  case 'new': if (!isset($HTTP_GET_VARS['nID'])) break;
  case 'send':
  case 'confirm_send':
	$newsletter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);

	$check_query = tep_db_query("select locked from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$newsletter_id . "'");
	$check = tep_db_fetch_array($check_query);

	if ($check['locked'] < 1) {
	  switch ($action) {
		case 'delete': $error = ERROR_REMOVE_UNLOCKED_NEWSLETTER; break;
		case 'new': $error = ERROR_EDIT_UNLOCKED_NEWSLETTER; break;
		case 'send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
		case 'confirm_send': $error = ERROR_SEND_UNLOCKED_NEWSLETTER; break;
	  }

	  $messageStack->add_session($error, 'error');

	  tep_redirect(tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']));
	}
	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>
<!-- START tinyMCE Anywhere //-->
<script language="javascript" type="text/javascript" src="includes/javascript/tiny_mce/tiny_mce.js"></script>
<?php include "includes/javascript/tiny_mce/mail.php"; // END tinyMCE ?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<div id="spiffycalendar" 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><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') {
$form_action = 'insert';

 $parameters = array('title' => '',
					'content' => '',
		// BOF Separate Pricing Per Customer
					'module' => '',
		'send_to_customer_groups' => '');
		// EOF Separate Pricing Per Customer
$nInfo = new objectInfo($parameters);

if (isset($HTTP_GET_VARS['nID'])) {
  $form_action = 'update';

  $nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

  //$newsletter_query = tep_db_query("select title, content, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
  // BOF Separate Pricing Per Customer
  $newsletter_query = tep_db_query("select title, content, module, send_to_customer_groups from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// EOF Separate Pricing Per Customer

  $newsletter = tep_db_fetch_array($newsletter_query);

  $nInfo->objectInfo($newsletter);
} elseif ($HTTP_POST_VARS) {
  $nInfo->objectInfo($HTTP_POST_VARS);
}

$file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
$directory_array = array();
if ($dir = dir(DIR_WS_MODULES . 'newsletters/')) {
  while ($file = $dir->read()) {
	if (!is_dir(DIR_WS_MODULES . 'newsletters/' . $file)) {
	  if (substr($file, strrpos($file, '.')) == $file_extension) {
		$directory_array[] = $file;
	  }
	}
  }
  sort($directory_array);
  $dir->close();
}

for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
  $modules_array[] = array('id' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')), 'text' => substr($directory_array[$i], 0, strrpos($directory_array[$i], '.')));
}
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr><?php echo tep_draw_form('newsletter', FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'action=' . $form_action); if ($form_action == 'update') echo tep_draw_hidden_field('newsletter_id', $nID); ?>
	<td><table border="0" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main"><?php echo TEXT_NEWSLETTER_MODULE; ?></td>
		<td class="main"><?php echo tep_draw_pull_down_menu('module', $modules_array, $nInfo->module); ?></td>
	  </tr>
	  <tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
	  <tr>
		<td class="main"><?php echo TEXT_NEWSLETTER_TITLE; ?></td>
		<td class="main"><?php echo tep_draw_input_field('title', $nInfo->title, '', true); ?></td>
	  </tr>
	  <tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
	  <tr>
		<td class="main" valign="top"><?php echo TEXT_NEWSLETTER_CONTENT; ?></td>
		<td class="main"><?php echo tep_draw_textarea_field('content', 'soft', '100%', '20', $nInfo->content); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main" align="right"><?php echo (($form_action == 'insert') ? tep_image_submit('button_save.gif', IMAGE_SAVE) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). '  <a href="' . tep_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . (isset($HTTP_GET_VARS['nID']) ? 'nID=' . $HTTP_GET_VARS['nID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
	  </tr>
	</table></td>
  </form></tr>
<?php
 } elseif ($action == 'preview') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

//$newsletter_query = tep_db_query("select title, content, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// BOF Separate Pricing Per Customer
$newsletter_query = tep_db_query("select title, content, module, send_to_customer_groups from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// EOF Separate Pricing Per Customer

$newsletter = tep_db_fetch_array($newsletter_query);

$nInfo = new objectInfo($newsletter);
?>
  <tr>
	<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
  </tr>
  <tr>
	<td><tt><?php echo nl2br($nInfo->content); ?></tt></td>
  </tr>
  <tr>
	<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
  </tr>
<?php
 } elseif ($action == 'send') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

//$newsletter_query = tep_db_query("select title, content, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// BOF Separate Pricing Per Customer
$newsletter_query = tep_db_query("select title, content, module, send_to_customer_groups from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// EOF Separate Pricing Per Customer

$newsletter = tep_db_fetch_array($newsletter_query);

$nInfo = new objectInfo($newsletter);

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
//$module = new $module_name($nInfo->title, $nInfo->content);
// BOF Separate Pricing Per Customer
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->send_to_customer_groups);
// EOF Separate Pricing Per Customer

?>
  <tr>
	<td><?php if ($module->show_choose_audience) { echo $module->choose_audience(); } else { echo $module->confirm(); } ?></td>
  </tr>
<?php
 } elseif ($action == 'confirm') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

//$newsletter_query = tep_db_query("select title, content, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// BOF Separate Pricing Per Customer
$newsletter_query = tep_db_query("select title, content, module, send_to_customer_groups from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// EOF Separate Pricing Per Customer

$newsletter = tep_db_fetch_array($newsletter_query);

$nInfo = new objectInfo($newsletter);

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
//$module = new $module_name($nInfo->title, $nInfo->content);
 // BOF Separate Pricing Per Customer
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->send_to_customer_groups);
// EOF Separate Pricing Per Customer

?>
  <tr>
	<td><?php echo $module->confirm(); ?></td>
  </tr>
<?php
 } elseif ($action == 'confirm_send') {
$nID = tep_db_prepare_input($HTTP_GET_VARS['nID']);

//$newsletter_query = tep_db_query("select newsletters_id, title, content, module from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// BOF Separate Pricing Per Customer
$newsletter_query = tep_db_query("select newsletters_id, title, content, module, send_to_customer_groups from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int)$nID . "'");
// EOF Separate Pricing Per Customer

$newsletter = tep_db_fetch_array($newsletter_query);
//---  Beginning of addition: Ultimate HTML Emails  ---//
if (EMAIL_USE_HTML == 'true') {
	$HTMLNewsletterContents = $newsletter['content'];
	require(DIR_FS_CATALOG_MODULES . 'UHtmlEmails/'. ULTIMATE_HTML_EMAIL_LAYOUT .'/newsletters.php');
	$newsletter['content'] = $html_email;

	if(ULTIMATE_HTML_EMAIL_DEVELOPMENT_MODE === 'true'){
		//Save the contents of the generated html email to the harddrive in .htm file. This can be practical when developing a new layout.
		$TheFileName = DIR_FS_CATALOG . 'Last_mail_from_newsletters.php.htm';
		$TheFileHandle = fopen($TheFileName, 'w') or die("can't open error log file");
		fwrite($TheFileHandle, $newsletter['content']);
		fclose($TheFileHandle);
	}

}
//---  End of addition: Ultimate HTML Emails  ---//

$nInfo = new objectInfo($newsletter);

include(DIR_WS_LANGUAGES . $language . '/modules/newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
include(DIR_WS_MODULES . 'newsletters/' . $nInfo->module . substr($PHP_SELF, strrpos($PHP_SELF, '.')));
$module_name = $nInfo->module;
//$module = new $module_name($nInfo->title, $nInfo->content);
// BOF Separate Pricing Per Customer
$module = new $module_name($nInfo->title, $nInfo->content, $nInfo->send_to_customer_groups);
// EOF Separate Pricing Per Customer
//---  Beginning of adittion: Ultimate HTML Emails  ---//
if((string)$module_name == "newsletter"){ //Do it the UHTML way! ---------------------------------------------------------------------------------------------------
	//Create the function to draw the progressbar based on "how many customers have received it"/"How many customers wan't newsletters"
	function draw_progress_bar($percent, $width, $height){
	global $uhtml_received_count, $uhtml_want_count;
		?>
		<p><span style="font-size:15pt;">Progress - <?php echo $percent; ?>%</span><br />
		<span style="font-size:12pt;"><?php echo $uhtml_received_count; ?> of <?php echo $uhtml_want_count ?> emails are sent.</span></p>
		<div align="left" style="width:<?php echo $width; ?>px; height:<?php echo $height; ?>px; border:2px solid #000000; padding:0px;">
			<div style="width:<?php echo (int)$percent/100*$width; ?>px; height:<?php echo $height; ?>px; background-color:#79973F;"></div>
		</div>
		<?php
	}
	$uhtml_received_count_query = tep_db_query("select count(*) as count from uhtml_newsletters_sent where newsletters_id = '" . (int)$nID . "'");
	$uhtml_received_count_query_array = tep_db_fetch_array($uhtml_received_count_query);
	$uhtml_received_count = $uhtml_received_count_query_array['count'];

	$uhtml_want_count_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
	$uhtml_want_count_query_array = tep_db_fetch_array($uhtml_want_count_query);
	$uhtml_want_count = $uhtml_want_count_query_array['count'];
	$uhtml_bar_percent = round($uhtml_received_count/$uhtml_want_count*100,0);

	?>
	  <tr>
		<td><table border="0" cellspacing="0" cellpadding="2">
		  <tr>
			<td class="main" valign="middle" colspan="2"><?php draw_progress_bar($uhtml_bar_percent, 400, 30); ?></td>
		  </tr>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		  </tr>
		  <tr>
			<td class="main" valign="middle" colspan="2"><p>The sending of the newsletters is in progress. Please wait untill it is finnished.</p><p>If the process is interrupted somehow, there is no need to worry. Just try to send the newsletter again and the process will continue where it was interrupted. No customer will receive duplets of emails as which emails are sent is logged in the database.</p></td>
		  </tr>
		</table></td>
	  </tr>
	<?php
	if($uhtml_received_count != $uhtml_want_count ){ //Send a pack of emails
		tep_set_time_limit(0);
		flush();
		$module->send($nInfo->newsletters_id);
		// This FOLLOWING CODE reload will make the page reload to send another package:
		?>
			<script type="text/javascript">
			<!--
			window.location = window.location.href
			//-->
			</script>
		<?php
	}else{ //All emails are sent!
		tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . (int)$nID . "'"); //Mark the newsletter as sent
		?>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		  </tr>
		  <tr>
			<td class="main"><font color="#ff0000"><b><?php echo TEXT_FINISHED_SENDING_EMAILS; ?></b></font></td>
		  </tr>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		  </tr>
		  <tr>
			<td><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
		  </tr>
		<?php
	}
}else{ //Do it the standard way for product notifications ---------------------------------------------------------------------------------------------------
//---  End of addition: Ultimate HTML Emails  ---//
?>
  <tr>
	<td><table border="0" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="main" valign="middle"><?php echo tep_image(DIR_WS_IMAGES . 'ani_send_email.gif', IMAGE_ANI_SEND_EMAIL); ?></td>
		<td class="main" valign="middle"><b><?php echo TEXT_PLEASE_WAIT; ?></b></td>
	  </tr>
	</table></td>
  </tr>
<?php
 tep_set_time_limit(0);
 flush();
// $module->send($nInfo->newsletters_id);
  // BOF Separate Pricing Per Customer
 $module->send($nInfo->newsletters_id, $nInfo->send_to_customer_groups);
// EOF Separate Pricing Per Customer
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
	<td class="main"><font color="#ff0000"><b><?php echo TEXT_FINISHED_SENDING_EMAILS; ?></b></font></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
	<td><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
  </tr>
<?php
//---  Beginning of adittion: Ultimate HTML Emails  ---//
}
//---  End of addition: Ultimate HTML Emails  ---//	
 } 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_NEWSLETTERS; ?></td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_SIZE; ?></td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_MODULE; ?></td>
			<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_SENT; ?></td>
			<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
		  </tr>
<?php
//$newsletters_query_raw = "select newsletters_id, title, length(content) as content_length, module, date_added, date_sent, status, locked from " . TABLE_NEWSLETTERS . " order by date_added desc";
// BOF Separate Pricing Per Customer
$newsletters_query_raw = "select newsletters_id, title, length(content) as content_length, module, date_added, date_sent, status, locked, send_to_customer_groups from " . TABLE_NEWSLETTERS . " order by date_added desc";
// EOF Separate Pricing Per Customer


$newsletters_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $newsletters_query_raw, $newsletters_query_numrows);
$newsletters_query = tep_db_query($newsletters_query_raw);
while ($newsletters = tep_db_fetch_array($newsletters_query)) {
if ((!isset($HTTP_GET_VARS['nID']) || (isset($HTTP_GET_VARS['nID']) && ($HTTP_GET_VARS['nID'] == $newsletters['newsletters_id']))) && !isset($nInfo) && (substr($action, 0, 3) != 'new')) {
	$nInfo = new objectInfo($newsletters);
  }

  if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) {
	echo '				  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '\'">' . "\n";
  } else {
	echo '				  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '\'">' . "\n";
  }
?>
			<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id'] . '&action=preview') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $newsletters['title']; ?></td>
			<td class="dataTableContent" align="right"><?php echo number_format($newsletters['content_length']) . ' bytes'; ?></td>
			<td class="dataTableContent" align="right"><?php echo $newsletters['module']; ?></td>
			<td class="dataTableContent" align="center"><?php if ($newsletters['status'] == '1') { echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK); } else { echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS); } ?></td>
			<td class="dataTableContent" align="center"><?php if ($newsletters['locked'] > 0) { echo tep_image(DIR_WS_ICONS . 'locked.gif', ICON_LOCKED); } else { echo tep_image(DIR_WS_ICONS . 'unlocked.gif', ICON_UNLOCKED); } ?></td>
			<td class="dataTableContent" align="right"><?php if (isset($nInfo) && is_object($nInfo) && ($newsletters['newsletters_id'] == $nInfo->newsletters_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $newsletters['newsletters_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
		  </tr>
<?php
}
?>
		  <tr>
			<td colspan="6"><table border="0" width="100%" cellspacing="0" cellpadding="2">
			  <tr>
				<td class="smallText" valign="top"><?php echo $newsletters_split->display_count($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_NEWSLETTERS); ?></td>
				<td class="smallText" align="right"><?php echo $newsletters_split->display_links($newsletters_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
			  </tr>
			  <tr>
				<td align="right" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'action=new') . '">' . tep_image_button('button_new_newsletter.gif', IMAGE_NEW_NEWSLETTER) . '</a>'; ?></td>
			  </tr>
			</table></td>
		  </tr>
		</table></td>
<?php
 $heading = array();
 $contents = array();

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

  $contents = array('form' => tep_draw_form('newsletters', FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=deleteconfirm'));
  $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
  $contents[] = array('text' => '<br><b>' . $nInfo->title . '</b>');
  $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  break;
default:
  if (is_object($nInfo)) {
	$heading[] = array('text' => '<b>' . $nInfo->title . '</b>');
// BOF Separate Pricing Per Customer
if (tep_not_null($cg_array)) {
	$cg_array_in_db = explode(',', $nInfo->send_to_customer_groups);
	$table_with_check_boxes_cgs = "
	<table border='0' cellspacing='0' cellpadding='2' style='border: 1px solid #c9c9c9; margin-top='10px;'>
	 <tr class='dataTableHeadingRow'>
	 <td class='dataTableHeadingContent'>" . TABLE_HEADING_CUSTOMERS_GROUPS . "</td>
	 <td class='dataTableHeadingContent'> </td>
	 </tr>";
$c = '0'; // variable used for background coloring of rows
  for ($z = 0; $z < sizeof($cg_array); $z++) { 
  $bgcolor = ($c++ & 1) ? " class='dataTableRow'" : ""; 
$table_with_check_boxes_cgs .= "
	 <tr" . $bgcolor . ">
	 <td class='dataTableContent'>" . $cg_array[$z]['customers_group_name'] . " </td>
	 <td class='dataTableContent' align='right'>" . tep_draw_checkbox_field('send_to_cgs[' . $z . ']', $cg_array[$z]['id'] , (in_array ($cg_array[$z]['id'], $cg_array_in_db)) ?  1 : 0) . "</td>
	 </tr>
	 ";
  } // end for ($z = 0; $z < sizeof($cg_array); $z++) 
$table_with_check_boxes_cgs .= "		 </table>";
}
 // EOF Separate Pricing Per Customer

	if ($nInfo->locked > 0) {
	  $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=new') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=unlock') . '">' . tep_image_button('button_unlock.gif', IMAGE_UNLOCK) . '</a>');
	} else {
	  $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=preview') . '">' . tep_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $nInfo->newsletters_id . '&action=lock') . '">' . tep_image_button('button_lock.gif', IMAGE_LOCK) . '</a>');
	}
	$contents[] = array('text' => '<br>' . TEXT_NEWSLETTER_DATE_ADDED . ' ' . tep_date_short($nInfo->date_added));
	if ($nInfo->status == '1') $contents[] = array('text' => TEXT_NEWSLETTER_DATE_SENT . ' ' . tep_date_short($nInfo->date_sent));
 	// BOF Separate Pricing Per Customer
	$contents[] = array('text' => TEXT_SEND_TO_CUSTOMERS_GROUPS . '<div align="center" style="margin-bottom: 10px;">'. tep_draw_form('select_customer_groups', FILENAME_NEWSLETTERS, tep_get_all_get_params() . 'action=update_cgs', 'post') . $table_with_check_boxes_cgs . '<br clear="all">'. tep_image_submit('button_update.gif', IMAGE_UPDATE) . '</form></div>');
// EOF Separate Pricing Per Customer
  }
  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>
<?php
 }
?>
</table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

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

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...