You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

767 lines
72KB

  1. Option Explicit
  2. Dim dev:dev = true
  3. Dim outFile
  4. Dim WaitTime:WaitTime = 15000
  5. Dim DataDirectory
  6. Dim ExportDirectory
  7. Dim PurpleEnvelopeProofReport,OfficeCopiesProofReport
  8. Dim WshShell:Set WshShell = WScript.CreateObject("Wscript.Shell")
  9. Dim oConn:Set oConn = WScript.CreateObject("ADODB.Connection")
  10. Dim ConnectionString
  11. Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
  12. Dim glob:set glob = CreateObject("Chilkat_9_5_0.Global")
  13. Dim success:success = glob.UnlockBundle("KENTCM.CB1022025_RGzBPM5J655e")
  14. If (success <> 1) Then
  15. WriteLine(glob.LastErrorText)
  16. WScript.Quit
  17. End If
  18. Dim objCSV:Set objCsv = CreateObject("Chilkat_9_5_0.Csv")
  19. Dim WorkingDirectory:WorkingDirectory = Replace(WScript.ScriptFullName,WScript.ScriptName,"")
  20. Select Case dev
  21. Case "local"
  22. DataDirectory = "C:\Share\TrackingDataImport\"
  23. ExportDirectory = "C:\Share\TrackingDataExport\"
  24. ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=F:\Development\Tracking_Kits\Data\webdata - Copy.mdb;"
  25. PurpleEnvelopeProofReport = "F:\Development\Tracking_Kits\Data\Proofs.rep"
  26. OfficeCopiesProofReport="F:\Development\Tracking_Kits\Data\Office-Copy-Proof.rep"
  27. set outFile = objFSO.CreateTextFile("C:\Share\TrackingDataExport\temp.csv",True)
  28. Case true
  29. DataDirectory = "C:\Share\TrackingDataImport\"
  30. ExportDirectory = "C:\Share\TrackingDataExport\"
  31. ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\Git Repos\tracking_kits\Data\webdata - Copy.mdb;"
  32. PurpleEnvelopeProofReport = "C:\Git Repos\tracking_kits\Data\Proofs.rep"
  33. OfficeCopiesProofReport = "C:\Git Repos\tracking_kits\Data\Office-Copy-Proof.rep"
  34. set outFile = objFSO.CreateTextFile("C:\Share\TrackingDataExport\temp.csv",True)
  35. Case Else
  36. DataDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataImport"
  37. ExportDirectory = "\\kci-syn-cl01\PC Transfer\TrackingDataExport\"
  38. ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=C:\inetpub\Data\webdata - Copy.mdb;"
  39. PurpleEnvelopeProofReport ="C:\inetpub\tracking\Data\Proofs.rep"
  40. OfficeCopiesProofReport = "C:\inetpub\tracking\Data\Office-Copy-Proof.rep"
  41. set outFile = objFSO.CreateTextFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\temp.csv",True)
  42. End Select
  43. 'ToDo create a checkstatus function so I dont need four functions of create a case switch that responds to the status of jobs
  44. Dim KitID:CheckForFiles:KitID = CheckForJobsToCass()
  45. If KitID > 0 Then
  46. ExportMMCsv(KitID)
  47. RunMailManager
  48. ImportCass
  49. End If
  50. KitID = CheckStatusFor("Ready to Assign Labels"):If KitID > 0 Then:createTrackingInfoForKit(KitID):End If
  51. KitID = CheckStatusFor("Ready For Export"):If KitID > 0 Then:CreateExportForSnailWorks(KitID):End If
  52. KitID = CheckStatusFor("Ready to Proof"):If KitID > 0 Then:CreateProofForJurisdiction(KitID):End If
  53. KitID = CheckStatusFor("Ready For Inkjet Export"):If KitID > 0 Then:ExportInkjetFile(KitID):End If
  54. if dev = False then
  55. CheckSnailWorksPurpleEnvelopeExport
  56. CheckSnailWorksTrakingKitExport
  57. End if
  58. WScript.Quit
  59. Sub CheckSnailWorksPurpleEnvelopeExport
  60. Dim Sftp:set Sftp = CreateObject("Chilkat_9_5_0.SFtp")
  61. Dim objFolder
  62. Dim success
  63. Set objFolder = objFSO.GetFolder("\\kci-syn-cl01\PC Transfer\TrackingDataExport\Export Purple Envelopes")
  64. If objFolder.Files.Count > 0 Then
  65. success = Sftp.Connect("sftp.snailworks.com",22)
  66. success = Sftp.AuthenticatePw("KCIHotFolder2024FTPUser","Z!4WXLSQMM#f")
  67. success = Sftp.InitializeSftp()
  68. Dim file
  69. For Each file In objFolder.Files
  70. debug.WriteLine file.Path
  71. Dim handle:handle = Sftp.OpenFile(file.Name,"writeOnly","createTruncate")
  72. Sftp.UploadFile handle,file.Path
  73. Sftp.CloseHandle handle
  74. file.Delete
  75. Next
  76. End If
  77. End Sub
  78. Sub CheckSnailWorksTrakingKitExport
  79. Dim Sftp:set Sftp = CreateObject("Chilkat_9_5_0.SFtp")
  80. Dim objFolder
  81. Dim success
  82. Set objFolder = objFSO.GetFolder("\\kci-syn-cl01\PC Transfer\TrackingDataExport\Export Tracking Kits")
  83. If objFolder.Files.Count > 0 Then
  84. success = Sftp.Connect("sftp.snailworks.com",22)
  85. success = Sftp.AuthenticatePw("KCI2024Type2FTPUser","Z!NXVRV5SH#f")
  86. success = Sftp.InitializeSftp()
  87. Dim file
  88. For Each file In objFolder.Files
  89. debug.WriteLine file.Path
  90. Dim handle:handle = Sftp.OpenFile(file.Name,"writeOnly","createTruncate")
  91. Sftp.UploadFile handle,file.Path
  92. Sftp.CloseHandle handle
  93. file.Delete
  94. Next
  95. End If
  96. End Sub
  97. Function ExportInkjetFile(KitID)
  98. If oConn.State = 0 Then:oConn.Open(ConnectionString):End If
  99. Dim KitRs:set KitRs = oConn.Execute("Select * From [Kit] Where [ID] =" & KitID & ";")
  100. Dim KitLabelsRs: Set KitLabelsRs = oConn.Execute("Select * FROM (SELECT IIf(Len([PRECINCT]) = 1, '0' & [PRECINCT] & Right([BALLOT_NUMBER],4), [PRECINCT] & Right([BALLOT_NUMBER],4)) AS SORT_ORDER," &_
  101. "InkjetRecords.ID, InkjetRecords.KitID, InkjetRecords.VOTERID, InkjetRecords.LASTNAME," &_
  102. " InkjetRecords.FIRSTNAME, InkjetRecords.MIDDLENAME, InkjetRecords.SUFFIX, InkjetRecords.PRECINCT," &_
  103. " InkjetRecords.ADDRESS1, InkjetRecords.ADDRESS2, InkjetRecords.ADDRESS3, InkjetRecords.ADDRESS4," &_
  104. " InkjetRecords.ADDRESS5, InkjetRecords.APPSENT, InkjetRecords.APPRETURNED, InkjetRecords.BALSENT," &_
  105. " InkjetRecords.BALRETURNED, InkjetRecords.CountingBoard, InkjetRecords.UOCAVASTATUS, InkjetRecords.EMAILADDRESS," &_
  106. " InkjetRecords.PHONENUMBER, InkjetRecords.BALLOT_NUMBER, InkjetRecords.CassADDRESS1, InkjetRecords.CassADDRESS2," &_
  107. " InkjetRecords.CassADDRESS3, InkjetRecords.CassADDRESS4, InkjetRecords.CassADDRESS5, InkjetRecords.KitLabelID," &_
  108. " KitLabels.ID, KitLabels.KitID, KitLabels.OutboundSerial, KitLabels.InBoundSerial, KitLabels.OutboundIMB," &_
  109. " KitLabels.InBoundIMB, KitLabels.OutboundIMBDigits, KitLabels.InBoundIMBDigits, KitLabels.OutboundIMBPNG," &_
  110. " KitLabels.INBOUNDIMBPNG, KitLabels.SetNumber" &_
  111. " FROM InkjetRecords" &_
  112. " LEFT JOIN [KitLabels] ON InkjetRecords.KitLabelID = KitLabels.ID" & _
  113. " WHERE InkjetRecords.KitID =" & KitID & ") as [Data] Order By SORT_ORDER Desc;")
  114. Dim JurisdictionRs:Set JurisdictionRs = oConn.Execute("SELECT * FROM Jurisdiction WHERE JCode ='" & KitRs("Jcode").Value & "';")
  115. Dim ContactRs:Set ContactRs = oConn.Execute("SELECT * FROM Contacts WHERE [JURISCODE] ='" & KitRs("Jcode").Value & "';")
  116. Dim ExportFileName:ExportFileName = objFSO.GetBaseName(KitRs("Filename")) & ".csv"
  117. If Not objFSO.FolderExists(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value) Then:objFSO.CreateFolder(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value):End If
  118. If objFSO.FileExists(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName) Then:objFSO.DeleteFile(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName):End If
  119. Dim ElectionDate:ElectionDate=GetSetting("ElectionDate")
  120. Dim objInkjetCSV:Set objInkJetCSV = CreateObject("Chilkat_9_5_0.Csv")
  121. objInkjetCSV.HasColumnNames = 1
  122. objInkjetCSV.EnableQuotes = 1
  123. objInkjetCSV.SetColumnName 0,"Full Name"
  124. objInkjetCSV.SetColumnName 1,"Address 1"
  125. objInkjetCSV.SetColumnName 2,"Address 2"
  126. objInkjetCSV.SetColumnName 3,"Address 3"
  127. objInkjetCSV.SetColumnName 4,"Address 4"
  128. objInkjetCSV.SetColumnName 5,"IM barcode Characters"
  129. objInkjetCSV.SetColumnName 6,"Precinct"
  130. objInkjetCSV.SetColumnName 7,"Ballot ID"
  131. objInkjetCSV.SetColumnName 8,"Ballot Number"
  132. objInkjetCSV.SetColumnName 9,"Jurisdiction code"
  133. objInkjetCSV.SetColumnName 10,"Election Date"
  134. objInkJetCSV.SetColumnName 11,"Combined Pct_Ballot Num"
  135. objInkJetCSV.SetColumnName 12,"Title"
  136. objInkJetCSV.SetColumnName 13,"G2 Full Name"
  137. objInkJetCSV.SetColumnName 14,"G2 Company"
  138. objInkJetCSV.SetColumnName 15,"G2 Alternate 1 Address"
  139. objInkJetCSV.SetColumnName 16,"G2 Delivery Address"
  140. objInkJetCSV.SetColumnName 17,"G2 City St ZIP+4"
  141. objInkJetCSV.SetColumnName 18,"G2 IM barcode Characters"
  142. objInkJetCSV.SetColumnName 19,"Matching Code"
  143. Dim AddressArray
  144. Dim row:row = 0
  145. While Not KitLabelsRs.EOF
  146. AddressArray = CompressArray(Array(KitLabelsRs("CassADDRESS1").Value,KitLabelsRs("CassADDRESS2").Value,KitLabelsRs("CassADDRESS3").Value,KitLabelsRs("CassADDRESS4").Value,KitLabelsRs("CassADDRESS5").Value))
  147. objInkjetCSV.SetCellByName row,"Full Name",AddressArray(0)
  148. objInkjetCSV.SetCellByName row,"Address 1",AddressArray(1)
  149. objInkjetCSV.SetCellByName row,"Address 2",AddressArray(2)
  150. objInkjetCSV.SetCellByName row,"Address 3",AddressArray(3)
  151. objInkjetCSV.SetCellByName row,"Address 4",AddressArray(4)
  152. If KitRs("OutboundSTID") <> "0" Then
  153. objInkJetCSV.SetCellByName row,"IM barcode Characters",KitLabelsRs("OutboundIMBDigits").Value
  154. End If
  155. objInkJetCSV.SetCellByName row,"Precinct",KitLabelsRs("PRECINCT").Value
  156. objInkJetCSV.SetCellByName row,"Ballot ID","*" & KitLabelsRs("VOTERID").Value & "*"
  157. objInkJetCSV.SetCellByName row,"Ballot Number",TrimLeadingZeros(KitLabelsRs("BALLOT_NUMBER").Value)
  158. objInkJetCSV.SetCellByName row,"Jurisdiction code",KitRs("Jcode").Value
  159. objInkJetCSV.SetCellByName row,"Election Date",ElectionDate
  160. objInkJetCSV.SetCellByName row,"Combined Pct_Ballot Num",KitLabelsRs("PRECINCT").Value & TrimLeadingZeros(KitLabelsRs("BALLOT_NUMBER").Value)
  161. objInkjetCSV.SetCellByName row,"Title",CleanNull(ContactRs("Title").Value)
  162. objInkJetCSV.SetCellByName row,"G2 Full Name",JurisdictionRs("Name").Value
  163. objInkJetCSV.SetCellByName row,"G2 Company",JurisdictionRs("Mailing_Address").Value
  164. objInkJetCSV.SetCellByName row,"G2 Alternate 1 Address",JurisdictionRs("CSZ").Value
  165. objInkJetCSV.SetCellByName row,"G2 Delivery Address",""
  166. objInkJetCSV.SetCellByName row,"G2 City St ZIP+4",""
  167. objInkJetCSV.SetCellByName row,"G2 IM barcode Characters",JurisdictionRs("IMB_Digits").Value
  168. objInkJetCSV.SetCellByName row,"Matching Code",KitRs("Jcode").Value & TrimLeadingZeros(KitLabelsRs("PRECINCT").Value) & TrimLeadingZeros(KitLabelsRs("BALLOT_NUMBER").Value)
  169. 'Where do we put the roundtrip IMB
  170. row = row + 1
  171. KitLabelsRs.MoveNext
  172. Wend
  173. If KitRs("OfficeCopiesAmount").Value > 0 Then
  174. dim s
  175. For s = 0 to KitRs("OfficeCopiesAmount").Value -1
  176. objInkjetCSV.SetCellByName row + s,"Title",CleanNull(ContactRs("Title").Value)
  177. objInkJetCSV.SetCellByName row + s,"G2 Full Name",JurisdictionRs("Name").Value
  178. objInkJetCSV.SetCellByName row + s,"G2 Company",JurisdictionRs("Mailing_Address").Value
  179. objInkJetCSV.SetCellByName row + s,"G2 Alternate 1 Address",JurisdictionRs("CSZ").Value
  180. objInkJetCSV.SetCellByName row + s,"G2 Delivery Address",""
  181. objInkJetCSV.SetCellByName row + s,"G2 City St ZIP+4",""
  182. objInkJetCSV.SetCellByName row + s,"G2 IM barcode Characters",JurisdictionRs("IMB_Digits").Value
  183. Next
  184. End If
  185. objInkjetCSV.SaveFile(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName)
  186. oConn.Execute("UPDATE KIT SET [Status] ='Done',[InkJetJob]=1 WHERE [ID] =" & KitID & ";")
  187. If KitRs.State = 1 Then:KitRs.Close:End If
  188. If ContactRs.State =1 Then:ContactRs.Close:End If
  189. If KitLabelsRs.State = 1 Then:KitLabelsRs.Close: End If
  190. If JurisdictionRs.State = 1 Then:JurisdictionRs.Close:End If
  191. If oConn.State = 1 Then:oConn.Close:End If
  192. End Function
  193. Function CheckStatusFor(StatusString)
  194. If oConn.State = 0 Then:oConn.Open(ConnectionString):End If
  195. Dim rs:Set rs = oConn.Execute("Select TOP 1 [ID] FROM [Kit] Where Status ='" & StatusString & "' and JobType='Purple Envelopes';")
  196. If Not rs.EOF Then
  197. CheckStatusFor = rs("ID").value
  198. Else
  199. CheckStatusFor = 0
  200. End If
  201. If rs.State = 1 Then:rs.Close:End If
  202. If oConn.State = 1 Then:oConn.Close:End If
  203. End Function
  204. Function CreateProofForJurisdiction(KitID)
  205. Dim Qpdf:Set Qpdf = WScript.CreateObject("DebenuPDFLibraryAX1013.PDFLibrary")
  206. Dim Result:Result = Qpdf.UnlockKey("j564z3wi9i66k93cp3r798b3y")
  207. If oConn.State = 0 Then:oConn.Open(ConnectionString):End If
  208. Dim Rs:set Rs = oConn.Execute("SELECT MIN(ID) as [MIN],MAX(ID) as [MAX] FROM InkjetRecords WHERE KitID = " & KitID &";")
  209. Dim MIN:MIN = Rs("MIN").Value
  210. Dim MAX:MAX = Rs("MAX").Value
  211. Dim RecordCount:RecordCount = (MAX - MIN) + 1
  212. Rs.Close
  213. Dim KitRs:set KitRs = oConn.Execute("Select * From [Kit] Where [ID] =" & KitID & ";")
  214. Dim JurisdictionRs:set JurisdictionRs = oConn.Execute("SELECt * FROM [Jurisdiction] WHERE JCode='" & KitRs("Jcode").Value & "';")
  215. Dim ProofFileName:ProofFileName = objFSO.GetBaseName(KitRs("Filename")) & "-PROOF.PDF"
  216. If Not objFSO.FolderExists(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value) Then:objFSO.CreateFolder(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value):End If
  217. Dim reportManager:set reportManager = CreateObject("ReportMan.ReportManX")
  218. With reportManager
  219. .Preview = False
  220. .ShowProgress = False
  221. .ShowPrintDialog = False
  222. .filename = PurpleEnvelopeProofReport
  223. .SetDatabaseConnectionString "WEBDATA",ConnectionString
  224. .SetParamValue "PBKITID",KitID
  225. .SetParamValue "PBJCODE",KitRs("Jcode").Value
  226. Dim MAXRECORDS:MAXRECORDS = 3750
  227. If RecordCount > MAXRECORDS Then
  228. Dim i
  229. For i = 0 To RecordCount / MAXRECORDS
  230. Dim newMin:If MIN + (i * MAXRECORDS) > MIN Then:newMin = MIN + (i * MAXRECORDS) + 1:Else newMin = MIN:End If
  231. Dim newMax:If MIN + (i * MAXRECORDS) + MAXRECORDS > MAX Then:newMax = MAX:Else newMax = MIN + (i * MAXRECORDS) + MAXRECORDS:End If
  232. .SetParamValue "PBMIN",newMin
  233. .SetParamValue "PBMAX",newMax
  234. .SaveToPDF ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "\Part_" & i & "_" & ProofFileName,1
  235. Result = Qpdf.AddToFileList("Proofs",ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "\Part_" & i & "_" & ProofFileName)
  236. Next
  237. Result = Qpdf.MergeFileListFast("Proofs",ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ProofFileName)
  238. Dim test
  239. For test = 1 To Qpdf.FileListCount("Proofs")
  240. WshShell.Run "cmd.exe /c DEL /F /Q """ & Qpdf.FileListItem("Proofs",test) & """" ,0,True
  241. Next
  242. Else
  243. .SetParamValue "PBMIN",MIN
  244. .SetParamValue "PBMAX",MAX
  245. .SaveToPDF ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ProofFileName,1
  246. End If
  247. End With
  248. oConn.Execute("UPDATE KIT SET [Status] ='Ready For Inkjet Export' WHERE [ID] =" & KitID & ";")
  249. If KitRs.State = 1 Then:KitRs.Close:End If
  250. If JurisdictionRs.State = 1 Then:JurisdictionRs.Close:End If
  251. If oConn.State = 1 Then:oConn.Close:End If
  252. End Function
  253. Function CreateExportForSnailWorks(KitID)
  254. Dim State
  255. Dim ForeignTest
  256. If oConn.State = 0 Then:oConn.Open(ConnectionString):End If
  257. Dim KitRs:set KitRs = oConn.Execute("Select * From [Kit] Where [ID] =" & KitID & ";")
  258. If KitRs("OutboundSTID") <> "0" Then
  259. Dim KitLabelsRs: Set KitLabelsRs = oConn.Execute("SELECT InkjetRecords.ID, InkjetRecords.KitID, InkjetRecords.VOTERID, InkjetRecords.LASTNAME," &_
  260. " InkjetRecords.FIRSTNAME, InkjetRecords.MIDDLENAME, InkjetRecords.SUFFIX, InkjetRecords.PRECINCT," &_
  261. " InkjetRecords.ADDRESS1, InkjetRecords.ADDRESS2, InkjetRecords.ADDRESS3, InkjetRecords.ADDRESS4," &_
  262. " InkjetRecords.ADDRESS5, InkjetRecords.APPSENT, InkjetRecords.APPRETURNED, InkjetRecords.BALSENT," &_
  263. " InkjetRecords.BALRETURNED, InkjetRecords.CountingBoard, InkjetRecords.UOCAVASTATUS, InkjetRecords.EMAILADDRESS," &_
  264. " InkjetRecords.PHONENUMBER, InkjetRecords.BALLOT_NUMBER, InkjetRecords.CassADDRESS1, InkjetRecords.CassADDRESS2," &_
  265. " InkjetRecords.CassADDRESS3, InkjetRecords.CassADDRESS4, InkjetRecords.CassADDRESS5, InkjetRecords.KitLabelID," &_
  266. " KitLabels.ID, KitLabels.KitID, KitLabels.OutboundSerial, KitLabels.InBoundSerial, KitLabels.OutboundIMB," &_
  267. " KitLabels.InBoundIMB, KitLabels.OutboundIMBDigits, KitLabels.InBoundIMBDigits, KitLabels.OutboundIMBPNG," &_
  268. " KitLabels.INBOUNDIMBPNG, KitLabels.SetNumber" &_
  269. " FROM InkjetRecords" &_
  270. " LEFT JOIN [KitLabels] ON InkjetRecords.KitLabelID = KitLabels.ID" & _
  271. " WHERE InkjetRecords.KitID =" & KitID & " ;")
  272. Dim JurisdictionRs:Set JurisdictionRs = oConn.Execute("SELECT * FROM Jurisdiction WHERE JCode ='" & KitRs("Jcode").Value & "';")
  273. Dim ExportFileName:ExportFileName = objFSO.GetBaseName(KitRs("Filename")) & "_SW_EXPORT.csv"
  274. If Not objFSO.FolderExists(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value) Then:objFSO.CreateFolder(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value):End If
  275. If objFSO.FileExists(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName) Then:objFSO.DeleteFile(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName):End If
  276. Dim objExportFile:set objExportFile = objFSO.CreateTextFile(ExportDirectory & KitRs("JobNumber").Value & "-" & JurisdictionRs("Name").value & "/" & ExportFileName,2)
  277. With objExportFile
  278. .Write("""H"",") 'Record Type Required value must be = "H" (Header)
  279. .Write(Truncate("5.2",5)) 'Version Required value must be ="5.2" for current release
  280. .Write(Truncate("KCIHotFolder2024FTPUser",50)) 'UserId Required
  281. .Write(Truncate(KitRs("Jcode").Value,50)) 'Client Name Required (will create new subaccount if not already defined) - We decideded to make this the juriscode
  282. .Write(Truncate("",50)) 'Parent Client Name Optional (use if 3-tier account structure)
  283. .Write(Truncate("Purple envelope - " & KitRs("JobNumber").Value,50)) 'Job Name Required
  284. .Write(Truncate("",50)) 'Job Description Optional
  285. .Write(Truncate("",50)) 'Split Name Optional � will default to �Default�
  286. .Write(Truncate("",80)) 'Split Description Optional
  287. .Write(Truncate("L",1)) 'Piece Type Required L-Letters, C-Cards, F-Flats
  288. .Write(Truncate(Year(Now()) & "/" &_
  289. Right("0" & Month(Now()), 2) & "/" & Right("0" & Day(Now()), 2),10)) 'MailDate Required (YYYY/MM/DD)
  290. .Write(Truncate("N",1)) 'UploadType Required N = New job, new split A = Append new split to existing job R = Replace existing split
  291. .Write(Truncate("",8)) 'TrackedQuantity Optional
  292. .Write(Truncate("",8)) 'PiecesMailed Optional � shown as Estimated Quantity
  293. .Write(Truncate("",10)) 'Target InHomeDateStart Optional (YYYY/MM/DD)
  294. .Write(Truncate("",10)) 'Target InHomeDateEnd Optional (YYYY/MM/DD)
  295. .Write(Truncate("danielc@kentcommunications.com",100)) 'ConfirmationEmail Optional
  296. .Write(Truncate("",9)) 'JobId (SW) Optional for previously created jobs SWJobId
  297. .Write(Truncate("",4)) 'SplitId (SW) Optional for previously created jobs SWJobId
  298. .Write(Truncate(Choice(IsNull(KitRs("InboundSTID")),"O","R"),1)) 'TypeofTracking Required Values: O- Outbound Only I-Inbound Only R-Round Trip
  299. .Write(Truncate("",11)) 'ReturnedPostalRoutingCode
  300. .Write(Truncate("",2)) 'ReportId1
  301. .Write(Truncate("",255)) 'Report1Email
  302. .Write(Truncate("",2)) 'ReportId2
  303. .Write(Truncate("",255)) 'Report2Email
  304. .Write("""N""") 'INFOONLY
  305. .Write(vbCrLf)
  306. While Not KitLabelsRs.EOF
  307. ForeignTest = KitLabelsRs("CassADDRESS5").Value & " " & KitLabelsRs("CassADDRESS4").Value
  308. State = Truncate(Mid(KitLabelsRs("CassADDRESS5").Value, _
  309. InStr(KitLabelsRs("CassADDRESS5").Value, ",") + 2, 2),2)
  310. State = Replace(State," ","")
  311. If CheckStringDoesNotHaveForiegnCountries(ForeignTest) And State <> """""," then
  312. 'If InStr(ForeignTest,"CANADA") = 0 And InStr(ForeignTest,"AUSTRALIA") = 0 And State <> "" Then " ",
  313. .Write("""D"",") 'RecordType Required value must be = �D� (Detail)
  314. .Write(Truncate("",20)) 'CustomerUniqueIdentifier Optional- any identifier you designate
  315. .Write(Truncate(KitLabelsRs("OutboundIMBDigits"),31)) 'IMB Required � Unencoded, numeric IMB
  316. .Write(Truncate("",10)) 'Greeting Optional
  317. .Write(Truncate("",50)) 'First Name Optional
  318. .Write(Truncate("",2)) 'MI Optional
  319. .Write(Truncate("",50)) 'Last Name Optional
  320. .Write(Truncate("",10)) 'Suffix Optional
  321. .Write(Truncate((KitLabelsRs("CassADDRESS1").Value),100)) 'Full Name Optional
  322. .Write(Truncate("",50)) 'Company Optional
  323. .Write(Truncate("",50)) 'Title Optional
  324. .Write(Truncate(KitLabelsRs("CassADDRESS3").Value,128)) 'Address1 Optional
  325. .Write(Truncate(KitLabelsRs("CassADDRESS4").Value,128)) 'Address2 Optional
  326. .Write(Truncate(Left(KitLabelsRs("CassADDRESS5").Value, _
  327. InStr(KitLabelsRs("CassADDRESS5").Value, ",") - 1),50)) 'City Optional
  328. .Write(State) 'State Optional
  329. .Write Choice(InStr(KitLabelsRs("CassADDRESS5").Value,"-"),Truncate(Right(KitLabelsRs("CassADDRESS5").Value,11),11),Truncate(Right(KitLabelsRs("CassADDRESS5").Value,5),5)) 'Zip Optional
  330. .Write(Truncate(KitRs("Jcode"),100)) 'UserDefined1 Optional - Summary fields only
  331. .Write(Truncate("",100)) 'UserDefined2 Optional - Summary fields only
  332. .Write(Truncate("",100)) 'UserDefined3 Optional - Summary fields only
  333. .Write(Truncate(KitLabelsRs("PRECINCT").Value &_
  334. KitLabelsRs("BALLOT_NUMBER"),80)) 'UserDefinedIdentifier4 Optional � Allows for unique identifiers
  335. .Write(Truncate(KitLabelsRs("VOTERID").Value,80)) 'UserDefinedIdentifier5 Optional � Allows for unique identifiers
  336. .Write(Truncate("",1)) 'SeedIndicator Optional - if true provide �Y�
  337. .Write(Truncate("",80)) 'InductionPoint Optional
  338. .Write(Truncate("",10)) 'InductionDate Optional � Valid date format, ex. MM/DD/YYYY
  339. .Write(Truncate(Choice(IsNull(KitRs("InboundSTID")),"", _
  340. KitLabelsRs("InBoundIMBDigits").Value),31)) 'InboundIMB Optional � numeric IMB for Round trip jobs only
  341. .Write(Truncate("",24)) 'IMCB Optional � Container Barcode
  342. .Write("""""") 'IMTB Optional � Tray Barcode
  343. .Write(vbCrLf)
  344. End If
  345. KitLabelsRs.MoveNext
  346. Wend
  347. .Close
  348. End With
  349. If KitLabelsRs.State = 1 Then:KitLabelsRs.Close: End If
  350. If JurisdictionRs.State = 1 Then:JurisdictionRs.Close:End If
  351. End If
  352. oConn.Execute("UPDATE KIT SET [Status] ='Ready to Proof',[ExportedToSnailWorks] =#" & Now() & "# WHERE [ID] =" & KitID & ";")
  353. If oConn.State = 1 Then:oConn.Close:End If
  354. If KitRs.State = 1 Then:KitRs.Close:End If
  355. End Function
  356. Function createTrackingInfoForKit(KitID)
  357. If oConn.State = 0 Then:oConn.Open(ConnectionString):End If
  358. oConn.Execute("UPDATE Kit SET Status ='Applying Serial Numbers' WHERE ID =" & KitID & ";")
  359. Dim KitRs:set KitRs = oConn.Execute("Select * from Kit Where ID =" & KitID & ";")
  360. If KitRs("OutBoundSTID") = 0 Then
  361. oConn.Execute("UPDATE Kit Set [Status]='Ready For Export', LabelsPrinted=#" & Now() & "# WHERE [ID] =" & KitID &";")
  362. Else
  363. Dim InkjetRs:Set InkjetRs = oConn.Execute("Select * from InkjetRecords Where KitID =" & KitID & ";")
  364. Dim JurisRs:set JurisRs = oConn.Execute("Select Right(IMB_Digits,9) as IMBZip FROM Jurisdiction Where JCode ='" & KitRs("Jcode") & "';"):Dim Jcode:Jcode = JurisRs("IMBZip"):JurisRs.Close
  365. Dim SerialNumberStart:SerialNumberStart = GetSetting("SerialNumberStart")
  366. Dim serialOffset:serialOffset = GetSetting("SerialOffset")
  367. Dim serialStart:serialStart = CLng(GetSetting("SerialNumberStart")) + CLng(GetSetting("SerialOffset"))
  368. Dim Counter:Counter=0
  369. Dim KitLabelID
  370. Dim KitLabelRs
  371. Dim Mid:Mid = GetSetting("MailingID")
  372. Dim Step : If KitRs("InboundSTID") <> "" Then : Step = 2 : Else Step = 1
  373. serialStart = PadLeft(serialStart + CLng(Counter),9,"0")
  374. Dim oRsKitLabels : Set oRsKitLabels = CreateObject("ADODB.Recordset"):oRsKitLabels.Open "Select * FROM [KitLabels] Where KitID =" & KitID & ";",oConn,3,3
  375. While Not InkjetRs.EOF
  376. oRsKitLabels.AddNew
  377. KitLabelID = oRsKitLabels("ID").value
  378. If Step = 1 Then
  379. oRsKitLabels("KitID") = KitID
  380. oRsKitLabels("OutboundSerial") = serialStart
  381. oRsKitLabels("OutboundIMBDigits") = KitRs("OutBoundSTID").Value & Mid & serialStart
  382. Else
  383. oRsKitLabels("KitID") = KitID
  384. oRsKitLabels("OutboundSerial") = serialStart
  385. oRsKitLabels("InBoundSerial") = serialStart + 1
  386. oRsKitLabels("OutboundIMBDigits") = KitRs("OutBoundSTID").Value & Mid & serialStart
  387. oRsKitLabels("InBoundIMBDigits") = KitRs("InboundSTID").Value & Mid & serialStart + 1 & Jcode
  388. End If
  389. oRsKitLabels.Update
  390. oConn.Execute("UPDATE InkjetRecords Set [KitLabelID]=" & KitLabelID & " WHERE ID=" & InkjetRs("ID") & ";")
  391. Counter = Counter + Step
  392. serialStart = serialStart + Step
  393. InkjetRs.MoveNext
  394. Wend
  395. oRsKitLabels.Update
  396. oRsKitLabels.Close
  397. oConn.Execute("UPDATE Settings Set [Value]='" & serialOffset + Counter & "' WHERE [Name] = 'SerialOffset';")
  398. oConn.Execute("UPDATE Kit Set [Status]='Ready For Export', LabelsPrinted=#" & Now() & "# WHERE [ID] =" & KitID &";")
  399. oConn.Close
  400. End If
  401. End Function
  402. Function GetSetting(settingName)
  403. Dim rs:Set rs = oConn.Execute("Select Value From [Settings] Where [Name] = '" & settingName & "';")
  404. If Not rs.EOF Then
  405. GetSetting = rs(0).value
  406. rs.Close
  407. Else
  408. SetSetting = 0
  409. rs.Close
  410. End If
  411. End Function
  412. Function CheckForFiles()
  413. If objFSO.FolderExists(DataDirectory) Then
  414. Dim objFolder:Set objFolder = objFSO.GetFolder(DataDirectory)
  415. If objFolder.Files.Count > 0 Then
  416. 'WScript.Echo "Files found in directory: " & DataDirectory
  417. Dim objFile
  418. For Each objFile In objFolder.Files
  419. Dim CsvString:CsvString = ConvertCsvToString(objFile.Path)
  420. If ValidImportCSV(CsvString) Then
  421. SetupKit CsvString,objFile.Name
  422. objFSO.MoveFile objFile.Path, DataDirectory & "\import\" & objFile.Name
  423. End If
  424. Next
  425. Else
  426. 'WScript.Echo "No files found in directory: " & DataDirectory
  427. End If
  428. End If
  429. End Function
  430. Function ValidJcode(jcode)
  431. Dim oConn
  432. Set oConn = WScript.CreateObject("ADODB.Connection")
  433. oConn.ConnectionString = ConnectionString
  434. oConn.Open
  435. Dim oRs
  436. set oRs = oConn.Execute("Select * from Jurisdiction Where [JCode] = '" & jcode & "';")
  437. If oRs.EOF Then
  438. ValidJcode = 0
  439. Else
  440. ValidJcode = 1
  441. End If
  442. oRs.Close
  443. oConn.Close
  444. End Function
  445. Function CheckStringDoesNotHaveForiegnCountries(StringToCheck)
  446. Dim Countries
  447. Countries = Array("UNITED KINGDOM","NORWAY","AUSTRALIA","FRANCE","UK LL","KENT ENGLAND","CANADA","NETHERLANDS","GERMANY","TAIWAN","NICARAGUA","IREL")
  448. Dim Country
  449. For Each Country In Countries
  450. If InStr(StringToCheck,Country) Then
  451. CheckStringDoesNotHaveForiegnCountries = False
  452. Exit For
  453. End If
  454. CheckStringDoesNotHaveForiegnCountries = True
  455. Next
  456. End Function
  457. Function SetupKit(CsvString,FileName)
  458. Dim JobNumber:JobNumber = Mid(FileName,9,6)
  459. Dim JCode:JCode = Left(Filename,5)
  460. If IsNumeric(JobNumber) Then
  461. If ValidJcode(JCode) Then
  462. WScript.Echo FileName & " Is a Valid CSV for Importing"
  463. Dim oConn:Set oConn = WScript.CreateObject("ADODB.Connection")
  464. oConn.ConnectionString = ConnectionString
  465. oConn.Open
  466. oConn.Execute("Insert Into Kit ([JobNumber], [Jcode], [CreatedOn], [JobType],[Filename],[Status]) VALUES ('" & JobNumber & "','" & JCode & "',#" & Now() & "#,'Purple Envelopes','" & FileName & "','Importing');")
  467. Dim rs : set rs = oConn.Execute("Select TOP 1 ID from Kit ORDER BY ID DESC")
  468. Dim kitId : kitId = rs("ID").value
  469. rs.close
  470. Dim i
  471. For i = 1 To objCSV.NumRows -1
  472. oConn.Execute("Insert Into [InkjetRecords] (KitID,VOTERID,LASTNAME,FIRSTNAME,MIDDLENAME" & _
  473. ",SUFFIX,PRECINCT,ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4,ADDRESS5,APPSENT,APPRETURNED,BALSENT,BALRETURNED" & _
  474. ",CountingBoard,UOCAVASTATUS,EMAILADDRESS,PHONENUMBER,BALLOT_NUMBER) VALUES (" & kitId & _
  475. ",'" & Replace(objCSV.GetCell(i,0),"'","''") & _
  476. "','" & objCsv.GetCell(i,1) & _
  477. "','" & Replace(objCSV.GetCell(i,2),"'","''") & _
  478. "','" & Replace(objCSV.GetCell(i,3),"'","''") & _
  479. "','" & Replace(objCSV.GetCell(i,4),"'","''") & _
  480. "','" & Replace(objCSV.GetCell(i,5),"'","''") & _
  481. "','" & Replace(objCSV.GetCell(i,6),"'","''") & _
  482. "','" & Replace(objCSV.GetCell(i,7),"'","''") & _
  483. "','" & Replace(objCSV.GetCell(i,8),"'","''") & _
  484. "','" & Replace(objCSV.GetCell(i,9),"'","''") & _
  485. "','" & Replace(objCSV.GetCell(i,10),"'","''") & _
  486. "','" & Replace(objCSV.GetCell(i,11),"'","''") & _
  487. "','" & Replace(objCSV.GetCell(i,12),"'","''") & _
  488. "','" & Replace(objCsv.GetCell(i,13),"'","''") & _
  489. "','" & objCsv.GetCell(i,14) & _
  490. "','" & objCsv.GetCell(i,15) & _
  491. "','" & objCsv.GetCell(i,16) & _
  492. "','" & objCsv.GetCell(i,17) & _
  493. "','" & objCsv.GetCell(i,18) & _
  494. "','" & objCsv.GetCell(i,19) & _
  495. "')")
  496. Next
  497. oConn.Execute("Update Kit SET [Status] = 'Ready to Cass' Where ID = " & kitId &";")
  498. 'oConn.Close
  499. End If
  500. End If
  501. End Function
  502. Function ConvertCsvToString(FilePath)
  503. Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
  504. Dim objCsvFile:set objCsvFile = objFSO.OpenTextFile(FilePath)
  505. Dim strContent:strContent = ""
  506. Dim intLineCount:intLineCount = 0
  507. Do Until objCsvFile.AtEndOfStream Or intLineCount >= 3
  508. objCsvFile.SkipLine
  509. intLineCount = intLineCount + 1
  510. Loop
  511. ' Read the remaining content into a string
  512. Do Until objCsvFile.AtEndOfStream
  513. Dim strLine:strLine = objCsvFile.ReadLine
  514. strContent = strContent & strLine & vbCrLf
  515. Loop
  516. ConvertCsvToString = strContent
  517. End Function
  518. Function ValidImportCSV(CsvFileAsString)
  519. objCSV.LoadFromString(CsvFileAsString)
  520. If objCSV.NumColumns = 20 Then
  521. ValidImportCSV = True
  522. Else
  523. ValidImportCSV = False
  524. End If
  525. End Function
  526. Sub ImportCass
  527. Dim currentRow
  528. Select Case dev
  529. Case "local"
  530. objCsv.LoadFile("C:\Share\TrackingDataExport\FROM_MM.CSV")
  531. Case True
  532. objCsv.LoadFile("C:\Share\TrackingDataExport\FROM_MM.CSV")
  533. Case Else
  534. objCsv.LoadFile("\\kci-syn-cl01\PC Transfer\TrackingDataExport\FROM_MM.CSV")
  535. End Select
  536. For currentRow = 0 To objCsv.NumRows -1
  537. oConn.Execute("UPDATE InkJetRecords SET CassADDRESS1 = '" & Replace(objCsv.GetCell(currentRow,1),"'","''") & "', " &_
  538. "CassADDRESS2 = '" & Replace(objCSV.GetCell(currentRow,3),"'","''") & "', " &_
  539. "CassADDRESS3 = '" & Replace(objCSV.GetCell(currentRow,4),"'","''") & "', " &_
  540. "CassADDRESS4 = '" & Replace(objCSV.GetCell(currentRow,5),"'","''") & "', " &_
  541. "CassADDRESS5 = '" & Replace(objCsv.GetCell(currentRow,6) & ", " & objCsv.GetCell(currentRow,7) & " " & objCsv.GetCell(currentRow,8),"'","''") & "'" &_
  542. " WHERE ID = " & objCSV.GetCell(currentRow,0) & ";")
  543. Next
  544. oConn.Execute("UPDATE Kit SET Status ='Ready To Assign STIDS' WHERE ID =" & KitID & ";")
  545. oConn.Execute("UPDATE Kit SET [Cass] = 1 WHERE ID =" & KitID & ";")
  546. End Sub
  547. Sub RunMailManager
  548. Select Case dev
  549. Case "local"
  550. WshShell.Run "PsExec64.exe -i -e -u ntp\danielc -p SunBrightShine! \\MarkH2 ""\\MM2012\APPS\BCC\MM2010\mailman.exe"" -p -j MMJOB-LOCAL.mjb -u DAN",1,True
  551. Case True
  552. WshShell.Run "PsExec64.exe -i -e -u ntp\danielc -p SunBrightShine! \\MarkH2 ""\\MM2012\APPS\BCC\MM2010\mailman.exe"" -p -j MMJOB-DEV.mjb -u DAN",1,True
  553. Case Else
  554. WshShell.Run "PsExec64.exe -i -e -u ntp\danielc -p SunBrightShine! \\MarkH2 ""\\MM2012\APPS\BCC\MM2010\mailman.exe"" -p -j MMJOB.mjb -u DAN",1,True
  555. End Select
  556. End Sub
  557. Sub ExportMMCsv(KitId)
  558. Dim success
  559. objCsv.HasColumnNames = 1
  560. objCSV.EnableQuotes = 1
  561. success = objCsv.SetColumnName(0,"ID")
  562. success = objCsv.SetColumnName(1,"NAME")
  563. success = objCsv.SetColumnName(2,"ADDRESS1")
  564. success = objCsv.SetColumnName(3,"ADDRESS2")
  565. success = objCsv.SetColumnName(4,"ADDRESS3")
  566. success = objCsv.SetColumnName(5,"ADDRESS4")
  567. success = objCsv.SetColumnName(6,"ADDRESS5")
  568. Dim rs : Set rs = oConn.Execute("Select ID," & _
  569. "IIF(FIRSTNAME IS NULL,'',FIRSTNAME & ' ') & " & _
  570. "IIF(MIDDLENAME IS NULL,'',MIDDLENAME & ' ') & " & _
  571. "IIF(LASTNAME IS NULL,'',LASTNAME & ' ') & " & _
  572. "IIF(SUFFIX IS NULL,'',SUFFIX & ' ') " & _
  573. "AS NAME, ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4,ADDRESS5 FROM InkjetRecords WHERE KitID =" & KitID & " ORDER By ID;")
  574. Dim CurrentRow:CurrentRow = 0
  575. While Not rs.EOF
  576. objCSV.SetCell CurrentRow,0,rs("ID").value
  577. objCSV.SetCell CurrentRow,1,rs("NAME").value
  578. objCSV.SetCell CurrentRow,2,rs("ADDRESS1").value
  579. objCSV.SetCell CurrentRow,3,rs("ADDRESS2").value
  580. objCSV.SetCell CurrentRow,4,rs("ADDRESS3").value
  581. objCSV.SetCell CurrentRow,5,rs("ADDRESS4").value
  582. objCSV.SetCell CurrentRow,6,rs("ADDRESS5").value
  583. rs.MoveNext
  584. CurrentRow = CurrentRow +1
  585. Wend
  586. Dim CsvString:CsvString = objCSV.SaveToString()
  587. outFile.WriteLine CsvString
  588. outFile.Close
  589. End Sub
  590. Function CheckForJobsToCass()
  591. oConn.ConnectionString = ConnectionString
  592. oConn.Open
  593. 'oConn.Open
  594. Dim rs : set rs = oConn.Execute("Select TOP 1 ID from Kit Where Status ='Ready to Cass' ORDER BY ID DESC;")
  595. If Not rs.EOF Then
  596. Dim kitId : kitId = rs("ID").value
  597. rs.Close
  598. CheckForJobsToCass = KitID
  599. oConn.Execute("UPDATE Kit SET Status ='Cassing' WHERE ID =" & KitID & ";")
  600. Else
  601. CheckForJobsToCass = 0
  602. End If
  603. 'oConn.Close
  604. End Function
  605. Public Function PadLeft(originalString,desiredLength,Char)
  606. Dim padLength
  607. padLength = desiredLength - Len(originalString)
  608. If padLength > 0 Then
  609. ' Left pad the string with zeros
  610. PadLeft = String(padLength, Char) & originalString
  611. Else
  612. ' If the original string is already longer or equal to the desired length, no padding is needed
  613. PadLeft = originalString
  614. End If
  615. End Function
  616. Function Truncate(inputString, size)
  617. If Len(inputString) > size Then:Truncate = """" & Left(inputString,size) & """,":Else Truncate = """" & inputString & """,":End If
  618. End Function
  619. Function PadString(inputString, size)
  620. Dim paddedString
  621. Dim inputLength
  622. Dim i
  623. If IsNull(inputString) Then:inputString = ""
  624. ' Get the length of the input string
  625. inputLength = Len(inputString)
  626. ' If the input string is already equal to or longer than the specified size, return it as is
  627. If inputLength >= size Then
  628. PadString = inputString
  629. Exit Function
  630. End If
  631. ' Initialize the padded string with the input string
  632. paddedString = inputString
  633. ' Pad spaces to the right of the input string until it reaches the specified size
  634. For i = 1 To (size - inputLength)
  635. paddedString = paddedString & " "
  636. Next
  637. ' Return the padded string
  638. PadString = paddedString
  639. End Function
  640. Function CleanNull(StringToClean)
  641. If IsNull(StringToClean) Then:CleanNull = "":Else CleanNull = StringToClean:End If
  642. End Function
  643. Public Sub Assign(ByRef var, ByVal val)
  644. If IsObject(val) Then
  645. Set var = val
  646. Else
  647. var = val
  648. End If
  649. End Sub
  650. Public Function Choice(ByVal cond, ByVal if_true, ByVal if_false)
  651. If cond Then
  652. Assign Choice, if_true
  653. Else
  654. Assign Choice, if_false
  655. End If
  656. End Function
  657. Function CompressArray(arr)
  658. Dim temp,i,j
  659. For i = LBound(arr) To UBound(arr) - 1
  660. For j = i + 1 To UBound(arr)
  661. If arr(i) = "" Then
  662. temp = arr(i)
  663. arr(i) = arr(j)
  664. arr(j) = temp
  665. End If
  666. Next
  667. Next
  668. CompressArray = arr
  669. End Function
  670. Function TrimLeadingZeros(inputStr)
  671. Dim i
  672. For i = 1 To Len(inputStr)
  673. If Mid(inputStr, i, 1) <> "0" Then
  674. TrimLeadingZeros = Mid(inputStr, i)
  675. Exit Function
  676. End If
  677. Next
  678. ' If the input string is all zeros, return "0"
  679. TrimLeadingZeros = "0"
  680. End Function

Powered by TurnKey Linux.