changeset 42:1ff3b83b104c

Added a dialog to allow the user to send COD mail without a tracking number
author Asa Ayers <Asa.Ayers@Gmail.com>
date Mon, 19 Jul 2010 21:42:44 -0700
parents 36eb72329d69
children 60ab9a4d2de1
files CHANGELOG.txt Modules/Events.lua
diffstat 2 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Mon Jul 19 20:56:05 2010 -0700
+++ b/CHANGELOG.txt	Mon Jul 19 21:42:44 2010 -0700
@@ -1,6 +1,7 @@
 2010-07-18  Asa Ayers  <Asa.Ayers@Gmail.com>
 
 - Implemented COD mail (Ticket #1) and updated the way postage was counted so that if you mail multiple items at once, they will all have the postage counted. I also removed the 30c for postage from how QA thresholds are calculated now that they will be counted every time.
+- Added a dialog to allow the user to send COD mail without a tracking number.
 
 2010-07-18  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/Modules/Events.lua	Mon Jul 19 20:56:05 2010 -0700
+++ b/Modules/Events.lua	Mon Jul 19 21:42:44 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