heb een functie die gedeeltelijk de values retourneert. Heb alles nagecheckt doch vind de juiste script fout niet.Vreemde is dat de waarden wel worden geretourneerd van de database met de $order_description en niet werkt met de $order.Misschien de echo " niet juist geplaatst.
<?php
function draw_invoice($order_id) {
global $db,$db1;
$sql="SELECT
"._DB_PREFIX."orders.id AS order_id,
"._DB_PREFIX."orders.order_status,
"._DB_PREFIX."transactions.transaction_date,
"._DB_PREFIX."transactions.total_sum,
"._DB_PREFIX."transactions.sales_tax,
"._DB_PREFIX."transactions.shipping_charge,
"._DB_PREFIX."paymentInstruments.instrument_name,
"._DB_PREFIX."paymentTypes.payment_description,
"._DB_PREFIX."participantAddresses.*,
"._DB_PREFIX."participants.username,
"._DB_PREFIX."shipment_types.service AS ups_service,
CONCAT("._DB_PREFIX."participants.firstname,' ',"._DB_PREFIX."participants.lastname) AS participant_name
FROM "._DB_PREFIX."orders
INNER JOIN "._DB_PREFIX."participants ON "._DB_PREFIX."orders.participant_id="._DB_PREFIX."participants.id
INNER JOIN "._DB_PREFIX."participantAddresses ON "._DB_PREFIX."participants.id="._DB_PREFIX."participantAddresses.participant_id
INNER JOIN "._DB_PREFIX."transactions ON "._DB_PREFIX."orders.trans_id = "._DB_PREFIX."transactions.id
INNER JOIN "._DB_PREFIX."paymentTypes ON "._DB_PREFIX."transactions.payment_type = "._DB_PREFIX."paymentTypes.payment_type
INNER JOIN "._DB_PREFIX."shipment_types ON "._DB_PREFIX."orders.ups_service_id="._DB_PREFIX."shipment_types.ups_service_id
INNER JOIN "._DB_PREFIX."paymentInstruments ON "._DB_PREFIX."transactions.payment_instrument="._DB_PREFIX."paymentInstruments.id
WHERE "._DB_PREFIX."orders.id='".$order_id."'";
$db->query($sql);
$order=$db->fetchAssoc();
echo "<script>
function Clickheretoprint(){
var disp_setting='toolbar=yes,location=no,directories=yes,menubar=yes,';
disp_setting+='scrollbars=yes,width=650, height=600, left=100, top=0';
var content_vlue = document.getElementById('print_content').innerHTML;
var docprint=window.open('','',disp_setting);
docprint.document.open();
docprint.document.write('<html><head><title></title>');
docprint.document.write('</head><body onLoad=\"self.print()\"><center>');
docprint.document.write('<div align=\"left\">');
docprint.document.write(content_vlue);
docprint.document.write('</div>');
docprint.document.write('</center></body></html>');
docprint.document.close();
docprint.focus();
}
</script>";
echo "<br/>
<div style='border:1px solid #e2e0cb;' id='print_content' >
<br/>
<center><b>Invoice for order #".$order['order_id']."</b></center>
<table align=center class='default_dg_table' style='border:0px;' width='80%'>
<tr>
<td align='left'> </td>
<td align='right'><a style='cursor: pointer;' onclick='Clickheretoprint()'><img src='modules/datagrid/images/default/print_b.gif' onmouseover='this.src=\"modules/datagrid/images/default/print_r.gif\"' onmouseout='this.src=\"modules/datagrid/images/default/print_b.gif\"' alt='Printable View' title='Printable View'></a></td>
</tr>
</table>
<br/>
<table align=center class='default_dg_table' width='80%'>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Ship To:</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Bill To:</th>
</tr>
<tr>
<td class='default_dg_td dg_left'>
".$order['participant_name']."<br/>
".$order['shipping_address1']."<br/>
".$order['shipping_address2']."<br/>
".city($order['shipping_city'])."".($order['shipping_state']!=""?", ".$order['shipping_state']:"")."<br/>
".country($order['shipping_country'])."<br/>
".$order['shipping_postcode']."<br/>
</td>
<td class='default_dg_td dg_left'>
".$order['participant_name']."<br/>
".$order['billing_address1']."<br/>
".$order['billing_address2']."<br/>
".city($order['billing_city'])."".($order['billing_state']!=""?", ".$order['billing_state']:"")."<br/>
".country($order['billing_country'])."<br/>
".$order['billing_postcode']."<br/>
</td>
</tr>
</table>
<br/><br/>
<table align=center class='default_dg_table' width='80%'>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Order #</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Invoice Date</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Type</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Status</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Shipping</th>
</tr>
<tr>
<td class='default_dg_td dg_center'>".$order['order_id']."</td>
<td class='default_dg_td dg_left'>".date("d/m/Y",strtotime($order['transaction_date']))."</td>
<td class='default_dg_td dg_left'>".$order['payment_description']."</td>
<td class='default_dg_td dg_left'>".$order['order_status']."</td>
<td class='default_dg_td dg_left'>".$order['ups_service']."</td>
</tr>
</table><br/><br/>";
$sql = "SELECT
"._DB_PREFIX."orderDescription.id,
"._DB_PREFIX."products.item_code,
"._DB_PREFIX."products.product_name,
"._DB_PREFIX."products.ibo_price,
"._DB_PREFIX."products.bv_points,
"._DB_PREFIX."orderDescription.quantity,
"._DB_PREFIX."orderDescription.product_price,
("._DB_PREFIX."orderDescription.product_price * "._DB_PREFIX."orderDescription.quantity) as total_ibo_price,
("._DB_PREFIX."orderDescription.product_bv * "._DB_PREFIX."orderDescription.quantity) as total_bv_points,
"._DB_PREFIX."orderDescription.order_id,
"._DB_PREFIX."orderDescription.product_id
FROM "._DB_PREFIX."orderDescription
INNER JOIN "._DB_PREFIX."products ON "._DB_PREFIX."orderDescription.product_id = "._DB_PREFIX."products.id
WHERE "._DB_PREFIX."orderDescription.order_id = '".$order_id."'";
$db1->query($sql);
if ($db1->numRows()>0) {
echo "
<table align=center class='default_dg_table' width='80%'>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Item #</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Description</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Price</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Quantity</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Totals</th>
</tr>";
$total=0;
while($order_description=$db1->fetchAssoc()) {
$total +=$order_description['total_ibo_price'];
echo "<tr>
<td class='default_dg_td dg_center'>".$order_description['item_code']."</td>
<td class='default_dg_td dg_left'>".$order_description['product_name']."</td>
<td class='default_dg_td dg_left'>€".$order_description['product_price']."</td>
<td class='default_dg_td dg_center'>".$order_description['quantity']."</td>
<td class='default_dg_td dg_left'>€".$order_description['total_ibo_price']."</td>
</tr>";
}
echo "</table>";
}
echo "<br/><br/>
<table align=center border=0 width='80%'>
<tr>
<td width='60%' valign='top'>
<table class='default_dg_table' width='100%'>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Payment Date</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Payment Type</th>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Amount</th>
</tr>
<tr>
<td class='default_dg_td dg_left'>".$order['transaction_date']."</td>
<td class='default_dg_td dg_left'>".$order['instrument_name']."</td>
<td class='default_dg_td dg_left'>€".$order['total_sum']."</td>
</tr>
</table>
</td>
<td width='40%' align='left' valign='top'>
<table class='default_dg_table' width='100%'>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Sub Total</th>
<td class='default_dg_td dg_left'>€".$total."</td>
</tr>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Tax Total</th>
<td class='default_dg_td dg_left'>€".$order['sales_tax']."</td>
</tr>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Shipping Total</th>
<td class='default_dg_td dg_left'>€".$order['shipping_charge']."</td>
</tr>
<tr>
<th style='background-color:#e2e0cb;' class='default_dg_th dg_left'>Grand Total</th>
<td class='default_dg_td dg_left'>€".$order['total_sum']."</td>
</tr>
</table>
</td>
</tr>
</table>
";
//<div style='clear:both;height:10px;'></div>";
echo "<br/><br/></div><br/><br/>";
}
?>
1.385 views