| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- <?php
- class api_model extends Model {
- private $API = 'https://szollosil.bbus.smbinfo.hu/api/index.php';
- private $API_KEY = '92JxvN5Zeti4E1FDwKg0QPEl3md4vY63';
- public function getGroupsList() {
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $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) {
- $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;
- 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->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 => $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 getHotels($onlyHotels = false) {
- $curl = curl_init();
- $url = $this->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: '.$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('key' => 'hotel_'.$key, 'value' => $value['label']);
- }
- }
- 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);
- 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($hotelID, $actualMonth = 0) {
- $curl = curl_init();
- $postfix = '';
- if ($actualMonth == 1) {
- $postfix = '&actualMonth='.$actualMonth;
- }
- curl_setopt_array($curl, array(
- CURLOPT_URL => $this->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: '.$this->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;
- }
- }
|