 |
vtiger The Honest Open Source CRM
|
| Previous topic :: Next topic |
| Author |
Message |
dpaultn
Joined: 09 May 2008
Posts: 6
Location: Oak Ridge, Tennessee
|
| Posted: Fri May 09, 2008 6:32 pm Post subject: Calculated 'Valid Till' Quote Field |
|
|
I'd like to create a picklist field that will calculate the quote 'valid till' date from the quote modified date. The picklist would have data like, 15 days, 30 days, 45 days, etc.
Has this been done before or what is the route that I should take to accomplish this?
Thanks,
Dave |
|
| Back to top |
|
joebordes
Joined: 18 Aug 2006
Posts: 1089
Location: Alicante/Valencia, Spain
|
| Posted: Fri May 09, 2008 9:30 pm Post subject: Re: Calculated 'Valid Till' Quote Field |
|
|
Hi,
Have a look at this thread:
http://forums.vtiger.com/viewtopic.php?t=14515
Things have changed since 5.0.2, mostly because now we have the save_module() function which is where the type of operation you need should be done.
Give it a go and get back to us if you need help.
Regards, Joe
TSolucio |
|
| Back to top |
|
joebordes
Joined: 18 Aug 2006
Posts: 1089
Location: Alicante/Valencia, Spain
|
| Posted: Fri May 09, 2008 9:31 pm Post subject: Re: Calculated 'Valid Till' Quote Field |
|
|
If you would like us to get this done for you drop me a message.
Joe
TSolucio |
|
| Back to top |
|
dpaultn
Joined: 09 May 2008
Posts: 6
Location: Oak Ridge, Tennessee
|
| Posted: Tue May 13, 2008 7:35 pm Post subject: Re: Calculated 'Valid Till' Quote Field |
|
|
I think that I'm on the right path..., but please tell me. I have add this code to the Quotes/EditView. I have added a custom field to the quote form named "Expiration" that contains a picklist of "15 days", "30 days", "45 days", etc.
if($focus->mode != 'edit')
{
$nowdate = new DateTime(getdate());
$nowdate->modify("+".$quote_focus->column_fields['expiration']);
$focus->column_fields["validtill"] = $nowdate;
}
I'm new at this. Pardon me lack of knowledge on assignments. Thank you for your help!!!
Dave |
|
| Back to top |
|
dpaultn
Joined: 09 May 2008
Posts: 6
Location: Oak Ridge, Tennessee
|
| Posted: Wed May 14, 2008 5:58 pm Post subject: Re: Calculated 'Valid Till' Quote Field |
|
|
OK.... I'm really close!! I have added this code
$valid_till = date('Y-m-d', strtotime('+'.$_REQUEST['cf_499']));
$smarty->assign("QUOTES",$valid_till);
to the modules/Quotes/Save.php file, right above the
setObjectValuesFromRequest(&$focus);
The "cf_499" field contains a list of text for the expiration of the quote, like "15 days", "30 days", "45 days", for instance. The issue that I'm having is how to write it back to the form. I think that the $smarty->assign is the way to go but I have no idea how to find what array that the field "valid_till" is assigned.
Thanks for your help!
Dave |
|
| Back to top |
|
dpaultn
Joined: 09 May 2008
Posts: 6
Location: Oak Ridge, Tennessee
|
| Posted: Thu May 15, 2008 7:07 pm Post subject: Re: Calculated 'Valid Till' Quote Field |
|
|
OK, I got it.
Since the "Valid Till" date is based on the quote modified date, I just used todays date and added whatever the user chooses from the Expiration picklist to calculate a new Valid Till date.
All this code is in the "modules/Quotes/Save.php", directly after the "$focus = new Quotes();" line.
// edit the Quote expiration date and the Valid Till date changes
$new_date_arr = Array(
'day' => $stday,
'month' => $stmonth,
'year' => $styear
);
$valid_till = date('Y-m-d', strtotime('+'.$_REQUEST['cf_499']));
list($new_date_arr['year'], $new_date_arr['month'], $new_date_arr['day']) = split('[/.-]', $valid_till);
$_REQUEST['validtill'] = $new_date_arr['day']."-".$new_date_arr['month']."-".$new_date_arr['year'];
There is most likely a better way of coding it..., but hey..., it works.
Dave |
|
| Back to top |
|
| |
|