| [ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: recover_cart_sales.php 14 2006-07-28 17:42:07Z user $ 4 Recover Cart Sales Tool v2.23 5 6 osCMax Power E-Commerce 7 http://oscdox.com 8 9 Copyright 2006 osCMax2003 JM Ivler / OSCommerce 10 11 Released under the GNU General Public License 12 13 Based on an original release of unsold carts by: JM Ivler 14 */ 15 require ('includes/application_top.php'); 16 require (DIR_WS_CLASSES . 'currencies.php'); 17 18 //link_post_variable('custid'); // fix to allow turning off register_globals in php - does not work w/standard osC (requires some other mod!) 19 20 $currencies = new currencies(); 21 22 // Delete Entry Begin 23 if ($HTTP_GET_VARS['action']=='delete') { 24 $reset_query_raw = "delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id=" . $HTTP_GET_VARS[customer_id]; 25 tep_db_query($reset_query_raw); 26 27 $reset_query_raw2 = "delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id=" . $HTTP_GET_VARS[customer_id]; 28 tep_db_query($reset_query_raw2); 29 30 tep_redirect(tep_href_link(FILENAME_RECOVER_CART_SALES, 'delete=1&customer_id='. $HTTP_GET_VARS['customer_id'] . '&tdate=' . $HTTP_GET_VARS['tdate'])); 31 } 32 33 if ($HTTP_GET_VARS['delete']) { 34 $messageStack->add(MESSAGE_STACK_CUSTOMER_ID . $HTTP_GET_VARS['customer_id'] . MESSAGE_STACK_DELETE_SUCCESS, 'success'); 35 } 36 37 // Delete Entry End 38 $tdate = $_POST['tdate']; 39 if ($tdate == '') $tdate = RCS_BASE_DAYS; 40 41 $sdate = $_POST['sdate']; 42 if( $sdate == '' ) $sdate = RCS_SKIP_DAYS; 43 ?> 44 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> 45 <html <?php echo HTML_PARAMS; ?>> 46 <head> 47 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>"> 48 <title><?php echo TITLE; ?></title> 49 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> 50 </head> 51 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> 52 53 <!-- header //--> 54 55 <?php require (DIR_WS_INCLUDES . 'header.php'); ?> 56 57 <!-- header_eof //--> 58 59 <!-- body //--> 60 <?php 61 function seadate($day) 62 { 63 $rawtime = strtotime("-".$day." days"); 64 $ndate = date("Ymd", $rawtime); 65 return $ndate; 66 } 67 68 function cart_date_short($raw_date) { 69 if ( ($raw_date == '00000000') || ($raw_date == '') ) return false; 70 71 $year = substr($raw_date, 0, 4); 72 $month = (int)substr($raw_date, 4, 2); 73 $day = (int)substr($raw_date, 6, 2); 74 75 if (@date('Y', mktime(0, 0, 0, $month, $day, $year)) == $year) { 76 return date(DATE_FORMAT, mktime(0, 0, 0, $month, $day, $year)); 77 } else { 78 return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime(0, 0, 0, $month, $day, 2037))); 79 } 80 } 81 82 // This will return a list of customers with sessions. Handles either the mysql or file case 83 // Returns an empty array if the check sessions flag is not true (empty array means same SQL statement can be used) 84 function _GetCustomerSessions() 85 { 86 $cust_ses_ids = array(); 87 88 if( RCS_CHECK_SESSIONS == 'true' ) 89 { 90 if (STORE_SESSIONS == 'mysql') 91 { 92 // --- DB RECORDS --- 93 $sesquery = tep_db_query("select value from " . TABLE_SESSIONS . " where 1"); 94 while ($ses = tep_db_fetch_array($sesquery)) 95 { 96 if ( ereg( "customer_id[^\"]*\"([0-9]*)\"", $ses['value'], $custval ) ) 97 $cust_ses_ids[] = $custval[1]; 98 } 99 } 100 else // --- FILES --- 101 { 102 if( $handle = opendir( tep_session_save_path() ) ) 103 { 104 while (false !== ($file = readdir( $handle )) ) 105 { 106 if ($file != "." && $file != "..") 107 { 108 $file = tep_session_save_path() . '/' . $file; // create full path to file! 109 if( $fp = fopen( $file, 'r' ) ) 110 { 111 $val = fread( $fp, filesize( $file ) ); 112 fclose( $fp ); 113 114 if ( ereg( "customer_id[^\"]*\"([0-9]*)\"", $val, $custval ) ) 115 $cust_ses_ids[] = $custval[1]; 116 } 117 } 118 } 119 closedir( $handle ); 120 } 121 } 122 } 123 return $cust_ses_ids; 124 } 125 ?> 126 <table border="0" width="100%" cellspacing="2" cellpadding="2"> 127 <tr> 128 <td width="<?php echo BOX_WIDTH; ?>" valign="top"> 129 <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> 130 131 <!-- left_navigation //--> 132 <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?> 133 <!-- left_navigation_eof //--> 134 135 </table></td> 136 137 <!-- body_text //--> 138 139 <td width="100%" valign="top"> 140 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 141 <?php // Are we doing an e-mail to some customers? 142 if (count($custid) > 0 ) { ?> 143 <tr> 144 <td class="pageHeading" align="left" colspan=2 width="50%"><?php echo HEADING_TITLE; ?> </td> 145 <td class="pageHeading" align="left" colspan=4 width="50%"><?php echo HEADING_EMAIL_SENT; ?> </td> 146 </tr> 147 <tr class="dataTableHeadingRow"> 148 <td class="dataTableHeadingContent" align="left" colspan="1" width="15%" nowrap><?php echo TABLE_HEADING_CUSTOMER; ?></td> 149 <td class="dataTableHeadingContent" align="left" colspan="1" width="30%" nowrap> </td> 150 <td class="dataTableHeadingContent" align="left" colspan="1" width="25%" nowrap> </td> 151 <td class="dataTableHeadingContent" align="left" colspan="1" width="10%" nowrap> </td> 152 <td class="dataTableHeadingContent" align="left" colspan="1" width="10%" nowrap> </td> 153 <td class="dataTableHeadingContent" align="left" colspan="1" width="10%" nowrap> </td> 154 </tr><tr> <br></tr> 155 <tr class="dataTableHeadingRow"> 156 <td class="dataTableHeadingContent" align="left" colspan="1" width="15%" nowrap><?php echo TABLE_HEADING_MODEL; ?></td> 157 <td class="dataTableHeadingContent" align="left" colspan="2" width="55%" nowrap><?php echo TABLE_HEADING_DESCRIPTION; ?></td> 158 <td class="dataTableHeadingContent" align="center" colspan="1" width="10%" nowrap> <?php echo TABLE_HEADING_QUANTY; ?></td> 159 <td class="dataTableHeadingContent" align="right" colspan="1" width="10%" nowrap><?php echo TABLE_HEADING_PRICE; ?></td> 160 <td class="dataTableHeadingContent" align="right" colspan="1" width="10%" nowrap><?php echo TABLE_HEADING_TOTAL; ?></td> 161 </tr> 162 <?php 163 foreach ($custid as $cid) 164 { 165 unset($email); 166 167 $query1 = tep_db_query("select cb.products_id pid, 168 cb.customers_basket_quantity qty, 169 cb.customers_basket_date_added bdate, 170 cus.customers_firstname fname, 171 cus.customers_lastname lname, 172 cus.customers_email_address email 173 from " . TABLE_CUSTOMERS_BASKET . " cb, 174 " . TABLE_CUSTOMERS . " cus 175 where cb.customers_id = cus.customers_id and 176 cus.customers_id = '".$cid."' 177 order by cb.customers_basket_date_added desc "); 178 179 $knt = mysql_num_rows($query1); 180 for ($i = 0; $i < $knt; $i++) 181 { 182 $inrec = tep_db_fetch_array($query1); 183 184 // set new cline and curcus 185 if ($lastcid != $cid) { 186 if ($lastcid != "") { 187 $cline .= " 188 <tr> 189 <td class='dataTableContent' align='right' colspan='6' nowrap><b>" . TABLE_CART_TOTAL . "</b>" . $currencies->format($tprice) . "</td> 190 </tr> 191 <tr> 192 <td colspan='6' align='right'><a href=" . tep_href_link(FILENAME_RECOVER_CART_SALES, "action=delete&customer_id=" . $cid . "&tdate=" . $tdate . "&sdate=" . $sdate) . ">" . tep_image_button('button_delete.gif', IMAGE_DELETE) . "</a></td> 193 </tr>\n"; 194 echo $cline; 195 } 196 $cline = "<tr> <td class='dataTableContent' align='left' colspan='6' nowrap><a href='" . tep_href_link(FILENAME_CUSTOMERS, 'search=' . $inrec['lname'], 'NONSSL') . "'>" . $inrec['fname'] . " " . $inrec['lname'] . "</a>".$customer."</td></tr>"; 197 $tprice = 0; 198 } 199 $lastcid = $cid; 200 201 // get the shopping cart 202 $query2 = tep_db_query("select p.products_price price, 203 p.products_tax_class_id taxclass, 204 p.products_model model, 205 pd.products_name name 206 from " . TABLE_PRODUCTS . " p, 207 " . TABLE_PRODUCTS_DESCRIPTION . " pd, 208 " . TABLE_LANGUAGES . " l 209 where p.products_id = '" . $inrec['pid'] . "' and 210 pd.products_id = p.products_id and 211 pd.language_id = " . (int)$languages_id ); 212 213 $inrec2 = tep_db_fetch_array($query2); 214 $sprice = tep_get_products_special_price( $inrec['pid'] ); 215 if( $sprice < 1 ) 216 $sprice = $inrec2['price']; 217 // Some users may want to include taxes in the pricing, allow that. NOTE HOWEVER that we don't have a good way to get individual tax rates based on customer location yet! 218 if( RCS_INCLUDE_TAX_IN_PRICES == 'true' ) 219 $sprice += ($sprice * tep_get_tax_rate( $inrec2['taxclass'] ) / 100); 220 else if( RCS_USE_FIXED_TAX_IN_PRICES == 'true' && RCS_FIXED_TAX_RATE > 0 ) 221 $sprice += ($sprice * RCS_FIXED_TAX_RATE / 100); 222 223 $tprice = $tprice + ($inrec['qty'] * $sprice); 224 $pprice_formated = $currencies->format($sprice); 225 $tpprice_formated = $currencies->format(($inrec['qty'] * $sprice)); 226 227 $cline .= "<tr class='dataTableRow'> 228 <td class='dataTableContent' align='left' width='15%' nowrap>" . $inrec2['model'] . "</td> 229 <td class='dataTableContent' align='left' colspan='2' width='55%'><a href='" . tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID=' . $inrec['pid'] . '&origin=' . FILENAME_RECOVER_CART_SALES . '?page=' . $HTTP_GET_VARS['page'], 'NONSSL') . "'>" . $inrec2['name'] . "</a></td> 230 <td class='dataTableContent' align='center' width='10%' nowrap>" . $inrec['qty'] . "</td> 231 <td class='dataTableContent' align='right' width='10%' nowrap>" . $pprice_formated . "</td> 232 <td class='dataTableContent' align='right' width='10%' nowrap>" . $tpprice_formated . "</td> 233 </tr>"; 234 235 $mline .= $inrec['qty'] . ' x ' . $inrec2['name'] . "\n"; 236 237 if( EMAIL_USE_HTML == 'true' ) 238 $mline .= ' <blockquote><a href="' . tep_catalog_href_link(FILENAME_CATALOG_PRODUCT_INFO, 'products_id='. $inrec['pid']) . '">' . tep_catalog_href_link(FILENAME_CATALOG_PRODUCT_INFO, 'products_id='. $inrec['pid']) . "</a></blockquote>\n\n"; 239 else 240 $mline .= ' (' . tep_catalog_href_link(FILENAME_CATALOG_PRODUCT_INFO, 'products_id='. $inrec['pid']).")\n\n"; 241 } 242 243 $cline .= "</td></tr>"; 244 245 // E-mail Processing - Requires EMAIL_* defines in the 246 // includes/languages/english/recover_cart_sales.php file 247 $cquery = tep_db_query("select * from orders where customers_id = '".$cid."'" ); 248 $email = EMAIL_TEXT_LOGIN; 249 250 if( EMAIL_USE_HTML == 'true' ) 251 $email .= ' <a HREF="' . tep_catalog_href_link(FILENAME_CATALOG_LOGIN, '', 'SSL') . '">' . tep_catalog_href_link(FILENAME_CATALOG_LOGIN, '', 'SSL') . '</a>'; 252 else 253 $email .= ' (' . tep_catalog_href_link(FILENAME_CATALOG_LOGIN, '', 'SSL') . ')'; 254 255 $email .= "\n" . EMAIL_SEPARATOR . "\n\n"; 256 257 if (RCS_EMAIL_FRIENDLY == 'true') 258 $email .= EMAIL_TEXT_SALUTATION . $inrec['fname'] . ","; 259 else 260 $email .= STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n"; 261 262 if (mysql_num_rows($cquery) < 1) 263 $email .= sprintf(EMAIL_TEXT_NEWCUST_INTRO, $mline); 264 else 265 $email .= sprintf(EMAIL_TEXT_CURCUST_INTRO, $mline); 266 267 $email .= EMAIL_TEXT_BODY_HEADER . $mline . EMAIL_TEXT_BODY_FOOTER; 268 269 if( EMAIL_USE_HTML == 'true' ) 270 $email .= '<a HREF="' . tep_catalog_href_link('', '') . '">' . STORE_OWNER . "\n" . tep_catalog_href_link('', '') . '</a>'; 271 else 272 $email .= STORE_OWNER . "\n" . tep_catalog_href_link('', ''); 273 274 $email .= "\n\n". $_POST['message']; 275 $custname = $inrec['fname']." ".$inrec['lname']; 276 277 $outEmailAddr = '"' . $custname . '" <' . $inrec['email'] . '>'; 278 if( tep_not_null(RCS_EMAIL_COPIES_TO) ) 279 $outEmailAddr .= ', ' . RCS_EMAIL_COPIES_TO; 280 281 tep_mail('', $outEmailAddr, EMAIL_TEXT_SUBJECT, $email, '', STORE_OWNER . EMAIL_FROM); 282 283 $mline = ""; 284 285 // See if a record for this customer already exists; if not create one and if so update it 286 $donequery = tep_db_query("select * from ". TABLE_SCART ." where customers_id = '".$cid."'"); 287 if (mysql_num_rows($donequery) == 0) 288 tep_db_query("insert into " . TABLE_SCART . " (customers_id, dateadded, datemodified ) values ('" . $cid . "', '" . seadate('0') . "', '" . seadate('0') . "')"); 289 else 290 tep_db_query("update " . TABLE_SCART . " set datemodified = '" . seadate('0') . "' where customers_id = " . $cid ); 291 292 echo $cline; 293 $cline = ""; 294 } 295 echo "<tr><td colspan=8 align='right' class='dataTableContent'><b>" . TABLE_CART_TOTAL . "</b>" . $currencies->format($tprice) . "</td> </tr>"; 296 echo "<tr><td colspan=6 align='right'><a href=" . tep_href_link(FILENAME_RECOVER_CART_SALES, "action=delete&customer_id=" . $cid . "&tdate=" . $tdate . "&sdate=" . $sdate) . ">" . tep_image_button('button_delete.gif', IMAGE_DELETE) . "</a></td> </tr>\n"; 297 echo "<tr><td colspan=6 align=center><a href=".$PHP_SELF.">" . TEXT_RETURN . "</a></td></tr>"; 298 } 299 else //we are NOT doing an e-mail to some customers 300 { 301 ?> 302 <!-- REPORT TABLE BEGIN //--> 303 <tr> 304 <td class="pageHeading" align="left" width="50%" colspan="4"><?php echo HEADING_TITLE; ?></td> 305 <td class="pageHeading" align="right" width="50%" colspan="4"> 306 <form method=post action=<?php echo $PHP_SELF;?> > 307 <table align="right" width="100%"> 308 <tr class="dataTableContent" align="right"> 309 <td><?php echo DAYS_FIELD_PREFIX; ?><input type=text size=4 width=4 value=<?php echo $sdate; ?> name=sdate> - <input type=text size=4 width=4 value=<?php echo $tdate; ?> name=tdate><?php echo DAYS_FIELD_POSTFIX; ?><input type=submit value="<?php echo DAYS_FIELD_BUTTON; ?>"></td> 310 </tr> 311 </table> 312 </form> 313 </td> 314 </tr> 315 <form method=post action=<?php echo $PHP_SELF; ?>> 316 <tr class="dataTableHeadingRow"> 317 <td class="dataTableHeadingContent" align="left" colspan="2" width="10%" nowrap><?php echo TABLE_HEADING_CONTACT; ?></td> 318 <td class="dataTableHeadingContent" align="left" colspan="1" width="15%" nowrap><?php echo TABLE_HEADING_DATE; ?></td> 319 <td class="dataTableHeadingContent" align="left" colspan="1" width="30%" nowrap><?php echo TABLE_HEADING_CUSTOMER; ?></td> 320 <td class="dataTableHeadingContent" align="left" colspan="2" width="30%" nowrap><?php echo TABLE_HEADING_EMAIL; ?></td> 321 <td class="dataTableHeadingContent" align="left" colspan="2" width="15%" nowrap><?php echo TABLE_HEADING_PHONE; ?></td> 322 </tr><tr> <br></tr> 323 <tr class="dataTableHeadingRow"> 324 <td class="dataTableHeadingContent" align="left" colspan="2" width="10%" nowrap> </td> 325 <td class="dataTableHeadingContent" align="left" colspan="1" width="15%" nowrap><?php echo TABLE_HEADING_MODEL; ?></td> 326 <td class="dataTableHeadingContent" align="left" colspan="2" width="55%" nowrap><?php echo TABLE_HEADING_DESCRIPTION; ?></td> 327 <td class="dataTableHeadingContent" align="center" colspan="1" width="5%" nowrap> <?php echo TABLE_HEADING_QUANTY; ?></td> 328 <td class="dataTableHeadingContent" align="right" colspan="1" width="5%" nowrap><?php echo TABLE_HEADING_PRICE; ?></td> 329 <td class="dataTableHeadingContent" align="right" colspan="1" width="10%" nowrap><?php echo TABLE_HEADING_TOTAL; ?></td> 330 </tr> 331 <?php 332 $cust_ses_ids = _GetCustomerSessions(); 333 $bdate = seadate($sdate); 334 $ndate = seadate($tdate); 335 $query1 = tep_db_query("select cb.customers_id cid, 336 cb.products_id pid, 337 cb.customers_basket_quantity qty, 338 cb.customers_basket_date_added bdate, 339 cus.customers_firstname fname, 340 cus.customers_lastname lname, 341 cus.customers_telephone phone, 342 cus.customers_email_address email 343 from " . TABLE_CUSTOMERS_BASKET . " cb, 344 " . TABLE_CUSTOMERS . " cus 345 where cb.customers_basket_date_added <= '" . $bdate . "' and 346 cb.customers_basket_date_added > '" . $ndate . "' and 347 cus.customers_id not in ('" . implode(", ", $cust_ses_ids) . "') and 348 cb.customers_id = cus.customers_id order by cb.customers_basket_date_added desc, 349 cb.customers_id "); 350 $results = 0; 351 $curcus = ""; 352 $tprice = 0; 353 $totalAll = 0; 354 $first_line = true; 355 $skip = false; 356 357 $knt = mysql_num_rows($query1); 358 for ($i = 0; $i <= $knt; $i++) 359 { 360 $inrec = tep_db_fetch_array($query1); 361 362 // If this is a new customer, create the appropriate HTML 363 if ($curcus != $inrec['cid']) 364 { 365 // output line 366 $totalAll += $tprice; 367 $cline .= " </td> 368 <tr> 369 <td class='dataTableContent' align='right' colspan='8'><b>" . TABLE_CART_TOTAL . "</b>" . $currencies->format($tprice) . "</td> 370 </tr> 371 <tr> 372 <td colspan='6' align='right'><a href=" . tep_href_link(FILENAME_RECOVER_CART_SALES,"action=delete&customer_id=" . $curcus . "&tdate=" . $tdate . "&sdate=" . $sdate) . ">" . tep_image_button('button_delete.gif', IMAGE_DELETE) . "</a></td> 373 </tr>\n"; 374 if ($curcus != "" && !$skip) 375 echo $cline; 376 377 // set new cline and curcus 378 $curcus = $inrec['cid']; 379 380 if ($curcus != "") 381 { 382 $tprice = 0; 383 384 // change the color on those we have contacted add customer tag to customers 385 $fcolor = RCS_UNCONTACTED_COLOR; 386 $checked = 1; // assume we'll send an email 387 $new = 1; 388 $skip = false; 389 $sentdate = ""; 390 $beforeDate = RCS_CARTS_MATCH_ALL_DATES ? '0' : $inrect['bdate']; 391 $customer = $inrec['fname'] . " " . $inrec['lname']; 392 $status = ""; 393 394 $donequery = tep_db_query("select * from ". TABLE_SCART ." where customers_id = '".$curcus."'"); 395 $emailttl = seadate(RCS_EMAIL_TTL); 396 397 if (mysql_num_rows($donequery) > 0) { 398 $ttl = tep_db_fetch_array($donequery); 399 if( $ttl ) 400 { 401 if( tep_not_null($ttl['datemodified']) ) // allow for older scarts that have no datemodified field data 402 $ttldate = $ttl['datemodified']; 403 else 404 $ttldate = $ttl['dateadded']; 405 406 if ($emailttl <= $ttldate) { 407 $sentdate = $ttldate; 408 $fcolor = RCS_CONTACTED_COLOR; 409 $checked = 0; 410 $new = 0; 411 } 412 } 413 } 414 415 // See if the customer has purchased from us before 416 // Customers are identified by either their customer ID or name or email address 417 // If the customer has an order with items that match the current order, assume order completed, bail on this entry! 418 $ccquery = tep_db_query('select orders_id, orders_status from ' . TABLE_ORDERS . ' where (customers_id = ' . (int)$curcus . ' OR customers_email_address like "' . $inrec['email'] .'" or customers_name like "' . $inrec['fname'] . ' ' . $inrec['lname'] . '") and date_purchased >= "' . $beforeDate . '"' ); 419 if (mysql_num_rows($ccquery) > 0) 420 { 421 // We have a matching order; assume current customer but not for this order 422 $customer = '<font color=' . RCS_CURCUST_COLOR . '><b>' . $customer . '</b></font>'; 423 424 // Now, look to see if one of the orders matches this current order's items 425 while( $orec = tep_db_fetch_array( $ccquery ) ) 426 { 427 $ccquery = tep_db_query( 'select products_id from ' . TABLE_ORDERS_PRODUCTS . ' where orders_id = ' . (int)$orec['orders_id'] . ' AND products_id = ' . (int)$inrec['pid'] ); 428 if( mysql_num_rows( $ccquery ) > 0 ) 429 { 430 if( $orec['orders_status'] > RCS_PENDING_SALE_STATUS ) 431 $checked = 0; 432 433 // OK, we have a matching order; see if we should just skip this or show the status 434 if( RCS_SKIP_MATCHED_CARTS == 'true' && !$checked ) 435 { 436 $skip = true; // reset flag & break us out of the while loop! 437 break; 438 } 439 else 440 { 441 // It's rare for the same customer to order the same item twice, so we probably have a matching order, show it 442 $fcolor = RCS_MATCHED_ORDER_COLOR; 443 $ccquery = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = " . (int)$languages_id . " AND orders_status_id = " . (int)$orec['orders_status'] ); 444 445 if( $srec = tep_db_fetch_array( $ccquery ) ) 446 $status = ' [' . $srec['orders_status_name'] . ']'; 447 else 448 $status = ' ['. TEXT_CURRENT_CUSTOMER . ']'; 449 } 450 } 451 } 452 if( $skip ) 453 continue; // got a matched cart, skip to next one 454 } 455 $sentInfo = TEXT_NOT_CONTACTED; 456 457 if ($sentdate != '') 458 $sentInfo = cart_date_short($sentdate); 459 460 $cline = " 461 <tr bgcolor=" . $fcolor . "> 462 <td class='dataTableContent' align='center' width='1%'>" . tep_draw_checkbox_field('custid[]', $curcus, RCS_AUTO_CHECK == 'true' ? $checked : 0) . "</td> 463 <td class='dataTableContent' align='left' width='9%' nowrap><b>" . $sentInfo . "</b></td> 464 <td class='dataTableContent' align='left' width='15%' nowrap> " . cart_date_short($inrec['bdate']) . "</td> 465 <td class='dataTableContent' align='left' width='30%' nowrap><a href='" . tep_href_link(FILENAME_CUSTOMERS, 'search=' . $inrec['lname'], 'NONSSL') . "'>" . $customer . "</a>".$status."</td> 466 <td class='dataTableContent' align='left' colspan='2' width='30%' nowrap><a href='" . tep_href_link('mail.php', 'selected_box=tools&customer=' . $inrec['email']) . "'>" . $inrec['email'] . "</a></td> 467 <td class='dataTableContent' align='left' colspan='2' width='15%' nowrap>" . $inrec['phone'] . "</td> 468 </tr>"; 469 } 470 } 471 472 // We only have something to do for the product if the quantity selected was not zero! 473 if ($inrec['qty'] != 0) 474 { 475 // Get the product information (name, price, etc) 476 $query2 = tep_db_query("select p.products_price price, 477 p.products_tax_class_id taxclass, 478 p.products_model model, 479 pd.products_name name 480 from " . TABLE_PRODUCTS . " p, 481 " . TABLE_PRODUCTS_DESCRIPTION . " pd, 482 " . TABLE_LANGUAGES . " l 483 where p.products_id = '" . (int)$inrec['pid'] . "' and 484 pd.products_id = p.products_id and 485 pd.language_id = " . (int)$languages_id ); 486 $inrec2 = tep_db_fetch_array($query2); 487 488 // Check to see if the product is on special, and if so use that pricing 489 $sprice = tep_get_products_special_price( $inrec['pid'] ); 490 if( $sprice < 1 ) 491 $sprice = $inrec2['price']; 492 // Some users may want to include taxes in the pricing, allow that. NOTE HOWEVER that we don't have a good way to get individual tax rates based on customer location yet! 493 if( RCS_INCLUDE_TAX_IN_PRICES == 'true' ) 494 $sprice += ($sprice * tep_get_tax_rate( $inrec2['taxclass'] ) / 100); 495 else if( RCS_USE_FIXED_TAX_IN_PRICES == 'true' && RCS_FIXED_TAX_RATE > 0 ) 496 $sprice += ($sprice * RCS_FIXED_TAX_RATE / 100); 497 498 // BEGIN OF ATTRIBUTE DB CODE 499 $prodAttribs = ''; // DO NOT DELETE 500 501 if (RCS_SHOW_ATTRIBUTES == 'true') 502 { 503 $attribquery = tep_db_query("select cba.products_id pid, 504 po.products_options_name poname, 505 pov.products_options_values_name povname 506 from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " cba, 507 " . TABLE_PRODUCTS_OPTIONS . " po, 508 " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, 509 " . TABLE_LANGUAGES . " l 510 where cba.products_id ='" . $inrec['pid'] . "' and 511 cba.customers_id = " . $curcus . " and 512 po.products_options_id = cba.products_options_id and 513 pov.products_options_values_id = cba.products_options_value_id and 514 po.language_id = " . (int)$languages_id . " and 515 pov.language_id = " . (int)$languages_id 516 ); 517 $hasAttributes = false; 518 519 if (tep_db_num_rows($attribquery)) 520 { 521 $hasAttributes = true; 522 $prodAttribs = '<br>'; 523 524 while ($attribrecs = tep_db_fetch_array($attribquery)) 525 $prodAttribs .= '<small><i> - ' . $attribrecs['poname'] . ' ' . $attribrecs['povname'] . '</i></small><br>'; 526 } 527 } 528 // END OF ATTRIBUTE DB CODE 529 $tprice = $tprice + ($inrec['qty'] * $sprice); 530 $pprice_formated = $currencies->format($sprice); 531 $tpprice_formated = $currencies->format(($inrec['qty'] * $sprice)); 532 533 $cline .= "<tr class='dataTableRow'> 534 <td class='dataTableContent' align='left' vAlign='top' colspan='2' width='12%' nowrap> </td> 535 <td class='dataTableContent' align='left' vAlign='top' width='13%' nowrap>" . $inrec2['model'] . "</td> 536 <td class='dataTableContent' align='left' vAlign='top' colspan='2' width='55%'><a href='" . tep_href_link(FILENAME_CATEGORIES, 'action=new_product_preview&read=only&pID=' . $inrec['pid'] . '&origin=' . FILENAME_RECOVER_CART_SALES . '?page=' . $HTTP_GET_VARS['page'], 'NONSSL') . "'><b>" . $inrec2['name'] . "</b></a> 537 " . $prodAttribs . " 538 </td> 539 <td class='dataTableContent' align='center' vAlign='top' width='5%' nowrap>" . $inrec['qty'] . "</td> 540 <td class='dataTableContent' align='right' vAlign='top' width='5%' nowrap>" . $pprice_formated . "</td> 541 <td class='dataTableContent' align='right' vAlign='top' width='10%' nowrap>" . $tpprice_formated . "</td> 542 </tr>"; 543 } 544 } 545 $totalAll_formated = $currencies->format($totalAll); 546 $cline = "<tr></tr><td class='dataTableContent' align='right' colspan='8'><hr align=right width=55><b>" . TABLE_GRAND_TOTAL . "</b>" . $totalAll_formated . "</td> 547 </tr>"; 548 echo $cline; 549 echo "<tr><td colspan=8><hr size=1 color=000080><b>". PSMSG ."</b><br>". tep_draw_textarea_field('message', 'soft', '80', '5') ."<br>" . tep_draw_selection_field('submit_button', 'submit', TEXT_SEND_EMAIL) . "</td></tr>"; 550 ?> 551 </form> 552 <?php } 553 // 554 // end footer of both e-mail and report 555 // 556 ?> 557 <!-- REPORT TABLE END //--> 558 </table> 559 </td> 560 <!-- body_text_eof //--> 561 </tr> 562 </table> 563 <!-- body_eof //--> 564 <!-- footer //--> 565 <?php require (DIR_WS_INCLUDES . 'footer.php'); ?> 566 <!-- footer_eof //--> 567 <br> 568 </body> 569 </html> 570 <?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 |