예제 #1
0
 function view_pdf($id)
 {
     $preferences_q = query("SELECT settings FROM `" . $this->user['database'] . "`.account_settings WHERE group_id='" . $this->user['group'] . "' ORDER BY id DESC");
     $preferences_r = fetch($preferences_q);
     $this->smarty->assign('preferences', json_decode($preferences_r['settings'], 1));
     $shipment = new Shipment($id, $this->user);
     $this->smarty->assign('shipment', $shipment->toArray());
     $this->html['shipon_content'] = $this->smarty->fetch('history/view_pdf.tpl') . $this->get_pdf_footer($id);
 }
예제 #2
0
 public static function getRealTimeRates(ShippingRateCalculator $handler, Shipment $shipment)
 {
     $rates = new ShippingRateSet();
     $handler->setWeight($shipment->getChargeableWeight());
     $order = $shipment->order->get();
     // TODO: fix issue when address has zip and country data, but are missing city, user and record id!
     //             (now workround - get address id, if $address has no id, load address by id)
     if ($order->isMultiAddress->get()) {
         $address = $shipment->shippingAddress->get();
         $arr = $shipment->toArray();
     } else {
         $address = $order->shippingAddress->get();
         $arr = $order->toArray();
     }
     if (!$address->getID() && array_key_exists('shippingAddressID', $arr)) {
         $address = ActiveRecordModel::getInstanceByID('UserAddress', $arr['shippingAddressID'], true);
     }
     if (!$address) {
         return $rates;
     }
     $handler->setDestCountry($address->countryID->get());
     $handler->setDestState($address->state->get() ? $address->state->get()->code->get() : $address->stateName->get());
     $handler->setDestZip($address->postalCode->get());
     $handler->setDestCity($address->city->get());
     $config = $shipment->getApplication()->getConfig();
     $handler->setSourceCountry($config->get('STORE_COUNTRY'));
     $handler->setSourceZip($config->get('STORE_ZIP'));
     $handler->setSourceState($config->get('STORE_STATE'));
     foreach ($handler->getAllRates() as $k => $rate) {
         $newRate = new ShipmentDeliveryRate();
         $newRate->setApplication($shipment->getApplication());
         $newRate->setCost($rate->getCostAmount(), $rate->getCostCurrency());
         $newRate->setServiceName($rate->getServiceName());
         $newRate->setClassName($rate->getClassName());
         $newRate->setProviderName($rate->getProviderName());
         $newRate->setServiceId($rate->getClassName() . '_' . $k);
         $rates->add($newRate);
     }
     return $rates;
 }
예제 #3
0
 function init_with_data($id, $returnObj = 0)
 {
     $shipment = new Shipment($id, $this->user);
     $shipdata = $shipment->toArray();
     $preferences_q = query("SELECT settings FROM `" . $this->user['database'] . "`.account_settings WHERE group_id='" . $this->user['group'] . "'");
     $preferences_r = fetch($preferences_q);
     $preferences = json_decode($preferences_r['settings'], 1);
     if (isset($shipdata['pup_area']) && $shipdata['pup_area'] != '') {
         $preferences['shipon_settings_dad_pup_area'] = $shipdata['pup_area'];
     }
     if (isset($shipdata['del_area']) && $shipdata['del_area'] != '') {
         $preferences['shipon_settings_dad_del_area'] = $shipdata['del_area'];
     }
     $this->smarty->assign('preferences', $preferences);
     $view = $this->smarty->fetch('shipment/shipment.tpl');
     $view .= $this->load_tooltips('shipment', '0');
     $this->html['shipon_content'] = $view;
     foreach ($shipdata as $var => $val) {
         if ($var == 'id' || $var == 'timestamp' || $var == 'group_id' || $var == 'bill' || $var == 'pbnum' || $var == 'ext_id') {
             continue;
         }
         if (gettype($val) == "array" && $var == 'goods') {
             continue;
         }
         if (strpos($var, 'bill') !== false) {
             continue;
         }
         $key = 'shipon_' . $var;
         $this->return['inputs'][$key] = $val;
     }
     $this->return['inputs']['shipon_quote_no'] = '';
     $this->return['inputs']['shipon_del_date'] = date('m/d/Y');
     $goods = json_encode($shipdata['goods']);
     $html = "<script type='text/javascript'>window.goods_set_division = '" . $shipment->division . "'; window.goods_set_uom = '" . $shipment->uom . "'; window.is_recall = true; fill_goods_table('" . $goods . "');</script>";
     $this->html['shipon_content'] .= $html;
     if ($returnObj != 0) {
         return $shipment;
     }
 }
예제 #4
0
 public function order_save($indata, $api_key, $transaction_id)
 {
     date_default_timezone_set('Asia/Jakarta');
     $args = '';
     //$api_key = $this->get('key');
     //$transaction_id = $this->get('trx');
     if (is_null($api_key)) {
         $result = json_encode(array('status' => 'ERR:NOKEY', 'timestamp' => now()));
         return $result;
     } else {
         $app = \Prefs::get_key_info(trim($api_key));
         if ($app == false) {
             $result = json_encode(array('status' => 'ERR:INVALIDKEY', 'timestamp' => now()));
             return $result;
         } else {
             //$in = $this->input->post('transaction_detail');
             //$in = file_get_contents('php://input');
             $in = $indata;
             //print $in;
             $buyer_id = 1;
             $args = 'p=' . $in;
             $in = json_decode($in);
             //print "order input to save: \r\n";
             //print_r($in);
             $is_new = false;
             $in->phone = isset($in->phone) && $in->phone != '' ? \Prefs::normalphone($in->phone) : '';
             $in->mobile1 = isset($in->mobile1) && $in->mobile1 != '' ? \Prefs::normalphone($in->mobile1) : '';
             $in->mobile2 = isset($in->mobile2) && $in->mobile2 != '' ? \Prefs::normalphone($in->mobile2) : '';
             if (isset($in->buyer_id) && $in->buyer_id != '' && $in->buyer_id > 1) {
                 $buyer_id = $in->buyer_id;
                 $is_new = false;
             } else {
                 if ($in->email == '' || $in->email == '-' || !isset($in->email) || $in->email == 'noemail') {
                     $in->email = 'noemail';
                     $is_new = true;
                     if (trim($in->phone . $in->mobile1 . $in->mobile2) != '') {
                         if ($buyer = \Prefs::check_phone($in->phone, $in->mobile1, $in->mobile2)) {
                             $buyer_id = $buyer['id'];
                             $is_new = false;
                         }
                     }
                 } else {
                     if ($buyer = \Prefs::check_email($in->email)) {
                         $buyer_id = $buyer['id'];
                         $is_new = false;
                     } else {
                         if ($buyer = \Prefs::check_phone($in->phone, $in->mobile1, $in->mobile2)) {
                             $buyer_id = $buyer['id'];
                             $is_new = false;
                         }
                     }
                 }
             }
             if (isset($in->merchant_trans_id) && $in->merchant_trans_id != "") {
                 $transaction_id = $in->merchant_trans_id;
             }
             if ($is_new) {
                 $random_string = str_random(5);
                 $buyer_username = substr(strtolower(str_replace(' ', '', $in->buyer_name)), 0, 6) . $random_string;
                 $dataset['username'] = $buyer_username;
                 $dataset['email'] = $in->email;
                 $dataset['phone'] = $in->phone;
                 $dataset['mobile1'] = $in->mobile1;
                 $dataset['mobile2'] = $in->mobile2;
                 $dataset['fullname'] = $in->buyer_name;
                 $password = str_random(8);
                 $dataset['password'] = $password;
                 $dataset['created'] = date('Y-m-d H:i:s', time());
                 /*
                 $dataset['province'] =
                 $dataset['mobile']
                 */
                 $dataset['street'] = $in->shipping_address;
                 $dataset['district'] = $in->buyerdeliveryzone;
                 $dataset['city'] = $in->buyerdeliverycity;
                 $dataset['country'] = 'Indonesia';
                 $dataset['zip'] = isset($in->zip) ? $in->zip : '';
                 //$buyer_id = $this->register_buyer($dataset);
                 $is_new = true;
             }
             $order['created'] = date('Y-m-d H:i:s', time());
             $order['ordertime'] = date('Y-m-d H:i:s', time());
             $order['application_id'] = $app->id;
             $order['application_key'] = $app->key;
             $order['buyer_id'] = $buyer_id;
             $order['merchant_id'] = $app->merchant_id;
             $order['merchant_trans_id'] = trim($transaction_id);
             $order['buyer_name'] = $in->buyer_name;
             $order['recipient_name'] = $in->recipient_name;
             $order['email'] = $in->email;
             $order['directions'] = $in->directions;
             //$order['dir_lat'] = $in->dir_lat;
             //$order['dir_lon'] = $in->dir_lon;
             $order['buyerdeliverytime'] = $in->buyerdeliverytime;
             $order['buyerdeliveryslot'] = $in->buyerdeliveryslot;
             $order['buyerdeliveryzone'] = $in->buyerdeliveryzone;
             $order['buyerdeliverycity'] = is_null($in->buyerdeliverycity) || $in->buyerdeliverycity == '' ? 'Jakarta' : $in->buyerdeliverycity;
             $order['currency'] = $in->currency;
             $order['total_price'] = isset($in->total_price) ? $in->total_price : 0;
             $order['total_discount'] = isset($in->total_discount) ? $in->total_discount : 0;
             $order['total_tax'] = isset($in->total_tax) ? $in->total_tax : 0;
             if (in_array(strtoupper(trim($in->delivery_type)), array('COD', 'CCOD', 'PS', 'DO', 'DELIVERY ONLY'))) {
                 $in->delivery_type = 'COD';
             }
             $order['delivery_type'] = $in->delivery_type;
             if ($in->delivery_type == 'DO' || $in->delivery_type == 'Delivery Only') {
                 $order['cod_cost'] = 0;
             } else {
                 $order['cod_cost'] = \Prefs::get_cod_tariff($order['total_price'], $app->id);
             }
             $order['box_count'] = isset($in->box_count) ? $in->box_count : 1;
             $order['pending_count'] = isset($in->pending_count) ? $in->pending_count : 0;
             $order['delivery_note'] = isset($in->delivery_note) ? $in->delivery_note : '';
             $order['shipping_address'] = $in->shipping_address;
             $order['shipping_zip'] = $in->shipping_zip;
             $order['phone'] = $in->phone;
             $order['mobile1'] = $in->mobile1;
             $order['mobile2'] = $in->mobile2;
             $order['status'] = $in->status;
             $order['width'] = $in->width;
             $order['height'] = $in->height;
             $order['length'] = $in->length;
             $order['weight'] = isset($in->weight) ? $in->weight : 0;
             $order['actual_weight'] = isset($in->actual_weight) ? $in->actual_weight : 0;
             $order['delivery_cost'] = $order['weight'];
             $order['cod_bearer'] = isset($in->cod_bearer) ? $in->cod_bearer : 'merchant';
             $order['delivery_bearer'] = isset($in->delivery_bearer) ? $in->delivery_bearer : 'merchant';
             $order['cod_method'] = isset($in->cod_method) ? $in->cod_method : 'cash';
             $order['ccod_method'] = isset($in->ccod_method) ? $in->ccod_method : 'full';
             $order['fulfillment_code'] = isset($in->fulfillment_code) ? $in->fulfillment_code : '';
             // check out who is bearing the cost
             if ($order['delivery_type'] == 'COD' || $order['delivery_type'] == 'CCOD') {
                 if ($order['delivery_bearer'] == 'merchant') {
                     $dcost = 0;
                 } else {
                     $dcost = $order['delivery_cost'];
                 }
                 if ($order['cod_bearer'] == 'merchant') {
                     $codcost = 0;
                 } else {
                     $codcost = $order['cod_cost'];
                 }
                 $order['chargeable_amount'] = $order['total_price'] + $dcost + $codcost;
             } else {
                 if ($order['delivery_bearer'] == 'merchant') {
                     $dcost = 0;
                 } else {
                     $dcost = $order['delivery_cost'];
                 }
                 $order['chargeable_amount'] = $dcost;
             }
             if (isset($in->show_shop)) {
                 $order['show_shop'] = $in->show_shop;
             }
             if (isset($in->show_merchant)) {
                 $order['show_merchant'] = $in->show_merchant;
             }
             $order['is_api'] = 1;
             $ship = new \Shipment();
             foreach ($order as $k => $v) {
                 $ship->{$k} = $v;
             }
             $ship->save();
             $sequence = $ship->id;
             if (isset($in->delivery_id)) {
                 if (is_null($in->delivery_id) || $in->delivery_id == '') {
                     $delivery_id = \Prefs::get_delivery_id($sequence, $app->merchant_id);
                 } else {
                     $delivery_id = \Prefs::get_delivery_id($sequence, $app->merchant_id, $in->delivery_id);
                 }
             } else {
                 $delivery_id = \Prefs::get_delivery_id($sequence, $app->merchant_id);
             }
             $ship->delivery_id = $delivery_id;
             //print_r($ship);
             $ship->save();
             //die();
             if (isset($in->box_count)) {
                 $box_count = $in->box_count;
             } else {
                 $box_count = 1;
             }
             \Prefs::save_box($delivery_id, trim($transaction_id), $order['fulfillment_code'], $box_count);
             $nedata['fullname'] = $in->buyer_name;
             $nedata['merchant_trx_id'] = trim($transaction_id);
             $nedata['delivery_id'] = $delivery_id;
             $nedata['merchantname'] = $app->application_name;
             $nedata['app'] = $app;
             $order['delivery_id'] = $delivery_id;
             $buyer_id = \Prefs::save_buyer($order);
             /*
             $this->db->where('id',$sequence)->update($this->config->item('incoming_delivery_table'),array('delivery_id'=>$delivery_id));
             */
             /*
                 $this->table_tpl = array(
                     'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="dataTable">'
                 );
                 $this->table->set_template($this->table_tpl);
             
             
                 $this->table->set_heading(
                     'No.',
                     'Description',
                     'Quantity',
                     'Total'
                     ); // Setting headings for the table
             */
             $d = 0;
             $gt = 0;
             if ($in->trx_detail) {
                 $seq = 0;
                 foreach ($in->trx_detail as $it) {
                     $item = new \Deliverydetail();
                     $item->ordertime = $order['ordertime'];
                     $item->delivery_id = $delivery_id;
                     $item->unit_sequence = $seq++;
                     $item->unit_description = $it->unit_description;
                     $item->unit_price = $it->unit_price;
                     $item->unit_quantity = $it->unit_quantity;
                     $item->unit_total = $it->unit_total;
                     $item->unit_discount = $it->unit_discount;
                     $item->save();
                     /*
                     $this->table->add_row(
                         (int)$item['unit_sequence'] + 1,
                         $item['unit_description'],
                         $item['unit_quantity'],
                         $item['unit_total']
                     );
                     
                     $u_total = str_replace(array(',','.'), '', $item['unit_total']);
                     $u_discount = str_replace(array(',','.'), '', $item['unit_discount']);
                     $gt += (int)$u_total;
                     $d += (int)$u_discount;
                     */
                 }
                 $total = isset($in->total_price) && $in->total_price > 0 ? $in->total_price : 0;
                 $total = str_replace(array(',', '.'), '', $total);
                 $total = (int) $total;
                 $gt = $total < $gt ? $gt : $total;
                 $disc = isset($in->total_discount) ? $in->total_discount : 0;
                 $tax = isset($in->total_tax) ? $in->total_tax : 0;
                 $cod = isset($in->cod_cost) ? $in->cod_cost : 'Paid by merchant';
                 $disc = str_replace(array(',', '.'), '', $disc);
                 $tax = str_replace(array(',', '.'), '', $tax);
                 $cod = str_replace(array(',', '.'), '', $cod);
                 $disc = (int) $disc;
                 $tax = (int) $tax;
                 $cod = (int) $cod;
                 $chg = $gt - $disc + $tax + $cod;
                 /*
                 $this->table->add_row(
                     '',
                     '',
                     'Total Price',
                     number_format($gt,2,',','.')
                 );
                 
                 $this->table->add_row(
                     '',
                     '',
                     'Total Discount',
                     number_format($disc,2,',','.')
                 );
                 
                 $this->table->add_row(
                     '',
                     '',
                     'Total Tax',
                     number_format($tax,2,',','.')
                 );
                 
                 
                 if($cod == 0){
                     $this->table->add_row(
                         '',
                         '',
                         'COD Charges',
                         'Paid by Merchant'
                     );
                 }else{
                     $this->table->add_row(
                         '',
                         '',
                         'COD Charges',
                         number_format($cod,2,',','.')
                     );
                 }
                 
                 
                 $this->table->add_row(
                     '',
                     '',
                     'Total Charges',
                     number_format($chg,2,',','.')
                 );
                 
                 $nedata['detail'] = $this->table;
                 
                 
                 $result = json_encode(array('status'=>'OK:ORDERPOSTED','timestamp'=>now(),'delivery_id'=>$delivery_id,'buyer_id'=>$buyer_id));
                 */
                 //return $ship->toArray();
             } else {
                 //$nedata['detail'] = false;
                 //$result = json_encode(array('status'=>'OK:ORDERPOSTEDNODETAIL','timestamp'=>now(),'delivery_id'=>$delivery_id));
                 //return $order;
             }
             return $ship->toArray();
             //print_r($app);
             /*
             
                             if($app->notify_on_new_order == 1){
                                 send_notification('New Delivery Order - Jayon Express COD Service',$in->email,$app->cc_to,$app->reply_to,'order_submit',$nedata,null);
                             }
             
                             if($is_new == true){
                                 $edata['fullname'] = $dataset['fullname'];
                                 $edata['username'] = $buyer_username;
                                 $edata['password'] = $password;
                                 if($app->notify_on_new_member == 1 && $in->email != 'noemail'){
                                     send_notification('New Member Registration - Jayon Express COD Service',$in->email,null,null,'new_member',$edata,null);
                                 }
             
                             }*/
         }
     }
     //$this->log_access($api_key, __METHOD__ ,$result,$args);
 }
예제 #5
0
 function generate_pdf()
 {
     define('FPDF_FONTPATH', 'includes/pdf/font/');
     require_once 'includes/pdf/fpdf.php';
     require_once 'includes/pdf/fpdi.php';
     //get layout xml
     $pdf_xml = file_get_contents($this->user['folder'] . "/templates/pdf.xml");
     // if we state explicitly to show rates on waybill, then we use a different template
     if (isset($_REQUEST['show_rates']) && $_REQUEST['show_rates'] > 0) {
         $pdf_xml = file_get_contents($this->user['folder'] . "/templates/pdf_rates.xml");
     }
     $xml = new SimpleXMLElement($pdf_xml);
     $pdf = new AlphaPDI('P', 'pt', array($xml->pdf_pt_width, $xml->pdf_pt_height));
     $pdf->SetAutoPageBreak(false);
     $pdf->AddPage();
     $pdf->setSourceFile($this->user['folder'] . "/pdf/default.pdf");
     $tplIdx = $pdf->importPage(1);
     $pdf->useTemplate($tplIdx, 0, 0, 0, 0, false);
     // Check for external shipment data
     if (isset($_REQUEST['bill_id'])) {
         $req = array();
         $req['pbnum'] = $_REQUEST['bill_id'];
         $req['bill_to_code'] = $this->user['bill_to_code'];
         $integrate = new IntegrationHandler($this->user);
         $data = $integrate->process_request('order_details_request', $req);
         // Prevent order numbers from being inputted sequentially
         if ($data == false) {
             return false;
         }
         $data['sent'] = 1;
     } else {
         $shipment = new Shipment($_REQUEST['id'], $this->user);
         $data = $shipment->toArray();
     }
     $data['ship_name'] = clean_string($data['ship_name']);
     $data['ship_street1'] = clean_string($data['ship_street1']);
     $data['ship_street2'] = clean_string($data['ship_street2']);
     $data['ship_city'] = clean_string($data['ship_city']);
     $data['cons_name'] = clean_string($data['cons_name']);
     $data['cons_street1'] = clean_string($data['cons_street1']);
     $data['cons_street2'] = clean_string($data['cons_street2']);
     $data['cons_city'] = clean_string($data['cons_city']);
     $xml_data = $xml->LAYOUT->DATA->children();
     $radios_data = $xml->LAYOUT->RADIOS->children();
     $goods_data = $xml->LAYOUT->GOODS->column_data->children();
     $select_data = $xml->LAYOUT->SELECT->children();
     $custom_data = $xml->LAYOUT->CUSTOM->children();
     $pdf->SetFont('Helvetica', 'B', '12');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetAlpha(0.75);
     foreach ($xml_data as $entry) {
         if ($entry['size']) {
             $pdf->SetFontSize($entry['size']);
         }
         if (!$entry["multiline"]) {
             $pdf->SetXY($entry['x'], $entry['y']);
         }
         if (isset($entry["maxlength"]) && strlen($data[(string) $entry]) > $entry["maxlength"]) {
             $data[(string) $entry] = substr($data[(string) $entry], 0, (int) $entry["maxlength"]);
         }
         if ($entry["array"] && isset($data[(string) $entry['array']][(string) $entry])) {
             if ($entry["multiline"]) {
                 $pdf->MultiCell($entry['width'], $entry['height'], $data[(string) $entry['array']][(string) $entry]);
             } else {
                 if ($entry["letter_spacing"]) {
                     $pdf->CellFitSpaceForce($entry["width"], 0, $data[(string) $entry['array']][(string) $entry]);
                 } else {
                     $pdf->Write(0, strtoupper($data[(string) $entry['array']][(string) $entry]));
                 }
             }
         } elseif (isset($data[(string) $entry])) {
             if ($entry["multiline"]) {
                 if ($entry == 'pup_note' && $data[(string) $entry] != '') {
                     $data[(string) $entry] = "PU-" . $data[(string) $entry];
                 } else {
                     if ($entry == 'del_note' && $data[(string) $entry] != '') {
                         $data[(string) $entry] = "DL-" . $data[(string) $entry];
                     }
                 }
                 $textRaw = wordwrap($data[(string) $entry], 31, '\\n');
                 $wrapArr = explode('\\n', $textRaw);
                 $i = 0;
                 foreach ($wrapArr as $line) {
                     if ($i == 0) {
                         $pdf->SetXY($entry['x'], $entry['y']);
                     } else {
                         $pdf->SetXY($entry['x'], (int) $entry['y'] + $i * 10);
                     }
                     $pdf->MultiCell($entry['width'], 0, $line);
                     $i++;
                 }
             } else {
                 if ($entry["letter_spacing"]) {
                     if (isset($entry["type"]) && $entry["type"] == 'date') {
                         $dateArr = explode('/', $data[(string) $entry]);
                         $i = 0;
                         foreach ($dateArr as $line) {
                             if ($i == 1) {
                                 $pdf->SetXY($entry['x'], $entry['y']);
                             } else {
                                 if ($i == 0) {
                                     $pdf->SetXY((int) $entry['x'] + 30, $entry['y']);
                                 } else {
                                     $pdf->SetXY((int) $entry['x'] + $i * 30, $entry['y']);
                                 }
                             }
                             if ($i == 2) {
                                 $pdf->MultiCell($entry['width'], 0, substr($line, -2));
                             } else {
                                 $pdf->MultiCell($entry['width'], 0, $line);
                             }
                             $i++;
                         }
                     } else {
                         $pdf->CellFitSpaceForce($entry["width"], 0, $data[(string) $entry]);
                     }
                 } else {
                     $pdf->Write(0, strtoupper($data[(string) $entry]));
                 }
             }
         } else {
             $pdf->Write(0, strtoupper((string) $entry));
         }
     }
     foreach ($radios_data as $radio) {
         if (isset($data[(string) $radio->key])) {
             $radio_value = $data[(string) $radio->key];
             $offset_mult = (int) $radio->options->{$radio_value};
             if ($radio['orient'] == 'horizontal') {
                 $pdf->Rect($radio['x'] * $offset_mult, $radio['y'], $radio['size'], $radio['size'], 'F');
             } else {
                 if ($radio['orient'] == 'vertical') {
                     $pdf->Rect($radio['x'], $radio['y'] * $offset_mult, $radio['size'], $radio['size'], 'F');
                 }
             }
         }
     }
     foreach ($select_data as $select) {
         if ($select['size']) {
             $pdf->SetFontSize($select['size']);
         }
         $pdf->SetXY($select['x'], $select['y']);
         if ($select["array"] && isset($data[(string) $select['array']][(string) $select->key])) {
             $select_value = $data[(string) $select['array']][(string) $select->key];
         } else {
             if (isset($data[(string) $select->key])) {
                 $select_value = $data[(string) $select->key];
             }
         }
         if (isset($select_value)) {
             $pdf->Write(0, $select->options->{$select_value});
         }
     }
     $y = (int) $xml->LAYOUT->GOODS->table_start_y;
     if ($xml->LAYOUT->GOODS->size) {
         $pdf->SetFontSize($xml->LAYOUT->GOODS->size);
     }
     foreach ($data['goods'] as $good) {
         foreach ($goods_data as $column) {
             $pdf->SetXY((int) $column->offset, $y);
             $string = "";
             foreach ($column->keys->children() as $key) {
                 $key_name = (string) $key->getName();
                 switch ($key_name) {
                     case "entry":
                         if (($key == 'length' || $key == 'width' || $key == 'height' || $key == 'rate' || $key == 'total') && isset($good[(string) $key]) && $good[(string) $key] < 1) {
                             $string .= "-";
                         } elseif ($key == 'particulars' && !isset($_REQUEST['bill_id']) && isset($good[(string) $key]) && strlen($good[(string) $key]) > 0) {
                             $string .= " - " . $good[(string) $key];
                         } elseif ($key == 'pieceskids') {
                             $string .= $data['skids'] . '-' . $good['pieces'];
                         } else {
                             if (isset($good[(string) $key])) {
                                 $string .= $good[(string) $key] . " ";
                             }
                         }
                         break;
                     case "select":
                         $tag_name = $good[(string) $key->key];
                         if ($tag_name != 'COMMENT') {
                             $string .= strtoupper($key->options->{$tag_name}) . " ";
                         }
                         break;
                     case "static":
                         $string .= $key;
                         break;
                 }
             }
             $pdf->Write(0, $string);
         }
         $y += (int) $xml->LAYOUT->GOODS->line_height;
     }
     foreach ($custom_data as $entry) {
         $string = "";
         $pdf->SetXY($entry['x'], $entry['y']);
         if ($entry['size']) {
             $pdf->SetFontSize($entry['size']);
         }
         if ($entry['goods']) {
             foreach ($data['goods'] as $good) {
                 if ($entry['total']) {
                     $key_count = $entry->count();
                     $i = 0;
                     $j = 0;
                     foreach ($entry->children() as $key) {
                         $j = $j + (int) $good[(string) $key];
                         $i++;
                     }
                     $string = $string + $j;
                 } else {
                     $key_count = $entry->count();
                     $i = 0;
                     foreach ($entry->children() as $key) {
                         $string .= $good[(string) $key];
                         $i++;
                         if ($i < $key_count) {
                             $string .= $entry['key_seperator'];
                         }
                     }
                     $string .= $entry['data_seperator'];
                 }
             }
         } else {
             $key_count = $entry->count();
             $i = 0;
             foreach ($entry->children() as $key) {
                 if ($entry["array"] && isset($data[(string) $entry['array']][(string) $key])) {
                     $string .= $data[(string) $entry['array']][(string) $key];
                 } else {
                     $string .= $data[(string) $key];
                 }
                 $i++;
                 if ($i < $key_count) {
                     $string .= $entry['key_seperator'];
                 }
             }
         }
         if ($entry["multiline"]) {
             $pdf->MultiCell($entry['width'], $entry['height'], $string);
         } else {
             $pdf->Write(0, $string);
         }
     }
     if ($data['sent'] < 1) {
         // PENDING NOTICE
         $pdf->SetFillColor(0, 0, 0, 0.5);
         $pdf->Rect(0, 0, $xml->pdf_pt_width, $xml->pdf_pt_height, 'F');
         $pdf->SetFont('Helvetica', 'B', '14');
         $y_notice = ceil(intval($xml->pdf_pt_height / 2));
         $x_notice = intval($xml->pdf_pt_width) - 500;
         $pdf->SetTextColor(250, 245, 25);
         $pdf->SetXY($x_notice, $y_notice);
         $pdf->SetAlpha(1);
         $pdf->Write(0, "This shipment is still pending; click submit order to process.");
     }
     print $pdf->Output('', 'S');
 }