예제 #1
0
 public function __construct($config = array())
 {
     parent::__construct($config = array());
     // add the path to the scripts
     $this->setScriptPath(APPLICATION_PATH . "/views/scripts/email/");
     $this->appname = getAppName();
     $config = Zend_Registry::get("config");
     // default sign off name and email
     $mail = Zend_Registry::get('mail');
     $default_sender = $mail->getDefaultFrom();
     //$this->signoffname = $default_sender['name'];
     //$this->signoffemail = $default_sender['email'];
     $this->signoffname = getDefaultAdminName();
     $this->signoffemail = getDefaultAdminEmail();
     $this->contactusurl = $this->serverUrl($this->baseUrl('contactus'));
     $this->logourl = $this->serverUrl($this->baseUrl('images/logo.jpg'));
     $this->loginurl = $this->serverUrl($this->baseUrl('user/login'));
     $this->baseurl = $this->serverUrl($this->baseUrl());
     $this->settingsurl = $this->serverUrl($this->baseUrl('profile/view/tab/account'));
     $allcolors = getAllThemeColors();
     //debugMessage($allcolors);
     $colortxt = getThemeColor();
     $themecolor = "blue";
     if (!isEmptyString($colortxt)) {
         $themecolor = $colortxt;
     }
     $this->themecolor = $allcolors[$themecolor];
     // debugMessage('color is '.$allcolors[$themecolor]);
 }
예제 #2
0
 function sendActivationConfirmationNotification()
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     $view = new Zend_View();
     $session = SessionWrapper::getInstance();
     // assign values
     $template->assign('firstname', $this->getFirstName());
     $subject = "Account Activation";
     $save_toinbox = true;
     $type = "useraccount";
     $subtype = "profile_activated";
     $message_contents = "<p>This is to confirm that your Account has been successfully activated. </p>\n\t\t<p>You can login anytime at " . $view->serverUrl($view->baseUrl('user/login')) . " using any of your identities(email or username) and the password you provided during registration. </p>\n\t\t<p>If you happen to forget your login credentials, go to " . $view->serverUrl($view->baseUrl('user/recoverpassword')) . ". For any other issues, questions or feedback, please feel free to contact us.</p>";
     $template->assign('contents', $message_contents);
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     // configure base stuff
     $mail->addTo($this->getEmail(), $this->getName());
     // set the send of the email address
     $mail->setFrom(getDefaultAdminEmail(), getDefaultAdminName());
     $subject = sprintf($this->translate->_('profile_email_subject_invite_confirmation'), getAppName());
     $mail->setSubject($subject);
     // render the view as the body of the email
     $html = $template->render('default.phtml');
     $mail->setBodyHtml($html);
     // debugMessage($html); // exit();
     try {
         $mail->send();
     } catch (Exception $e) {
         $session->setVar(ERROR_MESSAGE, 'Email notification not sent! ' . $e->getMessage());
     }
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     if ($save_toinbox) {
         # save copy of message to user's application inbox
         $message_dataarray = array("senderid" => DEFAULT_ID, "subject" => $subject, "contents" => $message_contents, "html" => $html, "type" => $type, "subtype" => $subtype, "refid" => $this->getID(), "recipients" => array(md5(1) => array("recipientid" => $this->getID())));
         // debugMessage($message_dataarray);
         // process message data
         $message = new Message();
         $message->processPost($message_dataarray);
         $message->save();
     }
     return true;
 }
예제 #3
0
 function sendPayslipNotification()
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     $view = new Zend_View();
     $session = SessionWrapper::getInstance();
     // assign values
     $template->assign('firstname', $this->getUser()->getFirstName());
     $subject = "Payslip " . date('F Y', strtotime($this->getPayroll()->getStartDate()));
     $save_toinbox = true;
     $type = "payroll";
     $subtype = "payslip_generated";
     $viewurl = $template->serverUrl($template->baseUrl('temp/' . $this->getPDFName() . '.pdf'));
     $message_contents = "<p>This is to confirm that your Payslip for <b>" . date('F Y', strtotime($this->getPayroll()->getStartDate())) . "</b> has been completed and attached.</p>\n\t\t<p>You can also view it online <a href='" . $viewurl . "'>click here<a></p>\n\t\t<br />\n\t\t<p>" . $this->getPayroll()->getCreator()->getName() . "<br />\n\t\t" . getAppName() . "</p>\n\t\t";
     $template->assign('contents', $message_contents);
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     // configure base stuff
     $mail->addTo($this->getUser()->getEmail(), $this->getUser()->getName());
     // set the send of the email address
     $mail->setFrom(getDefaultAdminEmail(), getDefaultAdminName());
     $mail->setSubject($subject);
     // add attachment
     $content = file_get_contents($this->getPDFPath());
     // e.g. ("attachment/abc.pdf")
     $attachment = new Zend_Mime_Part($content);
     $attachment->type = 'application/pdf';
     $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
     $attachment->encoding = Zend_Mime::ENCODING_BASE64;
     $attachment->filename = $this->getPDFName();
     // name of file
     $mail->addAttachment($attachment);
     // render the view as the body of the email
     $html = $template->render('default.phtml');
     $mail->setBodyHtml($html);
     // debugMessage($html); // exit();
     if ($this->getUser()->allowEmailForPayslip() && !isEmptyString($this->getUser()->getEmail())) {
         try {
             $mail->send();
             // $session->setVar("custommessage1", "Email sent to ".$this->getUser()->getEmail());
         } catch (Exception $e) {
             debugMessage('Email notification not sent! ' . $e->getMessage());
             $session->setVar(ERROR_MESSAGE, 'Email notification not sent! ' . $e->getMessage());
         }
     }
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     if ($save_toinbox) {
         # save copy of message to user's application inbox
         $message_dataarray = array("senderid" => DEFAULT_ID, "subject" => $subject, "contents" => $message_contents, "html" => $html, "type" => $type, "subtype" => $subtype, "refid" => $this->getID(), "recipients" => array(md5(1) => array("recipientid" => $this->getUserID())));
         // debugMessage($message_dataarray);
         // process message data
         $message = new Message();
         $message->processPost($message_dataarray);
         $message->save();
     }
     return true;
 }
예제 #4
0
 function sendApprovalConfirmationNotification()
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     $view = new Zend_View();
     $session = SessionWrapper::getInstance();
     // assign values
     $template->assign('firstname', $this->getUser()->getFirstName());
     $statuslabel = $this->isApproved() ? "Approved" : "Rejected";
     $subject = "Leave " . $statuslabel;
     $save_toinbox = true;
     $type = "leave";
     $subtype = "leave_" . strtolower($statuslabel);
     $viewurl = $template->serverUrl($template->baseUrl('leave/view/id/' . encode($this->getID())));
     $rejectreason = "";
     if ($this->isRejected()) {
         $rejectreason = "<br><b>Synopsis:</b> " . $this->getComments() . "";
     }
     $days = $this->getDuration() / getHoursInDay();
     $message_contents = "<p>This is to confirm that your Leave Request from <b>" . changeMySQLDateToPageFormat($this->getStartDate()) . "</b> to <b> " . changeMySQLDateToPageFormat($this->getEndDate()) . "</b> has been successfully " . $statuslabel . $rejectreason . ".</p>\n\t\t<p>To view your request online <a href='" . $viewurl . "'>click here<a></p>\n\t\t<br />\n\t\t<p>" . $this->getApprover()->getName() . "<br />\n\t\t" . getAppName() . "</p>\n\t\t";
     $template->assign('contents', $message_contents);
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     // configure base stuff
     $mail->addTo($this->getUser()->getEmail(), $this->getUser()->getName());
     // set the send of the email address
     $mail->setFrom(getDefaultAdminEmail(), getDefaultAdminName());
     $mail->setSubject($subject);
     // render the view as the body of the email
     $html = $template->render('default.phtml');
     $mail->setBodyHtml($html);
     // debugMessage($html); exit();
     if ($this->getUser()->allowEmailForTimesheetApproval() && !isEmptyString($this->getUser()->getEmail())) {
         try {
             $mail->send();
             $session->setVar("custommessage1", "Email sent to " . $this->getUser()->getEmail());
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, 'Email notification not sent! ' . $e->getMessage());
         }
     }
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     if ($save_toinbox) {
         # save copy of message to user's application inbox
         $message_dataarray = array("senderid" => DEFAULT_ID, "subject" => $subject, "contents" => $message_contents, "html" => $html, "type" => $type, "subtype" => $subtype, "refid" => $this->getID(), "recipients" => array(md5(1) => array("recipientid" => $this->getUserID())));
         // debugMessage($message_dataarray);
         // process message data
         $message = new Message();
         $message->processPost($message_dataarray);
         $message->save();
     }
     return true;
 }
예제 #5
0
 /**
  * Send a notification to a user that a private message has been sent to them
  * 
  * @return Bool whether the email notification has been sent
  *
  */
 function sendInboxEmailNotification($fromemail, $fromname, $subject = '')
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     $sendername = $this->getSender()->getName();
     if (!isEmptyString($fromname)) {
         $sendername = $fromname;
     }
     $senderemail = getEmailMessageSender();
     if (!isEmptyString($fromemail)) {
         $senderemail = $fromemail;
     }
     // debugMessage($this->getRecipients()->toArray());
     // the message reciever's first name
     $template->assign('firstname', $this->getRecipient()->getFirstName());
     // the message sender's name
     $template->assign('emailsender', $sendername);
     $subject = $this->getSubject();
     if (isEmptyString($this->getSubject())) {
         $subject = sprintf($this->translate->_('message_private_email_subject'), $sendername);
     }
     // message subject
     $mail->setSubject($subject);
     // message introduction
     $template->assign('emailintro', sprintf($this->translate->_('message_private_email_subject'), $sendername));
     // message contents
     $template->assign('emailcontent', nl2br($this->getContents()));
     // the actual url will be built in the view
     $template->assign('emaillink', array("controller" => "message", "action" => "reply", "id" => encode($this->getID())));
     // message html file
     $mail->setBodyHtml($template->render('messagenotification.phtml'));
     // debugMessage($template->render('messagenotification.phtml'));
     // add the recipient emails TODO if sent to many users, add all their emails
     $mail->addTo($this->getRecipient()->getEmail());
     // $mail->addCc('*****@*****.**');
     // set the send of the email address
     $mail->setFrom($senderemail, getAppName());
     // send the message
     $mail->send();
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     return true;
 }
예제 #6
0
 /**
  * Send a notification to a user that a private message has been sent to them
  *
  * @return Bool whether the email notification has been sent
  *
  */
 function sendInboxEmailNotification($fromemail = '', $fromname = '', $subject = '', $toemail = '', $toname = '', $content = '')
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     # sender name
     $sendername = getAppName();
     $sendername = $this->getMessage()->getSender()->getName();
     if (!isEmptyString($fromname)) {
         $sendername = $fromname;
     }
     # sender email
     $senderemail = getDefaultAdminEmail();
     if (!isEmptyString($fromemail)) {
         $senderemail = $fromemail;
     }
     # receipient name
     $receivername = $this->getMessage()->getSender()->getFirstName();
     if (!isEmptyString($toname)) {
         $receivername = $toname;
     }
     # receipient email
     $receiveremail = $this->getMessage()->getSender()->getEmail();
     if (!isEmptyString($toemail)) {
         $receiveremail = $toemail;
     }
     # email subject
     $msgsubject = sprintf($this->translate->_('message_private_email_subject'), getAppName(), $subject);
     # email content
     $intro = "<p><i><b>" . $sendername . "</b> sent you a private message via <b>" . getAppName() . "</b> </i></p>";
     $msgcontent = '<p>"' . $this->getMessage()->getContents() . '"</p>';
     if (!isEmptyString($content)) {
         $msgcontent = '<p>"' . $content . '"</p>';
     }
     $viewurl = $template->serverUrl($template->baseUrl('message/view/id/' . encode($this->getID())));
     if (isEmptyString($this->getID())) {
         $viewurl = '';
     }
     $msgcontent .= '<p><a href="' . $viewurl . '">Click here</a> to view this message online</p>';
     // debugMessage($this->getRecipients()->toArray());
     // the message reciever's first name
     $template->assign('firstname', isEmptyString($toname) ? 'User' : $receivername);
     // the message sender's name
     $template->assign('emailsender', $sendername);
     // message subject
     $template->assign('subject', $msgsubject);
     $mail->setSubject($msgsubject);
     // add the recipient emails TODO if sent to many users, add all their emails
     $mail->addTo($toemail, $receivername);
     // set the send of the email address
     $mail->setFrom(getDefaultAdminEmail(), getAppName() . " on behalf of " . $fromname);
     // message contents
     $template->assign('emailcontent', $intro . nl2br($msgcontent));
     // the actual url will be built in the view
     $template->assign('emaillink', $viewurl);
     // message html file
     $mail->setBodyHtml($template->render('messagenotification.phtml'));
     // debugMessage($template->render('messagenotification.phtml'));
     // send the message
     try {
         $mail->send();
     } catch (Exception $e) {
         $session->setVar(ERROR_MESSAGE, 'Email notification not sent! ' . $e->getMessage());
     }
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     return true;
 }
예제 #7
0
 public function issuepayslipsAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit;
     $config = Zend_Registry::get("config");
     // generate the payslips silently via ajax
     $payroll = new Payroll();
     $payroll->populate($this->_getParam('id'));
     $employees = $payroll->getdetails();
     // debugMessage($employees->toArray());
     foreach ($employees as $employee) {
         if ($employee->getIsIgnored() != 1 && $employee->getNetPay() > 0) {
             // ignore users who are skipped on payroll or have 0 netpay
             $payrolldetailid = $employee->getID();
             $path = $employee->getPDFPath();
             $pdfurl = $this->view->serverUrl($this->view->baseUrl('user/view/id/' . encode($employee->getUserID()) . '/tab/payment/payrollid/' . $payrolldetailid . '/ref/view/print/1/pgc/1/payslipview/1/pdf/1/source/payroll'));
             // debugMessage($pdfurl);
             $pdfresult = trim(file_get_contents($pdfurl));
             $html = decode($pdfresult);
             // debugMessage($html); // exit;
             if (!isEmptyString($html)) {
                 try {
                     $mpdfpath = BASE_PATH . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'mpdf' . DIRECTORY_SEPARATOR . 'mpdf.php';
                     // debugMessage('pdf '.$mpdfpath);
                     ini_set('memory_limit', '128M');
                     require_once $mpdfpath;
                     // ob_get_clean();
                     $mpdf = new mPDF('win-1252', 'A4', '', '', 20, 15, 40, 20, 10, 10);
                     $mpdf->useOnlyCoreFonts = true;
                     // false is default
                     $mpdf->SetProtection(array('print'));
                     $mpdf->SetTitle("Payslip - " . $employee->getUser()->Name());
                     $mpdf->SetAuthor(getAppName());
                     $mpdf->SetWatermarkText(getCompanyName());
                     $mpdf->showWatermarkText = true;
                     $mpdf->watermark_font = 'DejaVuSansCondensed';
                     $mpdf->watermarkTextAlpha = 0.1;
                     $mpdf->SetDisplayMode('fullpage');
                     $mpdf->WriteHTML($html);
                     $mpdf->Output($path);
                     // $mpdf->Output($employee->getPDFName().'.pdf', 'I');
                 } catch (Exception $e) {
                     debugMessage('error ' . $e->getMessage());
                 }
                 if (file_exists($path)) {
                     debugMessage('pdf ' . $employee->getPDFName() . ' created ');
                     // $employee->afterPayslipGeneration();
                 } else {
                     debugMessage('pdf missing');
                 }
             }
         }
     }
     $session->setVar("issuepayslips", '0');
     // reset flag for determining if payslips are sent
 }
예제 #8
0
 /**
  * Backs up the database with an option of sending the backup via email 
  *
  */
 function backupAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $session = SessionWrapper::getInstance();
     $config = Zend_Registry::get('config');
     $formvalues = $this->_getAllParams();
     $result = array();
     $showverbose = true;
     $detect = '';
     if (!isEmptyString($this->_getParam('triggered'))) {
         $showverbose = false;
     }
     if ($this->_getParam('autocron') == 'yes') {
         $detect = '_cron';
     }
     # get the database connection parameters
     $db_params = Zend_Controller_Front::getInstance()->getParam("bootstrap")->getPluginResource('db')->getParams();
     // debugMessage($db_params);
     #  configure your database variables below:
     $host_array = explode(":", $db_params['host']);
     $dbhost = $host_array[0];
     #  Server address of your MySQL Server
     $dbuser = $db_params['username'];
     #  Username to access MySQL database
     $dbpass = $db_params['password'];
     #  Password to access MySQL database
     $dbname = $db_params['dbname'];
     #  Database Name
     $dbport = isArrayKeyAnEmptyString(1, $host_array) ? "3306" : "3356";
     // exit();
     # Optional Options You May Optionally Configure
     $use_gzip = $config->backup->usegzip;
     #  Set to No if you don't want the files sent in .gz format
     $remove_sql_file = $config->backup->removesqlfile;
     #  Set this to yes if you want to remove the .sql file after gzipping. Yes is recommended.
     $remove_gzip_file = $config->backup->removegzipfile;
     #  Set this to yes if you want to delete the gzip file also. I recommend leaving it to "no"
     # Configure the path that this script resides on your server.
     // $savepath = APPLICATION_PATH.$config->backup->scriptfolder; #  Full path to this directory. Do not use trailing slash!
     $savepath = BASE_PATH . DIRECTORY_SEPARATOR . 'backup';
     // debugMessage($savepath);
     $send_email = $config->backup->sendemail;
     #  Do you want this database backup sent to your email? Fill out the next 2 lines
     # email address
     $backupemail = $config->backup->backupemail;
     if (!isEmptyString($this->_getParam('email'))) {
         $backupemail = $this->_getParam('email');
     }
     # attachment mime type - default for a text attachment
     $attachment_mime_type = "text/plain";
     # set the maximum execution time to ensure that the backup is completed
     ini_set("max_execution_time", 600);
     $date = date("dMy_Hi");
     # sql backup filename
     $sqlattachmentname = $dbname . $detect . "_" . $date . ".sql";
     # zipped backup filename
     $gzipattachmentname = $dbname . "_" . $date . ".tar.gz";
     # sql backup path
     $sqlscriptpath = $savepath . DIRECTORY_SEPARATOR . $sqlattachmentname;
     # zipped backup path
     $zipfilepath = $savepath . DIRECTORY_SEPARATOR . $gzipattachmentname;
     # before backingup, move all current files at root to the archive folder
     $sqlfiles = glob($savepath . DIRECTORY_SEPARATOR . '*.sql');
     $tarfiles = glob($savepath . DIRECTORY_SEPARATOR . '*.tar.gz');
     $archivefiles = glob($savepath . DIRECTORY_SEPARATOR . 'archive' . DIRECTORY_SEPARATOR . '*');
     // debugMessage($sqlfiles);
     foreach ($sqlfiles as $afile) {
         $afile_filename = basename($afile);
         rename($afile, $savepath . DIRECTORY_SEPARATOR . 'archive' . DIRECTORY_SEPARATOR . $afile_filename);
     }
     foreach ($tarfiles as $afile) {
         $afile_filename = basename($afile);
         rename($afile, $savepath . DIRECTORY_SEPARATOR . 'archive' . DIRECTORY_SEPARATOR . $afile_filename);
     }
     $time = time();
     foreach ($archivefiles as $file) {
         if (is_file($file)) {
             $retentiondays = $config->backup->retentionperiod;
             $seconds = 60 * 60 * 24 * $retentiondays;
             // number of retention days for backup files. defaults to 7 days.
             // $seconds = 60; // debugMessage($time - filemtime($file));
             if ($time - filemtime($file) >= $seconds) {
                 // 2 days
                 // debugMessage($file);
                 unlink($file);
             }
         }
     }
     if ($this->_getParam('sql') == '1') {
         $use_gzip = "no";
         $remove_sql_file = "no";
         $remove_gzip_file = "no";
     }
     $tablesonly_sql = "";
     $ignore_sql = " ";
     if (!isEmptyString($this->_getParam('ignorelist'))) {
         $tables = str_replace(' ', '', $this->_getParam('ignorelist'));
         $tablearray = explode(',', $tables);
         if (count($tablearray) > 0) {
             foreach ($tablearray as $value) {
                 $ignore_sql .= " --ignore-table=" . $dbname . "." . $value . " ";
             }
         }
         //debugMessage($ignore_sql);
     }
     if (!isEmptyString($this->_getParam('tablelist'))) {
         $tables = str_replace(' ', '', $this->_getParam('tablelist'));
         $tablearray = explode(',', $tables);
         if (count($tablearray) > 0) {
             foreach ($tablearray as $value) {
                 $tablesonly_sql .= " " . $value . " ";
             }
         }
         // debugMessage($tablesonly_sql);
     }
     $backupcommand = "mysqldump -R --add-drop-table --complete-insert --add-locks --quote-names --lock-tables --skip-routines -h " . $ignore_sql . " " . $dbhost . " -P " . $dbport . " -u " . $dbuser . " -p" . $dbpass . " " . $dbname . $tablesonly_sql . ' > "' . $sqlscriptpath . '"';
     debugMessage($backupcommand);
     // exit();
     try {
         if (passthru($backupcommand)) {
             // exit();
             if ($showverbose) {
                 debugMessage(getAppName() . " Database backup completed to " . $sqlscriptpath);
             }
             # create tar archive
             if ($use_gzip == "yes") {
                 $zipline = "tar -czf " . $zipfilepath . " " . $sqlscriptpath;
                 passthru($zipline);
                 debugMessage($zipline);
                 debugMessage("Gzip of backup completed");
             }
             // exit();
             # set email attachment name and path depending on weather to form zip or not
             if ($use_gzip == "yes") {
                 $attachmentpath = $zipfilepath;
                 $attachmentname = $gzipattachmentname;
                 $attachment_mime_type = "application/gzip";
             } else {
                 $attachmentpath = $sqlscriptpath;
                 $attachmentname = $sqlattachmentname;
             }
             # send an email with a copy of the backup
             if ($send_email == "yes") {
                 $mail = Zend_Registry::get('mail');
                 # build the mailer class
                 // $mail->addTo($config->get(APPLICATION_ENV)->get("databasebackupemail"));
                 $mail->addTo($backupemail);
                 $mail->setFrom($config->notification->defaultadminemail, $config->notification->defaultadminname);
                 $mail->setSubject(sprintf($this->_translate->_("database_backup_subject"), getAppName(), date("j F Y h:iA")));
                 #  Subject in the email to be sent.
                 $mail->setBodyHtml(sprintf($this->_translate->_("database_backup_body"), getAppName()));
                 #  Brief Message.
                 # attachmentpath is the full path to the file and attachmentname is the name of the file
                 $at = new Zend_Mime_Part(file_get_contents($attachmentpath));
                 $at->filename = $attachmentname;
                 $at->disposition = Zend_Mime::DISPOSITION_INLINE;
                 $at->encoding = Zend_Mime::ENCODING_BASE64;
                 $at->type = $attachment_mime_type;
                 $mail->addAttachment($at);
                 // $mail->send();
                 try {
                     $mail->send();
                     $message = getAppName() . " Database backup sent to " . $backupemail;
                     if ($showverbose) {
                         debugMessage($message);
                     } else {
                         $result['message'] = $message;
                         $result['result'] = 1;
                     }
                 } catch (Exception $e) {
                     $message = 'Email notification not sent! ' . $e->getMessage();
                     if ($showverbose) {
                         debugMessage($message);
                     } else {
                         debugMessage($message);
                         $result['message'] = $message;
                         $result['result'] = 0;
                     }
                 }
                 $mail->clearRecipients();
                 $mail->clearSubject();
                 $mail->setBodyHtml('');
                 $mail->clearFrom();
             }
             # remove sql file if condition is set
             if ($remove_sql_file == "yes") {
                 passthru("rm -rf " . $sqlscriptpath);
             }
             # remove tar file if condition is set
             if ($remove_gzip_file == "yes") {
                 passthru("rm -rf " . $attachmentpath);
             }
             if ($this->_getParam('download') == '1') {
                 header('Location: ' . $this->view->serverUrl($this->view->baseUrl('backup/' . $sqlattachmentname)));
                 exit;
                 // file headers to force a download
                 /*header('Content-Description: File Transfer');
                 		header('Content-Type: application/octet-stream');
                 		// to handle spaces in the file names
                 		header("Content-Disposition: inline; filename=\"$sqlscriptpath\"");
                 		header('Content-Transfer-Encoding: binary');
                 		header('Expires: 0');
                 		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                 		header('Pragma: public');
                 		readfile($savepath);*/
             }
             if (!$showverbose) {
                 echo json_encode($result);
             }
         }
     } catch (Exception $e) {
         debugMessage($e->getMessage());
     }
 }