public function service()
 {
     $userManager = new UserManager($this->config, $this->args);
     $email = strtolower($this->secure($_REQUEST["email"]));
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $jsonArr = array('status' => "err", "errText" => $this->getPhrase(471));
         echo json_encode($jsonArr);
         return false;
     }
     $customer = $userManager->getCustomerByEmail($email);
     if ($customer != null) {
         $emailSenderManager = new EmailSenderManager('gmail');
         $customerEmail = $customer->getEmail();
         $userName = $customer->getName();
         $password = $customer->getPassword();
         $subject = "Your PcStore Password!";
         $templateId = "customer_forgot_password";
         $params = array("name" => $userName, "password" => $password);
         $emailSenderManager->sendEmail('support', $customerEmail, $subject, $templateId, $params);
         $jsonArr = array('status' => "ok", "message" => "Your password sent to your " . $email . " email.\nPlease check your email.");
         echo json_encode($jsonArr);
         return true;
     } else {
         $jsonArr = array('status' => "err", "errText" => $this->getPhrase(381));
         echo json_encode($jsonArr);
         return false;
     }
 }
 private function sendStockUpdatedEmailToCompany($company_id)
 {
     $emailSenderManager = new EmailSenderManager('gmail');
     $companyManager = CompanyManager::getInstance($this->config, $this->args);
     $company = $companyManager->selectByPK($company_id);
     if (isset($company) && $company->getReceiveEmailOnStockUpdate() == 1) {
         $company_email = $company->getEmail();
         $subject = $this->getPhrase(531, 'en');
         $templateId = 'company_stock_updated';
         $params = array("support_phone" => $this->getCmsVar('pcstore_support_phone_number'));
         $emailSenderManager->sendEmail('info', $company_email, $subject, $templateId, $params);
     }
 }
 public function service()
 {
     $userManager = new UserManager($this->config, $this->args);
     $email = strtolower($this->secure($_REQUEST["email"]));
     $name = $this->secure($_REQUEST["name"]);
     $phone = $this->secure($_REQUEST["phone"]);
     $pass = $this->secure($_REQUEST["pass"]);
     $invitation_code = $this->secure($_COOKIE["invc"]);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(471));
         echo json_encode($jsonArr);
         return false;
     }
     $custDto = $userManager->getCustomerByEmail($email);
     if ($custDto) {
         $jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(359));
         echo json_encode($jsonArr);
         return false;
     }
     if (!$userManager->checkPassword($pass)) {
         $jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(358));
         echo json_encode($jsonArr);
         return false;
     }
     if (!$name || strlen($name) == 0) {
         $jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(356));
         echo json_encode($jsonArr);
         return false;
     }
     if ($phone != null) {
         if (strpos($phone, ',') !== false) {
             $jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(521));
             echo json_encode($jsonArr);
             return false;
         }
     }
     $userId = $userManager->createUser($email, $pass, $name, $phone);
     $userManager->setSubUser($invitation_code, $userId, $email);
     $userDto = $userManager->selectByPK($userId);
     //sending activation email using $userDto->getActivationCode();
     $emailSenderManager = new EmailSenderManager('gmail');
     $username = $name;
     $subject = "PcStore Activation!";
     $activation_code = $userDto->getActivationCode();
     $template = "account_activation";
     $params = array("user_name" => $username, "activation_code" => $activation_code);
     $emailSenderManager->sendEmail('registration', $email, $subject, $template, $params);
     $jsonArr = array('status' => "ok");
     echo json_encode($jsonArr);
     return true;
 }
Пример #4
0
 public function service()
 {
     $emailSenderManager = new EmailSenderManager('gmail');
     $email = strtolower($this->secure($_REQUEST['email']));
     $msg = $this->secure($_REQUEST['msg']);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $jsonArr = array('status' => "err", "message" => $this->getPhraseSpan(471));
         echo json_encode($jsonArr);
         return false;
     }
     $pcstore_contact_us_email = $this->getCmsVar('pcstore_contact_us_email');
     $subject = "Message To PcStore from " . $email;
     $templateId = "contact_us";
     $params = array("msg" => $msg);
     if ($this->getUserLevel() !== UserGroups::$GUEST) {
         $fromName = $this->getCustomer()->getName() . ' (' . $this->getUserLevelString() . '-' . $this->getUserId() . ')';
     } else {
         $fromName = $email;
     }
     $emailSenderManager->sendEmail('contactus', $pcstore_contact_us_email, $subject, $templateId, $params, $email, $fromName);
     $jsonArr = array('status' => "ok", "message" => $this->getPhrase(438));
     echo json_encode($jsonArr);
     return true;
 }
Пример #5
0
 private function emailOrderDetails($orderId)
 {
     $emailSenderManager = new EmailSenderManager('gmail');
     $customer = $this->getCustomer();
     $userManager = UserManager::getInstance($this->config, $this->args);
     $customerEmail = $userManager->getRealEmailAddressByUserDto($customer);
     $emailAccountsManager = EmailAccountsManager::getInstance($this->config, $this->args);
     $infoEmailAddress = $emailAccountsManager->getEmailAddressById('info');
     $recipients = array($customerEmail, $infoEmailAddress);
     $lname = $customer->getLastName();
     $userName = $customer->getName();
     if (isset($lname)) {
         $userName .= ' ' . $lname;
     }
     $orderJoinedDetailsDtos = $this->ordersManager->getOrderJoinedWithDetails($orderId);
     $goupedOrderJoinedDetailsDtos = $this->groupBundlesInOrderJoinedDetailsDtos($orderJoinedDetailsDtos);
     $paymentType = $orderJoinedDetailsDtos[0]->getPaymentType();
     $payment_option_values = explode(',', $this->getCmsVar('payment_option_values'));
     $payment_options_display_names_ids = explode(',', $this->getCmsVar('payment_options_display_names_ids'));
     $index = array_search($paymentType, $payment_option_values);
     $paymentTypeDisplayNameId = $payment_options_display_names_ids[$index];
     $subject = $this->getPhrase(299);
     if ($paymentType == 'credit') {
         $template = "customer_credit_order";
     } else {
         $template = "customer_cash_order";
     }
     $params = array("user_name" => $userName, "dtos" => $goupedOrderJoinedDetailsDtos, "itemManager" => $this->itemManager, "support_phone" => $this->getCmsVar('pcstore_support_phone_number'), 'paymentTypeDisplayNameId' => $paymentTypeDisplayNameId);
     if ($paymentType == 'credit') {
         $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args);
         $csid = $orderJoinedDetailsDtos[0]->getCreditOrdersCreditSupplierId();
         $creditSupplierDto = $creditSuppliersManager->selectByPK($csid);
         $commission = $creditSupplierDto->getCommission();
         $grandTotalAMD = intval($orderJoinedDetailsDtos[0]->getOrderTotalAmd());
         $grandTotalAmdWithCommission = intval($grandTotalAMD / (1 - $commission / 100));
         $params['grandTotalAmdWithCommission'] = $grandTotalAmdWithCommission;
     }
     $emailSenderManager->sendEmail('orders', $recipients, $subject, $template, $params, '', '', true, false);
 }
Пример #6
0
 public function service()
 {
     $userManager = UserManager::getInstance($this->config, $this->args);
     $userPendingSubUsersManager = new UserPendingSubUsersManager($this->config, $this->args);
     $emailSenderManager = new EmailSenderManager('gmail');
     $userId = $this->getUserId();
     $user = $userManager->selectByPK($userId);
     $subUsersRegistrationCode = $user->getSubUsersRegistrationCode();
     if ($subUsersRegistrationCode == null || strlen($subUsersRegistrationCode) == 0) {
         $subUsersRegistrationCode = uniqid();
         $userManager->setSubUsersRegistrationCode($userId, $subUsersRegistrationCode);
     }
     if (isset($_REQUEST["emails"])) {
         $emails = $this->secure($_REQUEST["emails"]);
         $emailsArray = explode(',', $emails);
         $validEmailToBeInvited = array();
         foreach ($emailsArray as $email) {
             if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                 $customerByEmail = $userManager->getCustomerByEmail($email);
                 if (!isset($customerByEmail)) {
                     $byUserIdAndPendingSubUserEmail = $userPendingSubUsersManager->getByUserIdAndPendingSubUserEmail($userId, $email);
                     if (!isset($byUserIdAndPendingSubUserEmail)) {
                         $userPendingSubUsersManager->addPendingSubUserEmailToUser($email, $userId);
                         $validEmailToBeInvited[] = $email;
                     }
                 }
             }
         }
         if (count($validEmailToBeInvited) > 0) {
             $from = $userManager->getRealEmailAddress($userId);
             $username = $user->getName();
             $subject = $username . " invites you to join PcStore!";
             $template = "user_to_user_invitation";
             $params = array("user_name" => $username, "invitation_code" => $subUsersRegistrationCode);
             $fromName = $user->getName() . ' ' . $user->getLastName();
             $emailSenderManager->sendEmail('news', $validEmailToBeInvited, $subject, $template, $params, $from, $fromName);
         }
         $this->ok(array("message" => $this->getPhraseSpan(603)));
     } elseif (isset($_REQUEST["user_email"])) {
         $pendingUserEmail = $this->secure($_REQUEST["user_email"]);
         if (filter_var($pendingUserEmail, FILTER_VALIDATE_EMAIL)) {
             if ($userManager->getCustomerByEmail($pendingUserEmail)) {
                 $this->error(array("errText" => $this->getPhraseSpan(359)));
             }
             if (!$userPendingSubUsersManager->getByUserIdAndPendingSubUserEmail($userId, $pendingUserEmail)) {
                 $userPendingSubUsersManager->addPendingSubUserEmailToUser($pendingUserEmail, $userId);
                 //sending invitation email to user
                 $from = $userManager->getRealEmailAddress($userId);
                 $username = $user->getName();
                 $subject = $username . " invites you to join PcStore!";
                 $template = "user_to_user_invitation";
                 $params = array("user_name" => $username, "invitation_code" => $subUsersRegistrationCode);
                 $fromName = $user->getName() . ' ' . $user->getLastName();
                 $emailSenderManager->sendEmail('news', $pendingUserEmail, $subject, $template, $params, $from, $fromName);
                 $this->ok(array("message" => $this->getPhraseSpan(603)));
             } else {
                 $this->error(array("errText" => $this->getPhraseSpan(605)));
             }
         } else {
             $this->error(array("errText" => $this->getPhraseSpan(471)));
         }
     } elseif (isset($_REQUEST["invitation_id"])) {
         $invitationId = intval($_REQUEST["invitation_id"]);
         $from = $userManager->getRealEmailAddress($userId);
         $username = $user->getName();
         $subject = $username . " invites you to join PcStore!";
         $template = "user_to_user_invitation";
         $params = array("user_name" => $username, "invitation_code" => $subUsersRegistrationCode);
         $fromName = $user->getName() . ' ' . $user->getLastName();
         $dto = $userPendingSubUsersManager->selectByPK($invitationId);
         $pendingSubUserEmail = $dto->getPendingSubUserEmail();
         $emailSenderManager->sendEmail('news', $pendingSubUserEmail, $subject, $template, $params, $from, $fromName);
         $dto->setLastSent(date('Y-m-d H:i:s'));
         $userPendingSubUsersManager->updateByPk($dto);
         $this->ok(array("message" => $this->getPhraseSpan(603)));
     }
 }
 public function sendNewPriceUploadedEmailToCompanyDealers($company)
 {
     $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $compayDealers = $companyDealersManager->getCompanyDealersUsersFullInfoHiddenIncluded($company->getId());
     $allUsersEmails = $this->getUsersEmailByUsersDtos($compayDealers);
     $emailSenderManager = new EmailSenderManager('gmail');
     $companyName = $company->getName();
     $subject = 'New Price form ' . $companyName . '!!!';
     $template = "new_price_uploaded";
     $params = array("company_name" => $companyName);
     $emailSenderManager->sendEmail('info', $allUsersEmails, $subject, $template, $params, '', '', true, true);
 }