MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b744/yushibrentwood.com/
File Upload :
Current < : /hermes/sb_web/b744/yushibrentwood.com/print_specials.php

<?php
/***************************************************************************************
/*                            Revision Control Block
/***************************************************************************************
/* Script:	   print_specials.php
/* Abstract:   This module dynamically generates a printable page that includes all of 
               the specials in the Zen Cart store by Category.
/* 
/* Developer:  Tiger Team Solutions, LLC
/*             9712 Temple Drive 
/* 			   Little Rock, AR  72205
/*             1-501-228-4638 (ph)
/*			   1-501-588-0360 (fax) 
/*			   http://www.bestwebsitedevelopment.com/ 
/*             management@tigerteamsolutions.com
/***************************************************************************************/

// change <img src="admin/images/small_zen_logo.gif" /> to your company logo

//File updated to include products on special in ALL sub categories 10/13/08
//File updated to take into account apostraphes 10/13/08

require('includes/application_top.php');
$webpage = 'http://' . $_SERVER["SERVER_NAME"].str_replace('print_specials.php','',$_SERVER["REQUEST_URI"]);

//header and styles info
$output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>'.str_replace("'","\'",STORE_NAME).' Specials</title>' .
'<style type="text/css">' .
		' @media print { ' .
			'.buttonDisplay { display: none; }' .
                       'p.lastp {page-break-before: always;' .
								'padding: 0px;' .
                                 'margin: 0px;' .
					   '}' .
                        ' .title { color: darkblue;' .
                                  ' font-weight: bold; }' .
						' .subtitle { color: darkorange;' .
						          ' font-weight: bold; }' .
                        ' .red { color: red; }' .
                        ' .black { color: #000000; ' .
                                 ' font-weight: bold; }' .
                        ' .small { color: #999999; ' .
                                 ' font-size: 10px; }' .
						' a {     color: darkblue;' .
                                 'font-size: 10px; }' .
                       ' body, p, h2 { font-family: Arial; }' .
                 '}' .
                 '@media screen { ' .
			'.button { display: block; }' .
                        ' .title { color: darkblue;' .
                                  ' font-weight: bold; }' .
						' .subtitle { color: darkorange;' .
						          ' font-weight: bold; }' .
                        ' .red { color: red; }' .
                        ' .black { color: #000000; ' .
                                 ' font-weight: bold; }' .
                        ' .small { color: #999999; ' .
                                 ' font-size: 10px; }' .
						' a {     color: darkblue;' .
                                 'font-size: 10px; }' .
                        'body, p, h2 { font-family: Arial; }' .
                        'p.lastp {page-break-before: always;' .
								'padding: 0px;' .
                                 'margin: 0px;' .
						'}' .
                   '}' .
'</style></head>';

$output .= '<body>';
$output .= '<div style="float: right;" class="buttonDisplay"><button name="printbtn" onClick="javascript:window.print()">Print Specials</button></div><div>&nbsp;</div>';
$output .= '<br><div align="center"><a href="'.$webpage.'"><img src="admin/images/small_zen_logo.gif" border="0" /></a></div>' .
     '<center>' .
     '<table align="center" width="560px;">' .
         '<tr>' .
             '<td colspan="3" align="center"><br><span class="title" style="font-size:16px;">'.str_replace("'","\'",STORE_NAME).' Specials</span><br>'.
             '<span><a href="'.$webpage.'">'.$webpage.'</a></span></td>'.
         '</tr>';

//select all of the categories in the zen cart DB
$query_cat = "SELECT categories_name, c.categories_id FROM ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd where
c.categories_id = cd.categories_id and parent_id = 0 order by categories_name";
$result_cat = mysql_query($query_cat);

$cat0 = 0;
$cats = "";
$subs = "";
//select all the products that are on special by category
while($cat = mysql_fetch_array($result_cat)){
$cats = "(p2c.categories_id = '" . $cat["categories_id"] . "'";
$subs = $cat["categories_id"];

while($subs != ""){
	$query_subs = "SELECT categories_id from ".TABLE_CATEGORIES." where parent_id = '".$subs."'";
	$result_subs = mysql_query($query_subs);
	if(mysql_num_rows($result_subs) > 0){
		while($sub = mysql_fetch_array($result_subs)){
			$cats = $cats . " or p2c.categories_id = '" . $sub["categories_id"] . "'";
			$subs = $sub["categories_id"];
		}
	}else{
		$subs = "";
	}
	
}
$cats = $cats . ")";

//$query = "select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_priced_by_attribute, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status, s.specials_date_available from ".TABLE_PRODUCTS." p, ".TABLE_SPECIALS." s, ".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c, ".TABLE_CATEGORIES." c where p.products_id = p2c.products_id and c.categories_id = p2c.categories_id and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = s.products_id and s.expires_date >= now() and specials_date_available <=now() and ".$cats." order by pd.products_name";

$query = "select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_priced_by_attribute, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status, s.specials_date_available from ".TABLE_PRODUCTS." p, ".TABLE_SPECIALS." s, ".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS_TO_CATEGORIES." p2c where p.products_id = p2c.products_id and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = s.products_id and s.expires_date >= now() and specials_date_available <=now() and status = '1' and ".$cats." order by pd.products_name";


$result = mysql_query($query);
$num = mysql_num_rows($result);
$subnum = 0;
if($num < 1){
    $startnum = 0;
}else{
    $startnum = 1;
	$cat0++;
}
if(($num - 20) > 0){
   $subnum = 20;
}else{
   $subnum = $num;
}
if($num > 0){

	if($cat0 != 1){
	 $output .= '</table>';
      $output .= '<p class="lastp">&nbsp;</p>' .
      '<table align="center" width="560px;">' .
         '<tr>' .
             '<td colspan="3" align="center"><br><span class="title" style="font-size:16px;">'.str_replace("'","\'",STORE_NAME).' Specials</span><br>'.
             '<span><a href="'.$webpage.'">'.$webpage.'</a></span></td>'.
         '</tr>';
	 }


	$output .='<tr><td colspan="3"><img src="images/specialsline.gif" /></td></tr>' . 
          '<tr>' .
            '<td colspan="3" class="subtitle" align="center">'.str_replace("'","\'",$cat["categories_name"]).' Specials</td>' .
		  '</tr>' .
		  '<tr>' .
             '<td colspan="3" align="left">' .
                  '<span class="small" style="float:right">'.date("m/d/Y").'</span>' .
                  '<span class="small">Displaying '.$startnum . ' to ' . $subnum.' (of '.$num.' Results)</span><br>'.
                  '<img src="images/specialsline.gif" />' .
             '</td>' .
         '</tr>';  
}       

$test = true;
$count = 0;

while($row = mysql_fetch_array($result)){

//echo $row["specials_id"] . '<br />';

   if($test == true){
	   if($count == 20){
			$count = 0;
	
			$startnum = $startnum + 20;
			   if(($num -$subnum - 10) > 0){
				   $subnum = $subnum + 20;
			   }else{
				   $subnum = $num;
			   }

      $output .= '</table>';
      $output .= '<p class="lastp">&nbsp;</p>' .
      '<table align="center" width="560px;">' .
         '<tr>' .
             '<td colspan="3" align="center"><br><span class="title" style="font-size:16px;">'.str_replace("'","\'",STORE_NAME).' Specials</span><br>'.
             '<span><a href="'.$webpage.'">'.$webpage.'</a></span></td>'.
         '</tr>' .
		 '<tr><td colspan="3"><img src="images/specialsline.gif" /></td></tr>' . 
          '<tr>' .
            '<td colspan="3" class="subtitle" align="center">'.str_replace("'","\'",$cat["categories_name"]).' Specials</td>' .
		 '</tr>' .
         '<tr>' .
             '<td colspan="3" align="left">' .
                  '<span class="small" style="float:right">'.date("m/d/Y").'</span>' .
                  '<span class="small">Displaying '.$startnum. ' to '.$subnum.' (of '.$num.' Results)</span><br>'.
                  '<img src="images/specialsline.gif" />' .
             '</td>' .
         '</tr>';

   		}

        $count++;
        $output .= '<tr><td valign="top"><span class="title">'.str_replace("'","\'",$row["products_name"]).'</span><br><strike>$'.number_format($row["products_price"] , 2).'</strike>&nbsp;&nbsp;<span class="red">$'.number_format($row["specials_new_products_price"],2) .'</span><br><span class="small">[exp. '.date("m/d/Y", strtotime($row["expires_date"])).']</span></td><td>&nbsp;&nbsp;</td>';
        $test = false;
   }else{
         $count++;
         $output .= '<td valign="top" align="left"><span class="title">'.str_replace("'","\'",$row["products_name"]).'</span><br><strike>$'.number_format($row["products_price"] , 2).'</strike>&nbsp;&nbsp;<span class="red">$'.number_format($row["specials_new_products_price"],2) .'</span><br><span class="small">[exp. '.date("m/d/Y", strtotime($row["expires_date"])).']</span></td></tr>';
        $test = true;
   }

   if($test == true){
       $output .= '<tr><td colspan="3"><img src="images/specialsline.gif" /></td></tr>';
   }




}
if($test == $false){
   $output .= '<td>&nbsp;</td></tr><tr><td colspan="3"><img src="images/specialsline.gif" /></td></tr>';
}

$cats = "";
$test = "";
}

if($cat0 == 0){

//If there ar eno speials display this message
 $output .=  '<tr>' .
             '<td colspan="3" align="left"><br>' .
                  '<span class="small" style="float:right">'.date("m/d/Y").'</span>' .
                  '<span class="small">Displaying '.$startnum. ' to '.$subnum.' (of '.$num.' Results)</span><br>'.
                  '<img src="images/specialsline.gif" />' .
             '</td>' .
         '</tr>' .
 			'<tr><td colspan="3" align="center"><span class="small">' .
            'There are no specials at this time. Please try again soon!' .
           '</span></td></tr>' .
            '<tr><td colspan="3"><img src="images/specialsline.gif" /></td></tr>';

}


$output .=  '</table></center>';

$output .= '<div style="float: right;" class="buttonDisplay"><button name="printbtn" onClick="javascript:window.print()">Print Specials</button></div><div>&nbsp;</div>';
$output .= '</body></html>';

 // run the script on	 
echo '<script type="text/javascript" language="javascript">';
echo 'pageRef = window.open("", target="_self");';
echo 'pageRef.document.open("text/html", "replace");';
echo "pageRef.document.write('".$output."');" ;
echo "pageRef.document.close();";
echo'</script>';
//end print output


?>
<?php require(DIR_WS_INCLUDES . 'specials_footer.php');?>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>