Esempio n. 1
0
 /**
  * This action is used to send notification to inactive users.
  */
 public function inactiveusersAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $email_model = new Default_Model_EmailLogs();
     $cron_model = new Default_Model_Cronstatus();
     $cron_status = $cron_model->getActiveCron('Inactive users');
     if ($cron_status == 'yes') {
         try {
             //updating cron status table to in-progress
             $cron_data = array('cron_status' => 1, 'cron_type' => 'Inactive users', 'started_at' => gmdate("Y-m-d H:i:s"));
             $cron_id = $cron_model->SaveorUpdateCronStatusData($cron_data, '');
             if ($cron_id != '') {
                 $calc_date = new DateTime(date('Y-m-d'));
                 $calc_date->sub(new DateInterval('P3M'));
                 $print_date = $calc_date->format(DATEFORMAT_PHP);
                 $calc_date = $calc_date->format('Y-m-d');
                 $mail_data = $email_model->getInactiveusersData($calc_date);
                 if (count($mail_data) > 0) {
                     foreach ($mail_data as $did => $mdata) {
                         $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                         $view = $this->getHelper('ViewRenderer')->view;
                         $this->view->emp_name = $mdata['userfullname'];
                         $this->view->print_date = $print_date;
                         $this->view->user_id = $mdata['employeeId'];
                         $this->view->base_url = $base_url;
                         $text = $view->render('mailtemplates/inactiveusercron.phtml');
                         $options['subject'] = APPLICATION_NAME . ': Sentrifugo account inactivated';
                         $options['header'] = 'Employee inactivated';
                         $options['toEmail'] = $mdata['emailaddress'];
                         $options['toName'] = $mdata['userfullname'];
                         $options['message'] = $text;
                         $options['cron'] = 'yes';
                         sapp_Global::_sendEmail($options);
                     }
                 }
                 $cron_data = array('cron_status' => 0, 'completed_at' => gmdate("Y-m-d H:i:s"));
                 $cron_id = $cron_model->SaveorUpdateCronStatusData($cron_data, "id = " . $cron_id);
             }
             //end of cron status id if
         } catch (Exception $e) {
         }
     }
     //end of cron status if
 }
Esempio n. 2
0
 /**
  * This function is used to send mail.
  * @param Array $options  = data that needed to send email
  * @return string On success id ,on failure error message.
  */
 public static function _sendEmail($options)
 {
     $email_model = new Default_Model_EmailLogs();
     $date = new Zend_Date();
     if (is_array($options['toEmail'])) {
         $toemailData = implode(',', $options['toEmail']);
     } else {
         $toemailData = $options['toEmail'];
     }
     $data = array('toEmail' => $toemailData, 'toName' => isset($options['toName']) ? $options['toName'] : NULL, 'emailsubject' => $options['subject'], 'header' => $options['header'], 'message' => $options['message'], 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'));
     $empArrList = '';
     if (isset($options['cc'])) {
         $data['cc'] = $options['cc'];
     }
     if (isset($options['bcc'])) {
         if (!empty($options['bcc'])) {
             $empArrList = implode(',', $options['bcc']);
         }
         $data['bcc'] = $empArrList;
         //$options['bcc']     =  $empArrList;
     }
     $id = $email_model->SaveorUpdateEmailData($data, '');
     if (!isset($options['cron'])) {
         //echo "<pre>";print_r($options);
         $mail_status = sapp_Mail::_email($options);
         $where = array('id=?' => $id);
         $newdata['modifieddate'] = $date->get('yyyy-MM-dd HH:mm:ss');
         $newdata['is_sent'] = 1;
         if ($mail_status === true) {
             $id = $email_model->SaveorUpdateEmailData($newdata, $where);
             return $id;
         } else {
             return "fail";
         }
     }
 }
Esempio n. 3
0
 public static function _sendCalendarEmailOld1($options)
 {
     // Pear Mail Library
     require_once "Mail.php";
     $email_model = new Default_Model_EmailLogs();
     $date = new Zend_Date();
     if (is_array($options['toEmail'])) {
         $toemailData = implode(',', $options['toEmail']);
     } else {
         $toemailData = $options['toEmail'];
     }
     $meeting_duration = 3600;
     // 1hours
     $ISTTimeDifferenceInMS = 16200;
     $from_address = !empty($options['fromEmail']) ? $options['fromEmail'] : SUPERADMIN_EMAIL;
     $from_name = !empty($options['fromName']) ? $options['fromName'] : DONOTREPLYNAME;
     $to_name = isset($options['toName']) ? $options['toName'] : NULL;
     $to_address = $toemailData;
     $startTime = !empty($options['starttime']) ? $options['starttime'] : "01/01/2015 13:00:00";
     /* Meeting Stamp = Interview Date + Time */
     $startdatetime = sprintf("%s %s", $options['interviewdate'], $options['starttime']);
     $meetingstamp = STRTOTIME($startdatetime . " UTC");
     //$endTime = (!empty($options['endtime'])) ? $options['endtime'] : "01/01/2015 14:00:00";
     //$meetingstamp = STRTOTIME($startTime . " UTC");
     $dtstart = GMDATE("Ymd\\THis\\Z", $meetingstamp - $ISTTimeDifferenceInMS);
     $dtend = GMDATE("Ymd\\THis\\Z", $meetingstamp - ($ISTTimeDifferenceInMS + $meeting_duration));
     $subject = $options['subject'];
     $description = str_replace("\r\n", "\\n", $options['message']);
     $location = !empty($options['location']) ? $options['location'] : "Delta HR Office";
     $domain = 'deltaintech.com';
     $cal_unique_id = isset($options['calUniqueID']) ? $options['calUniqueID'] : date("Ymd\\TGis", strtotime($startTime)) . rand() . "@" . $domain;
     $cal_method = isset($options['method']) ? $options['method'] : 'REQUEST';
     $mime_boundary = "----Meeting Booking----" . MD5(TIME());
     $headers = array("From" => $from_name . " <" . $from_address . ">", "Reply-To" => $from_name . " <" . $from_address . ">", "MIME-Version" => "1.0", "Content-Type" => "multipart/alternative; boundary=\"{$mime_boundary}\"", "Content-class" => "urn:content-classes:calendarmessage");
     //Create Email Body (HTML)
     $message = "--{$mime_boundary}\r\n";
     $message .= "Content-Type: text/html; charset=UTF-8\n";
     $message .= "Content-Transfer-Encoding: 8bit\n\n";
     $message .= "<html>\n";
     $message .= "<body>\n";
     $message .= '<p>Dear ' . $to_name . ',</p>';
     $message .= '<p>' . $description . '</p>';
     $message .= "</body>\n";
     $message .= "</html>\n";
     $message .= "--{$mime_boundary}\r\n";
     $ical = 'BEGIN:VCALENDAR' . "\r\n" . 'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" . 'VERSION:2.0' . "\r\n" . 'METHOD:' . $cal_method . "\r\n" . 'BEGIN:VTIMEZONE' . "\r\n" . 'TZID:(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi' . "\r\n" . 'BEGIN:STANDARD' . "\r\n" . 'DTSTART:20091101T020000' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "\r\n" . 'TZOFFSETFROM:-0400' . "\r\n" . 'TZOFFSETTO:-0500' . "\r\n" . 'TZNAME:EST' . "\r\n" . 'END:STANDARD' . "\r\n" . 'BEGIN:DAYLIGHT' . "\r\n" . 'DTSTART:20090301T020000' . "\r\n" . 'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "\r\n" . 'TZOFFSETFROM:-0500' . "\r\n" . 'TZOFFSETTO:-0400' . "\r\n" . 'TZNAME:EDST' . "\r\n" . 'END:DAYLIGHT' . "\r\n" . 'END:VTIMEZONE' . "\r\n" . 'BEGIN:VEVENT' . "\r\n" . 'ORGANIZER;CN="' . $from_name . '":MAILTO:' . $from_address . "\r\n" . 'ATTENDEE;CN="' . $to_name . '";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:' . $to_address . "\r\n" . 'LAST-MODIFIED:' . date("Ymd\\TGis") . "\r\n" . 'UID:' . $cal_unique_id . "\r\n" . 'DTSTAMP:' . date("Ymd\\TGis") . "\r\n" . 'DTSTART:' . $dtstart . "\r\n" . 'DTEND:' . $dtend . "\r\n" . 'TRANSP:OPAQUE' . "\r\n" . 'SEQUENCE:1' . "\r\n" . 'SUMMARY:' . $subject . "\r\n" . 'LOCATION:' . $location . "\r\n" . 'CLASS:PUBLIC' . "\r\n" . 'PRIORITY:5' . "\r\n" . 'BEGIN:VALARM' . "\r\n" . 'TRIGGER:-PT15M' . "\r\n" . 'ACTION:DISPLAY' . "\r\n" . 'DESCRIPTION:Reminder' . "\r\n" . 'END:VALARM' . "\r\n" . 'END:VEVENT' . "\r\n" . 'END:VCALENDAR' . "\r\n";
     $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST\\n';
     $message .= "Content-Transfer-Encoding: 8bit\n\n";
     $message .= $ical;
     //$options['ical'] = (!empty($options['ical'])) ? $options['ical'] : $ical;
     $options['message'] = $message;
     $data = array('toEmail' => $toemailData, 'toName' => isset($options['toName']) ? $options['toName'] : NULL, 'emailsubject' => $options['subject'], 'header' => $options['header'], 'message' => $message, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'));
     /* if (isset($options['cc']))
        $data['cc'] = $options['cc'];
        if (isset($options['bcc']))
        $data['bcc'] = $options['bcc']; */
     $id = $email_model->SaveorUpdateEmailData($data, '');
     if (!isset($options['cron'])) {
         //$mail_status = sapp_Mail::_emailascalendar($options);
         $smtp = Mail::factory('smtp', array('host' => MAIL_TLS . '://' . MAIL_SMTP, 'port' => MAIL_PORT, 'auth' => true, 'username' => MAIL_USERNAME, 'password' => MAIL_PASSWORD));
         $mail_status = $smtp->send($to_address, $headers, $message);
         $where = array('id=?' => $id);
         $newdata['modifieddate'] = $date->get('yyyy-MM-dd HH:mm:ss');
         $newdata['is_sent'] = 1;
         if ($mail_status) {
             $id = $email_model->SaveorUpdateEmailData($newdata, $where);
             return $id;
         } else {
             return "fail";
         }
     }
 }