10 April 2012

How to create new UI type in vTiger CRM

Steps to make new UI Type

When new button is clicked the UI that comes uses EditViewUtils.php and EditViewUI.tpl

EditView and CreateView

EditViewUtils.php

Add a new elseif block for our new uitype - else if ($uitype == 1001) {

1) $editview_label[]=getTranslatedString($fieldlabel, $module_name); This line will store the label of the field

2) $fieldvalue[] = $phoneValue; $fieldValue will store the value of that UI type

So the block looks like this -
else if ($uitype == 1001) {
$phone = $_REQUEST[$fieldname];
//echo $_REQUEST['$fieldname'];
$phoneValue = explode("-",$phone);
//print_r($phoneValue);
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = $phoneValue;


}


EditViewUI.tpl

{elseif $uitype eq '1001'}

{$mandatory_field}{$usefldlabel}
{if $MASS_EDIT eq '1'}<< type="checkbox" name="{$fldname}_mass_edit_check" id="{$fldname}_mass_edit_check" class="small">{/if}


onFocus="this.className='detailedViewTextBoxStdCodeOn'"
onBlur="this.className='detailedViewTextBoxStdCode'" onChange="makePhoneNo()"> -
size="20" name="phoneno" id="phoneno" value="{$fldvalue[1]}"
class=detailedViewTextBoxPhone onFocus="this.className='detailedViewTextBoxPhoneOn'" onBlur="this.className='detailedViewTextBoxPhone'" onChange="makePhoneNo()">


1) {$usefldlabel} comes from $editview_label[] of EditViewUtils.php 2) {$fldvalue[0]} comes from $fieldvalue[] of EditViewUtils.php

Detail View

DetailViewUtils.php

elseif($uitype == 1001) {
//echo $_REQUEST[$fieldname];
$label_fld[] = getTranslatedString($fieldlabel, $module);
$fieldValues = explode("-",$col_fields[$fieldname]);
array_push($label_fld, $fieldValues);
//print_r($label_fld);
}

1) $label_fld[0]=getTranslatedString($fieldlabel, $module_name); This line will store the label of the field

2) $label_fld[1] = $phoneValue; $fieldValue will store the value of that UI type

DetailViewUI.tpl

{elseif $keyid eq 1001}
<td class="dvtCellInfo" align="left" width=25%"> {$keyval[0]}-{$keyval[1]}
<input type="hidden" name="{$keyfldname}" id="{$keyfldname}" value="{$keyval[0]}-{$keyval[1]}" ></td>
1) {$keyval[0]},{$keyval[1]} comes from $label_fld[1] of DetailViewUtils.php

dtlviewajax.js

else if(uitype == 1001)
{
fieldNameArray = fieldName.split(",");
var stdCode = document.getElementById(fieldNameArray[1]).value;
var phoneNo = document.getElementById(fieldNameArray[2]).value;
var txtBox = 'txtbox_' + fieldLabel;
document.getElementById(txtBox).value = stdCode + "-" + phoneNo;
//alert(document.getElementById(txtBox).value);

}

When in detail view u click on edit inside the box, then when the value of StdCode and Phone changes it should reflect in hidden field that is why we have this ajax.

CSS

Go to the following file and make appropiate css /themes/{theme_name}/style.css

Example in - /themes/softed/style.css I made the following css

.detailedViewTextBoxStdCode {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #000000;
border:1px solid #bababa;
padding-left:5px;
width:15%;
background-color:#ffffff;
}

.detailedViewTextBoxPhone {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #000000;
border:1px solid #bababa;
padding-left:5px;
width:60%;
background-color:#ffffff;
}
.detailedViewTextBoxStdCodeOn {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #000000;
border:1px solid #bababa;
padding-left:5px;
width:15%;
background-color:#ffffdd;
}

.detailedViewTextBoxPhoneOn {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #000000;
border:1px solid #bababa;
padding-left:5px;
width:60%;
background-color:#ffffdd;
}

Fixing the Issue on Custom Module Saving That Gives a Blank Data

The reason for displaying a page during save is the empty entry in the vtiger_entityname table.

mysql> insert into vtiger_entityname(fieldname,tablename,entityidfield,modulename,tabid,entityidcolumn) values ('didtestname','vtiger_didtest','didtes
tid','DIDTest',47,'didtestid');
Query OK, 1 row affected (0.03 sec)
but the other solution is to include this text..

$moduleInstance->initWebservice();
Another issue when a particular module is saved it is giving an empty page. This time aside from that table “vtiger_entityname” mentioned above, a table “vtiger_ws_entity” must be also looked upon. The issue encountered is that when saved, its just give an empty page. When that table is examined, it turns out that the name of the module is “Receivable” (notice the caps on R) while it expects to be “receivables”. After updating the table, it is fixed :)

fixing_blank_on_custom_module_saved_issue.txt · Last modified: 2010/05/28 14:00 (e

29 September 2009

Short note on javascript refresher

In the program i made, which tabulates the latest 20 call in a minute, I've found some good resource for it.
My setup, perl-cgi script is the one that generates the list of calls. This script is just called via an Ajax function.


The main important part of that is part that contains this setInterval.
I chose setInterval since the "Call Accounting System" i made needs a refreshing every minute to update
the user about the activity of PBX.

The code also requires to have an id "content" to have the content generated by "refresher.cgi" displayed.
An example of usage will be.

<div id="content">&nbsp;</div>

and i put the code at the bottom of the html page.

<script type="text/javascript" src="20records.js"></script>


Below is the content of the 20records.js file:





var xmlhttp;

function showList()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="refresher.cgi";
url=url+"?sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{

document.getElementById('content').innerHTML = xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
window.setInterval("showList();",60000)

11 May 2009

A Notes on UTF8 in PHP & MYSQL

According to Wikipedia, the Congo Region has 3 countries, the 2 Congo countries and the Angola.

I was tasked 2 list the countries all over the world and that includes the two (2) countries of Congo called Republic of the Congo (Congo-Brazzaville) and the Democratic Republic of the Congo (Congo-Kinshasa).

The addition of the dash - thing on the country to identify that separate country rendered some special unknown characters in both IE and Firefox browser. So upon seeing the content of the combo-box that contains the list of the country, this 2 country was rendered then as Congo <special character> Kinshasa and Congo <special character> Brazzaville. I thought that was just the result of the uploads via LOAD DATA INFILE command of Mysql yet when I browse the code via mysql client console, the dash stays there. Later I realize that this UTF8 thing really made that difference.

Thus using the command :
mysql_query("SET NAMES 'utf8'");
resolves that issue.

17 April 2009

Stop the Annoying Restart Now - Restart Later popup

I've been annoyed by this Windows Automatic Update popup on my WinXP box. I'm trying to get rid of this. When I google this keyword - I end up browsing and reading some suggestions to messed up with my Windows Registry.
One suggestion that i like is this - a very simple one.
Steps:
1) Click the start button
2) Select and click the "Run"
3) On the run dialog box, type the CMD to open the WinXP DOS shell.
4) On the command prompt (the one with c:\Documents and Settings\whoareyou>), type this sc stop wuauserv

Nice one. I've tried and tested this.

The Windows Update icon on the system tray will disappear. No more annoying restart popup also will appear after this.

01 February 2009

Perl: Appending array in a hash element

My code :
push($parentmenu{$parentkey}{childlist},[$childmenu{$childid}{name},$childmenu{$childid}{link}]);

Gives me this error.

Type of arg 1 to push must be array (not hash element) at ./test.cgi line 34, near "])"
Execution of ./test.cgi aborted due to compilation errors.


And it was just resolved by adding the @ and enclose it with {} - see the code below. I need an explanation though, but I'll have to find the explanation later, for the meantime the solution just worked for my task.

push(@{$parentmenu{$parentkey}{childlist}},[$childmenu{$childid}{name},$childmenu{$childid}{link}]);

06 July 2008

My Test in Blender

Here is my test in blender. Its a sandtimer though but I dont know how to put a sand on it.
Enjoy :)