Powered by Blogger.

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

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. These kind of companies do not sell always the same services or products, but they work on a “project basis”.

The process flow is similar to this one:
Marketing Department works on leads which turn into an opportunity.
Opportunity is passed to the Sales Department. When the opportunity has gone through all the sales stages and the customer finally agreea to buy your product/service it needs to be converted into a project.
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_IDamp;projectname=$POTENTIAL_NAMEamp;potential_id=$RECORD#39;, '',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:

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:

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:

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.

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.
    Blogger Comment
    Facebook Comment