/** * @name deleteAction * * This action is used to delete the agency and its point of contacts. * @author Asma * @version 1.0 */ public function deleteAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $login_user = $auth->getStorage()->read()->userfullname; } $id = $this->_request->getParam('objid'); $messages['message'] = ''; $messages['msgtype'] = ''; $actionflag = 3; if ($id) { $agencylistmodel = new Default_Model_Agencylist(); $childIds = $agencylistmodel->deleteAgencyData($id, $loginUserId); $deleteBGchecks = $agencylistmodel->deleteBGcheckdetails($id, $loginUserId); if ($childIds) { $menuID = AGENCYLIST; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); $messages['message'] = 'Agency is deleted successfully.'; $messages['msgtype'] = 'success'; $agencydata = $agencylistmodel->getAgencyEmail($id); $agencyname = $agencydata['userfullname']; $agencyemail = $agencydata['emailaddress']; /* Mail to agency */ $options['subject'] = APPLICATION_NAME . ' :: Agency is deleted'; $options['header'] = 'Agency deleted'; $options['toEmail'] = $agencyemail; $options['toName'] = $agencyname; $options['message'] = '<div> <div> Dear ' . $agencyname . ',</div> We regret to inform you that your agency has been deleted. <div></div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); /* Mails to All HR and Management Emails */ $emailids = $agencylistmodel->getAllHRManagementEMails(); foreach ($emailids as $email) { $options['subject'] = APPLICATION_NAME . ' :: Agency is Deleted'; $options['header'] = 'Agency deleted'; $options['toEmail'] = $email['groupEmail']; $options['toName'] = $email['group_name']; if ($email['group_id'] == 4) { $salutation = 'Dear HR,'; } else { $salutation = 'Dear Management,'; } $custom_base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $options['message'] = '<div> <div>' . $salutation . ' </div> <div></div> ' . $agencyname . ' agency has been deleted by ' . $login_user . '. <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $custom_base_url . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login and check the agency details.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } } else { $messages['message'] = 'Agency cannot be deleted.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Agency cannot be deleted.'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); }