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

Categories
Business suitecrm Technology Tutorial Ubuntu

HOW TO CHANGE THE ROW HEADERS IN SUITECRM LINE ITEMS IN QUOTES MODULE

PRE-CHAT

As always, SuiteCRM is one of my favourite business tools in the free and open software world. I like to describe it as ‘Sales Force on steroids’ because you can do whatever you want with it, basically, since the code is open and community supported. However, once in a while you will hit a road block.

This literally took me two weeks, full time, serious pain. Granted I didn’t know a drop of PHP, but wowzers – hard. The good news is this is going to save you that much time or more.

First of all, for some reason this really useful page evaded me for the first week. Had I found this everything would have made a lot more sense sooner. So bookmark this important page about SuiteCRM customizations. This page will be very useful if you plan to really dig deep and customize things for yourself and others.

This tutorial is assuming you have root access to your server and you are doing things ‘on the fly’ like me and not with a proper developers environment – a real weekend warrior hack space. If you are a real developer with skills, bonus! You can probably just upload your work and not worry about root user stuff maybe. In either case this will save you time.

Note this: SuiteCRM has periodic upgrades, of course, and if you do things the way they like your customizations will make it through the upgrade. Otherwise, you stand to lose your work when they upgrade. I would recommend documenting stuff as you go like I’m doing here in case you have to rebuild stuff. Ideally everything I’m doing here should be built right into the GUI, but for some reason it’s not for this part. Hopefully someone can take my work here and build this line item functionality right into the GUI.

WHAT I LEARNED ABOUT THE HEADERS

The customization of the row headers is essentially a ‘language-translation’ approach. This makes sense because if you were German you would want the word ‘List’ and ‘Price’ to be in German. However, unlike most of the other parts of SuiteCRM (‘scrm’ from now on) you can’t seem to edit these from within Admin / Studio – the logical place you would expect to be able to do this. I believe it is very rare that this kind of customization would be required however, more control over this part is, in my opinion, critical because of the various tax rates and other needs. In my case I needed to add recycling deposits and environmental fees to the row, but others I know needed multiple taxes.

In this case, we want to modify the strings / language that are found in this en_us language file.

Also it is worth mentioning that you should not change the pre-pending part of the php file as suiteCRM will go through and scan for that. So if you are using en_us (the default) make sure that stays at the front of your modified PHP file.

For this example, I want to change line 161 which has this:

‘LBL_UNIT_PRICE’ => ‘Sale Price’,

I don’t like the word ‘Sale Price’ and I want it to say ‘POOPY PRICE’ (to be sure it jumps off the page when it’s working)

Before we go forward, the documentation above fails to mention two important things:

  1. You must be root / sudo user in order to modify anything beyond the /modules path and
  2. There is no pre-existing ‘Language’ directory at all – you must create it first

This is the format and location of where your newly-created file will go and look like. Study it deeply:

custom/Extension/modules/<TheModule>/Ext/Language/<LanguageTag>.<Name>.php

Now let’s run the actual example step by step.

HOW TO DO IT.

As mentioned above, this string ‘Sale Price’ is found stock in this en_us language file in the AOS_Quotes module. So the first step is to be sure you are modifying the correct module. Adjust the paths according to your needs.

  1. Log into your SuiteCRM instance
  2. Change to root user (in my case with sudo su) and of course be careful since you can kill everything now, ha
  3. Navigate to the Ext folder: cd /var/www/html/suitecrm/custom/Extension/modules/AOS_Quotes/Ext/
  4. Make the ‘Language’ directory that SCRM needs: mkdir Language
  5. Navigate into it: cd Language
  6. Create a new blank php language customization file into which you will paste your code: sudo nano en_us.myTestFile.php
  7. Paste in this example code:
<?php
$mod_strings['LBL_UNIT_PRICE'] = 'SLOPPY PRICE';
  1. Control x to save your changes in the terminal (if you are using Ubuntu, if not not sure…)

At this point, in your test quote in SCRM you will see no changes it seems. I refreshed, I did a control + F5, I edited the quote, I did everything. My changes did not show. Then, I did the quick repair and build, refreshed changes and there was my new POOPY PRICE header. So these are those last steps after you make a customization:

  1. Go to ‘Admin’ in SCRM
  2. Under ‘System’ go to ‘Repair’
  3. Select ‘Quick Repair and Rebuild’
  4. Go back to your quote and refresh the page – your changes should now be visible in the header.

Very likely the process is the same for modifying all strings in SCRM so be sure to dig into that resource link above if you plan to go further.

I hope this helps and saves you the pain I had to go through! 🙂