Project Detail

Quick PHP Job - SugarCRM Hook to create autonumbering  

Quick PHP Job - SugarCRM Hook to create autonumbering is project number 467796
posted at Freelancer.com. Click here to post your own project.

 

| More Free Trial For New Buyers
 

Status:

Selected Providers: maruti1001

Budget: $30-250

Created: 07/13/2009 at 0:03 EDT

Bid Count: 3

Average Bid:
$ 163

07/14/2009 at 0:03 EDT

Project Creator: yourwebbox
Employer Rating: 10/1010/1010/1010/1010/1010/1010/1010/1010/1010/10 (2 reviews)

Bid On This Project
 

Description

Software: Sugar CRM
I need a logic hook created.

High level: Create Sequential AUTO ID for a new customer when a sugar crm user saves a new customer.

Sugar CRM has logic hooks. You can develop things within a certain environment.
When the user clicks the save button when creating a new customer, it will get the next customer id and write:

Name: NEXT ID + FIRST NAME + LAST NAME
SIC_CODE = NEXT ID
INTERNAL_KEY_C: = NEXT ID

Sample Data:
Name: AC1001003 George Smith
SIC_CODE: AC1001003
INTERNAL KEY: AC1001003

Current code that I use on my forms you could re-use:

//make new User Interface ID for a record
Function GetNewUID($module_name){
$chandle = mysql_connect(DBLOC, DBUSER, DBPASS) or die("Connection Failure to Database");
mysql_select_db(DBNAME, $chandle) or die(DBNAME . " Database not found. " . DBUSER);

$sql = "select name, value from a_settings where module_name = '" . $module_name . "'";
$result = mysql_db_query(DBNAME, $sql) or die("Failed Query of " . $sql);
if ($result = mysql_query($sql)) {
if ($row = mysql_fetch_row($result)) {
$new_prefix = $row[0];
$new_value = $row[1];
}
} else {
echo "<!-- SQL Error " . mysql_error() . " -->";
}
//define client id for new customer
$new_uid = $new_prefix . $new_value;

//update settings with new value
$new_value = $new_value +1;
$sql = "UPDATE a_settings SET value = '" . $new_value . "' WHERE module_name = '" . $module_name . "' LIMIT 1";
$result = mysql_db_query(DBNAME, $sql) or die("Failed Query of " . $sql);
return $new_uid;
}



Here is my code I use on my webforms to create a new customer:

// create new user if not found
if (empty ($_SESSION['ywb_user_info'][accounts_id])) {
$formData['uid'] = make_key();
$_SESSION['ywb_user_info'][accounts_id] = $formData['uid'];

//retrieve next client id
$formData['clid'] = GetNewUID('Accounts');
$_SESSION['ywb_user_info'][accounts_sic_code] = $formData['clid'];

//add customer record - accounts
$sql = "INSERT INTO accounts(
" . $insert_field . "
name,
date_entered,
date_modified,
modified_user_id,
created_by,
deleted,
assigned_user_id,
account_type,
sic_code,
id
)
VALUES (
" . $insert_value . "
'" . $formData['clid'] . " " . $formData['first_name']. " " . $formData['last_name'] . "',
'" . $formData['datetime'] . "',
'" . $formData['datetime'] . "',
'1',
'1',
'0',
'1',
'Lead',
'" . $_SESSION['ywb_user_info'][accounts_sic_code] . "',
'" . $formData['uid'] . "'
)";
$result = mysql_db_query(DBNAME, $sql) or die("Failed Query of " . $sql);

//add customer record - accounts_cstm
$sql = "INSERT INTO accounts_cstm(
" . $cstm_insert_field . "
internal_key_c,
id_c
)
VALUES (
" . $cstm_insert_value . "
'" . $_SESSION['ywb_user_info'][accounts_sic_code]. "',
'" . $formData['uid']. "'
)";
$result = mysql_db_query(DBNAME, $sql) or die("Failed Query of " . $sql);




Please read this post. They are doing it to contacts. So essentially it would be the same, however, I need to to an account record (a customer).

http://www.sugarcrm.com/forums/showthread.php?t=39696

I have a logic hook creator, it just needs the custom code.

This is where the custom code would be placed:

Editing method Autonumbering_method in class Autonumbering_class for Customers before_save

<?php
class Autonumbering_class
{
function Autonumbering_method(&$bean, $event, $arguments=null)
{
if ($event != 'before_save') return;
// Insert your custom logic between these comments




// Insert your custom logic between these comments
}
}
?>


Please BID and when i accept you I will give you login details to sqldb, sugarcrm, webroot to place your Custom Logic Code between the lines.
Cheers.

Messages Posted:0 View project clarification board Post message on project clarification board

Bid On This Project
 

If you are the project creator or one of the bidders Log In for more options

 

240

6 days

07-13-2009 04:44 EDT

lets start now

help

 

150

1 day

07-13-2009 05:34 EDT

Please check PMB. Thanks

help

 

100

4 days

07-13-2009 05:32 EDT

(No Feedback Yet)

Hello, I can do this Task. I have exp with SugarCrm & VTiger CRM and done small customization project in SugarCRM. Thanks, Bhushan

help


    Bid on this Project