This MOD will enable a download link to a file that complies with the actual AUPost international and domestic CSV template
- OPEN Application > Modules > Invoices > Views > view.php and after Line 2 PASTE:
if (isset($_GET['exportcsv'])){
$fields = array('Send From Name', 'Send From Business Name', 'Send From Address Line 1', 'Send From Address Line 2', 'Send From Address Line 3', 'Send From Suburb', 'Send From State', 'Send From Postcode', 'Send From Phone Number', 'Send From Email Address', 'Deliver To Name', 'Deliver To MyPost Number', 'Deliver To Business Name', 'Deliver To Type Of Address', 'Deliver To Country', 'Deliver To Address Line 1', 'Deliver To Address Line 2', 'Deliver To Address Line 3', 'Deliver To Suburb', 'Deliver To State', 'Deliver To Postcode', 'Deliver To Phone Number', 'Deliver To Email Address', 'Item Packaging Type', 'Item Delivery Service', 'Item Description', 'Item Length', 'Item Width', 'Item Height', 'Item Weight', 'Item Dangerous Goods Flag', 'Signature On Delivery', 'Extra Cover Amount', 'Cannot Be Delivered - Return To Sender / Abandon Parcel', 'Customs Declaration - Commercial Value', 'Customs Declaration - Reason For Export', 'Customs Declaration - Why Are You Exporting These Goods', 'Export Declaration Number', 'SMS Tracking Notifications', 'SMS Tracking Mobile Phone', 'Parcel Contents - Description', 'Parcel Contents - Weight', 'Parcel Contents - Value', 'Parcel Contents - Quantity', 'Parcel Contents - Country Of Origin', 'Parcel Contents - HS Tariff', 'Parcel 2 Contents - Description', 'Parcel 2 Contents - Weight', 'Parcel 2 Contents - Value', 'Parcel 2 Contents - Quantity', 'Parcel 2 Contents - Country Of Origin', 'Parcel 2 Contents - HS Tariff', 'Parcel 3 Contents - Description', 'Parcel 3 Contents - Weight', 'Parcel 3 Contents - Value', 'Parcel 3 Contents - Quantity', 'Parcel 3 Contents - Country Of Origin', 'Parcel 3 Contents - HS Tariff', 'Parcel 4 Contents - Description', 'Parcel 4 Contents - Weight', 'Parcel 4 Contents - Value', 'Parcel 4 Contents - Quantity', 'Parcel 4 Contents - Country Of Origin', 'Parcel 4 Contents - HS Tariff', 'Send Tracking Notifications', 'Send Tracking Email', 'Additional Label Information 1', 'Delivery Instructions', 'Comments', 'ImporterĀ“s Reference Number', 'Licence Numbers', 'Certificate Numbers', 'Invoice Numbers');
// CSV column headings
$delimiter = ",";
$filename = "aupostcsv-orderid-".$invoice->invoice_number.".csv";
$f = fopen("php://output", "w");
fputcsv($f, $fields, $delimiter);
$array = array(
array("Send From Name"=>$invoice->user_name, "Send From Business Name"=>$invoice->user_name, "Send From Address Line 1"=>$invoice->user_address_1, "Send From Address Line 2"=>"", "Send From Address Line 3"=>"", "Send From Suburb"=>$invoice->user_city, "Send From State"=>$invoice->user_state, "Send From Postcode"=>$invoice->user_zip, "Send From Phone Number"=>htmlsc($invoice->user_phone), "Send From Email Address"=>$invoice->user_email, "Deliver To Name"=>$invoice->client_address_1, "Deliver To MyPost Number"=>"", "Deliver To Business Name"=>"", "Deliver To Type Of Address"=>"standard", "Deliver To Country"=>$invoice->user_country, "Deliver To Address Line 1"=>"$invoice->user_address_1", "Deliver To Address Line 2"=>"", "Deliver To Address Line 3"=>"", "Deliver To Suburb"=>$invoice->user_city, "Deliver To State"=>$invoice->user_state, "Deliver To Postcode"=>$invoice->user_zip, "Deliver To Phone Number"=>htmlsc($invoice->client_phone), "Deliver To Email Address"=>$invoice->client_email, "Item Packaging Type"=>"PKOWN", "Item Delivery Service"=>"standard", "Item Description"=>"Your Company Order", "Item Length"=>"59", "Item Width"=>"29", "Item Height"=>"19", "Item Weight"=>"10.6", "Item Dangerous Goods Flag"=>"false", "Signature On Delivery"=>"enabled", "Extra Cover Amount"=>$invoice->invoice_total, "Cannot Be Delivered - Return To Sender / Abandon Parcel"=>"Return To Sender", "Customs Declaration - Commercial Value"=>"Yes", "Customs Declaration - Reason For Export"=>"saleOfGoods", "Customs Declaration - Why Are You Exporting These Goods"=>"Sale", "Export Declaration Number"=>"", "SMS Tracking Notifications"=>"true", "SMS Tracking Mobile Phone"=>htmlsc($invoice->user_phone), "Parcel Contents - Description"=>"High Roof Rack Brackets Ozroofracks", "Parcel Contents - Weight"=>"10.6", "Parcel Contents - Value"=>$invoice->invoice_total, "Parcel Contents - Quantity"=>"1", "Parcel Contents - Country Of Origin"=>"Australia", "Parcel Contents - HS Tariff"=>"7326190000", "Parcel 2 Contents - Description"=>"", "Parcel 2 Contents - Weight"=>"", "Parcel 2 Contents - Value"=>"", "Parcel 2 Contents - Quantity"=>"", "Parcel 2 Contents - Country Of Origin"=>"", "Parcel 2 Contents - HS Tariff"=>"", "Parcel 3 Contents - Description"=>"", "Parcel 3 Contents - Weight"=>"", "Parcel 3 Contents - Value"=>"", "Parcel 3 Contents - Quantity"=>"", "Parcel 3 Contents - Country Of Origin"=>"", "Parcel 3 Contents - HS Tariff"=>"", "Parcel 4 Contents - Description"=>"", "Parcel 4 Contents - Weight"=>"", "Parcel 4 Contents - Value"=>"", "Parcel 4 Contents - Quantity"=>"", "Parcel 4 Contents - Country Of Origin"=>"", "Parcel 4 Contents - HS Tariff"=>"", "Send Tracking Notifications"=>"true", "Send Tracking Email"=>$invoice->user_email, "Additional Label Information 1"=>"", "Delivery Instructions"=>"Signature required", "Comments"=>"", "ImporterĀ“s Reference Number"=>"", "Licence Numbers"=>"", "Certificate Numbers"=>"", "Invoice Numbers"=>$invoice->invoice_number), // first row
);
foreach($array as $row){
// Adding data into CSV
$row_data = array($row['Send From Name'], $row['Send From Business Name'], $row['Send From Address Line 1'], $row['Send From Address Line 2'], $row['Send From Address Line 3'], $row['Send From Suburb'], $row['Send From State'], $row['Send From Postcode'], $row['Send From Phone Number'], $row['Send From Email Address'], $row['Deliver To Name'], $row['Deliver To MyPost Number'], $row['Deliver To Business Name'], $row['Deliver To Type Of Address'], $row['Deliver To Country'], $row['Deliver To Address Line 1'], $row['Deliver To Address Line 2'], $row['Deliver To Address Line 3'], $row['Deliver To Suburb'], $row['Deliver To State'], $row['Deliver To Postcode'], $row['Deliver To Phone Number'], $row['Deliver To Email Address'], $row['Item Packaging Type'], $row['Item Delivery Service'], $row['Item Description'], $row['Item Length'], $row['Item Width'], $row['Item Height'], $row['Item Weight'], $row['Item Dangerous Goods Flag'], $row['Signature On Delivery'], $row['Extra Cover Amount'], $row['Cannot Be Delivered - Return To Sender / Abandon Parcel'], $row['Customs Declaration - Commercial Value'], $row['Customs Declaration - Reason For Export'], $row['Customs Declaration - Why Are You Exporting These Goods'], $row['Export Declaration Number'], $row['SMS Tracking Notifications'], $row['SMS Tracking Mobile Phone'], $row['Parcel Contents - Description'], $row['Parcel Contents - Weight'], $row['Parcel Contents - Value'], $row['Parcel Contents - Quantity'], $row['Parcel Contents - Country Of Origin'], $row['Parcel Contents - HS Tariff'], $row['Parcel 2 Contents - Description'], $row['Parcel 2 Contents - Weight'], $row['Parcel 2 Contents - Value'], $row['Parcel 2 Contents - Quantity'], $row['Parcel 2 Contents - Country Of Origin'], $row['Parcel 2 Contents - HS Tariff'], $row['Parcel 3 Contents - Description'], $row['Parcel 3 Contents - Weight'], $row['Parcel 3 Contents - Value'], $row['Parcel 3 Contents - Quantity'], $row['Parcel 3 Contents - Country Of Origin'], $row['Parcel 3 Contents - HS Tariff'], $row['Parcel 4 Contents - Description'], $row['Parcel 4 Contents - Weight'], $row['Parcel 4 Contents - Value'], $row['Parcel 4 Contents - Quantity'], $row['Parcel 4 Contents - Country Of Origin'], $row['Parcel 4 Contents - HS Tariff'], $row['Send Tracking Notifications'], $row['Send Tracking Email'], $row['Additional Label Information 1'], $row['Delivery Instructions'], $row['Comments'], $row['ImporterĀ“s Reference Number'], $row['Licence Numbers'], $row['Certificate Numbers'], $row['Invoice Numbers']);
fputcsv($f, $row_data, $delimiter);
}
fclose($f);
// Telling browser to download file as CSV
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="'.$filename.'";');
exit();
}
- CHANGE the information above to suit your needs.
- Somewhere around LINE 500 add
<a href="<?php echo $_SERVER['PHP_SELF'].'?exportcsv'; ?>" class="btn btn-info">Export CSV</a>
- Save & Upload