Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Exel


MoisesZaragoza

Recommended Posts

Posted

Hi I'm doing a new page that exports to exel document.

 

and it works really well.

 

But I have to make some minor adjustments

 

I need to get all the pending produts, Now I'm getting one ID

 

<?php
 require('includes/application_top.php');
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
 $orders_statuses = array();
 $orders_status_array = array();
 $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
#  $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");

 if (($action == 'edit') && isset($HTTP_GET_VARS['oID'])) {
   $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
   $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
   $order_exists = true; 
 }

include(DIR_WS_CLASSES . 'order.php');
?>

<html>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<table border="1" width="100%" cellspacing="10" cellpadding="10">



<?php	

   $order = new order($oID);
?>
 <table border="3" width="100%" cellspacing="10" cellpadding="10" >
         <tr class="dataTableHeadingRow">
           <td class="dataTableHeadingContent" colspan="2"><?php echo PRODUCTS; ?></td>
           <td class="dataTableHeadingContent"><?php echo PRODUCTS_MODEL; ?></td>
           <td class="dataTableHeadingContent" align="right"><?php echo TOTAL; ?></td>

         </tr>
<?php
   for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
     echo '          <tr class="dataTableRow">' . "\n" .
          '            <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . '</td>' . "\n" .
          '            <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];

     if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
       for ($j = 0, $k = sizeof($order->products[$i]['attributes']); $j < $k; $j++) {
         echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
         if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
         echo '</i></small></nobr>';
       }
     }

     echo '            </td>' . "\n" .
          '            <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n" .
          '            <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
     echo '          </tr>' . "\n";
   }
?>
         <tr>
           <td align="right" colspan="8">
	 <table border="0" cellspacing="0" cellpadding="0">
<?php
   for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
     echo '              <tr>' . "\n" .
          '                <td align="right" class="smallText">' . $order->totals[$i]['title'] . '</td>' . "\n" .
          '                <td align="right" class="smallText">' . $order->totals[$i]['text'] . '</td>' . "\n" .
          '              </tr>' . "\n";
   }
?>
           </table> 	 
	 </td>
         </tr>
       </table>            


 


</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

at the end of the day the code will be good

Posted

you will have to do something with the $order instance before using it. The constructor leaves the arrays empty. For example you could call

 

$order->query($oID);

 

to fill in the arrays after you instantiated with the $order

Archived

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

×
×
  • Create New...