<?php
require_once(__DIR__.'/../includes/sysinit.php');
require(SABLE_WORKING_PATH.'attendance/attendance_func.php');
//**********************************************************************************
$_SESSION['listParams']['searchVisible'] = 1;
if (isset($_POST))
{
	$_SESSION['listParams']['searchField'][0]['title'] = 'user_full_name';
	$_SESSION['listParams']['searchField'][0][0] = 'user_name';
	$_SESSION['listParams']['searchField'][0][1] = 'user_surname';
	$_SESSION['listParams']['searchField'][1] = 'attendance_in';
	$_SESSION['listParams']['searchField'][2] = 'attendance_out';
	$_SESSION['listParams']['searchField'][3]['title'] = 'checkin_coords';
	$_SESSION['listParams']['searchField'][3][0] = 'attendance_in_lat';
	$_SESSION['listParams']['searchField'][3][1] = 'attendance_in_lng';
	$_SESSION['listParams']['searchField'][4]['title'] = 'checkout_coords';
	$_SESSION['listParams']['searchField'][4][0] = 'attendance_out_lat';
	$_SESSION['listParams']['searchField'][4][1] = 'attendance_out_lng';
	$_SESSION['listParams']['searchField'][5] = 'attendance_in_ip';
	$_SESSION['listParams']['searchField'][6] = 'attendance_out_ip';
}

$_SESSION['listParams']['listSql'] = 	"select attendance_id, concat(user_name, ' ', user_surname) as user_full_name, 
										attendance_in, attendance_out, 
										concat(attendance_in_lat, ',', attendance_in_lng) as checkin_coords, 
										concat(attendance_out_lat, ',', attendance_out_lng) as checkout_coords, 
										attendance_in_ip, attendance_out_ip
									  	from attendance
									  	inner join user on user.user_code = attendance.user_code";

$_SESSION['listParams']['module']					= "attendance";
$_SESSION['listParams']['page']						= 0;
$_SESSION['listParams']['offset']					= 30; //the number of records to display per page
$_SESSION['listParams']['parentId']					= ""; //
$_SESSION['listParams']['moduleFolder']				= "attendance";
$_SESSION['listParams']['moduleFolderDesc']			= "Attendance";
$_SESSION['listParams']['modulePage']				= "index.php";
$_SESSION['listParams']['moduleIdField']			= "attendance_id";
$_SESSION['listParams']['moduleDescField']			= "attendance_id";
$_SESSION['listParams']['orderField']				= 1;
$_SESSION['listParams']['orderDirection']			= 1;

$_SESSION['listParams']['listHeadings'][0] = "Employee";
$_SESSION['listParams']['listHeadings'][1] = "Checked In";
$_SESSION['listParams']['listHeadings'][2] = "Checked Out";
$_SESSION['listParams']['listHeadings'][3] = "Check In Coords";
$_SESSION['listParams']['listHeadings'][4] = "Check Out Coords";
$_SESSION['listParams']['listHeadings'][5] = "Check In IP";
$_SESSION['listParams']['listHeadings'][6] = "Check Out IP";
$_SESSION['listParams']['listHeadings'][7] = ""; //view

$_SESSION['listParams']['listHeadingWidth'][0] = "10%";
$_SESSION['listParams']['listHeadingWidth'][1] = "15%";
$_SESSION['listParams']['listHeadingWidth'][2] = "15%";
$_SESSION['listParams']['listHeadingWidth'][3] = "20%";
$_SESSION['listParams']['listHeadingWidth'][4] = "20%";
$_SESSION['listParams']['listHeadingWidth'][5] = "10%";
$_SESSION['listParams']['listHeadingWidth'][6] = "10%";
$_SESSION['listParams']['listHeadingWidth'][7] = "99%";

$_SESSION['listParams']['listFields'][0]['field']			= "user_full_name";
$_SESSION['listParams']['listFields'][1]['field']			= "attendance_in";
$_SESSION['listParams']['listFields'][1]['date']			= "1";
$_SESSION['listParams']['listFields'][1]['format']			= "d F Y [H:i]";
$_SESSION['listParams']['listFields'][2]['field']			= "attendance_out";
$_SESSION['listParams']['listFields'][2]['date']			= "1";
$_SESSION['listParams']['listFields'][2]['format']			= "d F Y [H:i]";
$_SESSION['listParams']['listFields'][3]['field']			= "checkin_coords";
$_SESSION['listParams']['listFields'][4]['field']			= "checkout_coords";
$_SESSION['listParams']['listFields'][5]['field']			= "attendance_in_ip";
$_SESSION['listParams']['listFields'][6]['field']			= "attendance_out_ip";

$_SESSION['listParams']['listFields'][7]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_VIEW."' title='View --!--'></i>";
$_SESSION['listParams']['listFields'][7]['onClick'] = " onClick='viewAttendance(\"--#--\")' ";

SableGeneralFunctions::callDataList();
