function __construct()
 {
     $this->emailTranslation = getLanguageStringsPHP('Email');
     $conf = Configuration::getInstance();
     $this->role = $conf->get('notificationRole');
     $this->fromAddr = $conf->get('changeNotifierEmailAddress');
 }
 private function getExternalContractVariables($contract)
 {
     $contractData = $contract->toArray();
     $contractData = sanatizeBeanArrayForLatex($contractData);
     $contact = new Contact();
     if ($contact->retrieve($contract->clientcontact_id)) {
         $contractData['clientcontactperson'] = $contact->toArray();
     }
     $contact = new Contact();
     if ($contact->retrieve($contract->technicalcontact_id)) {
         $contractData['technicalcontactperson'] = $contact->toArray();
     }
     $contact = new Contact();
     if ($contact->retrieve($contract->contact_id)) {
         $contractData['contactperson'] = $contact->toArray();
     }
     $account = new Account();
     if ($account->retrieve($contract->account_id)) {
         $contractData['account'] = $account->toArray();
     }
     global $timedate;
     $contractData['startdate'] = $timedate->to_display_date($contract->startdate);
     $contractData['minimumduration'] = $timedate->to_display_date($contract->minimumduration);
     global $app_list_strings;
     if ($contract->endperiod == 'other') {
         $contractData['endperiod'] = $timedate->to_display_date($contract->enddate);
     } else {
         $contractData['endperiod'] = $app_list_strings['endperiod_list'][$contract->endperiod];
     }
     if ($contract->cancellationperiod == 'other') {
         $contractData['cancellationperiod'] = $timedate->to_display_date($contract->cancellationdate);
     } else {
         $contractData['cancellationperiod'] = $app_list_strings['cancellationperiod_list'][$contract->cancellationperiod];
     }
     // show address linebreaks in pdf
     $contractData['deliveryaddress'] = preg_replace("/\n/", '\\newline ', $contract->deliveryaddress);
     $contractData['completionaddress'] = preg_replace("/\n/", '\\newline ', $contract->completionaddress);
     $contractData['svnumbers'] = $contract->getSVNumbersArray();
     // TODO: abbreviation and type probably have to be converted in the future
     $contractMatters = explode('^,^', $contract->externalcontractmatter);
     foreach ($contractMatters as &$matter) {
         $matter = $app_list_strings['externalcontractmatter_list'][$matter];
     }
     $contractData['externalcontractmatter'] = implode('\\newline ', $contractMatters);
     $previousCategory = '';
     $costs = $contract->getCostsArray();
     $months = getLanguageStringsPHP('months');
     foreach ($costs as &$cost) {
         $cost['numberOfDetailedCosts'] = count($cost['detailedCosts']);
         if ($previousCategory == $cost['category']) {
             $previousCategory = $cost['category'];
             $cost['category'] = '';
             // TODO @LION i guess that leaving the category field empty should to some kind of marking... please comment.
         } else {
             $previousCategory = $cost['category'];
             $cost['category'] = $app_list_strings['externalcontractmatter_list'][$cost['category']];
         }
         if ('annually' === $cost['paymentinterval'] || 'once' === $cost['paymentinterval'] || 'other' === $cost['paymentinterval']) {
             $enddate = date_parse($contract->enddate);
             // if the payment interval of this cost is once, annually or other, there will be only one detailed cost row.
             // so it is correct to modify the first detailed cost item in the array.
             // set the month for this detailed cost row to the month of the enddate.
             $cost['detailedCosts'][0]['month'] = $enddate['month'];
         }
         // do translation now because paymentinterval will not be read from php code anymore.
         // so it can be in localized form from now on.
         $cost['paymentinterval'] = $app_list_strings['paymentinterval_list'][$cost['paymentinterval']];
         foreach ($cost['detailedCosts'] as &$detailedCosts) {
             $detailedCosts['price'] = formatCurrencyForSmartyLatex($detailedCosts['price'], false);
             // format price for latex template (see #387)
         }
     }
     $positions = $contract->getPositionsArray();
     foreach ($positions as &$position) {
         $position['type'] = $app_list_strings['externalcontractmatter_list'][$position['type']];
         $position['price'] = formatCurrencyForSmartyLatex($position['price'], false);
         // format price for latex template (see #387)
     }
     // convert all currency values / prices before giving them to smarty
     $contractData['finalcosts'] = formatCurrencyForSmartyLatex($contractData['finalcosts'], true);
     return array('numberOfCosts' => count($costs), 'months' => $months, 'contract' => $contractData, 'costs' => $costs, 'positions' => $positions, 'currencySymbol' => currencySymbolToLatexEquivalent(getSugarCrmLocale('default_currency_symbol')));
 }
if (!defined('sugarEntry')) {
    define('sugarEntry', true);
}
chdir('../../../');
require_once 'include/entryPoint.php';
require_once 'include/oqc/common/common.php';
require_once 'include/oqc/common/Configuration.php';
/* load php files neccessary for translation of popup depending on the language of the user
 * this is neccessary because the variable app_list_strings is not properly set in this context..
 */
global $sugar_config;
$lang = $sugar_config['default_language'];
require_once "custom/application/Ext/Language/{$lang}.lang.ext.php";
$languageDocuments = getLanguageStringsPHP('Documents');
$languageCommon = getLanguageStringsPHP('common');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>
<?php 
echo $languageDocuments['popupTitle'];
?>
</title>
<!--  some sugarcrm css files -->
<link rel="stylesheet" type="text/css" href="../../../themes/Sugar/navigation.css" />
<link rel="stylesheet" type="text/css" href="../../../themes/Sugar/style.css" />