Jump to content
jcall

All Customers Report

Recommended Posts

Great contribution. I added the "COMPANY" name to the file and translated to portuguese language. Everything works fine. Thanks a lot.

 

i got the below error from the csv file

<b>Fatal error</b>: Call to undefined function: html_entity_decode() in <b>/xxx/admin/all_customers.php</b> on line <b>32</b><br />

Share this post


Link to post
Share on other sites

Did anyone figure out the answer to this issue?

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/lyons/public_html/admin/includes/functions/database.php on line 107

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/lyons/public_html/admin/includes/functions/database.php on line 99

I can't figure it out


If the only tool you have is a hammer, all your problems look like nails

Share this post


Link to post
Share on other sites

Well I got the listings to come up in admin after severely modifying the admin/all_customers.php file. Now I can't get it to export in IE7!

Here is my code for admin/all_customers.php which will get you past the DB errors

<?php
/*
 $Id: all_customers.php, v1.0 March 21, 2005 18:45:00
 adapted by Robert Goth June 24, 2005

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]
 Copyright © 2002 - 2004 osCommerce

 written by Jared Call at client' suggestion
 some code nicked and modified from /catalog/admin/customers.php
 Released under the GNU General Public License
*/

// entry for bouncing csv string back as file
// Turn on output buffering
ob_start();
if (isset($_POST['csv'])) {
if (isset($HTTP_POST_VARS['saveas'])) {  // rebound posted csv as save file
	$savename= $HTTP_POST_VARS['saveas'] . ".csv";
	}
	else $savename='unknown.csv';
$csv_string = '';
if ($HTTP_POST_VARS['csv']) $csv_string=$HTTP_POST_VARS['csv'];
 if (strlen($csv_string)>0){
 header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
 header("Last-Modified: " . gmdate('D,d M Y H:i:s') . ' GMT');
 header("Cache-Control: no-cache, must-revalidate");
 header("Pragma: no-cache");
 header("Content-Type: text/csv");
 header("Content-Disposition: attachment; filename=$savename");
 echo html_entity_decode(stripslashes($csv_string), ENT_QUOTES);
 }
 else echo "CSV string empty";
exit;
};

require('includes/application_top.php');

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

     <tr>
       <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
<?php

// Used to determine sorting order by field
 switch ($orderby) {

  case "email" :
  $db_orderby = "c.customers_email_address";
  break;

  	case "address":
$db_orderby = "a.entry_street_address";
break;

case "city":
$db_orderby = "a.entry_city";
break;

case "state":
$db_orderby = "a.entry_state";
break;

case "telephone":
$db_orderby = "c.customers_telephone";
break;

case "pcode":
$db_orderby = "a.entry_postcode";
break;

  default :
  $db_orderby = "a.entry_lastname";;
  break;

  }



$customers_query_raw = "SELECT c.customers_id , c.customers_default_address_id, c.customers_email_address, c.customers_telephone,a.address_book_id, a.customers_id, a.entry_firstname, a.entry_lastname, a.entry_street_address, a.entry_suburb, a.entry_city, a.entry_state, a.entry_postcode FROM " . TABLE_CUSTOMERS . " c LEFT JOIN " .  TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id ORDER BY $db_orderby $sorted";
 $customers_query = tep_db_query($customers_query_raw);



//BOF HEADER  ?>
<tr class="dataTableHeadingRow">
<? /*<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NUMBER; ?></td> */ ?>
<td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, FULL_NAME, 'name');?></td>
<td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, EMAIL, 'email');?></td>
<td class="dataTableHeadingContent"><?php
 										echo tep_sort_order ($orderby, $sorted, ADDRESS, 'address');?></td>
<td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, CITY_NAME, 'city');?></td>
<td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, STATE, 'state');?></td>
<td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, POSTAL_CODE, 'pcode');?></td>
<td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, CONTRY_NAME, 'country');?></td>
<td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, TELEPHONE_NUMBER, 'telephone');

//EOF HEADER
?></td>

	   	 </tr>

 <?PHP
 $num_rows = tep_db_num_rows($customers_query);
 while ($customers = tep_db_fetch_array($customers_query)) {
  if ( tep_not_null($customers['customers_id']) ) {
  $rows++;
    if (strlen($rows) < 2) {
     $rows = '0' . $rows;
   }
$csv_accum .= "\n";

	  $email = '<a href="mailto:' . $customers['customers_email_address'] . '">'
	            . $customers['customers_email_address'] . '</a>';
	  $full_name = '<a href="customers.php?cID=' . $customers['customers_id'] . '&action=edit"> ' . $customers['entry_lastname'] . ", " . $customers['entry_firstname'] . '</a>';
?>
	      <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">
	      	 <? /*  <td align="left" class="dataTableContent"><?php echo $rows; ?>.</td> */ ?>
			   <td class="dataTableContent"><?php mirror_out($full_name);?></td>
	      	  <td class="dataTableContent"><?php  mirror_out($email); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['entry_street_address']); ?></td>
	          <td class="dataTableContent"><?php mirror_out($customers['entry_city']); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['entry_state']); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['entry_postcode']); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['countries_name']); ?></td>
			  <td class="dataTableContent"><?php mirror_out($customers['customers_telephone']); ?></td>

	   	 </tr>

      <?php
     } else { }
 }
?>

<!-- body_text_eof //-->
 </tr>
 <?PHP
		 if ($num_rows>0 && !$print) {
?>


			<td class="smallText" colspan="4"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method=post>
			<input type='hidden' name='csv' value='<?php echo htmlentities($csv_accum, ENT_QUOTES); ?>'>
			<?php //suggested file name for csv, include year and month ?>
			<input type='hidden' name='saveas' value='Customer_List_<?php echo date("Y" . "_" . "m" . "_" . "d" . "_" . "Hi"); ?>'><input type="submit" value="<?php echo TEXT_BUTTON_REPORT_SAVE ;?>"></form>
			</td>
</tr>
<?php }; // end button for Save CSV ?>
</table>


<!-- body_eof //-->





<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
</body>
</html>


If the only tool you have is a hammer, all your problems look like nails

Share this post


Link to post
Share on other sites

A new version has been uploaded with these changes:

 

- Fixed code that displays the page heading so it displays the correct one.

- Removed non-standard code from mysql call.

- Added newsletter option along with the code to filter by it.

- Added code to enter a start/stop date.

- Changed code so the report is not ran until submit is clicked. Automatically running it creates problems with sites with a large number of customers.

- Made minor changes to the code for formatting and displaying an error message.

 

Jack

Share this post


Link to post
Share on other sites

Hi,

 

I just installed this on a highly modified shop and on a stock shop.

I get the same error each time:

 

Parse error: syntax error, unexpected T_FUNCTION in C:\htdocs\mystorename\myadminfoldername\includes\functions\general.php on line 1512

 

// Produce CSV string for output

function mirror_out ($field) {

global $csv_accum;

echo $field;

$field = strip_tags($field);

$field = ereg_replace ("\"","\"\"",$field);

if ($csv_accum=='') $csv_accum= "\"" . $field . "\"";

else // Sort Function

function tep_sort_order ($orderby, $sorted, $title, $order_criteria){ // LINE 1512

global $csv_accum;

if (!isset($orderby) or ($orderby == $order_criteria and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC";

 

$field = strip_tags($title);

$field = ereg_replace ("\"","\"\"",$field);

if ($csv_accum=='') $csv_accum= "\"" . $field . "\"";

else

{if (strrpos($csv_accum,chr(10)) == (strlen($csv_accum)-1)) $csv_accum .= "\"" . $field . "\"";

else $csv_accum .= "," . "\"" . $field . "\""; };

$link = '<a href="' . tep_href_link(FILENAME_ALL_CUSTOMERS, 'orderby=' . $order_criteria .'&sorted='. $to_sort) . '" class="headerLink">' . $title . '</a>';

return $link;

}

 

 

OS:

Apache/2.2.9 (Win32) DAV/2 mod_ssl/2.2.9 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.6

DB: MySQL 5.0.67-community-nt

PHP: 5.2.6 (Zend: 2.2.0)

 

Thanks in advance.

Share this post


Link to post
Share on other sites

What version of the contribution are you using? My version says to add this code, which doesn't look like yours.

// Sort Function 
 function tep_sort_order ($orderby, $sorted, $title, $order_criteria){
 global $csv_accum;
 if (!isset($orderby) or ($orderby == $order_criteria and $sorted == "ASC"))  $to_sort = "DESC"; else $to_sort = "ASC"; 

$field = strip_tags($title);
$field = ereg_replace ("\"","\"\"",$field);
if ($csv_accum=='') $csv_accum= "\"" . $field . "\""; 
else 
{if (strrpos($csv_accum,chr(10)) == (strlen($csv_accum)-1)) $csv_accum .= "\"" . $field . "\"";
else $csv_accum .= "," . "\"" . $field . "\""; };
$link = '<a href="' . tep_href_link(FILENAME_ALL_CUSTOMERS, 'orderby=' . $order_criteria .'&sorted='. $to_sort) . '" class="headerLink">' . $title . '</a>';
  return $link;
 }

 // Produce CSV string for output
 function mirror_out ($field) {
global $csv_accum;
echo $field;
$field = strip_tags($field);
$field = ereg_replace ("\"","\"\"",$field);
if ($csv_accum=='') $csv_accum= "\"" . $field . "\""; 
else 
{if (strrpos($csv_accum,chr(10)) == (strlen($csv_accum)-1)) $csv_accum .= "\"" . $field . "\"";
	else $csv_accum .= "," . "\"" . $field . "\""; };
return;
};

 

Jack

Share this post


Link to post
Share on other sites

Well it was me :(

I have no idea why I got errors on the live and the test shop the 1st go around unless I was brain dead or tierd at the time.

 

All went well and I have another of your great contributions or modifications install :)

 

Many many thanks for all you do for the community :)

Share this post


Link to post
Share on other sites

Running highly modified oscMAX (not a vanilla osc install)

 

Just a FYI I installed an older version that timed out on me.. looked and saw there was a new version with., yippee a filter for newsletter subscribers.. and installed that but I was getting a

tep_hide_session_id() function error..

 

some quick searching said to just remove that code and whamo I'm in business

 

catalog/admin/all_customers.php

	  <?php echo tep_draw_form('news_date', FILENAME_ALL_CUSTOMERS, '', 'get') . tep_draw_hidden_field('process_form', 'process_form') . tep_hide_session_id(); ?>

 

revise to read:

	  <?php echo tep_draw_form('news_date', FILENAME_ALL_CUSTOMERS, '', 'get') . tep_draw_hidden_field('process_form', 'process_form'); ?>

 

A bit shocking to see just how many do not subscribe.. They will get a pretty post card reminding them to stop by :)

Edited by wkdwich

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Share this post


Link to post
Share on other sites

Removing that code will break the code on some shops. Better to add the function, which is included in the oscommerce package.

 

Jack

Share this post


Link to post
Share on other sites
Removing that code will break the code on some shops. Better to add the function, which is included in the oscommerce package.

 

Jack

 

oh my.. thats not good.. I did a test order and everything worked.. even created a new account.. can you point me to where I can find the code to add and where?? I hate breaking things :)


Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Share this post


Link to post
Share on other sites

I have a request for a second filter.. I installed this and "Inactive Users" and both work well.. but All Customers functions much more efficently especially with the newsletter & date filter and the save as csv option.

 

The goal here is to contact by postal mail all those who registered, do not subscribe to the newsletter and/or never never ordered.. I've got 1/2 of that accomplished.. the Inavtive User mod, while it works, there is no export function.. that alone would be helpful, but then I would need to add the address information to send them a postal mailing.. I'm thinking the most efficient means would be to mod All customers, not Inactive Users

 

Looks to my bad eye that this is the code to help make the query from Inactive users..

 

		  $siu_query_raw = "select ci.customers_info_date_of_last_logon, c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address, c.customers_newsletter from " . TABLE_CUSTOMERS_INFO . " ci join " . TABLE_CUSTOMERS . " c left join " . TABLE_ORDERS . " o on c.customers_id = o.customers_id where o.customers_id is NULL and c.customers_id = ci.customers_info_id  and (ci.customers_info_date_of_last_logon='0000-00-00 00:00:00' or ci.customers_info_date_of_last_logon is NULL) order by c.customers_id";

 

The filter for last_logon maybe could be a an option of 0 logins, or 1 login..

 

I plan on printing both php files and going over them to see if I can figure it out.. but I'm not very hopeful :) I'm not a n00b, but my PHP coding skills are lacking..

 

Does anyone think this can be accomplished?

thanks!

Edited by wkdwich

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Share this post


Link to post
Share on other sites
oh my.. thats not good.. I did a test order and everything worked.. even created a new account.. can you point me to where I can find the code to add and where?? I hate breaking things :)
Download the latest oscommerce package and search for the function in includes/html_output.php. Then copy/paste it to the same file in your shop.

 

Jack

Share this post


Link to post
Share on other sites
Download the latest oscommerce package and search for the function in includes/html_output.php. Then copy/paste it to the same file in your shop.

 

Jack

 

 

Odd.. wonder why it was there in the

/catalog/includs/functions/output_html.php

and not in:

/catalog/admin/includs/functions/output_html.php

 

making the change now .. OK done and tested.. thanks for the help :)


Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Share this post


Link to post
Share on other sites

Fatal error: Call to undefined function tep_hide_session_id() in /all_customers.php on line 122

 

CODE

 

<?php
/*
 $Id: all_customers.php, v1.0 March 21, 2005 18:45:00
 adapted by Robert Goth June 24, 2005

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]
 Copyright © 2002 - 2004 osCommerce

 written by Jared Call at client' suggestion
 some code nicked and modified from /catalog/admin/customers.php
 Released under the GNU General Public License
*/

// entry for bouncing csv string back as file
// Turn on output buffering

ob_start();
if (isset($_POST['csv'])) {
 if (isset($HTTP_POST_VARS['saveas'])) {  // rebound posted csv as save file
	$savename= $HTTP_POST_VARS['saveas'] . ".csv";
}
else $savename='unknown.csv';

 $csv_string = '';
 if ($HTTP_POST_VARS['csv']) $csv_string=$HTTP_POST_VARS['csv']; 

 if (strlen($csv_string)>0) {
   header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
   header("Last-Modified: " . gmdate('D,d M Y H:i:s') . ' GMT');
   header("Cache-Control: no-cache, must-revalidate");
   header("Pragma: no-cache");
   header("Content-Type: text/csv");
   header("Content-Disposition: attachment; filename=$savename");
   echo html_entity_decode(stripslashes($csv_string), ENT_QUOTES);
 }
 else echo "CSV string empty";

 exit;
};




require('includes/application_top.php');

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE_ALL_CUSTOMERS; ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <?php
     $where = '';
     $nsChecked = array();
     if (isset($_GET['group_newsletter'])) {
       switch ($_GET['group_newsletter'])
       {
         case 'Newsletter_On': $where = ' c.customers_newsletter = 1 ';
                               $nsChecked['on'] = 'checked'; 
                               break;
         case 'Newsletter_Off': $where = ' c.customers_newsletter != 1 '; 
                               $nsChecked['off'] = 'checked'; 
                               break;
         default: $where = '';
                  $nsChecked['both'] = 'checked'; 
       }  
     }
     else
       $nsChecked['both'] = 'checked'; 

     if (tep_not_null($where))
      $where = ' where ' . $where;

     $datePeriod = '';  
     if (isset($_GET['date_start']) && tep_not_null($_GET['date_start'])) {
       if (isset($_GET['date_stop']) && tep_not_null($_GET['date_stop'])) {
         $start = sprintf("'%s-%s-%s 0:0:0'", substr($_GET['date_start'], 4), substr($_GET['date_start'], 0, 2), substr($_GET['date_start'], 2, 2));
         $stop = sprintf("'%s-%s-%s 0:0:0'", substr($_GET['date_stop'], 4), substr($_GET['date_stop'], 0, 2), substr($_GET['date_stop'], 2, 2));
         $datePeriod = ' ci.customers_info_date_account_created between ' . $start . ' and '.$stop . ' '; 
       }    
     }
     if (tep_not_null($datePeriod))
     {
       if (tep_not_null($where))
         $where .= ' and ' . $datePeriod;
       else
         $where = ' where ' . $datePeriod;
     }

     $today = date("mdY");         
     ?>
     <?php echo tep_draw_form('news_date', FILENAME_ALL_CUSTOMERS, '', 'get') . tep_draw_hidden_field('process_form', 'process_form') . tep_hide_session_id(); ?>
     <tr>
       <td><table border="0" width="60%" cellspacing="0" cellpadding="0">
         <tr class="smallText">
           <td><?php echo ENTRY_GROUP_NEWSLETTER; ?></td>
           <td><INPUT TYPE="radio" NAME="group_newsletter" VALUE="Newsletter_On" <?php echo $nsChecked['on']; ?> ><?php echo TEXT_NEWSLETTER_SUBSCRIBED; ?></td>
           <td><INPUT TYPE="radio" NAME="group_newsletter" VALUE="Newsletter_Off" <?php echo $nsChecked['off']; ?> ><?php echo TEXT_NEWSLETTER_UNSUBSCRIBED; ?></td>
           <td><INPUT TYPE="radio" NAME="group_newsletter" VALUE="All" <?php echo $nsChecked['both']; ?> ><?php echo TEXT_NEWSLETTER_BOTH; ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>      
     <tr>
       <td><table border="0" width="60%" cellspacing="0" cellpadding="0">
         <tr class="smallText">
           <td width="80"><?php echo ENTRY_DATE_START; ?></td>
           <td><?php echo tep_draw_input_field('date_start', '', 'maxlength="8" size="8"', false); ?> </td>
           <td width="80" align="center"><?php echo ENTRY_DATE_STOP; ?></td>
           <td><?php echo tep_draw_input_field('date_stop', $today, 'maxlength="8" size="8"', false); ?> </td>
           <td><?php echo TEXT_EXPLAIN_DATE; ?></td>
         </tr>
         <tr>
          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
         </tr>      
         <tr>
           <td><input type="submit"></td>
         </tr>  
       </table></td>
     </tr>
     </form>      
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
<?php  
// Used to determine sorting order by field
 switch ($orderby) {

  case "email" :
  $db_orderby = "c.customers_email_address";
  break;

  case "newsletter" :
  $db_orderby = "c.customers_newsletter";
  break;

  case "address":
	 $db_orderby = "a.entry_street_address";
	 break;

	 case "city":
	 $db_orderby = "a.entry_city";
	 break;

	 case "state":
	 $db_orderby = "z.zone_code";
	 break;

	 case "country":
	 $db_orderby = "co.countries_name";
	 break;

	 case "telephone":
	 $db_orderby = "c.customers_telephone";
	 break;

	 case "pcode":
	 $db_orderby = "a.entry_postcode";
	 break;

  default :
  $db_orderby = "a.entry_lastname";;
  break;
 }

 $customers_query_raw = "SELECT c.customers_id , c.customers_default_address_id, c.customers_email_address, c.customers_newsletter, c.customers_fax, c.customers_telephone, c.customers_gender, a.entry_company, a.address_book_id, a.customers_id, a.entry_firstname, a.entry_lastname, a.entry_street_address, a.entry_suburb, a.entry_city, a.entry_state, a.entry_postcode, a.entry_country_id, a.entry_zone_id, z.zone_code, co.countries_name FROM " . TABLE_CUSTOMERS . " c LEFT JOIN " . TABLE_CUSTOMERS_INFO . " ci on c.customers_id = ci.customers_info_id LEFT JOIN " . TABLE_ADDRESS_BOOK . " a ON c.customers_id = a.customers_id  and c.customers_default_address_id = a.address_book_id left join " . TABLE_ZONES . " z ON a.entry_zone_id = z.zone_id left join " . TABLE_COUNTRIES . " co ON a.entry_country_id = co.countries_id $where ORDER BY $db_orderby $sorted" ;

 if ($start)
 {
   $customers_query = tep_db_query($customers_query_raw);
   $num_rows = tep_db_num_rows($customers_query);

   if ($num_rows)
   {  
   ?>
     <!-- BOF HEADER -->
     <tr>
      <td width="100%"><table border="0" width="100%">
       <tr class="dataTableHeadingRow">
        <?php /*<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NUMBER; ?></td> */ ?>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, FULL_NAME, 'name');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, EMAIL, 'email');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, ADDRESS, 'address');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, CITY_NAME, 'city');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, STATE, 'state');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, POSTAL_CODE, 'pcode');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, CONTRY_NAME, 'country');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, TELEPHONE_NUMBER, 'telephone');?></td>
        <td class="dataTableHeadingContent"><?php echo tep_sort_order ($orderby, $sorted, 'NewsLetter', 'newsletter');?></td>
        <!-- EOF HEADER -->
       </tr>
      <?php
      while ($customers = tep_db_fetch_array($customers_query)) {
    	  if ( tep_not_null($customers['customers_id']) ) {
    	    $rows++;
    	    if (strlen($rows) < 2) {
           $rows = '0' . $rows;
          }

          $firstName = explode(" ", $customers['entry_firstname']);
          $csv_accum .= "\n";

      	 $email = '<a href="mailto:' . $customers['customers_email_address'] . '">' . $customers['customers_email_address'] . '</a>';
      	 $full_name = '<a href="customers.php?cID=' . $customers['customers_id'] . '&action=edit">' . ucfirst(strtolower($firstName[0])) . " " . ucfirst(strtolower($customers['entry_lastname'])) . '</a>';
       ?>
 		    <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">
	      	  <?php /*  <td align="left" class="dataTableContent"><?php echo $rows; ?>.</td> */ ?>
			     <td class="dataTableContent"><?php mirror_out($full_name);?></td>
	      	  <td class="dataTableContent"><?php  mirror_out($email); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['entry_street_address']); ?></td>
          <td class="dataTableContent"><?php mirror_out($customers['entry_city']); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['zone_code']); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['entry_postcode']); ?></td>
	      	  <td class="dataTableContent"><?php mirror_out($customers['countries_name']); ?></td>
			     <td class="dataTableContent"><?php mirror_out($customers['customers_telephone']); ?></td>
			     <td class="dataTableContent"><?php mirror_out($customers['customers_newsletter']); ?></td>
 		    </tr>
        <?php
        }    
      } //while
      ?>
      </table></td>
     </tr>
     <?php
   } else {
     echo '<tr><td class="main" style="color: red;">'.ERROR_NO_MATCHES. '</td></tr>';
   } //if num rows
 } //end of if start
?>

<!-- body_text_eof //-->
 </tr>
 <?PHP
		 if ($num_rows > 0 && !$print) {
?>


			<td class="smallText" colspan="4"><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method=post>
			<input type='hidden' name='csv' value='<?php echo htmlentities($csv_accum, ENT_QUOTES); ?>'>
			<?php //suggested file name for csv, include year and month ?>
			<input type='hidden' name='saveas' value='Customer_List_<?php echo date("Y" . "_" . "m" . "_" . "d" . "_" . "Hi"); ?>'><input type="submit" value="<?php echo TEXT_BUTTON_REPORT_SAVE ;?>"></form>
			</td>
</tr>
<?php }; // end button for Save CSV ?>
</table>


<!-- body_eof //-->





<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
</body>
</html>


Yeah Yeah I am learning as I go... lol

Share this post


Link to post
Share on other sites

see the post above

 

http://forums.oscommerce.com/index.php?sho...t&p=1374838

 

you probably have the same issue I did, the function was missing from the admin/includes/functions/output_html.php

 

I did as Jack suggested grabbed the latest copy of osc and copied the code to my file and it worked perfectly


Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Share this post


Link to post
Share on other sites

ok I added /includes/functions/html_output and it didn't work... However, I replaced it also in the Admin section and it appears to be up... bout to test it and see what happens... Thanks!!!


Yeah Yeah I am learning as I go... lol

Share this post


Link to post
Share on other sites
ok I added /includes/functions/html_output and it didn't work... However, I replaced it also in the Admin section and it appears to be up... bout to test it and see what happens... Thanks!!!

To be clear, I didn't say to copy the whole file. If you did that, espeically if you copied the same one to both locations, you may have introduced errors into your shop. You should replace those files with the originals and then just copy the part of the file that is needed.

 

Jack

Share this post


Link to post
Share on other sites

You are right Jack... my image magik stopped working. But the weird thing is that I actually re-uploaded the html output files from a back up I have and image magik is working again but the All Customers is still working... hmmmm strange. but hey I am not complaining


Yeah Yeah I am learning as I go... lol

Share this post


Link to post
Share on other sites

Hi. I have downloaded and installed Customer Export Full package v. 1.5.

 

It appears that the STATE list still doesn't populate. In this forum I haven't been able to pin down the fix to get it to display the states. The column is there, but it is unpopulated. Also it appears that all countries are either US or Canada. Any other country defaults to US.

 

Also it doesn't export in IE7 or IE8. I had to do it via FireFox. But I can live with that. Just need the states.

 

Can anyone help???

 

Thx

Edited by woodpress

Share this post


Link to post
Share on other sites
Hi. I have downloaded and installed Customer Export Full package v. 1.5.

 

It appears that the STATE list still doesn't populate. In this forum I haven't been able to pin down the fix to get it to display the states. The column is there, but it is unpopulated. Also it appears that all countries are either US or Canada. Any other country defaults to US.

 

Also it doesn't export in IE7 or IE8. I had to do it via FireFox. But I can live with that. Just need the states.

 

Can anyone help???

 

Thx

 

 

EDIT: I think I figured out what is wrong with the state not appearing. The STATE field is being populated by the ADDRESS 2 Field. How is that fixed?

Share this post


Link to post
Share on other sites

So I added everything, and followed the instructions verbatim. And I got this error:

Fatal error: Call to undefined function tep_hide_session_id() in /home/alex/public_html/oscommerce/admin/all_customers.php on line 122

So I removed:

<?php echo tep_draw_form('news_date', FILENAME_ALL_CUSTOMERS, '', 'get') . tep_draw_hidden_field('process_form', 'process_form') . tep_hide_session_id(); ?>

And now it appears to be like it should be but when I hit submit query it doesn't do anything.

 

I'm only running MS2.2 not RCA if that matters.

 

Edit: fixed it my deleting the ". tep_hide_session_id();"

 

Edit: New problem, when I go to save csv it goes to a blank page.

Edited by magicandmischief182

Share this post


Link to post
Share on other sites

To fix the problem: Return everything to the way it was after the installation. Then open includes/functions/html_output.php and copy the code for the function named tep_hide_session. Then open the admin/includes/functions/public_html.php file and paste it into it before the last ?>.

 

Hack

Share this post


Link to post
Share on other sites

I installed this contribution and it is great! Client is lovin' it!

 

I have two questions which I hope I'm not asking too much.

 

1. is there a way to sort the customers by when they signed up?

 

2. Is there a way to break the list up into pages? Maybe 50-100 customers per page for display in the browser?

 

Any help would be greatly appreciated.

 

Thank you in advance.

 

Jim

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×