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 @@ 

<%= siteTitle %>

-
- Left Column +
+ +
-
- Right Column +
+
+
+ Switchboard + <%= Html.LinkTOExt("Create Kit","Home","CreateKit",empty,Array("Class","list-group-item list-group-item-action")) %> + <%= Html.LinkTOExt("View Current Kits","Home","ViewKits",empty,Array("Class","list-group-item list-group-item-action")) %> +
+
+
\ No newline at end of file diff --git a/App/Views/Kit/create.asp b/App/Views/Kit/create.asp index 8f13799..7ef48c1 100644 --- a/App/Views/Kit/create.asp +++ b/App/Views/Kit/create.asp @@ -1,7 +1,8 @@ -

<%= H(Model.Title) %> For <%=H(Model.Jurisdiction.Name) %>

+

<%= H(Model.Title) %> For <%=H(Model.Jurisdiction.Name) %> JCODE: <%= H(Model.JCODE) %>

<%= HTML.FormTag("Kit", "CreatePost", empty, empty) %> <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitCreateForm")) %> +<%= HTML.Hidden("Jcode", Model.Jcode) %>
@@ -16,16 +17,8 @@
- - <%= HTML.TextboxExt("Jcode", Model.Jcode, Array("class", "form-control")) %> -
-
-
-
-
-
- - <%= HTML.TextboxExt("Amount", Model.Jcode, Array("class", "form-control")) %> + + <%= HTML.TextboxExt("Amount", Model.Amount, Array("class", "form-control")) %>
diff --git a/App/Views/KitLabels/create.asp b/App/Views/KitLabels/create.asp index e9b1c60..9bab39c 100644 --- a/App/Views/KitLabels/create.asp +++ b/App/Views/KitLabels/create.asp @@ -60,6 +60,22 @@ <%= HTML.TextboxExt("InBoundIMBDigits", Model.InBoundIMBDigits, Array("class", "form-control")) %>
+
+
+
+
+ + <%= HTML.TextboxExt("OutboundIMBPNG", Model.OutboundIMBPNG, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("INBOUNDIMBPNG", Model.INBOUNDIMBPNG, Array("class", "form-control")) %> +
+
<%= HTML.Button("submit", " Create", "btn-primary") %>    diff --git a/App/Views/KitLabels/delete.asp b/App/Views/KitLabels/delete.asp index 7a9c199..ace5ab9 100644 --- a/App/Views/KitLabels/delete.asp +++ b/App/Views/KitLabels/delete.asp @@ -65,6 +65,22 @@ <%= HTML.TextboxExt("InBoundIMBDigits", Model.KitLabels.InBoundIMBDigits, Array("class", "form-control")) %> + +
+
+
+ + <%= HTML.TextboxExt("OutboundIMBPNG", Model.OutboundIMBPNG, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("INBOUNDIMBPNG", Model.INBOUNDIMBPNG, Array("class", "form-control")) %> +
+
diff --git a/App/Views/KitLabels/edit.asp b/App/Views/KitLabels/edit.asp index a84e2df..3c4a783 100644 --- a/App/Views/KitLabels/edit.asp +++ b/App/Views/KitLabels/edit.asp @@ -58,6 +58,22 @@ +
+
+
+ + <%= HTML.TextboxExt("OutboundIMBPNG", Model.KitLabels.OutboundIMBPNG, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("INBOUNDIMBPNG", Model.KitLabels.INBOUNDIMBPNG, Array("class", "form-control")) %> +
+
+

<% = HTML.Button("submit", " Save", "btn-primary") %> diff --git a/App/Views/KitLabels/index.asp b/App/Views/KitLabels/index.asp index 357b46f..607e186 100644 --- a/App/Views/KitLabels/index.asp +++ b/App/Views/KitLabels/index.asp @@ -28,10 +28,12 @@ KitId OutboundSerial InBoundSerial - OutboundIMB - InBoundIMB + Outbound Font Encoded + InBound Font Encoded OutboundIMBDigits InBoundIMBDigits + OutboundIMB + InBoundIMB @@ -52,6 +54,8 @@ <% = H(KitLabels.InBoundIMB) %> <% = H(KitLabels.OutboundIMBDigits) %> <% = H(KitLabels.InBoundIMBDigits) %> + Barcode + Barcode <% Wend %> diff --git a/App/Views/Shared/layout.header.asp b/App/Views/Shared/layout.header.asp index ec6d11a..0e17c98 100644 --- a/App/Views/Shared/layout.header.asp +++ b/App/Views/Shared/layout.header.asp @@ -11,6 +11,7 @@ <%= HTML.StylesheetTag(appCss) %> <%= HTML.StylesheetTag(iconsCss) %> + <%= HTML.StylesheetTag(tabulatorCss) %> diff --git a/App/app.config.asp b/App/app.config.asp index 6d3ea91..31bceb6 100644 --- a/App/app.config.asp +++ b/App/app.config.asp @@ -1,14 +1,19 @@ <% -dim appCss, appJs, appBootStrapJs, jqueryJs, siteTitle, iconsCss +dim appCss, appJs, appBootStrapJs, jqueryJs, siteTitle, iconsCss, tabulatorCss Routes.Initialize "/App/" siteTitle = "Mail Tracking Kits" iconsCss = "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" appCss = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" +tabulatorCss = "/dist/css/tabulator_bootstrap5.css" appBootStrapJs = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js' integrity='sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM' crossorigin='anonymous" jqueryJs = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js' integrity='sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==' crossorigin='anonymous' referrerpolicy='no-referrer" '======================================================================================================================= ' Set Global Variables Here '======================================================================================================================= - +dim glob:set glob = Server.CreateObject("Chilkat_9_5_0.Global") +dim success:success = glob.UnlockBundle("KENTCM.CB1022025_RGzBPM5J655e") +If (success <> 1) Then + put(glob.LastErrorText) +End If %> \ No newline at end of file diff --git a/Data/Migrations/Migration_05_Create_Kit_Labels_Table.asp b/Data/Migrations/Migration_05_Create_Kit_Labels_Table.asp index c3ce12d..4f3fe39 100644 --- a/Data/Migrations/Migration_05_Create_Kit_Labels_Table.asp +++ b/Data/Migrations/Migration_05_Create_Kit_Labels_Table.asp @@ -11,13 +11,14 @@ Class Migration_05_Create_Kit_Labels_Table "[OutboundIMB] VARCHAR(255)," &_ "[InBoundIMB] VARCHAR(255)," &_ "[OutboundIMBDigits] VARCHAR(255)," &_ - "[InBoundIMBDigits] VARCHAR(255)" &_ - ");" + "[InBoundIMBDigits] VARCHAR(255)," &_ + "[OutboundIMBPNG] MEMO," &_ + "[INBOUNDIMBPNG] MEMO);" Migration.Do "CREATE UNIQUE INDEX [ID] ON [KitLabels]( [ID] ) WITH PRIMARY;" End Sub Public Sub Down - Migration.Do "DROP TABLE [KKitLabels]" + Migration.Do "DROP TABLE [KitLabels]" End Sub End Class Migrations.Add "Migration_05_Create_Kit_Labels_Table" diff --git a/MVC/lib.Helpers.asp b/MVC/lib.Helpers.asp index e2f5a3f..40cc0b6 100644 --- a/MVC/lib.Helpers.asp +++ b/MVC/lib.Helpers.asp @@ -356,6 +356,18 @@ Public Function Q(ByVal input) Q = Replace(input, "'", """") End Function +Public Function PadLeft(originalString,desiredLength,Char) +Dim padLength + padLength = desiredLength - Len(originalString) + If padLength > 0 Then + ' Left pad the string with zeros + PadLeft = String(padLength, Char) & originalString +Else + ' If the original string is already longer or equal to the desired length, no padding is needed + PadLeft = originalString +End If + +End Function %>