Exemplo n.º 1
0
 function __Construct($dictionary)
 {
     parent::__Construct(get_class(), "desktop.html", $dictionary);
     //get input params
     $paymentConfigCode = Params::Get('state');
     $authCode = Params::Get('code');
     //load provider (verify code)
     $provider = Provider::FromPaymentConfigCode($paymentConfigCode);
     if (is_null($provider)) {
         //TODO: deal with this
     } else {
         //check stripe id isn't already set
         if (!is_null($provider->getStripeAccountId())) {
             //TODO: deal with this
         } else {
             $stripeAccount = StripeConnector::ConstructAccount($authCode);
             if (is_null($stripeAccount)) {
                 //TODO: deal with this
             } else {
                 //add to provider - clear code
                 $provider->setStripeAccountId($stripeAccount->getId());
                 $provider->setPaymentConfigCode(null);
                 $provider->save();
                 //notify success
                 $this->connected = true;
             }
         }
     }
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     $subscriptionId = null;
     if (HTTP::IsPost()) {
         $emailAddress = Params::Get('emailAddress');
         $listReference = Params::Get('listReference');
         $source = Params::Get('source', self::DEFAULT_SOURCE);
         if (!Util::ValidateEmail($emailAddress)) {
             $message = 'INVALID EMAIL ADDRESS';
         } else {
             //get list
             $emailList = EmailList::FromReference(Application::PARTNER_CODE, $listReference);
             if (is_null($emailList)) {
                 $message = "INVALID EMAIL LIST [" . $listReference . "]";
             } else {
                 $success = $emailList->subscribe($source, $emailAddress, $user->getId(), $dictionary->getCode(), $message);
             }
             //send welcome email
             if ($success) {
                 //load subscription back up for id
                 $subscription = Subscription::FromEmail($emailList->getId(), $emailAddress);
                 $subscriptionId = $subscription->getId();
                 //load template
                 if ($listReference == 'consumer') {
                     $templateRef = 'subscribe-consumer';
                 } else {
                     $templateRef = 'subscribe-provider';
                 }
                 //TODO: support multiple language emails (just need to deal with inheritance)
                 $template = EmsTemplate::FromReference(Application::PARTNER_CODE, $templateRef, 'EN');
                 //send email
                 Application::SendEmail($template->getFromEmailAddress(), $template->getFromName(), $template->getReplyToEmailAddress(), $emailAddress, $template->getSubject(), $template->getContent(), ContentType::HTML);
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'subscriptionId' => $subscriptionId, 'message' => $message);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         //inputs
         $subscriptionId = Params::GetLong('subscriptionId');
         $name = Params::Get('name');
         //load subscription
         $subscription = new Subscription($subscriptionId);
         $subscription->setName($name);
         $subscription->save();
         $success = true;
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
Exemplo n.º 4
0
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $siteContact = new SiteContact();
         $siteContact->setUserId($user->getId());
         $siteContact->setTypeId(Params::GetLong('typeId'));
         $siteContact->setContactName(Params::Get('contactName'));
         $siteContact->setContactEmailAddress(Params::Get('contactEmailAddress'));
         $siteContact->setContactPhone(Params::Get('contactPhone'));
         $siteContact->setDictionaryCode($dictionary->getCode());
         $siteContact->setContent(Params::Get('content'));
         if ($siteContact->validate()) {
             $siteContact->save();
             $success = true;
             //notify partner by email
             $partner = new Partner(Application::PARTNER_CODE);
             $recipientAddress = $partner->getConfigValue(PartnerConfig::COMMS_NOTIFY_EMAIL);
             $content = "\n";
             $content .= "A new site contact has been submitted on treatnow.co.\n\n";
             $content .= '---------------------------------------------------------------------' . "\n";
             $content .= "Type: " . $siteContact->getTypeName() . "\n";
             $content .= "Contact Name: " . $siteContact->getContactName() . "\n";
             $content .= "Contact Email: " . $siteContact->getContactEmailAddress() . "\n";
             $content .= "Contact Phone: " . $siteContact->getContactPhone() . "\n";
             $content .= '---------------------------------------------------------------------' . "\n\n";
             $content .= $siteContact->getContent() . "\n";
             $content .= '---------------------------------------------------------------------' . "\n\n";
             $content .= "You can manage the contact here: http://manage.zidmi.com/operations/contacts/";
             Application::SendEmail('*****@*****.**', 'Zidmi', null, $recipientAddress, 'Site Contact', $content);
         } else {
             $message = $siteContact->getValidationError();
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $verificationCode = Params::Get('verificationCode');
         $verifierName = Params::Get('verifierName');
         if (!is_null($verificationCode) && !is_null($verifierName)) {
             $provider = Provider::FromVerificationCode($verificationCode);
             if (!is_null($provider)) {
                 $reference = 'UserId:' . $user->getId();
                 $provider->verify($verifierName, $reference);
                 $success = true;
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $verificationCode = Params::Get('verificationCode');
         $verifierName = Params::Get('verifierName');
         $feedback = Params::Get('feedback');
         if (!is_null($verificationCode) && !is_null($verifierName) && !is_null($feedback)) {
             $provider = Provider::FromVerificationCode($verificationCode);
             if (!is_null($provider)) {
                 //add provider event
                 $reference = 'UserId:' . $user->getId();
                 $notes = "Submitted by:" . $verifierName . "\n" . $feedback;
                 $provider->addEvent(ProviderEventType::VERIFICATION_FEEDBACK, $reference, $notes);
                 $success = true;
                 //notify email
                 $partner = new Partner(Application::PARTNER_CODE);
                 $recipientAddress = $partner->getConfigValue(PartnerConfig::COMMS_NOTIFY_EMAIL);
                 $content = "\n";
                 $content .= "Some feedback has been submitted regarding provider data.\n\n";
                 $content .= '---------------------------------------------------------------------' . "\n";
                 $content .= "Provider: " . $provider->getName() . "\n";
                 $content .= "Submitted by: " . $verifierName . "\n";
                 $content .= "Feedback: \n";
                 $content .= $feedback . "\n";
                 $content .= '---------------------------------------------------------------------' . "\n\n";
                 Application::SendEmail('*****@*****.**', 'Zidmi', null, $recipientAddress, 'Provider Verification Feedback', $content);
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
Exemplo n.º 7
0
 $element1 = '';
 $element2 = '';
 if (count($elements) >= 1) {
     $element0 = $elements[0];
 }
 if (count($elements) >= 2) {
     $element1 = $elements[1];
 }
 if (count($elements) >= 3) {
     $element2 = $elements[2];
 }
 //always get user
 $user = Application::GetUser();
 //fork if api
 if ($element0 == 'api') {
     $langCode = Params::Get('lang', 'en');
     $dictionary = new Dictionary($langCode, 'treatnow.');
     if ($element1 == 'providers') {
         $response = new ProvidersResponse();
     } elseif ($element1 == 'subscribe') {
         $response = new SubscriptionResponse($user, $dictionary);
     } elseif ($element1 == 'subscribe-name') {
         $response = new SubscriptionNameResponse($user, $dictionary);
     } elseif ($element1 == 'categories') {
         $response = new CategoriesResponse($dictionary);
     } elseif ($element1 == 'contact') {
         $response = new ContactResponse($user, $dictionary);
     } elseif ($element1 == 'verify-provider') {
         $response = new VerifyProviderResponse($user, $dictionary);
     } elseif ($element1 == 'verify-feedback') {
         $response = new VerifyFeedbackResponse($user, $dictionary);
Exemplo n.º 8
0
 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);
 }