|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- <% Option Explicit %>
- <!--#include file="../../include_all.asp"-->
- <!--#include file="../../ViewModels/KitViewModels.asp"-->
- <%
- Class KitController
- Public Model
- Public Sub SwitchBoardIndex
-
- dim page_size : page_size = 10
- dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
- dim page_count, record_count
- set Model = new PagedIndex_ViewModel_Class
- Model.Title = "Tracking Kits"
- set Model.Kit = KitRepository.PagedIndexView(page_size, page_num, page_count, record_count)
- Model.CurrentPageNumber = page_num
- Model.PageSize = page_size
- Model.PageCount = page_count
- Model.RecordCount = record_count
- %> <!--#include file="../../Views/Kit/SwitchBoardIndex.asp"--> <%
- End Sub
-
- Public Sub SwitchBoardPurpleEnvelopsIndex
-
- dim page_size : page_size = 10
- dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
- dim page_count, record_count
- set Model = new SwitchBoard_PurpleEnvelopesViewModel_Class
- Model.Title = "Purple Envelope Kits"
- set Model.Kit = KitRepository.PagedPurpleEnvelopsIndexView(page_size, page_num, page_count, record_count)
- Model.CurrentPageNumber = page_num
- Model.PageSize = page_size
- Model.PageCount = page_count
- Model.RecordCount = record_count
- %> <!--#include file="../../Views/Kit/SwitchBoardPurpleEnvelopeIndex.asp"--> <%
- End Sub
-
- Public Sub SwitchBoardPurpleEnvelopeEditPost
- MVC.RequirePost
- HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
- dim ID : ID = Request.Form("Id")
- dim model : set model = KitRepository.FindByID(ID)
- set model = Automapper.AutoMap(Request.Form, model)
- if Request.Form("InBoundTracking") = "on" Then
- model.InboundSTID = SettingsRepository.FindByName("Inbound STID")
- end if
-
-
- model.Status = "Ready to Assign Labels"
- 'model.Validate
- 'If model.Validator.HasErrors then
- FormCache.SerializeForm "EditKit", Request.Form
- ' Flash.Errors = model.Validator.Errors
- ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
- 'Else
- KitRepository.Update model
- FormCache.ClearForm "EditKit"
- Flash.Success = "Kit updated."
- MVC.RedirectToAction "Index"
- 'End If
- End Sub
-
- Public Sub SwitchBoardPurpleEnvelopeEdit
-
- dim id : id = Request.QueryString("Id")
- set Model = new SwitchBoard_ViewModel_Class
- set Model.Kit = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(id)
- set Model.Labels = InkjetRecordsRepository.Find(Array("KitId =?",id),empty)
- set Model.StidDropDown = SettingsRepository.GetStidDropDownRS()
- Model.Title = "Purple Envelopes for "
- HTMLSecurity.SetAntiCSRFToken "KitEditForm"
- %> <!--#include file="../../Views/Kit/SwitchBoardPurpleEnvelopeEdit.asp"--> <%
- End Sub
-
- Public Sub Index
-
- dim page_size : page_size = 10
- dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
- dim page_count, record_count
- set Model = new PagedIndex_ViewModel_Class
- Model.Title = "Tracking Kits"
- set Model.Kit = KitRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count)
- Model.CurrentPageNumber = page_num
- Model.PageSize = page_size
- Model.PageCount = page_count
- Model.RecordCount = record_count
- %> <!--#include file="../../Views/Kit/Index.asp"--> <%
-
- End Sub
- Public Sub Search
-
- dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))
- dim page_size : page_size = 10
- dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
- dim page_count, record_count
- set Model = new PagedIndex_ViewModel_Class
- Model.Title = "Kit"
- set Model.Kit = KitRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JobNumber","%" & searchValue & "%","Jcode","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count)
- Model.CurrentPageNumber = page_num
- Model.PageSize = page_size
- Model.PageCount = page_count
- Model.RecordCount = record_count
- %> <!--#include file="../../Views/Kit/Index.asp"--> <%
-
- End Sub
-
- Public Sub SwitchBoardEdit
-
- dim id : id = Request.QueryString("Id")
-
- set Model = new SwitchBoard_ViewModel_Class
- set Model.Kit = KitRepository.SwitchBoardEditFindById(id)
- set Model.Labels = KitLabelsRepository.Find(Array("KitId =?",id),empty)
- Model.Title = "Kit for "
- HTMLSecurity.SetAntiCSRFToken "KitEditForm"
- %> <!--#include file="../../Views/Kit/SwitchBoardEdit.asp"--> <%
- End Sub
- Public Sub DownloadTrackingkitSnailWorksPDF
-
- dim id : id = Request.QueryString("Id")
- ReportManager.Filename = Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\Label_Report.rep"
- if dev = true Then
-
- 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;"
-
- else
-
- ReportManager.SetDatabaseConnectionString "TRACKINGKITLABELS","Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;"
-
- End If
- ReportManager.Preview = false
- ReportManager.ShowProgress = false
- ReportManager.ShowPrintDialog = false
-
- ReportManager.SetParamValue "PBKITID", CInt(id)
-
- ReportManager.SaveToPdf Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\" & id & ".pdf",1
-
- Dim objStream:Set objStream = Server.CreateObject("ADODB.Stream")
- objStream.Type = 1 'adTypeBinary
- objStream.Open
- objStream.LoadFromFile(Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\" & id & ".pdf")
- Response.ContentType = "application/octet-stream"
- Response.Addheader "Content-Disposition", "attachment; filename=" & id & ".pdf"
- Response.BinaryWrite objStream.Read
- objStream.Close
- Set objStream = Nothing
-
-
- End Sub
-
- Public Sub DownloadTrackingkitSnailWorks
-
- dim id : id = Request.QueryString("Id")
- dim export: set export = SnailWorksRepository.GetSnailWorksExportById(id)
-
- if export.DetailRecords.Count > 0 Then
- If Not Server.CreateObject("Scripting.FileSystemObject").FolderExists(server.mappath("/uploads/")) Then : Server.CreateObject("Scripting.FileSystemObject").CreateFolder(server.mappath("/uploads/")):End If
- dim objExportFile: Set objExportFile = Server.CreateObject("Scripting.FileSystemObject").CreateTextFile(server.mappath("/uploads/" & id & ".csv"),2)
- With objExportFile
- .Write """" & export.Header.RecordType & ""","
- .Write """" & export.Header.Version & ""","
- .Write """" & export.Header.UserId & ""","
- .Write """" & export.Header.ClientName & ""","
- .Write """" & export.Header.ParentClientName & ""","
- .Write """" & export.Header.JobName & ""","
- .Write """" & export.Header.JobDescription & ""","
- .Write """" & export.Header.SplitName & ""","
- .Write """" & export.Header.SplitDescription & ""","
- .Write """" & export.Header.PieceType & ""","
- .Write """" & export.Header.MailDate & ""","
- .Write """" & export.Header.UploadType & ""","
- .Write """" & export.Header.TrackedQuanity & ""","
- .Write """" & export.Header.PiecesMailed & ""","
- .Write """" & export.Header.TargetInHomeDateStart & ""","
- .Write """" & export.Header.TargetInHomeDateEnd & ""","
- .Write """" & export.Header.ConfirmationEmail & ""","
- .Write """" & export.Header.JobId & ""","
- .Write """" & export.Header.SplitId & ""","
- .Write """" & export.Header.TypeOfTracking & ""","
- .Write """" & export.Header.ReturnedPostalRoutingCode & ""","
- .Write """" & export.Header.ReportId1 & ""","
- .Write """" & export.Header.Report1Email & ""","
- .Write """" & export.Header.ReportId2 & ""","
- .Write """" & export.Header.Report2Email & ""","
- .Write """" & export.Header.INFOONLY & """"
- .Write vbCrLf
- dim it:set it = export.DetailRecords.Iterator
- dim records
- while it.HasNext
- set records = it.GetNext()
- .Write """" & records.RecordType & ""","
- .Write """" & records.CustomerUniqueIdentifier & ""","
- .Write """" & records.IMB & ""","
- .Write """" & records.Greeting & ""","
- .Write """" & records.FirstName & ""","
- .Write """" & records.MI & ""","
- .Write """" & records.LastName & ""","
- .Write """" & records.Suffix & ""","
- .Write """" & records.FullName & ""","
- .Write """" & records.Company & ""","
- .Write """" & records.Title & ""","
- .Write """" & records.Address1 & ""","
- .Write """" & records.Address2 & ""","
- .Write """" & records.City & ""","
- .Write """" & records.State & ""","
- .Write """" & records.Zip & ""","
- .Write """" & records.UserDefined1 & ""","
- .Write """" & records.UserDefined2 & ""","
- .Write """" & records.UserDefined3 & ""","
- .Write """" & records.UserDefinedIdentifier4 & ""","
- .Write """" & records.UserDefinedIdentifier5 & ""","
- .Write """" & records.SeedIndicator & ""","
- .Write """" & records.InductionPoint & ""","
- .Write """" & records.InductionDate & ""","
- .Write """" & records.InBoundIMB & ""","
- .Write """" & records.IMCB & ""","
- .Write """" & records.IMTB & """" & vbCRLF
- Wend
- End With
- objExportFile.Close
- Dim objStream:Set objStream = Server.CreateObject("ADODB.Stream")
- objStream.Type = 1 'adTypeBinary
- objStream.Open
- objStream.LoadFromFile(server.mappath("/uploads/" & id & ".csv"))
- Response.ContentType = "application/octet-stream"
- Response.Addheader "Content-Disposition", "attachment; filename=" & id & ".csv"
- Response.BinaryWrite objStream.Read
- objStream.Close
- Set objStream = Nothing
- End If
- End Sub
-
- Public Sub Edit
-
- dim id : id = Request.QueryString("Id")
- set Model = new Edit_ViewModel_Class
- set Model.Kit = KitRepository.FindByID(id)
- Model.Title = "Edit Kit"
- HTMLSecurity.SetAntiCSRFToken "KitEditForm"
- %> <!--#include file="../../Views/Kit/Edit.asp"--> <%
- Flash.Success = "Kit Updated."
- End Sub
-
- Public Sub EditPost
- MVC.RequirePost
- HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
- dim ID : ID = Request.Form("Id")
- dim model : set model = KitRepository.FindByID(ID)
- set model = Automapper.AutoMap(Request.Form, model)
- 'model.Validate
- 'If model.Validator.HasErrors then
- FormCache.SerializeForm "EditKit", Request.Form
- ' Flash.Errors = model.Validator.Errors
- ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
- 'Else
- KitRepository.Update model
- FormCache.ClearForm "EditKit"
- Flash.Success = "Kit updated."
- MVC.RedirectToAction "Index"
- 'End If
- End Sub
- Public Sub CreateTrackingKit
-
- dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
-
- dim ID : ID = Request.QueryString("Id")
- dim model : set model = new Create_ViewModel_Class
- model.Title = "Create Kit "
- model.JCode = ID
- dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
- set model.Jurisdiction = ugh.pop()
-
- 'If Not form_params Is Nothing then
- ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
- 'Else
- ' set Model = new Create_ViewModel_Class
- 'End If
-
- HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
-
- %> <!--#include file="../../Views/Kit/CreateTrackingKit.asp"--> <%
- End Sub
- Public Sub Create
-
- dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
-
- dim ID : ID = Request.QueryString("Id")
- dim model : set model = new Create_ViewModel_Class
- model.Title = "Create Kit "
- model.JCode = ID
- dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
- set model.Jurisdiction = ugh.pop()
-
- 'If Not form_params Is Nothing then
- ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
- 'Else
- ' set Model = new Create_ViewModel_Class
- 'End If
-
- HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
-
- %> <!--#include file="../../Views/Kit/Create.asp"--> <%
- End Sub
-
- Public Sub CreatePost
-
- MVC.RequirePost
- HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
-
- dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
-
- 'new_Kit_model.Validator.Validate
-
- 'If new_Kit_model.Validator.HasErrors then
- ' FormCache.SerializeForm "NewKit", Request.Form
- ' Flash.Errors = new_Kit_model.Validator.Errors
- ' MVC.RedirectToAction "Create"
- 'Else
-
- KitRepository.AddNew new_Kit_model
- KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
- ' FormCache.ClearForm "NewKit"
- Flash.Success = "Kit added."
- MVC.RedirectToAction "Index"
- 'End If
- End Sub
-
- Public Sub CreateTrackingKitPost
-
- MVC.RequirePost
- HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
-
- dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
-
- 'new_Kit_model.Validator.Validate
-
- 'If new_Kit_model.Validator.HasErrors then
- ' FormCache.SerializeForm "NewKit", Request.Form
- ' Flash.Errors = new_Kit_model.Validator.Errors
- ' MVC.RedirectToAction "Create"
- 'Else
-
- KitRepository.AddNew new_Kit_model
- KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
- ' FormCache.ClearForm "NewKit"
- Flash.Success = "Kit added."
- MVC.RedirectToAction "Index"
- 'End If
- End Sub
-
- Public Sub Delete
- dim id : id = Request.QueryString("Id")
- set Model = new Delete_ViewModel_Class
- set Model.Kit = KitRepository.FindByID(id)
- Model.Title = "Delete Kit"
-
- HTMLSecurity.SetAntiCSRFToken "KitDeleteForm"
-
- %> <!--#include file="../../Views/Kit/Delete.asp"--> <%
- End Sub
-
- Public Sub DeletePost
- MVC.RequirePost
- HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create"
-
- dim id : id = Request.Form("Id")
- KitRepository.Delete id
-
- Flash.Success = "Kit deleted."
- MVC.RedirectToAction "Index"
- End Sub
-
- End Class
- MVC.Dispatch
- %>
|