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?
echo custom field in table on 'time' page?
-
- Posts: 2
- Joined: Sat Jan 07, 2017 11:14 pm
Re: echo custom field in table on 'time' page?
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.
-
- Posts: 2
- Joined: Sat Jan 07, 2017 11:14 pm
Re: echo custom field in table on 'time' page?
Hi Nik. that's a good pointer to start from. thanks.
Re: echo custom field in table on 'time' page?
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} {/if}</td> //after this line add:
{if ($user -> isPluginEnabled('cf'))}
<td valign="top">{if $record.cvalue}{$record.cvalue|escape}{else} {/if}</td>
{/if}
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} {/if}</td> //after this line add:
{if ($user -> isPluginEnabled('cf'))}
<td valign="top">{if $record.cvalue}{$record.cvalue|escape}{else} {/if}</td>
{/if}
Re: echo custom field in table on 'time' page?
Hello together,
I'm using and providing Timetracker for more than one year and I'm very happy to have it.
I'm customizing some files for some months and it works great
But I had this problem above, too. I solved it in a similar way, as here shown.
After that I found this forum entry...
This useful small change is not on github.Why!?
I'm not familiar with github, but I want to try it.
Maybe some administer can help me
Thanks and greetings - Dan
I'm using and providing Timetracker for more than one year and I'm very happy to have it.
I'm customizing some files for some months and it works great

But I had this problem above, too. I solved it in a similar way, as here shown.
After that I found this forum entry...
This useful small change is not on github.Why!?
I'm not familiar with github, but I want to try it.
Maybe some administer can help me

Thanks and greetings - Dan
Re: echo custom field in table on 'time' page?
Custom field output is included on time.php page in Time Tracker 1.18.65.4934.
Re: echo custom field in table on 'time' page?
Unfortunately this functionality was lost in one of last TimeTracker-updates.
Maybe there is not enough space on time page, because of multiple custom fields.
In my case it's a feature for better usability. There are only narrow custom fields - e.g. work package in a work breakdown structure (german: PSP). So I modified some files to get more space for showing custom fields:
ttTimeHelper.class.php ==> you can find it on GitHub
time.tpl --> completely new, view new topic: viewtopic.php?f=4&t=2045
One new file: time_div.css --> for separating custom styling and layouts
two lines modified:
config.php --> define('DIV_CSS', 'time_div.css'); // for additional CSS
header.tpl --> <link href="{$smarty.const.DIV_CSS}" rel="stylesheet" type="text/css"> // include additional CSS-file
An additional possibility for more space is checking the display-option "note on separate row".
It would be fine if we can reactivate custom field(s) on time page...
Thanks - Dan
Maybe there is not enough space on time page, because of multiple custom fields.
In my case it's a feature for better usability. There are only narrow custom fields - e.g. work package in a work breakdown structure (german: PSP). So I modified some files to get more space for showing custom fields:
ttTimeHelper.class.php ==> you can find it on GitHub
time.tpl --> completely new, view new topic: viewtopic.php?f=4&t=2045
One new file: time_div.css --> for separating custom styling and layouts
two lines modified:
config.php --> define('DIV_CSS', 'time_div.css'); // for additional CSS
header.tpl --> <link href="{$smarty.const.DIV_CSS}" rel="stylesheet" type="text/css"> // include additional CSS-file
An additional possibility for more space is checking the display-option "note on separate row".
It would be fine if we can reactivate custom field(s) on time page...
Thanks - Dan
Re: echo custom field in table on 'time' page?
Latest Time Tracker (1.19.23.5287 at the time of this writing) now has a display option called "Custom fields", which turns on or off all defined custom fields on the time entry page.
You can access it from Group settings > Display options > Configure.
You can access it from Group settings > Display options > Configure.
- Attachments
-
- custom-fields-display-option.png (30.44 KiB) Viewed 1310 times