/** * 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 }