/** * @name deletepocAction * * This action is used to delete a point of contact of an agency. * @author Asma * @version 1.0 */ public function deletepocAction() { try { $pocsmodel = new Default_Model_Bgpocdetails(); $agencylistmodel = new Default_Model_Agencylist(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $poc_name = ''; $agencyid = $this->_request->getParam('agencyid'); $pocid = $this->_request->getParam('pocid'); $pocdata = $pocsmodel->getSingleagencyPOCData($pocid); if (!empty($pocdata[0])) { $poc_name = $pocdata[0]['first_name'] . ' ' . $pocdata[0]['last_name']; } $messages['message'] = ''; $messages['msgtype'] = ''; $actionflag = 3; if (isset($pocdata[0]['contact_type']) && $pocdata[0]['contact_type'] == '2') { if ($pocid && $agencyid) { $data = array('isactive' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = array('id=?' => $pocid, 'bg_agencyid=?' => $agencyid); $result = $pocsmodel->SaveorUpdatePOCDetails($data, $where); $result_2 = $pocsmodel->deleteBGcheckdetails($agencyid, $pocid, $loginUserId); // Mail to Secondary contact $options['subject'] = APPLICATION_NAME . ' :: POC is deleted'; $options['header'] = 'POC deleted'; $options['toEmail'] = trim($pocdata[0]['email']); $options['toName'] = $pocdata[0]['userfullname']; $salutation = 'Dear ' . $pocdata[0]['first_name'] . ','; $custom_base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $options['message'] = '<div> <div>' . $salutation . ' </div> <div></div> <div>You are deleted as a secondary point of contact from ' . $pocdata[0]['agencyname'] . ' agency.</div> <div> <table border="1" style="border-collapse:collapse;"> <tr><td>Name : </td><td>' . $poc_name . '</td></tr> <tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr> <tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr> </table> </div> <div></div> </div>'; $options['cron'] = 'Yes'; if ($options['toEmail'] != '') { $result_email = sapp_Global::_sendEmail($options); } // Mail to Primary contact $primary_poc = $pocsmodel->getPrimaryPOCData($agencyid); $primary_poc_name = $primary_poc[0]['first_name'] . ' ' . $primary_poc[0]['last_name']; $options['subject'] = APPLICATION_NAME . ' :: POC is deleted'; $options['header'] = 'POC deleted'; $options['toEmail'] = trim($primary_poc[0]['email']); $options['toName'] = $primary_poc_name; $salutation = 'Dear ' . $primary_poc[0]['first_name'] . ','; $options['message'] = '<div> <div>' . $salutation . ' </div> <div></div> <div>Secondary point of contact has been deleted from ' . $pocdata[0]['agencyname'] . ' agency. Please find the details below:</div> <div> <table border="1" style="border-collapse:collapse;"> <tr><td>Name : </td><td>' . $poc_name . '</td></tr> <tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr> <tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr> </table> </div> <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'; if ($options['toEmail'] != '') { $result_email = sapp_Global::_sendEmail($options); } // Mail to HR and Management $emailids = $agencylistmodel->getAllHRManagementEMails(); foreach ($emailids as $email) { $options['subject'] = APPLICATION_NAME . ' :: POC is deleted'; $options['header'] = 'POC deleted'; $options['toEmail'] = trim($email['groupEmail']); $options['toName'] = $email['group_name']; if ($email['group_id'] == 4) { $salutation = 'Dear HR,'; } else { $salutation = 'Dear Management,'; } $options['message'] = '<div> <div>' . $salutation . '</div> <div></div> <div>Secondary point of contact has been deleted from ' . $pocdata[0]['agencyname'] . ' agency. Please find the details below:</div> <div> <table cellpadding="0" cellspacing="0" border="1"> <tr><td>Name :</td><td>' . $poc_name . '</td></tr> <tr><td>Contact Number : </td><td>' . $pocdata[0]['contact_no'] . '</td></tr> <tr><td>Email : </td><td>' . $pocdata[0]['email'] . '</td></tr> </table> </div> <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'; if ($options['toEmail'] != '') { $result_email = sapp_Global::_sendEmail($options); } } if ($result) { $menuID = AGENCYLIST; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $agencyid, $pocid); $messages['message'] = 'Point Of Contact details deleted successfully.'; $messages['msgtype'] = 'success'; } else { $messages['message'] = 'POC cannot be deleted.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'POC cannot be deleted.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Primary point of contact cannot be deleted.'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); } catch (Exception $e) { exit($e->getMessage()); } }
public function sendEMails($agencyData, $flag) { $baseUrl = $this->generateBaseurl(); $agencylistmodel = new Default_Model_Agencylist(); if ($flag == 'activated') { $emailids = $agencylistmodel->getAllHRManagementEMails(); foreach ($emailids as $email) { $options['subject'] = APPLICATION_NAME . ' : Agency activated'; $options['header'] = 'Agency activated'; $options['toEmail'] = $email['groupEmail']; if ($email['group_id'] == 4) { $salutation = 'Dear HR,'; $options['toName'] = 'HR'; } else { $salutation = 'Dear Management,'; $options['toName'] = 'Management'; } $options['message'] = '<div> <div>' . $salutation . '</div> <div></div> ' . $agencyData['userfullname'] . ' agency has been activated. <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login to your Sentrifugo account.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } $options['subject'] = APPLICATION_NAME . ' : Agency Activated'; $options['header'] = 'Agency Activated'; $options['toEmail'] = $agencyData['emailaddress']; $options['toName'] = $agencyData['userfullname']; $options['message'] = '<div> <div>Dear ' . $agencyData['userfullname'] . ',</div> <div></div> Your agency has been activated. For further details, please contact our HR directly. <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login to your Sentrifugo account.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } else { if ($flag == 'inactivated') { $emailids = $agencylistmodel->getAllHRManagementEMails(); foreach ($emailids as $email) { $options['subject'] = APPLICATION_NAME . ' : Agency is deleted'; $options['header'] = 'Agency deleted'; $options['toEmail'] = $email['groupEmail']; if ($email['group_id'] == 4) { $salutation = 'Dear HR,'; $options['toName'] = 'HR'; } else { $salutation = 'Dear Management,'; $options['toName'] = 'Management'; } $options['message'] = '<div> <div>' . $salutation . ' </div> <div></div> ' . $agencyData['userfullname'] . ' agency has been deleted. <div></div> <div style="padding:20px 0 10px 0;">Please <a href="' . $baseUrl . '/index/popup" target="_blank" style="color:#b3512f;">click here</a> to login to your Sentrifugo account.</div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } $options['subject'] = APPLICATION_NAME . ' :: Agency is deleted'; $options['header'] = 'Agency Deleted'; $options['toEmail'] = $agencyData['emailaddress']; $options['toName'] = $agencyData['userfullname']; $options['message'] = '<div> <div>Dear ' . $agencyData['userfullname'] . ',</div> <div></div> We regret to inform you that your agency has been deleted. <div></div> </div>'; $options['cron'] = 'yes'; $result = sapp_Global::_sendEmail($options); } } }