Esempio n. 1
0
 /**
  * event function to send sales order by email
  * @param object $evctl
  */
 public function sendSalesOrderWithEmail(EventControler $evctl)
 {
     $record_id = $evctl->idsales_order;
     $sales_order_email = $evctl->sales_order_email;
     $crm_global_settings = new CRMGlobalSettings();
     $inventory_prefixes = $crm_global_settings->get_inventory_prefixes();
     $company_address = $crm_global_settings->get_setting_data_by_name('company_address');
     $export_inventory = new ExportInventoryData();
     if ((int) $record_id > 0) {
         if (is_array($sales_order_email) && count($sales_order_email) > 0) {
             $email_template = new EmailTemplate("send_sales_order_email");
             $emailer = new SQEmailer();
             $pdf_filename = $export_inventory->generate_inventory_pdf((int) $record_id, 14, true);
             foreach ($sales_order_email as $key => $val) {
                 $val_exploded = explode(':::', $val);
                 $to_email = $val_exploded[0];
                 $name = $val_exploded[1];
                 $name_explode = explode('::', $name);
                 $email_data = array("sales_order_number" => $inventory_prefixes["salesorder_num_prefix"] . $record_id, "company_name" => CRM_NAME, "firstname" => array_key_exists(0, $name_explode) ? $name_explode[0] : '', "lastname" => array_key_exists(1, $name_explode) ? $name_explode[1] : '', "company_address" => nl2br($company_address));
                 $to_name = (array_key_exists(0, $name_explode) ? $name_explode[0] : '') . ' ' . (array_key_exists(1, $name_explode) ? $name_explode[1] : '');
                 $emailer->IsSendmail();
                 $emailer->setEmailTemplate($email_template);
                 $emailer->mergeArray($email_data);
                 $emailer->AddAddress($to_email, $to_name);
                 $emailer->AddAttachment(OUTBOUND_PATH . '/' . $pdf_filename);
                 $emailer->send();
                 $_SESSION["do_crm_messages"]->set_message('success', _('Email has been sent !'));
                 $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
                 $dis = new Display($next_page);
                 $dis->addParam("sqrecord", $record_id);
                 $evctl->setDisplayNext($dis);
             }
         } else {
             $_SESSION["do_crm_messages"]->set_message('error', _('Operation failed! No email id specified.'));
             $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
             $dis = new Display($next_page);
             $dis->addParam("sqrecord", $record_id);
             $evctl->setDisplayNext($dis);
         }
     } else {
         $_SESSION["do_crm_messages"]->set_message('error', _('Operation failed! No record id specified.'));
         $next_page = NavigationControl::getNavigationLink($evctl->module, "detail");
         $dis = new Display($next_page);
         $dis->addParam("sqrecord", $record_id);
         $evctl->setDisplayNext($dis);
     }
 }
Esempio n. 2
0
     if ($do_group_user_rel->getNumRows() > 0) {
         while ($do_group_user_rel->next()) {
             $email_to_array[] = array("email" => $do_group_user_rel->email, "firstname" => $do_group_user_rel->firstname, "lastname" => $do_group_user_rel->lastname);
         }
     }
 }
 $event_url = SITE_URL . NavigationControl::getNavigationLink("Calendar", "detail", $do_calendar->idevents);
 $reminder_time = strtotime("- {$d} days - {$h} hours - {$m} minutes ", strtotime($start_date_time));
 if (strtotime($now) >= $reminder_time) {
     foreach ($email_to_array as $key => $val) {
         if ($key == 0) {
             foreach ($val as $additional_emailids) {
                 $email_data = array("firstname" => "Hi", "event_type" => $do_calendar->event_type, "start_time" => FieldType10::display_value($start_time), "start_date" => FieldType9::display_value($start_date), "CRM_NAME" => CRM_NAME, "event_url" => $event_url, "subject" => $do_calendar->subject);
                 $emailer->IsSendmail();
                 $emailer->setEmailTemplate($email_template);
                 $emailer->mergeArray($email_data);
                 $emailer->AddAddress($val["email"], $val["firstname"] . ' ' . $val["lastname"]);
                 $emailer->send();
                 echo "Email Sent to " . $val["email"] . "\n";
             }
         } else {
             $email_data = array("firstname" => $val["firstname"], "event_type" => $do_calendar->event_type, "start_time" => FieldType10::display_value($start_time), "start_date" => FieldType9::display_value($start_date), "CRM_NAME" => CRM_NAME, "event_url" => $event_url, "subject" => $do_calendar->subject);
             $emailer->IsSendmail();
             $emailer->setEmailTemplate($email_template);
             $emailer->mergeArray($email_data);
             $emailer->AddAddress($val["email"], $val["firstname"] . ' ' . $val["lastname"]);
             $emailer->send();
             echo "Email Sent to " . $val["email"] . "\n";
         }
     }
     $qry = "\r\n\t\t\t\tupdate \r\n                `events_reminder` \r\n                set `reminder_send` = 1 \r\n                where `idevents_reminder` = " . $do_event_reminder->idevents_reminder . " limit 1";
Esempio n. 3
0
 /**
  * function to send the cpanel login details to the customer
  * @param array $contact_data
  * @return void
  */
 public function send_cpanel_login_details($contact_data)
 {
     if (is_array($contact_data)) {
         $email_template = new EmailTemplate("send_portal_login_details");
         $emailer = new SQEmailer();
         $to_email = $contact_data["email"];
         $to_name = $contact_data["firstname"] . ' ' . $contact_data["lastname"];
         $email_data = array("firstname" => $contact_data["firstname"], "email" => $contact_data["email"], "password" => $contact_data["password"], "portal_url" => PORTAL_URL . '/modules/User/login', "CRM_NAME" => CRM_NAME);
         $emailer->IsSendmail();
         $emailer->setEmailTemplate($email_template);
         $emailer->mergeArray($email_data);
         $emailer->AddAddress($to_email, $to_name);
         $emailer->send();
     }
 }
Esempio n. 4
0
 /**
  * function to send nudge email on a note
  * @param integer $idnotes
  * @param string $note_content
  * @param integer $related_module_id
  * @param integer $sqcrm_record_id
  */
 public function send_note_nudge_email($idnotes, $note_content, $related_module_id, $sqcrm_record_id)
 {
     if ((int) $idnotes > 0) {
         $mentioned_email_receiptents = array();
         preg_match_all("/(^|[^@\\w])@(\\w{1,15})\\b/im", $note_content, $mentioned_users);
         if (is_array($mentioned_users) && array_key_exists(2, $mentioned_users) && count($mentioned_users[2]) > 0) {
             $do_user = new \User();
             $active_users = $do_user->get_active_users();
             $current_user = 0;
             $active_users_key_as_username = array();
             foreach ($active_users as $key => $users) {
                 if ($users["iduser"] == $current_user) {
                     continue;
                 }
                 $active_users_key_as_username[$users["user_name"]] = array("firstname" => $users["firstname"], "lastname" => $users["lastname"], "email" => $users["email"]);
             }
             foreach ($mentioned_users[2] as $key => $val) {
                 if (array_key_exists($val, $active_users_key_as_username)) {
                     $mentioned_email_receiptents[] = $active_users_key_as_username[$val];
                 }
             }
         }
         if (is_array($mentioned_email_receiptents) && count($mentioned_email_receiptents) > 0) {
             $email_template = new \EmailTemplate("send_notes_user_mentioned_email");
             $emailer = new \SQEmailer();
             $do_module = new \Module();
             $do_module->getId($related_module_id);
             $entity_url = \NavigationControl::getNavigationLink($do_module->name, 'detail', $sqcrm_record_id, '#note' . $idnotes);
             $view_url = '<a href="' . SITE_URL . $entity_url . '">' . _('view on sQcrm') . '</a>';
             $note_content = \FieldType200::display_value($note_content);
             $note_content = str_replace('/themes/images/emoji-pngs', SITE_URL . '/themes/images/emoji-pngs', $note_content);
             foreach ($mentioned_email_receiptents as $key => $mentioned) {
                 $to_email = $mentioned["email"];
                 $email_data = array("notes_content" => $note_content, "firstname" => $mentioned["firstname"], "lastname" => $mentioned["lastname"], "view_url" => $view_url, "module_name" => \CommonUtils::get_module_name_as_text($related_module_id), "user_name" => $_SESSION["do_user"]->user_name);
                 $emailer->IsSendmail();
                 $emailer->setEmailTemplate($email_template);
                 $emailer->mergeArray($email_data);
                 $emailer->AddAddress($to_email, $mentioned["firstname"] . ' ' . $mentioned["lastname"]);
                 $emailer->send();
             }
         }
     }
 }