/* Decoded by unphp.net */ class ControllerExtensionModuleBookurierAWB extends Controller{ private $error = array(); public function index() { $this->language->load('extension/module/bookurierawb'); $this->load->model('extension/module/bookurierawb'); $this->document->setTitle($this->language->get('heading_title')); $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $this->load->model('setting/setting'); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_setting_setting->editSetting('module_bookurierawb', $this->request->post); $this->model_extension_module_bookurierawb->install(); $this->session->data['success'] = "Datele au fost salvate."; // echo "
";
			// print_r($this->request->post);
			// echo "
"; // exit; $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true)); } $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) ); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extension'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true) ); if (!isset($this->request->get['module_id'])) { $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title'), 'href' => $this->url->link('extension/module/bookurierawb', 'user_token=' . $this->session->data['user_token'], true) ); } else { $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title'), 'href' => $this->url->link('extension/module/bookurierawb', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true) ); } if (!isset($this->request->get['module_id'])) { $data['action'] = $this->url->link('extension/module/bookurierawb', 'user_token=' . $this->session->data['user_token'], true); } else { $data['action'] = $this->url->link('extension/module/bookurierawb', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'], true); } $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module', true); $data['heading_title'] = $this->language->get('heading_title'); if (isset($this->error['module_bookurierawb_nume_client'])) { $data['error_module_bookurierawb_nume_client'] = $this->error['module_bookurierawb_nume_client']; } else { $data['error_module_bookurierawb_nume_client'] = ''; } if (isset($this->error['module_bookurierawb_client_id'])) { $data['error_module_bookurierawb_client_id'] = $this->error['module_bookurierawb_client_id']; } else { $data['error_module_bookurierawb_client_id'] = ''; } if (isset($this->error['module_bookurierawb_parola_client'])) { $data['error_module_bookurierawb_parola_client'] = $this->error['module_bookurierawb_parola_client']; } else { $data['error_module_bookurierawb_parola_client'] = ''; } if (isset($this->request->post['module_bookurierawb_nume_client'])) { $data['module_bookurierawb_nume_client'] = $this->request->post['module_bookurierawb_nume_client']; } else { $data['module_bookurierawb_nume_client'] = $this->config->get('module_bookurierawb_nume_client'); } if (isset($this->request->post['module_bookurierawb_client_id'])) { $data['module_bookurierawb_client_id'] = $this->request->post['module_bookurierawb_client_id']; } else { $data['module_bookurierawb_client_id'] = $this->config->get('module_bookurierawb_client_id'); } if (isset($this->request->post['module_bookurierawb_parola_client'])) { $data['module_bookurierawb_parola_client'] = $this->request->post['module_bookurierawb_parola_client']; } else { $data['module_bookurierawb_parola_client'] = $this->config->get('module_bookurierawb_parola_client'); } if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } if (isset($this->request->post['module_bookurierawbawb_status'])) { $data['module_bookurierawbawb_status'] = $this->request->post['module_bookurierawb_status']; } else { $data['module_bookurierawb_status'] = $this->config->get('module_bookurierawb_status'); } $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); $this->response->setOutput($this->load->view('extension/module/bookurierawb', $data)); } protected function validate() { if (!$this->user->hasPermission('modify', 'extension/module/bookurierawb')) { $this->error['warning'] = $this->language->get('error_permission'); } return !$this->error; } public function test_connection() { $json = array(); $username = $this->config->get('module_bookurierawb_nume_client'); $userpwd = $this->config->get('module_bookurierawb_parola_client'); $clientid = $this->config->get('module_bookurierawb_client_id'); $emagmp_api_call->execute(); if ($emagmp_api_call->save()) { if ($emagmp_api_call->status == 'error') { $json['error'] = 'Connection could not be established! The API function returned the following error: '.$emagmp_api_call->message_in; } elseif ($emagmp_api_call->status == 'success') { $json['success'] = $this->language->get('text_connection_ok'); } else { $json['error'] = 'The API call could not be executed!'; } } else { $json['error'] = 'Something is terribly wrong! Could not save the API call in the database!!!'; } $this->response->setOutput(json_encode($json)); } public function install(){ //INSTALARE_BOOKURIERAWB// } public function uninstall() { //DEZINSTALARE_BOOKURIERAWB// } public function xmlencode($data) { $table = array('“'=>''', '”'=>''', '‘'=>""", '’'=>""", '•'=>'*', '—'=>'-', '–'=>'-', '¿'=>'?', '¡'=>'!', '°'=>' deg. ','÷'=>' / ', '×'=>'X', '±'=>'+/-',' '=> ' ', '"'=> '"', "'"=> ''', '<'=> '<', '>'=> '>', " "=> ' ', " "=> ' '); $data = strip_tags(html_entity_decode($data)); $data = strtr($data, $table); $data = preg_replace('/&#?[a-z0-9]+;/i',' ',$data); $data = preg_replace('/\s{2,}/i', ' ', $data ); $table2 = array( 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'Ã¥'=>'a', 'æ'=>'a','ă'=>'a', 'Þ'=>'B', 'þ'=>'b', 'ß'=>'Ss', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'œ'=>'o', 'ð'=>'o', 'Å¡'=>'s','ș'=>'s','ț'=>'t', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ü'=>'u', 'ý'=>'y', 'ÿ'=>'y', 'ž'=>'z', 'ž'=>'z', '©'=>'(c)', '®'=>'(R)' ); $data = strtr($data, $table2); $data = preg_replace('/[^( -)]*/','', $data ); $data = utf8_encode($data); $data = htmlentities($data); return $data; } public function addOrderHistory($awb, $order_id, $order_status_id, $message = '', $notify = false, $customeremail, $storename){ $subject = $storename . " - Order Update " . $order_id; $message = "Comanda a fost procesata si ridicata de catre curier. Livrarea se va efectua in 24-48 de ore (exceptand weekendul). Pentru informatii legate de livrare, folositi numerele de telefon de mai jos sau urmariti link-ul AWB: " . $awb . "." . " "; $message .= "Dispecerat Bucuresti:". " "; $message .= "Telefon: 031.425.3254 / 0758.73.0043 / 031.425.3255" . " "; $message .= "Dispecerat Tara:" . " "; $message .= "Telefon: 0314.379.144 / 0756.076.784 / 0770.889.762 / 0770.701.794"; $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int)$order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (isset($notify) ? (int)$notify : 0) . "', comment = '" . $this->db->escape(strip_tags($message)) . "', date_added = NOW()"); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($customeremail); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($storename, ENT_QUOTES, 'UTF-8')); $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); $mail->setHtml(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } public function getawb(){ $url = 'http://www.bookurier.ro/colete/serv/add_cmd.php'; $username = $this->config->get('module_bookurierawb_nume_client'); $userpwd = $this->config->get('module_bookurierawb_parola_client'); $clientid = $this->config->get('module_bookurierawb_client_id'); /*echo "
";

		print_r($this->config); exit;*/

		//TODO
		$this->load->model('sale/order');

		if (isset($_GET['oid'])) {				

				$order_id=$this->db->escape($_GET['oid']);	
				$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order`  WHERE  order_id = ".(int)$order_id );		

				if ($query->num_rows) {

					$data = $query->row;
					$serviciu_id = ((int)$data['module_zone_id'] == 2688) ? 1 : 9;
					
					//echo "
";
					//print_r($data); exit;

					$msg="".$clientid."".$data['order_id']."".$data['module_firstname']." ".$data['module_lastname']."".$data['telephone']."".$data['email']."".$data['module_country']."".$data['module_city']."".$data['module_postcode']."".$data['module_zone']."".$data['module_address_1'].' '.$data['module_address_2']."".$serviciu_id."11".$data['total']."00$note";
					//echo $msg;
				
					$fields = array(
						'userid' => urlencode($username),
						'pwd' => urlencode($userpwd),
						'msg' => urlencode($msg)			
					);

					$fields_string='';
					foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
					rtrim($fields_string, '&');

					//open connection
					$ch = curl_init();

					//set the url, number of POST vars, POST data
					curl_setopt($ch,CURLOPT_URL, $url);
					curl_setopt($ch,CURLOPT_POST, count($fields));
					curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

					//execute post
					$result = curl_exec($ch);
					
					//close connection
					curl_close($ch);
					if(strlen($result)>6) {
					// obtine AWB
						$_SESSION['nr_awb'] = $result;
						// codul care aduce AWB-ul
						$awb = $_SESSION['nr_awb'];
						
							// salveaza AWB pt ORDER_ID daca avem ORDER_ID si AWB
							$this->db->query("UPDATE `".DB_PREFIX."order` SET book_AWB='". $this->db->escape($awb)."' WHERE order_id='". $this->db->escape($_GET['oid'])."'");
							$this->session->data['success'] = 'S-a generat AWB-ul nr.'.$awb;
							//Call print AWB
					}else{
						if($result=="-1")
						{
							$this->session->data['eroare_awb'] = 'Utilizator sau parola incorecte';
						}
						if($result=="-2")
						{
							$this->session->data['eroare_awb'] = 'Cod client incorect';
						}
						if($result!="-2" && $result!="-1" )
						{
							$this->session->data['eroare_awb'] = 'Eroare la generarea AWB, Contactati Bookurier';
						}
					}
			}
		}
		
		// daca ruta exista sau nu
		if (isset($_GET['ruta'])) $ruta = $_GET['ruta'];
		else $ruta = "";

		$this->response->redirect($this->url->link($ruta, 'order_id='.$_GET['oid'].'&user_token='.$this->session->data['user_token'], true));

	}

	public function printawb() {
		$url = 'http://www.bookurier.ro/colete/serv/get_AWB.php';

		$username=$this->config->get('module_bookurierawb_nume_client');
		$userpwd=$this->config->get('module_bookurierawb_parola_client');

		$this->load->model('sale/order');

		if (isset($_GET['oid'])){			

				$order_id=$this->db->escape($_GET['oid']);	
				$query = $this->db->query("SELECT book_AWB FROM `" . DB_PREFIX . "order`  WHERE  order_id = ".(int)$order_id );

				if ($query->num_rows) {
					$data = $query->row;

					$BookAWBString = $data['book_AWB'];
					$BookAWBArray = explode(',', $BookAWBString);
					//print_r($BookAWBArray);

					foreach ($BookAWBArray as $bookawb) {						
					
					$msg="".$bookawb."";					
				
					$fields = array(
						'userid' => urlencode($username),
						'pwd' => urlencode($userpwd),
						'msg' => urlencode($msg)			
					);
					

					$fields_string='';
					foreach($fields as $key=>$value) { 
						$fields_string .= $key.'='.$value.'&'; }
					rtrim($fields_string, '&');

					//echo '
'; print_r($fields); echo '
'; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute post $result = curl_exec($ch); echo $result; //close connection curl_close($ch); if(strlen($result)>200){ }else{ $this->error['warning'] = 'Utilizator sau parola incorecte pentru Bookurier'; } $Html= "
"; echo $Html; } //end foreach $Html= "
"; echo $Html; } } } public function removeawb() { $url = 'http://www.bookurier.ro/colete/serv/del_cmd.php'; $username=$this->config->get('module_bookurierawb_nume_client'); $userpwd=$this->config->get('module_bookurierawb_parola_client'); if (isset($_GET['oid'])) { $order_id=$this->db->escape($_GET['oid']); $query = $this->db->query("SELECT book_AWB FROM `" . DB_PREFIX . "order` WHERE order_id = ".(int)$order_id ); if ($query->num_rows){ $data = $query->row; $BookAWBString = $data['book_AWB']; $BookAWBArray = explode(',', $BookAWBString); //print_r($BookAWBArray); foreach ($BookAWBArray as $bookawb) { $msg="".$bookawb.""; $fields = array( 'userid' => urlencode($username), 'pwd' => urlencode($userpwd), 'msg' => urlencode($msg) ); $fields_string=''; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute post $result = curl_exec($ch); //close connection curl_close($ch); if($result == "1") { $_SESSION['nr_awb'] = ''; // codul care aduce AWB-ul $awb = ''; // salveaza AWB pt ORDER_ID daca avem ORDER_ID si AWB $this->db->query("UPDATE `".DB_PREFIX."order` SET book_AWB='' WHERE order_id='". (int)$order_id ."'"); $this->session->data['success'] = 'S-a sters AWB-ul nr.'.$data['book_AWB']; } else { $this->error['warning'] = 'Utilizator sau parola incorecte pentru Bookurier'; } } //end foreach } } if (isset($_GET['ruta'])) $ruta = $_GET['ruta']; else $ruta = ""; $this->response->redirect($this->url->link($ruta, 'order_id='.$_GET['oid'].'&user_token='.$this->session->data['user_token'], true)); } public function customAWB() { $this->document->setTitle('AWB Bookurier Custom'); if (!empty($this->request->get['order_id'])) { $order_id = (int)$this->request->get['order_id']; } else { die('Id-ul comenzii trebuie specificat!'); } $this->load->model('sale/order'); $order_info = $this->model_sale_order->getOrder($order_id); if (!$order_info) die('Comanda nu exista!'); if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $awb_data = $this->request->post; $result = $this->createCustomAwb($order_id, $awb_data); if (!empty($result['error'])) { $this->error['warning'] = $result['error']; } elseif (!empty($result['success'])) { $this->session->data['success'] = $result['success']; $this->session->data['bookurier_success'] = $result['success']; $this->response->redirect($this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true)); } } if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } if (isset($this->session->data['success'])) { $data['success'] = $this->session->data['success']; unset($this->session->data['success']); } else { $data['success'] = ''; } $data['breadcrumbs'] = array(); $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) ); $data['breadcrumbs'][] = array( 'text' => 'Extensii pentru livrare', 'href' => $this->url->link('extension/module', 'user_token=' . $this->session->data['user_token'], true) ); $data['breadcrumbs'][] = array( 'text' => 'Bookurier', 'href' => $this->url->link('extension/module/bookurierawb', 'user_token=' . $this->session->data['user_token'], true) ); $data['action'] = $this->url->link('extension/module/bookurierawb/customAWB', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true); $data['cancel'] = $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $order_id, true); $order_products = $this->model_sale_order->getOrderProducts($order_id); $order_totals = $this->model_sale_order->getOrderTotals($order_id); $serviciu_id = ((int)$order_info['shipping_zone_id'] == 2688) ? 1 : 9; if (isset($this->request->post['order_id'])) { $data['order_id'] = $this->request->post['order_id']; } else { $data['order_id'] = $order_info['order_id']; } if (isset($this->request->post['shipping_firstname'])) { $data['shipping_firstname'] = $this->request->post['shipping_firstname']; } else { $data['shipping_firstname'] = $order_info['shipping_firstname']; } if (isset($this->request->post['shipping_lastname'])) { $data['shipping_lastname'] = $this->request->post['shipping_lastname']; } else { $data['shipping_lastname'] = $order_info['shipping_lastname']; } if (isset($this->request->post['telephone'])) { $data['telephone'] = $this->request->post['telephone']; } else { $data['telephone'] = $order_info['telephone']; } if (isset($this->request->post['email'])) { $data['email'] = $this->request->post['email']; } else { $data['email'] = $order_info['email']; } if (isset($this->request->post['shipping_country'])) { $data['shipping_country'] = $this->request->post['shipping_country']; } else { $data['shipping_country'] = $order_info['shipping_country']; } if (isset($this->request->post['shipping_city'])) { $data['shipping_city'] = $this->request->post['shipping_city']; } else { $data['shipping_city'] = $order_info['shipping_city']; } if (isset($this->request->post['shipping_postcode'])) { $data['shipping_postcode'] = $this->request->post['shipping_postcode']; } else { $data['shipping_postcode'] = $order_info['shipping_postcode']; } if (isset($this->request->post['shipping_zone'])) { $data['shipping_zone'] = $this->request->post['shipping_zone']; } else { $data['shipping_zone'] = $order_info['shipping_zone']; } if (isset($this->request->post['shipping_address_1'])) { $data['shipping_address_1'] = $this->request->post['shipping_address_1']; } else { $data['shipping_address_1'] = $order_info['shipping_address_1'] . ' ' . $order_info['shipping_address_2']; } if (isset($this->request->post['shipping_number'])) { $data['shipping_number'] = $this->request->post['shipping_number']; } else { $data['shipping_number'] = ''; } if (isset($this->request->post['shipping_block'])) { $data['shipping_block'] = $this->request->post['shipping_block']; } else { $data['shipping_block'] = ''; } if (isset($this->request->post['shipping_entry'])) { $data['shipping_entry'] = $this->request->post['shipping_entry']; } else { $data['shipping_entry'] = ''; } if (isset($this->request->post['shipping_floor'])) { $data['shipping_floor'] = $this->request->post['shipping_floor']; } else { $data['shipping_floor'] = ''; } if (isset($this->request->post['shipping_apt'])) { $data['shipping_apt'] = $this->request->post['shipping_apt']; } else { $data['shipping_apt'] = ''; } if (isset($this->request->post['shipping_interphone'])) { $data['shipping_interphone'] = $this->request->post['shipping_interphone']; } else { $data['shipping_interphone'] = ''; } if (isset($this->request->post['shipping_service'])) { $data['shipping_service'] = $this->request->post['shipping_service']; } else { $data['shipping_service'] = $serviciu_id; } if (isset($this->request->post['shipping_packs'])) { $data['shipping_packs'] = $this->request->post['shipping_packs']; } else { $data['shipping_packs'] = 1; } if (isset($this->request->post['shipping_weight'])) { $data['shipping_weight'] = $this->request->post['shipping_weight']; } else { $data['shipping_weight'] = 1; } if (isset($this->request->post['shipping_rbs_val'])) { $data['shipping_rbs_val'] = $this->request->post['shipping_rbs_val']; } else { $data['shipping_rbs_val'] = $order_info['total']; } if (isset($this->request->post['shipping_exchange_pack'])) { $data['shipping_exchange_pack'] = $this->request->post['shipping_exchange_pack']; } else { $data['shipping_exchange_pack'] = 0; } if (isset($this->request->post['shipping_insurance_val'])) { $data['shipping_insurance_val'] = $this->request->post['shipping_insurance_val']; } else { $data['shipping_insurance_val'] = 0; } if (isset($this->request->post['shipping_notes'])) { $data['shipping_notes'] = $this->request->post['shipping_notes']; } else { $data['shipping_notes'] = ''; } $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); $this->response->setOutput($this->load->view('extension/module/bookurierawb_custom', $data)); } private function createCustomAwb($order_id, $awb_data) { $url = 'http://www.bookurier.ro/colete/serv/add_cmd.php'; $username=$this->config->get('module_bookurierawb_nume_client'); $userpwd=$this->config->get('module_bookurierawb_parola_client'); $clientid=$this->config->get('module_bookurierawb_client_id'); $msg="".$clientid."".$order_id."".$awb_data['module_firstname']." ".$awb_data['module_lastname']."".$awb_data['telephone']."".$awb_data['email']."".$awb_data['module_country']."".$awb_data['module_city']."".$awb_data['module_postcode']."".$awb_data['module_zone']."".$awb_data['module_address_1']."".$awb_data['module_number']."".$awb_data['module_block']."".$awb_data['module_entry']."".$awb_data['module_floor']."".$awb_data['module_apt']."".$awb_data['module_interphone']."".$awb_data['module_service']."".$awb_data['module_packs']."".$awb_data['module_weight']."".$awb_data['module_rbs_val']."".$awb_data['module_exchange_pack']."".$awb_data['module_insurance_val']."".$awb_data['module_notes'].""; die($msg); $fields = array( 'userid' => urlencode($username), 'pwd' => urlencode($userpwd), 'msg' => urlencode($msg) ); $fields_string=''; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); if (strlen($result) > 6) { $awb = $result;; $this->db->query("UPDATE `".DB_PREFIX."order` SET book_AWB='". $this->db->escape($awb)."' WHERE order_id='". (int)$order_id . "'"); return array('success' => 'S-a generat AWB-ul nr.'.$awb); } else { if ($result=="-1") { return array('error' => 'Utilizator sau parola incorecte'); } if ($result=="-2") { return array('error' => 'Cod client incorect'); } if ($result!="-2" && $result!="-1" ) { return array('error' => 'Eroare la generarea AWB, Contactati Bookurier'); } } } }