<?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;

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/DetailView/view.detail.my.php');
$detail = new ViewDetailEcmDocumentTemplates();
$detail->ss = new Sugar_Smarty();
$detail->module="EcmDocumentTemplates";
$detail->bean = $focus;

$detail->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){
	//$r=mysql_fetch_array(mysql_query("select id from ".strtolower($d)." where deleted='0' order by id asc limit 1"));
	//$id=$r['id'];
	$tf.='<tr>
			<td width="20%">'.$app_list_strings['moduleList'][$d].'</td>
			<td width="20%">'.$arr[$d].'</td>
			<td width="60%"><a style="cursor:pointer;" onclick="EcmPreviewPDF(\'index.php?module='.$d.'&action=previewPDF&method=I&record='.$id.'&to_pdf=1\',{zoom:75,toolbar:1});">'.$mod_strings['LBL_PREVIEW_PDF'].'</a></td>
		  </tr>';
}
$tf.='</table>';
$detail->ss->assign("TEMPLATE_FILES",$tf);
echo $detail->display();

require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, "EcmDocumentTemplates");
echo $subpanel->display();  
?>