Problem with tpls files in suitecrm version 7.14

Hi, I have this problem:
I have recently switched to version 7.14.2 of suitecrm and consequently to version 8.1 of PHP, I am testing the custom modules, created in the old version of suitecrm (7.12) and everything seems to work (I had to make some changes), but now I have installed a module already known on this forum and it is Advanced Report (which I have used a lot in previous versions and which I find very useful) which gives me an error when executed (Run Report):

Exception in Controller: Syntax error in template "/suitecrm/modules/adrep_report/tpls/RunReport.html" on line 79 "{html_options name=hour_$name options=$hours selected=$parameter.hour}:" - Unexpected "$name", expected one of: "}"

I imagine something has changed in the handling of tpls files, but I donā€™t know how to modify this code to be accepted.

Do you have an answer to this problem?

Can you get in touch with that add-onā€™s developer?

These fixes for new PHP versions are usually not too difficult to make

No, I donā€™t remember the name of the person who developed it, I also believe that the changes should not be huge, but I donā€™t know how to change them, Iā€™m trying, but nothing changes

You can find the add-on developer here

I contacted mvnrsa, but unfortunately he couldnā€™t help me.
Is there anyone else who uses the Advanced Report module created by mvnrsa and has upgraded to SuiteCRM version 7.14? Have you had the same problems as me? How did you solve them? Please, itā€™s important.

Hello @fab

I understand youā€™re encountering an error with the Advanced Report module in SuiteCRM 7.14.2 after upgrading to PHP 8.1. The error seems to be related to a syntax change in the html_options tag within the RunReport.html template file.

Here are some steps you can take to resolve this issue:

1. Contact the Add-on Developer:

  • The most recommended approach is to reach out to mvnrsa, the developer of the Advanced Report module. They likely have encountered this issue before and might already have a fix available.
  • You can find them here

2. Modify the RunReport.html File (if comfortable):

  • If contacting the developer isnā€™t an option, you can try modifying the RunReport.html file yourself. However, this requires familiarity with Smarty syntax and the html_options tag. The goal is to remove the reference to $name within the attribute or restructure the code to avoid using it.

3. Seek Help from the SuiteCRM Community:

  • If modifying the code yourself seems daunting, donā€™t hesitate to seek help from the SuiteCRM community forums. Share your specific issue and the relevant code snippet, and someone with more experience might be able to guide you through the fix.

Remember, modifying core files might not be the best approach unless youā€™re comfortable with SuiteCRM development. Prioritize contacting the add-on developer or seeking help from the community for specific guidance.

I hope this helps!

Thanks.

I have already done the steps you described, I ran out of ideas, which is why I was hoping there was someone else who used this module.
I contacted the developer, but he canā€™t help me.
Iā€™m modifying the code hoping to solve it, but not being a smarty expert, Iā€™m going a bit blind.

What I can say is that, in html_options, the lines containing name=..._$name, therefore:

{html_options name=hour_$name options=$hours selected=$parameter.hour}

and not only this line, also others with the same syntax, not only in this file, but also in others:

{html_options name=min_$name options=$minutes selected=$parameter.min}

by changing min_$name (for example) to min_name, the error goes away and the page appears, but it doesnā€™t work well

@chirag_biz309 please donā€™t post ChatGPT answers here in these forums. They are rarely useful, sometimes misleading, and if people want ChatGPT they can go and use it themselves.

@fab I am not sure your problem is a Smarty problem in the HTML file. It might also be a PHP problem in the file that prepares (assigns) the smarty variables and then tries to render the template.

Any way, I donā€™t think you can just remove the $name variable from there, that is never going to work.

Yes @pgr, I had thought about it and in fact I tried to reconstruct the path to see where the problem was, but the error is generated when the file where that line is is recalled.
I know it will never work by removing that variable, I was just experimenting to understand how to solve it.

I havent heard from Marnus for a while, nor has he posted any updates through git for a while, I do however have access to the Advanced reports git repo (I have added a few updates to it myself a few years back).

Iā€™m not sure if this is a PHP upgrade problem or a smarty upgrade problem, however I will get it fixed and submitted to the repo. Its not just that line however, there are a few and from testing today I got past the RunReport.html file and then onto some of the other files and encountered more problems. This line however:

{html_options name=hour_$name options=$hours selected=$parameter.hour}

should be:

{html_options name=ā€œhour_$nameā€ options=$hours selected=$parameter.hour}

For it to work (its a similar problem elsewhere)

Regards

Mark

Having gotten a bit further down the rabbit hole on this, the PDF generator uses the AOS_PDF_Templates folder and the mPDF in there, which no longer works under PHP8.2 (at least there are discussions about it not working on earlier PHP8.x as well). So looking at the newly included TCPDF now.

Yeah, I read somewhere on the forum that v8.x uses TCPDF engine and mPDF is no longer in the option. But, you will still find code related to mPDF in the v8.x.

So, usually others are going to admin setting and selecting TCPDF and other way is to check your config.php file to set pdf property.

  'pdf' => 
  array (
    'defaultEngine' => 'TCPDFEngine',
  ),

Well yes, but the Advanced Reports module that Marnus created is hardcoded to use the mpdf install within the AOS_PDF_Templates sub directoryā€¦ so its a matter of trying to migrate the usage across to TCPDF and keep the look working.

Yeah thatā€™s true. :heavy_check_mark:

Let us know, if you able to make those changes.

@markbond this PR might be helpful (as an example of converting code from mPDF to TCPDF) when doing that work:

The PR looks huge but if you ignore all the deleted files and just look at changed files, it will make some sense, hopefully

I think the biggest issue (I have the TCPDF Engine working) is that more CSS works in mPDF than in TCPDF which means currently the default output in PDF is ā€œlackingā€ shall we sayā€¦

As for the functioning of runReport.html, I had already made those changes and managed to make it work.
For the PDF generation, all true, MPDF does not work anymore and I had to rewrite the code inside advanced report to make it work with TCPDF, but there are still display problems (it is not like MPDF):
the columns have a fixed width and do not adapt to the page, so, if the number of columns is minimal (for example 4) there are no problems, but if there are 15 columns, the output does not adapt to the page, this means that the columns will have a fixed width and the content will be in columns if there is no space:

N | Add
a | re
m | ss
e |

This happens with version 8.4.2 of SuiteCRM
While with version 8.6 the width of the columns is variable row by row:

N  |
a |
m   |
e|

Joh |
n |
-------
Peter |
-------