Mercurial > wow > itemauditor
comparison Modules/Events.lua @ 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 | 5273038322d7 |
| children | 5e981c1df761 |
comparison
equal
deleted
inserted
replaced
| 41:36eb72329d69 | 42:1ff3b83b104c |
|---|---|
| 48 end | 48 end |
| 49 end | 49 end |
| 50 | 50 |
| 51 local attachedItems = {} | 51 local attachedItems = {} |
| 52 local Orig_SendMail = SendMail | 52 local Orig_SendMail = SendMail |
| 53 local skipCODTracking = false | |
| 54 | |
| 55 StaticPopupDialogs["ItemAuditor_Send_COD_without_tracking_number"] = { | |
| 56 text = "ItemAuditor cannot track COD mail with multiple item types attached. Do you want to send this mail without tracking?", | |
| 57 button1 = "Yes", | |
| 58 button2 = "No", | |
| 59 OnAccept = function() | |
| 60 skipCODTracking = true | |
| 61 end, | |
| 62 timeout = 0, | |
| 63 whileDead = true, | |
| 64 hideOnEscape = true, | |
| 65 } | |
| 53 | 66 |
| 54 function SendMail(recipient, subject, body, ...) | 67 function SendMail(recipient, subject, body, ...) |
| 55 local self = ItemAuditor | 68 local self = ItemAuditor |
| 56 self:GenerateBlankOutbox() | 69 self:GenerateBlankOutbox() |
| 57 | 70 |
| 78 local pricePerStack = GetSendMailPrice() / totalStacks | 91 local pricePerStack = GetSendMailPrice() / totalStacks |
| 79 for link, data in pairs(attachedItems) do | 92 for link, data in pairs(attachedItems) do |
| 80 data.price = pricePerStack * data.stacks | 93 data.price = pricePerStack * data.stacks |
| 81 end | 94 end |
| 82 | 95 |
| 83 if self.mailOutbox.COD > 0 then | 96 if self.mailOutbox.COD > 0 and skipCODTracking then |
| 97 | |
| 98 elseif self.mailOutbox.COD > 0 then | |
| 84 if self:tcount(attachedItems) > 1 then | 99 if self:tcount(attachedItems) > 1 then |
| 85 self:Print("ERROR: ItemAuditor can't track COD mail with more than one item type.") | |
| 86 self:GenerateBlankOutbox() | 100 self:GenerateBlankOutbox() |
| 87 -- I need to make a prompt so the user can send the mail without interference | 101 local vararg = ... |
| 102 StaticPopupDialogs["ItemAuditor_Send_COD_without_tracking_number"].OnAccept = function() | |
| 103 skipCODTracking = true | |
| 104 SendMail(recipient, subject, body, vararg) | |
| 105 skipCODTracking = false | |
| 106 end | |
| 107 StaticPopup_Show ("ItemAuditor_Send_COD_without_tracking_number"); | |
| 88 return | 108 return |
| 89 end | 109 end |
| 90 self:Debug("COD mail") | 110 self:Debug("COD mail") |
| 91 | 111 |
| 92 subject = format("[IA: %s] %s", self.mailOutbox.key, subject) | 112 subject = format("[IA: %s] %s", self.mailOutbox.key, subject) |
| 104 | 124 |
| 105 return Orig_SendMail(recipient, subject, body, ...) | 125 return Orig_SendMail(recipient, subject, body, ...) |
| 106 end | 126 end |
| 107 | 127 |
| 108 function addon:MAIL_SUCCESS(event) | 128 function addon:MAIL_SUCCESS(event) |
| 129 skipCODTracking = false | |
| 109 for link, data in pairs(attachedItems) do | 130 for link, data in pairs(attachedItems) do |
| 110 self:SaveValue(link, data.price, data.count) | 131 self:SaveValue(link, data.price, data.count) |
| 111 end | 132 end |
| 112 if self.mailOutbox.COD > 0 then | 133 if self.mailOutbox.COD > 0 then |
| 113 self:Debug(format("MAIL_SUCCESS %d [To: %s] [Subject: %s] [COD: %s]", self.mailOutbox.key, self.mailOutbox.to, self.mailOutbox.subject, self.mailOutbox.COD)) | 134 self:Debug(format("MAIL_SUCCESS %d [To: %s] [Subject: %s] [COD: %s]", self.mailOutbox.key, self.mailOutbox.to, self.mailOutbox.subject, self.mailOutbox.COD)) |
