api_model.php 36 KB

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