Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

376 wiersze
15KB

  1. <% Option Explicit %>
  2. <!--#include file="../../include_all.asp"-->
  3. <!--#include file="../../ViewModels/KitViewModels.asp"-->
  4. <%
  5. Class KitController
  6. Public Model
  7. Public Sub SwitchBoardIndex
  8. dim page_size : page_size = 10
  9. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  10. dim page_count, record_count
  11. set Model = new PagedIndex_ViewModel_Class
  12. Model.Title = "Tracking Kits"
  13. set Model.Kit = KitRepository.PagedIndexView(page_size, page_num, page_count, record_count)
  14. Model.CurrentPageNumber = page_num
  15. Model.PageSize = page_size
  16. Model.PageCount = page_count
  17. Model.RecordCount = record_count
  18. %> <!--#include file="../../Views/Kit/SwitchBoardIndex.asp"--> <%
  19. End Sub
  20. Public Sub SwitchBoardPurpleEnvelopsIndex
  21. dim page_size : page_size = 10
  22. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  23. dim page_count, record_count
  24. set Model = new SwitchBoard_PurpleEnvelopesViewModel_Class
  25. Model.Title = "Purple Envelope Kits"
  26. set Model.Kit = KitRepository.PagedPurpleEnvelopsIndexView(page_size, page_num, page_count, record_count)
  27. Model.CurrentPageNumber = page_num
  28. Model.PageSize = page_size
  29. Model.PageCount = page_count
  30. Model.RecordCount = record_count
  31. %> <!--#include file="../../Views/Kit/SwitchBoardPurpleEnvelopeIndex.asp"--> <%
  32. End Sub
  33. Public Sub SwitchBoardPurpleEnvelopeEditPost
  34. MVC.RequirePost
  35. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  36. dim ID : ID = Request.Form("Id")
  37. dim model : set model = KitRepository.FindByID(ID)
  38. set model = Automapper.AutoMap(Request.Form, model)
  39. if Request.Form("InBoundTracking") = "on" Then
  40. model.InboundSTID = SettingsRepository.FindByName("Inbound STID")
  41. end if
  42. model.Status = "Ready to Assign Labels"
  43. 'model.Validate
  44. 'If model.Validator.HasErrors then
  45. FormCache.SerializeForm "EditKit", Request.Form
  46. ' Flash.Errors = model.Validator.Errors
  47. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  48. 'Else
  49. KitRepository.Update model
  50. FormCache.ClearForm "EditKit"
  51. Flash.Success = "Kit updated."
  52. MVC.RedirectToAction "Index"
  53. 'End If
  54. End Sub
  55. Public Sub SwitchBoardPurpleEnvelopeEdit
  56. dim id : id = Request.QueryString("Id")
  57. set Model = new SwitchBoard_ViewModel_Class
  58. set Model.Kit = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(id)
  59. set Model.Labels = InkjetRecordsRepository.Find(Array("KitId =?",id),empty)
  60. set Model.StidDropDown = SettingsRepository.GetStidDropDownRS()
  61. Model.Title = "Purple Envelopes for "
  62. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  63. %> <!--#include file="../../Views/Kit/SwitchBoardPurpleEnvelopeEdit.asp"--> <%
  64. End Sub
  65. Public Sub Index
  66. dim page_size : page_size = 10
  67. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  68. dim page_count, record_count
  69. set Model = new PagedIndex_ViewModel_Class
  70. Model.Title = "Tracking Kits"
  71. set Model.Kit = KitRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count)
  72. Model.CurrentPageNumber = page_num
  73. Model.PageSize = page_size
  74. Model.PageCount = page_count
  75. Model.RecordCount = record_count
  76. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  77. End Sub
  78. Public Sub Search
  79. dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))
  80. dim page_size : page_size = 10
  81. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  82. dim page_count, record_count
  83. set Model = new PagedIndex_ViewModel_Class
  84. Model.Title = "Kit"
  85. set Model.Kit = KitRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JobNumber","%" & searchValue & "%","Jcode","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count)
  86. Model.CurrentPageNumber = page_num
  87. Model.PageSize = page_size
  88. Model.PageCount = page_count
  89. Model.RecordCount = record_count
  90. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  91. End Sub
  92. Public Sub SwitchBoardEdit
  93. Flash.ShowSuccessIfPresent
  94. dim id : id = Request.QueryString("Id")
  95. set Model = new SwitchBoard_ViewModel_Class
  96. set Model.Kit = KitRepository.SwitchBoardEditFindById(id)
  97. set Model.Labels = KitLabelsRepository.Find(Array("KitId =?",id),empty)
  98. Model.Title = "Kit for "
  99. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  100. %> <!--#include file="../../Views/Kit/SwitchBoardEdit.asp"--> <%
  101. End Sub
  102. Public Sub ExportTrackingLabels(id)
  103. dim KitInfo : Set KitInfo = KitRepository.FindByID(id)
  104. dim JurisdictionInfo : Set JurisdictionInfo = JurisdictionRepository.FindByJCode(KitInfo.Jcode)
  105. ReportManager.Filename = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\Label_Report.rep"
  106. if dev = true Then
  107. ReportManager.SetDatabaseConnectionString "TRACKINGKITLABELS","Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata - Copy.mdb;"
  108. else
  109. ReportManager.SetDatabaseConnectionString "TRACKINGKITLABELS","Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;"
  110. End If
  111. ReportManager.Preview = false
  112. ReportManager.ShowProgress = false
  113. ReportManager.ShowPrintDialog = false
  114. ReportManager.SetParamValue "PBKITID", CInt(id)
  115. if FSO.FolderExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) = False then
  116. FSO.CreateFolder(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name)
  117. end if
  118. if FSO.FileExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_labels.pdf") then
  119. FSO.DeleteFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_labels.pdf")
  120. end if
  121. ReportManager.SaveToPdf Request.ServerVariables("APPL_PHYSICAL_PATH") & "\Data\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & " Labels.pdf",1
  122. FSO.MoveFile Request.ServerVariables("APPL_PHYSICAL_PATH") & "\Data\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & " Labels.pdf" , ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_labels.pdf"
  123. End Sub
  124. Public Sub ExportSnailWorksTracking(id)
  125. dim KitInfo : Set KitInfo = KitRepository.FindByID(id)
  126. dim JurisdictionInfo : Set JurisdictionInfo = JurisdictionRepository.FindByJCode(KitInfo.Jcode)
  127. if FSO.FolderExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name) = False then
  128. FSO.CreateFolder(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name)
  129. end if
  130. if FSO.FileExists(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv") then
  131. FSO.DeleteFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv")
  132. end if
  133. dim export: set export = SnailWorksRepository.GetSnailWorksExportById(id)
  134. if export.DetailRecords.Count > 0 Then
  135. dim objExportFile: Set objExportFile = FSO.CreateTextFile(ExportDirectory & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "\" & JurisdictionInfo.JCode & "-" & JurisdictionInfo.Name & "_SW_EXPORT.csv",2)
  136. With objExportFile
  137. .Write """" & export.Header.RecordType & ""","
  138. .Write """" & export.Header.Version & ""","
  139. .Write """" & export.Header.UserId & ""","
  140. .Write """" & export.Header.ClientName & ""","
  141. .Write """" & export.Header.ParentClientName & ""","
  142. .Write """" & export.Header.JobName & ""","
  143. .Write """" & export.Header.JobDescription & ""","
  144. .Write """" & export.Header.SplitName & ""","
  145. .Write """" & export.Header.SplitDescription & ""","
  146. .Write """" & export.Header.PieceType & ""","
  147. .Write """" & export.Header.MailDate & ""","
  148. .Write """" & export.Header.UploadType & ""","
  149. .Write """" & export.Header.TrackedQuanity & ""","
  150. .Write """" & export.Header.PiecesMailed & ""","
  151. .Write """" & export.Header.TargetInHomeDateStart & ""","
  152. .Write """" & export.Header.TargetInHomeDateEnd & ""","
  153. .Write """" & export.Header.ConfirmationEmail & ""","
  154. .Write """" & export.Header.JobId & ""","
  155. .Write """" & export.Header.SplitId & ""","
  156. .Write """" & export.Header.TypeOfTracking & ""","
  157. .Write """" & export.Header.ReturnedPostalRoutingCode & ""","
  158. .Write """" & export.Header.ReportId1 & ""","
  159. .Write """" & export.Header.Report1Email & ""","
  160. .Write """" & export.Header.ReportId2 & ""","
  161. .Write """" & export.Header.Report2Email & ""","
  162. .Write """" & export.Header.INFOONLY & """"
  163. .Write vbCrLf
  164. dim it:set it = export.DetailRecords.Iterator
  165. dim records
  166. while it.HasNext
  167. set records = it.GetNext()
  168. .Write """" & records.RecordType & ""","
  169. .Write """" & records.CustomerUniqueIdentifier & ""","
  170. .Write """" & records.IMB & ""","
  171. .Write """" & records.Greeting & ""","
  172. .Write """" & records.FirstName & ""","
  173. .Write """" & records.MI & ""","
  174. .Write """" & records.LastName & ""","
  175. .Write """" & records.Suffix & ""","
  176. .Write """" & records.FullName & ""","
  177. .Write """" & records.Company & ""","
  178. .Write """" & records.Title & ""","
  179. .Write """" & records.Address1 & ""","
  180. .Write """" & records.Address2 & ""","
  181. .Write """" & records.City & ""","
  182. .Write """" & records.State & ""","
  183. .Write """" & records.Zip & ""","
  184. .Write """" & records.UserDefined1 & ""","
  185. .Write """" & records.UserDefined2 & ""","
  186. .Write """" & records.UserDefined3 & ""","
  187. .Write """" & records.UserDefinedIdentifier4 & ""","
  188. .Write """" & records.UserDefinedIdentifier5 & ""","
  189. .Write """" & records.SeedIndicator & ""","
  190. .Write """" & records.InductionPoint & ""","
  191. .Write """" & records.InductionDate & ""","
  192. .Write """" & records.InBoundIMB & ""","
  193. .Write """" & records.IMCB & ""","
  194. .Write """" & records.IMTB & """" & vbCRLF
  195. Wend
  196. End With
  197. End If
  198. End Sub
  199. Public Sub Edit
  200. dim id : id = Request.QueryString("Id")
  201. set Model = new Edit_ViewModel_Class
  202. set Model.Kit = KitRepository.FindByID(id)
  203. Model.Title = "Edit Kit"
  204. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  205. %> <!--#include file="../../Views/Kit/Edit.asp"--> <%
  206. Flash.Success = "Kit Updated."
  207. End Sub
  208. Public Sub EditPost
  209. MVC.RequirePost
  210. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  211. dim ID : ID = Request.Form("Id")
  212. dim model : set model = KitRepository.FindByID(ID)
  213. set model = Automapper.AutoMap(Request.Form, model)
  214. 'model.Validate
  215. 'If model.Validator.HasErrors then
  216. FormCache.SerializeForm "EditKit", Request.Form
  217. ' Flash.Errors = model.Validator.Errors
  218. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  219. 'Else
  220. KitRepository.Update model
  221. FormCache.ClearForm "EditKit"
  222. Flash.Success = "Kit updated."
  223. MVC.RedirectToAction "Index"
  224. 'End If
  225. End Sub
  226. Public Sub CreateTrackingKit
  227. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  228. dim ID : ID = Request.QueryString("Id")
  229. dim model : set model = new Create_ViewModel_Class
  230. model.Title = "Create Kit "
  231. model.JCode = ID
  232. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  233. set model.Jurisdiction = ugh.pop()
  234. 'If Not form_params Is Nothing then
  235. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  236. 'Else
  237. ' set Model = new Create_ViewModel_Class
  238. 'End If
  239. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  240. %> <!--#include file="../../Views/Kit/CreateTrackingKit.asp"--> <%
  241. End Sub
  242. Public Sub Create
  243. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  244. dim ID : ID = Request.QueryString("Id")
  245. dim model : set model = new Create_ViewModel_Class
  246. model.Title = "Create Kit "
  247. model.JCode = ID
  248. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  249. set model.Jurisdiction = ugh.pop()
  250. 'If Not form_params Is Nothing then
  251. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  252. 'Else
  253. ' set Model = new Create_ViewModel_Class
  254. 'End If
  255. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  256. %> <!--#include file="../../Views/Kit/Create.asp"--> <%
  257. End Sub
  258. Public Sub CreatePost
  259. MVC.RequirePost
  260. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  261. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  262. 'new_Kit_model.Validator.Validate
  263. 'If new_Kit_model.Validator.HasErrors then
  264. ' FormCache.SerializeForm "NewKit", Request.Form
  265. ' Flash.Errors = new_Kit_model.Validator.Errors
  266. ' MVC.RedirectToAction "Create"
  267. 'Else
  268. KitRepository.AddNew new_Kit_model
  269. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  270. ' FormCache.ClearForm "NewKit"
  271. ExportTrackingLabels(new_Kit_model.ID)
  272. ExportSnailWorksTracking(new_Kit_model.ID)
  273. Flash.Success = "Kit added."
  274. MVC.RedirectToAction "Index"
  275. 'End If
  276. End Sub
  277. Public Sub CreateTrackingKitPost
  278. MVC.RequirePost
  279. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  280. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  281. 'new_Kit_model.Validator.Validate
  282. 'If new_Kit_model.Validator.HasErrors then
  283. ' FormCache.SerializeForm "NewKit", Request.Form
  284. ' Flash.Errors = new_Kit_model.Validator.Errors
  285. ' MVC.RedirectToAction "Create"
  286. 'Else
  287. KitRepository.AddNew new_Kit_model
  288. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  289. ' FormCache.ClearForm "NewKit"
  290. Flash.Success = "Kit added."
  291. MVC.RedirectToAction "Index"
  292. 'End If
  293. End Sub
  294. Public Sub Delete
  295. dim id : id = Request.QueryString("Id")
  296. set Model = new Delete_ViewModel_Class
  297. set Model.Kit = KitRepository.FindByID(id)
  298. Model.Title = "Delete Kit"
  299. HTMLSecurity.SetAntiCSRFToken "KitDeleteForm"
  300. %> <!--#include file="../../Views/Kit/Delete.asp"--> <%
  301. End Sub
  302. Public Sub DeletePost
  303. MVC.RequirePost
  304. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create"
  305. dim id : id = Request.Form("Id")
  306. KitRepository.Delete id
  307. Flash.Success = "Kit deleted."
  308. MVC.RedirectToAction "Index"
  309. End Sub
  310. End Class
  311. MVC.Dispatch
  312. %>

Powered by TurnKey Linux.