Viewing file: specials.php (18.53 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? include('includes/application_top.php'); ?>
<?
if ($HTTP_GET_VARS['action']) {
if ($HTTP_GET_VARS['action'] == 'insert') {
tep_db_query("insert into specials values ('', '" . $HTTP_POST_VARS['products_id'] . "', '" . $HTTP_POST_VARS['specials_new_products_price'] . "', '" . date('Ymd') . "')");
header('Location: ' . tep_href_link(FILENAME_SPECIALS, '', 'NONSSL')); tep_exit();
} elseif ($HTTP_GET_VARS['action'] == 'save') {
tep_db_query("update specials set specials_new_products_price = '" . $HTTP_POST_VARS['specials_price'] . "' where specials_id = '" . $HTTP_POST_VARS['specials_id'] . "'");
header('Location: ' . tep_href_link(FILENAME_SPECIALS, '', 'NONSSL')); tep_exit();
} elseif ($HTTP_GET_VARS['action'] == 'deleteconfirm') {
tep_db_query("delete from specials where specials_id = '" . $HTTP_POST_VARS['specials_id'] . "'");
header('Location: ' . tep_href_link(FILENAME_SPECIALS, '', 'NONSSL')); tep_exit();
}
}
?>
<html>
<head>
<title><? echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body onload="SetFocus();" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<? $include_file = DIR_WS_INCLUDES . 'header.php'; include(DIR_WS_INCLUDES . 'include_once.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="5" cellpadding="5">
<tr>
<td width="<? echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<? echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<? $include_file = DIR_WS_INCLUDES . 'column_left.php'; include(DIR_WS_INCLUDES . 'include_once.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
</tr>
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="boxborder">
<tr>
<td bgcolor="<? echo TOP_BAR_BACKGROUND_COLOR; ?>" width="100%" nowrap><font face="<? echo TOP_BAR_FONT_FACE; ?>" size="<? echo TOP_BAR_FONT_SIZE; ?>" color="<? echo TOP_BAR_FONT_COLOR; ?>"> <? echo TOP_BAR_TITLE; ?> </font></td>
</tr>
</table></td>
</tr>
<tr>
<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td nowrap><font face="<? echo HEADING_FONT_FACE; ?>" size="<? echo HEADING_FONT_SIZE; ?>" color="<? echo HEADING_FONT_COLOR; ?>"> <? echo HEADING_TITLE; ?> </font></td>
<td align="right" nowrap> <? echo tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT, '0', ''); ?> </td>
</tr>
</table></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><? echo tep_black_line(); ?></td>
</tr>
<tr>
<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td nowrap><font face="<? echo TABLE_HEADING_FONT_FACE; ?>" size="<? echo TABLE_HEADING_FONT_SIZE; ?>" color="<? echo TABLE_HEADING_FONT_COLOR; ?>"><b> <? echo TABLE_HEADING_PRODUCTS; ?> </b></font></td>
<td align="right" nowrap><font face="<? echo TABLE_HEADING_FONT_FACE; ?>" size="<? echo TABLE_HEADING_FONT_SIZE; ?>" color="<? echo TABLE_HEADING_FONT_COLOR; ?>"><b> <? echo TABLE_HEADING_PRODUCTS_PRICE; ?> </b></font></td>
<td align="center" nowrap><font face="<? echo TABLE_HEADING_FONT_FACE; ?>" size="<? echo TABLE_HEADING_FONT_SIZE; ?>" color="<? echo TABLE_HEADING_FONT_COLOR; ?>"><b> <? echo TABLE_HEADING_DATE_ADDED; ?> </b></font></td>
<td align="center" nowrap><font face="<? echo TABLE_HEADING_FONT_FACE; ?>" size="<? echo TABLE_HEADING_FONT_SIZE; ?>" color="<? echo TABLE_HEADING_FONT_COLOR; ?>"><b> <? echo TABLE_HEADING_ACTION; ?> </b></font></td>
</tr>
<tr>
<td colspan="4"><? echo tep_black_line(); ?></td>
</tr>
<?
$rows = 0;
$specials_query_raw = "select p.products_id, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added from products p, specials s where p.products_id = s.products_id order by s.specials_date_added DESC";
$specials_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $specials_query_raw, $specials_query_numrows);
$specials_query = tep_db_query($specials_query_raw);
while ($specials = tep_db_fetch_array($specials_query)) {
$rows++;
if (((!$HTTP_GET_VARS['info']) || (@$HTTP_GET_VARS['info'] == $specials['specials_id'])) && (!$sInfo) && (substr($HTTP_GET_VARS['action'], 0, 3) != 'new')) {
$products_query = tep_db_query("select products_image from products where products_id = '" . $specials['products_id'] . "'");
$products = tep_db_fetch_array($products_query);
$sInfo_array = tep_array_merge($specials, $products);
$sInfo = new specialPriceInfo($sInfo_array);
}
if ($specials['specials_id'] == @$sInfo->id) {
echo ' <tr bgcolor="#b0c8df">' . "\n";
} else {
echo ' <tr bgcolor="#d8e1eb" onmouseover="this.style.background=\'#cc9999\';this.style.cursor=\'hand\'" onmouseout="this.style.background=\'#d8e1eb\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('info', 'action')) . 'info=' . $specials['specials_id'], 'NONSSL') . '\'">' . "\n";
}
?>
<td nowrap><font face="<? echo SMALL_TEXT_FONT_FACE; ?>" size="<? echo SMALL_TEXT_FONT_SIZE; ?>" color="<? echo SMALL_TEXT_FONT_COLOR; ?>"> <? echo tep_products_name($specials['products_id']); ?> </font></td>
<td align="right" nowrap><font face="<? echo SMALL_TEXT_FONT_FACE; ?>" size="<? echo SMALL_TEXT_FONT_SIZE; ?>" color="<? echo SMALL_TEXT_FONT_COLOR; ?>"> <s><? echo tep_currency_format($specials['products_price']); ?></s> <font color="<? echo SPECIALS_PRICE_COLOR; ?>"><? echo tep_currency_format($specials['specials_new_products_price']); ?></font> </font></td>
<td align="center" nowrap><font face="<? echo SMALL_TEXT_FONT_FACE; ?>" size="<? echo SMALL_TEXT_FONT_SIZE; ?>" color="<? echo SMALL_TEXT_FONT_COLOR; ?>"> <? echo tep_date_short($specials['specials_date_added']); ?> </font></td>
<?
if ($specials['specials_id'] == @$sInfo->id) {
?>
<td align="center" nowrap><font face="<? echo SMALL_TEXT_FONT_FACE; ?>" size="<? echo SMALL_TEXT_FONT_SIZE; ?>" color="<? echo SMALL_TEXT_FONT_COLOR; ?>"> <? echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', 13, 13, 0, ''); ?> </font></td>
<?
} else {
?>
<td align="center" nowrap><font face="<? echo SMALL_TEXT_FONT_FACE; ?>" size="<? echo SMALL_TEXT_FONT_SIZE; ?>" color="<? echo SMALL_TEXT_FONT_COLOR; ?>"> <? echo '<a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('info', 'action')) . 'info=' . $specials['specials_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', '13', '13', '0', IMAGE_ICON_INFO) . '</a>'; ?> </font></td>
<?
}
?>
</tr>
<?
}
?>
<tr>
<td colspan="4"><? echo tep_black_line(); ?></td>
</tr>
<tr>
<td colspan="4"><table border="0" width="100%" cellpadding="0"cellspacing="2">
<tr>
<td valign="top" nowrap><font face="<? echo SMALL_TEXT_FONT_FACE; ?>" size="<? echo SMALL_TEXT_FONT_SIZE; ?>" color="<? echo SMALL_TEXT_FONT_COLOR; ?>"> <? echo $specials_split->display_count($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?> </font></td>
<td align="right" nowrap><font face="<? echo SMALL_TEXT_FONT_FACE; ?>" size="<? echo SMALL_TEXT_FONT_SIZE; ?>" color="<? echo SMALL_TEXT_FONT_COLOR; ?>"> <? echo TEXT_RESULT_PAGE; ?> <? echo $specials_split->display_links($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?> <? if (substr($HTTP_GET_VARS['action'], 0, 3) != 'new') echo '<br><br> <a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action', 'info')) . 'action=new', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_new_product.gif', '103', '20', '0', IMAGE_NEW_PRODUCT) . '</a> '; ?></font></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="25%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?
$info_box_contents = array();
if ($sInfo) $info_box_contents[] = array('align' => 'left', 'text' => ' <b>' . tep_products_name($sInfo->products_id) . '</b> ');
if ((!$sInfo) && ($HTTP_POST_VARS['products_id'])) $info_box_contents[] = array('align' => 'left', 'text' => ' <b>' . tep_products_name($HTTP_POST_VARS['products_id']) . '</b> ');
if ((!$sInfo) && (!$HTTP_POST_VARS['products_id'])) $info_box_contents[] = array('align' => 'left', 'text' => ' <b>' . TEXT_INFO_HEADING_NEW_PRODUCT . '</b> ');
?>
<tr bgcolor="#81a2b6">
<td>
<? new infoBoxHeading($info_box_contents); ?>
</td>
</tr>
<tr bgcolor="#81a2b6">
<td><? echo tep_black_line(); ?></td>
</tr>
<?
if ($HTTP_GET_VARS['action'] == 'edit') {
$form = '<form name="specials_edit" action="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')) . 'action=save', 'NONSSL') . '" method="post"><input type="hidden" name="specials_id" value="' . $sInfo->id . '">' ."\n";
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left', 'text' => TEXT_INFO_EDIT_INTRO . '<br> ');
$info_box_contents[] = array('align' => 'left', 'text' => ' ' . TEXT_INFO_EDIT_SPECIALS_PRICE . '<br> <input type="text" name="specials_price" value="' . $sInfo->specials_price . '" size="8"><br> ');
$info_box_contents[] = array('align' => 'center', 'text' => tep_image_submit(DIR_WS_IMAGES . 'button_save.gif', '66', '20', '0', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')), 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_cancel.gif', '66', '20', '0', IMAGE_CANCEL) . '</a>');
} elseif ($HTTP_GET_VARS['action'] == 'delete') {
$form = '<form name="specials_delete" action="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')) . 'action=deleteconfirm', 'NONSSL') . '" method="post"><input type="hidden" name="specials_id" value="' . $sInfo->id . '">' . "\n";
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left', 'text' => TEXT_INFO_DELETE_INTRO . '<br> ');
$info_box_contents[] = array('align' => 'left', 'text' => ' <b>' . $sInfo->products_name . '</b>');
$info_box_contents[] = array('align' => 'center', 'text' => tep_image_submit(DIR_WS_IMAGES . 'button_delete.gif', '66', '20', '0', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')), 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_cancel.gif', '66', '20', '0', IMAGE_CANCEL) . '</a>');
} elseif ($HTTP_GET_VARS['action'] == 'new') {
if (!$HTTP_POST_VARS['products_id']) {
// we have to choose a product first, so we know the original price
$form = '<form name="specials_new" action="' . tep_href_link(FILENAME_SPECIALS, 'action=new', 'NONSSL') . '" method="post">' ."\n";
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left', 'text' => TEXT_INFO_SELECT_PRODUCT_INTRO . '<br> ');
$info_box_contents[] = array('align' => 'left', 'text' => ' ' . tep_products_pull_down('name="products_id" style="font-size:10px"'));
$info_box_contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit(DIR_WS_IMAGES . 'button_select.gif', '66', '20', '0', IMAGE_SELECT) . ' <a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')), 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_cancel.gif', '66', '20', '0', IMAGE_CANCEL) . '</a>');
} else {
// product has been chosen, its time to specify the new price
$product_query = tep_db_query("select products_price from products where products_id = '" . $HTTP_POST_VARS['products_id'] . "'");
$product = tep_db_fetch_array($product_query);
$sInfo_array = tep_array_merge($HTTP_POST_VARS, $product);
$sInfo = new specialPriceInfo($sInfo_array);
$form = '<form name="specials_new" action="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')) . 'action=new_preview', 'NONSSL') . '" method="post"><input type="hidden" name="products_id" value="' . $sInfo->products_id . '">' ."\n";
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left', 'text' => TEXT_INFO_INSERT_INTRO . '<br> ');
$info_box_contents[] = array('align' => 'left', 'text' => '<b>' . tep_products_name($sInfo->products_id) . '</b><br>' . TEXT_INFO_ORIGINAL_PRICE . ' ' . tep_currency_format($sInfo->products_price) . '<br> ');
$info_box_contents[] = array('align' => 'left', 'text' => ' ' . TEXT_INFO_EDIT_SPECIALS_PRICE . '<br> <input type="text" name="specials_new_products_price" size="8"><br>' . TEXT_INFO_SPECIAL_PRICE_TIP . '<br> ');
if (!EXPERT_MODE) $info_box_contents[] = array('align' => 'left', 'text' => TEXT_INFO_NEW_PRICE_NOTE . '<br> ');
$info_box_contents[] = array('align' => 'center', 'text' => tep_image_submit(DIR_WS_IMAGES . 'button_preview.gif', '66', '20', '0', IMAGE_PREVIEW) . ' <a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')), 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_cancel.gif', '66', '20', '0', IMAGE_CANCEL) . '</a>');
}
} elseif ($HTTP_GET_VARS['action'] == 'new_preview') {
$product_query = tep_db_query("select products_price, products_image from products where products_id = '" . $HTTP_POST_VARS['products_id'] . "'");
$product = tep_db_fetch_array($product_query);
if (substr($HTTP_POST_VARS['specials_new_products_price'], -1) == '%') $HTTP_POST_VARS['specials_new_products_price'] = ($product['products_price'] - (($HTTP_POST_VARS['specials_new_products_price'] / 100) * $product['products_price']));
$sInfo_array = tep_array_merge($HTTP_POST_VARS, $product);
$sInfo = new specialPriceInfo($sInfo_array);
$form = '<form name="specials_new" action="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')) . 'action=insert', 'NONSSL') . '" method="post"><input type="hidden" name="products_id" value="' . $sInfo->products_id . '"><input type="hidden" name="specials_new_products_price" value="' . $sInfo->specials_price . '">' ."\n";
$info_box_contents = array();
$info_box_contents[] = array('align' => 'left', 'text' => '<br> ' . TEXT_DATE_ADDED . ' ' . tep_date_short(date('Ymd')));
$info_box_contents[] = array('align' => 'left', 'text' => '<br>' . tep_info_image($sInfo->products_image, tep_products_name($sInfo->products_id)));
$info_box_contents[] = array('align' => 'left', 'text' => '<br> ' . TEXT_INFO_NEW_PRICE . ' ' . tep_currency_format($sInfo->specials_price));
$info_box_contents[] = array('align' => 'left', 'text' => ' ' . TEXT_INFO_ORIGINAL_PRICE . ' ' . tep_currency_format($sInfo->products_price));
$info_box_contents[] = array('align' => 'left', 'text' => ' ' . TEXT_INFO_PERCENTAGE . ' ' . number_format($sInfo->percentage, 2) . '%<br> <br>');
$info_box_contents[] = array('align' => 'center', 'text' => tep_image_submit(DIR_WS_IMAGES . 'button_insert.gif', '66', '20', '0', IMAGE_INSERT) . ' <a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')), 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_cancel.gif', '66', '20', '0', IMAGE_CANCEL) . '</a>');
} else { // default info box
$info_box_contents = array();
$info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')) . 'action=edit', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_edit.gif', '66', '20', '0', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action')) . 'action=delete', 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'button_delete.gif', '66', '20', '0', IMAGE_DELETE) . '</a>');
$info_box_contents[] = array('align' => 'left', 'text' => '<br> ' . TEXT_DATE_ADDED . ' ' . tep_date_short($sInfo->date_added) . '<br> ' . TEXT_LAST_MODIFIED);
$info_box_contents[] = array('align' => 'left', 'text' => '<br>' . tep_info_image($sInfo->products_image, tep_products_name($sInfo->products_id)));
$info_box_contents[] = array('align' => 'left', 'text' => '<br> ' . TEXT_INFO_NEW_PRICE . ' ' . tep_currency_format($sInfo->specials_price));
$info_box_contents[] = array('align' => 'left', 'text' => ' ' . TEXT_INFO_ORIGINAL_PRICE . ' ' . tep_currency_format($sInfo->products_price));
$info_box_contents[] = array('align' => 'left', 'text' => ' ' . TEXT_INFO_PERCENTAGE . ' ' . number_format($sInfo->percentage, 2) . '%');
}
?>
<tr bgcolor="#b0c8df"><? echo $form; ?>
<td>
<? new infoBox($info_box_contents); ?>
</td>
<? if ($form) echo '</form>'; ?></tr>
<tr bgcolor="#b0c8df">
<td><? echo tep_black_line(); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<? $include_file = DIR_WS_INCLUDES . 'footer.php'; include(DIR_WS_INCLUDES . 'include_once.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<? $include_file = DIR_WS_INCLUDES . 'application_bottom.php'; include(DIR_WS_INCLUDES . 'include_once.php'); ?>
|