| [ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: xsell.php 15 2006-07-28 20:46:15Z user $ 4 osCMax Power E-Commerce 5 http://oscdox.com 6 Copyright 2006 osCMax2005 osCMax, 2002 osCommerce 7 8 Released under the GNU General Public License 9 xsell.php 10 Original Idea From Isaac Mualem im@imwebdesigning.com <mailto:im@imwebdesigning.com> 11 Complete Recoding From Stephen Walker admin@snjcomputers.com 12 */ 13 14 require ('includes/application_top.php'); 15 require (DIR_WS_CLASSES . 'currencies.php'); 16 $currencies = new currencies(); 17 switch($_GET['action']){ 18 case 'update_cross' : 19 if ($_POST['product']){ 20 foreach ($_POST['product'] as $temp_prod){ 21 tep_db_query('delete from ' . TABLE_PRODUCTS_XSELL . ' where xsell_id = "'.$temp_prod.'" and products_id = "'.$_GET['add_related_product_ID'].'"'); 22 } 23 } 24 25 $sort_start_query = tep_db_query('select sort_order from ' . TABLE_PRODUCTS_XSELL . ' where products_id = "'.$_GET['add_related_product_ID'].'" order by sort_order desc limit 1'); 26 $sort_start = tep_db_fetch_array($sort_start_query); 27 28 $sort = (($sort_start['sort_order'] > 0) ? $sort_start['sort_order'] : '0'); 29 if ($_POST['cross']){ 30 foreach ($_POST['cross'] as $temp){ 31 $sort++; 32 $insert_array = array(); 33 $insert_array = array('products_id' => $_GET['add_related_product_ID'], 34 'xsell_id' => $temp, 35 'sort_order' => $sort); 36 tep_db_perform(TABLE_PRODUCTS_XSELL, $insert_array); 37 } 38 } 39 $messageStack->add(CROSS_SELL_SUCCESS, 'success'); 40 break; 41 case 'update_sort' : 42 foreach ($_POST as $key_a => $value_a){ 43 tep_db_query('update ' . TABLE_PRODUCTS_XSELL . ' set sort_order = "' . $value_a . '" where xsell_id = "' . $key_a . '"'); 44 } 45 $messageStack->add(SORT_CROSS_SELL_SUCCESS, 'success'); 46 break; 47 } 48 ?> 49 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 50 <html <?php echo HTML_PARAMS; ?>> 51 <head> 52 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> 53 <title><?php echo TITLE; ?></title> 54 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 55 <style> 56 .productmenutitle{ 57 cursor:pointer; 58 margin-bottom: 0px; 59 background-color:orange; 60 color:#FFFFFF; 61 font-weight:bold; 62 font-family:ms sans serif; 63 width:100%; 64 padding:3px; 65 font-size:12px; 66 text-align:center; 67 /*/*/border:1px solid #000000;/* */ 68 } 69 .productmenutitle1{ 70 cursor:pointer; 71 margin-bottom: 0px; 72 background-color: red; 73 color:#FFFFFF; 74 font-weight:bold; 75 font-family:ms sans serif; 76 width:100%; 77 padding:3px; 78 font-size:12px; 79 text-align:center; 80 /*/*/border:1px solid #000000;/* */ 81 } 82 </style> 83 <script language="JavaScript1.2"> 84 85 function cOn(td) 86 { 87 if(document.getElementById||(document.all && !(document.getElementById))) 88 { 89 td.style.backgroundColor="#CCCCCC"; 90 } 91 } 92 93 function cOnA(td) 94 { 95 if(document.getElementById||(document.all && !(document.getElementById))) 96 { 97 td.style.backgroundColor="#CCFFFF"; 98 } 99 } 100 101 function cOut(td) 102 { 103 if(document.getElementById||(document.all && !(document.getElementById))) 104 { 105 td.style.backgroundColor="DFE4F4"; 106 } 107 } 108 </script> 109 </head> 110 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 111 <!-- header //--> 112 <?php require (DIR_WS_INCLUDES . 'header.php'); ?> 113 <!-- header_eof //--> 114 115 <!-- body //--> 116 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 117 <tr> 118 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 119 <!-- left_navigation //--> 120 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 121 <!-- left_navigation_eof //--> 122 </table></td> 123 <td width="100%" valign="top"> 124 <!-- body_text //--> 125 <table border="0" width="100%" cellspacing="0" cellpadding="0"> 126 <tr> 127 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');?></td> 128 </tr> 129 <tr> 130 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 131 </tr> 132 <tr> 133 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '15');?></td> 134 </tr> 135 </table> 136 137 <?php 138 if ($_GET['add_related_product_ID'] == ''){ 139 ?> 140 <table border="0" cellspacing="1" cellpadding="2" bgcolor="#999999" align="center"> 141 <tr class="dataTableHeadingRow"> 142 <td class="dataTableHeadingContent" width="75"><?php echo TABLE_HEADING_PRODUCT_ID;?></td> 143 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCT_MODEL;?></td> 144 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCT_NAME;?></td> 145 <td class="dataTableHeadingContent" nowrap><?php echo TABLE_HEADING_CURRENT_SELLS;?></td> 146 <td class="dataTableHeadingContent" colspan="2" nowrap align="center"><?php echo TABLE_HEADING_UPDATE_SELLS;?></td> 147 </tr> 148 <?php 149 $products_query_raw = 'select p.products_id, p.products_model, pd.products_name, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by p.products_id asc'; 150 $products_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $products_query_numrows); 151 $products_query = tep_db_query($products_query_raw); 152 while ($products = tep_db_fetch_array($products_query)) { 153 ?> 154 <tr onMouseOver="cOn(this); this.style.cursor='pointer'; this.style.cursor='hand';" onMouseOut="cOut(this);" bgcolor='#DFE4F4' onClick=document.location.href="<?php echo tep_href_link(FILENAME_XSELL_PRODUCTS, 'add_related_product_ID=' . $products['products_id'], 'NONSSL');?>"> 155 <td class="dataTableContent" valign="top"> <?php echo $products['products_id'];?> </td> 156 <td class="dataTableContent" valign="top"> <?php echo $products['products_model'];?> </td> 157 <td class="dataTableContent" valign="top"> <?php echo $products['products_name'];?> </td> 158 <td class="dataTableContent" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> 159 <?php 160 $products_cross_query = tep_db_query('select p.products_id, p.products_model, pd.products_name, p.products_id, x.products_id, x.xsell_id, x.sort_order, x.ID from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd, '.TABLE_PRODUCTS_XSELL.' x where x.xsell_id = p.products_id and x.products_id = "'.$products['products_id'].'" and p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by x.sort_order asc'); 161 $i=0; 162 while ($products_cross = tep_db_fetch_array($products_cross_query)){ 163 $i++; 164 ?> 165 <tr> 166 <td class="dataTableContent"> <?php echo $i . '. <b>' . $products_cross['products_model'] . '</b> ' . $products_cross['products_name'];?> </td> 167 </tr> 168 <?php 169 } 170 if ($i <= 0){ 171 ?> 172 <tr> 173 <td class="dataTableContent"> -- </td> 174 </tr> 175 <?php 176 }else{ 177 ?> 178 <tr> 179 <td class="dataTableContent"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10');?></td> 180 </tr> 181 <?php 182 } 183 ?> 184 </table></td> 185 <td class="dataTableContent" valign="top"> <a href="<?php echo tep_href_link(FILENAME_XSELL_PRODUCTS, tep_get_all_get_params(array('action')) . 'add_related_product_ID=' . $products['products_id'], 'NONSSL');?>"><?php echo TEXT_EDIT_SELLS;?></a> </td> 186 <td class="dataTableContent" valign="top" align="center"> <?php echo (($i > 0) ? '<a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, tep_get_all_get_params(array('action')) . 'sort=1&add_related_product_ID=' . $products['products_id'], 'NONSSL') .'">'.TEXT_SORT.'</a> ' : '--')?></td> 187 </tr> 188 <?php 189 } 190 ?> 191 <tr> 192 <td colspan="6"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="infoBoxContent"> 193 <tr> 194 <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> 195 <td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID', 'action'))); ?></td> 196 </tr> 197 </table></td> 198 </tr> 199 </table> 200 <?php 201 }elseif($_GET['add_related_product_ID'] != '' && $_GET['sort'] == ''){ 202 $products_name_query = tep_db_query('select pd.products_name, p.products_model, p.products_image from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = "'.$_GET['add_related_product_ID'].'" and p.products_id = pd.products_id and pd.language_id ="'.(int)$languages_id.'"'); 203 $products_name = tep_db_fetch_array($products_name_query); 204 ?> 205 <table border="0" cellspacing="0" cellpadding="0" bgcolor="#999999" align="center"> 206 <tr> 207 <td><?php echo tep_draw_form('update_cross', FILENAME_XSELL_PRODUCTS, tep_get_all_get_params(array('action')) . 'action=update_cross', 'post');?><table cellpadding="1" cellspacing="1" border="0"> 208 <tr> 209 <td colspan="6"><table cellpadding="3" cellspacing="0" border="0" width="100%"> 210 <tr class="dataTableHeadingRow"> 211 <td valign="top" align="center" colspan="2"><span class="pageHeading"><?php echo TEXT_SETTING_SELLS.': '.$products_name['products_name'].' ('.TEXT_MODEL.': '.$products_name['products_model'].') ('.TEXT_PRODUCT_ID.': '.$_GET['add_related_product_ID'].')';?></span></td> 212 </tr> 213 <tr class="dataTableHeadingRow"> 214 <td align="right"><?php echo tep_image('../images/'.$products_name['products_image']);?></td> 215 <td align="right" valign="bottom"><?php echo tep_image_submit('button_update.gif') . '<br><br><a href="'.tep_href_link(FILENAME_XSELL_PRODUCTS, 'men_id=catalog').'">' . tep_image_button('button_cancel.gif') . '</a>';?></td> 216 </tr> 217 </table></td> 218 </tr> 219 <tr class="dataTableHeadingRow"> 220 <td class="dataTableHeadingContent" width="75"> <?php echo TABLE_HEADING_PRODUCT_ID;?> </td> 221 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_MODEL;?> </td> 222 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_IMAGE;?> </td> 223 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_CROSS_SELL_THIS;?> </td> 224 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_NAME;?> </td> 225 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_PRICE;?> </td> 226 </tr> 227 <?php 228 $products_query_raw = 'select p.products_id, p.products_model, p.products_image, p.products_price, pd.products_name, p.products_id from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by p.products_id asc'; 229 $products_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $products_query_numrows); 230 $products_query = tep_db_query($products_query_raw); 231 while ($products = tep_db_fetch_array($products_query)) { 232 $xsold_query = tep_db_query('select * from '.TABLE_PRODUCTS_XSELL.' where products_id = "'.$_GET['add_related_product_ID'].'" and xsell_id = "'.$products['products_id'].'"'); 233 ?> 234 <tr bgcolor='#DFE4F4'> 235 <td class="dataTableContent" align="center"> <?php echo $products['products_id'];?> </td> 236 <td class="dataTableContent" align="center"> <?php echo $products['products_model'];?> </td> 237 <td class="dataTableContent" align="center"> <?php echo ((is_file('../images/'.$products['products_image'])) ? tep_image('../images/'.$products['products_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) : '<br>No Image<br>');?> </td> 238 <td class="dataTableContent"> <?php echo tep_draw_hidden_field('product[]', $products['products_id']) . tep_draw_checkbox_field('cross[]', $products['products_id'], ((tep_db_num_rows($xsold_query) > 0) ? true : false), '', ' onMouseOver="this.style.cursor=\'hand\'"');?> <label onMouseOver="this.style.cursor='hand'"><?php echo TEXT_CROSS_SELL;?></label> </td> 239 <td class="dataTableContent"> <?php echo $products['products_name'];?> </td> 240 <td class="dataTableContent"> <?php echo $currencies->format($products['products_price']);?> </td> 241 </tr> 242 <?php 243 } 244 ?> 245 </table></form></td> 246 </tr> 247 <tr> 248 <td colspan="6"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="infoBoxContent"> 249 <tr> 250 <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td> 251 <td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID', 'action'))); ?></td> 252 </tr> 253 </table></td> 254 </tr> 255 </table> 256 <?php 257 }elseif($_GET['add_related_product_ID'] != '' && $_GET['sort'] != ''){ 258 $products_name_query = tep_db_query('select pd.products_name, p.products_model, p.products_image from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd where p.products_id = "'.$_GET['add_related_product_ID'].'" and p.products_id = pd.products_id and pd.language_id ="'.(int)$languages_id.'"'); 259 $products_name = tep_db_fetch_array($products_name_query); 260 ?> 261 <table border="0" cellspacing="0" cellpadding="0" bgcolor="#999999" align="center"> 262 <tr> 263 <td><?php echo tep_draw_form('update_sort', FILENAME_XSELL_PRODUCTS, tep_get_all_get_params(array('action')) . 'action=update_sort', 'post');?><table cellpadding="1" cellspacing="1" border="0"> 264 <tr> 265 <td colspan="6"><table cellpadding="3" cellspacing="0" border="0" width="100%"> 266 <tr class="dataTableHeadingRow"> 267 <td valign="top" align="center" colspan="2"><span class="pageHeading"><?php echo 'Setting cross-sells for: '.$products_name['products_name'].' (Model: '.$products_name['products_model'].') (Product ID: '.$_GET['add_related_product_ID'].')';?></span></td> 268 </tr> 269 <tr class="dataTableHeadingRow"> 270 <td align="right"><?php echo tep_image('../images/'.$products_name['products_image']);?></td> 271 <td align="right" valign="bottom"><?php echo tep_image_submit('button_update.gif') . '<br><br><a href="'.tep_href_link(FILENAME_XSELL_PRODUCTS, 'men_id=catalog').'">' . tep_image_button('button_cancel.gif') . '</a>';?></td> 272 </tr> 273 </table></td> 274 </tr> 275 <tr class="dataTableHeadingRow"> 276 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_ID;?> </td> 277 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_MODEL;?> </td> 278 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_IMAGE;?> </td> 279 <td class="dataTableHeadingContent" align="center"> <?php echo TABLE_HEADING_PRODUCT_NAME;?> </td> 280 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_PRICE;?> </td> 281 <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_PRODUCT_SORT;?> </td> 282 </tr> 283 <?php 284 $products_query_raw = 'select p.products_id as products_id, p.products_price, p.products_image, p.products_model, pd.products_name, p.products_id, x.products_id as xproducts_id, x.xsell_id, x.sort_order, x.ID from '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_DESCRIPTION.' pd, '.TABLE_PRODUCTS_XSELL.' x where x.xsell_id = p.products_id and x.products_id = "'.$_GET['add_related_product_ID'].'" and p.products_id = pd.products_id and pd.language_id = "'.(int)$languages_id.'" order by x.sort_order asc'; 285 $products_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $products_query_raw, $products_query_numrows); 286 $sort_order_drop_array = array(); 287 for($i=1;$i<=$products_query_numrows;$i++){ 288 $sort_order_drop_array[] = array('id' => $i, 'text' => $i); 289 } 290 $products_query = tep_db_query($products_query_raw); 291 while ($products = tep_db_fetch_array($products_query)){ 292 ?> 293 <tr bgcolor='#DFE4F4'> 294 <td class="dataTableContent" align="center"> <?php echo $products['products_id'];?> </td> 295 <td class="dataTableContent" align="center"> <?php echo $products['products_model'];?> </td> 296 <td class="dataTableContent" align="center"> <?php echo ((is_file('../images/'.$products['products_image'])) ? tep_image('../images/'.$products['products_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) : '<br>'.TEXT_NO_IMAGE.'<br>');?> </td> 297 <td class="dataTableContent" align="center"> <?php echo $products['products_name'];?> </td> 298 <td class="dataTableContent" align="center"> <?php echo $currencies->format($products['products_price']);?> </td> 299 <td class="dataTableContent" align="center"> <?php echo tep_draw_pull_down_menu($products['products_id'], $sort_order_drop_array, $products['sort_order']);?> </td> 300 </tr> 301 <?php 302 } 303 ?> 304 </table></form></td> 305 </tr> 306 <tr> 307 <td colspan="6"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="infoBoxContent"> 308 <tr> 309 <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> 310 <td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID', 'action'))); ?></td> 311 </tr> 312 </table></td> 313 </tr> 314 </table> 315 <?php 316 } 317 ?> 318 <!-- body_text_eof //--> 319 </td> 320 </tr> 321 </table> 322 <!-- body_eof //--> 323 <!-- footer //--> 324 <?php require (DIR_WS_INCLUDES . 'footer.php'); ?> 325 <!-- footer_eof //--> 326 <br> 327 </body> 328 </html> 329 <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |