Thanks Sid
Most appreciated!
Youāre welcome !!
can we do like this its generating pdf in custome module
1 ) first We need to add your custom module in to *Type drop down of PDF template module
- This We can do it by drop down editor from admin , We need to search for pdf_template_type_dom drop down list and add -> option
Item name [ your custom directory name ] : example my custom module is ca_payment
Display label [ your wish ] : in my case i have given Payment
Save it .
2 ) After this We need Print as pdf option in our details view page of custom module
- to add option in details view page open detailviewdefs.php
we can find this file under /custom/modules//metadata/detailviewdefs.php
we need to add option in to buttons array
array (
ābuttonsā =>
array (
0 => āEDITā,
1 => āDUPLICATEā,
2 => āDELETEā,
3 => āFIND_DUPLICATESā,
// add option like this
4 => array ( ācustomCodeā => āā,
),
save it and check if you are not able to see the optin than
open custom/modules//language/en_us.lang.php
add label in this file
$mod_strings = array ( āLBL_PRINT_AS_PDFā => āprint PDFā,);
save it
and check [ now option will be there ]( if option is still not there than delete cache and check )
- now all we need to do is call function on click of option
for this easiest way which i did copy the view.detail.php file from qoues or invoice
and replace it with custom/modules//views/view.detail.php
mostly following function will be there in the file
b_bookViewDetail
display
populateInvoiceTemplates
displayPopupHtml
replace the aos_qotes with your custom module name
Thanks for your steps but its still not working
Actually when i click on print pdf noting is happening
Hi Arpit ,
Make sure u have Pdf template created for respective module ( module which you are trying to add print as pdf option ) under PDF Template module !
Hi,
I have double checked what you said, but it is still not working ā¦
Hi arpit ,
it would be nice if you can share the details of where you did the changes in files . with some screen shoots . on the your original post .
and you can also make use of Mpdf class unser :
require_once(āmodules/AOS_PDF_Templates/PDF_Lib/mpdf.phpā);
My apologies if Iām beating this topic to death but Iāve tried following Sidās instructions (#5953) on creating the functionality of PDF templates working with custom modules but Iāve run into a wall now aka lack of knowledge
1)I have my module(class attendees) available in the PDF template dropdown and it pulls data from the module to create a tempalte,
2) I have a the āGenerate Letterā button in the detail view of the Attendees module showing
3) When I click Generate Letter I can view the list of available templates
- When I select any template I get the following error
Fatal error: Class āAtnd_Attendeeā not found in /home/safety456/webapps/suitecrm/modules/AOS_PDF_Templates/formLetterPdf.php on line 39
I;'ve looked at this line which is below but not sure where to go from here. does anyone have any suggestions?
39| $module = new $module_type_create();
Here is the code I used to create the extended view in cusomt/moduleAttendee/views/detailview.php
require_once(āinclude/MVC/View/views/view.detail.phpā);
class CustomAtnd_AttendeesViewDetail extends ViewDetail{
public function display(){
global $sugar_config;
//$aop_portal_enabled = !empty($sugar_config['aop']['enable_portal']) && !empty($sugar_config['aop']['enable_aop']);
//$this->ss->assign("AOP_PORTAL_ENABLED", $aop_portal_enabled);
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::DVPopupHtml('Atnd_Attendees');
parent::display();
}
}
Sidenote: This is running on 7.2 Release
You are almost there!
Are you sure āAtnd_Attendeeā is the exact name of your module and its not āAtnd_Attendeesā? If you look at line 36 you will see $module_type_create = rtrim($module_type,āsā); This line is stripping the āsā off the the module name and we need this for standard modules but with custom modules it may cause problems. Basically when the āsā is stripped off your modules name it is no longer recognised. So what I would do is add an if statement to check for your module and not strip the āsā off.
After line 37 add this:
if($_REQUEST['module'] == 'Atnd_Attendees'){
$module_type_create = $_REQUEST['module'];
}
I also noticed you are not doing this in the custom folder so these changes wont be upgrade safe.
Hi Andy,
Thank you for your suggestion. I applied it and the pdf templates are working in my custom module. (you were correct my custom file name is Atnd_Attenddees not Atnd_Attendee as I wrote)
As you mentioned this change is not upgrade safe. knowing this now, I copied the AOS_PDF_Templates folder to the custom folder. However, when I do this Iām getting same error of ā39| $module = new $module_type_create();ā even though I included the if statement as directed.
Iām not a programmer but to me it seems that when I click on the pdf template name it does not know to look in custom/module/AOS_PDF_Templates/formLetterPdf.php, thus the same error
I would prefer to make this pdf template feature upgrade safe, How would I go about this if you wouldnāt mind sharing?
Thank you again
In the view.detail.php change this line to the custom version of your formLetter.php
require_once('modules/AOS_PDF_Templates/formLetter.php');
to
require_once('custom/modules/AOS_PDF_Templates/formLetter.php');
But to be truly upgrade safe you will have to create a custom version of the view.detail.php in the custom folder of your module and then add the above line to that.
I am trying to get Generate Letter working for Cases module. I have done everything as advised on this and other threads. I get the button and I get the popup showing templates made for Cases module. But when I click one of the templates I get a blank page with url: http://office.advokatibijeljina.com/index.php?entryPoint=formLetter and no dowload.
Is there anything specific when trying to add Generate Letter functionality to one of basic modules like Cases? Any help or clue what I am I doing wrong?
THX!
Hi
Ive been following the guides for adding a generate letter function to a custom module and iāve hit a brick wall, iāve gone over everything a few times and even started from scratch but i seem to hit the same point as bojkic in that the function results in a blank white page:
I have a āgenerate letterā button in my custom module detail view,
I have a pdf template set up for the module which shows up as a pop up when you press āgenerate letterā but then i just get a white screen.
Iāve checked for errors in the log and in chrome developer consul of which i have attached screen grabs and i have also attached copies of the custom/modules/[custom_module]views and the ListViewSmarty.php that i created in the custom/modules/[custom_module] folder.
If anyone could point me in the right direction iād be really happy as iām feeling pretty dumb right now! :S
Thanks
Have you checked the php error log?
Here is the log, iāve had a look but canāt work it out, iāll have a good look over the weekend unless someone spots something obvious?
THanks
Rob
looks like it is a bug in formLetterPdf.php
so any suggestion how to fix it? I have tried many things but with Cases module I always end up with black page /index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3DCases%26action%3DDetailView%26record%3D1de544d5-dacd-7347-0a3a-55bb2f306a57
Timelyā¦ Iām getting exactly the same problem now that Iāve figured out how to actually add the button.
BTW - EVERYTHING on the web talks about āadding 'AOS_GENLET ā => ā¦ā etc. to your detailviewdef.php file in your custom module. Big problem - most custom modules wonāt have that file, and if you copy the one from another built-in module, youāre going to have a hell of a time rewriting it (your panels, etc.). Worse, if you just add a button to the array without the rest of the code thatās normally in that file, youāll get nothing but the button!
Best way: Find the cache-generated detailviewdef.php file, copy it to your custom metadata directory, and add the button there:
find /yourWebRoot/suitecrm/ -iname detailviewdefs.php | grep YourModuleName
cp eb50-upload/upgrades/temp/0113Y4/SugarModules/modules/YourModuleName/metadata/detailviewdefs.php custom/modules/YourModuleName/metadata/
Bang, it all works (except for this blank screen bug).
Soā¦ any thoughts on what the bug is in formLetterPdf.php?
I made button work fine, and appropriate list of the templates appears, however when I click on the template I get a blank screenā¦
Bingoā¦ formLetterPdf.php has a debug line right up top! (Clever, saves me the effort!) soooā¦
Fatal error: Class āyour_ModuleNameā not found in /yourWebRoot/suitecrm/modules/AOS_PDF_Templates/formLetterPdf.php on line 39
Anyone know how to properly instantiate and include the class of a custom module youāve built?
Admins? Will?