| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087 |
- <?php
- class api_model extends Model {
- //private $API = 'https://szollosil.bbus.smbinfo.hu/api/index.php';
- //private $API = 'https://hoponticket.com/api/index.php';
- private $API = 'https://php82fpm.umsbox.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, $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;
- }
- private function getAllEventsListByGroup($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);
- $eventsByKey = [];
- $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'];
- $eventsByKey[$key] = $event;
- }
- return $eventsByKey;
- }
- 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));
- }
- private function fetchLowestPrices($eventIDs) {
- $multiHandle = curl_multi_init();
- $handles = [];
- foreach ($eventIDs as $eventID) {
- $ch = curl_init();
- curl_setopt_array($ch, array(
- CURLOPT_URL => $this->API.'/affiliateapi/menus?eventDetailId='.$eventID,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => '',
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => 'GET',
- CURLOPT_HTTPHEADER => array(
- 'DOLAPIKEY: '.$this->API_KEY
- ),
- ));
- $handles[$eventID] = $ch;
- curl_multi_add_handle($multiHandle, $ch);
- }
- $running = null;
- do {
- curl_multi_exec($multiHandle, $running);
- curl_multi_select($multiHandle);
- } while ($running > 0);
- $prices = [];
- foreach ($handles as $eventID => $ch) {
- $response = curl_multi_getcontent($ch);
- $menus = json_decode($response, true);
- $lowest = null;
- if (is_array($menus)) {
- foreach ($menus as $item) {
- if ($lowest === null || $item['price'] < $lowest) {
- $lowest = $item['price'];
- }
- }
- }
- $prices[$eventID] = $lowest !== null ? formatize::currency(round($lowest)) : '';
- curl_multi_remove_handle($multiHandle, $ch);
- curl_close($ch);
- }
- curl_multi_close($multiHandle);
- return $prices;
- }
- 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.";");
- if (empty($rows)) {
- return [];
- }
- // 1) Egyetlen API hívás az összes event date-hez (N cURL → 1 cURL)
- $allEventsByKey = $this->getAllEventsListByGroup($groupID);
- // 2) Egyetlen DB query az összes image-hez (N query → 1 query)
- $boxIds = [];
- foreach ($rows as $row) {
- $boxIds[] = $row->box_id;
- }
- $allImages = $this->query("SELECT * FROM `azonics_events_blocks` WHERE block_status=1 AND box_id IN (".implode(',', $boxIds).");");
- $imagesByBoxId = [];
- foreach ($allImages as $img) {
- $imagesByBoxId[$img->box_id][] = $img;
- }
- // 3) Párhuzamos menu API hívások az árakhoz (N szekvenciális → N párhuzamos cURL)
- $eventIDs = [];
- foreach ($rows as $row) {
- $eventIDs[] = $row->parent_event;
- }
- $lowestPrices = $this->fetchLowestPrices($eventIDs);
- $results = [];
- foreach ($rows as $row) {
- $row->parent_price = isset($lowestPrices[$row->parent_event]) ? $lowestPrices[$row->parent_event] : '';
- $row->images = isset($imagesByBoxId[$row->box_id]) ? $imagesByBoxId[$row->box_id] : [];
- $row->dates = isset($allEventsByKey[$row->parent_event]) ? [$allEventsByKey[$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 getTransactionStatusFromSimplePay($uuid) {
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $this->API.'/affiliateapi/getTransactionStatusFromSimplePay?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 validateUUID($uuid) {
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $this->API.'/affiliateapi/CheckUUIDValidation?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);
- print_r($response);
- die();
- 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']."',
- order_error_code = '".$data['order_error_code']."',
- order_error_message = '".$data['order_error_message']."' 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;
- }
- }
|