<?php
require('company_func.php');
//**********************************************************************************
 
$_SESSION['listParams']['searchVisible'] = 1;
if (isset($_POST))
{
    $_SESSION['listParams']['searchField'][0] = 'company_logo';
    $_SESSION['listParams']['searchField'][1] = 'company_name';
    $_SESSION['listParams']['searchField'][2] = 'company_email';
    $_SESSION['listParams']['searchField'][3] = 'company_phone';
    $_SESSION['listParams']['searchField'][4] = 'company_type_name';
    $_SESSION['listParams']['searchField'][5] = 'company_reg_no';
}
 
$_SESSION['listParams']['listSql'] 	= "select company_id, company_name, company_email, company_logo, company_phone, 
									company_type_name, company_reg_no 
									from company 
									inner join company_type on company_type.company_type_id = company.company_type_id";
$_SESSION['module']['addlink'] = SableSystem::getCallPageLink('/company/add.php');
$_SESSION['listParams']['module']			= "Company";
$_SESSION['listParams']['page']				= 0;
$_SESSION['listParams']['offset']			= 30; //the number of records to display per page
$_SESSION['listParams']['parentId']			= ""; //
$_SESSION['listParams']['moduleFolder']		= "company";
$_SESSION['listParams']['modulePage']      	= "index.php";
$_SESSION['listParams']['moduleIdField']   	= "company_id";
$_SESSION['listParams']['moduleDescField']	= "company_name";
$_SESSION['listParams']['orderField']		= 1;
$_SESSION['listParams']['orderDirection']	= 0;
$_SESSION['listParams']['allowExport']		= 1;
$_SESSION['listParams']['exportAccess']		= ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER);
 
$_SESSION['listParams']['listHeadings'][0] = "Logo";
$_SESSION['listParams']['listHeadings'][1] = "Company";
$_SESSION['listParams']['listHeadings'][2] = "Email";
$_SESSION['listParams']['listHeadings'][3] = "Phone";
$_SESSION['listParams']['listHeadings'][4] = "Type";
$_SESSION['listParams']['listHeadings'][5] = "Reg. No.";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK) 
{
	$_SESSION['listParams']['listHeadings'][6] = ""; //view
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER) 
{
	$_SESSION['listParams']['listHeadings'][7] = ""; //edit
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN) 
{
    $_SESSION['listParams']['listHeadings'][8] = ""; //delete
}
$_SESSION['listParams']['listHeadingWidth'][0] = "10%";
$_SESSION['listParams']['listHeadingWidth'][1] = "25%";
$_SESSION['listParams']['listHeadingWidth'][2] = "15%";
$_SESSION['listParams']['listHeadingWidth'][3] = "10%";
$_SESSION['listParams']['listHeadingWidth'][4] = "14%";
$_SESSION['listParams']['listHeadingWidth'][5] = "10%";

if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK )
{
	$_SESSION['listParams']['listHeadingWidth'][6] = "2%"; //view
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER) 
{
	$_SESSION['listParams']['listHeadingWidth'][7] = "2%"; //edit
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN) 
{
	$_SESSION['listParams']['listHeadingWidth'][8] = "95%"; //delete
}

$_SESSION['listParams']['listFields'][0]['image'] 		= "1";
$_SESSION['listParams']['listFields'][0]['image_size']  = 125;
$_SESSION['listParams']['listFields'][0]['field'] 		= "company_logo";
$_SESSION['listParams']['listFields'][1]['field'] 		= "company_name";

$_SESSION['listParams']['listFields'][2]['field'] 		= "company_email";
$_SESSION['listParams']['listFields'][2]['emailLink'] 	= "1";

$_SESSION['listParams']['listFields'][3]['field']  		= "company_phone";
$_SESSION['listParams']['listFields'][3]['phoneLink']   = "1";
$_SESSION['listParams']['listFields'][4]['field']  		= "company_type_name";
$_SESSION['listParams']['listFields'][5]['field']  		= "company_reg_no";

if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK) 
{
	$_SESSION['listParams']['listFields'][6]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_VIEW."' title='View --!--'></i>";
	$_SESSION['listParams']['listFields'][6]['onClick'] = " onClick='viewCompany(\"--#--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER) 
{
	$_SESSION['listParams']['listFields'][7]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_EDIT."' title='Modify --!--'></i>";
	$_SESSION['listParams']['listFields'][7]['onClick'] = " onClick='editCompany(\"--#--\")' ";  
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN) 
{    
	$_SESSION['listParams']['listFields'][8]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_DELETE."' title='Delete --!--'></i>";
	$_SESSION['listParams']['listFields'][8]['onClick'] = " onClick='deleteCompany(\"--#--\",\"--!--\")' ";
}
SableGeneralFunctions::callDataList(); //functions_general.php
?>
