public function updateStatus(OrderEvent $event) { $order = $event->getOrder(); $colissimo = new Colissimo(); if ($order->isSent() && $order->getDeliveryModuleId() == $colissimo->getModuleModel()->getId()) { $contact_email = ConfigQuery::getStoreEmail(); if ($contact_email) { $message = MessageQuery::create()->filterByName('mail_colissimo')->findOne(); if (false === $message) { throw new \Exception("Failed to load message 'order_confirmation'."); } $order = $event->getOrder(); $customer = $order->getCustomer(); $this->parser->assign('customer_id', $customer->getId()); $this->parser->assign('order_ref', $order->getRef()); $this->parser->assign('order_date', $order->getCreatedAt()); $this->parser->assign('update_date', $order->getUpdatedAt()); $this->parser->assign('package', $order->getDeliveryRef()); $message->setLocale($order->getLang()->getLocale()); $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::getStoreName()); // Build subject and body $message->buildMessage($this->parser, $instance); $this->mailer->send($instance); Tlog::getInstance()->debug("Colissimo shipping message sent to customer " . $customer->getEmail()); } else { $customer = $order->getCustomer(); Tlog::getInstance()->debug("Colissimo shipping message no contact email customer_id", $customer->getId()); } } }
public function createPassword(AdministratorEvent $event) { $admin = $event->getAdministrator(); $email = $admin->getEmail(); if (!empty($email)) { $renewToken = $this->tokenProvider->getToken(); $admin->setPasswordRenewToken($renewToken)->save(); $this->mailer->sendEmailMessage('new_admin_password', [ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName()], [$email => $admin->getFirstname() . ' ' . $admin->getLastname()], ['token' => $renewToken, 'admin' => $admin]); } }
/** * send contact message */ public function sendAction() { $contactForm = new ContactForm($this->getRequest()); try { $form = $this->validateForm($contactForm); $message = \Swift_Message::newInstance($form->get('subject')->getData())->addFrom(ConfigQuery::getStoreEmail(), $form->get('name')->getData())->addReplyTo($form->get('email')->getData(), $form->get('name')->getData())->addTo(ConfigQuery::getStoreEmail(), ConfigQuery::getStoreName())->setBody($form->get('message')->getData()); $this->getMailer()->send($message); if (null !== ($successUrl = $this->retrieveSuccessUrl($contactForm))) { return $this->generateRedirect($successUrl); } return $this->generateRedirectFromRoute('contact.success'); } catch (FormValidationException $e) { $error_message = $e->getMessage(); } Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message)); $contactForm->setErrorMessage($error_message); $this->getParserContext()->addForm($contactForm)->setGeneralError($error_message); }
/** * send contact message */ public function sendAction() { $contactForm = $this->createForm(FrontForm::CONTACT); try { $form = $this->validateForm($contactForm); $this->getMailer()->sendSimpleEmailMessage([ConfigQuery::getStoreEmail() => $form->get('name')->getData()], [ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName()], $form->get('subject')->getData(), '', $form->get('message')->getData(), [], [], [$form->get('email')->getData() => $form->get('name')->getData()]); if ($contactForm->hasSuccessUrl()) { return $this->generateSuccessRedirect($contactForm); } return $this->generateRedirectFromRoute('contact.success'); } catch (FormValidationException $e) { $error_message = $e->getMessage(); } Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message)); $contactForm->setErrorMessage($error_message); $this->getParserContext()->addForm($contactForm)->setGeneralError($error_message); // Redirect to error URL if defined if ($contactForm->hasErrorUrl()) { return $this->generateErrorRedirect($contactForm); } }
public function exportAction() { if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('Colissimo'), AccessManager::UPDATE))) { return $response; } $form = new FormExport($this->getRequest()); try { $exportForm = $this->validateForm($form); // Get new status $status_id = $exportForm->get('status_id')->getData(); $status = OrderStatusQuery::create()->filterByCode($status_id)->findOne(); // Get Colissimo orders $orders = ColissimoQuery::getOrders()->find(); $export = ""; $store_name = ConfigQuery::getStoreName(); /** @var $order \Thelia\Model\Order */ foreach ($orders as $order) { $value = $exportForm->get('order_' . $order->getId())->getData(); if ($value) { // Get order information $customer = $order->getCustomer(); $locale = $order->getLang()->getLocale(); $address = $order->getOrderAddressRelatedByDeliveryOrderAddressId(); $country = CountryQuery::create()->findPk($address->getCountryId()); $country->setLocale($locale); $customerTitle = CustomerTitleQuery::create()->findPk($address->getCustomerTitleId()); $customerTitle->setLocale($locale); $weight = $exportForm->get('order_weight_' . $order->getId())->getData(); if ($weight == 0) { /** @var \Thelia\Model\OrderProduct $product */ foreach ($order->getOrderProducts() as $product) { $weight += (double) $product->getWeight(); } } /** * Get user's phone & cellphone * First get invoice address phone, * If empty, try to get default address' phone. * If still empty, set default value */ $phone = $address->getPhone(); if (empty($phone)) { $phone = $customer->getDefaultAddress()->getPhone(); if (empty($phone)) { $phone = self::DEFAULT_PHONE; } } // Cellphone $cellphone = $customer->getDefaultAddress()->getCellphone(); if (empty($cellphone)) { $cellphone = $customer->getDefaultAddress()->getCellphone(); if (empty($cellphone)) { $cellphone = self::DEFAULT_CELLPHONE; } } $export .= "\"" . $order->getRef() . "\";\"" . $address->getLastname() . "\";\"" . $address->getFirstname() . "\";\"" . $address->getAddress1() . "\";\"" . $address->getAddress2() . "\";\"" . $address->getAddress3() . "\";\"" . $address->getZipcode() . "\";\"" . $address->getCity() . "\";\"" . $country->getIsoalpha2() . "\";\"" . $phone . "\";\"" . $cellphone . "\";\"" . $weight . "\";\"" . $customer->getEmail() . "\";\"\";\"" . $store_name . "\";\"DOM\";\r\n"; if ($status) { $event = new OrderEvent($order); $event->setStatus($status->getId()); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); } } } return Response::create(utf8_decode($export), 200, array("Content-Encoding" => "ISO-8889-1", "Content-Type" => "application/csv-tab-delimited-table", "Content-disposition" => "filename=export.csv")); } catch (FormValidationException $e) { $this->setupFormErrorContext(Translator::getInstance()->trans("colissimo expeditor export", [], Colissimo::DOMAIN_NAME), $e->getMessage(), $form, $e); return $this->render("module-configure", array("module_code" => "Colissimo")); } }
/** * Send a message to the shop managers. * * @param string $messageCode * @param array $messageParameters an array of (name => value) parameters that will be available in the message. */ public function sendEmailToShopManagers($messageCode, $messageParameters = []) { $storeName = ConfigQuery::getStoreName(); // Build the list of email recipients $recipients = ConfigQuery::getNotificationEmailsList(); $to = []; foreach ($recipients as $recipient) { $to[$recipient] = $storeName; } $this->sendEmailMessage($messageCode, [ConfigQuery::getStoreEmail() => $storeName], $to, $messageParameters); }
protected function buildForm() { $tr = Translator::getInstance(); $this->formBuilder->add('store_name', 'text', ['data' => ConfigQuery::getStoreName(), 'constraints' => [new Constraints\NotBlank()], 'label' => $tr->trans('Store name'), 'attr' => ['placeholder' => $tr->trans('Used in your store front')]])->add('store_description', 'text', ['data' => ConfigQuery::getStoreDescription(), 'required' => false, 'label' => $tr->trans('Store description'), 'attr' => ['placeholder' => $tr->trans('Used in your store front')]])->add('store_email', 'text', ['data' => ConfigQuery::getStoreEmail(), 'constraints' => [new Constraints\NotBlank(), new Constraints\Email()], 'label' => $tr->trans('Store email address'), 'attr' => ['placeholder' => $tr->trans('Contact and sender email address')], 'label_attr' => ['help' => $tr->trans('This is the contact email address, and the sender email of all e-mails sent by your store.')]])->add('store_notification_emails', 'text', ['data' => ConfigQuery::read('store_notification_emails'), 'constraints' => [new Constraints\NotBlank(), new Constraints\Callback(['methods' => [[$this, 'checkEmailList']]])], 'label' => $tr->trans('Email addresses of notification recipients'), 'attr' => ['placeholder' => $tr->trans('A comma separated list of email addresses')], 'label_attr' => ['help' => $tr->trans('This is a comma separated list of email addresses where store notifications (such as order placed) are sent.')]])->add('store_business_id', 'text', ['data' => ConfigQuery::read('store_business_id'), 'label' => $tr->trans('Business ID'), 'required' => false, 'attr' => ['placeholder' => $tr->trans('Store Business Identification Number (SIRET, etc).')]])->add('store_phone', 'text', ['data' => ConfigQuery::read('store_phone'), 'label' => $tr->trans('Phone'), 'required' => false, 'attr' => ['placeholder' => $tr->trans('The store phone number.')]])->add('store_fax', 'text', ['data' => ConfigQuery::read('store_fax'), 'label' => $tr->trans('Fax'), 'required' => false, 'attr' => ['placeholder' => $tr->trans('The store fax number.')]])->add('store_address1', 'text', ['data' => ConfigQuery::read('store_address1'), 'constraints' => [new Constraints\NotBlank()], 'label' => $tr->trans('Street Address'), 'attr' => ['placeholder' => $tr->trans('Address.')]])->add('store_address2', 'text', ['data' => ConfigQuery::read('store_address2'), 'required' => false, 'attr' => ['placeholder' => $tr->trans('Additional address information')]])->add('store_address3', 'text', ['data' => ConfigQuery::read('store_address3'), 'required' => false, 'attr' => ['placeholder' => $tr->trans('Additional address information')]])->add('store_zipcode', 'text', ['data' => ConfigQuery::read('store_zipcode'), 'constraints' => [new Constraints\NotBlank()], 'label' => $tr->trans('Zip code'), 'attr' => ['placeholder' => $tr->trans('Zip code')]])->add('store_city', 'text', ['data' => ConfigQuery::read('store_city'), 'constraints' => [new Constraints\NotBlank()], 'label' => $tr->trans('City'), 'attr' => ['placeholder' => $tr->trans('City')]])->add('store_country', 'integer', ['data' => ConfigQuery::read('store_country'), 'constraints' => [new Constraints\NotBlank()], 'label' => $tr->trans('Country'), 'attr' => ['placeholder' => $tr->trans('Country')]]); }
/** * @since 2.3.0-alpha2 */ public function confirmSubscription(NewsletterEvent $event) { $this->mailer->sendEmailMessage('newsletter_subscription_confirmation', [ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName()], [$event->getEmail() => $event->getFirstname() . " " . $event->getLastname()], ['email' => $event->getEmail(), 'firstname' => $event->getFirstname(), 'lastname' => $event->getLastname()], $event->getLocale()); }
protected function sendCommentRequestCustomerMail($customerId, array $productIds) { $contact_email = ConfigQuery::getStoreEmail(); if ($contact_email) { $message = MessageQuery::create()->filterByName('comment_request_customer')->findOne(); if (null === $message) { throw new \Exception("Failed to load message 'comment_request_customer'."); } $customer = CustomerQuery::create()->findPk($customerId); if (null === $customer) { throw new \Exception(sprintf("Failed to load customer '%s'.", $customerId)); } $parser = $this->parser; $locale = $customer->getCustomerLang()->getLocale(); $parser->assign('customer_id', $customer->getId()); $parser->assign('product_ids', $productIds); $parser->assign('lang_id', $customer->getCustomerLang()->getId()); $message->setLocale($locale); $instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::getStoreName()); // Build subject and body $message->buildMessage($parser, $instance); $this->mailer->send($instance); Tlog::getInstance()->debug("Message sent to customer " . $customer->getEmail() . " to ask for comments"); } }