fb_client_id = "819012162367590"; $this->fb_redirect_url = $this->getvalue('fieldday_facebook_redirect', $fielddaySetting, false); $this->google_client = "743631987217-7bhocn53ich8cl9oe6d3in465o3d6set.apps.googleusercontent.com"; $this->google_redirect_url = $this->getvalue('fieldday_google_redirect', $fielddaySetting, false); $this->google_recaptcha_key = $this->getvalue('fieldday_google_recaptcha_id', $fielddaySetting, false); $this->google_recaptcha_secret = $this->getvalue('fieldday_google_recaptcha_secret', $fielddaySetting, false); $this->stripe_payment_mode = $this->getvalue('fieldday_payment_mode', $fielddaySetting, false); if ($this->stripe_payment_mode == 'yes') { $this->stripe_token = "pk_live_2PIp7ZDshJ5IXCiy0Wdtkl5q"; } else { $this->stripe_token = "pk_test_x2ptAQABuV51Jb80felkSj8q"; } } /** * get the session page filter options * @return array */ public function fielddayFilters() { return apply_filters('fieldday_session_filters', [ 'location' => __('Locations', 'fieldday'), 'search' => __('Search Input', 'fieldday'), 'activities' => __("Activities", 'fieldday'), 'types' => __("Types", 'fieldday'), 'bankdays' => __('Bank Days', 'fieldday'), 'month' => __("Month", 'fieldday'), 'age' => __("Age", 'fieldday'), ]); } /** * get the selected filters from database * @return array */ public function fielddaySelectedFilters() { global $fielddaySetting; $session_filters = $this->getValue('session_filters', $fielddaySetting, false); if (!$session_filters) { $session_filters = array_keys($this->fielddayFilters()); } return $session_filters; } /** * Display session filter output * @param string $filterKey * @param string $tagId session active tag * @param array $locations session locations * @param array $activityTags session tags * * @return string Html */ public function session_filter_output($filterKey, $tagId, $activityTags) { switch ($filterKey) { case 'search': return $this->searchInput(); break; case 'types': $activityTags = apply_filters('km_activity_tags', $activityTags); return $this->sessionActivityTags($tagId, $activityTags); break; case 'bankdays': return $this->filterBankDays(); break; case 'location': $locations = []; $locationsResponse = fieldday()->api->getProviderLocations(); if ($locationsResponse->statusCode == 200) { foreach ($locationsResponse->data as $key => $locationdata) { $locations[$locationdata->_id] = $locationdata->name; } } return $this->filterLocations($locations); break; case 'month': return $this->filterMonths(); break; case 'age': return $this->filterAge(); break; case 'type': return $this->filterType(); break; case 'activities': return $this->filterActivities(); break; default: break; } } /** * get the session filter html for Activity Tags * * @param string $tagId * @param array $activityTags * @return array */ private function sessionActivityTags($tagId, $activityTags) { return; } /** * Filter html for session tyoe i.e Camp or class * @return type Html */ private function filterType() { global $fielddaySetting; $activetheme = $this->getValue('fieldday_theme_mode', $fielddaySetting, false); } /** * Filter html for activities * @return type Html */ private function filterActivities() { global $fielddaySetting; $activetheme = $this->getValue('fieldday_theme_mode', $fielddaySetting, false); } /** * get the filter html for age filter * @return string Html */ private function filterAge() { global $fielddaySetting; $activetheme = $this->getValue('fieldday_theme_mode', $fielddaySetting, false); } /** * get the filter options for months * @return string Html */ private function filterMonths() { global $fielddaySetting; $activetheme = $this->getValue('fieldday_theme_mode', $fielddaySetting, false); } /** * Get the locations filter html * * @param array $locations session available locations array * @return string Html */ private function filterLocations($locations) { $options = ""; foreach ($locations as $location_id => $location) { $options .= wp_sprintf('', $location_id, $location); } return '
'; } /** * get the input text html for search input filter * @return string */ private function searchInput() { return '
'; } /** * get the filter options html for bank days * @return Html */ private function filterBankDays() { global $fielddaySetting; $activetheme = $this->getValue('fieldday_theme_mode', $fielddaySetting, false); } /** * get the data for bank days * @return Boolean */ public function GetBankDays() { $bankDays = fieldday()->api->getShoppingPackages(); if ($bankDays->data) { return true; } else {return false;} } /** * get the data for GiftCards * @return array */ public function GetGiftCards() { $giftOptions = fieldday()->api->getProviderGiftCards(); if ($giftOptions->data) {return true;} else {return false;} } public function displaySessionTabs($activityTypes) { $html = "
"; $html .= '"; $html .= "
"; $html .= "
"; $html .= ""; $html .= "
"; print $html; } /** * session booking types * * @return array session booking type parameters */ public function _sessionBookingTypes() { return [ 'oneDayKidRegistration' => [ 'lable' => __("One Day Only", "fieldday"), 'icon' => "oneday_icon.png", 'duration' => '/day', 'apikey' => 'fullDay', 'singlesessionkey' => 'oneDayDetails', ], 'morningKidRegistration' => [ 'lable' => __("Morning Only", "fieldday"), 'icon' => "morning_icon.png", 'duration' => '/day(Morning)', 'apikey' => 'halfDayMrng', 'singlesessionkey' => 'morningOnlyDetails', ], 'eveningKidRegistration' => [ 'lable' => __("Afternoon Only", "fieldday"), 'icon' => "afternoon_icon.png", 'duration' => '/day(Evening)', 'apikey' => 'halfDayEvng', 'singlesessionkey' => 'eveningOnlyDetails', ], 'weeklyKidRegistration' => [ 'lable' => __("Full Week", "fieldday"), 'icon' => "fullweek_icon.png", 'duration' => '', 'apikey' => 'price', 'singlesessionkey' => '', ], ]; } /** * * @return String Stripe token */ public function getStripeToken() { return $this->stripe_token; } /** * * @param string $type error type "error" "success" * @param string $message message to display * @return string Html message */ public function displayFlash($type, $message) { return "
$message
"; } /** * get the content from view file * @param String $viewname view file name * @param Array $data Data to send into view file * @throws ApiException on a non 2xx response * @return HTML */ public function getView($viewname, array $data = []) { if (!empty($data)) { foreach ($data as $key => $value) { $$key = $value; } } /* default variables in view */ global $KmUser; global $fielddaySetting; ob_start(); $viewpath = get_stylesheet_directory() . "/fieldday/{$viewname}.php"; $activetheme = $this->getValue('fieldday_theme_mode', $fielddaySetting, false); if (!file_exists($viewpath)) { $themeViewFile = fieldday_ABSPATH . "views/theme/{$activetheme}/{$viewname}.php"; if (file_exists($themeViewFile)) { $viewpath = $themeViewFile; } else { $viewpath = fieldday_ABSPATH . "views/{$viewname}.php"; } } require $viewpath; $html = ob_get_clean(); return $html; } /** * get the states * @param type $html get html or array * @return type mixed array of states of Html */ public function getStatesList($html = true) { $states = [ "AL" => __("Alabama", 'fieldday'), "AK" => __("Alaska", 'fieldday'), "AZ" => __("Arizona", 'fieldday'), "AR" => __("Arkansas", 'fieldday'), "CA" => __("California", 'fieldday'), "CO" => __("Colorado", 'fieldday'), "CT" => __("Connecticut", 'fieldday'), "DE" => __("Delaware", 'fieldday'), "DC" => __("District Of Columbia", 'fieldday'), "FL" => __("Florida", 'fieldday'), "GA" => __("Georgia", 'fieldday'), "HI" => __("Hawaii", 'fieldday'), "ID" => __("Idaho", 'fieldday'), "IL" => __("Illinois", 'fieldday'), "IN" => __("Indiana", 'fieldday'), "IA" => __("Iowa", 'fieldday'), "KS" => __("Kansas", 'fieldday'), "KY" => __("Kentucky", 'fieldday'), "LA" => __("Louisiana", 'fieldday'), "ME" => __("Maine", 'fieldday'), "MD" => __("Maryland", 'fieldday'), "MA" => __("Massachusetts", 'fieldday'), "MI" => __("Michigan", 'fieldday'), "MN" => __("Minnesota", 'fieldday'), "MS" => __("Mississippi", 'fieldday'), "MO" => __("Missouri", 'fieldday'), "MT" => __("Montana", 'fieldday'), "NE" => __("Nebraska", 'fieldday'), "NV" => __("Nevada", 'fieldday'), "NH" => __("New Hampshire", 'fieldday'), "NJ" => __("New Jersey", 'fieldday'), "NM" => __("New Mexico", 'fieldday'), "NY" => __("New York", 'fieldday'), "NC" => __("North Carolina", 'fieldday'), "ND" => __("North Dakota", 'fieldday'), "OH" => __("Ohio", 'fieldday'), "OK" => __("Oklahoma", 'fieldday'), "OR" => __("Oregon", 'fieldday'), "PA" => __("Pennsylvania", 'fieldday'), "RI" => __("Rhode Island", 'fieldday'), "SC" => __("South Carolina", 'fieldday'), "SD" => __("South Dakota", 'fieldday'), "TN" => __("Tennessee", 'fieldday'), "TX" => __("Texas", 'fieldday'), "UT" => __("Utah", 'fieldday'), "VT" => __("Vermont", 'fieldday'), "VA" => __("Virginia", 'fieldday'), "WA" => __("Washington", 'fieldday'), "WV" => __("West Virginia", 'fieldday'), "WI" => __("Wisconsin", 'fieldday'), "WY" => __("Wyoming", 'fieldday'), ]; if (!$html) { return apply_filters('fieldday_states_list', $states); } foreach ($states as $ID => $state) { print wp_sprintf("", $ID, $state); } } /** * return value for Class Package Renewal Frequency */ public function RenewalFrequencyCalc($validFor, $validForUnit) { if ($validFor == 1 && $validForUnit == 'months') { $period = "/month"; } else if ($validFor == 6 && $validForUnit == 'months') { $period = '/Quarter'; } else if ($validFor == 1 && $validForUnit == 'years') { $period = '/Year'; } else { $period = $validFor . ' ' . $validForUnit; } return $period; } /** * return value for Class Package Price */ public function CountPackagePrice($kidscount, $array = true, $renewal_freq = false) { $classPackages = fieldday()->api->getPackages(); $prices = array(); $packagepricelist = $classPackages->data; foreach ($packagepricelist->price as $key => $price) { $prices[$key] = $price; } if ($array) { return $prices; } else { if (isset($packagepricelist->price->$kidscount)) { $totalprice = $packagepricelist->price->$kidscount; $price = $this->display_price($totalprice); } else { $additionalcost = $packagepricelist->price->additionalSeatCost; $price_last = array_slice($prices, -2, 1, true); $key = key($price_last); $value = current($price_last); $additional_price = $additionalcost * ($kidscount - $key); $totalprice = $value + $additional_price; $price = $this->display_price($totalprice); /*if(isset($packagecalc)){ echo "exist"; $total_prices = count($prices); $no_of_prices = $total_prices-1; $seatprice = $packagepricelist->price->$no_of_prices; $totalkids = $kidscount-$no_of_prices; $extra_price = $totalkids*$additionalcost; $price = $extra_price+$seatprice; }*/ } if (isset($renewal_freq) && $renewal_freq == true) { $frequency = $this->RenewalFrequencyCalc($packagepricelist->validFor, $packagepricelist->validForUnit); $price = $price . $frequency; } return $price; } } /** * get value from array/object if set * * @param String $key * @param Mixed $Data * * return Mixed */ public function getValue($key, $Data, $print = true) { if (is_array($Data)) { if (array_key_exists($key, $Data)) { if ($print) { if (is_array($Data[$key])) { return $Data[$key]; } else { echo $Data[$key]; } } else { return $Data[$key]; } } } if (isset($Data->$key)) { if ($print) { echo $Data->$key; } else { return $Data->$key; } } return false; } /** * mask any string * * @param String $string * @param type $maskingCharacter * @return String */ private function ccMasking($string, $maskingCharacter = '*') { $length = strlen($string); $output = substr_replace($string, str_repeat($maskingCharacter, $length - 4), 0, $length - 4); return $output; } /** * get country dialcode * */ public function kmGetCountryDialCode() { global $KmUser, $fielddaySetting; $kmUserDialCode = '1'; // Default value if ($KmUser) { $kmUserDialCodeSettings = $this->getValue('fieldday_provider_dial_code', $fielddaySetting, false) ?? '1'; $kmUserDialCode = $this->getValue('countryCode', $KmUser, false) ?? $kmUserDialCodeSettings; if ($kmUserDialCodeSettings == '') {$kmUserDialCode = 1;} } elseif ($fielddaySetting) { $kmUserDialCode = $this->getValue('fieldday_provider_dial_code', $fielddaySetting, false) ?? '1'; if ($kmUserDialCodeSettings == '') {$kmUserDialCode = 1;} } return $kmUserDialCode; } /** * get country code * */ public function kmGetCountryCode() { global $KmUser, $fielddaySetting; $kmUserCountryCode = 'US'; // Default value if ($fielddaySetting) { $kmUserCountryCode = $this->getValue('fieldday_provider_country_code', $fielddaySetting, false) ?? 'US'; } return $kmUserCountryCode; } /** * hide email address partially * @param string $email * @return type */ public function emailMasking($email) { $em = explode("@", $email); $name = implode('@', array_slice($em, 0, count($em) - 1)); $len = floor(strlen($name) / 2); return substr($name, 0, $len) . str_repeat('*', $len) . "@" . end($em); } /* * get all month names * * @return Array */ public function KmMonths($key = null) { $months = [ '01' => __('Jan', 'fieldday'), '02' => __('Feb', 'fieldday'), '03' => __('Mar', 'fieldday'), '04' => __('Apr', 'fieldday'), '05' => __('May', 'fieldday'), '06' => __('Jun', 'fieldday'), '07' => __('Jul', 'fieldday'), '08' => __('Aug', 'fieldday'), '09' => __('Sep', 'fieldday'), '10' => __('Oct', 'fieldday'), '11' => __('Nov', 'fieldday'), '12' => __('Dec', 'fieldday'), ]; if ($key) { $intKey = $key + 1; $intKey = ($intKey < 10) ? "0" . $intKey : $intKey; return $this->getValue($intKey, $months, false); } return $months; } /** fieldday purchase form steps * @param Int $stepId form id to return single step * return Mixed */ public function Km_purchase_Steps($stepId = null) { $steps = [ 1 => ['name' => 'personal_information', 'classes' => 'km_active_step km_single_step personal_information', 'label' => $this->displayText('km_checkout_personal_info_lable', false)], 2 => ['name' => 'kid_information', 'classes' => 'km_single_step kid_information', 'label' => $this->displayText('km_checkout_kid_info_lable', false)], 3 => ['name' => 'purchase_details', 'classes' => 'km_single_step purchase_details', 'label' => $this->displayText('km_checkout_purchase_info_lable', false)], 4 => ['name' => 'purchase_confirmation', 'classes' => 'km_single_step purchase_confirmation', 'label' => $this->displayText('km_checkout_purchase_confirmation_lable', false)], ]; if ($stepId && array_key_exists($stepId, $steps)) { return $steps[$stepId]; } return $steps; } /** * get the kid information * @param array $kids * @return array Kids information */ public function getKids($kids = []) { $KidInformation = []; if (empty($kids)) { if (is_array($kids)) { $allkids = fieldday()->api->GetKids(); if ($allkids->statusCode == 200) { foreach ($allkids->data as $key => $kid) { $kidInfo = $this->getSingleKid($kid->_id); if ($kidInfo) { $KidInformation[] = $kidInfo; } } } } return $KidInformation; } else { foreach ($kids as $key => $kidId) { $kidInfo = $this->getSingleKid($kidId); if ($kidInfo) { $KidInformation[] = $kidInfo; } } } return $KidInformation; } /** * add new kid in fieldday * * @param array $profile profile data * @param array $forms * * @return mixed kid information object from fieldday API */ public function addNewKid(array $profile, array $forms = []) { /* add new kid */ if (trim($this->getValue('school', $profile, false) == '' || trim($this->getValue('school', $profile, false) == 'select'))) { unset($profile['school']); } $apiResponse = fieldday()->api->AddKid($profile); if ($apiResponse->statusCode !== 201) { return false; } $kidId = $apiResponse->data->_id; /* add forms */ if ($forms && $kidId) { if (array_key_exists('medicalInsurance', $forms)) { unset($forms['medicalInsurance']); } if (array_key_exists('dentalInsurance', $forms)) { unset($forms['dentalInsurance']); } $kidFormData = ['kidId' => $kidId, 'forms' => $forms]; fieldday()->api->SaveMedicalForms($kidFormData); } return $apiResponse->data; } /** * check if forms are required or not * @param array $kidForms */ public function isParticipantFormRequired($kidForms) { $totalForms = null; foreach ($kidForms as $key => $value) { if ($value === true) { $totalForms = $totalForms + 1; } } return $totalForms; } /** * * @param String $kidId kid Id * * @return Mixed Single kid infomation object */ public function getSingleKid($kidId) { /* get info from cookie */ $kids_from_cookie = $this->getCookieStorage('km_saved_kids'); if (array_key_exists($kidId, $kids_from_cookie) && preg_match("/new_kid_/", $kidId)) { $kidInfo = new stdClass; $kidInfo->_id = $kidId; $kidProfile = $kids_from_cookie->$kidId; $schoolId = isset($kidProfile->school->_id) ? $kidProfile->school->_id : null; if ($schoolId) { $schoolresponse = fieldday()->api->getSchoolInfo($schoolId); if ($schoolresponse->statusCode === 200) { $kidProfile->school = $schoolresponse->data; } } $kidInfo->kidProfile = $kidProfile; return $kidInfo; } else { $response = $this->kidAllDetail($kidId); return $response; } return false; } /** * * @param String $kidId kid Id * * @return Mixed Single kid infomation object */ private function kidAllDetail($kidId) { $response = fieldday()->api->GetKidDetail($kidId); $insurance = fieldday()->api->GetInsurance(); if ($response->statusCode === 200) { if ($insurance->statusCode === 200) { $response->data->dentalInsurance = $insurance->data->dentalInsurance; $response->data->medicalInsurance = $insurance->data->medInsurance; } return $response->data; } } /** * create array of unique kids to fill the unique data in medical forms * * @return mixed mixed array of unique kids data with forms */ public function getUniqueKids() { $uniqueKids = []; $cartdata = $this->GetCartData(); //$cartdata = json_decode(json_encode($cartdata), true); foreach ($cartdata as $sess_key => $sessionItem) { $forms = []; //$session_info = $sessionItem['session_detail']; $sessionKidFormsValidation = $sessionItem->activityId->regFormValidations; //$sessionKidFormsValidation = $sessionItem['activityId']['regFormValidations']; $sessionItemKids = json_decode(json_encode($sessionItem->kidId), true); foreach ($sessionItemKids as $key => $kid) { $kidId = (array_key_exists('_id', $kid) && $kid['_id']) ? $kid['_id'] : $this->generateRandomId(16, 'new_kid_'); $uniqueKids[$kidId]['kidInfo'] = $kid; //Doctors $uniqueKids[$kidId]['forms']['kidsDoctors'] = $this->add_kidform_value('kidsDoctors', $uniqueKids[$kidId], $sessionKidFormsValidation); $uniqueKids[$kidId]['forms']['kidsDietRestricts'] = $this->add_kidform_value('kidsDietRestricts', $uniqueKids[$kidId], $sessionKidFormsValidation); //Medical $uniqueKids[$kidId]['forms']['kidsTreatments'] = $this->add_kidform_value('kidsTreatments', $uniqueKids[$kidId], $sessionKidFormsValidation); $uniqueKids[$kidId]['forms']['kidsSymptoms'] = $this->add_kidform_value('kidsSymptoms', $uniqueKids[$kidId], $sessionKidFormsValidation); //Allergies $uniqueKids[$kidId]['forms']['kidsFoodAllergies'] = $this->add_kidform_value('kidsFoodAllergies', $uniqueKids[$kidId], $sessionKidFormsValidation); $uniqueKids[$kidId]['forms']['kidsEnvironmentAllergies'] = $this->add_kidform_value('kidsEnvironmentAllergies', $uniqueKids[$kidId], $sessionKidFormsValidation); $uniqueKids[$kidId]['forms']['kidsMedicationAllergies'] = $this->add_kidform_value('kidsMedicationAllergies', $uniqueKids[$kidId], $sessionKidFormsValidation); //Insurance $uniqueKids[$kidId]['forms']['kidsMedicalInsurances'] = $this->add_kidform_value('kidsMedicalInsurances', $uniqueKids[$kidId], $sessionKidFormsValidation); $uniqueKids[$kidId]['forms']['kidsDentalInsurances'] = $this->add_kidform_value('kidsDentalInsurances', $uniqueKids[$kidId], $sessionKidFormsValidation); $uniqueKids[$kidId]['forms']['kidsHealthConcerns'] = $this->add_kidform_value('kidsHealthConcerns', $uniqueKids[$kidId], $sessionKidFormsValidation); } } //echo "
"; print_r($uniqueKids); echo "
"; return $uniqueKids; } /** * * @param String $key medical form key in Kid information from API * @param mixed $Kid kid information object from fieldday * @param mixed $sessionForms forms supported by session in session infor from fieldday API * @return boolean if form required or not */ private function add_kidform_value($key, $Kid, $sessionForms) { if (isset($sessionForms->$key) && $sessionForms->$key === true) { return true; } if (isset($Kid['forms']) && array_key_exists($key, $Kid['forms']) && $Kid['forms'][$key] === true) { return true; } return false; } /** * get facebook auth sacreen url * @param Array $params fieldday website redirect after login * @return String Facebook auth sacreen url * */ public function getFacebookAuthUrl($params = []) { $state = "facebook"; if ($params) { $state .= "_" . implode("_", $params); } $args = [ 'client_id' => $this->fb_client_id, 'redirect_uri' => $this->fb_redirect_url, 'response_type' => 'code', 'scope' => 'email', 'state' => $state, ]; return add_query_arg($args, 'https://www.facebook.com/dialog/oauth'); } /** * get google auth sacreen url * @param String $params extra parameters to send * @return String google auth sacreen url * */ public function getGooglekAuthUrl($params = []) { $state = "google"; if ($params) { $state .= "_" . implode("_", $params); } $args = [ 'client_id' => $this->google_client, 'redirect_uri' => $this->google_redirect_url, 'response_type' => 'code', 'scope' => 'email profile', 'state' => $state, ]; return add_query_arg($args, 'https://accounts.google.com/o/oauth2/auth'); } public function googleRecaptcha($captcha = null, $return = null) {if (!$captcha) {$captcha = 'g-recaptcha';} if ($return) { return $html = '
'; } else { echo wp_sprintf('
', $captcha, $captcha, $this->google_recaptcha_key); }} /** * * @param String $recaptcha google recaptcha code * * @return Array resposne from google */ public function recaptchaVerify($recaptcha) { $google_url = "https://www.google.com/recaptcha/api/siteverify"; $ip = $_SERVER['REMOTE_ADDR']; $url = add_query_arg(['secret' => $this->google_recaptcha_secret, 'response' => $recaptcha, 'remoteip' => $ip], $google_url); $results = wp_remote_get($url); if ($results['response']['code'] === 200) { return json_decode($results['body'], true); } return ['success' => false]; } /** * * @param Mixed $userData * * @return Int wordpress user id */ public function fielddayDoLogin($userData) { if (!isset($userData->_id)) { return false; } if ($userId = username_exists($userData->_id)) { wp_clear_auth_cookie(); /* update user meta */ update_user_meta($userId, 'km_user_data', $userData); $theUser = new WP_User($userId); $theUser->add_role(fieldday_ROLE); wp_set_current_user($userId); wp_set_auth_cookie($userId); return $userId; } else if ($userId = email_exists($userData->email)) { wp_clear_auth_cookie(); /* update user meta */ update_user_meta($userId, 'km_user_data', $userData); $theUser = new WP_User($userId); $theUser->add_role(fieldday_ROLE); wp_set_current_user($userId); wp_set_auth_cookie($userId); return $userId; } else { /* register a user with fieldday_user role */ //$userId = register_new_user($userData->_id, $userData->email); $userdata = array( 'user_login' => $userData->_id, 'user_pass' => $userData->_id, 'user_email' => $userData->email, ); $userId = wp_insert_user($userdata); if (!is_wp_error($userId)) { wp_clear_auth_cookie(); $this->UpdateWordpressUser($userId, $userData); wp_set_current_user($userId); wp_set_auth_cookie($userId); return $userId; } else { return false; } } } /** * login user in fieldday with facebook * @param String $code facebook code from auth login screen * @return Mixed */ public function fielddayFacebookLogin($code) { $data = [ 'clientId' => $this->fb_client_id, 'redirectUri' => $this->fb_redirect_url, 'code' => $code, ]; return fieldday()->api->LoginWithFacebook($data); } /** * login user with google * @param String $code google auth code * @return Mixed Response */ public function fielddayGoogleLogin($code) { $data = [ 'clientId' => $this->google_client, 'redirectUri' => $this->google_redirect_url, 'code' => $code, ]; return fieldday()->api->LoginWithGoogle($data); } /** * Update user data in wordpress database * * @param Int $userId wordpress inserted user * @param Array $userData * * @return Boolean response */ private function UpdateWordpressUser($userId, $userData) { $data = [ 'ID' => $userId, 'user_login' => $userData->_id, 'display_name' => $userData->name, 'role' => fieldday_ROLE, ]; wp_update_user($data); /* update user meta */ update_user_meta($userId, 'km_user_data', $userData); } /** * * @global type $fielddaySetting * @param type $redirect * @return String url */ public function LoginRedirect($redirect = false) { global $fielddaySetting; $page = array_key_exists('login_redirect', $fielddaySetting) ? $fielddaySetting['login_redirect'] : null; if ($page) { $pagelink = get_page_link($page); if (!$redirect) { return $pagelink; } return wp_redirect($redirect); } } /** * * @global type $fielddaySetting * @param type $redirect * @return String url */ public function ThankyouRedirect($redirect = false) { global $fielddaySetting; $page = array_key_exists('thankyou_page', $fielddaySetting) ? $fielddaySetting['thankyou_page'] : ''; if ($page && $page!='') { $isPageExists = get_post($page); $pagelink = get_page_link($page); if (!$redirect && $isPageExists) { return $pagelink; }else{ return ''; } return wp_redirect($redirect); }else{ return ''; } } /** * * @global type $fielddaySetting * @param type $redirect * @return String url */ public function myaccounyRedirect($redirect = false) { global $fielddaySetting; $page = array_key_exists('myaccount_redirect', $fielddaySetting) ? $fielddaySetting['myaccount_redirect'] : null; if ($page) { $pagelink = get_page_link($page); if (!$redirect) { return $pagelink; } return wp_redirect($redirect); } } /** * fieldday session register trigger * @param String $sessionId Session Id * @param String $tagId session Tag Id if one dayonly, morning only or weeklu etc * @param Date $sessionDate session onedayselected date only for one day session * @param Boolean $guest force to login or not * @param Date String $sessionDate session Date if one day session * * @return String javascript function to display login form or to register a session */ public function sessionRegister($sessionId = null, $tagId = null, $sessionDate = null, $guest = false, $sessionfeatured = null, $typevent = null) { if (!$this->isKmLogin() && $guest === false) { if ($typevent != 'multiweek' && isset($_SESSION['typeofuser'])) { return wp_sprintf('onclick="fieldday.registerSession(\'%s\', \'%s\', \'%s\', \'%s\')"', $sessionId, $tagId, $sessionDate, $sessionfeatured); } else { return wp_sprintf('data-session-id="%s" data-tag-id="%s" data-session-date="%s" onclick="fieldday.showAuthPopup(this, event)"', $sessionId, $tagId, $sessionDate, '', '', 'event'); } } else if ($sessionId && $guest === true) { return wp_sprintf('onclick="fieldday.registerSession(\'%s\', \'%s\', \'%s\',\'%s\')"', $sessionId, $tagId, $sessionDate, $sessionfeatured); } else { return wp_sprintf('onclick="fieldday.registerSession(\'%s\', \'%s\', \'%s\', \'%s\')"', $sessionId, $tagId, $sessionDate, $sessionfeatured); } //} //} } public function packageRegister($sessionId = null, $packageId = null, $guest = false) { if (!$this->isKmLogin() && $guest === false) { if (isset($_SESSION['typeofuser'])) { return wp_sprintf('onclick="fieldday.registerPackage(\'%s\',\'%s\')"', $sessionId, $packageId); } else { return wp_sprintf('data-session-id="%s" data-isguest="false" data-ispackage="true" onclick="fieldday.showAuthPopup(this, event)"', $sessionId, $packageId); } } else if ($sessionId && $guest === true) { return wp_sprintf('onclick="fieldday.registerPackage(\'%s\',\'%s\')"', $sessionId, $packageId); } else { return wp_sprintf('onclick="fieldday.registerPackage(\'%s\',\'%s\')"', $sessionId, $packageId); } } public function eventRegister($sessionId = null, $typevent = null, $guest = false) { if (!$this->isKmLogin() && $guest === false) { return wp_sprintf('onclick="fieldday.registerEvent(\'%s\',\'%s\')"', $sessionId, 'event'); /*******************AS PER THE REQUIREMENTS LOGIN PROCESS IS TO BE SKIPPED FOR QUICK PURCHASE************ */ /* if (isset($_SESSION['typeofuser'])) { return wp_sprintf('onclick="fieldday.registerEvent(\'%s\',\'%s\')"', $sessionId, 'event'); } else { return wp_sprintf('data-session-id="%s" data-type="%s" onclick="fieldday.showAuthPopup(this, event)"', $sessionId, 'event'); } */ } else if ($sessionId && $guest === true) { return wp_sprintf('onclick="fieldday.registerEvent(\'%s\',\'%s\')"', $sessionId, 'event'); } else { return wp_sprintf('onclick="fieldday.registerEvent(\'%s\',\'%s\')"', $sessionId, 'event'); } } public function sessionWaitList($sessionId = null, $tagId = null, $sessionDate = null, $guest = false, $sessionfeatured = null, $typevent = null) { if (!$this->isKmLogin() && $guest === false) { return wp_sprintf('data-session-id="%s" data-tag-id="%s" data-session-date="%s" onclick="fieldday.showAuthPopup(this, event)"', $sessionId, $tagId, $sessionDate, '', '', 'event'); } else { return wp_sprintf('onclick="fieldday.registerSession(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\')"', $sessionId, $tagId, $sessionDate, $sessionfeatured, 'waitlist'); } } public function InstallmentPopup($sessionId = null, $tagId = null, $sessionDate = null, $guest = false, $sessionfeatured = null) { print wp_sprintf('onclick="fieldday.InstallmentPlans(\'%s\', \'%s\', \'%s\', \'%s\')"', $sessionId, $tagId, $sessionDate, $sessionfeatured); } /** * * @param String $offerId shopping package ID * @param type $guest if guest user allow to continue as guest * * @return String click function and other related informations */ public function merchandiseRegister($offerId, $offername, $guest = false, $sessionfeatured = null) { if (!$this->isKmLogin() && $guest === false) { if (isset($_SESSION['typeofuser'])) { print wp_sprintf('onclick="fieldday.registermerchandise(\'%s\', \'%s\')"', $offerId, $offername); } else { print wp_sprintf('data-offer-id="%s" data-offer-name="%s" onclick="fieldday.showAuthPopup(this, event)"', $offerId, $offername); } } else { print wp_sprintf('onclick="fieldday.registermerchandise(\'%s\', \'%s\')"', $offerId, $offername); } } /** * if user is loggedin with fieldday role * @return boolean */ public function isKmLogin() { global $KmUser; if (is_user_logged_in() && current_user_can(fieldday_ROLE) && $KmUser) { return true; } return false; } /** * get the option list of all schools for select * @param Array $schoolInfo selected school id * @return String option html */ public function displaySchools($schoolInfo = []) { $ProviderSchools = fieldday()->api->getProviderSchools(); $selected = isset($schoolInfo->_id) ? $schoolInfo->_id : null; if ($ProviderSchools->statusCode == 200) { foreach ($ProviderSchools->data as $key => $schools) { $slect = $selected == $schools->_id ? "selected" : ''; print ""; } } } /** * * @param String $date full date string * * @return Date date in wordpress format */ public function parseDate($date, $format = 'Y-m-d') { if ($date) { return date($format, strtotime($date)); } } public function return_week($datee) { $duedt = explode("-", $datee); $date = mktime(0, 0, 0, $duedt[1], $duedt[2], $duedt[0]); $week = (int) date('W', $date); return $week; } /** * * @param String $date full date string * * @return Date date in wordpress format */ public function weeks_between($strtDate, $endDate) { // input dates of format yyyy-mm-dd between which you want to get number of weeks $start_date = new DateTime($strtDate); //$start_date = DateTime::createFromFormat("Y-m-d", $strtDate); //print_r($start_date); //echo $start_date->date; $end_date = new DateTime($endDate); //$end_date = DateTime::createFromFormat("Y-m-d", $endDate); //print_r($end_date); //echo $end_date->date; $start_year = $start_date->format("Y"); $end_year = $end_date->format("Y"); $start_month = $start_date->format("m"); $end_month = $end_date->format("m"); $week1 = $this->return_week($strtDate); $week2 = $this->return_week($endDate); $diff = $end_year - $start_year; if ($end_month < $start_month && $start_year != $end_year) { $week_diff = (52 * $diff - $week1) + $week2 + 1; return ($start_year == $end_year) ? $week_diff : abs($week_diff); } else { $week_diff = $week2 - $week1 + 1; return ($start_year == $end_year) ? $week_diff : abs($week_diff) + 52 * $diff; } } /** * * @param String $date full date string * * @return Time time in wordpress format */ public function parseTime($date) { if ($date) { return date(get_option('time_format'), strtotime($date)); } } /** * * @param mixed $session * * @return string session single image url */ public function getsessionImageUrl($session) { $sessionPhotoURL = $session->activityId->photosURL; return $sessionPhotoURL[0]->original; } /** * display session image * * @param mixed $session session data from fieldday API * * @return Html image tag with session Thumb url */ public function displaySessionThumb($session, $multiple = false, $return = false, $if_detailed_view_widget_page = false) { $sessionPhotoURL = isset($session->activityId->photosURL) ? $session->activityId->photosURL : []; $photoOriginal = null; if ($multiple) { $sessionPhotoURL[] = $session->sessionImage; $sessionPhotoURL = array_reverse($sessionPhotoURL); $class = count($sessionPhotoURL) > 1 ? "km_slick_theme km_slides" : ""; $html = "
"; if ($sessionPhotoURL) { foreach ($sessionPhotoURL as $photo) { if ($photo->original) { $html .= wp_sprintf('
%s
', $photo->original, $session->name, $session->name); } else { $html .= wp_sprintf('
', fieldday_PLACEHOLDER); } } } else { $html .= wp_sprintf('
', fieldday_PLACEHOLDER); } $html .= "
"; print $html; } else { $sessionPhotoURL = isset($session->sessionImage->original) ? $session->sessionImage->original : null; if ($sessionPhotoURL) { if ($return == true) { $html = '' . $session->name . ''; return $html; } else { print wp_sprintf('%s', $sessionPhotoURL, $session->name, $session->name); } } else { if ($return == true) { $html = '' . __('Field Day Placeholder') . ''; return $html; } else { print wp_sprintf('%s', fieldday_PLACEHOLDER, __('Field Day Placeholder'), __('Field Day Placeholder')); } } } } /** * * @param Object $session fieldday session object * * @return mixed array of imp session vars */ private function GetSessionVar($session) { $vars = [ 'activityType' => 'weekly', 'activityTitle' => 'Full Week', 'SeatsClass' => 'text-danger', ]; /* set activity type and title */ if ($this->getValue('oneDayType', $session, false) == 'halfDayEvng') { $vars['activityType'] = 'eveningonly'; $vars['activityTitle'] = 'Evening Only'; } elseif ($this->getValue('oneDayType', $session, false) == 'halfDayMrng') { $vars['activityType'] = 'morningonly'; $vars['activityTitle'] = 'Morning Only'; } elseif ($this->getValue('oneDayType', $session, false) == 'fullDay') { $vars['activityType'] = 'fullday'; $vars['activityTitle'] = 'Full Day'; } /* set activity type and title */ /* set seats availabilty class */ $availableSpots = $this->getValue('availableSpots', $session, false); if ($availableSpots > 10) { $vars['SeatsClass'] = "text-success"; } elseif ($availableSpots < 10 && $availableSpots > 5) { $vars['SeatsClass'] = "text-warning"; } /* set seats availabilty class */ return $vars; } /** * order confermation text */ public function getOrderConfirmationText() { print wp_sprintf('

%s

%s

', __('Order Confirmation', 'fieldday'), __('Take a minute to review everything below and make sure it all looks correct.', 'fieldday')); } /** * * @param String $textId Id for the string * @param Bolean $print print or return the value * @return String display filtered text */ public function displayText($textId, $print = true) { return $this->getValue($textId, $this->getLabelValues(), $print); } /** * * @param String $key cookie key * @param (boolen) $decode is return in decode or not. * @return mixed */ public function getCookieStorage($key, $decode = true) { $cookie = $this->getValue($key, $_COOKIE, false); if (!$cookie) { return []; } if ($decode) { return json_decode(stripslashes($cookie)); } return $cookie; } /** * * @param Int $length lenght of the generated Id * * @return String generated tring of give length */ public function generateRandomId($length = 16, $prefix = null) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = $prefix; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } /** * * @return cart sidepopup html */ public function GetCartView() { $item = ''; return $item; } /** * get the fieldday cart items * * @return array cart items */ public function GetCartData($completearray = false) { global $fielddaySetting;global $KmUser; $GcartId = fieldday()->engine->getCookieStorage('GcartId', false); $GparentId = fieldday()->engine->getCookieStorage('GparentId', false); $apicartitems = fieldday()->api->GetCartItemApi($GcartId, $GparentId); //print_r($apicartitems); if ($apicartitems->statusCode === 200) { if ($completearray) { return $cartDetails = $apicartitems->data; } else { return $cartDetails = $apicartitems->data->cartDetails; } } else { return []; } /*if (array_key_exists('km_cart_items', $_SESSION)) { if($KmUser){ foreach($_SESSION['km_cart_items'] as $key=>$value){ if(array_key_exists('Usertype', $_SESSION['km_cart_items'][$key])){ $_SESSION['removed_cart_items'][$key] = $value; unset($_SESSION['km_cart_items'][$key]); } } } return $_SESSION['km_cart_items']; } return [];*/ } /** * save item to cart * * @param array $item * @param string $cartKey cart item key to update existing item * * @return mixed cart items */ /* public function saveCartItem(array $item, $cartKey = null) { //notinuse $cartData = $this->GetCartData(); if (!$cartKey) { $cartKey = $this->generateRandomId(8); } $cartData[$cartKey] = $item; $_SESSION['km_cart_items'] = $cartData; return $cartData; }*/ /** * remove one item from cart * * @param String $itemKey cart item key to delete item * * @return mixed updated cart data */ /*public function removeCartItem($itemKey) { //notinuse $cartData = $this->GetCartData(); if (array_key_exists($itemKey, $cartData)) { unset($cartData[$itemKey]); } $_SESSION['km_cart_items'] = $cartData; return $cartData; }*/ /** * remove one item from cart * * @param String $itemKey cart item key to delete item * * @return mixed updated cart data */ public function getCartItem($itemKey) { $cartData = $this->GetCartData(); return $this->getValue($itemKey, $cartData, false); } /** * remove cart data * * @return mixed updated cart data */ /*public function removeCart() { $_SESSION['km_cart_items'] = []; }*/ /** * get form data saved in kid profile * * @param String $formtype * @param mixed $kid_data * * @return mixed kidformdata */ private function getKidFormData($formtype, $kid_data) { $mappedData = [ 'kidsDoctors' => 'doctors', 'kidsDietRestricts' => 'dietRestricts', 'kidsTreatments' => 'treatments', 'kidsSymptoms' => 'symptoms', 'kidsFoodAllergies' => 'foodAllergies', 'kidsEnvironmentAllergies' => 'environmentAllergies', 'kidsMedicationAllergies' => 'medicationAllergies', 'kidsMedicalInsurances' => 'medicalInsurance', 'kidsDentalInsurances' => 'dentalInsurance', 'kidsHealthConcerns' => 'healthConcerns', ]; if (array_key_exists($formtype, $mappedData)) { $objectkey = $mappedData[$formtype]; if (isset($kid_data->$objectkey) && !empty((array) $kid_data->$objectkey)) { return $kid_data->$objectkey; } } return false; } /** * generate the kid forms HTML * * @param mixed $kid_data kid information object * @param String $formtype * @param Int $kidNumber * @param String $modalId * * @return HTML form html */ public function kid_formpopup($kid_data, $formtype, $kidNumber, $modalId) { $wrapperId = $formtype . '_' . $kidNumber; $output = ''; return $output; } /** * * @param String $key Form key * * */ public function MedicalFormLable($key) { $defaults = [ 'kidsDoctors' => apply_filters('fieldday_doctor_form_lable', __('Doctors', 'fieldday')), 'kidsDietRestricts' => apply_filters('fieldday_dietrestrict_form_lable', __('Diet Restrictions', 'fieldday')), 'kidsTreatments' => apply_filters('fieldday_treatments_form_lable', __('Treatments', 'fieldday')), 'kidsSymptoms' => apply_filters('fieldday_symptoms_form_lable', __('Symptoms', 'fieldday')), 'kidsFoodAllergies' => apply_filters('fieldday_food_allergies_form_lable', __('Food Allergies', 'fieldday')), 'kidsEnvironmentAllergies' => apply_filters('fieldday_environment_allergies_form_lable', __('Environment Allergies', 'fieldday')), 'kidsMedicationAllergies' => apply_filters('fieldday_medication_allergies_form_lable', __('Medication Allergies', 'fieldday')), 'kidsMedicalInsurances' => apply_filters('fieldday_medical_insurance_form_lable', __('Medical Insurances', 'fieldday')), 'kidsDentalInsurances' => apply_filters('fieldday_dental_insurance_form_lable', __('Dental Insurances', 'fieldday')), 'kidsHealthConcerns' => apply_filters('fieldday_health_concerns_form_lable', __('Health Concerns', 'fieldday')), ]; if (array_key_exists($key, $defaults)) { return $defaults[$key]; } } /** * Display Kid doctor fields * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_doctor_form($wrapperId, $kidNumber, $kid_data) { $doctor_info = $this->getvalue('doctors', $kid_data, false); return $this->getview('medicalforms/kid_doctor_form', ['wrapperId' => $wrapperId, 'doctor_info' => $doctor_info, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data]); } /** * display health form * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_health_form($wrapperId, $kidNumber, $kid_data) { $kid_heathConcerns = $this->getvalue('healthConcerns', $kid_data, false); return $this->getview('medicalforms/kid_health_form', ['wrapperId' => $wrapperId, 'kid_heathConcerns' => $kid_heathConcerns, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data]); } /** * Display treatments fields * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_treatment_form($wrapperId, $kidNumber, $kid_data) { $kid_heathConcerns = $this->getvalue('healthConcerns', $kid_data, false); $kid_treatments = $this->getvalue('treatments', $kid_data, false); return $this->getview('medicalforms/kid_treatment_form', ['wrapperId' => $wrapperId, 'kidNumber' => $kidNumber, 'kid_treatments' => $kid_treatments, 'kid_heathConcerns' => $kid_heathConcerns, 'kid_data' => $kid_data]); } /** * Display symptoms form fields * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_symptoms_form($wrapperId, $kidNumber, $kid_data) { $kid_symptoms = $this->getvalue('symptoms', $kid_data, false); $extremelyReactive = $this->getvalue('extremelyReactive', $kid_symptoms, false); $mildSymptoms = $this->getvalue('extremelyReactive', $kid_symptoms, false); return $this->getview('medicalforms/symptoms_form', ['wrapperId' => $wrapperId, 'mildSymptoms' => $mildSymptoms, 'extremelyReactive' => $extremelyReactive, 'kidNumber' => $kidNumber, 'kid_symptoms' => $kid_symptoms, 'kid_data' => $kid_data]); } /** * Display food allergies form fields * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_food_allergies_form($wrapperId, $kidNumber, $kid_data) { $kid_food_allergies = $this->getvalue('foodAllergies', $kid_data, false); return $this->getview('medicalforms/food_allergies_form', ['wrapperId' => $wrapperId, 'kid_food_allergies' => $kid_food_allergies, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data]); } /** * Display environment allergies fields * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_environment_allergies_form($wrapperId, $kidNumber, $kid_data) { $kid_environment_allergies = $this->getvalue('environmentAllergies', $kid_data, false); return $this->getview('medicalforms/environment_allergies_form', ['wrapperId' => $wrapperId, 'kid_environment_allergies' => $kid_environment_allergies, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data]); } /** * display diet restricts form * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_diet_restricts_form($wrapperId, $kidNumber, $kid_data) { $kid_dietRestricts = $this->getvalue('dietRestricts', $kid_data, false); return $this->getview('medicalforms/diet_restricts_form', ['wrapperId' => $wrapperId, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data, 'kid_dietRestricts' => $kid_dietRestricts]); } /** * display medical allergies * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_medication_allergies_form($wrapperId, $kidNumber, $kid_data) { $kid_medication_allregies = $this->getvalue('medicationAllergies', $kid_data, false); return $this->getview('medicalforms/medication_allergies_form', ['wrapperId' => $wrapperId, 'kid_medication_allregies' => $kid_medication_allregies, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data]); } /** * display medical unsrance form fields * * @param String $wrapperId wraper Id genrated * @param type $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_medical_insurances_form($wrapperId, $kidNumber, $kid_data) { $insuranceData = []; return $this->getview('medicalforms/medical_insurances_form', ['wrapperId' => $wrapperId, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data]); } /** * dispay dental insurance fields * * @param String $wrapperId wraper Id genrated * @param Int $kidNumber * @param mixed $kid_data object of kid information from fieldday API * * @return HTML Html form fields */ private function __km_dental_insurances_form($wrapperId, $kidNumber, $kid_data) { $dentalInsuranceData = []; return $this->getview('medicalforms/dental_insurances_form', ['wrapperId' => $wrapperId, 'kidNumber' => $kidNumber, 'kid_data' => $kid_data]); } /** * * @param String $sessionId session id * * @return mixed session info object from fieldday API */ public function getsingleSession($sessionId, $date = null) { $params = []; if ($date) { $params['oneDaySelectedDate'] = $date; } $sessionInfo = fieldday()->api->getActivitySession($sessionId, $params); if ($sessionInfo->statusCode === 200) { return $sessionInfo->data; } } /** * Display the applied credit i.e Day credit or Dollar credit * * @param type $cartInfo */ public function getCreditApplied($cartInfo) { if ($cartInfo->isPerDayCredit === true) { return $cartInfo->storeCreditPaid . " Days"; } else { return $this->display_price($cartInfo->storeCreditPaid); } } /** * * @param mixed $cartItemDetail */ public function displayKidsOnCart($cartItemDetail) { if (array_key_exists('kids', $cartItemDetail)): print wp_sprintf("%s(s):", $this->displayText('km_kid_text', false)); foreach ($cartItemDetail['kids'] as $key => $kidInfo) { $kidDisplayName = $this->getValue('knownAs', $kidInfo, false); if ($kidDisplayName) { $kidDisplayName = $this->getValue('firstName', $kidInfo, false); } print wp_sprintf('%s', $kidDisplayName); } endif; } public function displayCartSessionName($cartItemDetail) { $sessionInfo = $cartItemDetail['session_detail']; print $sessionInfo->name; } /** * Display additional charges on cart page * * @param object $cartInfo Cart information with calculation API * * @return String Additional charges HTML */ public function displayAdditionalChargesOnCart($cartInfo) { $html = ""; $additionalCharges = $this->getValue('additionalChargeDetails', $cartInfo, false); if ($additionalCharges) { foreach ($additionalCharges as $key => $singleItem) { $html .= wp_sprintf("%s %s", $singleItem->title, $this->display_price($singleItem->price)); } } else { $html .= wp_sprintf("
%s
", __("Additional Charges-N/A", 'fieldday')); } print $html; } public function displayPurchaseTags($purcaseData) { $additionalCharges = $this->getValue('additionalChargeDetails', $purcaseData, false); $html = ""; if ($additionalCharges) { foreach ($additionalCharges as $key => $singleItem) { $html .= wp_sprintf("%s", $singleItem->title); } } $selectedCare = $this->getValue('extendedCareSelected', $purcaseData, false); if ($selectedCare) { if (array_key_exists($selectedCare, $this->extendedCareTypes())) { $html .= wp_sprintf("%s", $this->extendedCareTypes($selectedCare)); } } print $html; } /** * Display top nav on my account page * * @return print html */ public function displayAccountTopNav(array $data = []) { $html = $this->getView('account/accountnav', $data); print $html; } /** * * @param String $type Care type * * @return mixed array of care labels or single item lable */ public function extendedCareTypes($type = null) { $cares = [ 'earlyCare' => __("Early Drop", 'fieldday'), 'afterCare' => __("Late Pickup", 'fieldday'), 'combined' => __("Early Drop + Late Pickup", 'fieldday'), ]; if ($type) { return $this->getValue($type, $cares, false); } else { return $cares; } } /** * Display Extended care charges on cart page * * @param object $cartInfo Cart information with calculation API * * @return String extended care details HTML */ public function displayExtendedCareOnCart($cartInfo, $cartItemDetail) { //additionalChargeDetails $html = ""; $extendedCares = $this->getValue('extendedCareDetails', $cartItemDetail['session_detail'], false); $selectedCare = $this->getValue('extendedCareSelected', $cartInfo, false); $selectedCareData = $this->getValue($selectedCare, $extendedCares, false); if ($selectedCare) { if (array_key_exists($selectedCare, $this->extendedCareTypes())) { $html .= wp_sprintf("%s %s", $this->extendedCareTypes($selectedCare), $this->display_price($selectedCareData->pricePerSession)); } } else { $html .= wp_sprintf("
%s
", __("Extended Care charges-N/A", 'fieldday')); } print $html; } /** * Display formated price * * @param mixed $price price to format * * @return Float price string with symbol */ public function display_price($price) { if (is_float($price)) { return fieldday_CURRENCY . number_format($price, 2); } else { return fieldday_CURRENCY . number_format($price, 0); } } /** * * @param mixed $object * @param String $key * * @return HTML string if checked */ public function km_display_pop_checked($object, $key) { if (isset($object->$key) && $object->$key) { print 'value="true" checked'; } } /** * get terms and consitions * * @param array $queryOptions filter options * * @return String terms and conditions for that provider */ public function getProviderTerms($stepName, array $queryOptions = []) { $response = fieldday()->api->getActivityProviderTerms($queryOptions); $termsHtml = ""; if ($response->statusCode == 200) { foreach ($response->data as $key => $termData) { $termsHtml .= wp_sprintf("", $key, $termData->termId->_id); $termsHtml .= wp_sprintf('', $key); } } return $termsHtml; } /** * fieldday logout Url * * @return String Logout url */ public function kmLogoutUrl() { return wp_logout_url(apply_filters('fieldday_after_logout_url', home_url())); } /** * fieldday user menu * @param object $menu * * @return Html user menu html */ public function UserInMenuHtml() { global $KmUser; if ($KmUser) { $item = ''; return $item; } } /** * generate user menu HTML * @global type $KmUser * @return string */ public function userMenuHtml() { global $KmUser; global $fielddaySetting; $userDPStyleHeight = $fielddaySetting['fieldday_user_menu_height']; $userDPStyleWidth = $fielddaySetting['fieldday_user_menu_width']; if ($userDPStyleHeight || $userDPStyleWidth) { $userDPStyles = 'style="'; if ($userDPStyleHeight && $userDPStyleHeight != '') { $userDPStyles .= 'height:' . $userDPStyleHeight . 'px!important;'; } if ($userDPStyleWidth && $userDPStyleWidth != '') { $userDPStyles .= 'width:' . $userDPStyleWidth . 'px!important;'; } $userDPStyles .= '";'; } else { $userDPStyles = null; } $html = ''; $html .= '
'; $html .= $this->getfielddayUserDP('', $userDPStyles); $html .= ''; $html .= '
'; return $html; } /** * get user thumbnail * @global type $KmUser * * @return HTML user image html */ public function getfielddayUserDP($user = null, $image_styles = '') { global $KmUser; global $fielddaySetting; if ($user == null) { $user = $KmUser; } if (isset($user->profilePicURL->thumbnail) && $user->profilePicURL->thumbnail) { if ($image_styles) { return wp_sprintf('%s', $user->profilePicURL->thumbnail, $user->name, $image_styles); } else { return wp_sprintf('%s', $user->profilePicURL->thumbnail, $user->name); } } else { $initial = ""; if ($name = $this->getValue('name', $user, false)) { $words = explode(" ", $name); foreach ($words as $count => $w) { if ($count >= 2) { break; } $initial .= $w[0]; } } if ($image_styles) { return wp_sprintf("%s", $initial); } else { return wp_sprintf("%s", $initial); } } } /** * get the pic for kid * @param object $kidsInfo * * @return html user image */ public function getfielddayKidDP($kidsInfo) { if (isset($kidsInfo->profilePicURL->thumbnail) && $kidsInfo->profilePicURL->thumbnail) { return wp_sprintf('%s %s', $kidsInfo->profilePicURL->thumbnail, $kidsInfo->firstName, $kidsInfo->lastName); } else { $initial = substr($kidsInfo->firstName, 0, 1); if ($kidsInfo->firstName) { $initial .= substr($kidsInfo->lastName, 0, 1); } return wp_sprintf("%s", $initial); } } /** * Function for pagination * * @param integer $rowperpage The rowperpage * @param integer $currentPage The current page * @param object $pageInfo The page information * * @return string pagination html */ public function km_pagination($rowperpage, $currentPage, $pageInfo) { // calculate total pages $pagination = ' "; return $pagination; } /** * Function for pagination * * @param integer $rowperpage The rowperpage * @param integer $currentPage The current page * @param object $pageInfo The page information * * @return string pagination html */ public function km_global_pagination($rowperpage, $currentPage, $pageInfo) { // calculate total pages $pagination = ' "; return $pagination; } /** * filter function for discount popup before button html * @param array $discount filter function * @return string $html The html */ public function discount_before_button($discount) { $html = wp_sprintf('

%s

', __('Siblings discount!', 'fieldday')); $html .= wp_sprintf('

%s

', __('*This discount will be applied at checkout.', 'fieldday')); return $html; } /** * filter function for discount popup button html * @param array $discount filter function * @return string $html The html */ public function discount_button_text($discount) { $html = wp_sprintf('%s', __('Shop Now', 'fieldday')); return $html; } /** * filter function for discount popup after button html * @param array $discount filter function * @return string $html The html */ public function discount_after_button($discount) { $html = wp_sprintf('

%s

', __('terms and conditions apply', 'fieldday')); return $html; } /** * filter function for parents manage account note * * @return string $html html on account page for Parents note */ public function fieldday_before_account_text() { if (empty(fieldday()->engine->getCookieStorage('display_account_help', false))) { /* $html = wp_sprintf('
'); $html .= wp_sprintf(' '); $html .= wp_sprintf('%s', __('Manage your account and purchases by downloading the FieldDay Mobile App from the AppStore. We would like to invite you to use a more secure and user-friendly platform to locate and manage your activities.', 'fieldday')); $html .= wp_sprintf('
'); */ $html = ''; return $html; } } /** * display the active filters * @param type $sessions * @param type $filters * @return html */ public function session_filterinfo($sessions, $filters) { $activefilters = $this->getValue('filters', $filters, false); //unset($activefilters['activityId']); $filterText = ""; if ($activefilters) { $filterText .= "
"; $filterText .= wp_sprintf("%s", __("Active Filters", "fieldday")); $filterText .= "
"; foreach ($activefilters as $filterkey => $filter) { $filtername = $this->getFilterText($filterkey, $filter, $sessions); if ($filtername) { if ($filterkey == 'fromDate' || $filterkey == 'toDate') { $datefomet = str_replace(array('FromDate: ', 'ToDate: '), '', $filtername); $new_date = substr_replace($datefomet, '', 11, 11); // $filternames = date("d-m-Y", $new_date); $filterText .= wp_sprintf("%s X", $new_date, $filterkey); } else { $filterText .= wp_sprintf("%s X", $filtername, $filterkey); } } } $filterText .= "
"; $filterText .= "
"; } print $filterText; } /** * get the filter title * @param string $key * @param string $value * @return mixed */ private function getFilterText($key, $value, $sessions) { switch ($key) { case 'sessionId': $sessionInfo = $this->getsingleSession($value); if ($sessionInfo) { return __("Session: ", 'fieldday') . $sessionInfo->name; } break; case 'location': $locationstring = $this->getSessionLocations($sessions, $value); if ($locationstring) { return fieldday()->engine->getValue($key, fieldday()->engine->fielddayFilters(), false) . ": " . $locationstring; } break; case 'month': if ($value) { return fieldday()->engine->getValue($key, fieldday()->engine->fielddayFilters(), false) . ": " . $this->KmMonths($value); } break; case 'activityId': $activitystring = $this->getSessionActivity($sessions, $value); if ($activitystring) { return fieldday()->engine->getValue('activities', fieldday()->engine->fielddayFilters(), false) . ": " . $activitystring; } break; default: $label = fieldday()->engine->getValue($key, fieldday()->engine->fielddayFilters(), false); if ($label) {$label = $label . ": ";} if ($value && trim($value) != '') { return ucfirst(__($label, 'fieldday')) . $value; } break; } return false; } /** * * @param string $tabId * @param string $tagId * @param string $filters */ public function displaySessionList($tabId, $tagId, $filters, $permalink) { $activities = fieldday()->api->getProviderActivities(['sessionTypeTag' => $tabId]); if ($activities->statusCode != 200) { return $this->displayFlash('error', __($activities->message, 'fieldday')); } $html = ""; foreach ($activities->data as $key => $activity) { $filters['filters']['activityId'] = $activity->_id; //$filters['showAllSessions'] = 'true'; $sessions = fieldday()->api->GetProviderSessionsNew($filters); $html .= $this->getView('_sessionlist_part', ['activity' => $activity, 'sessions' => $sessions, 'permalink' => $permalink, 'filters' => $filters, 'tagId' => $tagId]); } return $html; } /** * get locations from session * @param mixed $sessions * @return string */ public function getSessionLocations($sessions, $key = false) { $locations = $sessions->data->locations; $searchLocation = []; foreach ($locations as $location) { if (!array_key_exists($location->_id, $searchLocation)) { $searchLocation[$location->_id] = wp_sprintf('%s, %s, %s', $location->name, $location->city, $location->state); } } if ($key) { return $this->getValue($key, $searchLocation, false); } return $searchLocation; } /** * get locations from session * @param mixed $sessions * @return string */ public function getSessionActivity($sessions, $key = false) { $activitys = $sessions->data->sessions; $searchactivitys = []; foreach ($activitys as $activity => $singlesessions) { foreach ($singlesessions->sessions as $singleactivitys => $singleactivity) { if (!array_key_exists($singleactivity->activityId->_id, $searchactivitys)) { $searchactivitys[$singleactivity->activityId->_id] = wp_sprintf('%s', $singleactivity->activityId->title); } } } if ($key) { return $this->getValue($key, $searchactivitys, false); } return $searchactivitys; } /** * display records count info * @param mixed $sessions * @param type $filters */ public function session_recordsinfo($sessions, $filters) { global $fielddaySetting; $activetheme = $this->getValue('fieldday_theme_mode', $fielddaySetting, false); if ($activetheme == "one_column_layout") { $location = $sessions->street . ", " . $sessions->city . ", " . $sessions->state . ", " . $sessions->country; return wp_sprintf('
%s %d %s %s.
', __('Displaying', 'fieldday'), count($sessions->sessions), __('record(s) in', 'fieldday'), $location); } elseif ($activetheme == "two_column_layout") { $activityTags = fieldday()->api->getActivityTagsCount(); $getActivities = fieldday()->api->getFeaturedActivities(); $tagTitle = "All Activities"; $tagId = $this->getValue('tagId', $filters, false); if (isset($filters['filters'])) { if (fieldday()->engine->getValue('activityId', $filters['filters'], false)) { foreach ($getActivities->data as $key => $activity) { if ($activity->_id === $filters['filters']['activityId']) { $tagTitle = $activity->title; } } } else { foreach ($activityTags->data as $key => $tag) { if ($tag->_id === $tagId) { $tagTitle = $tag->wpShowTitle ? $tag->wpShowTitle : $tag->title; } } } } elseif (!isset($filters['filters']) && !isset($filters['tagId'])) { $tagTitle = "All Activities"; } else { foreach ($activityTags->data as $key => $tag) { if ($tag->_id === $tagId) { $tagTitle = $tag->wpShowTitle ? $tag->wpShowTitle : $tag->title; } } } return wp_sprintf('%s %d %s %s.', __('Displaying', 'fieldday'), count($sessions->data->sessions), __('records in', 'fieldday'), $tagTitle); } elseif ($activetheme == "list_view") { $activityTags = fieldday()->api->getActivityTagsCount(); $getActivities = fieldday()->api->getFeaturedActivities(); $tagTitle = "All Activities"; $tagId = $this->getValue('tagId', $filters, false); $actvityfilterId = $this->getValue('actvityfilterId', $filters, false); if (isset($filters['filters'])) { if (fieldday()->engine->getValue('activityId', $filters['filters'], false)) { foreach ($getActivities->data as $key => $activity) { if ($activity->_id === $filters['filters']['activityId']) { $tagTitle = $activity->title; } } } else { foreach ($activityTags->data as $key => $tag) { if ($tag->_id === $tagId) { $tagTitle = $tag->wpShowTitle ? $tag->wpShowTitle : $tag->title; } } } } elseif (!isset($filters['filters']) && !isset($filters['tagId'])) { $tagTitle = "All Activities"; } else { foreach ($activityTags->data as $key => $tag) { if ($tag->_id === $tagId) { $tagTitle = $tag->wpShowTitle ? $tag->wpShowTitle : $tag->title; } } } return wp_sprintf('%s %d %s%s. ', __('Displaying', 'fieldday'), $sessions, __('records', 'fieldday'), $tagTitle); } } /** * display session type * * @param string $session_type * * @return html session days */ public function sessionServiceDays($session_type) { if ($session_type == 'weekly') { return __('for all days', 'fieldday'); } else { return __('Per Day', 'fieldday'); } } /** * * @param array $fieldAttributes * @param string $date */ public function fielddayDateField(array $fieldAttributes, $date = null, $sessionInfo = []) { if ($date) { $day = date('d', strtotime($date)); $month = date('m', strtotime($date)); $year = date('Y', strtotime($date)); } else { $day = 15; $month = 06; $year = date("Y", strtotime("-10 year")); } $fieldAttributes['class'] = "km_hidden_dob"; $attributes = ""; if ($sessionInfo) { $agefrom = $sessionInfo->activityId->ageRange->from; $ageto = $sessionInfo->activityId->ageRange->to; $attributes = "data-age-from='{$agefrom}' data-age-to='{$ageto}'"; } $inputAttributes = ""; foreach ($fieldAttributes as $attr_name => $att_value) { $inputAttributes .= " {$attr_name}='{$att_value}'"; } $fieldHtml = "
"; $fieldHtml .= wp_sprintf("", $inputAttributes); $fieldHtml .= wp_sprintf("", $this->_createOptions('days', $day)); $fieldHtml .= wp_sprintf("", $this->_createOptions('month', $month)); $fieldHtml .= wp_sprintf("", $this->_createOptions('year', $year)); $fieldHtml .= "
"; print $fieldHtml; } /** * * @param string $type * @param mixed $selected * @return Html options */ private function _createOptions($type, $selected) { $options = ""; switch ($type) { case 'days': $array = range(1, 31); foreach ($array as $key => $day) { $day = $day < 10 ? "0" . $day : $day; $select = $day == $selected ? "selected" : ""; $options .= wp_sprintf("", $select, $day, $day); } break; case 'month': $array = $this->KmMonths(); foreach ($array as $key => $month) { $select = $key == $selected ? "selected" : ""; $options .= wp_sprintf("", $select, $key, $month); } break; case 'year': $array = range(date("Y", strtotime("-89 year")), date('Y')); foreach ($array as $key => $year) { $select = $year == $selected ? "selected" : ""; $options .= wp_sprintf("", $select, $year, $year); } break; default: break; } return $options; } /** * * @param object $session session Data * */ public function sessionDays($session, $daysOfWeek = null) { if (!$daysOfWeek) { $daysOfWeek = $this->getValue('daysOfWeek', $session, false); } foreach ($this->_weekDays() as $dayNum => $weekday) { $activeClass = is_array($daysOfWeek) && in_array($dayNum, $daysOfWeek) ? "km_day_active km_secondary_bg" : ""; print wp_sprintf("
%s
", $weekday['name'], $activeClass, $weekday['initial']); } } /** * * day of a given date * */ public function dayofweek($d, $m, $y) { static $t = array(0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4); $y -= $m < 3; return ($y + $y / 4 - $y / 100 + $y / 400 + $t[$m - 1] + $d) % 7; } public function fullweeksessionDays($session) { $daysOfWeek = $this->getValue('daysOfWeek', $session, false); $fullweekactiveDays; foreach ($this->_weekDays() as $dayNum => $weekday) { $activeClass = in_array($dayNum, $daysOfWeek) ? $fullweekactiveDays++ : ""; } return $fullweekactiveDays; } public function eventDays($session) { $daysOfWeek = $this->getValue('daysOfWeek', $session, false); $activeDays; foreach ($this->_weekDays() as $dayNum => $weekday) { $activeClass = in_array($dayNum, $daysOfWeek) ? $dayNum : ''; $activeDays[] = $activeClass; } return $activeDays; } /** * * @param String $day * @return mixed */ private function _weekDays($day = null) { $days = [ ['name' => __("Sunday", 'fieldday'), 'initial' => 'Su', 'short' => 'Sun'], ['name' => __("Monday", 'fieldday'), 'initial' => 'M', 'short' => 'Mon'], ['name' => __("Tuesday", 'fieldday'), 'initial' => 'T', 'short' => 'Tue'], ['name' => __("Wednesday", 'fieldday'), 'initial' => 'W', 'short' => 'Wed'], ['name' => __("Thursday", 'fieldday'), 'initial' => 'Th', 'short' => 'Thur'], ['name' => __("Friday", 'fieldday'), 'initial' => 'F', 'short' => 'Fri'], ['name' => __("Saturday", 'fieldday'), 'initial' => 'S', 'short' => 'Sat'], ]; if ($day) { return array_key_exists($day, $days) ? $days[$day] : false; } return $days; } /** * display site location string * @param Array $session * * @return String location info */ public function getSiteLocation($session) { $location = $this->getValue('siteLocationId', $session, false); if (isset($session->isOnlineSession) && $session->isOnlineSession) { return wp_sprintf('

%s

', $location->name); } $street = $this->getValue('street', $location, false); $city = $this->getValue('city', $location, false); $state = $this->getValue('state', $location, false); $country = $this->getValue('country', $location, false); $pin = $this->getValue('pin', $location, false); return wp_sprintf('

%s, %s, %s %s, %s

', $street, $city, $state, $pin, $country); } /** * display Important Dates string * @param Array $session * @return string */ public function getImportantDates($session) { $importantdates = $this->getValue('importantDates', $session, false); return $importantdates; } /** * * @param mixed $session * @return string */ public function displaysessionReviews($session) { $reviews = $this->getValue('reviews', $session, false); $html = ""; if ($reviews) { $html .= '
'; foreach ($reviews as $key => $review) {$description = $this->getValue('description', $review, false); if ($description != '') { $html .= '
'; $html .= '

' . $this->getValue('description', $review, false) . '

' . $review->reviewBy->name . '
'; $html .= '
'; }} $html .= '
'; } return $html; } /** * display session rating * @param array $session */ public function sessionRating($session) { $sessionRating = (int) round($session->providerId->rating); $html = '
'; $html .= "
"; for ($index = 5; $index >= 1; $index--) {$rating_class = ''; if ($index <= $sessionRating) {$rating_class = 'km_fill';} $checked = $sessionRating == $index ? "checked" : "oops"; $html .= wp_sprintf('', $index, $checked, $sessionRating, $rating_class);} $html .= '
'; $html .= wp_sprintf("(%d star based on %d reviews)", $sessionRating, count($session->reviews)); $html .= '
'; print $html; } /** * * @param mixed $session * @param Array $tags available tags with their Id * return HTML */ public function sessionBookingTypes($session, $tags, $displayLable = true) { global $fielddaySetting; $html = '
'; $bookingTypesAvailable = $this->_sessionBookingTypes(); $purchasePage = get_permalink($this->getValue('purchase_page', $fielddaySetting, false)); foreach ($bookingTypesAvailable as $key => $bookingType) { if ($bookingArray = $this->getValue($key, $session, false)) { $lable = $bookingType['lable']; $tagId = $this->getValue($lable, $tags, false); $purchaseLink = add_query_arg(['tagId' => $tagId, '_id' => $session->_id], $purchasePage); $html .= wp_sprintf('
%s
', $lable, $purchaseLink, fieldday_URL, $bookingType['icon'], $displayLable ? $lable : ""); } } /* add weekly booking */ $purchaseLink = add_query_arg(['_id' => $session->_id], $purchasePage); $html .= wp_sprintf('
%s
', $bookingTypesAvailable['weeklyKidRegistration']['lable'], $purchaseLink, fieldday_URL, $bookingTypesAvailable['weeklyKidRegistration']['icon'], $displayLable ? $bookingTypesAvailable['weeklyKidRegistration']['lable'] : ""); $html .= '
'; return $html; } public function sessionBookingavail($session, $displayLable = true, $groupSessionListing = null) { global $fielddaySetting; $html =''; $bookingTypesAvailable = $this->_sessionBookingTypes(); $fullWeekPrice = null; /*if($is_single==true){ $fullWeekPrice = $this->getValue('price', $session->fullCampDetails, false); }else{*/ if (isset($session->oneDayType) && $session->oneDayType != 'fullDay') { $fullWeekPrice = $this->getValue('price', $session, false); } /*}*/ $oneDayDetails = $this->getValue('oneDayPrice', $session, false); if ($session->availableSpots > 0 || $groupSessionListing) { $html = ''; if (isset($fullWeekPrice) || $fullWeekPrice != 0) { $html .= wp_sprintf('%s', $this->display_price($fullWeekPrice)); } foreach ($bookingTypesAvailable as $key => $bookingType) { if ($bookingArray = $this->getValue($key, $session, false)) { $lable = $bookingType['lable']; $duration = $bookingType['duration']; $Pricekey = $bookingType['apikey']; if (isset($is_single) && $is_single == true) { $singlesessionkey = $bookingType['singlesessionkey']; $PriceValue = $this->getValue('price', $session->$singlesessionkey, false); } else { $PriceValue = $this->getValue($Pricekey, $oneDayDetails, false); } $html .= wp_sprintf('%s%s', $this->display_price($PriceValue), $duration); } } $html .= ''; } else { if (isset($session->oneDayType) && $session->oneDayType != 'fullDay') { $html = 'No Available Seats'; } } return $html; } public function CartbookingOptions($session) { // not in use: This function is not used anywhere in the website global $fielddaySetting; $html = ''; $bookingTypesAvailable = $this->_sessionBookingTypes(); //if($session->oneDayType!='fullDay'){ //$fullWeekPrice = $this->getValue('price', $session, false); //} $oneDayPrice = $this->getValue('oneDayPrice', $session, false); $days = $this->eventDays($session); $days_count = count(array_filter($days)); if (array($days)) { $days = implode(',', array_filter($days)); } $fullWeekPrice = $this->getValue('price', $session, false); $html .= '

What type of booking would you prefer? *

'; if ($fullWeekPrice) { $lable = $bookingTypesAvailable['weeklyKidRegistration']['lable']; $duration = $bookingTypesAvailable['weeklyKidRegistration']['duration']; //$Pricekey = $bookingTypesAvailable['weeklyKidRegistration']['apikey']; $fullWeekPrice = $this->getValue('price', $session, false); $html .= '
'; $html .= wp_sprintf('All Session Days', $days_count); $html .= '
'; } if ($this->getValue('oneDayKidRegistration', $session, false)) { $lable = $bookingTypesAvailable['oneDayKidRegistration']['lable']; $duration = $bookingTypesAvailable['oneDayKidRegistration']['duration']; $Pricekey = $bookingTypesAvailable['oneDayKidRegistration']['apikey']; $PriceValue = $this->getValue($Pricekey, $oneDayPrice, false); $html .= '
Drop-In'; } $html .= '
'; $html .= '
'; foreach ($bookingTypesAvailable as $key => $bookingType) { if ($bookingArray = $this->getValue($key, $session, false)) { $lable = $bookingType['lable']; $duration = $bookingType['duration']; $Pricekey = $bookingType['apikey']; $PriceValue = $this->getValue($Pricekey, $oneDayPrice, false); $html .= ''; } } $html .= '
'; $html .= '
'; $html .= '

What day(s) would you like to register for? *

Select Date
Done
'; return $html; } /** * * @param mixed $session Types Label * @param Array $tags available tags with their Id * return HTML */ public function sessionBookingTypesLable($session, $tags, $displayLable = true) { global $fielddaySetting; $html; $bookingTypesAvailable = $this->_sessionBookingTypes(); $purchasePage = get_permalink($this->getValue('purchase_page', $fielddaySetting, false)); foreach ($bookingTypesAvailable as $key => $bookingType) { if ($bookingArray = $this->getValue($key, $session, false)) { $lable = $bookingType['lable']; $html[] = $lable; } } /* add weekly booking */ $html[] = $bookingTypesAvailable['weeklyKidRegistration']['lable']; return $html; } /** * get session extended care options * @param mixed $session * @return boolean|string */ public function ExtendedCareOptions($session) { $extendedCareDetails = $this->getValue('extendedCareDetails', $session->fullCampDetails, false); $isAvailable = false; $html = "
"; if ($extendedCareDetails) { foreach ($extendedCareDetails as $chargetype => $charges) { if ($chargetype == 'afterCare' || $chargetype == 'earlyCare' || $chargetype == 'combined') { if ($this->getvalue('isAvailable', $extendedCareDetails, false)) { $isAvailable = true; $html .= wp_sprintf('%s', $this->extendedCareTypes($chargetype)); } } } } $html .= "
"; if ($isAvailable === false) { return false; } return $html; } /** * return session options * @param mixed $session * @return boolean|string */ public function sessionOtherOptions($session) { $additionalCharges = $this->getValue('additionalCharges', $session->fullCampDetails, false); if (!$additionalCharges) { return false; } $html = "
"; foreach ($additionalCharges as $key => $product) { $html .= wp_sprintf('%s', $product->title); } $html .= "
"; return $html; } private function ifKeyExists($array, $val) { foreach ($array as $item) { if (isset($item) && in_array($val, $item)) { return true; } } return false; } /** * display participants for add to cart */ public function fielddayCartParticipants($cartItem, $sessionInfo = null, $title = null, $logintitle = null) { if (!$title) { $title = "How many Participants you want to register?"; } if (!$logintitle) { $logintitle = "Select Participants to register?"; } if ($this->isKmLogin()) { $kidsresponse = fieldday()->api->GetKids(); //echo "
"; print_r($kidsresponse); echo "
"; if ($kidsresponse->statusCode === 200) { $html = wp_sprintf("

%s *

", __($logintitle, 'fieldday')); $html .= ""; $html .= "
"; } } else { if ($cartItem) { $seatcount = count($cartItem['kids']); } else { $seatcount = 1; } $html = wp_sprintf("

%s

", __($title, 'fieldday')); $html .= ""; $html .= "
"; for ($i = 1; $i <= $seatcount; $i++) { $participantDetail = isset($cartItem['kids'][$i]) ? $cartItem['kids'][$i] : []; $kidId = fieldday()->engine->generateRandomId(16, 'new_kid_'); $html .= $this->getview('cart/single_kid_form', ['counter' => $i, 'kidId' => $kidId, 'profile' => $participantDetail, 'sessionInfo' => $sessionInfo]); } $html .= "
"; } return $html; } public function KidsGradesOptions($from = null, $to = null) { $Avail_Grades = array(); /*$GradeArray = array('PreK'=> 'Pre-kindergarten','K'=>'Kindergarten', '1'=>'1st grade', '2'=>'2nd grade', '3'=>'3rd grade', '4'=>'4th grade', '5'=>'5th grade', '6'=>'6th grade', '7'=>'7th grade', '8'=>'8th grade', '9'=>'9th grade', '10'=>'10th grade', '11'=>'11th grade', '12'=>'12th grade');*/ $GradeArray = array('PreK', 'K', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'); $min = array_search($from, $GradeArray); $max = array_search($to, $GradeArray); //$GradeArrayKeys = array_keys($GradeArray); for ($i = $min; $i <= $max; $i++) { //$val = $GradeArray[$i]; $Avail_Grades[] = $GradeArray[$i]; } return $Avail_Grades; } /** * display participants for add to cart */ public function fielddayCartParticipantsNew($cartItem, $sessionInfo = null, $title = null, $logintitle = null) { $cartItem = json_decode(json_encode($cartItem), true); if (!$title) { $title = "How many Participants you want to register?"; } if (!$logintitle) { $logintitle = "Select Participants to register?"; } $km_edit_checked_students = 0; if ($this->isKmLogin()) { $kidsresponse = fieldday()->api->GetKids(); if ($kidsresponse->statusCode === 200) { $html = wp_sprintf("

%s *

", __($logintitle, 'fieldday')); $html .= ""; $html .= "
"; } } else { if ($cartItem) { $seatcount = count($cartItem['kidId']); } else { $seatcount = 1; } $html = wp_sprintf("

%s

", __($title, 'fieldday')); $html .= ""; $html .= "
"; for ($i = 0; $i <= $seatcount - 1; $i++) { $j = $i + 1; $participantDetail = isset($cartItem['kidId'][$i]) ? $cartItem['kidId'][$i] : []; $kidId = fieldday()->engine->generateRandomId(16, 'new_kid_'); $html .= $this->getview('cart/single_kid_form', ['counter' => $j, 'kidId' => $kidId, 'profile' => $participantDetail, 'sessionInfo' => $sessionInfo]); } $html .= "
"; } return $html; } /** * Global Popup Template content display */ public function fielddayShowElementorTemplate($template_id) { /* $arg = array(); $arg["source"] ='local'; $arg["template_id"] = $template_id; $temp = \Elementor\Plugin::instance()->templates_manager->get_template_data($arg); */ $response = \Elementor\Plugin::instance()->frontend->get_builder_content($template_id, true); print $response; } public function fielddayGlobalPopupData() { global $fielddaySetting; $activeGlobleTemplate = $this->getValue('fieldday_globalpopup_template', $fielddaySetting, false); $this->fielddayShowElementorTemplate($activeGlobleTemplate); } /** * * @param type $parsleyStepGroup * @return type Mixed */ public function getCardSaveOptions($parsleyStepGroup) { $checkboxOptions = ''; $cartItems = $this->GetCartData(); foreach ($cartItems as $cartKey => $cartItem) { $paymentOption = $cartItem->enabledPaymentOptions; if ($paymentOption) { $checkboxOptions = " data-parsley-group='{$parsleyStepGroup}' data-parsley-required-message='Required for installment/recurring payments' required='required' checked='checked'"; return $checkboxOptions; } } return $checkboxOptions; } /** * * @param type Get_User_Credit * @return type Mixed */ public function Get_User_Credit() { $queryOptions['isPerDayCredit'] = 'false'; $response = fieldday()->api->userProviderCreditSummary($queryOptions); if ($response->statusCode === 200 || $response->status == 'success') { return $response->data; } } /** * * @param type Calculations * @return type Mixed */ public function multiWeekRegistrationsCalc($data) { $response = fieldday()->api->multiWeekRegistrationsCalc($data); if ($response->statusCode === 200 || $response->status == 'success') { return $response->data; } } /** * Sibling Popup Template content display*/ // public function fielddaySiblingPopupData(){ // global $fielddaySetting; // $activeSiblingTemplate = $this->getValue('fieldday_siblingpopup_template', $fielddaySetting, false); // $this->fielddayShowElementorTemplate($activeSiblingTemplate); // } }