778
* Returns data for the custom fields weekly report, based on the field and options passed in.
781
* @param integer $fld_id The id of the custom field.
782
* @param array $cfo_ids An array of option ids.
783
* @param string $start_date
784
* @param string $end_date
785
* @return array An array of data.
787
function getCustomFieldWeeklyReport($fld_id, $cfo_ids, $start_date, $end_date)
789
$prj_id = Auth::getCurrentProject();
790
$fld_id = Misc::escapeInteger($fld_id);
791
$cfo_ids = Misc::escapeInteger($cfo_ids);
793
$options = Custom_Field::getOptions($fld_id, $cfo_ids);
797
SUM(ttr_time_spent) time_spent,
803
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field,
804
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking,";
805
if (count($options) > 0) {
807
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "custom_field_option,";
810
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_custom_field,
811
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,
812
" . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
814
ttr_created_date BETWEEN '" . Misc::escapeString($start_date) . "' AND '" . Misc::escapeString($end_date) . "' AND
815
fld_id = icf_fld_id AND
816
ttr_iss_id = iss_id AND
818
if (count($options) > 0) {
820
" cfo_id = icf_value AND";
823
icf_iss_id = iss_id AND
824
isu_iss_id = iss_id AND
825
icf_fld_id = $fld_id";
826
if (count($options) > 0) {
828
cfo_id IN('" . join("','", Misc::escapeString(array_keys($options))) . "')";
834
$res = DB_Helper::getInstance()->getAll($sql, DB_FETCHMODE_ASSOC);
835
if (PEAR::isError($res)) {
836
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
839
for ($i = 0; $i < count($res); $i++) {
840
$res[$i]['field_value'] = Custom_Field::getDisplayValue($res[$i]['iss_id'], $res[$i]['fld_id']);
841
$res[$i]['time_spent_human'] = Misc::getFormattedTime($res[$i]['time_spent'], false);
780
847
* Returns workload information for the specified date range and interval.