I'm trying to implement a logichook for Tasks module. I'm simply trying to get the difference between the start_date and end_date of the tasks. I'm new to PHP and SugarCRM so if there is an internal function that I can use please let me know. Any guidance provided is greatly appreciated.
The section of code in question is highlighted in red below.
Thanks,
Brod
Version: 5.1.0b
Windows
MySQL 5.0.51b
<?php
function lookup_year_week(&$year_num, &$week_num, $start_date){
//try if this can obtain db connection, might not work
global $timedate;
$db_date = $timedate->swap_formats($start_date, $timedate->get_date_format(), $timedate->dbDayFormat);
$db = DBManagerFactory::getInstance();
$query = 'select year, week from week_period where start_date <=\''. $db_date . '\' AND end_date >=\''. $db_date . '\'';
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'].$type.": <BR>.".$query);
$row = $db->fetchByAssoc($result, -1, false);
$year_num = $row['year'];
$week_num = $row['week'];
}
function date_diff($end_date, $start_date){
error_log($end_date . " " . $start_date . "\r\n", 3, "bellis.log");
$timedate = new
$dateDiff = $end_date - $start_date;
error_log($dateDiff . "\r\n", 3, "test.log");
$fullDays = floor($dateDiff/(60*60*24));
$fullHours = floor(($dateDiff-($fullDays*60*60*24))/(60*60));
$fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60);
error_log($fullMinute, 3, "bellis.log");
return $fullMinutes;
}


LinkBack URL
About LinkBacks



Reply With Quote



Bookmarks