MacBook Air

27 01 2008

Minc***!!! Sono rimasto di stucco quando l’ho visto… Non ci sono parole per descriverlo…

MakBook Air

Guardate il video



osCommerce: Ordine in excel

27 01 2008

Rieccomi qua dopo tanto tempo, ma con la voglia di ricominciare a postare sul blog…

In questo fine settimana mi sono imbattuto in osCommerce, uno straordinario CMS per l’e-commerce:

From Wikipedia, the free encyclopedia

osCommerce (“open source Commerce”) is an e-commerce and online store-management software program. It can be used on any web server that has PHP and MySQL installed. It is available as free software under the GNU General Public License.

Lo scopo del mio interesse è stato quello di creare una semplice applicazione che mi permettesse di trasformare un ordine in formato excel…

Ecco come ho fatto:

Prima di tutto ho creato un nuovo file excel.php che verrà salvato nella cartella [oscommerce-dir]->admin. Il contenuto del file sarà il seguente:

<?php
require(’includes/application_top.php’);
require(DIR_WS_CLASSES . ‘currencies.php’);
$filename=”sheet.xls”;
header (”Content-Type: application/vnd.ms-excel”);
header (”Content-Disposition: inline; filename=$filename”);
if(@$_GET["excel"]){
$queryconn1 = tep_db_query(”select *
from orders_products
where orders_id=’”.$_GET["excel"].”‘”);
$row1 = tep_db_fetch_array($queryconn1);
$queryconn2 = tep_db_query(”select *
from orders
where orders_id=’”.$_GET["excel"].”‘”);
$row2 = tep_db_fetch_array($queryconn2);
}
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html lang=it><head>
<title>Titolo</title></head>
<body>
<table border=”1″>
<tr>
<td>ID</td>
<td>Customer ID</td>
<td>Customer Name</td>
<td>Customer Company</td>
<td>Customer Address</td>
<td>Customer Suburb</td>
<td>Customer City</td>
<td>Customer Postcode</td>
<td>Customer Stato</td>
<td>Customer Country</td>
<td>Customer Telephone</td>
<td>Customer Email</td>
<td>Customer Format ID</td>
</tr>
<tr>
<td><? echo $row2['orders_id']?></td>
<td><? echo $row2['customers_id']?></td>
<td><? echo $row2['customers_name']?></td>
<td><? echo $row2['customers_company']?></td>
<td><? echo $row2['customers_street_address']?></td>
<td><? echo $row2['customers_suburb']?></td>
<td><? echo $row2['customers_city']?></td>
<td><? echo $row2['customers_postcode']?></td>
<td><? echo $row2['customers_state']?></td>
<td><? echo $row2['customers_country']?></td>
<td><? echo $row2['customers_telephone']?></td>
<td><? echo $row2['customers_email_address']?></td>
<td><? echo $row2['customers_address_format_id']?></td>
</tr>
<tr>

Viene sfruttata la capacità di excel di poter visualizzare i file html strutturati in un certo modo. A questo punto basta inserire la seguente linea:

<a href="excel.php?excel=<? echo $oID?>" TARGET="_blank">Crea il file Excel</a>

nella zona che più vi piace del file [oscommerce-dir]->admin->orders.php ed il gioco è fatto…

Con la versione di osCommerce 2.2 RC2 funziona bene, per le altre funzioni non vi so dire perché non so se il database è diverso, comunque per qualsiasi problema o miglioramento contattatemi.

Ciao






Please visit WP-Admin > Options > Snap Shots and enter the Snap Shots key. How to find your key