$cl_date = $selected_date->toString(DB_DATEFORMAT);
$_SESSION['date'] = $cl_date;
// TODO: for time page we may limit the day to today only.
$cl_date = $selected_date->toString(DB_DATEFORMAT);
$_SESSION['date'] = $cl_date;
// TODO: for time page we may limit the day to today only.
$cl_start = trim($request->getParameter('browser_time'));
$cl_finish = trim($request->getParameter('browser_time'));
// Custom field.
$cl_start = trim($request->getParameter('browser_time'));
$cl_finish = trim($request->getParameter('browser_time'));
// Custom field.
-if (in_array('iv', explode(',', $user->plugins))) {
- if ($request->getMethod() == 'POST') {
+if ($user->isPluginEnabled('iv')) {
+ if ($request->isPost()) {
$_SESSION['task'] = $cl_task;
// Obtain uncompleted record. Assumtion is that only 1 uncompleted record is allowed.
$_SESSION['task'] = $cl_task;
// Obtain uncompleted record. Assumtion is that only 1 uncompleted record is allowed.
-if (MODE_TIME == $user->tracking_mode && in_array('cl', explode(',', $user->plugins))) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
+ $active_clients = ttGroupHelper::getActiveClients(true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
- if (in_array('cl', explode(',', $user->plugins))) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ if ($user->isPluginEnabled('cl')) {
+ $active_clients = ttGroupHelper::getActiveClients(true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
// Build a client list out of active clients. Use only clients that are relevant to user.
// Also trim their associated project list to only assigned projects (to user).
foreach($active_clients as $client) {
// Build a client list out of active clients. Use only clients that are relevant to user.
// Also trim their associated project list to only assigned projects (to user).
foreach($active_clients as $client) {
- $projects_assigned_to_client = explode(',', $client['projects']);
- $intersection = array_intersect($projects_assigned_to_client, $projects_assigned_to_user);
- if ($intersection) {
- $client['projects'] = implode(',', $intersection);
- $client_list[] = $client;
- }
+ $projects_assigned_to_client = explode(',', $client['projects']);
+ $intersection = array_intersect($projects_assigned_to_client, $projects_assigned_to_user);
+ if ($intersection) {
+ $client['projects'] = implode(',', $intersection);
+ $client_list[] = $client;
+ }
}
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
}
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
-if (in_array('iv', explode(',', $user->plugins)))
- $form->addInput(array('type'=>'checkbox','name'=>'billable','data'=>1,'value'=>$cl_billable,'enable'=>$enable_controls));
+if ($user->isPluginEnabled('iv'))
+ $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable,'enable'=>$enable_controls));
$form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on button click.
$form->addInput(array('type'=>'hidden','name'=>'browser_time','value'=>'')); // User current time, which gets filled in on button click.
$enable_start = $uncompleted ? false : true;
$form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on button click.
$form->addInput(array('type'=>'hidden','name'=>'browser_time','value'=>'')); // User current time, which gets filled in on button click.
$enable_start = $uncompleted ? false : true;
-$enable_stop = $uncompleted ? true : false;
-$form->addInput(array('type'=>'submit','name'=>'btn_start','onclick'=>'browser_time.value=get_time()','value'=>$i18n->getKey('label.start'),'enable'=>$enable_start));
-$form->addInput(array('type'=>'submit','name'=>'btn_stop','onclick'=>'browser_time.value=get_time()','value'=>$i18n->getKey('label.finish'),'enable'=>$enable_stop));
-
+if (!$uncompleted)
+ $form->addInput(array('type'=>'submit','name'=>'btn_start','onclick'=>'browser_time.value=get_time()','value'=>$i18n->get('label.start'),'enable'=>$enable_start));
+else
+ $form->addInput(array('type'=>'submit','name'=>'btn_stop','onclick'=>'browser_time.value=get_time()','value'=>$i18n->get('label.finish'),'enable'=>!$enable_start));
+
// If we have custom fields - add controls for them.
if ($custom_fields && $custom_fields->fields[0]) {
// Only one custom field is supported at this time.
if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) {
$form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1));
// If we have custom fields - add controls for them.
if ($custom_fields && $custom_fields->fields[0]) {
// Only one custom field is supported at this time.
if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT) {
$form->addInput(array('type'=>'text','name'=>'cf_1','value'=>$cl_cf_1));
$form->addInput(array('type'=>'combobox','name'=>'cf_1',
'style'=>'width: 250px;',
'value'=>$cl_cf_1,
'data'=>$custom_fields->options,
$form->addInput(array('type'=>'combobox','name'=>'cf_1',
'style'=>'width: 250px;',
'value'=>$cl_cf_1,
'data'=>$custom_fields->options,
-// Determine lock date. Time entries earlier than lock date cannot be created or modified.
-$lock_interval = $user->lock_interval;
-$lockdate = 0;
-if ($lock_interval > 0) {
- $lockdate = new DateAndTime();
- $lockdate->decDay($lock_interval);
-}
-
if ($request->getParameter('btn_start')) {
// Start button clicked. We need to create a new uncompleted record with only the start time.
$cl_finish = null;
// Validate user input.
if ($request->getParameter('btn_start')) {
// Start button clicked. We need to create a new uncompleted record with only the start time.
$cl_finish = null;
// Validate user input.
- if (in_array('cl', explode(',', $user->plugins)) && in_array('cm', explode(',', $user->plugins)) && !$cl_client)
- $errors->add($i18n->getKey('error.client'));
+ if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client)
+ $err->add($i18n->get('error.client'));
- if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $errors->add($i18n->getKey('error.field'), $custom_fields->fields[0]['label']);
+ if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->get('error.field'), $custom_fields->fields[0]['label']);
$browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null));
if ($selected_date->after($browser_today))
$browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null));
if ($selected_date->after($browser_today))
- if ($errors->isEmpty() && $uncompleted) {
- $errors->add($i18n->getKey('error.uncompleted_exists')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->getKey('error.goto_uncompleted')."</a>");
+ if ($err->no() && $uncompleted) {
+ $err->add($i18n->get('error.uncompleted_exists')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
- if ($errors->isEmpty()) {
- if (ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $cl_start, $cl_finish))
- $errors->add($i18n->getKey('error.overlap'));
- }
-
- if ($errors->isEmpty()) {
+ if ($err->no()) {
+ if (ttTimeHelper::overlaps($user->getUser(), $cl_date, $cl_start, $cl_finish))
+ $err->add($i18n->get('error.overlap'));
+ }
+
+ if ($err->no()) {
- 'user_id' => $user->getActiveUser(),
+ 'user_id' => $user->getUser(),
+ 'group_id' => $user->getGroup(),
+ 'org_id' => $user->org_id,
'duration' => $cl_duration,
'note' => $cl_note,
'billable' => $cl_billable));
'duration' => $cl_duration,
'note' => $cl_note,
'billable' => $cl_billable));
// Insert a custom field if we have it.
$result = true;
if ($id && $custom_fields && $cl_cf_1) {
if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
$result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], null, $cl_cf_1);
// Insert a custom field if we have it.
$result = true;
if ($id && $custom_fields && $cl_cf_1) {
if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
$result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], null, $cl_cf_1);
$result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], $cl_cf_1, null);
}
$result = $custom_fields->insert($id, $custom_fields->fields[0]['id'], $cl_cf_1, null);
}
}
}
if ($request->getParameter('btn_stop')) {
// Stop button clicked. We need to finish an uncompleted record in progress.
}
}
if ($request->getParameter('btn_stop')) {
// Stop button clicked. We need to finish an uncompleted record in progress.
// Can we complete this record?
if (ttTimeHelper::isValidInterval($record['start'], $cl_finish) // finish time is greater than start time
// Can we complete this record?
if (ttTimeHelper::isValidInterval($record['start'], $cl_finish) // finish time is greater than start time
- && !ttTimeHelper::overlaps($user->getActiveUser(), $cl_date, $record['start'], $cl_finish)) { // no overlap
+ && !ttTimeHelper::overlaps($user->getUser(), $cl_date, $record['start'], $cl_finish)) { // no overlap
- 'id'=>$record['id'],
- 'date'=>$cl_date,
- 'user_id'=>$user->getActiveUser(),
- 'client'=>$record['client_id'],
- 'project'=>$record['project_id'],
- 'task'=>$record['task_id'],
- 'start'=>$record['start'],
+ 'id'=>$record['id'],
+ 'date'=>$cl_date,
+ 'user_id'=>$user->getUser(),
+ 'client'=>$record['client_id'],
+ 'project'=>$record['project_id'],
+ 'task'=>$record['task_id'],
+ 'start'=>$record['start'],
'finish'=>$cl_finish,
'note'=>$record['comment'],
'billable'=>$record['billable']));
'finish'=>$cl_finish,
'note'=>$record['comment'],
'billable'=>$record['billable']));
} else {
// Cannot complete, redirect for manual edit.
header('Location: time_edit.php?id='.$record['id']);
} else {
// Cannot complete, redirect for manual edit.
header('Location: time_edit.php?id='.$record['id']);
$smarty->assign('week_total', $week_total);
$smarty->assign('uncompleted', $uncompleted);
$smarty->assign('week_total', $week_total);
$smarty->assign('uncompleted', $uncompleted);
-$smarty->assign('time_records', ttTimeHelper::getRecords($user->getActiveUser(), $cl_date));
-$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getActiveUser(), $cl_date));
+$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date));
+$smarty->assign('day_total', ttTimeHelper::getTimeForDay($cl_date));
$smarty->assign('client_list', $client_list);
$smarty->assign('project_list', $project_list);
$smarty->assign('task_list', $task_list);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('onload', 'onLoad="fillDropdowns()"');
$smarty->assign('timestring', $selected_date->toString($user->date_format));
$smarty->assign('client_list', $client_list);
$smarty->assign('project_list', $project_list);
$smarty->assign('task_list', $task_list);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('onload', 'onLoad="fillDropdowns()"');
$smarty->assign('timestring', $selected_date->toString($user->date_format));
$smarty->assign('content_page_name', 'mobile/timer.tpl');
$smarty->display('mobile/index.tpl');
$smarty->assign('content_page_name', 'mobile/timer.tpl');
$smarty->display('mobile/index.tpl');