self::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: '.self::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 => self::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: '.self::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) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => self::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: '.self::API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $events = []; $response = json_decode($response, true); foreach ($response as $key => $item) { $event = []; $event['key'] = $key; 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 => self::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: '.self::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 => self::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: '.self::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 => self::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: '.self::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 => self::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: '.self::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 => self::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: '.self::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 => self::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: '.self::API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return $response; } public function getProviderDetails() { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => self::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: '.self::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 getEventsData($groupID, $lang = 'hu') { $parentID = $this->getGroupID($groupID); $rows = $this->query("SELECT * FROM `azonics_events` WHERE box_status=1 AND parent_service=".$parentID.";"); //print_r($rows); //die(); foreach ($rows as $row) { $images = $this->query("SELECT * FROM `azonics_events_blocks` WHERE block_status=1 AND box_id=".$row->box_id.";"); $row->images = $images; $row->dates = $this->getEventsList($groupID); if ($lang == 'en') { $row->box_title = $row->box_title_en; $row->box_subtitle = $row->box_subtitle_en; } $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 => self::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: '.self::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 => self::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: '.self::API_KEY ), )); $response = curl_exec($curl); curl_close($curl); return json_decode($response); } public function getHotels($onlyHotels = false) { $curl = curl_init(); $url = self::API.'/affiliateapi/getAllHotels?givePartnerData=1'; if ($onlyHotels) { //$url .= '?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: '.self::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('key' => 'hotel_'.$key, 'value' => $value['label']); } } return $options; } public function checkout($data) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => self::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: '.self::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 => self::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: '.self::API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $options = []; $response = json_decode($response, true); 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 => self::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: '.self::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($hotelID, $actualMonth = 0) { $curl = curl_init(); $postfix = ''; if ($actualMonth == 1) { $postfix = '&actualMonth='.$actualMonth; } curl_setopt_array($curl, array( CURLOPT_URL => self::API.'/affiliateapi/getAmount?hotel_id='.$hotelID.$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: '.self::API_KEY ), )); $response = curl_exec($curl); curl_close($curl); $response = str_replace('"','',$response); $result = intval($response); return $result; } public function getReports() { $hotels = $this->getHotels(true); $reports = []; $userData = unserialize($_SESSION['admin_user']->admin_dashboard); foreach ($userData as $hotelID) { $hotel = array_filter($hotels, function($h) use ($hotelID) { return $h['key'] == $hotelID; }); if (!empty($hotel)) { $hotel = array_values($hotel)[0]; } $report = []; $report['hotel'] = $hotel['value']; $report['actual_month'] = $this->getMonthRevenue($hotelID, 1); $report['last_month'] = $this->getMonthRevenue($hotelID, 0); $reports[] = $report; } return $reports; } }