You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KitController.asp 14KB

8 months ago
8 months ago
8 months ago
8 months ago
6 months ago
6 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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. dim id : id = Request.QueryString("Id")
  94. set Model = new SwitchBoard_ViewModel_Class
  95. set Model.Kit = KitRepository.SwitchBoardEditFindById(id)
  96. set Model.Labels = KitLabelsRepository.Find(Array("KitId =?",id),empty)
  97. Model.Title = "Kit for "
  98. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  99. %> <!--#include file="../../Views/Kit/SwitchBoardEdit.asp"--> <%
  100. End Sub
  101. Public Sub DownloadTrackingkitSnailWorksPDF
  102. dim id : id = Request.QueryString("Id")
  103. ReportManager.Filename = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\Label_Report.rep"
  104. if dev = true Then
  105. 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;"
  106. else
  107. ReportManager.SetDatabaseConnectionString "TRACKINGKITLABELS","Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;"
  108. End If
  109. ReportManager.Preview = false
  110. ReportManager.ShowProgress = false
  111. ReportManager.ShowPrintDialog = false
  112. ReportManager.SetParamValue "PBKITID", CInt(id)
  113. ReportManager.SaveToPdf Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\" & id & ".pdf",1
  114. Dim objStream:Set objStream = Server.CreateObject("ADODB.Stream")
  115. objStream.Type = 1 'adTypeBinary
  116. objStream.Open
  117. objStream.LoadFromFile(Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\" & id & ".pdf")
  118. Response.ContentType = "application/octet-stream"
  119. Response.Addheader "Content-Disposition", "attachment; filename=" & id & ".pdf"
  120. Response.BinaryWrite objStream.Read
  121. objStream.Close
  122. Set objStream = Nothing
  123. End Sub
  124. Public Sub DownloadTrackingkitSnailWorks
  125. dim id : id = Request.QueryString("Id")
  126. dim export: set export = SnailWorksRepository.GetSnailWorksExportById(id)
  127. if export.DetailRecords.Count > 0 Then
  128. If Not Server.CreateObject("Scripting.FileSystemObject").FolderExists(server.mappath("/uploads/")) Then : Server.CreateObject("Scripting.FileSystemObject").CreateFolder(server.mappath("/uploads/")):End If
  129. dim objExportFile: Set objExportFile = Server.CreateObject("Scripting.FileSystemObject").CreateTextFile(server.mappath("/uploads/" & id & ".csv"),2)
  130. With objExportFile
  131. .Write """" & export.Header.RecordType & ""","
  132. .Write """" & export.Header.Version & ""","
  133. .Write """" & export.Header.UserId & ""","
  134. .Write """" & export.Header.ClientName & ""","
  135. .Write """" & export.Header.ParentClientName & ""","
  136. .Write """" & export.Header.JobName & ""","
  137. .Write """" & export.Header.JobDescription & ""","
  138. .Write """" & export.Header.SplitName & ""","
  139. .Write """" & export.Header.SplitDescription & ""","
  140. .Write """" & export.Header.PieceType & ""","
  141. .Write """" & export.Header.MailDate & ""","
  142. .Write """" & export.Header.UploadType & ""","
  143. .Write """" & export.Header.TrackedQuanity & ""","
  144. .Write """" & export.Header.PiecesMailed & ""","
  145. .Write """" & export.Header.TargetInHomeDateStart & ""","
  146. .Write """" & export.Header.TargetInHomeDateEnd & ""","
  147. .Write """" & export.Header.ConfirmationEmail & ""","
  148. .Write """" & export.Header.JobId & ""","
  149. .Write """" & export.Header.SplitId & ""","
  150. .Write """" & export.Header.TypeOfTracking & ""","
  151. .Write """" & export.Header.ReturnedPostalRoutingCode & ""","
  152. .Write """" & export.Header.ReportId1 & ""","
  153. .Write """" & export.Header.Report1Email & ""","
  154. .Write """" & export.Header.ReportId2 & ""","
  155. .Write """" & export.Header.Report2Email & ""","
  156. .Write """" & export.Header.INFOONLY & """"
  157. .Write vbCrLf
  158. dim it:set it = export.DetailRecords.Iterator
  159. dim records
  160. while it.HasNext
  161. set records = it.GetNext()
  162. .Write """" & records.RecordType & ""","
  163. .Write """" & records.CustomerUniqueIdentifier & ""","
  164. .Write """" & records.IMB & ""","
  165. .Write """" & records.Greeting & ""","
  166. .Write """" & records.FirstName & ""","
  167. .Write """" & records.MI & ""","
  168. .Write """" & records.LastName & ""","
  169. .Write """" & records.Suffix & ""","
  170. .Write """" & records.FullName & ""","
  171. .Write """" & records.Company & ""","
  172. .Write """" & records.Title & ""","
  173. .Write """" & records.Address1 & ""","
  174. .Write """" & records.Address2 & ""","
  175. .Write """" & records.City & ""","
  176. .Write """" & records.State & ""","
  177. .Write """" & records.Zip & ""","
  178. .Write """" & records.UserDefined1 & ""","
  179. .Write """" & records.UserDefined2 & ""","
  180. .Write """" & records.UserDefined3 & ""","
  181. .Write """" & records.UserDefinedIdentifier4 & ""","
  182. .Write """" & records.UserDefinedIdentifier5 & ""","
  183. .Write """" & records.SeedIndicator & ""","
  184. .Write """" & records.InductionPoint & ""","
  185. .Write """" & records.InductionDate & ""","
  186. .Write """" & records.InBoundIMB & ""","
  187. .Write """" & records.IMCB & ""","
  188. .Write """" & records.IMTB & """" & vbCRLF
  189. Wend
  190. End With
  191. objExportFile.Close
  192. Dim objStream:Set objStream = Server.CreateObject("ADODB.Stream")
  193. objStream.Type = 1 'adTypeBinary
  194. objStream.Open
  195. objStream.LoadFromFile(server.mappath("/uploads/" & id & ".csv"))
  196. Response.ContentType = "application/octet-stream"
  197. Response.Addheader "Content-Disposition", "attachment; filename=" & id & ".csv"
  198. Response.BinaryWrite objStream.Read
  199. objStream.Close
  200. Set objStream = Nothing
  201. End If
  202. End Sub
  203. Public Sub Edit
  204. dim id : id = Request.QueryString("Id")
  205. set Model = new Edit_ViewModel_Class
  206. set Model.Kit = KitRepository.FindByID(id)
  207. Model.Title = "Edit Kit"
  208. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  209. %> <!--#include file="../../Views/Kit/Edit.asp"--> <%
  210. Flash.Success = "Kit Updated."
  211. End Sub
  212. Public Sub EditPost
  213. MVC.RequirePost
  214. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  215. dim ID : ID = Request.Form("Id")
  216. dim model : set model = KitRepository.FindByID(ID)
  217. set model = Automapper.AutoMap(Request.Form, model)
  218. 'model.Validate
  219. 'If model.Validator.HasErrors then
  220. FormCache.SerializeForm "EditKit", Request.Form
  221. ' Flash.Errors = model.Validator.Errors
  222. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  223. 'Else
  224. KitRepository.Update model
  225. FormCache.ClearForm "EditKit"
  226. Flash.Success = "Kit updated."
  227. MVC.RedirectToAction "Index"
  228. 'End If
  229. End Sub
  230. Public Sub CreateTrackingKit
  231. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  232. dim ID : ID = Request.QueryString("Id")
  233. dim model : set model = new Create_ViewModel_Class
  234. model.Title = "Create Kit "
  235. model.JCode = ID
  236. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  237. set model.Jurisdiction = ugh.pop()
  238. 'If Not form_params Is Nothing then
  239. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  240. 'Else
  241. ' set Model = new Create_ViewModel_Class
  242. 'End If
  243. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  244. %> <!--#include file="../../Views/Kit/CreateTrackingKit.asp"--> <%
  245. End Sub
  246. Public Sub Create
  247. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  248. dim ID : ID = Request.QueryString("Id")
  249. dim model : set model = new Create_ViewModel_Class
  250. model.Title = "Create Kit "
  251. model.JCode = ID
  252. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  253. set model.Jurisdiction = ugh.pop()
  254. 'If Not form_params Is Nothing then
  255. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  256. 'Else
  257. ' set Model = new Create_ViewModel_Class
  258. 'End If
  259. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  260. %> <!--#include file="../../Views/Kit/Create.asp"--> <%
  261. End Sub
  262. Public Sub CreatePost
  263. MVC.RequirePost
  264. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  265. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  266. 'new_Kit_model.Validator.Validate
  267. 'If new_Kit_model.Validator.HasErrors then
  268. ' FormCache.SerializeForm "NewKit", Request.Form
  269. ' Flash.Errors = new_Kit_model.Validator.Errors
  270. ' MVC.RedirectToAction "Create"
  271. 'Else
  272. KitRepository.AddNew new_Kit_model
  273. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  274. ' FormCache.ClearForm "NewKit"
  275. Flash.Success = "Kit added."
  276. MVC.RedirectToAction "Index"
  277. 'End If
  278. End Sub
  279. Public Sub CreateTrackingKitPost
  280. MVC.RequirePost
  281. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  282. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  283. 'new_Kit_model.Validator.Validate
  284. 'If new_Kit_model.Validator.HasErrors then
  285. ' FormCache.SerializeForm "NewKit", Request.Form
  286. ' Flash.Errors = new_Kit_model.Validator.Errors
  287. ' MVC.RedirectToAction "Create"
  288. 'Else
  289. KitRepository.AddNew new_Kit_model
  290. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  291. ' FormCache.ClearForm "NewKit"
  292. Flash.Success = "Kit added."
  293. MVC.RedirectToAction "Index"
  294. 'End If
  295. End Sub
  296. Public Sub Delete
  297. dim id : id = Request.QueryString("Id")
  298. set Model = new Delete_ViewModel_Class
  299. set Model.Kit = KitRepository.FindByID(id)
  300. Model.Title = "Delete Kit"
  301. HTMLSecurity.SetAntiCSRFToken "KitDeleteForm"
  302. %> <!--#include file="../../Views/Kit/Delete.asp"--> <%
  303. End Sub
  304. Public Sub DeletePost
  305. MVC.RequirePost
  306. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create"
  307. dim id : id = Request.Form("Id")
  308. KitRepository.Delete id
  309. Flash.Success = "Kit deleted."
  310. MVC.RedirectToAction "Index"
  311. End Sub
  312. End Class
  313. MVC.Dispatch
  314. %>

Powered by TurnKey Linux.