vTiger Project Management: How to convert an Opportunity into a Project

Gantt Charts? Are you looking to improve vtiger Gantt chart and project management functionality? Check out a gantt chart add-on for VT 6

 

Being vTiger Project Management such a frequent requested feature, the most particular aspect of it usually required, is how to convert an opportunity into a project.

The Project-Oriented Company Business Case

This applies to service- oriented companies business cases, such as VGS Global. This kind of companies do not always sell the same services or products, but they work on a “project basis”.

The process flow is similar to this one:

  1. Marketing Department works on leads which turn into an opportunity.
  2. Opportunity is passed to the Sales Department. When the opportunity has gone through all the sales stages and the customer finally agreed to buy your product/service it needs to be converted into a project.
  3. Project is managed by Project Management team and this stage should have an option to issue an invoice after the project is completed.

In our last post, we have covered how to do a sales follow up with vTiger. Today, we are moving forward into the business model to convert a won opportunity into a project.

Adding a link in vTiger Module

The first step to convert the opportunity into a project is adding a link which, when clicked, will show the user the screen where he can create a new project, with the opportunity information on it.

To create the link we will use vtiger developer library called VTLIB. To get started,  create a new php file in your vtiger directory and paste the following code in it:

<?php

require_once('vtlib/Vtiger/Link.php');

Vtiger_Link::addLink(2,'DETAILVIEWBASIC','Create Project','index.php?module=Project&view=Edit&linktoaccountscontacts=$POT_PARENT_ID$&projectname=$POTENTIAL_NAME$&potential_id=$RECORD$', '',0,'');

?>

Save it as Add_new_link.php and point your browser  to http://www.example.com/vtigercrm/Add_new_link.php

Once done, when you go to opportunity, you will see the new Create Project link as shown below:

 vtiger new link opportunity

Add a new field in the project module to store the related opportunity

After creating a project, in order to track back from which opportunity this project originated, we need to add a new field in the project module, to relate the opportunity to the project.

To do so, we will use the VTLIB library, one more time. Create a new blank php file in your vtiger root and paste the following code on it:

<?php 
// Turn on debugging level 
$Vtiger_Utils_Log = true; 
include_once('vtlib/Vtiger/Menu.php'); 
include_once('vtlib/Vtiger/Module.php'); 

$module = Vtiger_Module::getInstance('Project'); 
$block1 = Vtiger_Block::getInstance('LBL_PROJECT_INFORMATION',$module); 

$field1 = new Vtiger_Field(); 
$field1->label = 'Opportunity'; 
$field1->name = 'potential_id'; 
$field1->table = 'vtiger_project'; 
$field1->column = 'potential_id'; 
$field1->columntype = 'VARCHAR(10)'; 
$field1->uitype = 10; 
$field1->typeofdata = 'V~O'; 

$block1->addField($field1); 
$field1->setRelatedModules(Array('Potentials')); 

$block1->save($module);  
?>

Save it as Add_related_field.php and point your browser  to http://www.example.com/vtigercrm/Add_related_field.php

Once done, when you go to project module you will see the new field on it:

Opportunity in project module

 Adding the link variables in DetailView

For the link to fully work, we need to pass some information from the potential module into the link. In this case, we will move three values from one module to the other.

  • Potential Account > Project Parent ID
  • Potential Name > Project Name
  • Potential Id > Project Opportunity Field

To do so, we need to edit the file located in modules/Potentials/models/DetailView.php. Look for the lines commented as VGS XXXXX below and copy that code into your file.

	public function getDetailViewLinks($linkParams) {
		$currentUserModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

               //VGS To add potential-project link - Starts
               $recordModel = $this->getRecord();

               $potentialRelated= $recordModel->entity->column_fields['related_to'];
               $potentialName=str_replace(' ', '%20', $recordModel->entity->column_fields['potentialname']);
               $linkParams['POTENTIAL_NAME']=$potentialName;
               $linkParams['POT_PARENT_ID']=$potentialRelated;

               //VGS To add potential-project link - Ends

		$linkModelList = parent::getDetailViewLinks($linkParams);
		//$recordModel = $this->getRecord(); VGS to convert LINK
		$invoiceModuleModel = Vtiger_Module_Model::getInstance('Invoice');

Once you finish editing this file, all you need to do is test the whole thing to make sure everything is working fine. If it does, when you click the create project link you should get the following:

vtiger project create view

Opportunity – Project’s Related List

To finish this tutorial, we will add a new related list in Opportunity module, to show the related project we have created, using the link we added in step one.

Once again, we will use the VTLIB Library. In this case, start by creating a new php file and paste the following code in it:

<?php

$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Module.php');

$module = Vtiger_Module::getInstance('Potentials');
$module->setRelatedList(Vtiger_Module::getInstance('Project'), 'Project',Array('ADD'),'get_dependents_list');
?>

Save it as Add_related_list and point your browser  to http://www.example.com/vtigercrm/Add_related_list.php

Once done, you will see your related projects in the opportunity module.

 Opportunity related Projects

Wrap up & Next Steps

To finish this process flow, it would be nice to create a custom function, to create an invoice from the project, using the project task as the invoice lines. Although it’s possible, it would take same serious programming to make it work.

In today’s post I have shown to you how to build your own sales and project management app, using vtiger. This same flow can be successfully applied to any company working on project basis.  You can also use the examples in this tutorial to create new links, related fields and lists within vtiger crm.

Make sure you subscribe to our newsletter! We will keep you posted about new ideas, developments and case studies you can easily put into practice to make your vtiger more efficient.

 

36 Comments:
  1. Thank you for the good tutorial!
    Do you have a suggestion how to link a project to an invoice?
    Thank you!

    • Frank,

      There is no easy way to convert the project into an invoice using the tasks as the products, that’s because you will need to create one product for each project task while converting the project into an invoice.

      Its possible to do it but it will take a lot of time.

  2. Thank you for the answer!
    But i’m afraid, there has been a misunderstanding here. I dont want to convert a project in an invoice but to link a project to an invoice and vice versa.
    How is that possible?

  3. Hi

    Thanks for this brilliant tutorial, it’s just what we needed:)

    Is there a way to migrate more information from the opportunity to the project? Currently only the opportunity name gets transferred but it would be good to also migrate other detail.

    Thanks
    Martin

    • Yes.. You need to repeat the same steps as you did with the opportunity name.

  4. Hi, thanks for the excellent tutorial

    I see in VTiger on demand, it is possible to associate emails with opportunities (either through the Outlook plugin 6.1, or through the Opportunity in vtiger or from migrating from leads)

    Is this possible to add this functionality using VTLib for the open source edition – either through a tutorial such as this or through custom development of a module?

    Best Regards,

    • Dave Hi..

      Yes, its possible to add e-mails related list to a module. Would take same coding besides adding the related list using VTLIB. Please contacts us over email is you are interested in this development.

      Thanks

        • Hi..

          Adding emails to a module its not as easy as adding any other module.

          The get_emails function expect the module to have a valid email field that its would use to search for the emails. You will need to modify that function.

          • Hi, thanks for the response. I have added an email field to projects, but am not sure what to modify in the function.

            Would you consider providing the code to do this on a commercial basis? Please email me a quote for this if possible.

            I would also need to be able to add emails to Projects through the Outlook plugin. Thx

          • Got emails linking to Projects, thanks for the feedback…only thing outstanding is listing Projects in the Outlook plugin, would be great to get this added then I will add full solution to the forum. Cheers

  5. I installed on VT6 and works great. Does it work with 5.4 or are there other instructions/modifications posted?

    • Hello Nate,
      Is very similar for vtiger 5.4 although its not exactly the same process. In 5.4 look for the file DetialView inside opportunity module to add the extra parameter.

      Adding the link should be the same.

      Let me know if you need extra help.

      • Can you describe where in the modules/Potentials/DetailView.php of the 5.4 version the changes need to be made to pass the parameters off to the Project?

        I have looked through that file for something similar to what you have listed for version 6 but can not find the correct location to enter the info.

        • Hello in 5.4 you need to look for the variable $CUSTOM_LINK inside DetailView.php. Usually is the last line in the file.

  6. One further query, is it possible to change the Opportunity status to “Closed Won” automatically on converting to a project? Thanks

  7. Hi Conrado,
    thanks for that nice tut.
    How is it if i want to add a custom Module with name “Partners”.

    Just replace “projects” with “partners”?

    thanks for your input and greetings from Austria,
    Marco

      • oh, Im sory. You missunderstood – my fault.
        My Module should be related to “OGANISATIONS”.
        So when I´n inside an organisation, i want to klick on the right side to “Partners” and then come to the related “Partners” Module.

        regards, Marco

  8. Thanks.
    I added an item on Related List and I want to delete it.
    Do you know the function ?

    Thank you
    Deken

    • Hi Deken,

      The function you are looking is: unsetRelatedList($moduleInstance, $label=”, $function_name=’get_related_list’)

      Or you can just remove from the module editor (vt6) or the database: vtiger_relatedlists

  9. Hi Conrado,
    can you please help me?

    Did it like you said in your Tutourial, but when i try to go to the related module (in related list) i just got blank page.

    http://sis.url1y.com/SiakS30

    What´s the “problem” – why are there no infos?
    When i go to the module itself, all is fine.
    but not in the related list.

    Marco

  10. Thank you very much, everything works fine, just no “Updates” information shows up.
    World you like to make this perfect.

    Thanks

  11. Thanks.for the excellent tutorial
    ======================

    For Reinstallation, they(database table,) will disappear.

    1.How to make the “expansion module”For auto installation?

    2.How to save “a custom field, and block”,For Reinstallation?

  12. Hi,

    I want remove this config how should procced?
    Or help-me fix infos for project …

    Many Thanks
    Tiago Carvalho

    • Hi.

      You need to delete the link you have added. Look in the vtiger_links table.

  13. Hi

    Great tutorial – however I am having a few issues with this step:
    Adding the link variables in DetailView

    When opening the file DetailView.php I am unsure where to paste your code as I cannot located any lines with VGS XXXXX. I have tried pasting it towards the bottom but then I just get a blank page when testing it.

    Any ideas?

    Thanks

    • Hello.. The lines with VGS are the ones you need to add. Look for the immediate line before/after those lines.

  14. Hi,
    Thanks for your tutorial.
    Maybe I missed something because from an opportunity, when I click on ‘Projects’ in the right, I can’t see my related project (I have just a screen with the opportunity name).
    Thks

    • Hello,

      When you create a new project the “Opportunity” Field is properly complete?

      • I know where is my mistake :
        Your tuto is ok and running perfectly on a fresh installation.
        I updated vtiger 5.4 to vtiger 6.2. In 5.54, there was a link beetween opportunities and projects (manually created). This link doesn’t work on 6.2. -> I have to recreate it.
        If I follow your tuto, I got an error message =
        “Fatal error: Call to undefined method Potentials::get_dependents_project_list() in /home/web/vtiger62dev/modules/Vtiger/models/Module.php on line 1311”.
        So, I have to change somethings in my configuration.