<?php
require_once(__DIR__.'/../includes/sysinit.php');
require(SABLE_WORKING_PATH.'netcash_payment/netcash_payment_func.php');
//**********************************************************************************
$_SESSION['listParams']['searchVisible'] = 1;
$_SESSION['listParams']['allowExport'] = 1;
$_SESSION['module']['add'] = 0;

if (isset($_POST))
{
	$_SESSION['listParams']['searchField'][0] = 'user_full_name';
	$_SESSION['listParams']['searchField'][1] = 'np_date';
	$_SESSION['listParams']['searchField'][2] = 'np_reference';
	$_SESSION['listParams']['searchField'][3] = 'np_description';
	$_SESSION['listParams']['searchField'][4] = 'np_amount';
	$_SESSION['listParams']['searchField'][5] = 'pay_type_name';
	$_SESSION['listParams']['searchField'][6] = 'gym_name';
	$_SESSION['listParams']['searchField'][7] = 'itensity_reference';
	if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN)
	{
		$_SESSION['listParams']['searchField'][8] = 'np_trace_id';
	}
}

$_SESSION['listParams']['listSql'] = "select np_id, concat(user_name, ' ', user_surname) as user_full_name, np_date, np_reference, 
np_description, np_amount, netcash_pay_type.pay_type_name, gyms.gym_name, member_registration.itensity_reference, np_success, np_trace_id  
from netcash_payment 
inner join user on user.user_code = netcash_payment.np_user 
inner join member_registration on member_registration.user_id = user.user_id 
inner join gyms on gyms.gym_id = member_registration.gym_id 
left join netcash_pay_type on netcash_pay_type.pay_type_id = netcash_payment.np_payment_type ";

if ($_SESSION['user']['access_level'] < SABLE_ACCESS_ADMIN)
{
	$_SESSION['listParams']['listSql'] .= "where (np_success = 1) ";
}

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

$_SESSION['listParams']['listHeadings'][0] = "Member";
$_SESSION['listParams']['listHeadings'][1] = "Date";
$_SESSION['listParams']['listHeadings'][2] = "Reference";
$_SESSION['listParams']['listHeadings'][3] = "Description";
$_SESSION['listParams']['listHeadings'][4] = "Amount";
$_SESSION['listParams']['listHeadings'][5] = "Method";
$_SESSION['listParams']['listHeadings'][6] = "Gym";
$_SESSION['listParams']['listHeadings'][7] = "Itensity Ref.";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN)
{
	$_SESSION['listParams']['listHeadings'][8] = 'Trace ID';
}

$_SESSION['listParams']['listHeadingWidth'][0] = "15%";
$_SESSION['listParams']['listHeadingWidth'][1] = "5%";
$_SESSION['listParams']['listHeadingWidth'][2] = "10%";
$_SESSION['listParams']['listHeadingWidth'][3] = "15%";
$_SESSION['listParams']['listHeadingWidth'][4] = "7%";
$_SESSION['listParams']['listHeadingWidth'][5] = "8%";
$_SESSION['listParams']['listHeadingWidth'][6] = "22%";
$_SESSION['listParams']['listHeadingWidth'][7] = "5%";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN)
{
	$_SESSION['listParams']['listHeadingWidth'][8] = "8%";
}

$_SESSION['listParams']['listFields'][0]['field']			= "user_full_name";
$_SESSION['listParams']['listFields'][1]['field']			= "np_date";
$_SESSION['listParams']['listFields'][1]['date']			= "1";
$_SESSION['listParams']['listFields'][2]['field']			= "np_reference";
$_SESSION['listParams']['listFields'][3]['field']			= "np_description";
$_SESSION['listParams']['listFields'][4]['field']			= "np_amount";
$_SESSION['listParams']['listFields'][4]['currency']		= "1";
$_SESSION['listParams']['listFields'][4]['precision']		= "2";
$_SESSION['listParams']['listFields'][5]['field']			= "pay_type_name";
$_SESSION['listParams']['listFields'][6]['field']			= "gym_name";
$_SESSION['listParams']['listFields'][7]['field']			= "itensity_reference";
if ($_SESSION['user']['access_level'] >= SABLE_ACCESS_ADMIN)
{
	$_SESSION['listParams']['listFields'][8]['link']	= "https://ws.netcash.co.za/PayNow/TransactionStatus/Check?RequestTrace=--!--";
	$_SESSION['listParams']['listFields'][8]['field']	= "np_trace_id";
}

SableGeneralFunctions::callDataList();
