Packing Slip Details
Just above that code, add:
At the very top of the page, find the line:
require_once("includes/open.php");
Just under that line, add the code:
$cust_err=''; if($mode=='year' OR $mode=='month' OR $mode=='week') { $custarray=array('Name'=>'InvName', 'Company'=>'InvCompany', 'Address'=>'InvAddress', 'City'=>'InvCity', 'State'=>'InvState', 'Zip'=>'InvZip', 'Country'=>'InvCountry', 'Email'=>'Email', 'Phone'=>'Phone'); $lastfield=end($custarray); $oint='1 ' .strtoupper($mode); $customers = mysql_query("SELECT " .implode(', ', $custarray) ." FROM " .SB_DB_PREFIX ."_orders WHERE OrderDate BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL " .$oint .") AND CURRENT_DATE()", $dblink) or die ("Unable to view customers."); if(mysql_num_rows($customers)==0) $cust_err='No Customers Found
'; else { $custdata=implode(" ", array_keys($custarray)) ."
"; while($custrow = mysql_fetch_array($customers)) { foreach($custarray AS $custkey=>$custval) { $custdata.=stripslashes($custrow[$custval]); if($custval==$lastfield) $custdata.="
"; else $custdata.=" "; } } header('Content-type: text/plain'); header('Content-Disposition: attachment; filename="customers.txt"'); echo $custdata; die(); } }
OPTIONAL. In that code, change:
'Name'=>'InvName', 'Company'=>'InvCompany', 'Address'=>'InvAddress', 'City'=>'InvCity', 'State'=>'InvState', 'Zip'=>'InvZip', 'Country'=>'InvCountry', 'Email'=>'Email', 'Phone'=>'Phone'
to reflect the fields that you want to display. The values are separated by commas and are in the format:
'COLUMN HEADING NAME'=>'FIELD IN DATABASE'
For instance, if you want to show the bill to name, the order number and the total paid, you would use something like:
'Bill To'=>'InvName', 'Order #'=>'OrderNumber', 'Total Paid'=>'Total'
where 'Bill To', 'Order #' and 'Total Paid' are labels you make up (these will show as columns across the top of the report), and 'InvName', 'OrderNumber' and 'Total are fields in the opc_orders table in the database. (Contact us if you need help with this part and we will gladly assist you!)
Save and reload the file. At this point, your client can select 'Orders' in the storeadmin area and click the 'Last Week', 'Last Month' or 'Last Year' button to view customer data for that time period.