<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.14.4435 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.15.4436 | 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>
print "Updated $tt_expense_items_updated tt_expense_items records...<br>\n";
}
- if ($_POST["convert11797to11814"]) {
+ if ($_POST["convert11797to11815"]) {
setChange("ALTER TABLE `tt_fav_reports` CHANGE `group_by` `group_by1` varchar(20) default NULL");
setChange("ALTER TABLE `tt_fav_reports` ADD `group_by2` varchar(20) default NULL AFTER `group_by1`");
setChange("ALTER TABLE `tt_fav_reports` ADD `group_by3` varchar(20) default NULL AFTER `group_by2`");
setChange("ALTER TABLE `tt_invoices` MODIFY `name` varchar(80) COLLATE utf8mb4_bin NOT NULL");
setChange("ALTER TABLE `tt_clients` MODIFY `name` varchar(80) COLLATE utf8mb4_bin NOT NULL");
setChange("UPDATE `tt_site_config` SET param_value = '1.18.14', modified = now() where param_name = 'version_db' and param_value = '1.18.13'");
+ setChange("ALTER TABLE `tt_monthly_quotas` ADD `org_id` int(11) default NULL AFTER `group_id`");
+ setChange("UPDATE `tt_monthly_quotas` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.14') set org_id = group_id where org_id is null");
+ setChange("UPDATE `tt_site_config` SET param_value = '1.18.15', modified = now() where param_name = 'version_db' and param_value = '1.18.14'");
// TODO: this does not work as we just introduced group_id and it is NULL. Same for tt_project_task_binds. Improve.
// setChange("UPDATE `tt_user_project_binds` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.12') set org_id = group_id where org_id is null");
<h2>DB Install</h2>
<table width="80%" border="1" cellpadding="10" cellspacing="0">
<tr>
- <td width="80%"><b>Create database structure (v1.18.14)</b>
+ <td width="80%"><b>Create database structure (v1.18.15)</b>
<br>(applies only to new installations, do not execute when updating)</br></td><td><input type="submit" name="crstructure" value="Create"></td>
</tr>
</table>
</tr>
</tr>
<tr valign="top">
- <td>Update database structure (v1.17.97 to v1.18.14)</td>
- <td><input type="submit" name="convert11797to11814" value="Update"></td>
+ <td>Update database structure (v1.17.97 to v1.18.15)</td>
+ <td><input type="submit" name="convert11797to11815" value="Update"></td>
</tr>
</table>
#
CREATE TABLE `tt_monthly_quotas` (
`group_id` int(11) NOT NULL, # group id
+ `org_id` int(11) default NULL # organization id
`year` smallint(5) UNSIGNED NOT NULL, # quota year
`month` tinyint(3) UNSIGNED NOT NULL, # quota month
`minutes` int(11) default NULL, # quota in minutes in specified month and year
PRIMARY KEY (`param_name`)
);
-INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.18.14', now()); # TODO: change when structure changes.
+INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.18.15', now()); # TODO: change when structure changes.
var $db; // Database connection.
var $group_id; // Group id.
+ var $org_id; // Organization id.
function __construct() {
$this->db = getConnection();
global $user;
- $this->group_id = $user->group_id;
+ $this->group_id = $user->getActiveGroup();
+ $this->org_id = $user->org_id;
}
// update - deletes a quota, then inserts a new one.
public function update($year, $month, $minutes) {
- $group_id = $this->group_id;
- $deleteSql = "DELETE FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $group_id";
+ $deleteSql = "DELETE FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $this->group_id";
$this->db->exec($deleteSql);
if ($minutes){
- $insertSql = "INSERT INTO tt_monthly_quotas (group_id, year, month, minutes) values ($group_id, $year, $month, $minutes)";
+ $insertSql = "INSERT INTO tt_monthly_quotas (group_id, org_id, year, month, minutes)".
+ " values ($this->group_id, $this->org_id, $year, $month, $minutes)";
$affected = $this->db->exec($insertSql);
return (!is_a($affected, 'PEAR_Error'));
}
// getSingle - obtains a quota for a single month.
private function getSingle($year, $month) {
- $group_id = $this->group_id;
- $sql = "SELECT minutes FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $group_id";
+ $sql = "SELECT minutes FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $this->group_id";
$reader = $this->db->query($sql);
if (is_a($reader, 'PEAR_Error')) {
return false;
// getMany - returns an array of quotas for a given year for group.
private function getMany($year){
- $group_id = $this->group_id;
- $sql = "SELECT month, minutes FROM tt_monthly_quotas WHERE year = $year AND group_id = $group_id";
+ $sql = "SELECT month, minutes FROM tt_monthly_quotas WHERE year = $year AND group_id = $this->group_id";
$result = array();
$res = $this->db->query($sql);
if (is_a($res, 'PEAR_Error')) {