<?php
require_once(__DIR__.'/../includes/sysinit.php');
require(SABLE_WORKING_PATH.'team/team_func.php');
//**********************************************************************************
$_SESSION['listParams']['searchVisible'] = 1;
if (isset($_POST))
{
	$_SESSION['listParams']['searchField'][0] = 'team_name';
	$_SESSION['listParams']['searchField'][1] = 'vehicle_name';
	$_SESSION['listParams']['searchField'][2] = 'team_active';
}

$_SESSION['listParams']['listSql'] = "select team_id, team_name, vehicle.vehicle_name, team_active
									  from team
									  left join vehicle on vehicle.vehicle_id = team.vehicle_id";
$_SESSION['module']['addlink'] = SableSystem::getCallPageLink('/team/add.php');
$_SESSION['listParams']['module']					= "team";
$_SESSION['listParams']['page']						= 0;
$_SESSION['listParams']['offset']					= 50; //the number of records to display per page
$_SESSION['listParams']['parentId']					= ""; //
$_SESSION['listParams']['moduleFolder']				= "team";
$_SESSION['listParams']['moduleFolderDesc']			= "Team";
$_SESSION['listParams']['modulePage']				= "index.php";
$_SESSION['listParams']['moduleIdField']			= "team_id";
$_SESSION['listParams']['moduleDescField']			= "team_name";
$_SESSION['listParams']['orderField']				= 1;
$_SESSION['listParams']['orderDirection']			= 0;

$_SESSION['listParams']['listHeadings'][0] = "Team Name";
$_SESSION['listParams']['listHeadings'][1] = "Vehicle";
$_SESSION['listParams']['listHeadings'][2] = "Active?";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER){	$_SESSION['listParams']['listHeadings'][3] = "";} //Add
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK){	$_SESSION['listParams']['listHeadings'][4] = "";} //Edit
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN){	$_SESSION['listParams']['listHeadings'][5] = "";} //Delete

$_SESSION['listParams']['listHeadingWidth'][0] = "17%";
$_SESSION['listParams']['listHeadingWidth'][1] = "17%";
$_SESSION['listParams']['listHeadingWidth'][2] = "17%";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER){	$_SESSION['listParams']['listHeadingWidth'][3] = "5%";} //View
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK){	$_SESSION['listParams']['listHeadingWidth'][4] = "5%";} //Edit
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN){	$_SESSION['listParams']['listHeadingWidth'][5] = "5%";} //Delete

$_SESSION['listParams']['listFields'][0]['field']			= "team_name";
$_SESSION['listParams']['listFields'][1]['field']			= "vehicle_name";
$_SESSION['listParams']['listFields'][2]['field']			= "team_active";
$_SESSION['listParams']['listFields'][2]['yesNo']			= 1;
$_SESSION['listParams']['listFields'][2]['yesNoYes']			= "Yes";
$_SESSION['listParams']['listFields'][2]['yesNoNo']			= "No";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER) 
{
	$_SESSION['listParams']['listFields'][3]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_VIEW."' title='View --!--'></i>";
	$_SESSION['listParams']['listFields'][3]['onClick'] = " onClick='viewTeam(\"--#--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK) 
{
	$_SESSION['listParams']['listFields'][4]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_EDIT."' title='Modify --!--'></i>";
	$_SESSION['listParams']['listFields'][4]['onClick'] = " onClick='editTeam(\"--#--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN) 
{
	$_SESSION['listParams']['listFields'][5]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_DELETE."' title='Delete --!--'></i>";
	$_SESSION['listParams']['listFields'][5]['onClick'] = " onClick='deleteTeam(\"--#--\",\"--!--\")' ";
}
SableGeneralFunctions::callDataList();
