<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings, $db;
	  
$app_list_strings['ecmproducts_parent_dom'] = array (
  'Accounts' => $app_list_strings['moduleList']['Accounts'],
  'Leads' => $app_list_strings['moduleList']['Leads'],
);
require_once('modules/EcmDocumentTemplates/EcmDocumentTemplate.php');
require_once('modules/EcmDocumentTemplates/Forms.php');
require_once('include/time.php');
require_once('include/json_config.php');

$json_config = new json_config();

$focus = new EcmDocumentTemplate();   
  
if(isset($_REQUEST['record'])){
	$focus->retrieve($_REQUEST['record']);
}

$json = getJSONobj();

require_once('include/MVC/View/SugarView.php');  
require_once('modules/EcmDocumentTemplates/views/EditView/view.edit.my.php');
$edit = new ViewEditEcmDocumentTemplates();
$edit->ss = new Sugar_Smarty();
$edit->bean = $focus;

$edit->preDisplay(); 

$arr=unserialize(base64_decode($focus->template_files_defs));
$dir_path="modules/EcmDocumentTemplates/templates/";
$docs=$focus->docs;

$tf='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
foreach($docs as $d){
	$tf.='<tr>
			<td width="20%">'.$app_list_strings['moduleList'][$d].'</td>
			<td width="80%">'.$focus->selectTemplateFile($d,$focus->getListOfTemplateFiles($dir_path,$d),$arr[$d]).'</td>
		  </tr>';
}
$tf.='</table>';
$edit->ss->assign("TEMPLATE_FILES",$tf);
echo $edit->display();

?>