<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.9.16.3427 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.9.16.3428 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
$time_rec['comment'] = htmlspecialchars($time_rec['comment']);
if ($request->getMethod() == 'POST') {
- if ($request->getParameter('delete_button')) { // Delete button pressed.
+ if ($request->getParameter('delete_button')) { // Delete button pressed.
// Determine if it's okay to delete the record.
$item_date = new DateAndTime(DB_DATEFORMAT, $time_rec['date']);
// Report settings are stored in session bean before we get here.
$bean = new ActionForm('reportBean', new Form('reportForm'), $request);
-// At the moment, we distinguish 2 types of export to file:
-// 1) export to xml
-// 2) export to csv
+// This file handles 2 types of export to a file:
+// 1) xml
+// 2) csv
+// Export to pdf is handled separately in topdf.php.
$type = $request->getParameter('type');
// Also, there are 2 variations of report: totals only, or normal. Totals only means that the report
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Cache-Control: private', false);
-
+
// Handle 2 cases of possible exports individually.
// 1) entries exported to xml
if ('xml' == $type) {
header('Content-Type: application/xml');
header('Content-Disposition: attachment; filename="timesheet.xml"');
-
+
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print "<rows>\n";
-
+
$group_by = $bean->getAttribute('group_by');
if ($totals_only) {
// Totals only report. Print subtotals.
print "\t<duration><![CDATA[".$val."]]></duration>\n";
}
if ($bean->getAttribute('chcost')) {
- print "\t<cost><![CDATA[";
- if ($user->canManageTeam() || $user->isClient())
- print $subtotal['cost'];
- else
- print $subtotal['expenses'];
- print "]]></cost>\n";
+ print "\t<cost><![CDATA[";
+ if ($user->canManageTeam() || $user->isClient())
+ print $subtotal['cost'];
+ else
+ print $subtotal['expenses'];
+ print "]]></cost>\n";
}
print "</row>\n";
}
} else {
// Normal report.
- foreach ($items as $item) {
+ foreach ($items as $item) {
print "<row>\n";
print "\t<date><![CDATA[".$item['date']."]]></date>\n";
if ($bean->getAttribute('chstart')) print "\t<start><![CDATA[".$item['start']."]]></start>\n";
if ($bean->getAttribute('chfinish')) print "\t<finish><![CDATA[".$item['finish']."]]></finish>\n";
if ($bean->getAttribute('chduration')) {
- $duration = $item['duration'];
+ $duration = $item['duration'];
if($duration && defined('EXPORT_DECIMAL_DURATION') && isTrue(EXPORT_DECIMAL_DURATION))
$duration = time_to_decimal($duration);
print "\t<duration><![CDATA[".$duration."]]></duration>\n";
}
if ($bean->getAttribute('chnote')) print "\t<note><![CDATA[".$item['note']."]]></note>\n";
if ($bean->getAttribute('chcost')) {
- print "\t<cost><![CDATA[";
- if ($user->canManageTeam() || $user->isClient())
- print $item['cost'];
- else
- print $item['expense'];
- print "]]></cost>\n";
+ print "\t<cost><![CDATA[";
+ if ($user->canManageTeam() || $user->isClient())
+ print $item['cost'];
+ else
+ print $item['expense'];
+ print "]]></cost>\n";
}
if ($bean->getAttribute('chinvoice')) print "\t<invoice><![CDATA[".$item['invoice']."]]></invoice>\n";
print "</row>\n";
- }
+ }
}
-
+
print "</rows>";
-}
+}
// 2) entries exported to csv
if ('csv' == $type) {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="timesheet.csv"');
-
+
// Print UTF8 BOM first to identify encoding.
$bom = chr(239).chr(187).chr(191); // 0xEF 0xBB 0xBF in the beginning of the file is UTF8 BOM.
print $bom; // Without this Excel does not display UTF8 characters properly.
$group_by = $bean->getAttribute('group_by');
if ($totals_only) {
// Totals only report.
-
- // Determine group_by header.
+
+ // Determine group_by header.
if ('cf_1' == $group_by)
$group_by_header = $custom_fields->fields[0]['label'];
else {
if ($bean->getAttribute('chduration')) print ',"'.$i18n->getKey('label.duration').'"';
if ($bean->getAttribute('chcost')) print ',"'.$i18n->getKey('label.cost').'"';
print "\n";
-
+
// Print subtotals.
foreach ($subtotals as $subtotal) {
print '"'.$subtotal['name'].'"';
if ($bean->getAttribute('chduration')) {
$val = $subtotal['time'];
- if($val && defined('EXPORT_DECIMAL_DURATION') && isTrue(EXPORT_DECIMAL_DURATION))
+ if($val && defined('EXPORT_DECIMAL_DURATION') && isTrue(EXPORT_DECIMAL_DURATION))
$val = time_to_decimal($val);
- print ',"'.$val.'"';
+ print ',"'.$val.'"';
}
if ($bean->getAttribute('chcost')) {
- if ($user->canManageTeam() || $user->isClient())
+ if ($user->canManageTeam() || $user->isClient())
print ',"'.$subtotal['cost'].'"';
else
print ',"'.$subtotal['expenses'].'"';
}
if ($bean->getAttribute('chnote')) print ',"'.str_replace('"','""',$item['note']).'"';
if ($bean->getAttribute('chcost')) {
- if ($user->canManageTeam() || $user->isClient())
- print ',"'.$item['cost'].'"';
- else
- print ',"'.$item['expense'].'"';
+ if ($user->canManageTeam() || $user->isClient())
+ print ',"'.$item['cost'].'"';
+ else
+ print ',"'.$item['expense'].'"';
}
if ($bean->getAttribute('chinvoice')) print ',"'.str_replace('"','""',$item['invoice']).'"';
print "\n";
if ($bean->getAttribute('chinvoice')) { $colspan++; $html .= '<td>'.$i18n->getKey('label.invoice').'</td>'; }
$html .= '</tr>';
$html .= '</thead>';
-
+
foreach ($items as $item) {
// Print a subtotal for a block of grouped values.
$cur_date = $item['date'];
}
if ($bean->getAttribute('chinvoice')) $html .= '<td>'.htmlspecialchars($item['invoice']).'</td>';
$html .= '</tr>';
-
+
$prev_date = $item['date'];
if ($print_subtotals) $prev_grouped_by = $item['grouped_by'];
}
-
+
// Print a terminating subtotal.
if ($print_subtotals) {
$html .= '<tr style="background-color:#e0e0e0;">';
if ($bean->getAttribute('chinvoice')) $html .= '<td></td>';
$html .= '</tr>';
}
-
+
// Print totals.
$html .= '<tr><td colspan="'.$colspan.'"> </td></tr>';
$html .= '<tr style="background-color:#e0e0e0;">';
if ($user->canManageTeam() || $user->isClient())
$html .= $totals['cost'];
else
- $html .= $totals['expenses'];
+ $html .= $totals['expenses'];
$html .= '</td>';
}
if ($bean->getAttribute('chinvoice')) $html .= '<td></td>';
public $image_file = 'images/tt_logo.png'; // Image file for the logo in header.
public $page_word = 'Page'; // Localized "Page" word in footer, ex: Page 1/2.
-
+
// SetImageFile - sets image file name.
public function SetImageFile($imgFile) {
$this->image_file = $imgFile;
}
-
+
// SetPageWord - sets page word for footer.
public function SetPageWord($pageWord) {
$this->page_word = $pageWord;
}
-
+
// Page header.
public function Header() {
// Print logo, which is the only element of our custom header.
if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name'));
if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login'));
if (!$auth->isPasswordExternal()) {
- if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
- if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
+ if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
+ if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
if ($cl_password1 !== $cl_password2)
$errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
- }
+ }
if (!ttValidEmail($cl_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
if (!ttValidFloat($cl_rate, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.users.default_rate'));
} else
$errors->add($i18n->getKey('error.user_exists'));
}
-} // post
+} // POST
$smarty->assign('auth_external', $auth->isPasswordExternal());
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
if ($ok_to_go && $user->isCoManager() && (ROLE_COMANAGER == $user_details['role']))
$ok_to_go = ($user->id == $user_details['id']); // Comanager is not allowed to delete other comanagers.
if ($ok_to_go && $user->isCoManager() && (ROLE_MANAGER == $user_details['role']))
- $ok_to_go = false; // Comanager is not allowed to delete a manager.
+ $ok_to_go = false; // Comanager is not allowed to delete a manager.
if (!$ok_to_go)
die ($i18n->getKey('error.sys'));
else
- $smarty->assign('user_to_delete', $user_details['name']." (".$user_details['login'].")");
+ $smarty->assign('user_to_delete', $user_details['name']." (".$user_details['login'].")");
// Create confirmation form.
$form = new Form('userDeleteForm');
$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$user_id));
$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete')));
$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel')));
-
+
if ($request->getMethod() == 'POST') {
if ($request->getParameter('btn_delete')) {
if (ttUserHelper::markDeleted($user_id)) {
}
// If we deleted our own account, do housekeeping and logout.
if ($user->id == $user_id) {
- // Remove tt_login cookie that stores login name.
- unset($_COOKIE['tt_login']);
- setcookie('tt_login', NULL, -1);
-
+ // Remove tt_login cookie that stores login name.
+ unset($_COOKIE['tt_login']);
+ setcookie('tt_login', NULL, -1);
+
$auth->doLogout();
header('Location: login.php');
} else {
- header('Location: users.php');
+ header('Location: users.php');
}
exit();
} else {
header('Location: users.php');
exit();
}
-}
+} // POST
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('title', $i18n->getKey('title.delete_user'));
$cl_email = trim($request->getParameter('email'));
$cl_role = $request->getParameter('role');
$cl_client_id = $request->getParameter('client');
- $cl_status = $request->getParameter('status');
+ $cl_status = $request->getParameter('status');
$cl_rate = $request->getParameter('rate');
$cl_projects = $request->getParameter('projects');
if (is_array($cl_projects)) {
if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name'));
if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login'));
if (!$auth->isPasswordExternal() && ($cl_password1 || $cl_password2)) {
- if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
- if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
+ if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
+ if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password'));
if ($cl_password1 !== $cl_password2)
$errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
- }
+ }
if (!ttValidEmail($cl_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
if (!ttValidFloat($cl_rate, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.users.default_rate'));
'rate' => $cl_rate,
'projects' => $assigned_projects);
if (right_assign_roles & $user->rights) {
- $fields['role'] = $cl_role;
- $fields['client_id'] = $cl_client_id;
+ $fields['role'] = $cl_role;
+ $fields['client_id'] = $cl_client_id;
}
if (ttUserHelper::update($user_id, $fields)) {
if (($user_id == $user->id) && ($user->login != $cl_login)) {
setcookie('tt_login', $cl_login, time() + COOKIE_EXPIRE, '/');
}
-
+
// In case the name of the "on behalf" user has changed - set it in session.
if (($user->behalf_id == $user_id) && ($user->behalf_name != $cl_name)) {
$_SESSION['behalf_name'] = $cl_name;
}
-
+
// If we deactivated our own account, do housekeeping and logout.
if ($user->id == $user_id && !is_null($cl_status) && $cl_status == INACTIVE) {
- // Remove tt_login cookie that stores login name.
- unset($_COOKIE['tt_login']);
- setcookie('tt_login', NULL, -1);
-
+ // Remove tt_login cookie that stores login name.
+ unset($_COOKIE['tt_login']);
+ setcookie('tt_login', NULL, -1);
+
$auth->doLogout();
header('Location: login.php');
exit();
}
-
+
header('Location: users.php');
exit();
} else
$errors->add($i18n->getKey('error.user_exists'));
}
-} // post
+} // POST
$rates = ttProjectHelper::getRates($user_id);
$smarty->assign('rates', $rates);