public function indexAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $date = new Zend_Date();
     $email_model = new Default_Model_EmailLogs();
     $cron_model = new Default_Model_Cronstatus();
     // appraisal notifications
     $this->checkperformanceduedate();
     // feed forward notifications
     // $this->checkffduedate();
     $cron_status = $cron_model->getActiveCron('General');
     if ($cron_status == 'yes') {
         try {
             //updating cron status table to in-progress
             $cron_data = array('cron_status' => 1, 'cron_type' => 'General', 'started_at' => gmdate("Y-m-d H:i:s"));
             $cron_id = $cron_model->SaveorUpdateCronStatusData($cron_data, '');
             if ($cron_id != '') {
                 $mail_data = $email_model->getNotSentMails();
                 if (count($mail_data) > 0) {
                     foreach ($mail_data as $mdata) {
                         $options = array();
                         $options['header'] = $mdata['header'];
                         $options['message'] = $mdata['message'];
                         $options['subject'] = $mdata['emailsubject'];
                         $options['toEmail'] = $mdata['toEmail'];
                         $options['toName'] = $mdata['toName'];
                         if ($mdata['cc'] != '') {
                             $options['cc'] = $mdata['cc'];
                         }
                         if ($mdata['bcc'] != '') {
                             $options['bcc'] = $mdata['bcc'];
                         }
                         // to send email
                         $mail_status = sapp_Mail::_email($options);
                         $mail_where = array('id=?' => $mdata['id']);
                         $new_maildata['modifieddate'] = gmdate("Y-m-d H:i:s");
                         if ($mail_status === true) {
                             $new_maildata['is_sent'] = 1;
                             //to udpate email log table that mail is sent.
                             $id = $email_model->SaveorUpdateEmailData($new_maildata, $mail_where);
                         }
                     }
                     //end of for loop
                 }
                 //end of mails count if
                 //updating cron status table to completed.
                 $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
 }
Example #2
0
 public function sendpasswordAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('sendpassword', 'json')->initContext();
     $emailaddress = $this->_request->getParam('emailaddress');
     $user = new Default_Model_Users();
     $result['result'] = '';
     $result['message'] = '';
     if ($emailaddress) {
         $isvalidemail = filter_var($emailaddress, FILTER_VALIDATE_EMAIL);
     }
     if ($emailaddress == '') {
         $result['result'] = 'error';
         $result['message'] = 'Please enter email.';
     } else {
         if ($emailaddress != $isvalidemail) {
             $result['result'] = 'error';
             $result['message'] = 'Please enter valid email.';
         } else {
             $emailexists = $user->getEmailAddressCount($emailaddress);
             $emailcount = $emailexists[0]['emailcount'];
             $username = $emailexists[0]['userfullname'];
             if ($emailcount > 0) {
                 $generatedPswd = uniqid();
                 $encodedPswd = md5($generatedPswd);
                 $user->updatePwd($encodedPswd, $emailaddress);
                 $options['subject'] = APPLICATION_NAME . ' Password Change';
                 $options['header'] = APPLICATION_NAME . ' Password';
                 $options['toName'] = $username;
                 $options['toEmail'] = $emailaddress;
                 $options['message'] = "<div>Hello " . $username . ",</div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div>Your password for " . APPLICATION_NAME . " application has been changed. Following is the new password <b>" . $generatedPswd . "</b>.</div>";
                 $res = sapp_Mail::_email($options);
                 if ($res === true) {
                     $result['result'] = 'success';
                     $result['message'] = 'New password is sent to given E-mail';
                 } else {
                     $result['result'] = 'error';
                     $result['message'] = 'Problem sending email. Try again later.';
                 }
             } else {
                 $empdetailsbyemailaddress = $user->getEmpDetailsByEmailAddress($emailaddress);
                 if (!empty($empdetailsbyemailaddress)) {
                     $username = $empdetailsbyemailaddress[0]['userfullname'];
                     $status = $empdetailsbyemailaddress[0]['isactive'];
                     $isaccountlock = $empdetailsbyemailaddress[0]['emptemplock'];
                     if ($status == 0) {
                         $result['result'] = 'error';
                         $result['message'] = 'Employee has been inactivated from the organization.';
                     } else {
                         if ($status == 2) {
                             $result['result'] = 'error';
                             $result['message'] = 'Employee has resigned from the organization.';
                         } else {
                             if ($status == 3) {
                                 $result['result'] = 'error';
                                 $result['message'] = 'Employee has left the organization.';
                             } else {
                                 if ($status == 4) {
                                     $result['result'] = 'error';
                                     $result['message'] = 'Employee has been suspended from the organization.';
                                 } else {
                                     if ($status == 5) {
                                         $result['result'] = 'error';
                                         $result['message'] = 'Employee deleted.';
                                     } else {
                                         if ($isaccountlock == 1) {
                                             $result['result'] = 'error';
                                             $result['message'] = 'Employee has been locked.';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     if ($emailcount == 0) {
                         $result['result'] = 'error';
                         $result['message'] = 'Email does not exist.';
                     }
                 }
             }
         }
     }
     $this->_helper->json($result);
 }
Example #3
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";
         }
     }
 }
    public function save_email_settings($form)
    {
        $auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity()) {
            $loginUserId = $auth->getStorage()->read()->id;
            $loginuserGroup = $auth->getStorage()->read()->group_id;
            $loginuserName = $auth->getStorage()->read()->userfullname;
        }
        $msgarray = array();
        $errorflag = 'true';
        if (extension_loaded('openssl')) {
            $errorflag = 'true';
        } else {
            $msgarray['tls'] = 'Openssl is not configured';
            $errorflag = 'false';
        }
        if ($form->isValid($this->_request->getPost()) && $errorflag == 'true') {
            $id = $this->_request->getParam('id');
            $username = $this->_request->getParam('username');
            $password = $this->_request->getParam('password');
            $server_name = $this->_request->getParam('server_name');
            $tls = $this->_request->getParam('tls');
            $auth = $this->_request->getParam('auth');
            $port = $this->_request->getParam('port');
            $usersModel = new Default_Model_Users();
            $options = array();
            if ($auth == 1) {
                $auth = 'crammd5';
            } else {
                if ($auth == 2) {
                    $auth = 'login';
                } else {
                    if ($auth == 3) {
                        $auth = 'plain';
                    } else {
                        $auth = 'crammd5';
                    }
                }
            }
            $options['username'] = $username;
            $options['password'] = $password;
            $options['server_name'] = $server_name;
            $options['tls'] = $tls;
            $options['auth'] = $auth;
            $options['port'] = $port;
            $options['subject'] = 'Test Mail Checking';
            $options['header'] = 'Test Mail';
            $options['fromEmail'] = DONOTREPLYEMAIL;
            $options['fromName'] = DONOTREPLYNAME;
            $options['toEmail'] = SUPERADMIN_EMAIL;
            $options['toName'] = $loginuserName;
            $options['message'] = '<div>
												<div>Hi ' . ucfirst($loginuserName) . ',</div><br/>
												<div>This is a test email to check the new mail settings provided for ' . APPLICATION_NAME . '.</div></div>';
            $result = sapp_Mail::_checkMail($options);
            if ($result == 'success') {
                $data = array('username' => $username, 'password' => $password, 'server_name' => $server_name, 'auth' => $auth, 'tls' => $tls, 'port' => $port, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                if ($id != '') {
                    $where = array('id=?' => $id);
                } else {
                    $data['createddate'] = gmdate("Y-m-d H:i:s");
                    $where = '';
                }
                $Id = $usersModel->addOrUpdateSettingsData($data, $where);
                sapp_Global::writeEMailSettingsconstants($tls, $auth, $port, $username, $password, $server_name);
                if ($Id == 'update') {
                    $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Mail Settings updated successfully."));
                } else {
                    $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Mail Settings added successfully."));
                }
            } else {
                $this->_helper->getHelper("FlashMessenger")->addMessage(array("error" => "Invalid parameters."));
            }
            $this->_redirect('dashboard/emailsettings');
        } else {
            $messages = $form->getMessages();
            foreach ($messages as $key => $val) {
                foreach ($val as $key2 => $val2) {
                    $msgarray[$key] = $val2;
                    break;
                }
            }
            return $msgarray;
        }
    }
Example #5
0
 /**
  * 
  * @param type $options
  * @return string
  */
 public static function _sendCalendarEmailOld($options)
 {
     $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 = "From: " . $from_name . " <" . $from_address . ">\n";
     $headers .= "Reply-To: " . $from_name . " <" . $from_address . ">\n";
     $headers .= "MIME-Version: 1.0\n";
     $headers .= "Content-Type: multipart/alternative; boundary=\"{$mime_boundary}\"\n";
     $headers .= "Content-class: urn:content-classes:calendarmessage\n";
     //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" . 'DESCRIPTION:' . $description . "\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);
         $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";
         }
     }
 }