<?php
if (!defined('sugarEntry') || !sugarEntry)
    die('Not A Valid Entry Point');
if (!$current_user->is_admin) {
    ACLController::displayNoAccess(true);
    sugar_die();
}
global $sugar_config, $current_user, $mod_strings;

$db = $GLOBALS ['db'];
$get_saved_templates_query = "SELECT id AS id,value0 AS template_name  FROM operating_values WHERE name='AgreementTemplates' AND module_name='EcmAgreements' AND value1=0 ORDER BY value0";
$get_saved_templates_result = $db->query($get_saved_templates_query);
$get_saved_templates_array = array();
while($row = $db->fetchByAssoc($get_saved_templates_result)){
	$get_saved_templates_array[$row['id']] = $row['template_name'];
}
$parser_fields = EcmAgreement::get_parse_fields_for_pdf();

$format = array();
$smarty = new Sugar_Smarty();
$smarty->assign('MOD', $mod_strings);
$smarty->assign('templates', $get_saved_templates_array);
$smarty->assign('parser_fields', $parser_fields);
echo $smarty->display('modules/EcmAgreements/tpl/AgreementTemplates.tpl');
