@@ -1,11 +1,49 @@ | |||
<% Option Explicit %> | |||
<!--#include file="../../include_all.asp"--> | |||
<!--#include file="../../ViewModels/JurisdictionViewModels.asp"--> | |||
<% | |||
dim Model | |||
Class HomeController | |||
Public Sub Index | |||
%> <!--#include file="../../Views/Home/Index.asp"--> <% | |||
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 | |||
%> <!--#include file="../../Views/Home/CreateKit.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 = "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 | |||
%> <!--#include file="../../Views/Home/CreateKit.asp"--> <% | |||
End Sub | |||
Public Sub PostCreateKit | |||
End Sub | |||
End Class | |||
MVC.Dispatch |
@@ -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" | |||
@@ -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." | |||
@@ -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 | |||
@@ -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 | |||
@@ -23,6 +23,8 @@ Class Create_ViewModel_Class | |||
Public InBoundIMB | |||
Public OutboundIMBDigits | |||
Public InBoundIMBDigits | |||
Public OutboundIMBPNG | |||
Public INBOUNDIMBPNG | |||
End Class | |||
Class Delete_ViewModel_Class | |||
@@ -1,10 +1,19 @@ | |||
| |||
<h1><%= siteTitle %></h1> | |||
<div class="row"> | |||
<div class="col-md-4" style="background-color: #eee;"> | |||
Left Column | |||
<div class="col-md-4"> | |||
</div> | |||
<div class="col-md-8"> | |||
Right Column | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="list-group"> | |||
<a href="#" class="list-group-item list-group-item-action active">Switchboard</a> | |||
<%= 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")) %> | |||
</div> | |||
</div> | |||
</div | |||
</div> | |||
</div> |
@@ -1,7 +1,8 @@ | |||
<h2><%= H(Model.Title) %> For <%=H(Model.Jurisdiction.Name) %></h2> | |||
<h2><%= H(Model.Title) %> For <%=H(Model.Jurisdiction.Name) %> JCODE: <%= H(Model.JCODE) %> </h2> | |||
<%= HTML.FormTag("Kit", "CreatePost", empty, empty) %> | |||
<%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitCreateForm")) %> | |||
<%= HTML.Hidden("Jcode", Model.Jcode) %> | |||
<hr /> | |||
<div class="form-group"> | |||
@@ -16,16 +17,8 @@ | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="Jcode">Jcode</label> | |||
<%= HTML.TextboxExt("Jcode", Model.Jcode, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="Amount">Jcode</label> | |||
<%= HTML.TextboxExt("Amount", Model.Jcode, Array("class", "form-control")) %> | |||
<label for="Amount">Amount of Labels</label> | |||
<%= HTML.TextboxExt("Amount", Model.Amount, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
@@ -60,6 +60,22 @@ | |||
<%= HTML.TextboxExt("InBoundIMBDigits", Model.InBoundIMBDigits, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="OutboundIMBPNG">OutboundIMBPNG</label> | |||
<%= HTML.TextboxExt("OutboundIMBPNG", Model.OutboundIMBPNG, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="INBOUNDIMBPNGs">INBOUNDIMBPNG</label> | |||
<%= HTML.TextboxExt("INBOUNDIMBPNG", Model.INBOUNDIMBPNG, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<%= HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Create", "btn-primary") %> | |||
| |||
@@ -65,6 +65,22 @@ | |||
<%= HTML.TextboxExt("InBoundIMBDigits", Model.KitLabels.InBoundIMBDigits, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="OutboundIMBPNG">OutboundIMBPNG</label> | |||
<%= HTML.TextboxExt("OutboundIMBPNG", Model.OutboundIMBPNG, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="INBOUNDIMBPNGs">INBOUNDIMBPNG</label> | |||
<%= HTML.TextboxExt("INBOUNDIMBPNG", Model.INBOUNDIMBPNG, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
@@ -58,6 +58,22 @@ | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="OutboundIMBPNG">OutboundIMBPNG</label> | |||
<%= HTML.TextboxExt("OutboundIMBPNG", Model.KitLabels.OutboundIMBPNG, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="col-md-4"> | |||
<div class="form-group"> | |||
<label for="INBOUNDIMBPNGs">INBOUNDIMBPNG</label> | |||
<%= HTML.TextboxExt("INBOUNDIMBPNG", Model.KitLabels.INBOUNDIMBPNG, Array("class", "form-control")) %> | |||
</div> | |||
</div> | |||
</div> | |||
<hr /> | |||
<div class="form-group"> | |||
<% = HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Save", "btn-primary") %> | |||
@@ -28,10 +28,12 @@ | |||
<th style="text-align: left">KitId</th> | |||
<th style="text-align: left">OutboundSerial</th> | |||
<th style="text-align: left">InBoundSerial</th> | |||
<th style="text-align: left">OutboundIMB</th> | |||
<th style="text-align: left">InBoundIMB</th> | |||
<th style="text-align: left">Outbound Font Encoded</th> | |||
<th style="text-align: left">InBound Font Encoded</th> | |||
<th style="text-align: left">OutboundIMBDigits</th> | |||
<th style="text-align: left">InBoundIMBDigits</th> | |||
<th style="text-align: left">OutboundIMB</th> | |||
<th style="text-align: left">InBoundIMB</th> | |||
<th></th> | |||
</tr> | |||
</thead> | |||
@@ -52,6 +54,8 @@ | |||
<td><% = H(KitLabels.InBoundIMB) %></td> | |||
<td><% = H(KitLabels.OutboundIMBDigits) %></td> | |||
<td><% = H(KitLabels.InBoundIMBDigits) %></td> | |||
<td><img src='data:image/png;base64, <% = KitLabels.OutboundIMBPNG%>' alt='Barcode'</td> | |||
<td><img src='data:image/png;base64, <% = KitLabels.INBOUNDIMBPNG %>' alt='Barcode'</td> | |||
</tr> | |||
<% Wend %> | |||
</tbody> | |||
@@ -11,6 +11,7 @@ | |||
<!-- Latest compiled and minified CSS --> | |||
<%= HTML.StylesheetTag(appCss) %> | |||
<%= HTML.StylesheetTag(iconsCss) %> | |||
<%= HTML.StylesheetTag(tabulatorCss) %> | |||
</head> | |||
<body> | |||
@@ -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 | |||
%> |
@@ -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" |
@@ -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 | |||
%> |
Powered by TurnKey Linux.