<HTML>
<HEAD>
	<TITLE>GoatPad</TITLE>

	<HTA: APPLICATION ID="objGoatPad"
	APPLICATIONNAME="Goat Pad"
	VERSION="1.37"
	BORDER="thin"
	BORDERSTYLE="normal"
	CAPTION="no"
	ICON=""
	MAXIMIZEBUTTON="no"
	MINIMIZEBUTTON="yes"
	SHOWINTASKBAR="yes"
	SINGLEINSTANCE="yes"
	SYSMENU="yes"
	SCROLL="no"
	WINDOWSTATE="normal"/>

<Script Language="VBScript">

Option Explicit 
On Error Resume Next
Dim objFolder, colFiles, objFile, objOption
Dim InputFile, objShell, FSO, oFile, strFileName, objExcel, objWorkbook, objSheet, Sheet, strExcelPath, row, curDate, mySummary, iArray, iA, iData(), iStart, iEnd, iB
Dim	strData, strName, strTemp, tempStr, strPath, myLink, myChoice, message, title, defaultValue, myTicket, myLang, sizeToggle
Dim objSysInfo,strUserDN,objUser

Sub Window_OnLoad
	window.resizeTo 1100,700
	Set objShell = CreateObject("Wscript.Shell")
	strPath = objShell.CurrentDirectory								'Get current directory to use as reference point
	Set FSO = CreateObject("Scripting.FileSystemObject")
	CheckFolders
	Set objFolder = FSO.GetFolder(strPath & "\Templates")
	Set colFiles = objFolder.Files
	document.title = strPath & "\GoatPad v" & objGoatPad.version	'Shows Path and Version number in the title bar
	message = "Enter your First Name: "
	title = "First Name?"
	' defaultValue = objShell.ExpandEnvironmentStrings("%USERNAME%")	'Default name is pulled from System login name.
	' Retrieve Distinguished Name of current user.
     Set objSysInfo = CreateObject("ADSystemInfo")
     strUserDN = objSysInfo.UserName
     ' Bind to the user object in Active Directory.
     Set objUser = GetObject("LDAP://" & strUserDN)
     ' Retrieve the first name of the user (if assigned).
     defaultValue = objUser.givenName
	strName=InputBox(message,title,defaultValue)					'Prompt the user to input their first name
	If strName="" Then strName = defaultValue						'If the user intentional leaves it blank, populate it with defaultValue
	iArray=Array("Ticket Summary:","Reporter Name:","Reporter Phone:","Reporter Dept:","Reporter Email:","Partner Service Desk Ticket number:","Problem description:","Activity description:")
	Redim iData(UBound(iArray))
	row="1"
	myTicket="XXXXXX"
	myLang="en"
	PopulateFreeform
	PopulateScript1
	PopulateScript2
	PopulateOtherScript
	FixSize
	OpenExcelFile
	PopulateTemplateList	'New Way to Populate Template Dropdown List
End Sub

Sub Window_OnUnload
	objExcel.ActiveWorkbook.Close	'Close the WorkBook
	objExcel.Application.Quit		'Quit Excel
	ExitHTA
End Sub

Sub CheckFolders
	If NOT (FSO.FolderExists(strPath + "\Templates")) Then FSO.CreateFolder(strPath + "\Templates")
	If NOT (FSO.FolderExists(strPath + "\Tickets")) Then FSO.CreateFolder(strPath + "\Tickets")
	If NOT (FSO.FolderExists(strPath + "\Scripts")) Then FSO.CreateFolder(strPath + "\Scripts")
End Sub

Sub ShowSize	'Not in use to show size but to resize to minimum nice-looking window size.
	'document.title= strPath & "\GoatPad v" & objGoatPad.version & " - " & document.body.offsetHeight & " by " & document.body.offsetWidth
	If document.body.offsetWidth<1020 Then
		window.resizeTo 1020, 640
	End If
End Sub

Sub FixSize
	If SizeToggle="1" Then
		window.resizeBy 0, 1
		window.resizeBy 0, -1
		SizeToggle="0"
	Else
		window.resizeBy 0, -1
		window.resizeBy 0, 1
		SizeToggle="1"
	End If
End Sub

Sub ClearPad
	pad.value=""
End Sub

Sub CheckTicket
	If txtTicket.value="" Then
		myTicket="XXXXXX"
	Else
		myTicket=txtTicket.value
	End If
	PopulateScript2
End Sub

Sub ClearTicket
	txtTicket.value=""
	CheckTicket
	PopulateFreeform
	PopulateScript1
	PopulateScript2
	PopulateOtherScript
End Sub

Sub PopulateFreeform
	If (FSO.FileExists(strPath & "\Scripts\Greeting.txt")) Then		'Search for Greeting.txt file
		InputFile = strPath & "\Scripts\Greeting.txt" 				'set file to current directory\scripts\file.txt
		Set oFile = FSO.OpenTextFile(InputFile) 					'Open file to memory
		freeform.value = oFile.ReadAll 								'Read file and set to freeform section
		oFile.Close													'Close file from memory
		freeform.value=Replace(freeform.value,"<name>",strName)		'Replace "<name>" with Agent's First Name as entered in the message box prompt
	Else															'If file can't be found, hardcoded template can be used
		freeform.value="Thank you for calling the Service Desk my name is " & strName & ", could I have your first and last name please?" & vbCrLf & "Merci d'avoire appeler le bureau de service mon nom est " &strName & " puis j'avoir votre prnom et nom de famille s'il vous plait?" & vbCrLf & vbCrLf & "Reporter Name: " & vbCrLf & "Reporter Phone: " & vbCrLf & "Dept: " & vbCrLf & "Partner Service Desk Ticket number: " & vbCrLf & "Problem description: " & vbCrLf & vbCrLf & "Assigning to XXXXXXXX as per interested party for CI: XXXXXXX - XXXXXXXXXXXXXXXXX"
	End If
End Sub

Sub PopulateScript1
	If myLang="en" Then												'If English is selected (default)
		If (FSO.FileExists(strPath & "\Scripts\Script1en.txt")) Then
			InputFile = strPath & "\Scripts\Script1en.txt"
			Set oFile = FSO.OpenTextFile(InputFile)
			pScript1.innerText = oFile.ReadAll
			oFile.Close
			pScript1.innerText=Replace(pScript1.innerText,"<name>",strName)
		Else
			pScript1.innerText="Thank you for calling the Service Desk my name is " & strName & ", could I have your first and last name please?"
		End If
	ElseIf myLang="fr" Then
		If (FSO.FileExists(strPath & "\Scripts\Script1fr.txt")) Then
			InputFile = strPath & "\Scripts\Script1fr.txt"
			Set oFile = FSO.OpenTextFile(InputFile)
			pScript1.innerText = oFile.ReadAll
			oFile.Close
			pScript1.innerText=Replace(pScript1.innerText,"<name>",strName)
		Else
			pScript1.innerText= "Merci d'avoire appeler le bureau de service mon nom est " & strName & ", puis j'avoir votre prnom et nom de famille s'il vous plait?"
		End If
	End If
End Sub

Sub PopulateScript2
	If myLang="en" Then												'If English is selected (default)
		If (FSO.FileExists(strPath & "\Scripts\Script2en.txt")) Then
			InputFile = strPath & "\Scripts\Script2en.txt"
			Set oFile = FSO.OpenTextFile(InputFile)
			pScript2.innerText = oFile.ReadAll
			oFile.Close
			pScript2.innerText=Replace(pScript2.innerText,"<ticket>",myTicket)
		Else
			pScript2.innerText="Your reference number for this call is " & myTicket & ". Is there anything else I can assist with? Thank you for calling the Service Desk."
		End If
	ElseIf myLang="fr" Then
		If (FSO.FileExists(strPath & "\Scripts\Script2fr.txt")) Then
			InputFile = strPath & "\Scripts\Script2fr.txt"
			Set oFile = FSO.OpenTextFile(InputFile)
			pScript2.innerText = oFile.ReadAll
			oFile.Close
			pScript2.innerText=Replace(pScript2.innerText,"<ticket>",myTicket)
		Else
			pScript2.innerText="Voici votre numro de billet " & myTicket & ", Est-ce qu'il y a autre chose avec laquelle je puisse vous aider? Merci d'avoire apell le bureau6 de service."
		End If
	End If
End Sub

Sub PopulateOtherScript
	If (FSO.FileExists(strPath & "\Scripts\ScriptOther.txt")) Then		'Load the Other section
			InputFile = strPath & "\Scripts\ScriptOther.txt"
			Set oFile = FSO.OpenTextFile(InputFile)
			pOther.innerText = oFile.ReadAll
			oFile.Close
		Else
			pOther.innerText="Assigning to XXXXXXX as per interested party for CI XXXXXXX - XXXXXXXXXXX"
		End If
End Sub

Sub CopyData
	CheckData
	FillData
End Sub

Sub CheckData
	If Right(freeform.value,1) <> chr(10) Then freeform.value=freeform.value & vbCrLf	'Check for Carriage Return at the end of Freeform, if not found, put one.
	For iA = 0 to uBound(iArray)
		If InStr(freeform.value,iArray(iA))>0  Then
			iStart=(InStr(freeform.value,iArray(iA))+len(iArray(iA)))		'Set starting point for next line by finding Array Data and adding the length of itself.
			iEnd=InStr(iStart,freeform.value,chr(13))						'Finds the position of LineBreak after Array Data position
			iData(iA)=Mid(freeform.value,iStart,iEnd - iStart)				'Store the characters in between End of Array Data and the Line Break to a new Array
		End If
	Next
	mySummary=iData(0)		'Set summary to 1st item in Data Array !Verify if variables in the iArray match!
End Sub
	
Sub FillData
	tempStr = pad.value		'Store Data for manipulation
	
	For iB = 0 to uBound(iArray)				'Loop through the Array
		If InStr(tempStr,iArray(iB))>0 Then		'If Array Data is found
			tempStr = Left(tempStr, (InStr(tempStr,iArray(iB))+len(iArray(iB)))) + iData(iB) + Mid(tempStr, (InStr(tempStr,iArray(iB))+Len(iArray(iB))))			'Replace string with (Before the end of Array Data) plus (value of stored Data Array) plus (anything after Array Data)
			pad.value = tempStr					'Save the temp file to the Pad
			CheckData							'Check Data again since start and end positions may change.
		End If
	Next
	
	'Reset Data Array
	For iA = 0 to uBound(iArray)
		iData(iA)=""
	Next
End Sub

Sub ExitHTA
	self.close()
End Sub

Sub DropChoice
	myChoice=myList.Value
	ClearPad
	If FSO.FileExists(strPath & "\Templates\" & myChoice) Then				'Check if file exists
		If FSO.GetFile(strPath & "\Templates\" & myChoice).Size > 0	Then	'Check if file isn't empty
			InputFile = strPath & "\Templates\" & myChoice					'Select file location
			Set oFile = FSO.OpenTextFile(InputFile) 						'Open the file
			pad.value = pad.value & oFile.ReadAll 							'Read file and place value in the Pad
			oFile.Close 													'Close the file
			pad.value=Replace(pad.value,"<name>",strName)					'Replace "<name>" with the agent's name as entered in the first prompt
		Else
			pad.value=pad.value & vbCrLf & "Oops! FILE CONTAINS NO DATA - Verify the file in the \Templates folder" & vbCrLf & vbCrLf & strPath & "\Templates\" & myChoice & vbCrLf
		End If
	Else
		pad.value=pad.value & vbCrLf & "Oops! FILE COULD NOT BE LOCATED - Try Reloading GoatPad" & vbCrLf & vbCrLf & strPath & "\Templates\" & myChoice & vbCrLf
	End If
End Sub

Sub GOPmsg
	MsgBox "JUS - Department of Justice (aka DOJ)" & vbCrLf & "LAC - Library and Archives" & vbCrLf & "PCO - Privy Council (aka PMO)" & vbCrLf & "PSC - Public Service Commission" & vbCrLf & "TBS - Treasury Board of Canada" & vbCrLf & vbCrLf & "RFC's from these deptartments get assigned to NATCOGD in Infoweb", 48, "Government Organizational Partners"
End Sub

Sub SearchResource
		tempStr = myList.value						'Get the search words from the drop-list
		tempStr = Left(tempStr, (LEN(tempStr)-4))	'Remove the .txt
		tempStr = Right(tempStr, (LEN(tempStr)-4))	'Remove the number prefix (first 4 characters)
		tempStr = Replace(tempStr," Template","")	'Remove Template from string
		tempStr = Replace(tempStr," Related","")	'Remove Related from string
		tempStr = Replace(tempStr," ","+")			'Replace spaces with plus-sign
		myLink="https://gcdocs.gc.ca/ssc-spc/llisapi.dll?slice=5227282&searchbarwidgetmode=fulltext&where1=" & tempStr & "&ScopeSelection=5227282&lookfor1=allwords&modifier1=relatedto&boolean2=And&lookfor2=complexquery&typeDropDownId=1&boolean3=And&lookfor3=complexquery&userDropDownId=1&dateDropDownId=1&func=search&objType=258&SearchBarSearch=TRUE&facets=user&fulltextMode=allwords"
		CreateObject("WScript.Shell").Run(myLink)	'Open the Link
End Sub

Sub openCBAS
	myLink="https://gcdocs.gc.ca/ssc-spc/llisapi.dll?func=ll&objaction=overview&objid=2697466"
	CreateObject("WScript.Shell").Run(myLink)
End Sub

Sub ToggleLanguage
	If myLang="en" Then
		'Make Everything French
		myLang="fr"
		btnLanguage.value="English"
	Else
		'Make Everything English
		myLang="en"
		btnLanguage.value="Francais"
	End If
	PopulateScript1
	PopulateScript2
End Sub

Sub OpenExcelFile
	'Set the save location
	curDate = Day(Date) & "_" & MonthName(Month(Date)) & "_" & Year(Date)				'Format Date
	strExcelPath = strPath & "\Tickets\" & curDate & " - " & strName & ".xlsx"			'Select FileName
	Set objExcel = CreateObject("Excel.Application")			'Bind to the Excel object
	If (FSO.FileExists(strExcelPath)) Then						'If the file already exists:
		objExcel.Workbooks.Open(strExcelPath)					'Open the workbook
		Sheet = 1												'Select the first worksheet
		Set objSheet = objExcel.ActiveWorkbook.Worksheets(Sheet)'Bind to the worksheet
	Else
		objExcel.Workbooks.Add									'Create a new workbook.
		Sheet = 1												'Select the first sheet
		Set objSheet = objExcel.ActiveWorkbook.Worksheets(Sheet)'Bind to the worksheet.
		objSheet.Name = strName & " Tickets"					'Name the worksheet
		'Add some titles to row 1
		objSheet.Cells(1, 1).Value = "Ticket #"					'Row 1 Column 1 (A)
		objSheet.Cells(1, 2).Value = "Summary"					'Row 1 Column 2 (B)
		objSheet.Cells(1, 3).Value = "Date & Time"				'Row 1 Column 3 (C)
		'--------------------------------------------------------
		' Format the spreadsheet
		'--------------------------------------------------------
 
		objSheet.Range("A1:C1").Font.Bold = True				'Put the first row in bold
		objSheet.Range("A1:C1").Font.Size = 14					'Change the font size of the first row to 14
		objSheet.Range("A2").Select								'Select range to freeze
		objExcel.ActiveWindow.FreezePanes = True				'Freeze the panes
		objExcel.Columns(1).ColumnWidth = 20					'Change column A and B to use a fixed width
		objExcel.Columns(2).ColumnWidth = 30
		objExcel.Columns(3).AutoFit()							'Change column C to autofit
		objExcel.Columns(1).Interior.ColorIndex = 36			'Change the background colour of column A to a light yellow
		objExcel.Columns(3).Font.ColorIndex = 5					'Change the font colour of column C to blue
		
		objExcel.ActiveWorkbook.SaveAs strExcelPath				'Save the spreadsheet As
	End If
	
End Sub

Sub PopulateExcelFile
	CheckData				'To fill the mySummary Field
	'--------------------------------------------------------
	'Populate the worksheet with data
	'--------------------------------------------------------
	'   objSheet.Cells(row, column).Value = "Whatever"
 
	objExcel.Workbooks.Open(strExcelPath)					'Open the workbook
	Sheet = 1												'Select the first worksheet
	Set objSheet = objExcel.ActiveWorkbook.Worksheets(Sheet)'Bind to the worksheet
	If txtTicket.value <> "" Then
		Do Until Len(objSheet.Cells(row, 1).Value) = 0		'Find the First Empty Row
			row = row + 1									'Point to the Next Row
		Loop
		objSheet.Cells(row, 1).Value = myTicket				'Add Ticket Number to the 1st column
		objSheet.Cells(row, 2).Value = mySummary			'Add Summary to the 2nd column
		objSheet.Cells(row, 3).Value = Now					'Timestamp the 3rd column
		objExcel.ActiveWorkbook.Save						'Save the Excel Workbook
		row = "1"											'Reset Row pointer
	End If
End Sub

Sub PopulateTemplateList
	For Each objFile in colFiles									'Repeat for each file in the Templates folder
		Set objOption = Document.createElement("OPTION")			'Bind to the Option element
		objOption.Text = Left(objFile.Name, (LEN(objFile.Name)-4))	'Set the Option text, minus the last 4 characters (".txt") in the filename
		objOption.Value = objFile.Name								'Set the Option value to the filename
		myList.Add(objOption)										'Add the Option to the myList
	Next
End Sub

</SCRIPT>
<style type="text/css">
BODY {
	FONT-FAMILY: Georgia, Serif; TEXT-ALIGN: center ; BODY..MARGIN-TOP: 10px
}
#frame {
	WIDTH: 100% ; HEIGHT: 100%; TEXT-ALIGN: left
}
#main {
	font-size:70% ; WIDTH: 100% ; HEIGHT: 96%; BACKGROUND: #f5f5f5; PADDING-TOP: 10px; PADDING-BOTTOM: 5px; PADDING-LEFT: 10px; MARGIN: 5px; PADDING-RIGHT: 10px
}
#leftcontent {
	HEIGHT:95%; BORDER-TOP: #cccccc 1px dashed; BORDER-RIGHT: #cccccc 1px dashed; WIDTH: 15%; BACKGROUND: #dddddd; BORDER-BOTTOM: #cccccc 1px dashed; FLOAT: left; PADDING-BOTTOM: 5px; PADDING-TOP: 10px; PADDING-LEFT: 10px; BORDER-LEFT: #cccccc 1px dashed; MARGIN: 5px; PADDING-RIGHT: 10px
}
#rightcontent {
	HEIGHT:95%; BORDER-TOP: #cccccc 1px dashed; BORDER-RIGHT: #cccccc 1px dashed; WIDTH: 25%; BACKGROUND: #ddeeff; BORDER-BOTTOM: #cccccc 1px dashed; FLOAT: right; PADDING-BOTTOM: 5px; PADDING-TOP: 10px; PADDING-LEFT: 10px; BORDER-LEFT: #cccccc 1px dashed; MARGIN: 5px; PADDING-RIGHT: 10px
}
#rightcontent P {
	FONT-SIZE: 15px
}
#leftcontent A {
	FONT-SIZE: 15px; LINE-HEIGHT: 2
}
H1 {
	FONT-SIZE: large
}
.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 1px 1px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}
</style>
</HEAD>
<BODY SCROLL="no" style="min-width:1010px" onresize="ShowSize"> <!--  //-->
<div id="frame" style="clear:both;">
    <div id="leftcontent">
      <h1>Links</h1><a title="Open the GetAnswers knowledge base" href="http://papw-vigors/oaa/login.jsp">Get Answers</a><br>
      <a title="Search GCDocs for a relevant article based on your Template selection" href="#" onclick="SearchResource">GCDocs</a><br>
      <a title="Open the Standard Template doc in GCDocs" href="https://gcdocs.gc.ca/ssc-spc/llisapi.dll?func=ll&objaction=overview&objid=4827987">Standard_Templates</a><br>
      <a title="Open the most up-to-date CBAS file" href="https://gcdocs.gc.ca/ssc-spc/llisapi.dll?func=ll&objaction=overview&objid=2697466">CBAS</a><br>
	  <a title="Open the most up-to-date Priority Matrix" href="\\FS-NCR-V013\NCRP001\PWGSC\SSC\GOP\DCE\EUS\SD\Knowledge Base\SSCNSD\Enterprise\IUP Incident Priority Matrix_v2.0.pdf">Priority Matrix</a><br>
      <a title="Initiate a session on the Mainframe" href="https://ocsprod.pwgsc.gc.ca:3443/term-e.htm">Mainframe_MVS1</a><br>
      <a title="Just a reminder of who's Special... you're special too." href="#" onclick="GOPmsg">Who's GOP?</a><br>
	  <a title="Useful link to Partner Service Desk contact info" href="http://www.gcpedia.gc.ca/wiki/IT_help_desks-Bureaux_d%27aide_de_la_TI">IT Help Desks</a><br>
      <a title="List of Security Access Control Officers" href="http://service.ssc-spc.gc.ca/en/contact/partclisupport/saco-contact">SACO List</a><br>
      <a title="Opens GCDocs list of Local Registered Authorities" href="https://gcdocs.gc.ca/ssc-spc/llisapi.dll?func=ll&objaction=overview&objid=8809110">Main LRA List</a><br>
      <a title="Opens Network Drive list of LRA's for SSC" href="\\FS-NCR-V013\NCRP001\PWGSC\SSC\GOP\DCE\EUS\SD\Knowledge Base\SSCNSD\PKI\SSC and GOP GSS_LRAListJAN_1_2017.xlsx">SSC LRA List</a><br>
	  <a title="Opens the portal for Siebel/GCPens/DCT/IDM/Penfax" href="https://gcpens-idm.tpsgc-pwgsc.gc.ca/identity">Siebel/GCPens/DCT_Login</a><br>
	  <a title="Opens Citrix to connect to TC Assist" href="https://tcaccess.tc.gc.ca/">TC Assist (Citrix)</a><br>
	  <a title="Connect to the iBES" href="https://205.195.234.39:38443/webconsole/app">iBES</a><br>
    </div>
	<div id="rightcontent">
		<button class="button" name="Copy" title="Copies information typed next to specific fields from the top freeform section to their counterpart down below" onclick="CopyData">Copy Data</button>&nbsp;<input type="button" class="button" name="Clear" value="Clear" title="For when you're done with a ticket and ready for the next" onclick="ClearTicket">&nbsp;<input type="button" class="button" title="Toggle between EN/FR" name="btnLanguage" value="Francais" onclick="ToggleLanguage">
		<h4>Scripts</h4>
		<p id="pScript1" contenteditable="true">Thank you for calling the Service Desk my name is Justin, could I have your first and last name please?.</p>
		<p id="pScript2"contenteditable="true">Your ticket number is XXXXXXX. Is there anything else I can assist with? Thanks for calling, have a nice day.</p>
		<h4>Other</h4>
		<p id="pOther" contenteditable="true">Assigning to XXXXXXXX  as per interested party for CI: XXXXXXX  - XXXXXXXXXXXXXXXXX</p>
    </div>
    <div id="main">
	&emsp;<select name="myList" style="font-size: 18px;width: 50%;background-color: #6492db" title="Template List - pick the closest match for your incident or request" onchange=DropChoice>
	</select>   Ticket #   <input type="text" name="txtTicket" style="height:25px;width:30%;font-size:12px" maxlength="50" onkeyup="CheckTicket"> <input type="button" class="button" name="Export" value="Ex." title="Export to Excel" onclick="PopulateExcelFile">
	<textarea name="freeform" style="height:25%;width:100%;font-size:14px;background:#ffffff;PADDING-LEFT: 10px; PADDING-RIGHT: 10px" title="Input your ticket number and Summary then click 'Ex' to save your tickets to Excel" onchange="CheckData" onkeypress="FixSize" onclick="FixSize">Freeform Area</textarea>
	<textarea name="pad" style="height:67%;width:100%;font-size:14px;background:#ffffff;PADDING-LEFT: 10px; PADDING-RIGHT: 10px" title="Repopulate common fields after you've selected a template by clicking 'Copy Data'" onchange="FixSize" onkeypress="FixSize" onclick="FixSize">Welcome to GoatPad - a spot to find some ticket templates, an area to write notes and quick access to useful GCDocs links. To get started, select something from the drop-list above. The freeform section ABOVE will remain, however THIS SECTION WILL OVERRIDE when you select a template.

New: Export the tickets you've worked on to Excel.</textarea>
	</div>
  </div>
</BODY>
</HTML>
