|
|
@@ -2,7 +2,10 @@
|
|
|
|
|
|
class api_model extends Model {
|
|
|
|
|
|
- private $API = 'https://szollosil.bbus.smbinfo.hu/api/index.php';
|
|
|
+ //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() {
|
|
|
@@ -72,9 +75,57 @@ class api_model extends Model {
|
|
|
return $products;
|
|
|
}
|
|
|
|
|
|
- public function getEventsList($groupID) {
|
|
|
+ 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,
|
|
|
@@ -95,6 +146,9 @@ class api_model extends Model {
|
|
|
foreach ($response as $key => $item) {
|
|
|
$event = [];
|
|
|
$event['key'] = $key;
|
|
|
+ if ($key != $eventID) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
foreach ($item as $subkey => $subitem) {
|
|
|
$sub = [];
|
|
|
$date = explode(' ', $subkey);
|
|
|
@@ -394,11 +448,14 @@ class api_model extends Model {
|
|
|
$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);
|
|
|
+ $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;
|
|
|
@@ -508,13 +565,45 @@ class api_model extends Model {
|
|
|
return json_decode($response);
|
|
|
}
|
|
|
|
|
|
- public function getHotels($onlyHotels = false) {
|
|
|
+ public function getAllHotels() {
|
|
|
$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 ($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,
|
|
|
@@ -534,8 +623,71 @@ class api_model extends Model {
|
|
|
$groups = [];
|
|
|
$response = json_decode($response, true);
|
|
|
foreach ($response as $key => $value) {
|
|
|
- if ($value['contracted_partner'] == '1') {
|
|
|
- $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label']);
|
|
|
+ $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;
|
|
|
@@ -585,9 +737,19 @@ class api_model extends Model {
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
@@ -627,7 +789,7 @@ class api_model extends Model {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function getMonthRevenue($hotelID, $actualMonth = 0) {
|
|
|
+ public function getMonthRevenue($hotelIDs, $actualMonth = 0) {
|
|
|
$curl = curl_init();
|
|
|
|
|
|
$postfix = '';
|
|
|
@@ -636,7 +798,7 @@ class api_model extends Model {
|
|
|
}
|
|
|
|
|
|
curl_setopt_array($curl, array(
|
|
|
- CURLOPT_URL => $this->API.'/affiliateapi/getAmount?hotel_id='.$hotelID.$postfix,
|
|
|
+ CURLOPT_URL => $this->API.'/affiliateapi/getAmount?hotelids='.$hotelIDs.$postfix,
|
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
|
CURLOPT_ENCODING => '',
|
|
|
CURLOPT_MAXREDIRS => 10,
|
|
|
@@ -650,29 +812,107 @@ class api_model extends Model {
|
|
|
));
|
|
|
$response = curl_exec($curl);
|
|
|
curl_close($curl);
|
|
|
- $response = str_replace('"','',$response);
|
|
|
- $result = intval($response);
|
|
|
+ $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->getHotels(true);
|
|
|
+ $hotels = $this->getAllPartner();
|
|
|
$reports = [];
|
|
|
$userData = unserialize($_SESSION['admin_user']->admin_dashboard);
|
|
|
+ $ids = [];
|
|
|
foreach ($userData as $hotelID) {
|
|
|
- $hotel = array_filter($hotels, function($h) use ($hotelID) {
|
|
|
- return $h['key'] == $hotelID;
|
|
|
- });
|
|
|
- if (!empty($hotel)) {
|
|
|
- $hotel = array_values($hotel)[0];
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
- $report = [];
|
|
|
- $report['hotel'] = $hotel['value'];
|
|
|
- $report['actual_month'] = $this->getMonthRevenue($hotelID, 1);
|
|
|
- $report['last_month'] = $this->getMonthRevenue($hotelID, 0);
|
|
|
- $reports[] = $report;
|
|
|
}
|
|
|
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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|