Customer Visit (Meeting) Report

I’d like to print a Meeting Report in this way (see attachment)

How do you think could it be possible?

Thanks in advance

I’m using the PDF Template Module after adding the Meetings module to its DropDown type field.

Now, how can i add the print action to the Meetings module?

I succeded in adding a button to the Edit View of Meeting module.

I’ve done this following these steps:

  1. Add a value in the drop down menu of type field in PDF Template module

  2. Create a template with type= Meetings

  3. Add in custom/modules/Meetings/metadata/detailviewdefs.php

this code


5 =>
                        array (
                            'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="Stampa PDF">',
                        ),

like this way:


array (
    'form' => 
    array (
      'buttons' => 
      array (
        0 => 'EDIT',
        1 => 'DUPLICATE',
        2 => 'DELETE',
        3 => 
        array (
...

5 =>
                        array (
                            'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="Stampa PDF">',
                        ),
  1. in custom/modules/Meetings/views
    i’ve added a file: view.detail.php
    I’ve made it copying it from view.detail.php in modules/AOS_Quotes/views
    i’ve changed inside “AOS_Quotes” with “Meetings”

I know i’m missing something. Do you know what?

I’m receiving this message from Firebug when hitting on the Generate PDF button in Detail view:

“ReferenceError: showPopup is not defined”

There must be an error in your view.detail.php, if you look at the AOS_Quotes view.detail.php line 90 you will see a JavaScript function showPopup(task). Either you have deleted this in your view.detail.php or there is an error in the JavaScript before this that will make this function appear to be not defined.

HI mayerelyashiv
You are in the correct path.

just repair the js from studio.

Thank you Jaydeep, but even if i’ve hit all the repair js links, nothing’s going on…

Hi mayerelyashiv,

i got the error, what you did, in ur custom code u manually give the value name “Stampa PDF” . Dont do that, follw this process. beceause, its not the only about value, one id is also included here, if u inspect you will came to know.

I just check out, 3 simple procedure and it is working fine,

But before that you have to create, template in aos_pdf_templates module.

  1. custom/modules//metadata/detailvewdefs.php

in buttons array. (that you accomplished).

4 => 
          array (
            'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="{$MOD.LBL_PRINT_AS_PDF}">',
          ),
          5 => 
          array (
            'customCode' => '<input type="button" class="button" onClick="showPopup(\'emailpdf\');" value="{$MOD.LBL_EMAIL_PDF}">',
          ),
          6 => 
          array (
            'customCode' => '<input type="button" class="button" onClick="showPopup(\'email\');" value="{$MOD.LBL_EMAIL_QUOTE}">',
          ),
  1. modules//language/en_us.lang.php

Add this piece of lables


        'LBL_PRINT_AS_PDF' => 'Print as PDF',
        'LBL_EMAIL_QUOTE' => 'Email Quotation',
        'LBL_EMAIL_PDF' => 'Email PDF',
  1. custom/modules//views/view.detail.php
 function display(){ 
       $this->populateQuoteTemplates();
       $this->displayPopupHtml(); 
       $this->dv->process();  
       echo $this->dv->display(); 
 }
function populateQuoteTemplates(){
        global $app_list_strings, $current_user;
         
        //here you need to change the type , what you created for your module in templates 
            
        $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>';
    }
  }

it will work for you .
:cheer:

2 Likes

Thank you Jaydeep,

i followed all your istructions,
but i’m still receiving the same error: “ReferenceError: showPopup is not defined”

I’ve tried to substitute in custom/modules/Meetings/metadatadetailviewdefs.php

4 => 
          array (
            'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="{$MOD.LBL_PRINT_AS_PDF}">',
          ),

with

4 => 
          array (
            'customCode' => '<input type="button" class="button" onClick="alert(\'ciao!\');" value="{$MOD.LBL_PRINT_AS_PDF}">',
          ),

and i can see the Alert message…

I’m sorry, but i still can’t get it work,…

this is my custom/modules/Meetings/views/view.detail.php


if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
...
*/
require_once('include/MVC/View/views/view.detail.php');

class MeetingsViewDetail extends ViewDetail {

	function MeetingsViewDetail(){
 		parent::ViewDetail();
 	}
	
	function display(){ 
       $this->populateQuoteTemplates();
       $this->displayPopupHtml(); 
       $this->dv->process();  
       echo $this->dv->display(); 
 }
function populateQuoteTemplates(){
        global $app_list_strings, $current_user;
         
        //here you need to change the type , what you created for your module in templates 
            
        $sql = "SELECT id, name FROM aos_pdf_templates WHERE deleted=0 AND type='Meetings' 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>';
    }
  }
}

i can’t understand why i always receive a “ReferenceError: showPopup is not defined” from Firebug,…

Do you have developer mode turned on in your admin settings?

1 Like

Hi Andy, thanks for you answer,

i tried to turn On the Developer Mode but the result hasn’t changed…

Hello mayerelyashiv

I have the same problem, could you solve it?

Thank You.

Just for reference… You’ll find the solution here: suitecrm.com/media/kunena/attachments/33374/AddingPrintPDFtocustomModule.pdf

1 Like

Hey, mayerelyashiv, you should put that up on a blog or something just so it’s available for everyone, and searchable on Google.

If you don’t have a good place to post it, I can put it on my blog, referencing your name, of course.

And thanks for sharing!

Hi pgr,
you’re most welcome.
Feel free to post it on your blog. Actually i retrieved that link from a forum post here around.