PDF maker outputs variable name when empty - Printable Version +- CoreBOSBB (https://discussions.corebos.org) +-- Forum: Support (https://discussions.corebos.org/forumdisplay.php?fid=17) +--- Forum: Modules/Extension Support (https://discussions.corebos.org/forumdisplay.php?fid=9) +--- Thread: PDF maker outputs variable name when empty (/showthread.php?tid=193) |
PDF maker outputs variable name when empty - Guido1982 - 11-07-2015 I updated my CoreBOS install to the latest files, github dated 4-11-2015. I've got it all working pretty nicely, but have one problem. I used to make PDF templates that output either a product or a service, based on what was listed. I used variables for both in the same table cell, since an empty value would just not be shown. For instance, I could use Code: $PRODUCT_NAME$ $SERVICE_NAME$ In other words, the system doesn't recognise these values as variables anymore when they're empty. Check image to see what I mean RE: PDF maker outputs variable name when empty - omarllorens - 11-09-2015 Hi. You are using the incorrect variables. If you try to print the product/service lines, you need to put this variable between the #PRODUCTBLOC_START# and #PRODUCTBLOC_END#. But you have to use "Common fields for Products & Services" picklist. This picklist has the variable that you need. Only you can use the picklist: Available fields for Products or Available fields for Services, if your are sure that you print a product or service. RE: PDF maker outputs variable name when empty - Guido1982 - 11-09-2015 Hi Omar, Well this sounds viable, but the behaviour used to be different, and this 'old' behaviour is what we need. When you create say a quote and you want to offer a product and the time needed to install that product on site, you need to be able to quote both products and services on one quote. Keep in mind this used to work, and I have not changed my PDF maker version or anything in the PDF templates. I just updated coreBOS. In the old behaviour, maybe the variable name for products would not exist on a line for a service, but that would result in a service description and leave the product variables blank. This way I could list products and services in one quote. Now I cannot, because any service would have the product variable name and vice versa. In the mixed dropdown, I can only choose the description, not the names. And I can't use any custom fields for products this way (we use a custom field for the brand name). EDIT Yes we are using the variables between the productblocks, as I said these templates used to work fine and nothing has changed in them. I've been using PDF maker for years and built all templates myself. Let me be more specific about my problem by posting an example from one of my templates: Code: <div>#PRODUCTBLOC_START#</div> In the above (note that I wrapped the productblocs in DIV's because else the WYSIWYG editor will wrap them in P tags that create unwanted line spaces) example look at the first table cell. It starts with the Product brand name (The customfield 543) and the product name. Next line is the product description. After that the same for services, in the same table cell. Now in the old behaviour, let's say we are quoting a product. There will be nothing for service name and service description. The template would output the product brand name, product name and product description and leave the service part blank because there was no service. The other way around also worked. When the template would reach a service, the product stuff would be left blank and the line would output as if there were no product variables in place. This way, the template would be flexible and would self-decide, no matter what was thrown at it. In the new behaviour, let's say we have a product quoted, this would work fine but also the variable names for services would be printed, as in the attached image from post 1. This also poses a problem for the image tag. If we output a template that has multiple products, some of which have no image, or no image was chosen when generating the PDF, the template will output the variable name "$PRODUCTS_IMAGENAME$" in stead of just leaving the table cell empty. I hope this clears up what I mean. RE: PDF maker outputs variable name when empty - Guido1982 - 11-09-2015 Another example of my problem: check out the two attached images. One is the letterhead from an invoice that has a contact assigned to it. The second line shows the contact name as excepted. The second one is the letterhead of an invoice using the exact same template, but this invoice doesn't have a contact related to it. It's quite clear that PDF maker doesn't understand this anymore, and prints the variable names. I shall do some more testing to see if I can locate this. If anyone has any idea how this can happen I'd be very happy to get some clues. This problem is holding me back to update the entire system at this point, I've got all other issues sorted out. I've been looking around in the PDF maker files, as far as they aren't encrypted (I get it, it's commercial so they have to protect it, not a complaint). I've noticed in PDFMaker.php there is a private method called "mpdf_processing": Code: private function mpdf_processing(&$mpdf, $templateid, $when) { I thnk maybe somewhere in this processing there is an issue, but the weird thing is, I can't find the folder 'modules/PDFMaker/mpdf_processing/'. It doesn't exist in respect to the root. Basically the 'generate PDF button' fires the 'CreatePDFFromTemplate' action, which is a file that does nothing but include 'checkGenerate.php'. That last file is totally encrypted, so I'm at a dead end. RE: PDF maker outputs variable name when empty - Guido1982 - 11-09-2015 About the variable notation inside PDF maker (the $VARNAME$), it is different than Smarty notation we see in tpl files. Does anyone know how and where these variable names into information to be retrieved from the database? Maybe I can continue my search here. RE: PDF maker outputs variable name when empty - omarllorens - 11-10-2015 Hi. I've been doing some tests and you have reason, there is something that we change in corebos that affect to pdfmaker. I'm trying to fix this problem and inform you here when you can update. RE: PDF maker outputs variable name when empty - Guido1982 - 11-10-2015 Ah great, thanks a million for the effort. If you have the time please post here what the problem was, so I can learn from it. RE: PDF maker outputs variable name when empty - omarllorens - 11-10-2015 The problem was fixed. You can update your code. We introduce this problem when we sync all the modules with the vtlib module code base. The directory to create a new module. In the construct before we call the function getColumnFields("Contacts" or "Service", ...) but now we have getColumnFields($currentModule). This was the problem, because the current module when call to construct was "PDFMaker" and not the related module. Now we use the class name for not have this kind of problems. You can do a git pull in your code and you can see the next commits: https://github.com/tsolucio/corebos/commit/1e07132b7e06323bbda24832160cec966f2fd366 https://github.com/tsolucio/corebos/commit/1b2885d2af5d7f19f5cd60b8ec27dcc75c119463 Thank you for find this problem and contribute to the project. Regards, Omar. RE: PDF maker outputs variable name when empty - Guido1982 - 11-10-2015 You are a genius. I will study this and see what I can learn. In the meantime it seems like it's working again. RE: PDF maker outputs variable name when empty - omarllorens - 11-10-2015 Thank you and wellcome! :-) |