arpit
19 February 2015 06:25
1
I have followed the recommended step earlier posted in our community
I have done the below steps:
Add your Custom Module in the Type dropdown of PDF Template. This will help you select your custom module for creating a sample. You do this by editing the ā'pdf_template_type_domā through the dropdown editor from the admin panel. The āitem nameā must be the name of the module directory.
Add the default āGenerate Letterā link in the actions dropdown in the detail view page of the custom module. To do this, you have to first edit the /custom/modules/Custom_Module/metadata/detailviewdefs.php file of the custom module and include
āAOS_GENLETā =>
array (
ācustomCodeā => āā,
),
in the buttons array.
Next on, add the generate letter functionality. To do this, edit the view.detail.php file in custom/module//Custom_Module/views directory. If there is no such file or directory create it.Now add the following piece of code in the display() method,
require_once(āmodules/AOS_PDF_Templates/formLetter.phpā);
formLetter::DVPopupHtml(āCustom_Moduleā);
Now, generate letter option seems visible but when i click on that noting is happen .
might be it is unable to call any function
please helpā¦
Ian
19 February 2015 09:41
2
Hi arpit,
can you open developer tools in the brouswer that you use and view the console (In Firefox its key F12). when you click on the generate letter option is there any errors in the console ?
Ian.
arpit
19 February 2015 10:17
3
when i used the firebug in firefox and clicked on print pdf option its show some function is undefined
function name: showpopup
i used thid function to adding the print pdf option in detail view menu option
please find the attached screenshot
Hi Arpit,
Thing is the that you need to create a template for ut letter First in AOS_PDF_TEMPLATES. Like what i did for generating PDF template.
I create one pdf template for my custom module and named by module name (Not mandatory that you have to give name as module name).
Make changes in Detailviewdefs.php file.
'buttons' =>
array (
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
3 => 'FIND_DUPLICATES',
4 =>
array (
'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="{$MOD.LBL_PRINT_AS_PDF}">', //this label u need to define in language file
),
),
Last step and Mandatory step,
changes in view.detail.php
require_once('include/MVC/View/views/view.detail.php');
class p_ProposalViewDetail extends ViewDetail {
function p_ProposalViewDetail(){
parent::ViewDetail();
}
function display(){
$this->populateQuoteTemplates(); [i]//This two function u need to write here[/i]
$this->displayPopupHtml();
unset($this->dv->defs['templateMeta']['form']['buttons'][1]);
// put all your condition over here ..
if($this->bean->approval_status=='Approved'){
unset($this->dv->defs['templateMeta']['form']['buttons'][0]); // for hide the edit button
unset($this->dv->defs['templateMeta']['form']['buttons'][2]); //for hide delete button
}
$this->dv->process();
echo $this->dv->display();
}
function populateQuoteTemplates(){
global $app_list_strings, $current_user;
//what u created the template call it here just changed the type ='?'//
$sql = "SELECT id, name FROM aos_pdf_templates WHERE deleted=0 AND type='p_Proposal' AND active = 1";
$res = $this->bean->db->query($sql);
$app_list_strings['template_ddown_c_list'] = array();
while($row = $this->bean->db->fetchByAssoc($res)){
if($row['id']){
$app_list_strings['template_ddown_c_list'][$row['id']] = $row['name'];
}
}
}
function displayPopupHtml(){
global $app_list_strings,$app_strings, $mod_strings;
$templates = array_keys($app_list_strings['template_ddown_c_list']);
if($templates){
echo ' <div id="popupDiv_ara" style="display:none;position:fixed;top: 39%; left: 41%;opacity:1;z-index:9999;background:#FFFFFF;">
<form id="popupForm" action="index.php?entryPoint=generatePdf" method="post">
<table style="border: #000 solid 2px;padding-left:40px;padding-right:40px;padding-top:10px;padding-bottom:10px;font-size:110%;" >
<tr height="20">
<td colspan="2">
<b>'.$app_strings['LBL_SELECT_TEMPLATE'].':-</b>
</td>
</tr>';
foreach($templates as $template){
if(!$template){
continue;
}
$template = str_replace('^','',$template);
$js = "document.getElementById('popupDivBack_ara').style.display='none';document.getElementById('popupDiv_ara').style.display='none';var form=document.getElementById('popupForm');if(form!=null){form.templateID.value='".$template."';form.submit();}else{alert('Error!');}";
echo '<tr height="20">
<td width="17" valign="center"><a href="#" onclick="'.$js.'"><img src="themes/default/images/txt_image_inline.gif" width="16" height="16" /></a></td>
<td><b><a href="#" onclick="'.$js.'">'.$app_list_strings['template_ddown_c_list'][$template].'</a></b></td></tr>';
}
echo ' <input type="hidden" name="templateID" value="" />
<input type="hidden" name="task" value="pdf" />
<input type="hidden" name="module" value="'.$_REQUEST['module'].'" />
<input type="hidden" name="uid" value="'.$this->bean->id.'" />
</form>
<tr style="height:10px;"><tr><tr><td colspan="2"><button style=" display: block;margin-left: auto;margin-right: auto" onclick="document.getElementById(\'popupDivBack_ara\').style.display=\'none\';document.getElementById(\'popupDiv_ara\').style.display=\'none\';return false;">Cancel</button></td></tr>
</table>
</div>
<div id="popupDivBack_ara" onclick="this.style.display=\'none\';document.getElementById(\'popupDiv_ara\').style.display=\'none\';" style="top:0px;left:0px;position:fixed;height:100%;width:100%;background:#000000;opacity:0.5;display:none;vertical-align:middle;text-align:center;z-index:9998;">
</div>
<script>
function showPopup(task){
var form=document.getElementById(\'popupForm\');
var ppd=document.getElementById(\'popupDivBack_ara\');
var ppd2=document.getElementById(\'popupDiv_ara\');
if('.count($templates).' == 1){
form.task.value=task;
form.templateID.value=\''.$template.'\';
form.submit();
}else if(form!=null && ppd!=null && ppd2!=null){
ppd.style.display=\'block\';
ppd2.style.display=\'block\';
form.task.value=task;
}else{
alert(\'Error!\');
}
}
</script>';
}
else{
echo '<script>
function showPopup(task){
alert(\''.$mod_strings['LBL_NO_TEMPLATE'].'\');
}
</script>';
}
}
}
4 .Do Quick Repair and rebuild
Follow this step. It will work.
:cheer:
arpit
19 February 2015 10:35
5
i did the same step what you suggested
but its not showing when i used the developer console its show me error that showpopup function is undefined
please find the screenshot
in view.detail.php file what i have mentioned. u did fully coz there only showpopup fuction definedā¦ if u look into thisā¦
if you did this. then give permission and do quick repair and rebulid . it should work. coz its the only way to do thisā¦
try this, if then also not working then u have to debugā¦
Ian
19 February 2015 10:45
7
The first screen shot which was posted shows the view.detail.php file but doesnt have the same code a jaydeep has posted,
The error suggests that there is a issue with the view.detail.php code maybe the syntax is incorrect ?
There is something not right with the view.detail.php file.
ian
Ian.
arpit
20 February 2015 06:36
8
the problem which i understand is
function showpop () not able to get the definationā¦
Ian
20 February 2015 09:07
9
Hi arpit,
yes but is the function showpopup defined in the view.detail.php file ? can you post this file here ?
arpit
23 February 2015 06:09
10
Hi Ian,
Its working now there was some a single variable which getting problem so i sorted out