<?php
require_once(__DIR__.'/../includes/sysinit.php');
require(SABLE_WORKING_PATH.'client/client_func.php');

$_SESSION['listParams']['searchVisible']= 1;
/***
$_SESSION['module']['add']= 1;
$_SESSION['module']['addlink']= SableSystem::getSableLinkPath('client/');
***/
$_SESSION['module']['back']				= 1;
$_SESSION['module']['backlink']			= SableSystem::getThemeLinkPath('dashboard/client/');
$_SESSION['listParams']['allowExport']	= 1;
$_SESSION['listParams']['exportAccess']	= SABLE_ACCESS_MANAGER;

if (isset($_POST))
{
	$_SESSION['listParams']['searchField'][0] = 'client_name';
	$_SESSION['listParams']['searchField'][1] = 'client_surname';
	$_SESSION['listParams']['searchField'][2] = 'id_type_id';
	$_SESSION['listParams']['searchField'][3] = 'client_id_no';
	$_SESSION['listParams']['searchField'][4] = 'client_type_id';
	$_SESSION['listParams']['searchField'][5] = 'address_id';
	$_SESSION['listParams']['searchField'][6] = 'client_address_note';
	$_SESSION['listParams']['searchField'][7] = 'client_distance';
	$_SESSION['listParams']['searchField'][8] = 'client_addr_bill';
	$_SESSION['listParams']['searchField'][9] = 'client_phone';
	$_SESSION['listParams']['searchField'][10] = 'client_phone_alt';
	$_SESSION['listParams']['searchField'][11] = 'client_email';
	$_SESSION['listParams']['searchField'][12] = 'client_note';
	$_SESSION['listParams']['searchField'][13] = 'gender_id';
	$_SESSION['listParams']['searchField'][14] = 'client_business_name';
	$_SESSION['listParams']['searchField'][15] = 'client_vat_no';
	$_SESSION['listParams']['searchField'][16] = 'client_reg_no';
	$_SESSION['listParams']['searchField'][17] = 'client_contract';
	$_SESSION['listParams']['searchField'][18] = 'client_parent_id';
	$_SESSION['listParams']['searchField'][19] = 'reward_level_id';
	$_SESSION['listParams']['searchField'][20] = 'client_deleted';
}

$_SESSION['listParams']['listSql']="select client_id, client_name, client_surname, id_type_id, 
									client_id_no, client_type_id, address_id, client_address_note, client_distance, client_addr_bill, 
									client_phone, client_phone_alt, client_email, client_note, gender_id, client_business_name, 
									client_vat_no, client_reg_no, client_contract, client_parent_id, reward_level_id, client_deleted
									from client";

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

$_SESSION['listParams']['listHeadings'][0] = "Client Id";
$_SESSION['listParams']['listHeadings'][1] = "Client Name";
$_SESSION['listParams']['listHeadings'][2] = "Client Surname";
$_SESSION['listParams']['listHeadings'][3] = "Id Type Id";
$_SESSION['listParams']['listHeadings'][4] = "Client Id No";
$_SESSION['listParams']['listHeadings'][5] = "Client Type Id";
$_SESSION['listParams']['listHeadings'][6] = "Address Id";
$_SESSION['listParams']['listHeadings'][7] = "Client Address Note";
$_SESSION['listParams']['listHeadings'][8] = "Client Distance";
$_SESSION['listParams']['listHeadings'][9] = "Same as billing address";
$_SESSION['listParams']['listHeadings'][10] = "Client Phone";
$_SESSION['listParams']['listHeadings'][11] = "Client Phone Alt";
$_SESSION['listParams']['listHeadings'][12] = "Client Email";
$_SESSION['listParams']['listHeadings'][13] = "Client Note";
$_SESSION['listParams']['listHeadings'][14] = "Client Type Nature Id";
$_SESSION['listParams']['listHeadings'][15] = "Client Business Name";
$_SESSION['listParams']['listHeadings'][16] = "Client Vat No";
$_SESSION['listParams']['listHeadings'][17] = "Client Reg No";
$_SESSION['listParams']['listHeadings'][18] = "Client Contract";
$_SESSION['listParams']['listHeadings'][19] = "Client Parent Id";
$_SESSION['listParams']['listHeadings'][20] = "Reward Level Id";
$_SESSION['listParams']['listHeadings'][21] = "Client Deleted";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER){	$_SESSION['listParams']['listHeadings'][22] = "";} //Add
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK){	$_SESSION['listParams']['listHeadings'][23] = "";} //Edit
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER){	$_SESSION['listParams']['listHeadings'][24] = "";} //Delete

$_SESSION['listParams']['listHeadingWidth'][0] = "3%";
$_SESSION['listParams']['listHeadingWidth'][1] = "3%";
$_SESSION['listParams']['listHeadingWidth'][2] = "3%";
$_SESSION['listParams']['listHeadingWidth'][3] = "3%";
$_SESSION['listParams']['listHeadingWidth'][4] = "3%";
$_SESSION['listParams']['listHeadingWidth'][5] = "3%";
$_SESSION['listParams']['listHeadingWidth'][6] = "3%";
$_SESSION['listParams']['listHeadingWidth'][7] = "3%";
$_SESSION['listParams']['listHeadingWidth'][8] = "3%";
$_SESSION['listParams']['listHeadingWidth'][9] = "3%";
$_SESSION['listParams']['listHeadingWidth'][10] = "3%";
$_SESSION['listParams']['listHeadingWidth'][11] = "3%";
$_SESSION['listParams']['listHeadingWidth'][12] = "3%";
$_SESSION['listParams']['listHeadingWidth'][13] = "3%";
$_SESSION['listParams']['listHeadingWidth'][14] = "3%";
$_SESSION['listParams']['listHeadingWidth'][15] = "3%";
$_SESSION['listParams']['listHeadingWidth'][16] = "3%";
$_SESSION['listParams']['listHeadingWidth'][17] = "3%";
$_SESSION['listParams']['listHeadingWidth'][18] = "3%";
$_SESSION['listParams']['listHeadingWidth'][19] = "3%";
$_SESSION['listParams']['listHeadingWidth'][20] = "3%";
$_SESSION['listParams']['listHeadingWidth'][21] = "3%";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER){	$_SESSION['listParams']['listHeadingWidth'][22] = "5%";} //View
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK){	$_SESSION['listParams']['listHeadingWidth'][23] = "5%";} //Edit
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER){	$_SESSION['listParams']['listHeadingWidth'][24] = "5%";} //Delete

$_SESSION['listParams']['listFields'][0]['field']			= "client_id";
$_SESSION['listParams']['listFields'][1]['field']			= "client_name";
$_SESSION['listParams']['listFields'][2]['field']			= "client_surname";
$_SESSION['listParams']['listFields'][3]['field']			= "id_type_id";
$_SESSION['listParams']['listFields'][4]['field']			= "client_id_no";
$_SESSION['listParams']['listFields'][5]['field']			= "client_type_id";
$_SESSION['listParams']['listFields'][6]['field']			= "address_id";
$_SESSION['listParams']['listFields'][7]['field']			= "client_address_note";
$_SESSION['listParams']['listFields'][8]['field']			= "client_distance";
$_SESSION['listParams']['listFields'][9]['field']			= "client_addr_bill";
$_SESSION['listParams']['listFields'][10]['field']			= "client_phone";
$_SESSION['listParams']['listFields'][11]['field']			= "client_phone_alt";
$_SESSION['listParams']['listFields'][12]['field']			= "client_email";
$_SESSION['listParams']['listFields'][12]['emailLink']		= "1";
$_SESSION['listParams']['listFields'][13]['field']			= "client_note";
$_SESSION['listParams']['listFields'][14]['field']			= "gender_id";
$_SESSION['listParams']['listFields'][15]['field']			= "client_business_name";
$_SESSION['listParams']['listFields'][16]['field']			= "client_vat_no";
$_SESSION['listParams']['listFields'][17]['field']			= "client_reg_no";
$_SESSION['listParams']['listFields'][18]['field']			= "client_contract";
$_SESSION['listParams']['listFields'][18]['yesNo']			= 1;
$_SESSION['listParams']['listFields'][18]['yesNoYes']			= "Yes";
$_SESSION['listParams']['listFields'][18]['yesNoNo']			= "No";
$_SESSION['listParams']['listFields'][19]['field']			= "client_parent_id";
$_SESSION['listParams']['listFields'][20]['field']			= "reward_level_id";
$_SESSION['listParams']['listFields'][21]['field']			= "client_deleted";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER) 
{
	$_SESSION['listParams']['listFields'][22]['field']	= "<i class='fa fa-2x ".SABLE_DATALIST_VIEW."' title='View --!--'></i>";
	$_SESSION['listParams']['listFields'][22]['onClick']= " onClick='viewClient(\"--#--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK) 
{
	$_SESSION['listParams']['listFields'][23]['field']	="<i class='fa fa-2x ".SABLE_DATALIST_EDIT."' title='Modify --!--'></i>";
	$_SESSION['listParams']['listFields'][23]['onClick']= " onClick='editClient(\"--#--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER) 
{
	$_SESSION['listParams']['listFields'][24]['field']	= "<i class='fa fa-2x ".SABLE_DATALIST_DELETE."' title='Delete --!--'></i>";
	$_SESSION['listParams']['listFields'][24]['onClick']= " onClick='deleteClient(\"--#--\",\"--!--\")' ";
}
SableGeneralFunctions::callDataList();
