X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttExportHelper.class.php;h=7072f2b732c1e8a3b9f15b1eecd333863627b494;hb=a711e76851f29c7e0ac290a279eb4dd984ea7167;hp=c71b856da2288a67df3cccdac8efe9ec266eb49b;hpb=9494c6e4f474c5687d388b32c167f31cbe0aeb62;p=timetracker.git diff --git a/WEB-INF/lib/ttExportHelper.class.php b/WEB-INF/lib/ttExportHelper.class.php index c71b856d..7072f2b7 100644 --- a/WEB-INF/lib/ttExportHelper.class.php +++ b/WEB-INF/lib/ttExportHelper.class.php @@ -29,7 +29,7 @@ import('ttTeamHelper'); import('ttTimeHelper'); -// ttExportHelper - this class is used to export team data to a file. +// ttExportHelper - this class is used to export group data to a file. class ttExportHelper { var $fileName = null; // Name of the file with data. @@ -45,9 +45,10 @@ class ttExportHelper { var $customFieldOptionMap = array(); // Custop field option ids. var $logMap = array(); // Time log ids. - // createDataFile creates a file with all data for a given team. + // createDataFile creates a file with all data for a given group. function createDataFile($compress = false) { global $user; + $group_id = $user->getActiveGroup(); // Create a temporary file. $dirName = dirname(TEMPLATE_DIR . '_c/.'); @@ -59,18 +60,20 @@ class ttExportHelper { // Write XML to the file. fwrite($file, "\n"); - fwrite($file, "\n"); + fwrite($file, "\n"); - // Write team info. - fwrite($file, "currency."\" decimal_mark=\"".$user->decimal_mark."\" lang=\"".$user->lang. + // Write group info. + fwrite($file, "currency."\" decimal_mark=\"".$user->decimal_mark."\" lang=\"".$user->lang. "\" date_format=\"".$user->date_format."\" time_format=\"".$user->time_format."\" week_start=\"".$user->week_start. "\" tracking_mode=\"".$user->tracking_mode."\" project_required=\"".$user->project_required."\" task_required=\"".$user->task_required. "\" record_type=\"".$user->record_type."\" bcc_email=\"".$user->bcc_email. "\" plugins=\"".$user->plugins."\" lock_spec=\"".$user->lock_spec."\" workday_minutes=\"".$user->workday_minutes. "\" config=\"".$user->config. "\">\n"); - fwrite($file, " team."]]>\n"); - fwrite($file, "\n"); + fwrite($file, " group_name."]]>\n"); + fwrite($file, " allow_ip."]]>\n"); + fwrite($file, " password_complexity."]]>\n"); + fwrite($file, "\n"); // Prepare role map. $roles = $this->getRoles(); @@ -83,17 +86,17 @@ class ttExportHelper { $this->userMap[$user_item['id']] = $key + 1; // Prepare project map. - $projects = ttTeamHelper::getAllProjects($user->team_id, true); + $projects = ttTeamHelper::getAllProjects($group_id, true); foreach ($projects as $key=>$project_item) $this->projectMap[$project_item['id']] = $key + 1; // Prepare task map. - $tasks = ttTeamHelper::getAllTasks($user->team_id, true); + $tasks = ttTeamHelper::getAllTasks($group_id, true); foreach ($tasks as $key=>$task_item) $this->taskMap[$task_item['id']] = $key + 1; // Prepare client map. - $clients = ttTeamHelper::getAllClients($user->team_id, true); + $clients = ttTeamHelper::getAllClients($group_id, true); foreach ($clients as $key=>$client_item) $this->clientMap[$client_item['id']] = $key + 1; @@ -103,12 +106,12 @@ class ttExportHelper { $this->invoiceMap[$invoice_item['id']] = $key + 1; // Prepare custom fields map. - $custom_fields = ttTeamHelper::getAllCustomFields($user->team_id); + $custom_fields = ttTeamHelper::getAllCustomFields($group_id); foreach ($custom_fields as $key=>$custom_field) $this->customFieldMap[$custom_field['id']] = $key + 1; // Prepare custom field options map. - $custom_field_options = ttTeamHelper::getAllCustomFieldOptions($user->team_id); + $custom_field_options = ttTeamHelper::getAllCustomFieldOptions($group_id); foreach ($custom_field_options as $key=>$option) $this->customFieldOptionMap[$option['id']] = $key + 1; @@ -118,6 +121,7 @@ class ttExportHelper { fwrite($file, " roleMap[$role['id']]."\" rank=\"".$role['rank']."\"". " rights=\"".$role['rights']."\" status=\"".$role['status']."\">\n"); fwrite($file, " \n"); + fwrite($file, " \n"); fwrite($file, " \n"); } fwrite($file, "\n"); @@ -164,7 +168,7 @@ class ttExportHelper { // Write user to project binds. fwrite($file, "\n"); - $user_binds = ttTeamHelper::getUserToProjectBinds($user->team_id); + $user_binds = ttTeamHelper::getUserToProjectBinds($group_id); foreach ($user_binds as $bind) { $user_id = $this->userMap[$bind['user_id']]; $project_id = $this->projectMap[$bind['project_id']]; @@ -222,7 +226,7 @@ class ttExportHelper { unset($custom_field_options); // Write monthly quotas. - $quotas = ttTeamHelper::getMonthlyQuotas($user->team_id); + $quotas = ttTeamHelper::getMonthlyQuotas($group_id); fwrite($file, "\n"); foreach ($quotas as $quota) { fwrite($file, " \n"); @@ -237,7 +241,7 @@ class ttExportHelper { foreach ($records as $record) { $key++; $this->logMap[$record['id']] = $key; - fwrite($file, " userMap[$record['user_id']]."\" date=\"".$record['date']."\" start=\"".$record['start']."\" finish=\"".$record['finish']."\" duration=\"".($record['start']?"":$record['duration'])."\" client_id=\"".$this->clientMap[$record['client_id']]."\" project_id=\"".$this->projectMap[$record['project_id']]."\" task_id=\"".$this->taskMap[$record['task_id']]."\" invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\" billable=\"".$record['billable']."\" paid=\"".$record['paid']."\" status=\"".$record['status']."\">\n"); + fwrite($file, " userMap[$record['user_id']]."\" date=\"".$record['date']."\" start=\"".$record['start']."\" finish=\"".$record['finish']."\" duration=\"".($record['start']?"":$record['duration'])."\" client_id=\"".$this->clientMap[$record['client_id']]."\" project_id=\"".$this->projectMap[$record['project_id']]."\" task_id=\"".$this->taskMap[$record['task_id']]."\" invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\" billable=\"".$record['billable']."\" paid=\"".$record['paid']."\" status=\"".$record['status']."\">\n"); fwrite($file, " \n"); fwrite($file, " \n"); } @@ -246,7 +250,7 @@ class ttExportHelper { unset($records); // Write custom field log. - $custom_field_log = ttTeamHelper::getCustomFieldLog($user->team_id); + $custom_field_log = ttTeamHelper::getCustomFieldLog($group_id); fwrite($file, "\n"); foreach ($custom_field_log as $entry) { fwrite($file, " logMap[$entry['log_id']]."\" field_id=\"".$this->customFieldMap[$entry['field_id']]."\" option_id=\"".$this->customFieldOptionMap[$entry['option_id']]."\" status=\"".$entry['status']."\">\n"); @@ -257,7 +261,7 @@ class ttExportHelper { unset($custom_field_log); // Write expense items. - $expense_items = ttTeamHelper::getExpenseItems($user->team_id); + $expense_items = ttTeamHelper::getExpenseItems($group_id); fwrite($file, "\n"); foreach ($expense_items as $expense_item) { fwrite($file, " userMap[$expense_item['user_id']]."\" client_id=\"".$this->clientMap[$expense_item['client_id']]."\" project_id=\"".$this->projectMap[$expense_item['project_id']]."\" cost=\"".$expense_item['cost']."\" invoice_id=\"".$this->invoiceMap[$expense_item['invoice_id']]."\" paid=\"".$expense_item['paid']."\" status=\"".$expense_item['status']."\">\n"); @@ -269,7 +273,7 @@ class ttExportHelper { // Write fav reports. fwrite($file, "\n"); - $fav_reports = ttTeamHelper::getFavReports($user->team_id); + $fav_reports = ttTeamHelper::getFavReports($group_id); foreach ($fav_reports as $fav_report) { $user_list = ''; if (strlen($fav_report['users']) > 0) { @@ -291,6 +295,8 @@ class ttExportHelper { " period_end=\"".$fav_report['period_end']."\"". " show_client=\"".$fav_report['show_client']."\"". " show_invoice=\"".$fav_report['show_invoice']."\"". + " show_paid=\"".$fav_report['show_paid']."\"". + " show_ip=\"".$fav_report['show_ip']."\"". " show_project=\"".$fav_report['show_project']."\"". " show_start=\"".$fav_report['show_start']."\"". " show_duration=\"".$fav_report['show_duration']."\"". @@ -299,7 +305,10 @@ class ttExportHelper { " show_end=\"".$fav_report['show_end']."\"". " show_note=\"".$fav_report['show_note']."\"". " show_custom_field_1=\"".$fav_report['show_custom_field_1']."\"". - " group_by=\"".$fav_report['group_by']."\"". + " show_work_units=\"".$fav_report['show_work_units']."\"". + " group_by1=\"".$fav_report['group_by1']."\"". + " group_by2=\"".$fav_report['group_by2']."\"". + " group_by3=\"".$fav_report['group_by3']."\"". " show_totals_only=\"".$fav_report['show_totals_only']."\">\n"); fwrite($file, " \n"); fwrite($file, " \n"); @@ -314,7 +323,7 @@ class ttExportHelper { $this->projectMap = array(); $this->taskMap = array(); - fwrite($file, "\n"); + fwrite($file, "\n"); fclose($file); if ($compress) { @@ -358,16 +367,14 @@ class ttExportHelper { /* * Note about the utility functions below. - * We have roughly 3 groups of operations: + * We have roughly 4 groups of operations: * 1) Regular system usage for tracking time, etc. - * 2) Admin usage - used infrequently. - * 3) Export - used infrequently. - * - * TODO: we also have user registration process without initialized user. - * Perhaps we need a separate helper class for this. Think about it. + * 2) Registration process - used infrequently. + * 3) Admin usage - used infrequently. + * 4) Export - used infrequently. * * It is tempting to have a generic function to get things done for - * all situations. However, as export and admin access are one-off + * all situations. However, as registration, export and admin access are one-off * operations, while regular system usage is daily and must be efficient, * the current approach is to have SEPARATE functions for each mode. * @@ -375,13 +382,13 @@ class ttExportHelper { * and we don't want to over-complicate things. */ - // getRoles - obtains all roles defined for team. + // getRoles - obtains all roles defined for group. function getRoles() { global $user; $mdb2 = getConnection(); $result = array(); - $sql = "select * from tt_roles where team_id = $user->team_id"; + $sql = "select * from tt_roles where group_id = ".$user->getActiveGroup(); $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) { @@ -393,12 +400,13 @@ class ttExportHelper { return false; } - // The getUsers obtains all users in team for the purpose of export. + // The getUsers obtains all users in group for the purpose of export. function getUsers() { global $user; $mdb2 = getConnection(); - $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id order by upper(u.name)"; // Note: deleted users are included. + $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = ". + $user->getActiveGroup()." order by upper(u.name)"; // Note: deleted users are included. $res = $mdb2->query($sql); $result = array(); if (!is_a($res, 'PEAR_Error')) {