+
+ // getTimeForMonth - gets total time for a user for a given month.
+ static function getTimeForMonth($user_id, $date){
+ import('Period');
+ $mdb2 = getConnection();
+
+ $period = new Period(INTERVAL_THIS_MONTH, $date);
+ $sql = "select sum(time_to_sec(duration)) as sm from tt_log where user_id = $user_id and date >= '".$period->getBeginDate(DB_DATEFORMAT)."' and date <= '".$period->getEndDate(DB_DATEFORMAT)."' and status = 1";
+ $res = $mdb2->query($sql);
+ if (!is_a($res, 'PEAR_Error')) {
+ $val = $res->fetchRow();
+ return sec_to_time_fmt_hm($val['sm']);
+ }
+ return 0;
+ }
+