| [ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: articles_xsell.php 14 2006-07-28 17:42:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax 9 10 cross.sale.php created By Isaac Mualem im@imwebdesigning.com 11 12 Modified by Andrew Edmond (osc@aravia.com) 13 Sept 16th, 2002 14 15 Further Modified by Rob Anderson 12 Dec 03 16 17 Released under the GNU General Public License 18 */ 19 20 require ('includes/application_top.php'); 21 22 ?> 23 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 24 <html <?php echo HTML_PARAMS; ?>> 25 <head> 26 <title><?php echo TITLE; ?></title> 27 28 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 29 </head> 30 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 31 <!-- header //--> 32 <?php include (DIR_WS_INCLUDES . 'header.php'); ?> 33 <!-- header_eof //--> 34 35 36 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 37 <tr> 38 <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 39 <!-- left_navigation //--> 40 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 41 <!-- left_navigation_eof //--> 42 </table></td> 43 <!-- body_text //--> 44 <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> 45 <tr> 46 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 47 <tr> 48 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> 49 <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 50 </tr> 51 </table></td> 52 </tr> 53 <tr> 54 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 55 </tr> 56 <!-- body_text //--> 57 <td width="100%" valign="top"> 58 <!-- Start of cross sale //--> 59 60 <table width="100%" border="0" cellpadding="0" cellspacing="0"> 61 <tr><td align=left> 62 <?php 63 /* general_db_conct($query) function */ 64 /* calling the function: list ($test_a, $test_b) = general_db_conct($query); */ 65 function general_db_conct($query_1) 66 { 67 $result_1 = tep_db_query($query_1); 68 $num_of_rows = mysql_num_rows($result_1); 69 for ($i=0;$i<$num_of_rows;$i++) 70 { 71 $fields = mysql_fetch_row($result_1); 72 $a_to_pass[$i]= $fields[$y=0]; 73 $b_to_pass[$i]= $fields[++$y]; 74 $c_to_pass[$i]= $fields[++$y]; 75 $d_to_pass[$i]= $fields[++$y]; 76 $e_to_pass[$i]= $fields[++$y]; 77 $f_to_pass[$i]= $fields[++$y]; 78 $g_to_pass[$i]= $fields[++$y]; 79 $h_to_pass[$i]= $fields[++$y]; 80 $i_to_pass[$i]= $fields[++$y]; 81 $j_to_pass[$i]= $fields[++$y]; 82 $k_to_pass[$i]= $fields[++$y]; 83 $l_to_pass[$i]= $fields[++$y]; 84 $m_to_pass[$i]= $fields[++$y]; 85 $n_to_pass[$i]= $fields[++$y]; 86 $o_to_pass[$i]= $fields[++$y]; 87 } 88 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); 89 }//end of function 90 91 // first major piece of the program 92 // we have no instructions, so just dump a full list of products and their status for cross selling 93 94 if (!$add_related_article_ID ) 95 { 96 $query = "select a.articles_id, ad.articles_name, ad.articles_description, ad.articles_url from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_DESCRIPTION . " ad where ad.articles_id = a.articles_id and ad.language_id = '" . (int)$languages_id . "' order by ad.articles_name"; 97 list ($articles_id, $articles_name, $articles_description, $articles_url) = general_db_conct($query); 98 ?> 99 100 <table border="0" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC"> 101 <tr class="dataTableHeadingRow"> 102 <td class="dataTableHeadingContent" align="center" nowrap>ID</td> 103 <td class="dataTableHeadingContent"><?php echo HEADING_ARTICLE_NAME; ?></td> 104 <td class="dataTableHeadingContent" nowrap><?php echo HEADING_CROSS_ASSOCIATION; ?></td> 105 <td class="dataTableHeadingContent" colspan="3" align="center" nowrap><?php echo HEADING_CROSS_SELL_ACTIONS; ?></td> 106 </tr> 107 <?php 108 $num_of_articles = sizeof($articles_id); 109 for ($i=0; $i < $num_of_articles; $i++) 110 { 111 /* now we will query the DB for existing related items */ 112 $query = "select pd.products_name, ax.xsell_id from " . TABLE_ARTICLES_XSELL . " ax, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = ax.xsell_id and ax.articles_id ='".$articles_id[$i]."' and pd.language_id = '" . (int)$languages_id . "' order by ax.sort_order"; 113 list ($Related_items, $xsell_ids) = general_db_conct($query); 114 115 echo "<tr bgcolor='#FFFFFF'>"; 116 echo "<td class=\"dataTableContent\" valign=\"top\"> ".$articles_id[$i]." </td>\n"; 117 echo "<td class=\"dataTableContent\" valign=\"top\"> ".$articles_name[$i]." </td>\n"; 118 if ($Related_items) 119 { 120 echo "<td class=\"dataTableContent\"><ol>"; 121 foreach ($Related_items as $display) 122 echo '<li>'. $display .' '; 123 echo"</ol></td>\n"; 124 } 125 else 126 echo "<td class=\"dataTableContent\">--</td>\n"; 127 echo '<td class="dataTableContent" valign="top"> <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL, 'add_related_article_ID=' . $articles_id[$i], 'NONSSL') . '">Add/Remove</a></td>'; 128 129 if (count($Related_items)>1) 130 { 131 echo '<td class="dataTableContent" valign="top"> <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL, 'sort=1&add_related_article_ID=' . $articles_id[$i], 'NONSSL') . '">Sort</a> </td>'; 132 } else { 133 echo "<td class=\"dataTableContent\" valign=top align=center>--</td>"; 134 } 135 echo "</tr>\n"; 136 unset($Related_items); 137 } 138 ?> 139 140 </table> 141 <?php 142 } // the end of -> if (!$add_related_article_ID) 143 144 if ($_POST && !$sort) 145 { 146 if ($_POST[run_update]==true) 147 { 148 $query ="DELETE FROM " . TABLE_ARTICLES_XSELL . " WHERE articles_id = '".$_POST[add_related_article_ID]."'"; 149 if (!tep_db_query($query)) 150 exit(TEXT_NO_DELETE); 151 } 152 if ($_POST[xsell_id]) 153 foreach ($_POST[xsell_id] as $temp) 154 { 155 $query = "INSERT INTO " . TABLE_ARTICLES_XSELL . " VALUES ('',$_POST[add_related_article_ID],$temp,1)"; 156 if (!tep_db_query($query)) 157 exit(TEXT_NO_INSERT); 158 } ?> 159 <tr> 160 <td class="main"><?php echo TEXT_DATABASE_UPDATED; ?></td> 161 </tr> 162 <tr> 163 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 164 </tr> 165 <tr> 166 <td class="main"><?php echo sprintf(TEXT_LINK_SORT_PRODUCTS, tep_href_link(FILENAME_ARTICLES_XSELL, '&sort=1&add_related_article_ID=' . $add_related_article_ID, 'NONSSL')); ?></td> 167 </tr> 168 <tr> 169 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 170 </tr> 171 <tr> 172 <td class="main"><?php echo sprintf(TEXT_LINK_MAIN_PAGE, tep_href_link(FILENAME_ARTICLES_XSELL, '', 'NONSSL')); ?></td> 173 </tr> 174 <tr> 175 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 176 </tr> 177 <?php 178 179 // if ($_POST[xsell_id]) 180 // echo '<a href="' . tep_href_link(FILENAME_ARTICLES_XSELL, 'sort=1&add_related_article_ID=' . $_POST[add_related_article_ID], 'NONSSL') . '">Click here to sort (top to bottom) the added cross sale</a>' . "\n"; 181 } 182 183 if ($add_related_article_ID && ! $_POST && !$sort) 184 { 185 echo tep_draw_form('goto', "articles_xsell.php", '', 'get'); 186 echo '<input type="hidden" name="add_related_article_ID" value="'.$add_related_article_ID.'" />'; 187 echo SELECT_CATEGORY ." :" . tep_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"'); 188 echo '</form>'; 189 if (isset($_GET['cPath'])) { 190 ?> 191 192 <table border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> 193 <form action="<?php tep_href_link(FILENAME_ARTICLES_XSELL, '', 'NONSSL'); ?>" method="post"> 194 <tr class="dataTableHeadingRow"> 195 <td class="dataTableHeadingContent"> </td> 196 <td class="dataTableHeadingContent" nowrap>ID</td> 197 <td class="dataTableHeadingContent"><?php echo HEADING_PRODUCT_NAME; ?></td> 198 </tr> 199 200 <?php 201 202 $query = "select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, products_to_categories p2c where p2c.categories_id='".tep_db_input($_GET['cPath'])."' and pd.products_id = p.products_id and p2c.products_id=p.products_id and pd.language_id = '" . (int)$languages_id . "' order by pd.products_name "; 203 204 list ($products_id, $products_name, $products_description, $products_url ) = general_db_conct($query); 205 $num_of_products = sizeof($products_id); 206 $query = "select * from " . TABLE_ARTICLES_XSELL . " where articles_id = '".$add_related_article_ID."'"; 207 list ($ID_PR, $products_id_pr, $xsell_id_pr) = general_db_conct($query); 208 for ($i=0; $i < $num_of_products; $i++) 209 { 210 ?><tr bgcolor="#FFFFFF"> 211 <td class="dataTableContent"> 212 213 <input <?php /* this is to see it it is in the DB */ 214 $run_update=false; // set to false to insert new entry in the DB 215 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> 216 217 <?php echo "<td class=\"dataTableContent\" align=center>".$products_id[$i]."</td>\n" 218 ."<td class=\"dataTableContent\">".$products_name[$i]."</td>\n"; 219 }?> 220 <tr> 221 <td> </td> 222 <td> </td> 223 <td bgcolor="#CCCCCC"> 224 <div style="display:none"> 225 <?php 226 // list also those products not in current category 227 $myquery = "SELECT ax.xsell_id AS nid FROM articles_xsell ax, products_to_categories p2c WHERE ax.articles_id='".$add_related_article_ID."' AND ax.xsell_id=p2c.products_id AND categories_id!='".tep_db_input($_GET['cPath'])."'"; 228 $myids_query = tep_db_query($myquery); 229 230 while ($tempid = tep_db_fetch_array($myids_query)) { 231 echo '<input type="checkbox" name="xsell_id[]" value="'.$tempid['nid'].'" checked>'; 232 } 233 234 ?></div> 235 <input type="hidden" name="run_update" value="<?php if ($run_update==true) echo "true"; else echo "false" ?>"> 236 <input type="hidden" name="add_related_article_ID" value="<?php echo $add_related_article_ID; ?>"> 237 <?php echo tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?> 238 </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_ARTICLES_XSELL . " SET sort_order = '".$value_a."' WHERE xsell_id= '$key_a' "; 254 if ($value_a != 'Update') 255 if (!tep_db_query($query)) 256 exit(TEXT_NO_UPDATE); 257 else 258 if ($run_once==0) 259 { ?> 260 <tr> 261 <td class="main"><?php echo TEXT_DATABASE_UPDATED; ?></td> 262 </tr> 263 <tr> 264 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 265 </tr> 266 <tr> 267 <td class="main"><?php echo sprintf(TEXT_LINK_MAIN_PAGE, tep_href_link(FILENAME_ARTICLES_XSELL, '', 'NONSSL')); ?></td> 268 </tr> 269 <tr> 270 <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 271 </tr> 272 <?php 273 $run_once++; 274 } 275 276 }// end of foreach. 277 ?> 278 <form method="post" action="<?php tep_href_link(FILENAME_ARTICLES_XSELL, 'sort=1&add_related_article_ID=' . $add_related_article_ID, 'NONSSL'); ?>"> 279 <table cellpadding="3" cellspacing="1" bgcolor="#CCCCCC" border="0"> 280 <tr class="dataTableHeadingRow"> 281 <td class="dataTableHeadingContent">ID</td> 282 <td class="dataTableHeadingContent"><?php echo HEADING_PRODUCT_NAME; ?></td> 283 <td class="dataTableHeadingContent"><?php echo HEADING_PRODUCT_ORDER; ?></td> 284 </tr> 285 <?php 286 $query = "select * from " . TABLE_ARTICLES_XSELL . " where articles_id = '".$add_related_article_ID."'"; 287 list ($ID_PR, $products_id_pr, $xsell_id_pr, $order_PR) = general_db_conct($query); 288 $ordering_size =sizeof($ID_PR); 289 for ($i=0;$i<$ordering_size;$i++) 290 { 291 292 $query = "select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = ".$xsell_id_pr[$i].""; 293 294 list ($products_id, $products_name, $products_description, $products_url) = general_db_conct($query); 295 296 ?> 297 <tr class="dataTableContentRow" bgcolor="#FFFFFF"> 298 <td class="dataTableContent"><?php echo $products_id[0]; ?></td> 299 <td class="dataTableContent"><?php echo $products_name[0]; ?></td> 300 <td class="dataTableContent" align="center"><select name="<?php echo $products_id[0]; ?>"> 301 <?php for ($y=1;$y<=$ordering_size;$y++) 302 { 303 echo "<option value=\"$y\""; 304 if (!(strcmp($y, "$order_PR[$i]"))) {echo "SELECTED";} 305 echo ">$y</option>"; 306 } 307 ?> 308 </select></td> 309 </tr> 310 <?php } // the end of foreach 311 ?> 312 <tr> 313 <td> </td> 314 <td bgcolor="#CCCCCC"><?php echo tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES_XSELL) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> 315 <td> </td> 316 </tr> 317 </table> 318 </form> 319 320 <?php }?> 321 322 323 </td> 324 </tr> 325 </table> 326 <!-- End of cross sale //--> 327 </td> 328 </tr></table> 329 <!-- body_text_eof //--> 330 <!-- footer //--> 331 <?php include (DIR_WS_INCLUDES . 'footer.php'); ?> 332 <!-- footer_eof //--> 333 <br> 334 </body> 335 </html> 336 <?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 |