Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Order Info


MoisesZaragoza

Recommended Posts

here is something that could come close. Note that I havent tested it in a real shop.

 

"select o.orders_id, o.delivery_street_address from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_PRODUCTS . " ot op (o.orders_id = op.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = 'pending' order by o.customer_name";

 

and you may want to add specific product fields you need after the select

Link to comment
Share on other sites

Than enigma1 but I still have a bit Code problem.

Im ok with Query but I'm really a beginer.

 

 

I think that this topic should be link to End of day Report becase I'm using it together.

 

This is what I'm doing.

1) I created a new php file and Named it OrderExel. php

2) Now I need the proper Query

3) Linkthe PHP in the End of day Report to the Query

 

 

Now I'm just missing the file where all the table names are defind as o.Table & s.Table

 

I think (!)

at the end of the day the code will be good

Link to comment
Share on other sites

ok you could try it at least to see what the excel html file generates. Keep the last part (those header fields)

 

So the file would look like this. I added only the delivery address but once this works you could expand it. (Not sure of the excel format though you have to make sure the text format is good enough)

<?php 
require('includes/application_top.php');
$data='';
$order_excel_query = tep_db_query("the code query posted earlier");
while($order_query = tep_db_fetch_array($order_excel_query)) {
 $data .= $order_query['delivery_street_address'] . "\n";
}

header("Content-type: application/x-msdownload"); 
header("Content-Disposition: attachment; filename=othours.xls"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
print "$header\n$data"; 

?>

put that file in the catalog root and check for errors I just glued it together with what you had available. Finally I think the tep_db_..... wrappers are sufficient for it you shouldnt need additional my_sql functions

Link to comment
Share on other sites

Thanks for the help but it returnd an error

 

1064 - You have an error in your SQL syntax near 'op (o.orders_id = op.orders_id), orders_status s where o.orders_status = s.order' at line 1

 

select o.orders_id, o.delivery_street_address from orders o left join orders_products ot op (o.orders_id = op.orders_id), orders_status s where o.orders_status = s.orders_status_id and s.language_id = '1' and s.orders_status_id = 'pending' order by o.customer_name

 

[TEP STOP]

at the end of the day the code will be good

Link to comment
Share on other sites

yes had a couple of syntax errors so this time I checked the syntax at least

  $orders_excel_query = tep_db_query("select o.orders_id, o.delivery_street_address from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_PRODUCTS . " op on (o.orders_id = op.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = 'Pending' order by o.customers_name");

 while($order_query = tep_db_fetch_array($order_excel_query)) {
  $data .= $order_query['delivery_street_address'] . "\n";
 }

 

see if this goes any further

Link to comment
Share on other sites

I was still getting errors so I modify the Querry a bit

now I have

 

 $query_Recordset1 = "select o.orders_id, o.delivery_street_address from " . orders . " o left join " . orders_products . " op on (o.orders_id = op.orders_id), " . orders_status . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = 'Pending' order by o.customers_name";
$Recordset1 = mysql_query($query_Recordset1, $MaxInt) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

 

but the problem is that it dose not show any records.

The code that I'm using to display is

 

 <table border="0" cellpadding="10" cellspacing="0">
 <tr>
   <td>orders_id</td>
   <td>delivery_street_address</td>
   <td>orders_id</td>
   <td>products_model</td>
 </tr>
 <?php do { ?>
 <tr>
   <td><?php echo $row_Recordset1['o.orders_id']; ?></td>
   <td><?php echo $row_Recordset1['o.delivery_street_address']; ?></td>
   <td><?php echo $row_Recordset1['orders_id.orders_id']; ?></td>
   <td><?php echo $row_Recordset1['products_model']; ?></td>
 </tr>
 <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>

at the end of the day the code will be good

Link to comment
Share on other sites

Ok I been playing with it.

I'm still getting an Error

 

 

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

 

 

 
### This is the script for /catalog/admin/includes/functions/database.php 

function tep_db_fetch_array($db_query) {
   return mysql_fetch_array($db_query, MYSQL_ASSOC);
 }

at the end of the day the code will be good

Link to comment
Share on other sites

I dont get sql errors here. Also set the $header var to something for the time being. I tried on both admin and catalog sides

 

Here is what I tried:

<?php
 require('includes/application_top.php');
$data='';
$orders_excel_query = tep_db_query("select o.orders_id, o.delivery_street_address from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_PRODUCTS . " op on (o.orders_id = op.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = 'Pending' order by o.customers_name");

while($order_query = tep_db_fetch_array($order_excel_query)) {
 $data .= $order_query['delivery_street_address'] . "\n";
}
$header = 'someheader';
$data .= "\n" . 'Last Line print check' . "\n";

header("Content-type: application/x-msdownload"); 
header("Content-Disposition: attachment; filename=othours.xls"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 

print "$header\n$data"; 

?>

Link to comment
Share on other sites

do you have anything else on that php page becase I'm getting the same error

 

 

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

at the end of the day the code will be good

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...