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.

376 lignes
14KB

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

Powered by TurnKey Linux.