]> wagnertech.de Git - timetracker.git/commitdiff
updated according to comments from anuko
authorAnže Videnič <anze.videnic@gmail.com>
Mon, 4 Jul 2016 09:28:13 +0000 (11:28 +0200)
committerAnže Videnič <anze.videnic@gmail.com>
Mon, 4 Jul 2016 09:28:13 +0000 (11:28 +0200)
22 files changed:
WEB-INF/config.php.dist
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/resources/de.lang.php
WEB-INF/resources/en.lang.php
WEB-INF/resources/es.lang.php
WEB-INF/resources/fa.lang.php
WEB-INF/resources/fi.lang.php
WEB-INF/resources/fr.lang.php
WEB-INF/resources/he.lang.php
WEB-INF/resources/nl.lang.php
WEB-INF/resources/pl.lang.php
WEB-INF/resources/pt-br.lang.php
WEB-INF/resources/ru.lang.php
WEB-INF/resources/sk.lang.php
WEB-INF/resources/sr.lang.php
WEB-INF/templates/cf_monthly_quota.tpl
WEB-INF/templates/reports.tpl
cf_monthly_quota.php
dbinstall.php [changed mode: 0644->0755]
default.css
mysql.sql
plugins/MonthlyQuota.class.php

index b52e0d809ccb198e98d36079513cc75ebc5f98a7..5afca00d28d72fd1ac8ac01189dee6d4e8830fc9 100644 (file)
@@ -214,3 +214,7 @@ define('AUTH_MODULE', 'db');
 //  'member_of' => array());            // List of groups, membership in which is required for user to be authenticated.
 
 // define('AUTH_DEBUG', false); // Note: enabling AUTH_DEBUG breaks redirects as debug output is printed before setting redirect header. Do not enable on production systems.
+
+// team manager can set monthly quota for years between these values:
+define('MONTHLY_QUOTA_YEARS_START', 2010); // if nothing is specified, it falls back to 2010
+define('MONTHLY_QUOTA_YEARS_END', 2031); // if nothing is specified it falls back to 2030
index ed4c5195acc8f4c4c8a98e2741fd74396f438231..186f7a1e55fcd061a798b8ed4d919133daa3679d 100644 (file)
@@ -703,7 +703,7 @@ class ttTeamHelper {
   static function update($team_id, $fields)
   {
     // We'll require team name to be always set.
-    if (!isset($fields['name'])) return false;
+    if (!isset($fields['name']) || $fields['name'] == "") return false;
 
     $mdb2 = getConnection();
     $name_part = 'name = '.$mdb2->quote($fields['name']);
@@ -718,6 +718,7 @@ class ttTeamHelper {
     $record_type_part = '';
     $plugins_part = '';
     $lock_spec_part = '';
+    $working_hours_part = '';
 
     if (isset($fields['address'])) $addr_part = ', address = '.$mdb2->quote($fields['address']);
     if (isset($fields['currency'])) $currency_part = ', currency = '.$mdb2->quote($fields['currency']);
@@ -730,10 +731,11 @@ class ttTeamHelper {
     if (isset($fields['record_type'])) $record_type_part = ', record_type = '.intval($fields['record_type']);
     if (isset($fields['plugins'])) $plugins_part = ', plugins = '.$mdb2->quote($fields['plugins']);
     if (isset($fields['lock_spec'])) $lock_spec_part = ', lock_spec = '.$mdb2->quote($fields['lock_spec']);
+    if (isset($fields['working_hours'])) $working_hours_part = ', daily_working_hours = '.$mdb2->quote($fields['working_hours']);
 
     $sql = "update tt_teams set $name_part $addr_part $currency_part $lang_part $decimal_mark_part
       $date_format_part $time_format_part $week_start_part $tracking_mode_part $record_type_part
-      $plugins_part $lock_spec_part where id = $team_id";
+      $plugins_part $lock_spec_part $working_hours_part where id = $team_id";
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error')) return false;
 
index 24f18b6e42ab10cc20125f5d325a4c7e8c443b65..ae05e9f7532eec0600cfa1761ddf7b634186f2f6 100644 (file)
@@ -203,6 +203,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Anmelden',
index f540a932a127a4e960d89baab57113ff813e903d..f82e543273109bdb913fb7c6d0a144f9afb1b661 100644 (file)
@@ -199,6 +199,8 @@ $i18n_key_words = array(
 'label.year' => 'Year',
 'label.month' => 'Month',
 'label.quota' => 'Quota',
+'label.dailyWorkingHours' => 'Daily working hours',
+'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Login',
index dfdaba3798771e7da543bf05b07f7ffbcd239032..3f1696e515bd5b58609d6ed1d8258f3e6f22e427 100644 (file)
@@ -234,6 +234,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Sesión iniciada',
index d63ec4f98f022032ba93f8e7846eff03436e2de4..acdb8f06f1a3c9d28d4a3a2ed065d5e7e6566e7f 100644 (file)
@@ -211,6 +211,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'ورود',
index d94c3c6949c9291d4008c409138e3a01231ee297..ee94cad00de9989e3bad0302f0092004be800b67 100644 (file)
@@ -197,6 +197,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Kirjautuminen',
index e9e71fd1c016edc9ead432eff7fec7269bdc6ed1..ee899fa2a518f97e2be050f6d06f1d2eb259dac6 100644 (file)
@@ -216,6 +216,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Connexion',
index e3ef87ad6ea0ec00760e39b12a304e796840c2b3..ce02dba807b6e066d7fbd8558a93924bd55800a8 100644 (file)
@@ -216,6 +216,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'כניסה',
index 167bb29ac408048f60b1cd6004f01cb7b2d1a21e..b2ad9bf8aae8d1a8369c2de41dc0272eb6d479e9 100644 (file)
@@ -198,6 +198,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Aanmelden',
index 59257b16d2fa294786ef101e32cba9ae8fa7fc1f..35a53557523b36e5d2e2212bcec1f6c48db7e6b0 100644 (file)
@@ -203,6 +203,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Logowanie',
index f52a9df3b8271d97c58789f9b175f8e14e30f160..021c1386972454a1518c91eb2df2ae9fae4d3ec5 100644 (file)
@@ -197,6 +197,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Login',
index 932f0a9ac88d152ab120e66cd82d09fa1be0bab1..0c99c07185f4302c0b021f42ecd5d28687b2d68a 100644 (file)
@@ -199,6 +199,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Вход в систему',
index 6ee28baab8b376bd9b844be46ce2517bab118f18..c8479ad4d3c85b846b1ed77739cae6a2ff0b3d57 100644 (file)
@@ -213,6 +213,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Prihlásenie',
index b24a57b9f55bf4d3dc2e2a504341a2f16254796b..546515b788bffcb9c3b703e7c473df1474aa3364 100644 (file)
@@ -199,6 +199,8 @@ $i18n_key_words = array(
 // 'label.year' => 'Year',
 // 'label.month' => 'Month',
 // 'label.quota' => 'Quota',
+// 'label.dailyWorkingHours' => 'Daily working hours',
+// 'label.empty_values_explanation' => 'If values are empty, quotas are calculated automatically based on holidays in config',
 
 // Form titles.
 'title.login' => 'Prijava',
index 8243eb1daf5ba5ec2cba030cfe20597102ac102d..6e3d9feebce114019e9ef6643c5ad6e001ca45b7 100644 (file)
@@ -1,7 +1,22 @@
 {$forms.monthlyQuotaForm.open}
+<div style="padding: 0 0 10 0">
+    <table border="0" class="divider">
+        <tr>
+            <td align="center">
+                <table>
+                    <tr>
+                        <td>{$i18n.label.dailyWorkingHours}</td>
+                        <td>{$forms.monthlyQuotaForm.dailyWorkingHours.control}</td>
+                        <td><input type="submit" name="dailyHours" value="{$i18n.button.save}"></td>
+                    </tr>
+                </table>
+            </td>
+        </tr>        
+    </table>
+</div>
 <table>
     <tr>
-        <td>{$i18n.label.year}</td>
+        <td>{$i18n.label.year}:</td>
         <td>{$forms.monthlyQuotaForm.years.control}</td>
     </tr>
     <tr>
                     <td>{$month}</td>
                     <td>{$forms.monthlyQuotaForm.$month.control}</td>
                 </tr>
- {/foreach}         
+ {/foreach}     
                 <tr>
                     <td colspan="2" style="text-align:center;">
-                        <input type="submit" value="{$i18n.button.save}">
+                        <input type="submit" name="quotas" value="{$i18n.button.save}*">
                     </td>
                 </tr>
             </table>
         </td>
     </tr>
 </table>
+<div>* - {$i18n.label.empty_values_explanation}</div>
 {$forms.monthlyQuotaForm.close}
 <script>
 function yearChange(value){
index bd5ab3f48e83265bde4e80ff86f7c79fcbce5532..ce804dc575fcdb601ce10cba3b7e6902a8f15257 100644 (file)
@@ -149,7 +149,7 @@ function handleCheckboxes() {
 
 {$forms.reportForm.open}
 <div style="padding: 0 0 10 0;">
-  <table border="0" bgcolor="#efefef" width="720">
+  <table border="0" class="divider">
     <tr>
       <td>
         <table cellspacing="1" cellpadding="3" border="0">
@@ -278,7 +278,7 @@ function handleCheckboxes() {
       </table>
 
 <div style="padding: 10 0 10 0;">
-  <table border="0" bgcolor="#efefef" width="720">
+  <table border="0" class="divider">
     <tr>
       <td align="center">
         <table cellspacing="1" cellpadding="3" border="0">
index 14d0f3fbcc03f84cea86c549e4ffdba5a15fdd7e..19b43bf6d9da4c86825886bdcd3974ff5c9cc0bf 100644 (file)
@@ -3,6 +3,7 @@
 require_once('initialize.php');
 require_once('plugins/MonthlyQuota.class.php');
 import('form.Form');
+import('WEB-INF/lib/ttTeamHelper');
 
 // Access check.
 if (!ttAccessCheck(right_manage_team)) {
@@ -10,41 +11,67 @@ if (!ttAccessCheck(right_manage_team)) {
   exit();
 }
 
-$form = new Form('monthlyQuotaForm');
-// months are zero indexed
-$months = $i18n->monthNames;
+// fallback values
+$yearStart = 2010;
+$yearEnd = 2030;
+
+if (defined('MONTHLY_QUOTA_YEARS_START')){
+  $yearStart = (int)MONTHLY_QUOTA_YEARS_START;
+}
+if (defined('MONTHLY_QUOTA_YEARS_END')){
+  $yearEnd = (int)MONTHLY_QUOTA_YEARS_END;
+}
+
+// create values for dropdown
 $years = array();
-for ($i=1990; $i < 2040; $i++) { 
+for ($i=$yearStart; $i < $yearEnd; $i++) { 
   array_push($years, array('id'=>$i, 'name'=>$i));
 }
 
-$year = $request->getParameter("year");
-if (!$year or !ttValidInteger($year)){
-  $year = date("Y");
-}else {
-  $year = intval($year);
+// get selected year from url parameters
+$selectedYear = $request->getParameter("year");
+if (!$selectedYear or !ttValidInteger($selectedYear)){
+  $selectedYear = date("Y");
+} else {
+  $selectedYear = intval($selectedYear);
 }
 
+// months are zero indexed
+$months = $i18n->monthNames;
+
 $quota = new MonthlyQuota();
 
 if ($request->isPost()){
-  $postedYear = $request->getParameter("years");
-  $year = intval($postedYear);
   $res = false;
-  for ($i=0; $i < count($months); $i++){
-    $res = $quota->update($postedYear, $i+1, $request->getParameter($months[$i]));
+  // if user pressed save fpr monthly quotas
+  if ($_POST["quotas"]){
+    $postedYear = $request->getParameter("years");
+    $selectedYear = intval($postedYear);
+    for ($i=0; $i < count($months); $i++){
+      $res = $quota->update($postedYear, $i+1, $request->getParameter($months[$i]));
+    }
+  }
+  // if user saved required working hours for a day
+  if ($_POST["dailyHours"]){
+    $hours = $request->getParameter("dailyWorkingHours");
+    $teamDetails = ttTeamHelper::getTeamDetails($quota->usersTeamId);
+    $res = ttTeamHelper::update($quota->usersTeamId, array('name'=>$teamDetails['team_name'], 
+                                                           'working_hours'=>$hours));
   }
-  if ($res){
+  if ($res) {
     header('Location: profile_edit.php');
     exit();
-  } else
-      $err->add($i18n->getKey('error.db'));
+  } else {
+    $err->add($i18n->getKey('error.db'));
+  }
 }
 
 // returns months where January is month 1, not 0
-$monthsData = $quota->get($year);
+$monthsData = $quota->get($selectedYear);
+
+$form = new Form('monthlyQuotaForm');
 
-$form->addInput(array('type'=>'combobox', 'name'=>'years', 'data'=>$years, 'datakeys'=>array('id', 'name'), 'value'=>$year, 'onchange'=>'yearChange(this.value);'));
+$form->addInput(array('type'=>'combobox', 'name'=>'years', 'data'=>$years, 'datakeys'=>array('id', 'name'), 'value'=>$selectedYear, 'onchange'=>'yearChange(this.value);'));
 for ($i=0; $i < count($months); $i++) { 
   $value = "";
   if (array_key_exists($i+1, $monthsData)){
@@ -53,7 +80,9 @@ for ($i=0; $i < count($months); $i++) {
   $name = $months[$i];
   $form->addInput(array('type'=>'text', 'name'=>$name, 'maxlength'=>3, 'value'=> $value, 'style'=>'width:50px'));
 }
+$form->addInput(array('type'=>'text', 'name'=>'dailyWorkingHours', 'value'=>$quota->getDailyWorkingHours(), 'style'=>'width:50px'));
 $smarty->assign('months', $months);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('title', $i18n->getKey('title.monthly_quota'));
 $smarty->assign('content_page_name', 'cf_monthly_quota.tpl');
 $smarty->display('index.tpl');
old mode 100644 (file)
new mode 100755 (executable)
index 8964d93..1009f51
@@ -521,9 +521,12 @@ if ($_POST) {
   }
   
   if ($_POST["convert1900to1930"]){
-    setChange("CREATE TABLE `timetracker`.`tt_monthly_quota` ( `year` SMALLINT UNSIGNED NOT NULL , `month` TINYINT UNSIGNED NOT NULL , `quota` SMALLINT UNSIGNED NOT NULL , PRIMARY KEY (`year`, `month`))");
+    setChange("CREATE TABLE `tt_monthly_quota` (`team_id` int(11) NOT NULL, `year` smallint(5) UNSIGNED NOT NULL, `month` tinyint(3) UNSIGNED NOT NULL, `quota` smallint(5) UNSIGNED NOT NULL, PRIMARY KEY (`year`,`month`,`team_id`))");
+    setChange("ALTER TABLE `tt_monthly_quota` ADD CONSTRAINT `FK_TT_TEAM_CONSTRAING` FOREIGN KEY (`team_id`) REFERENCES `tt_teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE");
+    setChange("ALTER TABLE `tt_teams` ADD `daily_working_hours` SMALLINT NULL DEFAULT '8' AFTER `lock_spec`");
+    setChange("UPDATE `tt_teams` SET `daily_working_hours` = 8");
   }
-
+  
   // The update_clients function updates projects field in tt_clients table.
   if ($_POST["update_clients"]) {
     $mdb2 = getConnection();
@@ -607,6 +610,7 @@ if ($_POST) {
     setChange("OPTIMIZE TABLE tt_fav_reports");
     setChange("OPTIMIZE TABLE tt_invoices");
     setChange("OPTIMIZE TABLE tt_log");
+    setChange("OPTIMIZE TABLE tt_monthly_quota");
     setChange("OPTIMIZE TABLE tt_project_task_binds");
     setChange("OPTIMIZE TABLE tt_projects");
     setChange("OPTIMIZE TABLE tt_tasks");
index a24eda7bb0078beec6d96d72a73d65c1ef0a52ce..62032fca11e5c85035482c643c1bed20b4feb393 100644 (file)
@@ -117,6 +117,10 @@ select{ font-size: 10pt; font-family: verdana; }
   border-bottom: 1px solid silver;
 }
 
+.borderTop td {
+  border-top: 1px solid silver;
+}
+
 .sectionHeaderNoBorder {
   font-weight: bold;
 }
@@ -131,4 +135,11 @@ select{ font-size: 10pt; font-family: verdana; }
   color: #0000c0;
 }
 
+.divider {
+  background-color: #efefef;
+}
+table.divider {
+  width: 720px;
+}
+
 div#LoginAboutText { width:400px; }
index 1734852d5c7205656ace4e5492e135ac9be7c241..bfc198a945c213519f28794f0af75c58e534bbc0 100644 (file)
--- a/mysql.sql
+++ b/mysql.sql
@@ -28,6 +28,7 @@ CREATE TABLE `tt_teams` (
   `plugins` varchar(255) default NULL,                   # a list of enabled plugins for team
   `lock_spec` varchar(255) default NULL,                 # Cron specification for record locking,
                                                          # for example: "0 10 * * 1" for "weekly on Mon at 10:00".
+  `daily_working_hours` smallint(6) DEFAULT '8',         # number of working hours per days, a worker is suppose to work
   `custom_logo` tinyint(4) default '0',                  # whether to use a custom logo or not
   `status` tinyint(4) default '1',                       # team status
   PRIMARY KEY (`id`)
@@ -341,12 +342,17 @@ create index invoice_idx on tt_expense_items(invoice_id);
 
 #
 # Structure for table tt_monthly_quota.
-# This table lists expense items.
+# This table lists monthly quota per team.
 #
 
-CREATE TABLE `tt_monthly_quota` ( 
-  `year` SMALLINT UNSIGNED NOT NULL ,   # year we'setting monthly quota for
-  `month` TINYINT UNSIGNED NOT NULL ,   # month we're settng monthly quota for
-  `quota` SMALLINT UNSIGNED NOT NULL ,  # the monthly quota
-  PRIMARY KEY (`year`, `month`)
+CREATE TABLE `tt_monthly_quota` (
+  `team_id` int(11) NOT NULL,             # team's id
+  `year` smallint(5) UNSIGNED NOT NULL,   # year we'setting monthly quota for
+  `month` tinyint(3) UNSIGNED NOT NULL,   # month we're settng monthly quota for
+  `quota` smallint(5) UNSIGNED NOT NULL,  # the monthly quota
+  PRIMARY KEY (`year`,`month`,`team_id`)
 );
+
+ALTER TABLE `tt_monthly_quota`
+  ADD CONSTRAINT `FK_TT_TEAM_CONSTRAING` FOREIGN KEY (`team_id`) REFERENCES `tt_teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+
index ed1c9f8cd17b49ba1fa4887e4d7f5582995dcb07..b50469b39469c96c7e5c7d1c62487ebab99030fe 100644 (file)
@@ -4,33 +4,51 @@ class MonthlyQuota {
     
     var $db;
     var $holidays;
+    var $usersTeamId;
     // Old style constructors are DEPRECATED in PHP 7.0, and will be removed in a future version. You should always use __construct() in new code.
     function __construct() {
         $this->db = getConnection();
         $i18n = $GLOBALS['I18N'];
         $this->holidays = $i18n->holidays;
+        global $user;
+        $this->usersTeamId = $user->team_id;
     }
     
     public function update($year, $month, $quota) {
-        $deleteSql = "DELETE FROM tt_monthly_quota WHERE year = $year AND month = $month";
+        $teamId = $this->usersTeamId;
+        $deleteSql = "DELETE FROM tt_monthly_quota WHERE year = $year AND month = $month AND team_id = $teamId";
         $this->db->exec($deleteSql);
-        $insertSql = "INSERT INTO tt_monthly_quota (year, month, quota) values ($year, $month, $quota)";
-        $affected = $this->db->exec($insertSql);
-        return (!is_a($affected, 'PEAR_Error'));
+        if ($quota){
+            $insertSql = "INSERT INTO tt_monthly_quota (team_id, year, month, quota) values ($teamId, $year, $month, $quota)";
+            $affected = $this->db->exec($insertSql);
+            return (!is_a($affected, 'PEAR_Error'));
+        }
+        return true;
     }
         
     public function get($year, $month) {
-        
         if (is_null($month)){
             return $this->getMany($year);
         }
         
         return $this->getSingle($year, $month);
     }
+
+    public function getDailyWorkingHours(){
+        $teamId = $this->usersTeamId;
+        $sql = "SELECT daily_working_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["daily_working_hours"];
+    }
     
     private function getSingle($year, $month) {
-        
-        $sql = "SELECT quota FROM tt_monthly_quota WHERE year = $year AND month = $month";
+        $teamId = $this->usersTeamId;
+        $sql = "SELECT quota FROM tt_monthly_quota WHERE year = $year AND month = $month AND team_id = $teamId";
         $reader = $this->db->query($sql);
         if (is_a($reader, 'PEAR_Error')) {
             return false;
@@ -49,14 +67,15 @@ class MonthlyQuota {
             }
             
             $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
-            return $this->getWorkingDays("$year-$month-01", "$year-$month-$daysInMonth", $holidaysWithYear) * 8;
+            return $this->getWorkingDays("$year-$month-01", "$year-$month-$daysInMonth", $holidaysWithYear) * $this->getDailyWorkingHours();
         }
         
         return $row["quota"];  
     }
     
     private function getMany($year){
-        $sql = "SELECT year, month, quota FROM tt_monthly_quota WHERE year = $year";
+        $teamId = $this->usersTeamId;
+        $sql = "SELECT month, quota FROM tt_monthly_quota WHERE year = $year AND team_id = $teamId";
         $result = array();
         $res = $this->db->query($sql);
         if (is_a($res, 'PEAR_Error')) {