<!---Training_log_print.cfm--->

<cfquery  name="GetLog" datasource="#Application.DataSrc#" result="getempr">
SELECT *
	FROM #Request.prefix_db_lookup#.Training_Log
	LEFT OUTER JOIN #Request.prefix_db_lookup#.Employee on  (Training_Log.Employee =  Employee.Employee_ID  or    
    Training_Log.Created_By =  Employee.Employee_ID  or 
    (Employee.Last_Name =  substring_index(Training_Log.Employee,' ',1) 
    or Employee.First_Name = substring_index(substring_index(Training_Log.Employee,' ',2 ), ' ', -1)))
	WHERE Training_Log.Agency_ID =  '#session.AgencyId#'
	AND Training_Log.Agency_ID = Employee.Agency_ID
    AND Created_Date > '2017-01-01'
    GROUP BY Training_Log.Train_ID
    
</cfquery>

<!---<table border="0" style="border: 1px solid #CCCCCC" cellpadding="0" cellspacing="0"
            width="100%" height="100%">
			<thead>
				<tr>
					<th width="20%" align="left">Employee</th>
					<th width="40%" align="left">Training Step</th>
					<th width="20%" align="left">Training Date</th>
					<th width="20%" align="left">Notes</th>
				</tr>
			</thead>
--->
<cfdocument format="pdf" orientation = "portrait" overwrite = "yes">
<table class="table table-bordered table-striped table-condensed flip-content" style="border: 2px solid #CCCCCC" cellpadding="4" cellspacing="4">
			<thead>
				<tr>
					<th>Employee</th>
					<th>Training Step</th>
					<th>Training Date</th>
					<th>Notes</th>
				</tr>
			</thead>
			<tbody>
			<cfif GetLog.RecordCount gt 0 >
			<cfoutput query="GetLog">
					<tr>
					    <cfscript>
								Encrypted_Emp_ID=encrypt(#Employee_ID#,"54kczhzgHTj4a8n+SRZPyg==","AES","Hex");
						</cfscript>
						<td>#Last_Name#,#First_Name#</td>
						<td><cfif Train_Step neq 0 >#Train_Step#</cfif></td>
						<td>#DateFormat(Train_Date,'yyyy-mm-dd')#</td>
						 <td>#Notes#</td>
					</tr> 
			</cfoutput>
			<cfelse>
			      <tr><td colspan="4"  align="center">There is no Training Log history for this Agency</td></tr>
			</cfif>
			</tbody>
		</table>
</cfdocument>