function getAppName($id = '')
{
    $session = SessionWrapper::getInstance();
    $config = Zend_Registry::get("config");
    $currentcompany = $session->getVar('currentcompany');
    $defaultcompany = $session->getVar('defaultcompany');
    if (!isEmptyString($id) && isEmptyString($session->getVar('userid'))) {
        $company = new Company();
        $company->populate($id);
        return isEmptyString($company->getAppname()) ? getDefaultAppName() : $company->getAppname();
    }
    return !isEmptyString($currentcompany['appname']) ? $currentcompany['appname'] : (!isEmptyString($defaultcompany['appname']) ? $defaultcompany['appname'] : $config->system->appname);
}
    function sendProfileInvitationNotification()
    {
        $session = SessionWrapper::getInstance();
        $template = new EmailTemplate();
        # create mail object
        $mail = getMailInstance();
        $view = new Zend_View();
        // assign values
        $template->assign('inviter', $this->getName());
        $template->assign('type', $this->getType());
        $template->assign('company', $this->getCompany()->getName());
        $template->assign('firstname', isEmptyString($this->getFirstName()) ? 'Friend' : $this->getFirstName());
        $template->assign('inviter', $this->getInvitedBy()->getName());
        // the actual url will be built in the view
        $viewurl = $template->serverUrl($template->baseUrl('signup/index/id/' . encode($this->getID()) . "/"));
        $template->assign('invitelink', $viewurl);
        $contents = "";
        if ($this->isCompanyAdmin()) {
            $contents = '<p>Your company <b>' . $this->getCompany()->getName() . '</b> has been successfully setup on <b>' . getDefaultAppName() . '</b> and you have been invited by <b>' . $this->getInvitedBy()->getName() . '</b> to activate your <b>' . getTrialDays() . ' day</b> free trial account.</p>
	
			<p><b>' . getDefaultAppName() . '</b> is an online state of the art Human Resource application that automates almost ALL your company HR needs. All the way from Employee management, benefits, attendance and timesheets, leave time, payroll and many other HR functions.</p>';
        } else {
            $contents = '<p>You have been invited by <b>' . $this->getCompany()->getName() . '</b> to activate your Employee HR account.</p>';
        }
        $template->assign('contents', $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 = $this->translate->_('profile_email_subject_invite_user');
        $template->assign('subject', $subject);
        $mail->setSubject($subject);
        // render the view as the body of the email
        $mail->setBodyHtml($template->render('invitenotification.phtml'));
        // debugMessage($template->render('invitenotification.phtml')); exit();
        if (isEmptyString($this->getEmail())) {
            $session->setVar('warningmessage', "Invitation not sent. No email available on profile");
        } else {
            try {
                $mail->send();
            } catch (Exception $e) {
                $session->setVar("warningmessage", 'Email notification not sent! ' . $e->getMessage());
            }
        }
        $mail->clearRecipients();
        $mail->clearSubject();
        $mail->setBodyHtml('');
        $mail->clearFrom();
        return true;
    }