don't count assigned domain quota for inactive domains
now only summing up the assigned domain quota for active domains, and not subtracting disc base occupied by mailboxes of inactive domains (inactive_bytes)
This commit is contained in:
		
							parent
							
								
									471ab05423
								
							
						
					
					
						commit
						f01e3e59c5
					
				@ -44,8 +44,9 @@ else {
 | 
				
			|||||||
          $exec_fields = array('cmd' => 'system', 'task' => 'df', 'dir' => '/var/vmail');
 | 
					          $exec_fields = array('cmd' => 'system', 'task' => 'df', 'dir' => '/var/vmail');
 | 
				
			||||||
          $vmail_df = explode(',', json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true));
 | 
					          $vmail_df = explode(',', json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true));
 | 
				
			||||||
          $domainQuota = round(domain_admin('total_quota')/1024);
 | 
					          $domainQuota = round(domain_admin('total_quota')/1024);
 | 
				
			||||||
 | 
					          $inactive_bytes = round(mailbox('get','inactive_bytes')/1024/1024/1024);
 | 
				
			||||||
          $quotaPercent1 = round(($domainQuota/substr($vmail_df[3], 0, -1))*100);
 | 
					          $quotaPercent1 = round(($domainQuota/substr($vmail_df[3], 0, -1))*100);
 | 
				
			||||||
          $quotaPercent2 = round((($domainQuota-substr($vmail_df[2], 0, -1))/substr($vmail_df[3], 0, -1))*100);
 | 
					          $quotaPercent2 = round((($domainQuota-substr($vmail_df[2], 0, -1)+$inactive_bytes)/substr($vmail_df[3], 0, -1))*100);
 | 
				
			||||||
          $quotaPercent2 = ($quotaPercent2+substr($vmail_df[4], 0, -1)>100) ? 100-substr($vmail_df[4], 0, -1) : $quotaPercent2; //handling overcommitment
 | 
					          $quotaPercent2 = ($quotaPercent2+substr($vmail_df[4], 0, -1)>100) ? 100-substr($vmail_df[4], 0, -1) : $quotaPercent2; //handling overcommitment
 | 
				
			||||||
        ?>
 | 
					        ?>
 | 
				
			||||||
        <div role="tabpanel" class="tab-pane active" id="tab-containers">
 | 
					        <div role="tabpanel" class="tab-pane active" id="tab-containers">
 | 
				
			||||||
 | 
				
			|||||||
@ -453,7 +453,7 @@ function domain_admin($_action, $_data = null) {
 | 
				
			|||||||
        );
 | 
					        );
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      $stmt = $pdo->query("SELECT SUM(`quota`) AS `quota` FROM `domain`");
 | 
					      $stmt = $pdo->query("SELECT SUM(`quota`) AS `quota` FROM `domain` WHERE `active`=1");
 | 
				
			||||||
      $row = $stmt->fetch(PDO::FETCH_ASSOC);
 | 
					      $row = $stmt->fetch(PDO::FETCH_ASSOC);
 | 
				
			||||||
      return $row['quota'];
 | 
					      return $row['quota'];
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
 | 
				
			|||||||
@ -3254,6 +3254,19 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
          return $resourcedata;
 | 
					          return $resourcedata;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					        case 'inactive_bytes':
 | 
				
			||||||
 | 
					          if ($_SESSION['mailcow_cc_role'] != "admin") {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					          $stmt = $pdo->query("SELECT SUM(`quota2`.`bytes`) AS `bytes`
 | 
				
			||||||
 | 
					              FROM `mailbox`, `quota2`, `domain`
 | 
				
			||||||
 | 
					                WHERE `mailbox`.`kind` NOT REGEXP 'location|thing|group'
 | 
				
			||||||
 | 
					                  AND `mailbox`.`username` = `quota2`.`username`
 | 
				
			||||||
 | 
					                  AND `domain`.`domain` = `mailbox`.`domain`
 | 
				
			||||||
 | 
					                  AND `domain`.`active` = 0");
 | 
				
			||||||
 | 
					          $row = $stmt->fetch(PDO::FETCH_ASSOC);
 | 
				
			||||||
 | 
					          return $row['bytes'];
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
    case 'delete':
 | 
					    case 'delete':
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user