Ejemplo 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);
     }
 }
Ejemplo n.º 2
0
// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt
/**
* Cronjob to send event reminder
* Usually it should run every minute round the clock.
* $GLOBALS['cfg_full_path'] is the path to the CRM root so that the cron job could be 
* set outside web access directory which is recomended
* TODO : 
* In the current version it does not care about the individual user time zone before sending the email
* So in the future version need to implement the code such that emails are send as per the user timezone
* @author Abhik Chakraborty
*/
$GLOBALS['cfg_full_path'] = '/var/www/sqcrm/';
include_once $GLOBALS['cfg_full_path'] . 'config.php';
$email_template = new EmailTemplate("event_reminder");
$emailer = new SQEmailer();
$do_event_reminder = new EventsReminder();
$do_event_reminder->get_reminder_emails_to_send();
$do_calendar = new Calendar();
$now = date("Y-m-d H:i:s");
if ($do_event_reminder->getNumRows() > 0) {
    while ($do_event_reminder->next()) {
        $d = $do_event_reminder->days;
        $h = $do_event_reminder->hours;
        $m = $do_event_reminder->minutes;
        if (strlen($do_event_reminder->email_ids) > 3) {
            $additional_email = explode(",", $do_event_reminder->email_ids);
            if (is_array($additional_email) && count($additional_email) > 0) {
                $email_to_array = array();
                $email_to_array[0] = $additional_email;
            }
Ejemplo 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();
     }
 }
Ejemplo 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();
             }
         }
     }
 }