$this->API.'/affiliateapi/groups', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $groups = []; $response = json_decode($response, true); foreach ($response as $key => $item) { $group = []; $group['id'] = $key; $group['label'] = $item; $groups[] = $group; } //$data = json_encode($groups, true); return $groups; } public function getProductsList($groupID) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/products?group_id='.$groupID, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $products = []; $response = json_decode($response, true); foreach ($response as $group) { foreach ($group as $key => $categories) { foreach ($categories as $item) { $product = []; $product['id'] = $item['id']; $product['name'] = $item['label']; $product['price'] = $item['price']; $products[$key]['products'][] = $product; } $products[$key]['label'] = $products[$key]['products'][0]['name']; $products[$key]['key'] = $key; } } //$data = json_encode($products, true); return $products; } public function getEventsList($groupID, $eventID='') { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/events?group_id='.$groupID.'&groupByDate=1', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $events = []; $response = json_decode($response, true); foreach ($response as $key => $item) { $event = []; $event['key'] = $key; /*if ($key != $eventID) { continue; }*/ foreach ($item as $subkey => $subitem) { $sub = []; $date = explode(' ', $subkey); $sub['id'] = $subitem['id']; $sub['label'] = $subitem['label']; $sub['description'] = $subitem['description']; $sub['date'] = $date[0]; $sub['time'] = substr($date[1],0,-3); $sub['max_num'] = $subitem['max_num']; $sub['participants'] = $subitem['participants']; $sub['available'] = $subitem['max_num'] - $subitem['participants']; $event['dates'][] = $sub; } $event['label'] = $event['dates'][0]['label']; $event['description'] = $event['dates'][0]['description']; $event['date'] = $event['dates'][0]['date']; $event['time'] = $event['dates'][0]['time']; $event['available'] = $event['dates'][0]['available']; $events[] = $event; } //$data = json_encode($events, true); return $events; } public function getEventsListByGroup($groupID, $eventID) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/events?group_id='.$groupID.'&groupByDate=1', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $events = []; $response = json_decode($response, true); foreach ($response as $key => $item) { $event = []; $event['key'] = $key; if ($key != $eventID) { continue; } foreach ($item as $subkey => $subitem) { $sub = []; $date = explode(' ', $subkey); $sub['id'] = $subitem['id']; $sub['label'] = $subitem['label']; $sub['description'] = $subitem['description']; $sub['date'] = $date[0]; $sub['time'] = substr($date[1],0,-3); $sub['max_num'] = $subitem['max_num']; $sub['participants'] = $subitem['participants']; $sub['available'] = $subitem['max_num'] - $subitem['participants']; $event['dates'][] = $sub; } $event['label'] = $event['dates'][0]['label']; $event['description'] = $event['dates'][0]['description']; $event['date'] = $event['dates'][0]['date']; $event['time'] = $event['dates'][0]['time']; $event['available'] = $event['dates'][0]['available']; $events[] = $event; } //$data = json_encode($events, true); return $events; } public function getMenusList($eventID) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/menus?eventDetailId='.$eventID, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $response = json_decode($response, true); foreach ($response as $key => $item) { $menu = []; $menu['id'] = $item['fk_product']; $menu['label'] = $item['label']; $menu['description'] = $item['description']; $menu['price'] = $item['price']; $menus[] = $menu; } //$data = json_encode($events, true); return $menus; } public function getEvents($packageid, $participants) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/events?id='.$packageid.'&participants='.$participants, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $events = []; $response = json_decode($response, true); foreach ($response as $item) { $event = []; $date_temp = explode(' ', $item['start_date']); $date_exp = explode('-',$date_temp[0]); $honap = $date_exp[1] < 10 ? str_replace('0','',$date_exp[1]) : $date_exp[1]; $nap = $date_exp[2] < 10 ? str_replace('0','',$date_exp[2]) : $date_exp[2]; $datum = $date_exp[0] .'-'. $honap .'-'. $nap; $timePart = substr($date_temp[1], 0, -3); $event['id'] = $item['id']; $event['date'] = $datum; $event['datum'] = $date_temp[0]; $event['time'] = $timePart; $event['products'] = $item['products']; $events[] = $event; } $data = json_encode($events, true); return $data; } public function getProductImage() { $id = $this->escapeString($_REQUEST['id']); $row = $this->query("select * from azonics_products where slide_title='".$id."' AND slide_status='1';"); return $row[0]; } public function getServices() { $rows = $this->query("select * from azonics_services where box_status='1';"); $result = []; foreach ($rows as $row) { $result[] = $row; } return $result; } public function getGroupNameByID($groupID) { $rows = $this->query("select * from azonics_services where box_status='1' AND parent_service='".$groupID."';"); return $rows[0]->box_subtitle; } public function getProdutNameByID($productID) { $rows = $this->query("select * from azonics_services where box_status='1' AND parent_service='".$groupID."';"); return $rows[0]->box_subtitle; } public function initializeTransaction() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/init', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); $response = str_replace('"','',$response); curl_close($curl); return $response; } public function startReservation() { $curl = curl_init(); $post_data = array( 'uuid' => $_REQUEST['uuid'], 'event_id' => $_REQUEST['event_id'], 'qty' => $_REQUEST['qty'] ); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/reserve', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => http_build_query($post_data), CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return $response; } public function order() { $data = json_decode($_REQUEST['data']); $curl = curl_init(); $post_data = $data; $post_data->uuid = str_replace('"','',$post_data->uuid); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/order', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($post_data), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'DOLAPIKEY: '.$this->API_KEY ), )); //print_r(json_encode($post_data)); //die(); $response = curl_exec($curl); curl_close($curl); return $response; } public function paymentstatus() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/paymentstatus?uuid='.$_REQUEST['uuid'], CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return $response; } public function getProviderDetails() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/getCustomerData', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return $response; } public function getLabels($lang = 'hu') { $rows = $this->query("select setting_name, setting_value_text, setting_value_text_en, setting_status from azonics_settings where setting_status='1';"); foreach ($rows as $row) { if ($lang == 'en') { $row->setting_value_text = $row->setting_value_text_en; } $results[] = $row; } return $results; } public function getGroups($lang = 'hu') { $rows = $this->query("SELECT * FROM `azonics_services` WHERE box_status=1;"); foreach ($rows as $row) { if ($lang == 'en') { $row->box_subtitle = $row->box_subtitle_en; $row->box_title = $row->box_button_text_en; } $results[] = $row; } return $results; } public function getGroupID($groupKey) { $row = $this->query("SELECT * FROM `azonics_services` WHERE box_status=1 AND box_title_en='".$groupKey."';"); return $row[0]->parent_service; } public function getLowestEventprice($eventID) { $events = $this->getMenusList($eventID); foreach ($events as $event) { if (!isset($lowest) || $event['price'] < $lowest) { $lowest = $event['price']; } } return formatize::currency(round($lowest)); } public function getEventsData($groupID, $lang = 'hu') { $parentID = $this->getGroupID($groupID); $rows = $this->query("SELECT * FROM `azonics_events` WHERE box_status=1 AND parent_service=".$parentID.";"); foreach ($rows as $row) { $row->parent_price = $this->getLowestEventprice($row->parent_event); $images = $this->query("SELECT * FROM `azonics_events_blocks` WHERE block_status=1 AND box_id=".$row->box_id.";"); $row->images = $images; $row->dates = $this->getEventsListByGroup($groupID, $row->parent_event); if ($lang == 'en') { $row->box_title = $row->box_title_en; $row->box_subtitle = $row->box_subtitle_en; } if (count($row->dates) < 1) { continue; } $results[] = $row; } return $results; } public function getEventMenus($eventID, $lang = 'hu') { $rows = $this->query("SELECT * FROM `azonics_packages` WHERE box_status=1 AND parent_event=".$eventID." ORDER BY box_order ASC;"); $menus = $this->getMenusList($eventID); foreach ($rows as $row) { $images = $this->query("SELECT * FROM `azonics_package_blocks` WHERE block_status=1 AND box_id=".$row->box_id.";"); $row->images = $images; foreach ($menus as $menu) { if ($menu['id'] == $row->parent_menu) { $row->parent_price = $menu['price']; } } if ($lang == 'en') { $row->box_title = $row->box_title_en; $row->box_subtitle = $row->box_subtitle_en; } if (count($images) > 0) { $results[] = $row; } } return $results; } public function getEventName($groupID, $eventID) { $row = $this->query("SELECT * FROM `azonics_events` WHERE box_status=1 AND parent_service=".$groupID." AND parent_event=".$eventID.";"); return $row[0]->box_title; } public function getEventsRawList() { $rows = $this->query("SELECT * FROM `azonics_events` WHERE box_status=1;"); return $rows; } public function getProductsData($groupID, $lang = 'hu') { $items = $this->getProductsList($groupID); $rows = $this->query("SELECT * FROM `azonics_prods` WHERE box_status=1 AND parent_service=".$groupID.";"); foreach ($rows as $row) { $images = $this->query("SELECT * FROM `azonics_prods_blocks` WHERE block_status=1 AND box_id=".$row->box_id.";"); $row->images = $images; $row->items = $items[$row->parent_prods]['products']; if ($lang == 'en') { $row->box_title = $row->box_title_en; $row->box_subtitle = $row->box_subtitle_en; } $results[] = $row; } return $results; } public function getContent($slug, $lang = 'hu') { $row = $this->query("SELECT * FROM `azonics_blog` WHERE page_status=1 AND page_slug='".$slug."';"); if ($lang == 'en') { $row[0]->page_title = $row[0]->page_title_en; $row[0]->page_content = $row[0]->page_content_en; } return $row[0]; } public function getUID() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/init', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return $response; } public function reserveEvent($uuid, $eventID, $qty) { $curl = curl_init(); $post_data = array('uuid' => $uuid, 'event_id' => $eventID, 'qty' => $qty); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/reserve', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($post_data), CURLOPT_HTTPHEADER => array( 'Content-Type:application/json', 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return json_decode($response); } public function getAllHotels() { $curl = curl_init(); $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1'; curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $groups = []; $response = json_decode($response, true); foreach ($response as $key => $value) { if ($allHotels === false ) { if ($value['contracted_partner'] == 1) { $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']); } } else if ($allHotels === true) { $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']); } } return $options; } public function getAllPartner() { $curl = curl_init(); $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1'; curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $groups = []; $response = json_decode($response, true); foreach ($response as $key => $value) { $options[] = array('id' => $value['id'], 'key' => $key, 'value' => $value['label'], 'partner' => $value['contracted_partner']); } return $options; } public function getAllContractedPartner() { $curl = curl_init(); $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1'; curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $groups = []; $response = json_decode($response, true); foreach ($response as $key => $value) { if ($value['contracted_partner'] == 1) { $options[] = array('id' => $value['id'], 'key' => $key, 'value' => $value['label'], 'partner' => $value['contracted_partner']); } } return $options; } public function getHotels($allHotels = false) { $curl = curl_init(); $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1'; curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $groups = []; $response = json_decode($response, true); foreach ($response as $key => $value) { if ($allHotels === false ) { if ($value['contracted_partner'] == 1) { $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']); } } else if ($allHotels === true) { $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']); } } return $options; } public function checkout($data) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/order', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_HTTPHEADER => array( 'Content-Type:application/json', 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return json_decode($response); } public function getCountries() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/setup/dictionary/countries?sortfield=code&sortorder=ASC&limit=3000', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $options = []; $response = json_decode($response, true); if (is_array($response)) { usort($response, function($a, $b) { $la = isset($a['label']) ? mb_strtolower($a['label'], 'UTF-8') : ''; $lb = isset($b['label']) ? mb_strtolower($b['label'], 'UTF-8') : ''; return $la <=> $lb; }); } foreach ($response as $value) { $options[] = array('key' => $value['id'].'_'.$value['code'], 'value' => $value['label']); } return $options; } public function getPaymentStatus($uuid) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/paymentstatus?uuid='.$uuid, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $response = json_decode($response, true); return $response; } public function authenticateUser($username, $password) { $row = $this->query("SELECT * FROM `azonics_admin_users` WHERE admin_pass='".$password."' AND (admin_email='".$username."' OR admin_name='".$username."') AND admin_status='1';"); if (count($row) == 0) { return ['success' => false]; } else { return [ 'success' => true, 'name' => $row[0]->admin_name, 'hotel' => $row[0]->admin_dashboard ]; } } public function getMonthRevenue($hotelIDs, $actualMonth = 0) { $curl = curl_init(); $postfix = ''; if ($actualMonth == 1) { $postfix = '&actualMonth='.$actualMonth; } curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/getAmount?hotelids='.$hotelIDs.$postfix, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $result = json_decode($response); return $result; } public function createOrderDetails($data) { $this->execute("INSERT INTO `azonics_orders` SET order_uuid = '".$data['order_uuid']."', order_hotel = '".$data['order_hotel']."', order_sales = '".$data['order_sales']."', order_cart = '".serialize($data['order_cart'])."', order_customer_fname = '".$data['order_customer_fname']."', order_customer_lname = '".$data['order_customer_lname']."', order_customer_email = '".$data['order_customer_email']."', order_customer_city = '".$data['order_customer_city']."', order_customer_country = '".$data['order_customer_country']."', order_customer_zip = '".$data['order_customer_zip']."', order_customer_street = '".$data['order_customer_street']."', order_customer_house = '".$data['order_customer_house']."', order_customer_phone = '".$data['order_customer_phone']."', order_customer_hotel = '".$data['order_customer_hotel']."', order_customer_ip = '".$data['order_customer_ip']."', order_customer_browser = '".$data['order_customer_browser']."', order_terms_accepted = 1, order_status = 1;"); return $this->getLastInsertID(); } public function updateOrderDetails($data) { $this->execute("UPDATE azonics_orders SET order_transaction_id = '".$data['order_transaction_id']."', order_auth_code = '".$data['order_auth_code']."' WHERE order_id = '".$data['order_id']."';"); return $data['order_id']; } public function getReports() { $hotels = $this->getAllPartner(); $reports = []; $userData = unserialize($_SESSION['admin_user']->admin_dashboard); $ids = []; foreach ($userData as $hotelID) { foreach ($hotels as $hotel) { if ($hotel['key'] == $hotelID) { $ids[] = $hotel['id']; $reports[] = [ 'id' => $hotel['id'], 'hotel' => $hotel['value'], 'actual_month' => '', 'last_month' => '' ]; } } } $actualMonth = $this->getMonthRevenue(implode(',',$ids), 1); $lastMonth = $this->getMonthRevenue(implode(',',$ids), 0); foreach ($reports as $key => $report) { foreach ($actualMonth as $id => $item) { if ($id == $report['id']) { $reports[$key]['actual_month'] = $item; } } foreach ($lastMonth as $id => $item) { if ($id == $report['id']) { $reports[$key]['last_month'] = $item; } } } return $reports; } public function getQRCodes($orderID) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $this->API.'/affiliateapi/getSaledItemsQR?sendid='.$orderID, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'DOLAPIKEY: '.$this->API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $groups = []; $response = json_decode($response, true); foreach ($response as $key => $item) { $group = []; $group['id'] = $key; $group['label'] = $item; $groups[] = $group; } //$data = json_encode($groups, true); return $groups; } }