$exportHelper = new ttExportHelper();
if ($exportHelper->createDataFile($compress)) {
- header('Pragma: public'); // This is needed for IE8 to download files over https.
- header('Content-Type: '.$mime_type);
- header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
- header('Content-Disposition: attachment; filename="'.$filename.'"');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Cache-Control: private', false);
-
+ header('Pragma: public'); // This is needed for IE8 to download files over https.
+ header('Content-Type: '.$mime_type);
+ header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Cache-Control: private', false);
+
if ($file_pointer = fopen($exportHelper->getFileName(), 'r')) {
while ($data = fread($file_pointer, 4096)) {
- echo $data;
+ echo $data;
}
fclose($file_pointer);
unlink($exportHelper->getFileName());
}
else if ($user->isClient()) {
header('Location: reports.php');
- exit();
+ exit();
}
}
<?php
}
-?>
\ No newline at end of file
+?>
// If auth params are not defined (in config.php) - initialize with an empty array.
if (!isset($GLOBALS['AUTH_MODULE_PARAMS']) || !is_array($GLOBALS['AUTH_MODULE_PARAMS']))
$GLOBALS['AUTH_MODULE_PARAMS'] = array();
-
+
// Smarty initialization.
import('smarty.Smarty');
$smarty = new Smarty;
}
// Start or resume PHP session.
-session_name('tt_PHPSESSID'); // "tt_" prefix is to avoid sharing session with other PHP apps that do not name session.
+session_name('tt_PHPSESSID'); // "tt_" prefix is to avoid sharing session with other PHP apps that do not name session.
@session_start();
// Authorization.
if (!$lang) {
if (defined('LANG_DEFAULT'))
$lang = LANG_DEFAULT;
-
+
// If we still do not have the language get it from the browser.
if (!$lang) {
$lang = $i18n->getBrowserLanguage();
-
+
// Finally - English is the default.
if (!$lang) {
$lang = 'en';
$smarty->assign('errors', $errors);
$smarty->assign('messages', $messages);
-// TODO: move this code out of here to the files that use it.
-
+// TODO: move this code out of here to the files that use it.
+
// We use js/strftime.js to print dates in JavaScript (in DateField controls).
// One of our date formats (%d.%m.%Y %a) prints a localized short weekday name (%a).
// The init_js_date_locale function iniitializes Date.ext.locales array in js/strftime.js for our language
if ($errors->isEmpty()) {
if (ttInvoiceHelper::getInvoiceByName($cl_number))
$errors->add($i18n->getKey('error.invoice_exists'));
-
+
if (!ttInvoiceHelper::invoiceableItemsExist($fields))
- $errors->add($i18n->getKey('error.no_invoiceable_items'));
+ $errors->add($i18n->getKey('error.no_invoiceable_items'));
}
if ($errors->isEmpty()) {
- // Now we can go ahead and create our invoice.
+ // Now we can go ahead and create our invoice.
if (ttInvoiceHelper::createInvoice($fields)) {
header('Location: invoices.php');
exit();
}
- $errors->add($i18n->getKey('error.db'));
+ $errors->add($i18n->getKey('error.db'));
}
} // post
if (ttInvoiceHelper::getInvoice($cl_invoice_id)) {
if (ttInvoiceHelper::delete($cl_invoice_id, $request->getParameter('delete_invoice_entries'))) {
header('Location: invoices.php');
- exit();
+ exit();
} else
$errors->add($i18n->getKey('error.db'));
} else
if (!ttValidEmailList($cl_cc, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.cc'));
if (!ttValidString($cl_subject)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.subject'));
if (!ttValidString($cl_comment, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.comment'));
-
+
if ($errors->isEmpty()) {
// Save last invoice emails for future use.
$sc->setValue(SYSC_LAST_INVOICE_EMAIL, $cl_receiver);
- $sc->setValue(SYSC_LAST_INVOICE_CC, $cl_cc);
-
- $body = ttInvoiceHelper::prepareInvoiceBody($cl_invoice_id, $cl_comment);
-
+ $sc->setValue(SYSC_LAST_INVOICE_CC, $cl_cc);
+
+ $body = ttInvoiceHelper::prepareInvoiceBody($cl_invoice_id, $cl_comment);
+
import('mail.Mailer');
$mailer = new Mailer();
$mailer->setCharSet(CHARSET);
if ($tax_percent) {
$tax_expenses = in_array('et', explode(',', $user->plugins));
foreach($invoice_items as $item) {
- if ($item['type'] == 2 && !$tax_expenses)
- continue;
- $tax += round($item['cost'] * $tax_percent / 100, 2);
+ if ($item['type'] == 2 && !$tax_expenses)
+ continue;
+ $tax += round($item['cost'] * $tax_percent / 100, 2);
}
}
$total = $subtotal + $tax;
if ('.' != $user->decimal_mark) {
foreach ($invoice_items as &$item)
- $item['cost'] = str_replace('.', $user->decimal_mark, $item['cost']);
+ $item['cost'] = str_replace('.', $user->decimal_mark, $item['cost']);
}
// Calculate colspan for invoice summary.
// Validate user input.
if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login'));
if (!ttValidString($cl_password)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password'));
-
+
if ($errors->isEmpty()) {
- // Use the "limit" plugin if we have one. Ignore include errors.
+ // Use the "limit" plugin if we have one. Ignore include errors.
// The "limit" plugin is not required for normal operation of Time Tracker.
@include('plugins/limit/access_check.php');
-
+
if ($auth->doLogin($cl_login, $cl_password)) {
// Set current user date (as determined by user browser) into session.
$current_user_date = $request->getParameter('browser_today', null);
if ($current_user_date)
$_SESSION['date'] = $current_user_date;
-
+
// Remember user login in a cookie.
setcookie('tt_login', $cl_login, time() + COOKIE_EXPIRE, '/');
-
+
$user = new ttUser(null, $auth->getUserId());
// Redirect, depending on user role.
if ($user->isAdmin()) {
}
else if ($user->isClient()) {
header('Location: reports.php');
- exit();
+ exit();
}
else {
header('Location: time.php');
`name` varchar(80) COLLATE utf8_bin NOT NULL, # project name
`description` varchar(255) default NULL, # project description
`tasks` text default NULL, # comma-separated list of task ids associated with this project
- `status` tinyint(4) default '1', # project status
+ `status` tinyint(4) default '1', # project status
PRIMARY KEY (`id`)
);
# Structure for table tt_project_task_binds. This table maps projects to assigned tasks.
#
CREATE TABLE `tt_project_task_binds` (
- `project_id` int(11) NOT NULL, # project id
+ `project_id` int(11) NOT NULL, # project id
`task_id` int(11) NOT NULL # task id
);
`task_id` int(11) default NULL, # task id (if selected)
`billable` tinyint(4) default NULL, # whether to include billable, not billable, or all records
`invoice` tinyint(4) default NULL, # whether to include invoiced, not invoiced, or all records
- `users` text default NULL, # Comma-separated list of user ids. Nothing here means "all" users.
+ `users` text default NULL, # Comma-separated list of user ids. Nothing here means "all" users.
`period` tinyint(4) default NULL, # selected period type for report
`period_start` date default NULL, # period start
`period_end` date default NULL, # period end
`show_client` tinyint(4) NOT NULL default '0', # whether to show client column
- `show_invoice` tinyint(4) NOT NULL default '0', # whether to show invoice column
+ `show_invoice` tinyint(4) NOT NULL default '0', # whether to show invoice column
`show_project` tinyint(4) NOT NULL default '0', # whether to show project column
`show_start` tinyint(4) NOT NULL default '0', # whether to show start field
`show_duration` tinyint(4) NOT NULL default '0', # whether to show duration field
- `show_cost` tinyint(4) NOT NULL default '0', # whether to show cost field
+ `show_cost` tinyint(4) NOT NULL default '0', # whether to show cost field
`show_task` tinyint(4) NOT NULL default '0', # whether to show task column
`show_end` tinyint(4) NOT NULL default '0', # whether to show end field
`show_note` tinyint(4) NOT NULL default '0', # whether to show note column
#
CREATE TABLE `tt_custom_field_options` (
`id` int(11) NOT NULL auto_increment, # option id
- `field_id` int(11) NOT NULL, # custom field id
+ `field_id` int(11) NOT NULL, # custom field id
`value` varchar(32) NOT NULL default '', # option value
PRIMARY KEY (`id`)
);
if (!ttValidEmail($cl_email)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
if ($errors->isEmpty()) {
- // Calculate next execution time.
- $next = tdCron::getNextOccurrence($cl_cron_spec, mktime());
-
+ // Calculate next execution time.
+ $next = tdCron::getNextOccurrence($cl_cron_spec, mktime());
+
if (ttNotificationHelper::insert(array(
'team_id' => $user->team_id,
'cron_spec' => $cl_cron_spec,
header('Location: notifications.php');
exit();
} else
- $errors->add($i18n->getKey('error.db'));
+ $errors->add($i18n->getKey('error.db'));
}
-} // post
+} // POST
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
-// $smarty->assign('onload', 'onLoad="document.clientForm.name.focus()"');
$smarty->assign('title', $i18n->getKey('title.add_notification'));
$smarty->assign('content_page_name', 'notification_add.tpl');
$smarty->display('index.tpl');
if ($request->getMethod() == 'POST') {
if ($request->getParameter('btn_delete')) {
- if(ttNotificationHelper::get($cl_notification_id)) {
+ if(ttNotificationHelper::get($cl_notification_id)) {
if (ttNotificationHelper::delete($cl_notification_id)) {
header('Location: notifications.php');
exit();
} else
$errors->add($i18n->getKey('error.db'));
} else if ($request->getParameter('btn_cancel')) {
- header('Location: notifications.php');
- exit();
+ header('Location: notifications.php');
+ exit();
}
-} // post
-
+} // POST
+
$smarty->assign('notification_to_delete', $notification_to_delete);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('onload', 'onLoad="document.notificationDeleteForm.btn_cancel.focus()"');
'value'=>$cl_fav_report,
'data'=>$fav_reports,
'datakeys'=>array('id','name'),
- 'empty'=>array(''=>$i18n->getKey('dropdown.select'))
-));
+ 'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'cron_spec','style'=>'width: 250px;','value'=>$cl_cron_spec));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','style'=>'width: 250px;','value'=>$cl_email));
$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.save')));
if (!ttValidEmail($cl_email)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
if ($errors->isEmpty()) {
- // Calculate next execution time.
- $next = tdCron::getNextOccurrence($cl_cron_spec, mktime());
-
+ // Calculate next execution time.
+ $next = tdCron::getNextOccurrence($cl_cron_spec, mktime());
+
if (ttNotificationHelper::update(array(
'id' => $notification_id,
'team_id' => $user->team_id,
header('Location: notifications.php');
exit();
} else
- $errors->add($i18n->getKey('error.db'));
+ $errors->add($i18n->getKey('error.db'));
}
-} // post
+} // POST
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
-// $smarty->assign('onload', 'onLoad="document.clientForm.name.focus()"');
$smarty->assign('title', $i18n->getKey('title.add_notification'));
$smarty->assign('content_page_name', 'notification_edit.tpl');
$smarty->display('index.tpl');
if ($request->getMethod() == 'POST') {
if ($request->getParameter('btn_add')) {
- // The Add button clicked. Redirect to notification_add.php page.
- header('Location: notification_add.php');
- exit();
+ // The Add button clicked. Redirect to notification_add.php page.
+ header('Location: notification_add.php');
+ exit();
}
} else {
$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
$errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password'));
if ($errors->isEmpty()) {
- // Use the "limit" plugin if we have one. Ignore include errors.
+ // Use the "limit" plugin if we have one. Ignore include errors.
// The "limit" plugin is not required for normal operation of Time Tracker.
$cl_login = $user->login; // $cl_login is used in access_check.cpp.
@include('plugins/limit/access_check.php');
-
- ttUserHelper::setPassword($user_id, $cl_password1);
- if ($auth->doLogin($user->login, $cl_password1)) {
+ ttUserHelper::setPassword($user_id, $cl_password1);
+ if ($auth->doLogin($user->login, $cl_password1)) {
setcookie('tt_login', $user->login, time() + COOKIE_EXPIRE, '/');
header('Location: time.php');
exit();
if ($request->getMethod() == 'POST') {
$cl_login = $request->getParameter('login');
-
+
// Validate user input.
if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login'));
if ($errors->IsEmpty()) {
- if (!ttUserHelper::getUserByLogin($cl_login)) {
- // User with a specified login was not found.
- // In this case, if login looks like email, try finding user by email.
- if (ttValidEmail($cl_login)) {
+ if (!ttUserHelper::getUserByLogin($cl_login)) {
+ // User with a specified login was not found.
+ // In this case, if login looks like email, try finding user by email.
+ if (ttValidEmail($cl_login)) {
$login = ttUserHelper::getUserByEmail($cl_login);
if ($login)
$cl_login = $login;
$errors->add($i18n->getKey('error.no_login'));
} else
$errors->add($i18n->getKey('error.no_login'));
- }
+ }
}
-
- if ($errors->IsEmpty()) {
+
+ if ($errors->IsEmpty()) {
$user = new ttUser($cl_login); // Note: reusing $user from initialize.php here.
-
+
// Prepare and save a temporary reference for user.
$temp_ref = md5(uniqid());
ttUserHelper::saveTmpRef($temp_ref, $user->id);
$user_i18n = null;
if ($user->lang != $i18n->lang) {
$user_i18n = new I18n();
- $user_i18n->load($user->lang);
+ $user_i18n->load($user->lang);
} else
$user_i18n = &$i18n;
-
+
// Where do we email to?
$receiver = null;
if ($user->email)
else
$errors->add($i18n->getKey('error.no_email'));
}
-
+
if ($receiver) {
import('mail.Mailer');
$sender = new Mailer();
- $sender->setCharSet(CHARSET);
+ $sender->setCharSet(CHARSET);
$sender->setSender(SENDER);
$sender->setReceiver("$receiver");
if ((!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] !== 'off')) || ($_SERVER['SERVER_PORT'] == 443))
$cl_subject = $user_i18n->getKey('form.reset_password.email_subject');
if (APP_NAME)
- $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/'.APP_NAME.'/password_change.php?ref='.$temp_ref;
+ $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/'.APP_NAME.'/password_change.php?ref='.$temp_ref;
else
- $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/password_change.php?ref='.$temp_ref;
-
+ $pass_edit_url = $http.'://'.$_SERVER['HTTP_HOST'].'/password_change.php?ref='.$temp_ref;
+
$sender->setSendType(MAIL_MODE);
$res = $sender->send($cl_subject, sprintf($user_i18n->getKey('form.reset_password.email_body'), $pass_edit_url));
- $smarty->assign('result_message', $res ? $i18n->getKey('form.reset_password.message') : $i18n->getKey('error.mail_send'));
- }
+ $smarty->assign('result_message', $res ? $i18n->getKey('form.reset_password.message') : $i18n->getKey('error.mail_send'));
+ }
}
}