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.

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

Powered by TurnKey Linux.