setFacturiIdExtern($order_id); $order->setFacturiNumar($order_id); $order->setFacturiData(date('Y-m-d H:i:s', strtotime($created_date))); $order->setFacturiMoneda($currency); $order->setFacturiClientId($customer_id); $order->setFacturiNumeClient($this->getPaymentName($customer_first_name, $customer_last_name, $billing_address_first_name, $billing_address_last_name, $billing_company, $company)); $order->setFacturiTipPersoana(!empty($fiscal_code) ? 'juridica' : 'fizica'); $order->setFacturiCodfClient($fiscal_code); $order->setFacturiNrregClient($nr_inreg); $order->setFacturiEmailClient($email); $order->setFacturiSediuClient($this->getPaymentAddress($billing_address_address1, $billing_address_address2, $billing_address_zip)); $order->setFacturiOrasClient($this->stripSpecialChars($billing_address_city)); $order->setFacturiJudetClient($this->stripSpecialChars($billing_address_province)); $order->setFacturiTelClient($billing_address_phone); $order->setFacturiNumeLivrare($this->getShippingName($shipping_address_first_name, $shipping_address_last_name)); $order->setFacturiClientiAdresaLivrare($this->getShippingAddress($shipping_address_address1, $shipping_address_address2, $shipping_address_zip)); $order->setFacturiCodpostalLivrare($shipping_address_zip); $order->setFacturiOrasLivrare($this->stripSpecialChars($shipping_address_city)); $order->setFacturiJudetLivrare($this->stripSpecialChars($shipping_address_province)); $order->setFacturiTelLivrare($this->getShippingPhone($shipping_address_phone, $billing_address_phone)); $order->setFacturiStatus($order_status); $order->setFacturiModPlata($payment_method); $order->setFacturiObs($this->getObs($order_id, $shipping_address_first_name, $shipping_address_last_name, $shipping_address_phone, $billing_address_phone, $comments)); return $order; } protected function getPaymentName($customer_first_name, $customer_last_name, $billing_address_first_name, $billing_address_last_name, $billing_company, $company) { $name = $customer_first_name . ' ' . $customer_last_name; $billing_name = $billing_address_first_name . ' ' . $billing_address_last_name; $billing_name = trim($billing_name); if(!empty($billing_name)) { $name = $billing_name; } if(!empty($billing_company)) { $name = $billing_company; } if(!empty($company)) { $name = $company; } return $this->stripSpecialChars($name); } protected function getPaymentAddress($billing_address_address1, $billing_address_address2, $billing_address_zip) { $address = array(); $address[] = $billing_address_address1 . ' ' . $billing_address_address2; $address[] = $billing_address_zip; return $this->stripSpecialChars(implode(' ', $address)); } protected function getShippingAddress($shipping_address_address1, $shipping_address_address2, $shipping_address_zip) { $address = array(); $address[] = $shipping_address_address1; $address[] = $shipping_address_address2; $address[] = $shipping_address_zip; return $this->stripSpecialChars(implode(' ', $address)); } protected function getShippingName($shipping_address_first_name, $shipping_address_last_name) { $result = $this->stripSpecialChars($shipping_address_first_name . ' ' . $shipping_address_last_name); return $result; } protected function getShippingPhone($shipping_address_phone, $billing_address_phone) { if(!empty($shipping_address_phone)) { return $shipping_address_phone; } else { return $billing_address_phone; } } protected function getObs($order_id, $shipping_address_first_name, $shipping_address_last_name, $shipping_address_phone, $billing_address_phone, $comments) { $output = array(); $output[] = 'Comanda nr: ' . $order_id; $output[] = 'Nume si prenume la livrare: ' . $this->getShippingName($shipping_address_first_name, $shipping_address_last_name); $output[] = 'Telefon la livrare: ' . $this->getShippingPhone($shipping_address_phone, $billing_address_phone); if(empty($comments)) { $comments = '-'; } $output[] = 'Comentarii la comanda: ' . $this->stripSpecialChars($comments); return implode('; ', $output); } }