diff Modules/Events.lua @ 48:508110e7c8ee

Merged my fix for the changelog
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 20 Jul 2010 00:20:15 -0700
parents 1ff3b83b104c
children 5e981c1df761
line wrap: on
line diff
--- a/Modules/Events.lua	Tue Jul 20 00:18:10 2010 -0700
+++ b/Modules/Events.lua	Tue Jul 20 00:20:15 2010 -0700
@@ -50,6 +50,19 @@
 
 local attachedItems = {}
 local Orig_SendMail = SendMail
+local skipCODTracking = false
+
+StaticPopupDialogs["ItemAuditor_Send_COD_without_tracking_number"] = {
+	text = "ItemAuditor cannot track COD mail with multiple item types attached. Do you want to send this mail without tracking?",
+	button1 = "Yes",
+	button2 = "No",
+	OnAccept = function()
+		skipCODTracking = true
+	end,
+	timeout = 0,
+	whileDead = true,
+	hideOnEscape = true,
+}
 
 function SendMail(recipient, subject, body, ...)
 	local self = ItemAuditor
@@ -80,11 +93,18 @@
 		data.price = pricePerStack * data.stacks
 	end
 	
-	if self.mailOutbox.COD > 0 then
+	if self.mailOutbox.COD > 0 and skipCODTracking then
+		
+	elseif self.mailOutbox.COD > 0 then
 		if self:tcount(attachedItems) > 1 then
-			self:Print("ERROR: ItemAuditor can't track COD mail with more than one item type.")
 			self:GenerateBlankOutbox()
-			-- I need to make a prompt so the user can send the mail without interference
+			local vararg = ...
+			StaticPopupDialogs["ItemAuditor_Send_COD_without_tracking_number"].OnAccept = function()
+				skipCODTracking = true
+				SendMail(recipient, subject, body, vararg)
+				skipCODTracking = false
+			end
+			StaticPopup_Show ("ItemAuditor_Send_COD_without_tracking_number");
 			return
 		end
 		self:Debug("COD mail")
@@ -106,6 +126,7 @@
 end
 
 function addon:MAIL_SUCCESS(event)
+	skipCODTracking = false
 	for link, data in pairs(attachedItems) do
 		self:SaveValue(link, data.price, data.count)
 	end