New release

Leandro Silva [11-16-18 - 11:34]
New release
Filename
LeoGuildManager.lua
LeoGuildManager.txt
LeoGuildManager.xml
LeoGuildManagerInit.lua
LeoGuildManagerUI.lua
Settings.lua
diff --git a/LeoGuildManager.lua b/LeoGuildManager.lua
index 6066357..4dc504a 100644
--- a/LeoGuildManager.lua
+++ b/LeoGuildManager.lua
@@ -1,4 +1,3 @@
-
 LeoGuildManager.members = {}
 LeoGuildManager.guilds = {}
 LeoGuildManager.isScanning = false
@@ -42,6 +41,15 @@ function LeoGuildManager.UseTooltipRoster(guildName)
     end
     return LeoGuildManager.globalData.settings.guilds[guildName].tooltipRoster
 end
+function LeoGuildManager.SetPurgePurchases(guildName, value)
+    LeoGuildManager.globalData.settings.guilds[guildName].purchases = value
+end
+function LeoGuildManager.GetPurgePurchases(guildName)
+    if LeoGuildManager.globalData.settings.guilds[guildName].purchases == nil then
+        LeoGuildManager.globalData.settings.guilds[guildName].purchases = 0
+    end
+    return LeoGuildManager.globalData.settings.guilds[guildName].purchases
+end

 function LeoGuildManager.TimeAgo(timestamp)
     local diff = GetTimeStamp() - timestamp
@@ -56,12 +64,22 @@ function LeoGuildManager.TimeAgo(timestamp)
 end

 function LeoGuildManager.formatNumber(amount)
-    if amount == nil then return nil; end
-    if type(amount) == "string" then amount = tonumber( amount ) end
-    if type(amount) ~= "number" then return amount; end
-    if amount < 0 then amount = 0 end
-    if amount < 1000 then return amount; end
-    return FormatIntegerWithDigitGrouping( amount, GetString( SI_DIGIT_GROUP_SEPARATOR ) )
+    if amount == nil then
+        return nil;
+    end
+    if type(amount) == "string" then
+        amount = tonumber(amount)
+    end
+    if type(amount) ~= "number" then
+        return amount;
+    end
+    if amount < 0 then
+        amount = 0
+    end
+    if amount < 1000 then
+        return amount;
+    end
+    return FormatIntegerWithDigitGrouping(amount, GetString(SI_DIGIT_GROUP_SEPARATOR))
 end

 local function formatMessage(message)
@@ -74,7 +92,7 @@ end

 function LeoGuildManager.debug(message)
     if LeoGuildManager.isDebug == true then
-        d(formatMessage("[D] "..message))
+        d(formatMessage("[D] " .. message))
     end
 end

@@ -96,16 +114,23 @@ function LeoGuildManager.GetCycleName(id)
         cycleData = LeoGuildManager.cycleATT
     end
     for _, data in pairs(cycleData) do
-        if data.id == id then return data.name end
+        if data.id == id then
+            return data.name
+        end
     end
     return nil
 end

 function LeoGuildManager.GetNewRangeName(value)
-    if value == 7 then return "1 week"
-    elseif value == 14 then return "2 weeks"
-    elseif value == 21 then return "3 weeks"
-    else return "1 month" end
+    if value == 7 then
+        return "1 week"
+    elseif value == 14 then
+        return "2 weeks"
+    elseif value == 21 then
+        return "3 weeks"
+    else
+        return "1 month"
+    end
 end

 function LeoGuildManager.GetCycleIdByName(name)
@@ -114,27 +139,33 @@ function LeoGuildManager.GetCycleIdByName(name)
         cycleData = LeoGuildManager.cycleATT
     end
     for _, data in pairs(cycleData) do
-        if data.name == name then return data.id end
+        if data.name == name then
+            return data.id
+        end
     end
     return nil
 end

 function LeoGuildManager.GetGuildId(name)
     for guildId, guildName in pairs(LeoGuildManager.guilds) do
-        if guildName == name then return guildId end
+        if guildName == name then
+            return guildId
+        end
     end
     return nil
 end

 function LeoGuildManager.GetGuilds()
-    if #LeoGuildManager.guilds > 0 then return LeoGuildManager.guilds end
+    if #LeoGuildManager.guilds > 0 then
+        return LeoGuildManager.guilds
+    end

     LeoGuildManager.guilds = {}
     if GetNumGuilds() > 0 then
         for guild = 1, GetNumGuilds() do
             local guildId = GetGuildId(guild)
             local guildName = GetGuildName(guildId)
-            if(not guildName or (guildName):len() < 1) then
+            if (not guildName or (guildName):len() < 1) then
                 guildName = "Guild " .. guildId
             end
             LeoGuildManager.guilds[guildId] = guildName
@@ -148,7 +179,9 @@ function LeoGuildManager.GetGuildIndex(guildName)
     if GetNumGuilds() > 0 then
         for guild = 1, GetNumGuilds() do
             local name = GetGuildName(guildId)
-            if name == guildName then return guild end
+            if name == guildName then
+                return guild
+            end
         end
     end
     return nil
@@ -168,7 +201,9 @@ function LeoGuildManager.GetGuildRankId(guildId, rankName)
         if name == "" then
             name = GetDefaultGuildRankName(guildId, i)
         end
-        if name == rankName then return i end
+        if name == rankName then
+            return i
+        end
     end
     return 0
 end
@@ -217,6 +252,7 @@ function LeoGuildManager.GetGuildMembers(guildId)
             deposits = -1,
             taxes = 0,
             sales = -1,
+            purchases = -1,
             joined = 0,
             endangered = false,
             depositEvents = {}
@@ -276,17 +312,33 @@ end
 function LeoGuildManager.AddSale(memberName, value)
     for i = 1, #LeoGuildManager.members do
         if LeoGuildManager.members[i].name == memberName then
-            if LeoGuildManager.members[i].sales < 0 then LeoGuildManager.members[i].sales = 0 end
+            if LeoGuildManager.members[i].sales < 0 then
+                LeoGuildManager.members[i].sales = 0
+            end
             LeoGuildManager.members[i].sales = LeoGuildManager.members[i].sales + value
             return
         end
     end
 end

+function LeoGuildManager.AddPurchase(memberName, value)
+    for i = 1, #LeoGuildManager.members do
+        if LeoGuildManager.members[i].name == memberName then
+            if LeoGuildManager.members[i].purchases < 0 then
+                LeoGuildManager.members[i].purchases = 0
+            end
+            LeoGuildManager.members[i].purchases = LeoGuildManager.members[i].purchases + value
+            return
+        end
+    end
+end
+
 function LeoGuildManager.AddDeposit(memberName, value, timestamp)
     for i = 1, #LeoGuildManager.members do
         if LeoGuildManager.members[i].name == memberName then
-            if LeoGuildManager.members[i].deposits < 0 then LeoGuildManager.members[i].deposits = 0 end
+            if LeoGuildManager.members[i].deposits < 0 then
+                LeoGuildManager.members[i].deposits = 0
+            end
             LeoGuildManager.members[i].deposits = LeoGuildManager.members[i].deposits + value
             table.insert(LeoGuildManager.members[i].depositEvents, {
                 value = value,
@@ -306,34 +358,58 @@ function LeoGuildManager.CreatePurgeDescription(guildName)

     local tickets = LeoGuildManager.globalData.settings.guilds[guildName].tickets
     local sales = LeoGuildManager.globalData.settings.guilds[guildName].sales
+    local purchases = LeoGuildManager.globalData.settings.guilds[guildName].purchases
     local inactivity = LeoGuildManager.globalData.settings.guilds[guildName].inactivity
     local ignoreRank = LeoGuildManager.globalData.settings.guilds[guildName].ignoreRank
     local ignoreNew = LeoGuildManager.globalData.settings.guilds[guildName].ignoreNew

-    local guildId = LeoGuildManager.GetGuildId(LeoGuildManager.globalData.selectedGuild)
+    local guildId = LeoGuildManager.GetGuildId(guildName)
     local canScan = LeoGuildManager.CanScanBankHistory(guildId)
     local integrationLoaded = LeoGuildManager.HasIntegrationAddonsLoaded()
-    if not canScan then tickets = 0 end
-    if not integrationLoaded then sales = 0 end
+    if not canScan then
+        tickets = 0
+    end
+    if not integrationLoaded then
+        sales = 0
+    end

     local descPurge = ""

-    if tickets > 0 and sales > 0 then
-        descPurge = cycle .. ", members were required to buy at least " .. tickets .. "k in raffle tickets OR have " .. sales .. "k sales."
-    elseif tickets > 0 then
-        descPurge = cycle .. ", members were required to buy at least " .. tickets .. "k in raffle tickets."
-    elseif sales > 0 then
-        descPurge = cycle .. ", members were required to have at least " .. sales .. "k sales."
+    if tickets > 0 or sales > 0 or purchases > 0 then
+        descPurge = cycle .. ", members were required "
+    end
+    local hasCond = false
+    if tickets > 0 then
+        descPurge = descPurge .. "to buy at least " .. tickets .. "k in raffle tickets"
+        hasCond = true
+    end
+    if sales > 0 then
+        if hasCond then
+            descPurge = descPurge .. " OR "
+        end
+        descPurge = descPurge .. "to have at least " .. sales .. "k sales"
+        hasCond = true
+    end
+    if purchases > 0 then
+        if hasCond then
+            descPurge = descPurge .. " OR "
+        end
+        descPurge = descPurge .. "to have at least " .. purchases .. "k purchases"
+        hasCond = true
     end

+    hasCond = false
     if inactivity > 0 then
-        descPurge = descPurge .. "\r\nInactivity policy of " .. inactivity .." days."
+        descPurge = descPurge .. "\r\nInactivity policy of " .. inactivity .. " days. "
+        hasCond = true
     end

     if ignoreRank > 0 then
-        local guildId = LeoGuildManager.GetGuildId(guildName)
         local rankName = LeoGuildManager.GetGuildRankName(guildId, LeoGuildManager.globalData.settings.guilds[guildName].ignoreRank)
-        descPurge = descPurge .. "\r\nIgnore members with rank equal or above " .. rankName .. "."
+        if not hasCond then
+            descPurge = descPurge == "\r\n"
+        end
+        descPurge = descPurge .. "Ignore members with rank equal or above " .. rankName .. "."
     end
     descPurge = descPurge .. "\r\nIgnore new members who joined the guild in less than " .. LeoGuildManager.GetNewRangeName(ignoreNew) .. "."
     return descPurge
@@ -377,7 +453,7 @@ local function normalizeGuilds()
             end
         end
         if deleted then
-            LeoGuildManager.log("Not part of guild " .. name .." anymore. Deleting ...")
+            LeoGuildManager.log("Not part of guild " .. name .. " anymore. Deleting ...")
             LeoGuildManager.globalData.settings.guilds[name] = nil
             LeoGuildManager.scanData[name] = nil
         end
@@ -392,7 +468,7 @@ local function normalizeGuilds()
             end
         end
         if not found then
-            LeoGuildManager.log("New guild " .. guildName .." found. Initializing ...")
+            LeoGuildManager.log("New guild " .. guildName .. " found. Initializing ...")
             LeoGuildManager.globalData.settings.guilds[guildName] = {
                 id = guildId,
                 enabled = false,
@@ -401,6 +477,7 @@ local function normalizeGuilds()
                 ignoreNew = 1,
                 tickets = 0,
                 sales = 0,
+                purchases = 0,
                 inactivity = 30,
                 blacklist = {},
                 tooltipRoster = false
@@ -432,10 +509,10 @@ function LeoGuildManager.Initialize()

     local LibFeedback = LibStub:GetLibrary("LibFeedback")
     local showButton, feedbackWindow = LibFeedback:initializeFeedbackWindow(LeoGuildManager,
-        LeoGuildManager.name,LeoGuildManagerWindow, "@LeandroSilva",
-        {TOPRIGHT, LeoGuildManagerWindow, TOPRIGHT,-50,3},
-        {0,1000,10000,"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y9KM4PZU2UZ6A"},
-        "If you found a bug, have a request or a suggestion, or simply wish to donate, send a mail.")
+            LeoGuildManager.name, LeoGuildManagerWindow, "@LeandroSilva",
+            { TOPRIGHT, LeoGuildManagerWindow, TOPRIGHT, -50, 3 },
+            { 0, 1000, 10000, "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y9KM4PZU2UZ6A" },
+            "If you found a bug, have a request or a suggestion, or simply wish to donate, send a mail.")
     LeoGuildManager.feedback = feedbackWindow
     LeoGuildManager.feedback:SetDrawLayer(DL_OVERLAY)
     LeoGuildManager.feedback:SetDrawTier(DT_LOW)
@@ -450,7 +527,8 @@ function LeoGuildManager.Initialize()
     LeoGuildManager.settings:CreatePanel()

     SLASH_COMMANDS["/leogm"] = function(cmd)
-        if cmd == "" then LeoGuildManagerUI:ToggleUI()
+        if cmd == "" then
+            LeoGuildManagerUI:ToggleUI()
         elseif cmd == "debug" then
             if LeoGuildManager.isDebug == false then
                 LeoGuildManager.isDebug = true
@@ -473,11 +551,11 @@ function LeoGuildManager.AutoKick(kick)
                     local displayName = GetGuildMemberInfo(guildId, guildMemberIndex)
                     if displayName == userId then
                         if kick == true then
-                            d("Found " .. userId .." on " .. guildName .. ". Kicking ...")
+                            d("Found " .. userId .. " on " .. guildName .. ". Kicking ...")
                             GuildRemove(guildId, userId)
                             d("Bye bye!")
                         else
-                            d("Found " .. userId .." on " .. guildName)
+                            d("Found " .. userId .. " on " .. guildName)
                         end
                         break
                     end
@@ -505,7 +583,9 @@ end
 function ZO_KeyboardGuildRosterRowDisplayName_OnMouseEnter(control)
     orig_ZO_KeyboardGuildRosterRowDisplayName_OnMouseEnter(control)

-    if not LeoGuildManager.globalData.settings.tooltipRoster then return end
+    if not LeoGuildManager.globalData.settings.tooltipRoster then
+        return
+    end

     local parent = control:GetParent()
     local data = ZO_ScrollList_GetData(parent)
@@ -631,12 +711,18 @@ local function RequestGuildHistoryCategoryOlderLocal(guildIndex, category, numGu
     return false
 end

-function LeoGuildManager.HasIntegrationAddonsLoaded()
-    return (LeoGuildManager.globalData.settings.integration == LeoGuildManager.integrations[2] and
-            ArkadiusTradeTools ~= nil and ArkadiusTradeTools.Modules ~= nil and ArkadiusTradeTools.Modules.Sales ~= nil)
-            or
-            (LeoGuildManager.globalData.settings.integration == LeoGuildManager.integrations[1] and
-                    MasterMerchant ~= nil and MasterMerchant.guildSales ~= nil)
+function LeoGuildManager.HasIntegrationAddonsLoaded(integration)
+    if integration == 1 then
+        return MasterMerchant ~= nil and MasterMerchant.guildSales ~= nil
+    elseif integration == 2 then
+        return ArkadiusTradeTools ~= nil and ArkadiusTradeTools.Modules ~= nil and ArkadiusTradeTools.Modules.Sales ~= nil
+    else
+        return (LeoGuildManager.globalData.settings.integration == LeoGuildManager.integrations[2] and
+                LeoGuildManager.HasIntegrationAddonsLoaded(2))
+                or
+                (LeoGuildManager.globalData.settings.integration == LeoGuildManager.integrations[1] and
+                        LeoGuildManager.HasIntegrationAddonsLoaded(1))
+    end
 end

 function LeoGuildManager.GuildNeedsScan(guildId)
@@ -648,7 +734,7 @@ end
 function LeoGuildManager.CanScanBankHistory(guildId)
     local guildName = GetGuildName(guildId)
     return LeoGuildManager.globalData.settings.guilds[guildName].enabled and
-        DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_BANK_VIEW_GOLD)
+            DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_BANK_VIEW_GOLD)
 end

 local manualScan = false
@@ -665,7 +751,9 @@ function LeoGuildManager.StartScanGuilds(manual)
         manualScan = true
         LeoGuildManager.log("Starting guild scan ...")
     elseif LeoGuildManager.globalData.settings.scanAutomatically == false then
-        zo_callLater(function() LeoGuildManager.StartScanGuilds() end, 5000)
+        zo_callLater(function()
+            LeoGuildManager.StartScanGuilds()
+        end, 5000)
         return
     end

@@ -771,12 +859,16 @@ local function onSettingsControlsCreated(panel)
 end

 local function onNewMovementInUIMode(eventCode)
-    if not LeoGuildManagerWindow:IsHidden() then LeoGuildManagerUI:CloseUI() end
+    if not LeoGuildManagerWindow:IsHidden() then
+        LeoGuildManagerUI:CloseUI()
+    end
 end

-local function onChampionPerksSceneStateChange(oldState,newState)
+local function onChampionPerksSceneStateChange(oldState, newState)
     if newState == SCENE_SHOWING then
-        if not LeoGuildManagerWindow:IsHidden() then LeoGuildManagerUI:CloseUI() end
+        if not LeoGuildManagerWindow:IsHidden() then
+            LeoGuildManagerUI:CloseUI()
+        end
     end
 end

@@ -786,7 +878,9 @@ end

 local function onPlayerActivated(eventCode)
     EVENT_MANAGER:UnregisterForEvent(LeoGuildManager.name, eventCode)
-    zo_callLater(function() LeoGuildManager.StartScanGuilds() end, 5000)
+    zo_callLater(function()
+        LeoGuildManager.StartScanGuilds()
+    end, 5000)
 end

 function LeoGuildManager.OnAddOnLoaded(event, addonName)
@@ -796,7 +890,9 @@ function LeoGuildManager.OnAddOnLoaded(event, addonName)

         LeoGuildManager.Initialize()

-        EVENT_MANAGER:RegisterForUpdate(LeoGuildManager.name, 60000, function() LeoGuildManager.OnUpdate() end)
+        EVENT_MANAGER:RegisterForUpdate(LeoGuildManager.name, 60000, function()
+            LeoGuildManager.OnUpdate()
+        end)
         EVENT_MANAGER:RegisterForEvent(LeoGuildManager.name, EVENT_PLAYER_ACTIVATED, onPlayerActivated)
         CALLBACK_MANAGER:RegisterCallback("LAM-PanelControlsCreated", onSettingsControlsCreated)
         EVENT_MANAGER:RegisterForEvent(LeoGuildManager.name, EVENT_NEW_MOVEMENT_IN_UI_MODE, onNewMovementInUIMode)
diff --git a/LeoGuildManager.txt b/LeoGuildManager.txt
index 048d53b..4ea4d66 100644
--- a/LeoGuildManager.txt
+++ b/LeoGuildManager.txt
@@ -1,7 +1,7 @@
 ## Title: Leo's Guild Manager
 ## APIVersion: 100024 100025
-## Version: 1.1.4
-## AddOnVersion: 114
+## Version: 1.1.5
+## AddOnVersion: 115
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoGuildManagerGlobalData LeoGuildManagerScanData
 ## OptionalDependsOn: LibStub LibFeedback LibAddonMenu-2.0
diff --git a/LeoGuildManager.xml b/LeoGuildManager.xml
index 7a5c949..a388c9a 100644
--- a/LeoGuildManager.xml
+++ b/LeoGuildManager.xml
@@ -153,10 +153,17 @@
                                                 ZO_SortHeader_Initialize(self, "Sales", "sales", ZO_SORT_ORDER_DOWN, TEXT_ALIGN_LEFT, "ZoFontGameLargeBold")
                                             </OnInitialized>
                                         </Control>
-                                        <Control name="$(parent)Online" inherits="ZO_SortHeader">
+                                        <Control name="$(parent)Purchases" inherits="ZO_SortHeader">
                                             <Anchor point="TOPLEFT" relativeTo="$(parent)Sales" relativePoint="TOPRIGHT" offsetX="10" />
                                             <Dimensions x="100" y="20" />
                                             <OnInitialized>
+                                                ZO_SortHeader_Initialize(self, "Purchases", "purchases", ZO_SORT_ORDER_DOWN, TEXT_ALIGN_LEFT, "ZoFontGameLargeBold")
+                                            </OnInitialized>
+                                        </Control>
+                                        <Control name="$(parent)Online" inherits="ZO_SortHeader">
+                                            <Anchor point="TOPLEFT" relativeTo="$(parent)Purchases" relativePoint="TOPRIGHT" offsetX="10" />
+                                            <Dimensions x="100" y="20" />
+                                            <OnInitialized>
                                                 ZO_SortHeader_Initialize(self, "Online", "online", ZO_SORT_ORDER_DOWN, TEXT_ALIGN_LEFT, "ZoFontGameLargeBold")
                                             </OnInitialized>
                                         </Control>
@@ -189,14 +196,9 @@
                             <Dimensions x="150" y="60"/>
                             <Anchor point="TOPLEFT" relativeTo="$(parent)MemberScrollList" relativePoint="BOTTOMLEFT" offsetX="0" offsetY="20" />
                         </Label>
-                        <Label name="$(parent)EndangeredCounter" text="Selected 0" font="ZoFontGame" wrapMode="ELLIPSIS"
-                               verticalAlignment="CENTER" horizontalAlignment="LEFT" mouseEnabled="false">
-                            <Dimensions x="150" y="60"/>
-                            <Anchor point="TOPLEFT" relativeTo="$(parent)ListResult" relativePoint="TOPRIGHT" offsetX="20" offsetY="0" />
-                        </Label>

                         <Button name="$(parent)ClearSelected" text="Clear Selected" inherits="ZO_DefaultButton" clickSound="Click">
-                            <Anchor point="TOPLEFT" relativeTo="$(parent)ListResult" relativePoint="TOPRIGHT" offsetX="200" offsetY="16"/>
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)ListResult" relativePoint="TOPRIGHT" offsetX="10" offsetY="16"/>
                             <Dimensions x="180" />
                             <OnClicked> LeoGuildManager.ClearSelected() </OnClicked>
                         </Button>
@@ -206,10 +208,16 @@
                             <OnInitialized> self:SetEnabled(false) </OnInitialized>
                             <OnClicked> LeoGuildManager.DemoteAllClick() </OnClicked>
                         </Button>
-                        <Button name="$(parent)KickButton" text="Remove Selected" inherits="ZO_DefaultButton" clickSound="Click">
+                        <Button name="$(parent)PromoteButton" text="Promote Selected" inherits="ZO_DefaultButton" clickSound="Click">
                             <Anchor point="TOPLEFT" relativeTo="$(parent)DemoteButton" relativePoint="TOPRIGHT" offsetX="0" offsetY="0"/>
                             <Dimensions x="180" />
                             <OnInitialized> self:SetEnabled(false) </OnInitialized>
+                            <OnClicked> LeoGuildManager.PromoteAllClick() </OnClicked>
+                        </Button>
+                        <Button name="$(parent)KickButton" text="Remove Selected" inherits="ZO_DefaultButton" clickSound="Click">
+                            <Anchor point="TOPLEFT" relativeTo="$(parent)PromoteButton" relativePoint="TOPRIGHT" offsetX="0" offsetY="0"/>
+                            <Dimensions x="180" />
+                            <OnInitialized> self:SetEnabled(false) </OnInitialized>
                             <OnClicked> LeoGuildManager.KickAllClick() </OnClicked>
                         </Button>

@@ -247,9 +255,15 @@
                     <OnMouseEnter> LeoGuildManagerUI.TooltipSales(self, true) </OnMouseEnter>
                     <OnMouseExit> LeoGuildManagerUI.TooltipSales(self, false) </OnMouseExit>
                 </Label>
-                <Label name="$(parent)Online" font="LeoGuildManagerNormalFont" verticalAlignment="CENTER">
+                <Label name="$(parent)Purchases" font="LeoGuildManagerNormalFont" verticalAlignment="CENTER" mouseEnabled="true">
                     <Dimensions x="100" y="32" />
                     <Anchor point="TOPLEFT" relativeTo="$(parent)Sales" relativePoint="TOPRIGHT" offsetX="10"/>
+                    <!--<OnMouseEnter> LeoGuildManagerUI.TooltipSales(self, true) </OnMouseEnter>-->
+                    <!--<OnMouseExit> LeoGuildManagerUI.TooltipSales(self, false) </OnMouseExit>-->
+                </Label>
+                <Label name="$(parent)Online" font="LeoGuildManagerNormalFont" verticalAlignment="CENTER">
+                    <Dimensions x="100" y="32" />
+                    <Anchor point="TOPLEFT" relativeTo="$(parent)Purchases" relativePoint="TOPRIGHT" offsetX="10"/>
                 </Label>
                 <Label name="$(parent)Joined" font="LeoGuildManagerNormalFont" verticalAlignment="CENTER">
                     <Dimensions x="100" y="32" />
diff --git a/LeoGuildManagerInit.lua b/LeoGuildManagerInit.lua
index 568b85e..3aa2fa0 100644
--- a/LeoGuildManagerInit.lua
+++ b/LeoGuildManagerInit.lua
@@ -4,7 +4,7 @@ LeoGuildManagerUI = LeoGuildManagerUI or {}

 LeoGuildManager.name = "LeoGuildManager"
 LeoGuildManager.displayName = "Leo's Guild Manager"
-LeoGuildManager.version = "1.1.4"
+LeoGuildManager.version = "1.1.5"
 LeoGuildManager.chatPrefix = "|c39B027" .. LeoGuildManager.name .. "|r: "

 LeoGuildManager.TAB_PURGE = "Purge"
diff --git a/LeoGuildManagerUI.lua b/LeoGuildManagerUI.lua
index 0223342..d577101 100644
--- a/LeoGuildManagerUI.lua
+++ b/LeoGuildManagerUI.lua
@@ -4,6 +4,8 @@ LeoGuildManager.memberScroll = nil
 LeoGuildManager.selectedRank = nil
 LeoGuildManager.endangered = {}

+local purgeTotal = 0
+
 function LeoGuildManagerUI:OnWindowMoveStop()
     LeoGuildManager.globalData.position = {
         left = LeoGuildManagerWindow:GetLeft(),
@@ -94,6 +96,7 @@ function LeoGuildManagerMemberList:New(control)
         ["name"] = {},
         ["deposits"] = { isNumeric = true, tiebreaker = "name"},
         ["sales"] = { isNumeric = true, tiebreaker = "name"},
+        ["purchases"] = { isNumeric = true, tiebreaker = "name"},
         ["online"] = { isNumeric = true, tiebreaker = "name"},
         ["joined"] = { isNumeric = true, tiebreaker = "name"},
         ["rankIndex"] = { isNumeric = true, tiebreaker = "name"},
@@ -110,9 +113,8 @@ function LeoGuildManagerMemberList:New(control)
     return self
 end

-
 local function updateEndangered()
-    LeoGuildManagerWindowPurgePanelEndangeredCounter:SetText("Selected: " .. #LeoGuildManager.endangered)
+    LeoGuildManagerWindowPurgePanelListResult:SetText("Selected: " .. #LeoGuildManager.endangered .. " / " .. purgeTotal)
     if #LeoGuildManager.endangered > 0 then
         LeoGuildManagerWindowPurgePanelDemoteButton:SetEnabled(true)
         LeoGuildManagerWindowPurgePanelKickButton:SetEnabled(true)
@@ -148,6 +150,22 @@ local function removeEndangered(member, control)
     end
 end

+local function promoteNext()
+    local guildId = LeoGuildManager.GetGuildId(LeoGuildManager.globalData.selectedGuild)
+    for i, member in pairs(LeoGuildManager.endangered) do
+        LeoGuildManager.log("Promoting " .. member .. " ...")
+        GuildPromote(guildId, member)
+        table.remove(LeoGuildManager.endangered, i)
+        removeEndangered(member)
+
+        LeoGuildManager.UpdateMemberRank(guildId, member)
+
+        LeoGuildManagerMemberList:RefreshData()
+        zo_callLater(promoteNext, 1000)
+        return
+    end
+end
+
 local function demoteNext()
     local guildId = LeoGuildManager.GetGuildId(LeoGuildManager.globalData.selectedGuild)
     for i, member in pairs(LeoGuildManager.endangered) do
@@ -192,6 +210,20 @@ function LeoGuildManager.DemoteAllClick(control, button, upInside)
     end)
 end

+function LeoGuildManager.PromoteAllClick(control, button, upInside)
+
+    local guildId = LeoGuildManager.GetGuildId(LeoGuildManager.globalData.selectedGuild)
+    if not DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_PROMOTE) then
+        LeoGuildManager.log("|cFF2222You don't have permission to promote members of this guild.|r")
+        return
+    end
+
+    local LAM = LibStub("LibAddonMenu-2.0")
+    LAM.util.ShowConfirmationDialog("Confirmation", "Do you really want to promote ALL selected members???", function()
+        zo_callLater(promoteNext, 1000)
+    end)
+end
+
 function LeoGuildManager.KickAllClick(control, button, upInside)

     local guildId = LeoGuildManager.GetGuildId(LeoGuildManager.globalData.selectedGuild)
@@ -269,6 +301,7 @@ function LeoGuildManagerMemberList:SetupEntry(control, data)
     local guildId = LeoGuildManager.GetGuildId(LeoGuildManager.globalData.selectedGuild)
     local canScan = LeoGuildManager.CanScanBankHistory(guildId)
     local integrationLoaded = LeoGuildManager.HasIntegrationAddonsLoaded()
+    local ATTLoaded = LeoGuildManager.HasIntegrationAddonsLoaded(2)

     control.checkbox = GetControl(control, "Checkbox")
     if data.endangered then
@@ -296,6 +329,13 @@ function LeoGuildManagerMemberList:SetupEntry(control, data)
         control.sales:SetText("-")
     end

+    control.purchases = GetControl(control, "Purchases")
+    if ATTLoaded then
+        control.purchases:SetText(LeoGuildManager.formatNumber(data.purchases))
+    else
+        control.purchases:SetText("-")
+    end
+
     control.online = GetControl(control, "Online")
     control.online:SetText(LeoGuildManager.GetTime(data.online))

@@ -338,9 +378,11 @@ function LeoGuildManagerMemberList:ColorRow(control, data, mouseIsOver)
     local guildId = LeoGuildManager.GetGuildId(LeoGuildManager.globalData.selectedGuild)
     local canScan = LeoGuildManager.CanScanBankHistory(guildId)
     local integrationLoaded = LeoGuildManager.HasIntegrationAddonsLoaded()
+    local ATTLoaded = LeoGuildManager.HasIntegrationAddonsLoaded(2)

     local ticketsThreshold = guildData.tickets * 1000
     local salesThreshold = guildData.sales * 1000
+    local purchasesThreshold = guildData.purchases * 1000
     local offlineThreshold = guildData.inactivity * LeoGuildManager.SECONDS_IN_DAY

     local child = GetControl(control, "Name")
@@ -366,6 +408,20 @@ function LeoGuildManagerMemberList:ColorRow(control, data, mouseIsOver)
         child:SetColor(1,1,1)
     end

+    child = GetControl(control, "Purchases")
+    child:SetColor(1,1,1)
+    if ATTLoaded then
+        if purchasesThreshold > 0 then
+            if data.purchases < purchasesThreshold then
+                child:SetColor(1,0,0)
+            else
+                child:SetColor(0,1,0)
+            end
+        end
+    else
+        child:SetColor(1,1,1)
+    end
+
     child = GetControl(control, "Online")
     child:SetColor(0,1,0)
     if offlineThreshold > 0 and data.online > 0 and data.online > offlineThreshold then
@@ -382,6 +438,7 @@ function LeoGuildManagerMemberList:FilterScrollList()

     local ticketsThreshold = guildData.tickets * 1000
     local salesThreshold = guildData.sales * 1000
+    local purchasesThreshold = guildData.purchases * 1000
     local offlineThreshold = guildData.inactivity * LeoGuildManager.SECONDS_IN_DAY
     local ignoreRank = guildData.ignoreRank
     local ignoreNew = guildData.ignoreNew * LeoGuildManager.SECONDS_IN_DAY
@@ -399,6 +456,9 @@ function LeoGuildManagerMemberList:FilterScrollList()
         if canAdd and canScan and ticketsThreshold > 0 and data.deposits >= ticketsThreshold then
             canAdd = false
         end
+        if canAdd and canScan and purchasesThreshold > 0 and data.purchases >= purchasesThreshold then
+            canAdd = false
+        end

         --Add even if sold a lot??
         if not canAdd and offlineThreshold > 0 and data.online > 0 and data.online > offlineThreshold then
@@ -418,8 +478,8 @@ function LeoGuildManagerMemberList:FilterScrollList()
             table.insert(scrollData, ZO_ScrollList_CreateDataEntry(1, data))
         end
     end
-    LeoGuildManagerWindowPurgePanelListResult:SetText("Total: " .. #scrollData)
-    LeoGuildManagerWindowPurgePanelEndangeredCounter:SetText("Selected: 0")
+    purgeTotal = #scrollData
+    LeoGuildManagerWindowPurgePanelListResult:SetText("Selected: 0 / " .. purgeTotal)
 end

 local function getStartOfDay(relativeDay)
@@ -492,10 +552,10 @@ local function getSalesData(memberName, cycle, start, finish)
                 MasterMerchant.guildSales and MasterMerchant.guildSales[guildName] and
                 MasterMerchant.guildSales[guildName].sellers and MasterMerchant.guildSales[guildName].sellers[memberName] and
                 MasterMerchant.guildSales[guildName].sellers[memberName].sales[cycle] then
-            return MasterMerchant.guildSales[guildName].sellers[memberName].sales[cycle]
+            return 0, MasterMerchant.guildSales[guildName].sellers[memberName].sales[cycle]
         end
     elseif LeoGuildManager.globalData.settings.integration == LeoGuildManager.integrations[2] then
-        return select(2, ArkadiusTradeTools.Modules.Sales:GetPurchasesAndSalesVolumes(guildName, memberName, start, finish))
+        return ArkadiusTradeTools.Modules.Sales:GetPurchasesAndSalesVolumes(guildName, memberName, start, finish)
     end

     return 0
@@ -578,10 +638,13 @@ function LeoGuildManager.ListPurge()
     if integrationLoaded then
         for i = 1, #LeoGuildManager.members do
             local name = LeoGuildManager.members[i].name
-            local sale = getSalesData(name, cycle, start, finish)
+            local purchase, sale = getSalesData(name, cycle, start, finish)
             if sale > 0 then
                 LeoGuildManager.AddSale(name, sale)
             end
+            if purchase > 0 then
+                LeoGuildManager.AddPurchase(name, purchase)
+            end
         end
     end

@@ -701,7 +764,7 @@ function LeoGuildManagerUI.TooltipSales(control, visible)
                 local start, finish = getStartFinishFromCycle(cycleId)

                 if start ~= nil and finish ~= nil then
-                    local sale = getSalesData(name, cycleId, start, finish)
+                    local _, sale = getSalesData(name, cycleId, start, finish)
                     if sale > 0 then
                         addLine(InformationTooltip, cycleData.name .. ": |c"..LeoGuildManager.color.hex.white.. LeoGuildManager.formatNumber(sale).."|r")
                     end
diff --git a/Settings.lua b/Settings.lua
index 6d02b6c..2b9728a 100644
--- a/Settings.lua
+++ b/Settings.lua
@@ -179,6 +179,17 @@ function LeoGuildManagerSettings:CreatePanel()
                                 min = 0,
                                 max = 120,
                                 default = 30,
+                            },{
+                                type = "slider",
+                                name = "Purchases (in k)",
+                                tooltip = "Required value of purchases. Available only for ATT",
+                                width = "half",
+                                disabled = function() return not LeoGuildManager.HasIntegrationAddonsLoaded(2) end,
+                                getFunc = function() return LeoGuildManager.GetPurgePurchases(guild) end,
+                                setFunc = function(value) LeoGuildManager.SetPurgePurchases(guild, value) end,
+                                min = 0,
+                                max = 1000,
+                                default = 0,
                             }
                         }
                     },{