init
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
include_once 'core.php';
|
||||
include_once 'config.php';
|
||||
include_once 'project-model.php';
|
||||
include_once 'calendar_functions.php';
|
||||
// check_login();
|
||||
$error = false;
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Project'
|
||||
];
|
||||
// $config = MkdConfig::get_instance()->get_config();
|
||||
// $apikey = $config['gohighlevel_key'];
|
||||
// $cid = $_POST['calendar_id'];
|
||||
$pid = 412;
|
||||
// $pid = 169;
|
||||
$projectModel = new ProjectModel();
|
||||
$model = $projectModel->get((int)$pid);
|
||||
$apikey = $model->location;
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://rest.gohighlevel.com/v1/calendars/services",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "GET",
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Accept: application/json",
|
||||
"Authorization: Bearer " . $apikey,
|
||||
"Version: 2021-04-15"
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
$status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
// print_r($response);
|
||||
|
||||
if ($status_code != 200) {
|
||||
echo "Something went wrong.";
|
||||
exit;
|
||||
}
|
||||
|
||||
$cid = $model->calendar;
|
||||
$data = json_decode($response, true);
|
||||
|
||||
// Search for the service with the specified ID
|
||||
$searchedService = null;
|
||||
if (!empty($data['services']) && count($data['services'] ) > 0) {
|
||||
foreach ($data['services'] as $service) {
|
||||
if ($service['id'] === $cid) {
|
||||
$searchedService = $service;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($searchedService == null) {
|
||||
echo "Calendar Service with ID '" . $cid . "' not found.";
|
||||
}
|
||||
|
||||
$slots = json_decode($model->slot);
|
||||
try {
|
||||
echo checkServiceInSlot($searchedService["availability"]["officeHours"],
|
||||
$slots,
|
||||
$model,
|
||||
$searchedService["availability"]["eventTiming"],
|
||||
$searchedService["availability"]["schedule"],
|
||||
$searchedService["id"]);
|
||||
} catch (\Throwable $th) {
|
||||
echo "Something went wrong.";
|
||||
print_r($th);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user