| [ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: xsell_products.php 14 2006-07-28 17:42:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax2005 osCMax, 2002 osCommerce 9 10 Released under the GNU General Public License 11 12 cross.sale.php created By Isaac Mualem im@imwebdesigning.com 13 14 Modified by Andrew Edmond (osc@aravia.com) 15 Sept 16th, 2002 16 */ 17 18 require ('includes/application_top.php'); 19 20 require (DIR_WS_CLASSES . 'currencies.php'); 21 $currencies = new currencies(); 22 23 ?> 24 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 25 <html <?php echo HTML_PARAMS; ?>> 26 <head> 27 <title><?php echo TITLE; ?></title> 28 29 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 30 <script language="JavaScript1.2"> 31 32 function cOn(td) 33 { 34 if(document.getElementById||(document.all && !(document.getElementById))) 35 { 36 td.style.backgroundColor="#CCCCCC"; 37 } 38 } 39 40 function cOnA(td) 41 { 42 if(document.getElementById||(document.all && !(document.getElementById))) 43 { 44 td.style.backgroundColor="#CCFFFF"; 45 } 46 } 47 48 function cOut(td) 49 { 50 if(document.getElementById||(document.all && !(document.getElementById))) 51 { 52 td.style.backgroundColor="DFE4F4"; 53 } 54 } 55 </script> 56 </head> 57 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 58 <!-- header //--> 59 <?php include (DIR_WS_INCLUDES . 'header.php'); ?> 60 <!-- header_eof //--> 61 62 63 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 64 <tr> 65 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 66 <!-- left_navigation //--> 67 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 68 <!-- left_navigation_eof //--> 69 </table></td> 70 <!-- body_text //--> 71 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 72 <tr> 73 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 74 <tr> 75 <td class="pageHeading"><?php echo "Cross-Sell (X-Sell) Admin"; ?></td> 76 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 77 </tr> 78 </table></td> 79 </tr> 80 81 <!-- body_text //--> 82 <td width="100%" valign="top"> 83 <!-- Start of cross sale //--> 84 85 <table width="100%" border="0" cellpadding="0" cellspacing="0"> 86 <tr><td align=center> 87 <?php 88 /* general_db_conct($query) function */ 89 /* calling the function: list ($test_a, $test_b) = general_db_conct($query); */ 90 function general_db_conct($query_1) 91 { 92 $result_1 = tep_db_query($query_1); 93 $num_of_rows = mysql_num_rows($result_1); 94 for ($i=0;$i<$num_of_rows;$i++) 95 { 96 $fields = mysql_fetch_row($result_1); 97 $a_to_pass[$i]= $fields[$y=0]; 98 $b_to_pass[$i]= $fields[++$y]; 99 $c_to_pass[$i]= $fields[++$y]; 100 $d_to_pass[$i]= $fields[++$y]; 101 $e_to_pass[$i]= $fields[++$y]; 102 $f_to_pass[$i]= $fields[++$y]; 103 $g_to_pass[$i]= $fields[++$y]; 104 $h_to_pass[$i]= $fields[++$y]; 105 $i_to_pass[$i]= $fields[++$y]; 106 $j_to_pass[$i]= $fields[++$y]; 107 $k_to_pass[$i]= $fields[++$y]; 108 $l_to_pass[$i]= $fields[++$y]; 109 $m_to_pass[$i]= $fields[++$y]; 110 $n_to_pass[$i]= $fields[++$y]; 111 $o_to_pass[$i]= $fields[++$y]; 112 } 113 return array($a_to_pass,$b_to_pass,$c_to_pass,$d_to_pass,$e_to_pass,$f_to_pass,$g_to_pass,$h_to_pass,$i_to_pass,$j_to_pass,$k_to_pass,$l_to_pass,$m_to_pass,$n_to_pass,$o_to_pass); 114 }//end of function 115 116 // first major piece of the program 117 // we have no instructions, so just dump a full list of products and their status for cross selling 118 119 if (!$add_related_product_ID ) 120 { 121 $query = "select a.products_id, b.products_name, b.products_description, " . 122 "a.products_quantity, a.products_model, a.products_image, " . 123 "b.products_url, a.products_price from products a, products_description b where b.products_id = a.products_id order by b.products_name"; 124 list ($PRODUCTS_id, $PRODUCTS_name, $PRODUCTS_description , $PRODUCTS_quantity , $PRODUCTS_model , $PRODUCTS_image , $PRODUCTS_url , $PRODUCTS_price ) = general_db_conct($query); 125 ?> 126 127 <table border="0" cellspacing="1" cellpadding="2" bgcolor="#999999"> 128 <tr class="dataTableHeadingRow"> 129 <td class="dataTableHeadingContent" nowrap align=center>ID</td> 130 <td class="dataTableHeadingContent">Product Name</td> 131 <td class="dataTableHeadingContent" nowrap>Cross-Associated Products</td> 132 <td class="dataTableHeadingContent" colspan=3 nowrap align=center>Cross Sell Actions</td> 133 </tr> 134 <?php 135 $num_of_products = sizeof($PRODUCTS_id); 136 for ($i=0; $i < $num_of_products; $i++) 137 { 138 /* now we will query the DB for existing related items */ 139 $query = "select b.products_name, a.xsell_id from " . TABLE_PRODUCTS_XSELL . " a, products_description b WHERE b.products_id = a.xsell_id and a.products_id ='".$PRODUCTS_id[$i]."' ORDER BY sort_order"; 140 list ($Related_items, $xsell_ids) = general_db_conct($query); 141 142 echo "<tr onMouseOver=\"cOn(this);\" onMouseOut=\"cOut(this);\" bgcolor='#DFE4F4'>"; 143 echo "<td class=\"dataTableContent\" valign=\"top\"> ".$PRODUCTS_id[$i]." </td>\n"; 144 echo "<td class=\"dataTableContent\" valign=\"top\"> ".$PRODUCTS_name[$i]." </td>\n"; 145 if ($Related_items) 146 { 147 echo "<td class=\"dataTableContent\"><ol>"; 148 foreach ($Related_items as $display) 149 echo '<li>'. $display .' '; 150 echo"</ol></td>\n"; 151 } 152 else 153 echo "<td class=\"dataTableContent\">--</td>\n"; 154 echo '<td class="dataTableContent" valign="top"> <a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, 'add_related_product_ID=' . $PRODUCTS_id[$i], 'NONSSL') . '">Add</a> </td><td class="dataTableContent" valign="top"> <a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, 'add_related_product_ID=' . $PRODUCTS_id[$i], 'NONSSL') . '">Remove</a> </td>'; 155 156 if (count($Related_items)>1) 157 { 158 echo '<td class="dataTableContent" valign="top"> <a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, 'sort=1&add_related_product_ID=' . $PRODUCTS_id[$i], 'NONSSL') . '">Sort</a> </td>'; 159 } else { 160 echo "<td class=\"dataTableContent\" valign=top align=center>--</td>"; 161 } 162 echo "</tr>\n"; 163 unset($Related_items); 164 } 165 ?> 166 167 </table> 168 <?php 169 } // the end of -> if (!$add_related_product_ID) 170 171 if ($_POST && !$sort) 172 { 173 if ($_POST[run_update]==true) 174 { 175 $query ="DELETE FROM " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '".$_POST[add_related_product_ID]."'"; 176 if (!tep_db_query($query)) 177 exit('could not delete'); 178 } 179 if ($_POST[xsell_id]) 180 foreach ($_POST[xsell_id] as $temp) 181 { 182 $query = "INSERT INTO " . TABLE_PRODUCTS_XSELL . " VALUES ('',$_POST[add_related_product_ID],$temp,1)"; 183 if (!tep_db_query($query)) 184 exit('could not insert to DB'); 185 } 186 echo '<a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, '', 'NONSSL') . '">Click Here to add a new cross sale</a><br>' . "\n"; 187 if ($_POST[xsell_id]) 188 echo '<a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, 'sort=1&add_related_product_ID=' . $_POST[add_related_product_ID], 'NONSSL') . '">Click here to sort (top to bottom) the added cross sale</a>' . "\n"; 189 } 190 191 if ($add_related_product_ID && ! $_POST && !$sort) 192 { ?> 193 <table border="0" cellpadding="2" cellspacing="1" bgcolor="#999999"> 194 <form action="<?php tep_href_link(FILENAME_XSELL_PRODUCTS, '', 'NONSSL'); ?>" method="post"> 195 <tr class="dataTableHeadingRow"> 196 <?php 197 198 $query = "select a.products_id, b.products_name, b.products_description, " . 199 "a.products_quantity, a.products_model, a.products_image, " . 200 "b.products_url, a.products_price from products a, products_description b where b.products_id = a.products_id and a.products_id = '".$add_related_product_ID."'"; 201 list ($PRODUCTS_id, $PRODUCTS_name, $PRODUCTS_description , $PRODUCTS_quantity , $PRODUCTS_model , $PRODUCTS_image , $PRODUCTS_url , $PRODUCTS_price ) = general_db_conct($query); 202 ?> 203 204 <td class="dataTableHeadingContent"> </td> 205 <td class="dataTableHeadingContent" nowrap>Item #</td> 206 <td class="dataTableHeadingContent">Item Name</td> 207 <td class="dataTableHeadingContent">$Price</td> 208 </tr> 209 210 <?php 211 212 $query = "select a.products_id, b.products_name, b.products_description, " . 213 "a.products_quantity, a.products_model, a.products_image, " . 214 "b.products_url, a.products_price from products a, products_description b where b.products_id = a.products_id and a.products_id != '".$add_related_product_ID."' order by b.products_name"; 215 216 list ($PRODUCTS_id, $PRODUCTS_name, $PRODUCTS_description , $PRODUCTS_quantity , $PRODUCTS_model , $PRODUCTS_image , $PRODUCTS_url , $PRODUCTS_price ) = general_db_conct($query); 217 $num_of_products = sizeof($PRODUCTS_id); 218 $query = "select * from " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '".$add_related_product_ID."'"; 219 list ($ID_PR, $PRODUCTS_id_PR, $xsell_id_PR) = general_db_conct($query); 220 for ($i=0; $i < $num_of_products; $i++) 221 { 222 ?><tr bgcolor='#DFE4F4'> 223 <td class="dataTableContent"> 224 225 <input <?php /* this is to see it it is in the DB */ 226 $run_update=false; // set to false to insert new entry in the DB 227 if ($xsell_id_PR) foreach ($xsell_id_PR as $compare_checked)if ($PRODUCTS_id[$i]===$compare_checked) {echo "checked"; $run_update=true;} ?> size="20" size="20" name="xsell_id[]" type="checkbox" value="<?php echo $PRODUCTS_id[$i]; ?>"></td> 228 229 <?php echo "<td class=\"dataTableContent\" align=center>".$PRODUCTS_id[$i]."</td>\n" 230 ."<td class=\"dataTableContent\">".$PRODUCTS_name[$i]."</td>\n" 231 ."<td class=\"dataTableContent\">".$currencies->display_price($PRODUCTS_price[$i], tep_get_tax_rate($product_info_values['products_tax_class_id']))."</td></tr>\n"; 232 }?> 233 <tr> 234 <td colspan="4"> 235 236 <input type="hidden" name="run_update" value="<?php if ($run_update==true) echo "true"; else echo "false" ?>"> 237 <input type="hidden" name="add_related_product_ID" value="<?php echo $add_related_product_ID; ?>"> 238 <input type="submit" name="Submit" value="Submit"></td> 239 </tr> 240 </form> 241 </table> 242 <?php } 243 244 // sort routines 245 if ($sort==1) 246 { 247 // first lets take care of the DB update. 248 $run_once=0; 249 if ($_POST) 250 foreach ($_POST as $key_a => $value_a) 251 { 252 tep_db_connect(); 253 $query = "UPDATE " . TABLE_PRODUCTS_XSELL . " SET sort_order = '".$value_a."' WHERE xsell_id= '$key_a' "; 254 //$query ="DELETE FROM " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '".$key_a."'"; 255 if ($value_a != 'Update') 256 if (!tep_db_query($query)) 257 exit('could not UPDATE DB'); 258 else 259 if ($run_once==0) 260 { 261 echo '<b>The Database was updated <a href="' . tep_href_link(FILENAME_XSELL_PRODUCTS, '', 'NONSSL') . '">Click here to back to the main page</a></b><br>' . "\n"; 262 $run_once++; 263 } 264 265 }// end of foreach. 266 ?> 267 <form method="post" action="<?php tep_href_link(FILENAME_XSELL_PRODUCTS, 'sort=1&add_related_product_ID=' . $add_related_product_ID, 'NONSSL'); ?>"> 268 <table cellpadding="2" cellspacing="1" bgcolor=999999 border="0"> 269 <tr class="dataTableHeadingRow"> 270 <td class="dataTableHeadingContent" width="75">Product ID</td> 271 <td class="dataTableHeadingContent">Name</td> 272 <td class="dataTableHeadingContent" width="150">Price</td> 273 <td class="dataTableHeadingContent" width="150">Order (1=Top)</td> 274 </tr> 275 <?php 276 $query = "select * from " . TABLE_PRODUCTS_XSELL . " WHERE products_id = '".$add_related_product_ID."'"; 277 list ($ID_PR, $PRODUCTS_id_PR, $xsell_id_PR, $order_PR) = general_db_conct($query); 278 $ordering_size =sizeof($ID_PR); 279 for ($i=0;$i<$ordering_size;$i++) 280 { 281 282 $query = "select a.products_id, b.products_name, b.products_description, " . 283 "a.products_quantity, a.products_model, a.products_image, " . 284 "b.products_url, a.products_price from products a, products_description b where b.products_id = a.products_id and a.products_id = ".$xsell_id_PR[$i].""; 285 286 list ($PRODUCTS_id, $PRODUCTS_name, $PRODUCTS_description , $PRODUCTS_quantity , $PRODUCTS_model , $PRODUCTS_image , $PRODUCTS_url , $PRODUCTS_price ) = general_db_conct($query); 287 288 ?> 289 <tr class="dataTableContentRow" bgcolor='#DFE4F4'> 290 <td class="dataTableContent"><?php echo $PRODUCTS_id[0]; ?></td> 291 <td class="dataTableContent"><?php echo $PRODUCTS_name[0]; ?></td> 292 <td class="dataTableContent"><?php echo $currencies->display_price($PRODUCTS_price[0], tep_get_tax_rate($product_info_values['products_tax_class_id'])); ?></td> 293 <td class="dataTableContent"><select name="<?php echo $PRODUCTS_id[0]; ?>"> 294 <?php for ($y=1;$y<=$ordering_size;$y++) 295 { 296 echo "<option value=\"$y\""; 297 if (!(strcmp($y, "$order_PR[$i]"))) {echo "SELECTED";} 298 echo ">$y</option>"; 299 } 300 ?> 301 </select></td> 302 </tr> 303 <?php } // the end of foreach ?> 304 <tr> 305 <td colspan="4" bgcolor='#DFE4F4'><input name="runing_update" type="submit" id="runing_update" value="Update"></td> 306 </tr> 307 </table> 308 </form> 309 310 <?php }?> 311 312 313 </td> 314 </tr> 315 </table> 316 <!-- End of cross sale //--> 317 </td> 318 <!-- products_attributes_eof //--> 319 </tr></table> 320 <!-- body_text_eof //--> 321 <!-- footer //--> 322 <?php include (DIR_WS_INCLUDES . 'footer.php'); ?> 323 <!-- footer_eof //--> 324 <br> 325 </body> 326 </html> 327 <?php include (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 |