fwrite($file, "<pack>\n");
// Write team info.
- fwrite($file, "<team currency=\"".$user->currency."\" lock_spec=\"".$user->lock_spec."\" lang=\"".$user->lang."\" decimal_mark=\"".$user->decimal_mark."\" date_format=\"".$user->date_format."\" time_format=\"".$user->time_format."\" week_start=\"".$user->week_start.
+ fwrite($file, "<team currency=\"".$user->currency."\" lock_spec=\"".$user->lock_spec."\" lang=\"".$user->lang.
+ "\" decimal_mark=\"".$user->decimal_mark."\" date_format=\"".$user->date_format."\" time_format=\"".$user->time_format.
+ "\" week_start=\"".$user->week_start."\" workday_hours=\"".$user->workday_hours.
"\" plugins=\"".$user->plugins."\" tracking_mode=\"".$user->tracking_mode."\" record_type=\"".$user->record_type."\">\n");
fwrite($file, " <name><![CDATA[".$user->team."]]></name>\n");
fwrite($file, " <address><![CDATA[".$user->address."]]></address>\n");
fwrite($file, "</custom_field_options>\n");
unset($custom_field_options);
+ // Write monthly quotas.
+ $quotas = ttTeamHelper::getMonthlyQuotas($user->team_id);
+ fwrite($file, "<monthly_quotas>\n");
+ foreach ($quotas as $quota) {
+ fwrite($file, " <monthly_quota year=\"".$quota['year']."\" month=\"".$quota['month']."\" quota=\"".$quota['quota']."\"/>\n");
+ }
+ fwrite($file, "</monthly_quotas>\n");
+
// Write time log entries.
fwrite($file, "<log>\n");
$key = 0;
return false;
}
+ // getNotifications - obtains monthly quotas for team.
+ static function getMonthlyQuotas($team_id) {
+ $mdb2 = getConnection();
+
+ $result = array();
+ $sql = "select year, month, quota from tt_monthly_quotas where team_id = $team_id";
+ $res = $mdb2->query($sql);
+ $result = array();
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ $result[] = $val;
+ }
+ return $result;
+ }
+ return false;
+ }
+
// The getTeams function returns an array of all active teams on the server.
static function getTeams() {
$result = array();
var $custom_logo = 0; // Whether to use a custom logo for team.
var $address = null; // Address for invoices.
var $lock_spec = null; // Cron specification for record locking.
+ var $workday_hours = 8; // Number of work hours in a regular day.
var $rights = 0; // A mask of user rights.
// Constructor.
$sql = "SELECT u.id, u.login, u.name, u.team_id, u.role, u.client_id, u.email, t.name as team_name,
t.address, t.currency, t.lang, t.decimal_mark, t.date_format, t.time_format, t.week_start,
- t.tracking_mode, t.record_type, t.plugins, t.lock_spec, t.custom_logo
+ t.tracking_mode, t.record_type, t.plugins, t.lock_spec, t.workday_hours, t.custom_logo
FROM tt_users u LEFT JOIN tt_teams t ON (u.team_id = t.id) WHERE ";
if ($id)
$sql .= "u.id = $id";
$this->currency = $val['currency'];
$this->plugins = $val['plugins'];
$this->lock_spec = $val['lock_spec'];
+ $this->workday_hours = $val['workday_hours'];
$this->custom_logo = $val['custom_logo'];
// Set "on behalf" id and name.
return $this->getSingle($year, $month);
}
- // getWorkdayHours - obtains workday_hours value for a team from the database.
- public function getWorkdayHours(){
- $teamId = $this->team_id;
- $sql = "SELECT workday_hours FROM tt_teams where id = $teamId";
- $reader = $this->db->query($sql);
- if (is_a($reader, 'PEAR_Error')) {
- return false;
- }
-
- $row = $reader->fetchRow();
- return $row['workday_hours'];
- }
-
// getSingle - obtains a quota for a single month.
private function getSingle($year, $month) {
$teamId = $this->team_id;
// If we did not find a record, return a calculated monthly quota.
$numWorkdays = $this->getNumWorkdays($month, $year);
- return $numWorkdays * $this->getWorkdayHours();
+ global $user;
+ return $numWorkdays * $user->workday_hours;
}
// getMany - returns an array of quotas for a given year for team.
$monthsData = $quota->get($selectedYear);
$form = new Form('monthlyQuotasForm');
-$form->addInput(array('type'=>'text', 'name'=>'workdayHours', 'value'=>$quota->getWorkdayHours(), 'style'=>'width:50px'));
+$form->addInput(array('type'=>'text', 'name'=>'workdayHours', 'value'=>$user->workday_hours, 'style'=>'width:50px'));
$form->addInput(array('type'=>'combobox','name'=>'year','data'=>$years,'datakeys'=>array('id','name'),'value'=>$selectedYear,'onchange'=>'yearChange(this.value);'));
for ($i=0; $i < count($months); $i++) {
$value = "";