Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

340 lignes
13KB

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

Powered by TurnKey Linux.