Codice: Seleziona tutto
$order = new order($oIDn);
$address = $order->customer;
$testo .= "<CustomerCode>".$address['id']."</CustomerCode>";
Moderatore: mod Generali
Codice: Seleziona tutto
$order = new order($oIDn);
$address = $order->customer;
$testo .= "<CustomerCode>".$address['id']."</CustomerCode>";
Codice: Seleziona tutto
<?php
// Esportazione Clienti da Oscommerce per Danea EasyFatt
// Realizzato da tReAle il 20 sett. 2008
function convStr($string){
$caratteri = array("¡", "°");
$string = str_replace($caratteri, " ", $string);
return $string;
}
require('includes/application_top.php');
include('includes/classes/order.php');
require(DIR_WS_CLASSES . 'currencies.php');
if(isset($HTTP_GET_VARS['oID']))
{
$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
$filename ="scarico_ordini_".date('d-m-Y').".xml";
/* CICLO PER OGNI ORDINE O EVENTUALMENTE PER IL SINGOLO ORDINE */
$testo ="";
$testo .="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<EasyfattDocuments AppVersion=\"2\">
<Documents>";
$i=0;
while($i < count($oID))
{
if (count($oID) == 1)
{
if (is_array($oID))
$oIDn = $oID[0];
else
$oIDn = $oID;
}else{
$oIDn = $oID[$i];
}
$order = new order($oIDn);
$address = $order->customer;
$billing = $order->billing;
$delivery = $order->delivery;
$order_total_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = ".((int)$oID)." and class = 'ot_total'");
$order_total = tep_db_fetch_array($order_total_query);
$order_shipping_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = ".((int)$oID)." and class = 'ot_shipping'");
$order_shipping = tep_db_fetch_array($order_shipping_query);
$order_fixed_payment_chg_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = ".((int)$oID)." and class = 'ot_fixed_payment_chg'");
$order_fixed_payment_chg = tep_db_fetch_array($order_fixed_payment_chg_query);
$testo .= "<Document>";
$testo .= "<DocumentType>C</DocumentType>";// C: Ordine cliente (tipo predefinito)
$testo .= "<CustomerCode>".convStr($address['id'])."</CustomerCode>";
$testo .= "<CustomerWebLogin>".str_replace(" ","",trim($order->customer['email_address']))."</CustomerWebLogin>";
$testo .= "<CustomerName>".convStr($billing['name'])."</CustomerName>";
$testo .= "<CustomerAddress>".convStr($billing['street_address'])."</CustomerAddress>";
$testo .= "<CustomerPostcode>".$billing['postcode']."</CustomerPostcode>";
$testo .= "<CustomerCity>".convStr($billing['city'])."</CustomerCity>";
$testo .= "<CustomerProvince>".$billing['state']."</CustomerProvince>";
$testo .= "<CustomerCountry>".$billing['country']."</CustomerCountry>";
$testo .= "<CustomerFiscalCode>".$billing['cf']."</CustomerFiscalCode>";
$testo .= "<CustomerVatCode>".$billing['piva']."</CustomerVatCode>";
$testo .= "<CustomerTel>".str_replace(" ","", trim($address['telephone']))."</CustomerTel>";
$testo .= "<CustomerEmail>".$address['email_address']."</CustomerEmail>";
$testo .= "<DeliveryName>".$delivery['name']."</DeliveryName>";
$testo .= "<DeliveryAddress>".$delivery['street_address']."</DeliveryAddress>";
$testo .= "<DeliveryPostcode>".$delivery['postcode']."</DeliveryPostcode>";
$testo .= "<DeliveryCity>".$delivery['city']."</DeliveryCity>";
$testo .= "<DeliveryProvince>".$delivery['state']."</DeliveryProvince>";
$testo .= "<DeliveryCountry>".$delivery['country']."</DeliveryCountry>";
$testo .= "<CostDescription>Trasporto</CostDescription>";
$testo .= "<CostAmount>".(($order_shipping['value']/1.2)+($order_fixed_payment_chg['value']/1.2)) ."</CostAmount>";
$date = substr($order->info['date_purchased'], 0, 10);
$testo .= "<Date>".$date."</Date>";
$testo .= "<Number>".$oIDn."</Number>";
$n = sizeof($order->totals);
$n--;
$testo .= "<Total>" .$order_total['value'] . "</Total>";
// PAGAMENTO
$payment = strip_tags($order->info['payment_method']);
$payments = "";
switch (trim($payment)) {
case (substr(trim($payment),0,6) == "PayPal"):
$payments = "Pagato";
break;
case "Bonifico Bancario":
$payments = "Bonifico anticipato";
break;
case "Pagamento alla consegna":
$payments = "Contrassegno";
break;
case "Ricarica PostePay":
$payments = "Ricarica PostePay";
break;
}
//----------------
$testo .= "<PaymentName>" . $payments . "</PaymentName>";
$testo .= "<PaymentBank></PaymentBank>";
$testo .= "<InternalComment>Nessun Acconto</InternalComment>";
$testo .= "<CustomField2>" . date("d/m/Y"). "</CustomField2>";
$testo .= "<SalesAgent>no</SalesAgent>";
// lista articoli
for ($x=0, $n=sizeof($order->products); $x<$n; $x++) {
$testo .= "<Row>";
$testo .= "<Code>".$order->products[$x]['model']."</Code>";
$testo .= "<Description>".$order->products[$x]['name']."</Description>";
$testo .= "<Qty>".$order->products[$x]['qty']."</Qty>";
$testo .= "<Um>pz</Um>";
$testo .= "<Price>".($order->products[$x]['final_price']/1.2)."</Price>";
$testo .= "<Discounts>0%</Discounts>";
$testo .= "<VatCode>20</VatCode>";
$testo .= "</Row>";
}
$testo .= "</Document>";
$i++;
}
$testo .="</Documents>
</EasyfattDocuments>";
/* da usare per eventuale scrittura su file
$fp = fopen($filename, 'w');
fwrite($fp, $testo);
fclose($fp);
*/
header("Content-disposition: filename=".$filename);
header("Content-type: application/octetstream; charset=utf-8");
header("Pragma: no-cache");
header("Expires: 0");
echo $testo;
}
else
{
echo 'Ordine non specificato!';
exit;
}
?>