function getContent() { // $this->provider = new Provider(); //CORE DETAILS //spoken languages $spokenLanguages = ''; foreach ($this->provider->getSpokenLanguages() as $language) { if ($spokenLanguages != '') { $spokenLanguages .= ', '; } $spokenLanguages .= HTML::Encode($language->getDictionaryName()); } //IMAGES $image = $this->provider->getImage(ProviderImageType::PRIMARY); if (is_null($image)) { $primaryImage = "We don't have a primary image from you yet, please email us your preferred image, if not we will try to do a screen grab from your website."; } else { $primaryImage = HTML::Img(Application::GetCdnUri($image, 200, 133)); } $image = $this->provider->getImage(ProviderImageType::SERVICE_LIST); if (is_null($image)) { $serviceListImage = "You don't have one set so we'll use the primary image."; } else { $serviceListImage = HTML::Img(Application::GetCdnUri($image, 200, 40)); } //FULFILLMENT //hours $requestHours = "We'll send you appointment requests "; if ($this->provider->getUseRequestOpenRules()) { $requestHours .= "using the following schedule:"; $requestHours .= $this->getHoursTable($this->provider->getRequestHours()); } else { $requestHours .= "whenever you're open using your standard open hours (see above)."; } //sms/email config $emailAddress = HTML::Span(HTML::Encode($this->provider->getEmailAddress()), null, 'highlight'); $smsNumber = HTML::Span(Format::Phone($this->provider->getSmsIdc(), $this->provider->getSmsNumber()), null, 'highlight'); if ($this->provider->getEmailRequests() && !$this->provider->getSmsRequests()) { $requestAction = 'When we receive a request we\'ll send an email to ' . $emailAddress . ' containing the details. ' . 'The email will contain a link to set your availability.'; } elseif (!$this->provider->getEmailRequests() && $this->provider->getSmsRequests()) { $requestAction = 'When we receive a request we\'ll send a text message to ' . $smsNumber . 'containing the details. You will be able to respond to the message or use the link provided to set your availability.'; } elseif ($this->provider->getEmailRequests() && $this->provider->getSmsRequests()) { $requestAction = 'When we receive a request we\'ll send an email to ' . $emailAddress . ' and a text message to ' . $smsNumber . '. ' . 'Both will contain a link to set your availability but you can reply directly to the text.'; } else { $requestAction = 'Currently your profile is not configured to send emails or text messages. ' . 'Until you let us know how you want to receive requests we won\'t be able to put you live in the app.'; } //slot config $slotConfig = 'When a customer requests an appointment we will show you '; $slotLength = $this->provider->getSlotLength(true); $slotStart = $this->provider->getSlotStart(true); $slotConfig .= $slotLength; $slotConfig .= ' minute slots starting '; $slotConfig .= $slotStart == 0 ? 'on the hour.' : 'at ' . $slotStart . ' past the hour.'; $slotConfig .= HTML::Br() . 'Example: '; $slotTime = new DateTime('1974-05-22 13:00'); $slotTime->modify('+' . $slotStart . ' minutes'); $periodEnd = new DateTime('1974-05-22 14:00'); while ($slotTime < $periodEnd) { $slotConfig .= HTML::Button(Format::Time($slotTime), null, 'slotButton') . ' '; $slotTime->modify('+' . $slotLength . ' minutes'); } //confirmation emails if ($this->provider->getSendConfirmationEmail()) { $confEmails = 'When a booking is completed by a customer we will send a email to ' . $emailAddress . '.'; } else { $confEmails = 'We will not send you an email when a booking is confirmed.'; } //compile page array $pageValues = array_merge(array('dictionaryCode' => $this->dictionary->getCode(), 'partnerCode' => Config::Get(Application::CONFIG_PARTNERCODE), 'verificationCode' => $this->provider->getVerificationCode(), 'phoneNumber' => Format::Phone($this->provider->getPhoneIdc(), $this->provider->getPhoneNumber()), 'openHours' => $this->getHoursTable($this->provider->getOpenHours()), 'spokenLanguages' => $spokenLanguages, 'primaryImage' => $primaryImage, 'serviceListImage' => $serviceListImage, 'fulfillment.requestHours' => $requestHours, 'fulfillment.requestAction' => $requestAction, 'fulfillment.slotConfig' => $slotConfig, 'fulfillment.confEmails' => $confEmails, 'services' => $this->getServices()), Util::PrependArray('provider', $this->provider->toArray())); //done return Application::LoadTemplate('provider-setup.html', $pageValues); }
function __Construct() { parent::__Construct(get_class()); $this->db = Database::GetInstance(Database::ZIDMI); //get input params //TODO: could do with some more validation $latLong = Params::Get('ll'); $latLong1 = Params::Get('ll1'); $latLong2 = Params::Get('ll2'); if ($latLong) { $this->lat1 = explode(',', $latLong)[0]; $this->lng1 = explode(',', $latLong)[1]; $this->locMode = self::LOCMODE_RADIAL; } else { if ($latLong1 && $latLong2) { $this->lat1 = explode(',', $latLong1)[0]; $this->lng1 = explode(',', $latLong1)[1]; $this->lat2 = explode(',', $latLong2)[0]; $this->lng2 = explode(',', $latLong2)[1]; $this->locMode = self::LOCMODE_BOUNDS; } } $this->categoryId = Params::GetLong('categoryId'); $this->langCode = Params::Get('lang'); //get providers/counters $providers = array(); $requestableCount = 0; $totalCount = 0; foreach ($this->getProvidersRs() as $row) { //update counters $requestable = false; if (!is_null($row['online_provider_id'])) { $requestableCount++; $requestable = true; } $totalCount++; //compile address $address = ''; if (!is_null($row['address_1'])) { $address .= ($address == '' ? '' : ', ') . $row['address_1']; } if (!is_null($row['address_2'])) { $address .= ($address == '' ? '' : ', ') . $row['address_2']; } if (!is_null($row['address_3'])) { $address .= ($address == '' ? '' : ', ') . $row['address_3']; } if (!is_null($row['address_postref'])) { $address .= ($address == '' ? '' : ', ') . $row['address_postref']; } //add to main array $providers[] = array('id' => $row['id'], 'reference' => $row['partner_reference'], 'name' => $row['name'], 'address1' => $row['address_1'], 'address' => $address, 'latitude' => $row['latitude'], 'longitude' => $row['longitude'], 'distance' => $row['distance'], 'requestable' => $requestable, 'categories' => $this->getProviderCategories($row['id'])); } //if no providers then get closest $nearestProvider = array(); if ($totalCount == 0) { $distance = null; $provider = $this->getNearestProvider($this->lat1, $this->lng1, $distance); if (!is_null($provider)) { //set provider image $imageUri = '/images/generic-venue.png'; if (!is_null($provider->getPrimaryImageId())) { $image = new Image($provider->getPrimaryImageId()); $imageUri = Application::GetCdnUri($image, 100, 100); } $nearestProvider = array('id' => $provider->getId(), 'reference' => $provider->getPartnerReference(), 'name' => $provider->getName(), 'address' => $provider->getAddress(), 'latitude' => $provider->getLatitude(), 'longitude' => $provider->getLongitude(), 'imageUri' => $imageUri, 'distance' => $distance, 'categories' => $this->getProviderCategories($provider->getId())); } } //done $this->jsonData = array('requestableCount' => $requestableCount, 'totalCount' => $totalCount, 'providers' => $providers, 'nearestProvider' => $nearestProvider); }