<?php
require_once(__DIR__.'/../includes/sysinit.php');
require(SABLE_WORKING_PATH.'finance/finance_func.php');
//**********************************************************************************
$_SESSION['listParams']['searchVisible'] = 1;
if (isset($_POST))
{
	$_SESSION['listParams']['searchField'][0] = 'txn_date';
	$_SESSION['listParams']['searchField'][1] = 'client_id';
	$_SESSION['listParams']['searchField'][2] = 'txn_type_name';
	$_SESSION['listParams']['searchField'][3] = 'pm_name';
	$_SESSION['listParams']['searchField'][4] = 'txn_amount';
	$_SESSION['listParams']['searchField'][5] = 'txn_paid';
}

$_SESSION['listParams']['listSql'] = "select finance_id, txn_date, client_id, txn_type.txn_type_name, 
									  payment_method.pm_name, txn_amount, txn_paid
									  from finance
									  inner join txn_type on txn_type.txn_type_id = finance.txn_type_id
									  inner join payment_method on payment_method.pm_id = finance.pm_id";

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

$_SESSION['listParams']['listHeadings'][0] = "Txn Date";
$_SESSION['listParams']['listHeadings'][1] = "Client Id";
$_SESSION['listParams']['listHeadings'][2] = "Txn Type Id";
$_SESSION['listParams']['listHeadings'][3] = "Pm Id";
$_SESSION['listParams']['listHeadings'][4] = "Txn Amount";
$_SESSION['listParams']['listHeadings'][5] = "Txn Paid";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER){	$_SESSION['listParams']['listHeadings'][6] = "";} //Add
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK){	$_SESSION['listParams']['listHeadings'][7] = "";} //Edit
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER){	$_SESSION['listParams']['listHeadings'][8] = "";} //Copy
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER){	$_SESSION['listParams']['listHeadings'][9] = "";} //Delete

$_SESSION['listParams']['listHeadingWidth'][0] = "9%";
$_SESSION['listParams']['listHeadingWidth'][1] = "9%";
$_SESSION['listParams']['listHeadingWidth'][2] = "9%";
$_SESSION['listParams']['listHeadingWidth'][3] = "9%";
$_SESSION['listParams']['listHeadingWidth'][4] = "9%";
$_SESSION['listParams']['listHeadingWidth'][5] = "9%";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER){	$_SESSION['listParams']['listHeadingWidth'][6] = "5%";} //View
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK){	$_SESSION['listParams']['listHeadingWidth'][7] = "5%";} //Edit
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER){	$_SESSION['listParams']['listHeadingWidth'][8] = "5%";} //Copy
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER){	$_SESSION['listParams']['listHeadingWidth'][9] = "5%";} //Delete

$_SESSION['listParams']['listFields'][0]['field']			= "txn_date";
$_SESSION['listParams']['listFields'][0]['date']			= "1";
$_SESSION['listParams']['listFields'][1]['field']			= "concat(client_name, ' ', client_surname)";
$_SESSION['listParams']['listFields'][2]['field']			= "txn_type_name";
$_SESSION['listParams']['listFields'][3]['field']			= "pm_name";
$_SESSION['listParams']['listFields'][4]['field']			= "txn_amount";
$_SESSION['listParams']['listFields'][4]['currency']		= "1";
$_SESSION['listParams']['listFields'][5]['field']			= "txn_paid";
$_SESSION['listParams']['listFields'][5]['yesNo']			= 1;
$_SESSION['listParams']['listFields'][5]['yesNoYes']			= "Yes";
$_SESSION['listParams']['listFields'][5]['yesNoNo']			= "No";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_USER) 
{
	$_SESSION['listParams']['listFields'][6]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_VIEW."' title='View --!--'></i>";
	$_SESSION['listParams']['listFields'][6]['onClick'] = " onClick='viewFinance(\"--#--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_CLERK) 
{
	$_SESSION['listParams']['listFields'][7]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_EDIT."' title='Modify --!--'></i>";
	$_SESSION['listParams']['listFields'][7]['onClick'] = " onClick='editFinance(\"--#--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER) 
{
	$_SESSION['listParams']['listFields'][8]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_COPY."' title='Copy --!--'></i>";
	$_SESSION['listParams']['listFields'][8]['onClick'] = " onClick='copyFinance(\"--#--\",\"--!--\")' ";
}
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_MANAGER) 
{
	$_SESSION['listParams']['listFields'][9]['field'] = "<i class='fa fa-2x ".SABLE_DATALIST_DELETE."' title='Delete --!--'></i>";
	$_SESSION['listParams']['listFields'][9]['onClick'] = " onClick='deleteFinance(\"--#--\",\"--!--\")' ";
}
SableGeneralFunctions::callDataList();
