diff --git a/App/Controllers/Home/HomeController.asp b/App/Controllers/Home/HomeController.asp index 6a0602b..d9f3803 100644 --- a/App/Controllers/Home/HomeController.asp +++ b/App/Controllers/Home/HomeController.asp @@ -1,11 +1,49 @@ <% Option Explicit %> + <% +dim Model Class HomeController Public Sub Index %> <% End Sub + + Public Sub CreateKit + 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 = "Create Kit" + set Model.Jurisdiction = JurisdictionRepository.FindPaged(empty, "JCode", page_size, page_num, page_count, record_count) + Model.CurrentPageNumber = page_num + Model.PageSize = page_size + Model.PageCount = page_count + Model.RecordCount = record_count + %> <% + 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 = "Create Kit" + set Model.Jurisdiction = JurisdictionRepository.SearchTablePaged(Array("JCode","%" & searchValue & "%","Name","%" & searchValue & "%","Mailing_Address","%" & searchValue & "%","CSZ","%" & searchValue & "%","IMB","%" & searchValue & "%","IMB_Digits","%" & searchValue & "%"),"JCode", page_size, page_num, page_count, record_count) + Model.CurrentPageNumber = page_num + Model.PageSize = page_size + Model.PageCount = page_count + Model.RecordCount = record_count + %> <% + + End Sub + + Public Sub PostCreateKit + + + End Sub End Class MVC.Dispatch diff --git a/App/Controllers/Kit/KitController.asp b/App/Controllers/Kit/KitController.asp index 4b17558..9715264 100644 --- a/App/Controllers/Kit/KitController.asp +++ b/App/Controllers/Kit/KitController.asp @@ -103,7 +103,9 @@ Class KitController ' 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" diff --git a/App/Controllers/KitLabels/KitLabelsController.asp b/App/Controllers/KitLabels/KitLabelsController.asp index cf92c75..8298f9b 100644 --- a/App/Controllers/KitLabels/KitLabelsController.asp +++ b/App/Controllers/KitLabels/KitLabelsController.asp @@ -95,6 +95,7 @@ Class KitLabelsController ' Flash.Errors = new_KitLabels_model.Validator.Errors ' MVC.RedirectToAction "Create" 'Else + KitLabelsRepository.AddNew new_KitLabels_model ' FormCache.ClearForm "NewKitLabels" Flash.Success = "KitLabels added." diff --git a/App/DomainModels/JurisdictionRepository.asp b/App/DomainModels/JurisdictionRepository.asp index 4087471..fe4e63e 100644 --- a/App/DomainModels/JurisdictionRepository.asp +++ b/App/DomainModels/JurisdictionRepository.asp @@ -36,8 +36,8 @@ Class JurisdictionRepository_Class set FindByJCode = Automapper.AutoMap(rs,"JurisdictionModel_Class") End If End Function - - Public Function GetAll(orderBy) + + Public Function GetAll(orderBy) set GetAll = Find(empty,orderBy) End Function diff --git a/App/DomainModels/KitLabelsRepository.asp b/App/DomainModels/KitLabelsRepository.asp index 46ff9a7..be2dd33 100644 --- a/App/DomainModels/KitLabelsRepository.asp +++ b/App/DomainModels/KitLabelsRepository.asp @@ -15,10 +15,11 @@ Class KitLabelsModel_Class Public InBoundIMB '106 Public OutboundIMBDigits '106 Public InBoundIMBDigits '106 - + Public OutboundIMBPNG + Public INBOUNDIMBPNG Private Sub Class_Initialize 'ValidateExitsts Me, "","" - Class_Get_Properties = Array("ID, KitId, OutboundSerial, InBoundSerial, OutboundIMB, InBoundIMB, OutboundIMBDigits, InBoundIMBDigits") + Class_Get_Properties = Array("ID, KitId, OutboundSerial, InBoundSerial, OutboundIMB, InBoundIMB, OutboundIMBDigits, InBoundIMBDigits,OutboundIMBPNG,INBOUNDIMBPNG") End Sub End CLass @@ -30,7 +31,7 @@ End CLass Class KitLabelsRepository_Class Public Function FindByID(ID) - dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels] WHERE ID = ?" + dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits],OutboundIMBPNG,INBOUNDIMBPNG FROM [KitLabels] WHERE ID = ?" dim rs : set rs = DAL.Query(sql,ID) If rs.EOF then Err.Raise 1, "KitLabelsRepository_Class", KitLabelsNotFoundException("ID", ID) @@ -44,7 +45,7 @@ Class KitLabelsRepository_Class End Function Public Function Find(where_kvarray, order_string_or_array) - dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]" + dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits],OutboundIMBPNG,INBOUNDIMBPNG FROM [KitLabels]" If Not IsEmpty(where_kvarray) then sql = sql & " WHERE " @@ -77,7 +78,7 @@ Class KitLabelsRepository_Class End Function Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) - dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]" + dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits],OutboundIMBPNG,INBOUNDIMBPNG FROM [KitLabels]" If Not IsEmpty(where_kvarray) then sql = sql & " WHERE " @@ -119,7 +120,7 @@ Class KitLabelsRepository_Class End Function Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) - dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]" + dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits],OutboundIMBPNG,INBOUNDIMBPNG FROM [KitLabels]" If Not IsEmpty(where_kvarray) then sql = sql & " WHERE " @@ -188,6 +189,43 @@ Class KitLabelsRepository_Class set KitLabelsList = list End Function + Public Sub BulkAdd(KitId,Amount) + Dim rest : Set rest = Server.CreateObject("Chilkat_9_5_0.Rest") + Dim responseJson : responseJson = rest.Connect("https://postalpro.usps.com",443,1,1) + Dim Kit : Set Kit = KitRepository.Find(Array("ID = ?",KitId),empty).pop() + Dim Jurisdiction:Set Jurisdiction = JurisdictionRepository.Find(Array("JCode =?",Kit.Jcode),empty).pop + Dim MailingID:MailingID = SettingsRepository.Find(Array("Name =?","MailingID"),empty).pop().Value + Dim SerialNumberStart:SerialNumberStart = SettingsRepository.Find(Array("Name =?","SerialNumberStart"),empty).pop().Value + Dim serialOffset:serialOffset = SettingsRepository.Find(Array("Name =?","SerialOffset"),empty).pop().Value + Dim SerialStart:SerialStart = CLng(SerialNumberStart) + CLng(serialOffset) + dim i + for i = 0 to (Amount * 2) - 2 Step 2 + dim NewKitLabel : set NewKitLabel = new KitLabelsModel_Class + NewKitLabel.KitId = KitId + NewKitLabel.OutboundSerial = PadLeft(SerialStart + i,9,"0") + NewKitLabel.InBoundSerial = PadLeft(SerialStart + i + 1,9,"0") + NewKitLabel.OutboundIMBDigits ="00716" & MailingID & NewKitLabel.OutboundSerial & "000000000" + NewKitLabel.InBoundIMBDigits = "00778" & MailingID & NewKitLabel.InBoundSerial & right(Jurisdiction.IMB_Digits,9) + dim imbJson : imbJson = rest.FullRequestNoBody("get","/ppro-tools-api/imb/encode?imb=" & NewKitLabel.OutboundIMBDigits) + json.loadJSON(imbJson) + 'dim ugh : set ugh = json.loadJSON(rest.FullRequestNoBody("get","/ppro-tools-api/imb/encode?imb=" & NewKitLabel.OutboundIMBDigits)) + NewKitLabel.OutboundIMB = json.Data("imb") 'left(rest.FullRequestNoBody("get","/ppro-tools-api/imb/encode?imb=" & "000000000"),250) + NewKitLabel.OutboundIMBPNG = json.Data("imbImage") + imbJson = rest.FullRequestNoBody("get","/ppro-tools-api/imb/encode?imb=" & NewKitLabel.InBoundIMBDigits ) + json.loadJSON(imbJson) + NewKitLabel.InBoundIMB = json.Data("imb") 'left(rest.FullRequestNoBody("get","/ppro-tools-api/imb/encode?imb=" & NewKitLabel.InBoundIMBDigits),250) + NewKitLabel.INBOUNDIMBPNG = json.Data("imbImage") + me.AddNew NewKitLabel + Next + + DAL.Execute "UPDATE Settings SET [Value] ='" & (Amount * 2) + serialOffset & "' Where [Name] ='SerialOffset'",empty + + +'https://postalpro.usps.com/ppro-tools-api/imb/encode?imb=00778202248200000081493019915 + + + End Sub + Public Sub AddNew(ByRef model) dim sql : sql = "INSERT INTO [KitLabels] (" &_ "[KitId]," &_ @@ -196,15 +234,19 @@ Class KitLabelsRepository_Class "[OutboundIMB]," &_ "[InBoundIMB]," &_ "[OutboundIMBDigits]," &_ - "[InBoundIMBDigits])" &_ - "VALUES (?,?,?,?,?,?,?)" + "[InBoundIMBDigits]," &_ + "[OutboundIMBPNG]," &_ + "[INBOUNDIMBPNG])" &_ + "VALUES (?,?,?,?,?,?,?,?,?)" DAL.Execute sql, Array(model.KitId, _ model.OutboundSerial, _ model.InBoundSerial, _ model.OutboundIMB, _ model.InBoundIMB, _ model.OutboundIMBDigits, _ - model.InBoundIMBDigits) + model.InBoundIMBDigits, _ + model.OutboundIMBPNG, _ + model.INBOUNDIMBPNG) sql = "SELECT TOP 1 ID FROM [KitLabels] ORDER BY ID DESC" dim rs : set rs = DAL.Query(sql, empty) model.ID = rs("ID") @@ -218,7 +260,8 @@ Class KitLabelsRepository_Class "[OutboundIMB] = ?," &_ "[InBoundIMB] = ?," &_ "[OutboundIMBDigits] = ?," &_ - "[InBoundIMBDigits] = ?" &_ + "[InBoundIMBDigits] = ?," &_ + "OutboundIMBPNG,INBOUNDIMBPNG)" &_ " WHERE [ID] = ?" DAL.Execute sql, Array(model.KitId, _ @@ -228,6 +271,8 @@ Class KitLabelsRepository_Class model.InBoundIMB, _ model.OutboundIMBDigits, _ model.InBoundIMBDigits, _ + model.OutboundIMBPNG, _ + model.INBOUNDIMBPNG, _ model.ID) End Sub diff --git a/App/ViewModels/KitLabelsViewModels.asp b/App/ViewModels/KitLabelsViewModels.asp index cae0e7b..838c2d4 100644 --- a/App/ViewModels/KitLabelsViewModels.asp +++ b/App/ViewModels/KitLabelsViewModels.asp @@ -23,6 +23,8 @@ Class Create_ViewModel_Class Public InBoundIMB Public OutboundIMBDigits Public InBoundIMBDigits + Public OutboundIMBPNG + Public INBOUNDIMBPNG End Class Class Delete_ViewModel_Class diff --git a/App/Views/Home/Index.asp b/App/Views/Home/Index.asp index 6ad1aa6..1854369 100644 --- a/App/Views/Home/Index.asp +++ b/App/Views/Home/Index.asp @@ -1,10 +1,19 @@