echo custom field in table on 'time' page?

Discussion forum about Anuko Time Tracker

echo custom field in table on 'time' page?

Postby whitlander » Sun Jan 08, 2017 2:19 pm

Thank you for this excellent tool. Its very near to what I need but need help echoing out the custom field I have added in the table shown below the form on the 'time' page.

Where the table is currently showing fields:
Project Start Finish Duration Note Edit
I need to show my custom field:
Project CustomField Start Finish Duration Note Edit

Can you help?
whitlander
 
Posts: 2
Joined: Sat Jan 07, 2017 11:14 pm

Re: echo custom field in table on 'time' page?

Postby Nik » Fri Jan 13, 2017 9:36 pm

Looks like you'll need to modify ttTimeHelper::getRecords() to do an additional join to get custom field value and then modify WEB-INF/templates/time.tpl to display appropriate header and value.
Nik
 
Posts: 343
Joined: Wed May 26, 2010 5:55 pm

Re: echo custom field in table on 'time' page?

Postby whitlander » Fri Jan 13, 2017 9:47 pm

Hi Nik. that's a good pointer to start from. thanks.
whitlander
 
Posts: 2
Joined: Sat Jan 07, 2017 11:14 pm

Re: echo custom field in table on 'time' page?

Postby jmkas » Sun Sep 24, 2017 2:11 pm

Hey,

if you wanna to make this you need to do that:

in WEB-INF/lib/ttTimeHelper.class.php at getRecords function add this stuff:
$client_field = null; //near this line
$custom_field = null; //add this
if ($user -> isPluginEnabled('cf')) //and this
$custom_field = ", cf.value as cvalue"; //and this

after $left_joins declaration add this:
if ($user -> isPluginEnabled('cf'))
$left_joins .= " left join tt_custom_field_log cf on (l.id = cf.log_id and cf.status = 1)";

and edit $sql like this:
$sql = "select l.id as id, TIME_FORMAT(l.start, $sql_time_format) as start,
TIME_FORMAT(sec_to_time(time_to_sec(l.start) + time_to_sec(l.duration)), $sql_time_format) as finish,
TIME_FORMAT(l.duration, '%k:%i') as duration, p.name as project, t.name as task, l.comment, l.billable, l.invoice_id $client_field $custom_field
from tt_log l
$left_joins
where l.date = '$date' and l.user_id = $user_id and l.status = 1
order by l.start, l.id";



and in WEB-INF/templates/time.tpl add this stuff:

<td class="tableHeader">{$i18n.label.note}</td> //after this line add:
{if ($user -> isPluginEnabled('cf'))}
<td class="tableHeader">{$custom_fields->fields[0]['label']}</td>
{/if}

and:
<td valign="top">{if $record.comment}{$record.comment|escape}{else}&nbsp;{/if}</td> //after this line add:

{if ($user -> isPluginEnabled('cf'))}
<td valign="top">{if $record.cvalue}{$record.cvalue|escape}{else}&nbsp;{/if}</td>
{/if}
jmkas
 
Posts: 5
Joined: Fri Jun 23, 2017 7:12 am


Return to Time Tracker

Who is online

Users browsing this forum: No registered users and 3 guests

cron