api_model.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  1. <?php
  2. class api_model extends Model {
  3. //private $API = 'https://hoponticket.com/api/index.php';
  4. //private $API = 'https://preprod2.bbus.umsbox.hu/api/index.php';
  5. //private $API = 'https://php82fpm.umsbox.hu/api/index.php';
  6. //private $API = 'https://szollosil.bbus.umsbox.hu/api/index.php';
  7. private $API = 'https://preprod.bbus.umsbox.hu/api/index.php';
  8. private $API_KEY = '92JxvN5Zeti4E1FDwKg0QPEl3md4vY63';
  9. public function getGroupsList() {
  10. $curl = curl_init();
  11. curl_setopt_array($curl, array(
  12. CURLOPT_URL => $this->API.'/affiliateapi/groups',
  13. CURLOPT_RETURNTRANSFER => true,
  14. CURLOPT_ENCODING => '',
  15. CURLOPT_MAXREDIRS => 10,
  16. CURLOPT_TIMEOUT => 0,
  17. CURLOPT_FOLLOWLOCATION => true,
  18. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  19. CURLOPT_CUSTOMREQUEST => 'GET',
  20. CURLOPT_HTTPHEADER => array(
  21. 'DOLAPIKEY: '.$this->API_KEY
  22. ),
  23. ));
  24. $response = curl_exec($curl);
  25. curl_close($curl);
  26. $groups = [];
  27. $response = json_decode($response, true);
  28. foreach ($response as $key => $item) {
  29. $group = [];
  30. $group['id'] = $key;
  31. $group['label'] = $item;
  32. $groups[] = $group;
  33. }
  34. //$data = json_encode($groups, true);
  35. return $groups;
  36. }
  37. public function getProductsList($groupID) {
  38. $curl = curl_init();
  39. curl_setopt_array($curl, array(
  40. CURLOPT_URL => $this->API.'/affiliateapi/products?group_id='.$groupID,
  41. CURLOPT_RETURNTRANSFER => true,
  42. CURLOPT_ENCODING => '',
  43. CURLOPT_MAXREDIRS => 10,
  44. CURLOPT_TIMEOUT => 0,
  45. CURLOPT_FOLLOWLOCATION => true,
  46. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  47. CURLOPT_CUSTOMREQUEST => 'GET',
  48. CURLOPT_HTTPHEADER => array(
  49. 'DOLAPIKEY: '.$this->API_KEY
  50. ),
  51. ));
  52. $response = curl_exec($curl);
  53. curl_close($curl);
  54. $products = [];
  55. $response = json_decode($response, true);
  56. foreach ($response as $group) {
  57. foreach ($group as $key => $categories) {
  58. foreach ($categories as $item) {
  59. $product = [];
  60. $product['id'] = $item['id'];
  61. $product['name'] = $item['label'];
  62. $product['price'] = $item['price'];
  63. $products[$key]['products'][] = $product;
  64. }
  65. $products[$key]['label'] = $products[$key]['products'][0]['name'];
  66. $products[$key]['key'] = $key;
  67. }
  68. }
  69. //$data = json_encode($products, true);
  70. return $products;
  71. }
  72. public function getEventsList($groupID, $eventID='') {
  73. $curl = curl_init();
  74. curl_setopt_array($curl, array(
  75. CURLOPT_URL => $this->API.'/affiliateapi/events?group_id='.$groupID.'&additionalDate=60&groupByDate=1',
  76. CURLOPT_RETURNTRANSFER => true,
  77. CURLOPT_ENCODING => '',
  78. CURLOPT_MAXREDIRS => 10,
  79. CURLOPT_TIMEOUT => 0,
  80. CURLOPT_FOLLOWLOCATION => true,
  81. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  82. CURLOPT_CUSTOMREQUEST => 'GET',
  83. CURLOPT_HTTPHEADER => array(
  84. 'DOLAPIKEY: '.$this->API_KEY
  85. ),
  86. ));
  87. $response = curl_exec($curl);
  88. curl_close($curl);
  89. $events = [];
  90. $response = json_decode($response, true);
  91. foreach ($response as $key => $item) {
  92. $event = [];
  93. $event['key'] = $key;
  94. /*if ($key != $eventID) {
  95. continue;
  96. }*/
  97. foreach ($item as $subkey => $subitem) {
  98. $sub = [];
  99. $date = explode(' ', $subkey);
  100. $sub['id'] = $subitem['id'];
  101. $sub['label'] = $subitem['label'];
  102. $sub['description'] = $subitem['description'];
  103. $sub['date'] = $date[0];
  104. $sub['time'] = substr($date[1],0,-3);
  105. $sub['max_num'] = $subitem['max_num'];
  106. $sub['participants'] = $subitem['participants'];
  107. $sub['available'] = $subitem['max_num'] - $subitem['participants'];
  108. $event['dates'][] = $sub;
  109. }
  110. $event['label'] = $event['dates'][0]['label'];
  111. $event['description'] = $event['dates'][0]['description'];
  112. $event['date'] = $event['dates'][0]['date'];
  113. $event['time'] = $event['dates'][0]['time'];
  114. $event['available'] = $event['dates'][0]['available'];
  115. $events[] = $event;
  116. }
  117. //$data = json_encode($events, true);
  118. return $events;
  119. }
  120. public function getEventsListByGroup($groupID, $eventID) {
  121. $curl = curl_init();
  122. curl_setopt_array($curl, array(
  123. CURLOPT_URL => $this->API.'/affiliateapi/events?group_id='.$groupID.'&additionalDate=60&groupByDate=1',
  124. CURLOPT_RETURNTRANSFER => true,
  125. CURLOPT_ENCODING => '',
  126. CURLOPT_MAXREDIRS => 10,
  127. CURLOPT_TIMEOUT => 0,
  128. CURLOPT_FOLLOWLOCATION => true,
  129. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  130. CURLOPT_CUSTOMREQUEST => 'GET',
  131. CURLOPT_HTTPHEADER => array(
  132. 'DOLAPIKEY: '.$this->API_KEY
  133. ),
  134. ));
  135. $response = curl_exec($curl);
  136. curl_close($curl);
  137. $events = [];
  138. $response = json_decode($response, true);
  139. foreach ($response as $key => $item) {
  140. $event = [];
  141. $event['key'] = $key;
  142. if ($key != $eventID) {
  143. continue;
  144. }
  145. foreach ($item as $subkey => $subitem) {
  146. $sub = [];
  147. $date = explode(' ', $subkey);
  148. $sub['id'] = $subitem['id'];
  149. $sub['label'] = $subitem['label'];
  150. $sub['description'] = $subitem['description'];
  151. $sub['date'] = $date[0];
  152. $sub['time'] = substr($date[1],0,-3);
  153. $sub['max_num'] = $subitem['max_num'];
  154. $sub['participants'] = $subitem['participants'];
  155. $sub['available'] = $subitem['max_num'] - $subitem['participants'];
  156. $event['dates'][] = $sub;
  157. }
  158. $event['label'] = $event['dates'][0]['label'];
  159. $event['description'] = $event['dates'][0]['description'];
  160. $event['date'] = $event['dates'][0]['date'];
  161. $event['time'] = $event['dates'][0]['time'];
  162. $event['available'] = $event['dates'][0]['available'];
  163. $events[] = $event;
  164. }
  165. //$data = json_encode($events, true);
  166. return $events;
  167. }
  168. private function getAllEventsListByGroup($groupID) {
  169. $curl = curl_init();
  170. curl_setopt_array($curl, array(
  171. CURLOPT_URL => $this->API.'/affiliateapi/events?group_id='.$groupID.'&additionalDate=60&groupByDate=1',
  172. CURLOPT_RETURNTRANSFER => true,
  173. CURLOPT_ENCODING => '',
  174. CURLOPT_MAXREDIRS => 10,
  175. CURLOPT_TIMEOUT => 0,
  176. CURLOPT_FOLLOWLOCATION => true,
  177. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  178. CURLOPT_CUSTOMREQUEST => 'GET',
  179. CURLOPT_HTTPHEADER => array(
  180. 'DOLAPIKEY: '.$this->API_KEY
  181. ),
  182. ));
  183. $response = curl_exec($curl);
  184. curl_close($curl);
  185. $eventsByKey = [];
  186. $response = json_decode($response, true);
  187. //print_r($response);
  188. //die();
  189. foreach ($response as $key => $item) {
  190. $event = [];
  191. $event['key'] = $key;
  192. foreach ($item as $subkey => $subitem) {
  193. $sub = [];
  194. $date = explode(' ', $subkey);
  195. $sub['id'] = $subitem['id'];
  196. $sub['label'] = $subitem['label'];
  197. $sub['description'] = $subitem['description'];
  198. $sub['date'] = $date[0];
  199. $sub['time'] = substr($date[1],0,-3);
  200. $sub['max_num'] = $subitem['max_num'];
  201. $sub['participants'] = $subitem['participants'];
  202. $sub['available'] = $subitem['max_num'] - $subitem['participants'];
  203. $event['dates'][] = $sub;
  204. }
  205. $event['label'] = $event['dates'][0]['label'];
  206. $event['description'] = $event['dates'][0]['description'];
  207. $event['date'] = $event['dates'][0]['date'];
  208. $event['time'] = $event['dates'][0]['time'];
  209. $event['available'] = $event['dates'][0]['available'];
  210. $eventsByKey[$key] = $event;
  211. }
  212. return $eventsByKey;
  213. }
  214. public function getMenusList($eventID) {
  215. $curl = curl_init();
  216. curl_setopt_array($curl, array(
  217. CURLOPT_URL => $this->API.'/affiliateapi/menus?eventDetailId='.$eventID,
  218. CURLOPT_RETURNTRANSFER => true,
  219. CURLOPT_ENCODING => '',
  220. CURLOPT_MAXREDIRS => 10,
  221. CURLOPT_TIMEOUT => 0,
  222. CURLOPT_FOLLOWLOCATION => true,
  223. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  224. CURLOPT_CUSTOMREQUEST => 'GET',
  225. CURLOPT_HTTPHEADER => array(
  226. 'DOLAPIKEY: '.$this->API_KEY
  227. ),
  228. ));
  229. $response = curl_exec($curl);
  230. curl_close($curl);
  231. $response = json_decode($response, true);
  232. foreach ($response as $key => $item) {
  233. $menu = [];
  234. $menu['id'] = $item['fk_product'];
  235. $menu['label'] = $item['label'];
  236. $menu['description'] = $item['description'];
  237. $menu['price'] = $item['price'];
  238. $menus[] = $menu;
  239. }
  240. //$data = json_encode($events, true);
  241. return $menus;
  242. }
  243. public function getEvents($packageid, $participants) {
  244. $curl = curl_init();
  245. curl_setopt_array($curl, array(
  246. CURLOPT_URL => $this->API.'/affiliateapi/events?id='.$packageid.'&additionalDate=60&participants='.$participants,
  247. CURLOPT_RETURNTRANSFER => true,
  248. CURLOPT_ENCODING => '',
  249. CURLOPT_MAXREDIRS => 10,
  250. CURLOPT_TIMEOUT => 0,
  251. CURLOPT_FOLLOWLOCATION => true,
  252. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  253. CURLOPT_CUSTOMREQUEST => 'GET',
  254. CURLOPT_HTTPHEADER => array(
  255. 'DOLAPIKEY: '.$this->API_KEY
  256. ),
  257. ));
  258. $response = curl_exec($curl);
  259. curl_close($curl);
  260. $events = [];
  261. $response = json_decode($response, true);
  262. foreach ($response as $item) {
  263. $event = [];
  264. $date_temp = explode(' ', $item['start_date']);
  265. $date_exp = explode('-',$date_temp[0]);
  266. $honap = $date_exp[1] < 10 ? str_replace('0','',$date_exp[1]) : $date_exp[1];
  267. $nap = $date_exp[2] < 10 ? str_replace('0','',$date_exp[2]) : $date_exp[2];
  268. $datum = $date_exp[0] .'-'. $honap .'-'. $nap;
  269. $timePart = substr($date_temp[1], 0, -3);
  270. $event['id'] = $item['id'];
  271. $event['date'] = $datum;
  272. $event['datum'] = $date_temp[0];
  273. $event['time'] = $timePart;
  274. $event['products'] = $item['products'];
  275. $events[] = $event;
  276. }
  277. $data = json_encode($events, true);
  278. return $data;
  279. }
  280. public function getProductImage() {
  281. $id = $this->escapeString($_REQUEST['id']);
  282. $row = $this->query("select * from azonics_products where slide_title='".$id."' AND slide_status='1';");
  283. return $row[0];
  284. }
  285. public function getServices() {
  286. $rows = $this->query("select * from azonics_services where box_status='1';");
  287. $result = [];
  288. foreach ($rows as $row) {
  289. $result[] = $row;
  290. }
  291. return $result;
  292. }
  293. public function getGroupNameByID($groupID) {
  294. $rows = $this->query("select * from azonics_services where box_status='1' AND parent_service='".$groupID."';");
  295. return $rows[0]->box_subtitle;
  296. }
  297. public function getProdutNameByID($productID) {
  298. $rows = $this->query("select * from azonics_services where box_status='1' AND parent_service='".$groupID."';");
  299. return $rows[0]->box_subtitle;
  300. }
  301. public function initializeTransaction() {
  302. $curl = curl_init();
  303. curl_setopt_array($curl, array(
  304. CURLOPT_URL => $this->API.'/affiliateapi/init',
  305. CURLOPT_RETURNTRANSFER => true,
  306. CURLOPT_ENCODING => '',
  307. CURLOPT_MAXREDIRS => 10,
  308. CURLOPT_TIMEOUT => 0,
  309. CURLOPT_FOLLOWLOCATION => true,
  310. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  311. CURLOPT_CUSTOMREQUEST => 'GET',
  312. CURLOPT_HTTPHEADER => array(
  313. 'DOLAPIKEY: '.$this->API_KEY
  314. ),
  315. ));
  316. $response = curl_exec($curl);
  317. $response = str_replace('"','',$response);
  318. curl_close($curl);
  319. return $response;
  320. }
  321. public function startReservation() {
  322. $curl = curl_init();
  323. $post_data = array(
  324. 'uuid' => $_REQUEST['uuid'],
  325. 'event_id' => $_REQUEST['event_id'],
  326. 'qty' => $_REQUEST['qty']
  327. );
  328. curl_setopt_array($curl, array(
  329. CURLOPT_URL => $this->API.'/affiliateapi/reserve',
  330. CURLOPT_RETURNTRANSFER => true,
  331. CURLOPT_ENCODING => '',
  332. CURLOPT_MAXREDIRS => 10,
  333. CURLOPT_TIMEOUT => 0,
  334. CURLOPT_FOLLOWLOCATION => true,
  335. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  336. CURLOPT_CUSTOMREQUEST => 'POST',
  337. CURLOPT_POSTFIELDS => http_build_query($post_data),
  338. CURLOPT_HTTPHEADER => array(
  339. 'DOLAPIKEY: '.$this->API_KEY
  340. ),
  341. ));
  342. $response = curl_exec($curl);
  343. curl_close($curl);
  344. return $response;
  345. }
  346. public function order() {
  347. $data = json_decode($_REQUEST['data']);
  348. $curl = curl_init();
  349. $post_data = $data;
  350. $post_data->uuid = str_replace('"','',$post_data->uuid);
  351. curl_setopt_array($curl, array(
  352. CURLOPT_URL => $this->API.'/affiliateapi/order',
  353. CURLOPT_RETURNTRANSFER => true,
  354. CURLOPT_ENCODING => '',
  355. CURLOPT_MAXREDIRS => 10,
  356. CURLOPT_TIMEOUT => 0,
  357. CURLOPT_FOLLOWLOCATION => true,
  358. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  359. CURLOPT_CUSTOMREQUEST => 'POST',
  360. CURLOPT_POSTFIELDS => json_encode($post_data),
  361. CURLOPT_HTTPHEADER => array(
  362. 'Content-Type: application/json',
  363. 'DOLAPIKEY: '.$this->API_KEY
  364. ),
  365. ));
  366. //print_r(json_encode($post_data));
  367. //die();
  368. $response = curl_exec($curl);
  369. curl_close($curl);
  370. return $response;
  371. }
  372. public function paymentstatus() {
  373. $curl = curl_init();
  374. curl_setopt_array($curl, array(
  375. CURLOPT_URL => $this->API.'/affiliateapi/paymentstatus?uuid='.$_REQUEST['uuid'],
  376. CURLOPT_RETURNTRANSFER => true,
  377. CURLOPT_ENCODING => '',
  378. CURLOPT_MAXREDIRS => 10,
  379. CURLOPT_TIMEOUT => 0,
  380. CURLOPT_FOLLOWLOCATION => true,
  381. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  382. CURLOPT_CUSTOMREQUEST => 'GET',
  383. CURLOPT_HTTPHEADER => array(
  384. 'DOLAPIKEY: '.$this->API_KEY
  385. ),
  386. ));
  387. $response = curl_exec($curl);
  388. curl_close($curl);
  389. return $response;
  390. }
  391. public function getProviderDetails() {
  392. $curl = curl_init();
  393. curl_setopt_array($curl, array(
  394. CURLOPT_URL => $this->API.'/affiliateapi/getCustomerData',
  395. CURLOPT_RETURNTRANSFER => true,
  396. CURLOPT_ENCODING => '',
  397. CURLOPT_MAXREDIRS => 10,
  398. CURLOPT_TIMEOUT => 0,
  399. CURLOPT_FOLLOWLOCATION => true,
  400. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  401. CURLOPT_CUSTOMREQUEST => 'GET',
  402. CURLOPT_HTTPHEADER => array(
  403. 'DOLAPIKEY: '.$this->API_KEY
  404. ),
  405. ));
  406. $response = curl_exec($curl);
  407. curl_close($curl);
  408. return $response;
  409. }
  410. public function getLabels($lang = 'hu') {
  411. $rows = $this->query("select
  412. setting_name,
  413. setting_value_text,
  414. setting_value_text_en,
  415. setting_status from azonics_settings where setting_status='1';");
  416. foreach ($rows as $row) {
  417. if ($lang == 'en') {
  418. $row->setting_value_text = $row->setting_value_text_en;
  419. }
  420. $results[] = $row;
  421. }
  422. return $results;
  423. }
  424. public function getGroups($lang = 'hu') {
  425. $rows = $this->query("SELECT * FROM `azonics_services` WHERE box_status=1;");
  426. foreach ($rows as $row) {
  427. if ($lang == 'en') {
  428. $row->box_subtitle = $row->box_subtitle_en;
  429. $row->box_title = $row->box_button_text_en;
  430. }
  431. $results[] = $row;
  432. }
  433. return $results;
  434. }
  435. public function getGroupID($groupKey) {
  436. $row = $this->query("SELECT * FROM `azonics_services` WHERE box_status=1 AND box_title_en='".$groupKey."';");
  437. return $row[0]->parent_service;
  438. }
  439. public function getLowestEventprice($eventID) {
  440. $events = $this->getMenusList($eventID);
  441. foreach ($events as $event) {
  442. if (!isset($lowest) || $event['price'] < $lowest) {
  443. $lowest = $event['price'];
  444. }
  445. }
  446. return formatize::currency(round($lowest));
  447. }
  448. private function fetchLowestPrices($eventIDs) {
  449. $multiHandle = curl_multi_init();
  450. $handles = [];
  451. foreach ($eventIDs as $eventID) {
  452. $ch = curl_init();
  453. curl_setopt_array($ch, array(
  454. CURLOPT_URL => $this->API.'/affiliateapi/menus?eventDetailId='.$eventID,
  455. CURLOPT_RETURNTRANSFER => true,
  456. CURLOPT_ENCODING => '',
  457. CURLOPT_MAXREDIRS => 10,
  458. CURLOPT_TIMEOUT => 30,
  459. CURLOPT_FOLLOWLOCATION => true,
  460. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  461. CURLOPT_CUSTOMREQUEST => 'GET',
  462. CURLOPT_HTTPHEADER => array(
  463. 'DOLAPIKEY: '.$this->API_KEY
  464. ),
  465. ));
  466. $handles[$eventID] = $ch;
  467. curl_multi_add_handle($multiHandle, $ch);
  468. }
  469. $running = null;
  470. do {
  471. curl_multi_exec($multiHandle, $running);
  472. curl_multi_select($multiHandle);
  473. } while ($running > 0);
  474. $prices = [];
  475. foreach ($handles as $eventID => $ch) {
  476. $response = curl_multi_getcontent($ch);
  477. $menus = json_decode($response, true);
  478. $lowest = null;
  479. if (is_array($menus)) {
  480. foreach ($menus as $item) {
  481. if ($lowest === null || $item['price'] < $lowest) {
  482. $lowest = $item['price'];
  483. }
  484. }
  485. }
  486. $prices[$eventID] = $lowest !== null ? formatize::currency(round($lowest)) : '';
  487. curl_multi_remove_handle($multiHandle, $ch);
  488. curl_close($ch);
  489. }
  490. curl_multi_close($multiHandle);
  491. return $prices;
  492. }
  493. public function getEventsData($groupID, $lang = 'hu') {
  494. $parentID = $this->getGroupID($groupID);
  495. $rows = $this->query("SELECT * FROM `azonics_events` WHERE box_status=1 AND parent_service=".$parentID.";");
  496. if (empty($rows)) {
  497. return [];
  498. }
  499. // 1) Egyetlen API hívás az összes event date-hez (N cURL → 1 cURL)
  500. $allEventsByKey = $this->getAllEventsListByGroup($groupID);
  501. // 2) Egyetlen DB query az összes image-hez (N query → 1 query)
  502. $boxIds = [];
  503. foreach ($rows as $row) {
  504. $boxIds[] = $row->box_id;
  505. }
  506. $allImages = $this->query("SELECT * FROM `azonics_events_blocks` WHERE block_status=1 AND box_id IN (".implode(',', $boxIds).");");
  507. $imagesByBoxId = [];
  508. foreach ($allImages as $img) {
  509. $imagesByBoxId[$img->box_id][] = $img;
  510. }
  511. // 3) Párhuzamos menu API hívások az árakhoz (N szekvenciális → N párhuzamos cURL)
  512. $eventIDs = [];
  513. foreach ($rows as $row) {
  514. $eventIDs[] = $row->parent_event;
  515. }
  516. $lowestPrices = $this->fetchLowestPrices($eventIDs);
  517. $results = [];
  518. foreach ($rows as $row) {
  519. $row->parent_price = isset($lowestPrices[$row->parent_event]) ? $lowestPrices[$row->parent_event] : '';
  520. $row->images = isset($imagesByBoxId[$row->box_id]) ? $imagesByBoxId[$row->box_id] : [];
  521. $row->dates = isset($allEventsByKey[$row->parent_event]) ? [$allEventsByKey[$row->parent_event]] : [];
  522. if ($lang == 'en') {
  523. $row->box_title = $row->box_title_en;
  524. $row->box_subtitle = $row->box_subtitle_en;
  525. }
  526. if (count($row->dates) < 1) {
  527. continue;
  528. }
  529. $results[] = $row;
  530. }
  531. return $results;
  532. }
  533. public function getEventMenus($eventID, $lang = 'hu') {
  534. $rows = $this->query("SELECT * FROM `azonics_packages` WHERE box_status=1 AND parent_event=".$eventID." ORDER BY box_order ASC;");
  535. $menus = $this->getMenusList($eventID);
  536. foreach ($rows as $row) {
  537. $images = $this->query("SELECT * FROM `azonics_package_blocks` WHERE block_status=1 AND box_id=".$row->box_id.";");
  538. $row->images = $images;
  539. foreach ($menus as $menu) {
  540. if ($menu['id'] == $row->parent_menu) {
  541. $row->parent_price = $menu['price'];
  542. }
  543. }
  544. if ($lang == 'en') {
  545. $row->box_title = $row->box_title_en;
  546. $row->box_subtitle = $row->box_subtitle_en;
  547. }
  548. if (count($images) > 0) {
  549. $results[] = $row;
  550. }
  551. }
  552. return $results;
  553. }
  554. public function getEventName($groupID, $eventID) {
  555. $row = $this->query("SELECT * FROM `azonics_events` WHERE box_status=1 AND parent_service=".$groupID." AND parent_event=".$eventID.";");
  556. return $row[0]->box_title;
  557. }
  558. public function getEventsRawList() {
  559. $rows = $this->query("SELECT * FROM `azonics_events` WHERE box_status=1;");
  560. return $rows;
  561. }
  562. public function getProductsData($groupID, $lang = 'hu') {
  563. $items = $this->getProductsList($groupID);
  564. $rows = $this->query("SELECT * FROM `azonics_prods` WHERE box_status=1 AND parent_service=".$groupID.";");
  565. foreach ($rows as $row) {
  566. $images = $this->query("SELECT * FROM `azonics_prods_blocks` WHERE block_status=1 AND box_id=".$row->box_id.";");
  567. $row->images = $images;
  568. $row->items = $items[$row->parent_prods]['products'];
  569. if ($lang == 'en') {
  570. $row->box_title = $row->box_title_en;
  571. $row->box_subtitle = $row->box_subtitle_en;
  572. }
  573. $results[] = $row;
  574. }
  575. return $results;
  576. }
  577. public function getContent($slug, $lang = 'hu') {
  578. $row = $this->query("SELECT * FROM `azonics_blog` WHERE page_status=1 AND page_slug='".$slug."';");
  579. if ($lang == 'en') {
  580. $row[0]->page_title = $row[0]->page_title_en;
  581. $row[0]->page_content = $row[0]->page_content_en;
  582. }
  583. return $row[0];
  584. }
  585. public function getUID() {
  586. $curl = curl_init();
  587. curl_setopt_array($curl, array(
  588. CURLOPT_URL => $this->API.'/affiliateapi/init',
  589. CURLOPT_RETURNTRANSFER => true,
  590. CURLOPT_ENCODING => '',
  591. CURLOPT_MAXREDIRS => 10,
  592. CURLOPT_TIMEOUT => 0,
  593. CURLOPT_FOLLOWLOCATION => true,
  594. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  595. CURLOPT_CUSTOMREQUEST => 'GET',
  596. CURLOPT_HTTPHEADER => array(
  597. 'DOLAPIKEY: '.$this->API_KEY
  598. ),
  599. ));
  600. $response = curl_exec($curl);
  601. curl_close($curl);
  602. return $response;
  603. }
  604. public function reserveEvent($uuid, $eventID, $qty) {
  605. $curl = curl_init();
  606. $post_data = array('uuid' => $uuid, 'event_id' => $eventID, 'qty' => $qty);
  607. curl_setopt_array($curl, array(
  608. CURLOPT_URL => $this->API.'/affiliateapi/reserve',
  609. CURLOPT_RETURNTRANSFER => true,
  610. CURLOPT_ENCODING => '',
  611. CURLOPT_MAXREDIRS => 10,
  612. CURLOPT_TIMEOUT => 0,
  613. CURLOPT_FOLLOWLOCATION => true,
  614. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  615. CURLOPT_CUSTOMREQUEST => 'POST',
  616. CURLOPT_POSTFIELDS => json_encode($post_data),
  617. CURLOPT_HTTPHEADER => array(
  618. 'Content-Type:application/json',
  619. 'DOLAPIKEY: '.$this->API_KEY
  620. ),
  621. ));
  622. $response = curl_exec($curl);
  623. curl_close($curl);
  624. return json_decode($response);
  625. }
  626. public function getAllHotels() {
  627. $curl = curl_init();
  628. $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1';
  629. curl_setopt_array($curl, array(
  630. CURLOPT_URL => $url,
  631. CURLOPT_RETURNTRANSFER => true,
  632. CURLOPT_ENCODING => '',
  633. CURLOPT_MAXREDIRS => 10,
  634. CURLOPT_TIMEOUT => 0,
  635. CURLOPT_FOLLOWLOCATION => true,
  636. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  637. CURLOPT_CUSTOMREQUEST => 'GET',
  638. CURLOPT_HTTPHEADER => array(
  639. 'DOLAPIKEY: '.$this->API_KEY
  640. ),
  641. ));
  642. $response = curl_exec($curl);
  643. curl_close($curl);
  644. $groups = [];
  645. $response = json_decode($response, true);
  646. foreach ($response as $key => $value) {
  647. if ($allHotels === false ) {
  648. if ($value['contracted_partner'] == 1) {
  649. $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']);
  650. }
  651. }
  652. else if ($allHotels === true) {
  653. $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']);
  654. }
  655. }
  656. return $options;
  657. }
  658. public function getAllPartner() {
  659. $curl = curl_init();
  660. $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1';
  661. curl_setopt_array($curl, array(
  662. CURLOPT_URL => $url,
  663. CURLOPT_RETURNTRANSFER => true,
  664. CURLOPT_ENCODING => '',
  665. CURLOPT_MAXREDIRS => 10,
  666. CURLOPT_TIMEOUT => 0,
  667. CURLOPT_FOLLOWLOCATION => true,
  668. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  669. CURLOPT_CUSTOMREQUEST => 'GET',
  670. CURLOPT_HTTPHEADER => array(
  671. 'DOLAPIKEY: '.$this->API_KEY
  672. ),
  673. ));
  674. $response = curl_exec($curl);
  675. curl_close($curl);
  676. $groups = [];
  677. $response = json_decode($response, true);
  678. foreach ($response as $key => $value) {
  679. $options[] = array('id' => $value['id'], 'key' => $key, 'value' => $value['label'], 'partner' => $value['contracted_partner']);
  680. }
  681. return $options;
  682. }
  683. public function getAllContractedPartner() {
  684. $curl = curl_init();
  685. $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1';
  686. curl_setopt_array($curl, array(
  687. CURLOPT_URL => $url,
  688. CURLOPT_RETURNTRANSFER => true,
  689. CURLOPT_ENCODING => '',
  690. CURLOPT_MAXREDIRS => 10,
  691. CURLOPT_TIMEOUT => 0,
  692. CURLOPT_FOLLOWLOCATION => true,
  693. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  694. CURLOPT_CUSTOMREQUEST => 'GET',
  695. CURLOPT_HTTPHEADER => array(
  696. 'DOLAPIKEY: '.$this->API_KEY
  697. ),
  698. ));
  699. $response = curl_exec($curl);
  700. curl_close($curl);
  701. $groups = [];
  702. $response = json_decode($response, true);
  703. foreach ($response as $key => $value) {
  704. if ($value['contracted_partner'] == 1) {
  705. $options[] = array('id' => $value['id'], 'key' => $key, 'value' => $value['label'], 'partner' => $value['contracted_partner']);
  706. }
  707. }
  708. return $options;
  709. }
  710. public function getHotels($allHotels = false) {
  711. $curl = curl_init();
  712. $url = $this->API.'/affiliateapi/getAllHotels?givePartnerData=1';
  713. curl_setopt_array($curl, array(
  714. CURLOPT_URL => $url,
  715. CURLOPT_RETURNTRANSFER => true,
  716. CURLOPT_ENCODING => '',
  717. CURLOPT_MAXREDIRS => 10,
  718. CURLOPT_TIMEOUT => 0,
  719. CURLOPT_FOLLOWLOCATION => true,
  720. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  721. CURLOPT_CUSTOMREQUEST => 'GET',
  722. CURLOPT_HTTPHEADER => array(
  723. 'DOLAPIKEY: '.$this->API_KEY
  724. ),
  725. ));
  726. $response = curl_exec($curl);
  727. curl_close($curl);
  728. $groups = [];
  729. $response = json_decode($response, true);
  730. foreach ($response as $key => $value) {
  731. if ($allHotels === false ) {
  732. if ($value['contracted_partner'] == 1) {
  733. $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']);
  734. }
  735. }
  736. else if ($allHotels === true) {
  737. $options[] = array('key' => 'hotel_'.$key, 'value' => $value['label'], 'partner' => $value['contracted_partner']);
  738. }
  739. }
  740. return $options;
  741. }
  742. public function checkout($data) {
  743. $curl = curl_init();
  744. curl_setopt_array($curl, array(
  745. CURLOPT_URL => $this->API.'/affiliateapi/order',
  746. CURLOPT_RETURNTRANSFER => true,
  747. CURLOPT_ENCODING => '',
  748. CURLOPT_MAXREDIRS => 10,
  749. CURLOPT_TIMEOUT => 0,
  750. CURLOPT_FOLLOWLOCATION => true,
  751. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  752. CURLOPT_CUSTOMREQUEST => 'POST',
  753. CURLOPT_POSTFIELDS => json_encode($data),
  754. CURLOPT_HTTPHEADER => array(
  755. 'Content-Type:application/json',
  756. 'DOLAPIKEY: '.$this->API_KEY
  757. ),
  758. ));
  759. $response = curl_exec($curl);
  760. curl_close($curl);
  761. return json_decode($response);
  762. }
  763. public function getCountries() {
  764. $curl = curl_init();
  765. curl_setopt_array($curl, array(
  766. CURLOPT_URL => $this->API.'/setup/dictionary/countries?sortfield=code&sortorder=ASC&limit=3000',
  767. CURLOPT_RETURNTRANSFER => true,
  768. CURLOPT_ENCODING => '',
  769. CURLOPT_MAXREDIRS => 10,
  770. CURLOPT_TIMEOUT => 0,
  771. CURLOPT_FOLLOWLOCATION => true,
  772. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  773. CURLOPT_CUSTOMREQUEST => 'GET',
  774. CURLOPT_HTTPHEADER => array(
  775. 'DOLAPIKEY: '.$this->API_KEY
  776. ),
  777. ));
  778. $response = curl_exec($curl);
  779. curl_close($curl);
  780. $options = [];
  781. $response = json_decode($response, true);
  782. if (is_array($response)) {
  783. usort($response, function($a, $b) {
  784. $la = isset($a['label']) ? mb_strtolower($a['label'], 'UTF-8') : '';
  785. $lb = isset($b['label']) ? mb_strtolower($b['label'], 'UTF-8') : '';
  786. return $la <=> $lb;
  787. });
  788. }
  789. foreach ($response as $value) {
  790. $options[] = array('key' => $value['id'].'_'.$value['code'], 'value' => $value['label']);
  791. }
  792. return $options;
  793. }
  794. public function getPaymentStatus($uuid) {
  795. $curl = curl_init();
  796. curl_setopt_array($curl, array(
  797. CURLOPT_URL => $this->API.'/affiliateapi/paymentstatus?uuid='.$uuid,
  798. CURLOPT_RETURNTRANSFER => true,
  799. CURLOPT_ENCODING => '',
  800. CURLOPT_MAXREDIRS => 10,
  801. CURLOPT_TIMEOUT => 0,
  802. CURLOPT_FOLLOWLOCATION => true,
  803. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  804. CURLOPT_CUSTOMREQUEST => 'GET',
  805. CURLOPT_HTTPHEADER => array(
  806. 'DOLAPIKEY: '.$this->API_KEY
  807. ),
  808. ));
  809. $response = curl_exec($curl);
  810. curl_close($curl);
  811. $response = json_decode($response, true);
  812. return $response;
  813. }
  814. public function getTransactionStatusFromSimplePay($uuid) {
  815. $curl = curl_init();
  816. curl_setopt_array($curl, array(
  817. CURLOPT_URL => $this->API.'/affiliateapi/getTransactionStatusFromSimplePay?uuid='.$uuid,
  818. CURLOPT_RETURNTRANSFER => true,
  819. CURLOPT_ENCODING => '',
  820. CURLOPT_MAXREDIRS => 10,
  821. CURLOPT_TIMEOUT => 0,
  822. CURLOPT_FOLLOWLOCATION => true,
  823. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  824. CURLOPT_CUSTOMREQUEST => 'GET',
  825. CURLOPT_HTTPHEADER => array(
  826. 'DOLAPIKEY: '.$this->API_KEY
  827. ),
  828. ));
  829. $response = curl_exec($curl);
  830. curl_close($curl);
  831. $response = json_decode($response, true);
  832. return $response;
  833. }
  834. public function validateUUID($uuid) {
  835. $curl = curl_init();
  836. curl_setopt_array($curl, array(
  837. CURLOPT_URL => $this->API.'/affiliateapi/CheckUUIDValidation?uuid='.$uuid,
  838. CURLOPT_RETURNTRANSFER => true,
  839. CURLOPT_ENCODING => '',
  840. CURLOPT_MAXREDIRS => 10,
  841. CURLOPT_TIMEOUT => 0,
  842. CURLOPT_FOLLOWLOCATION => true,
  843. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  844. CURLOPT_CUSTOMREQUEST => 'GET',
  845. CURLOPT_HTTPHEADER => array(
  846. 'DOLAPIKEY: '.$this->API_KEY
  847. ),
  848. ));
  849. $response = curl_exec($curl);
  850. print_r($response);
  851. die();
  852. curl_close($curl);
  853. $response = json_decode($response, true);
  854. return $response;
  855. }
  856. public function authenticateUser($username, $password) {
  857. // Look the user up by identity only; the password is verified in PHP
  858. // so we can support hashed passwords (and legacy plaintext during migration).
  859. $username = $this->escapeString($username);
  860. $row = $this->query("SELECT * FROM `azonics_admin_users` WHERE (admin_email='".$username."' OR admin_name='".$username."') AND admin_status='1';");
  861. if (count($row) == 0 || !admin_utils::verifyPassword($password, $row[0]->admin_pass)) {
  862. return ['success' => false];
  863. }
  864. else {
  865. // Upgrade legacy plaintext passwords to a proper hash on first valid login.
  866. if (admin_utils::passwordNeedsRehash($row[0]->admin_pass)) {
  867. $newHash = admin_utils::hashPassword($password);
  868. $this->execute("UPDATE `azonics_admin_users` SET admin_pass='".$this->escapeString($newHash)."' WHERE admin_id='".$row[0]->admin_id."';");
  869. }
  870. return [
  871. 'success' => true,
  872. 'name' => $row[0]->admin_name,
  873. 'hotel' => $row[0]->admin_dashboard
  874. ];
  875. }
  876. }
  877. public function getMonthRevenue($hotelIDs, $actualMonth = 0) {
  878. $curl = curl_init();
  879. $postfix = '';
  880. if ($actualMonth == 1) {
  881. $postfix = '&actualMonth='.$actualMonth;
  882. }
  883. curl_setopt_array($curl, array(
  884. CURLOPT_URL => $this->API.'/affiliateapi/getAmount?hotelids='.$hotelIDs.$postfix,
  885. CURLOPT_RETURNTRANSFER => true,
  886. CURLOPT_ENCODING => '',
  887. CURLOPT_MAXREDIRS => 10,
  888. CURLOPT_TIMEOUT => 0,
  889. CURLOPT_FOLLOWLOCATION => true,
  890. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  891. CURLOPT_CUSTOMREQUEST => 'GET',
  892. CURLOPT_HTTPHEADER => array(
  893. 'DOLAPIKEY: '.$this->API_KEY
  894. ),
  895. ));
  896. $response = curl_exec($curl);
  897. curl_close($curl);
  898. $result = json_decode($response);
  899. return $result;
  900. }
  901. public function createOrderDetails($data) {
  902. $this->execute("INSERT INTO `azonics_orders` SET
  903. order_uuid = '".$data['order_uuid']."',
  904. order_hotel = '".$data['order_hotel']."',
  905. order_sales = '".$data['order_sales']."',
  906. order_cart = '".serialize($data['order_cart'])."',
  907. order_customer_fname = '".$data['order_customer_fname']."',
  908. order_customer_lname = '".$data['order_customer_lname']."',
  909. order_customer_email = '".$data['order_customer_email']."',
  910. order_customer_city = '".$data['order_customer_city']."',
  911. order_customer_country = '".$data['order_customer_country']."',
  912. order_customer_zip = '".$data['order_customer_zip']."',
  913. order_customer_street = '".$data['order_customer_street']."',
  914. order_customer_house = '".$data['order_customer_house']."',
  915. order_customer_phone = '".$data['order_customer_phone']."',
  916. order_customer_hotel = '".$data['order_customer_hotel']."',
  917. order_customer_ip = '".$data['order_customer_ip']."',
  918. order_customer_browser = '".$data['order_customer_browser']."',
  919. order_terms_accepted = 1,
  920. order_status = 1;");
  921. return $this->getLastInsertID();
  922. }
  923. public function updateOrderDetails($data) {
  924. $this->execute("UPDATE azonics_orders SET
  925. order_transaction_id = '".$data['order_transaction_id']."',
  926. order_auth_code = '".$data['order_auth_code']."',
  927. order_error_code = '".$data['order_error_code']."',
  928. order_error_message = '".$data['order_error_message']."' WHERE order_id = '".$data['order_id']."';");
  929. return $data['order_id'];
  930. }
  931. public function getReports() {
  932. $hotels = $this->getAllPartner();
  933. $reports = [];
  934. $userData = unserialize($_SESSION['admin_user']->admin_dashboard);
  935. $ids = [];
  936. foreach ($userData as $hotelID) {
  937. foreach ($hotels as $hotel) {
  938. if ($hotel['key'] == $hotelID) {
  939. $ids[] = $hotel['id'];
  940. $reports[] = [
  941. 'id' => $hotel['id'],
  942. 'hotel' => $hotel['value'],
  943. 'actual_month' => '',
  944. 'last_month' => ''
  945. ];
  946. }
  947. }
  948. }
  949. $actualMonth = $this->getMonthRevenue(implode(',',$ids), 1);
  950. $lastMonth = $this->getMonthRevenue(implode(',',$ids), 0);
  951. foreach ($reports as $key => $report) {
  952. foreach ($actualMonth as $id => $item) {
  953. if ($id == $report['id']) {
  954. $reports[$key]['actual_month'] = $item;
  955. }
  956. }
  957. foreach ($lastMonth as $id => $item) {
  958. if ($id == $report['id']) {
  959. $reports[$key]['last_month'] = $item;
  960. }
  961. }
  962. }
  963. return $reports;
  964. }
  965. public function getPreviousUUID($uuid) {
  966. $uuid = $this->escapeString($uuid);
  967. $rows = $this->query("SELECT previous_uuid FROM `azonics_user_events`
  968. WHERE uuid = '".$uuid."' AND event_type = 'uuid_change'
  969. ORDER BY event_id DESC LIMIT 1;");
  970. if (count($rows) > 0 && !empty($rows[0]->previous_uuid)) {
  971. return $rows[0]->previous_uuid;
  972. }
  973. return '';
  974. }
  975. public function logUserEvent($data) {
  976. $uuid = $this->escapeString($data['uuid']);
  977. $event_type = $this->escapeString($data['event_type']);
  978. if ($event_type === 'uuid_change') {
  979. $previous_uuid = isset($data['previous_uuid']) ? $this->escapeString($data['previous_uuid']) : '';
  980. } else {
  981. $previous_uuid = $this->getPreviousUUID($data['uuid']);
  982. }
  983. $hotel = isset($data['hotel']) ? $this->escapeString($data['hotel']) : '';
  984. $order_id = isset($data['order_id']) ? $this->escapeString($data['order_id']) : '';
  985. $cart = isset($data['cart']) ? $this->escapeString(json_encode($data['cart'])) : '';
  986. $event_name = $this->escapeString($data['event_name']);
  987. $event_data = isset($data['data']) ? $this->escapeString(json_encode($data['data'])) : '';
  988. $page_url = isset($data['page_url']) ? $this->escapeString($data['page_url']) : '';
  989. $ip_address = $this->escapeString($_SERVER['REMOTE_ADDR']);
  990. $user_agent = $this->escapeString($_SERVER['HTTP_USER_AGENT'] ?? '');
  991. $this->execute("INSERT INTO `azonics_user_events` SET
  992. uuid = '".$uuid."',
  993. previous_uuid = '".$previous_uuid."',
  994. hotel = '".$hotel."',
  995. order_id = '".$order_id."',
  996. cart = '".$cart."',
  997. event_type = '".$event_type."',
  998. event_name = '".$event_name."',
  999. event_data = '".$event_data."',
  1000. page_url = '".$page_url."',
  1001. ip_address = '".$ip_address."',
  1002. user_agent = '".$user_agent."',
  1003. created_at = NOW();");
  1004. return $this->getLastInsertID();
  1005. }
  1006. public function getQRCodes($orderID) {
  1007. $curl = curl_init();
  1008. curl_setopt_array($curl, array(
  1009. CURLOPT_URL => $this->API.'/affiliateapi/getSaledItemsQR?sendid='.$orderID,
  1010. CURLOPT_RETURNTRANSFER => true,
  1011. CURLOPT_ENCODING => '',
  1012. CURLOPT_MAXREDIRS => 10,
  1013. CURLOPT_TIMEOUT => 0,
  1014. CURLOPT_FOLLOWLOCATION => true,
  1015. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  1016. CURLOPT_CUSTOMREQUEST => 'GET',
  1017. CURLOPT_HTTPHEADER => array(
  1018. 'DOLAPIKEY: '.$this->API_KEY
  1019. ),
  1020. ));
  1021. $response = curl_exec($curl);
  1022. curl_close($curl);
  1023. $groups = [];
  1024. $response = json_decode($response, true);
  1025. foreach ($response as $key => $item) {
  1026. $group = [];
  1027. $group['id'] = $key;
  1028. $group['label'] = $item;
  1029. $groups[] = $group;
  1030. }
  1031. //$data = json_encode($groups, true);
  1032. return $groups;
  1033. }
  1034. }