PHP File Manager
Editing File: Shipping.php
<?php /* * Copyright (C) Wayne Purton-Smith - All Rights Reserved * Unauthorized copying of this file or removing this paragraph, via any medium is strictly prohibited * Proprietary and confidential * Written by Wayne Purton-Smith <waynepurtonsmith@hotmail.co.uk> February 2014 */ class Shipping extends CI_Model { public function generateAddressLabelOfOrder($order_id = 0) { if(($order_id = (int) $order_id) > 0 && ($order_info = $this->orders->get($order_id))) { return $this->generateAddressLabel(array ( 'name' => ($order_info->delivery_business) ? $order_info->delivery_business : format_display($order_info->delivery_first_name, $order_info->delivery_last_name), 'address_1' => $order_info->delivery_address_1, 'address_2' => $order_info->delivery_address_2, 'address_3' => $order_info->delivery_address_3, 'town' => $order_info->delivery_town, 'county' => $order_info->delivery_county, 'postcode' => $order_info->delivery_postcode )); } return ''; } public function generateAddressLabel($label_data = array()) { $origin_address_pos = 50; $origin_address = array_reverse($this->filter_address(array ( 'Origin', $this->config->item('company_name'), $this->config->item('company_address_1'), $this->config->item('company_address_2'), $this->config->item('company_address_3'), $this->config->item('company_town'), $this->config->item('company_county'), $this->config->item('company_postcode') ))); $destination_address_pos = 740; $destination_address = $this->filter_address($label_data); $zpl[] = '^XA'; $zpl[] = ''; $zpl[] = '^CFA,32'; $zpl[] = '^FWR'; foreach($destination_address as $i => $address_component) { $zpl[] = '^FO' . $destination_address_pos . ',50^FD' . $address_component . '^FS'; $destination_address_pos -= ($i === 0) ? 80 : 50; } $zpl[] = '^CFA,15'; $zpl[] = ''; $zpl[] = '^CFA,20'; $zpl[] = '^FWR'; foreach($origin_address as $address_component) { $zpl[] = '^FO' . $origin_address_pos . ',50^FD' . $address_component . '^FS'; $origin_address_pos += 30; } $zpl[] = '^CFA,15'; $zpl[] = ''; $zpl[] = '^XZ'; return implode("\n", $zpl); } private function filter_address($address_data = array()) { return array_values(array_filter($address_data, function($component) { return (remove_whitespace($component) != '') ? $component : false; })); } }
Cancel