Categories
Business suitecrm Technology Tutorial Ubuntu

HOW TO MODIFY THE DISPLAY OF SUITECRM PRODUCT LINE ITEM ROWS IN QUOTE MODULE

It seems like I’m writing a series here on these SuiteCRM (‘SCRM’ moving forward) topics these days so I might as well keep going! If you haven’t read them, these might be of interest:

For this one, I will cover how to dig into the back end of SCRM to modify the way that the Quotes module displays the Line Items in their columns when not in edit mode. The content stuff will come in what I hope will be my last tutorial on this topic.

Disclaimer: I have no idea if any of these changes will survive a SCRM upgrade. Probably you’ll want to save any / all of your modified files somewhere safe when you create them, otherwise you’ll have to do a deep dive into how to do this properly (there is a correct way out there). In short, this is a hacky way to bring extra functionality until the GUI has what we need (hopefully soon, but they’re doing their best)

First, here is a reference link to the line_items.php file so that we are all on the same page and know to find it in our server and elsewhere.

This file is the one that tells SCRM how to lay out the Line Item module within the Quotes module. One would think you could just go in and edit the quotes module and a kind of a ‘sub-module’ for line items but it appears this functionality is still not here. If you are a good developer it would, obviously, be nice to have this built into the GUI so others don’t have to go through the pain of tutorials like these.

Let’s get familiar with the code blocks

For the purpose of this tutorial we will assume we all will be modifying products, not services and not groups, although I’m guessing you could apply the exact same method to those too.

There are two main code blocks in this page that concern most of what we’ll want to manipulate:

  1. This html table row (tr) block that starts on line 155. This one maps which column labels get applied to the headers and maps them.
  2. This second html table row block that starts on line 168

1. Headers and Column Display

This block, as you can see, assigns column widths to each row. I modified mine by adding two more, and doing some math on the column widths to adjust accordingly to hit 99% (which is where it was when I found it)

Then, I copied the following line of code from the example and pasted it right after where it was:

$product .= "<td width='9%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>".$mod_strings['LBL_VAT_AMT']."</td>";

The plan is to simply copy a line of what’s working, double it, and see if it shows up as a double. You can then modify stuff after you see it’s working (that’s my method). You can see that I modified the width a bit. You might want to try a more extreme number to see the results when the show up.

Then, I went into my terminal to add my changes in with the following steps:

  • Navigate to your Products_Quotes module directory:
    cd /var/www/html/suitecrm/modules/AOS_Products_Quotes
  • Open the file for editing: nano nano Line_Items.php
  • Drill down to the correct block. For me, I commented out the entire tr block with the php /** and */ comment lines so that I could just uncomment them, erase my code and have it back to normal again. Up to you. Once you find it, paste in the above line of code into the block.
  • Save your changes in your terminal (for me it is control x and save changes)

At this point, you will not see any changes in SCRM even if you refresh the browser. You need to perform these steps which I will then call ‘Repair / Rebuild’ after explaining them here:

  1. Go to ‘Admin’ in SCRM
  2. Go to Settings / Repair
  3. Select ‘Quick repair and rebuld’ option.
  4. Wait for changes
  5. Refresh browser to check changes

At this point you should see your column heading doubled, but there will be no content in the cell. That is because you need to do the next part which is to create the lines in the next code block

Mapping in the cell data to the cell

Now you should see your newly created header in the quotes module with line items.

Now we need to map the corressponding lines to that cell.

From my understanding there is one header per cell data and you have to map them in order. So if you wanted “Happy Tax” to be your fifth column / cell in the quote, you’d put it in the fifth position in for the header and then in this code block put it in the same position in the list. I just copied and pasted the same one, in the same posistion as my example above. This next one corresponds to the header I made above:

$product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt, $params)."</td>";

After adding this extra one, saving my changes, and doing the Repair / Rebuild, the data now showed up in the cell.

You have now successfully learned how to display the header and the cell content in the detail view of the line items in the Quotes module of SCRM. However, it’s still not useful since there is nothing mapping from the Products module. Hopefully that will be my next blog if everything goes well!

Hope that helps

Leave a Reply

Your email address will not be published. Required fields are marked *