| [ Index ] |
|
Code source de osCommerce 2.2ms2-060817 |
1 <?php 2 /* 3 $Id: specials.php,v 1.41 2003/06/29 22:50:52 hpdl Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2003 osCommerce 9 10 Released under the GNU General Public License 11 */ 12 13 require ('includes/application_top.php'); 14 15 require (DIR_WS_CLASSES . 'currencies.php'); 16 $currencies = new currencies(); 17 18 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); 19 20 if (tep_not_null($action)) { 21 switch ($action) { 22 case 'setflag': 23 tep_set_specials_status($HTTP_GET_VARS['id'], $HTTP_GET_VARS['flag']); 24 25 tep_redirect(tep_href_link(FILENAME_SPECIALS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'sID=' . $HTTP_GET_VARS['id'], 'NONSSL')); 26 break; 27 case 'insert': 28 $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); 29 $products_price = tep_db_prepare_input($HTTP_POST_VARS['products_price']); 30 $specials_price = tep_db_prepare_input($HTTP_POST_VARS['specials_price']); 31 $day = tep_db_prepare_input($HTTP_POST_VARS['day']); 32 $month = tep_db_prepare_input($HTTP_POST_VARS['month']); 33 $year = tep_db_prepare_input($HTTP_POST_VARS['year']); 34 35 if (substr($specials_price, -1) == '%') { 36 $new_special_insert_query = tep_db_query("select products_id, products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); 37 $new_special_insert = tep_db_fetch_array($new_special_insert_query); 38 39 $products_price = $new_special_insert['products_price']; 40 $specials_price = ($products_price - (($specials_price / 100) * $products_price)); 41 } 42 43 $expires_date = ''; 44 if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year)) { 45 $expires_date = $year; 46 $expires_date .= (strlen($month) == 1) ? '0' . $month : $month; 47 $expires_date .= (strlen($day) == 1) ? '0' . $day : $day; 48 } 49 50 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')"); 51 52 tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'])); 53 break; 54 case 'update': 55 $specials_id = tep_db_prepare_input($HTTP_POST_VARS['specials_id']); 56 $products_price = tep_db_prepare_input($HTTP_POST_VARS['products_price']); 57 $specials_price = tep_db_prepare_input($HTTP_POST_VARS['specials_price']); 58 $day = tep_db_prepare_input($HTTP_POST_VARS['day']); 59 $month = tep_db_prepare_input($HTTP_POST_VARS['month']); 60 $year = tep_db_prepare_input($HTTP_POST_VARS['year']); 61 62 if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price)); 63 64 $expires_date = ''; 65 if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year)) { 66 $expires_date = $year; 67 $expires_date .= (strlen($month) == 1) ? '0' . $month : $month; 68 $expires_date .= (strlen($day) == 1) ? '0' . $day : $day; 69 } 70 71 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 . "'"); 72 73 tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials_id)); 74 break; 75 case 'deleteconfirm': 76 $specials_id = tep_db_prepare_input($HTTP_GET_VARS['sID']); 77 78 tep_db_query("delete from " . TABLE_SPECIALS . " where specials_id = '" . (int)$specials_id . "'"); 79 80 tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'])); 81 break; 82 } 83 } 84 ?> 85 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 86 <html <?php echo HTML_PARAMS; ?>> 87 <head> 88 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 89 <title><?php echo TITLE; ?></title> 90 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 91 <script language="javascript" src="includes/general.js"></script> 92 <?php 93 if ( ($action == 'new') || ($action == 'edit') ) { 94 ?> 95 <link rel="stylesheet" type="text/css" href="includes/javascript/calendar.css"> 96 <script language="JavaScript" src="includes/javascript/calendarcode.js"></script> 97 <?php 98 } 99 ?> 100 </head> 101 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();"> 102 <div id="popupcalendar" class="text"></div> 103 <!-- header //--> 104 <?php require(DIR_WS_INCLUDES . 'header.php'); ?> 105 <!-- header_eof //--> 106 107 <!-- body //--> 108 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 109 <tr> 110 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 111 <!-- left_navigation //--> 112 <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> 113 <!-- left_navigation_eof //--> 114 </table></td> 115 <!-- body_text //--> 116 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 117 <tr> 118 <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 119 <tr> 120 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 121 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 122 </tr> 123 </table></td> 124 </tr> 125 <?php 126 if ( ($action == 'new') || ($action == 'edit') ) { 127 $form_action = 'insert'; 128 if ( ($action == 'edit') && isset($HTTP_GET_VARS['sID']) ) { 129 $form_action = 'update'; 130 131 $product_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, s.specials_new_products_price, s.expires_date from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id and s.specials_id = '" . (int)$HTTP_GET_VARS['sID'] . "'"); 132 $product = tep_db_fetch_array($product_query); 133 134 $sInfo = new objectInfo($product); 135 } else { 136 $sInfo = new objectInfo(array()); 137 138 // create an array of products on special, which will be excluded from the pull down menu of products 139 // (when creating a new product on special) 140 $specials_array = array(); 141 $specials_query = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s where s.products_id = p.products_id"); 142 while ($specials = tep_db_fetch_array($specials_query)) { 143 $specials_array[] = $specials['products_id']; 144 } 145 } 146 ?> 147 <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']); ?> 148 <td><br><table border="0" cellspacing="0" cellpadding="2"> 149 <tr> 150 <td class="main"><?php echo TEXT_SPECIALS_PRODUCT; ?> </td> 151 <td class="main"><?php echo (isset($sInfo->products_name)) ? $sInfo->products_name . ' <small>(' . $currencies->format($sInfo->products_price) . ')</small>' : tep_draw_products_pull_down('products_id', 'style="font-size:10px"', $specials_array); echo tep_draw_hidden_field('products_price', (isset($sInfo->products_price) ? $sInfo->products_price : '')); ?></td> 152 </tr> 153 <tr> 154 <td class="main"><?php echo TEXT_SPECIALS_SPECIAL_PRICE; ?> </td> 155 <td class="main"><?php echo tep_draw_input_field('specials_price', (isset($sInfo->specials_new_products_price) ? $sInfo->specials_new_products_price : '')); ?></td> 156 </tr> 157 <tr> 158 <td class="main"><?php echo TEXT_SPECIALS_EXPIRES_DATE; ?> </td> 159 <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="javascript: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> 160 </tr> 161 </table></td> 162 </tr> 163 <tr> 164 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> 165 <tr> 166 <td class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td> 167 <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> 168 </tr> 169 </table></td> 170 </form></tr> 171 <?php 172 } else { 173 ?> 174 <tr> 175 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 176 <tr> 177 <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 178 <tr class="dataTableHeadingRow"> 179 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td> 180 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRODUCTS_PRICE; ?></td> 181 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td> 182 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td> 183 </tr> 184 <?php 185 $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id order by pd.products_name"; 186 $specials_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $specials_query_raw, $specials_query_numrows); 187 $specials_query = tep_db_query($specials_query_raw); 188 while ($specials = tep_db_fetch_array($specials_query)) { 189 if ((!isset($HTTP_GET_VARS['sID']) || (isset($HTTP_GET_VARS['sID']) && ($HTTP_GET_VARS['sID'] == $specials['specials_id']))) && !isset($sInfo)) { 190 $products_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$specials['products_id'] . "'"); 191 $products = tep_db_fetch_array($products_query); 192 $sInfo_array = array_merge($specials, $products); 193 $sInfo = new objectInfo($sInfo_array); 194 } 195 196 if (isset($sInfo) && is_object($sInfo) && ($specials['specials_id'] == $sInfo->specials_id)) { 197 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"; 198 } else { 199 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"; 200 } 201 ?> 202 <td class="dataTableContent"><?php echo $specials['products_name']; ?></td> 203 <td class="dataTableContent" align="right"><span class="oldPrice"><?php echo $currencies->format($specials['products_price']); ?></span> <span class="specialPrice"><?php echo $currencies->format($specials['specials_new_products_price']); ?></span></td> 204 <td class="dataTableContent" align="right"> 205 <?php 206 if ($specials['status'] == '1') { 207 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>'; 208 } else { 209 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); 210 } 211 ?></td> 212 <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> 213 </tr> 214 <?php 215 } 216 ?> 217 <tr> 218 <td colspan="4"><table border="0" width="100%" cellpadding="0"cellspacing="2"> 219 <tr> 220 <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> 221 <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> 222 </tr> 223 <?php 224 if (empty($action)) { 225 ?> 226 <tr> 227 <td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?></td> 228 </tr> 229 <?php 230 } 231 ?> 232 </table></td> 233 </tr> 234 </table></td> 235 <?php 236 $heading = array(); 237 $contents = array(); 238 239 switch ($action) { 240 case 'delete': 241 $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_SPECIALS . '</b>'); 242 243 $contents = array('form' => tep_draw_form('specials', FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=deleteconfirm')); 244 $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); 245 $contents[] = array('text' => '<br><b>' . $sInfo->products_name . '</b>'); 246 $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>'); 247 break; 248 default: 249 if (is_object($sInfo)) { 250 $heading[] = array('text' => '<b>' . $sInfo->products_name . '</b>'); 251 252 $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>'); 253 $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($sInfo->specials_date_added)); 254 $contents[] = array('text' => '' . TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($sInfo->specials_last_modified)); 255 $contents[] = array('align' => 'center', 'text' => '<br>' . tep_info_image($sInfo->products_image, $sInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)); 256 $contents[] = array('text' => '<br>' . TEXT_INFO_ORIGINAL_PRICE . ' ' . $currencies->format($sInfo->products_price)); 257 $contents[] = array('text' => '' . TEXT_INFO_NEW_PRICE . ' ' . $currencies->format($sInfo->specials_new_products_price)); 258 $contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%'); 259 260 $contents[] = array('text' => '<br>' . TEXT_INFO_EXPIRES_DATE . ' <b>' . tep_date_short($sInfo->expires_date) . '</b>'); 261 $contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . tep_date_short($sInfo->date_status_change)); 262 } 263 break; 264 } 265 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { 266 echo ' <td width="25%" valign="top">' . "\n"; 267 268 $box = new box; 269 echo $box->infoBox($heading, $contents); 270 271 echo ' </td>' . "\n"; 272 } 273 } 274 ?> 275 </tr> 276 </table></td> 277 </tr> 278 </table></td> 279 <!-- body_text_eof //--> 280 </tr> 281 </table> 282 <!-- body_eof //--> 283 284 <!-- footer //--> 285 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> 286 <!-- footer_eof //--> 287 </body> 288 </html> 289 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 19:48:25 2007 | par Balluche grâce à PHPXref 0.7 |
|