<?php
if( $a == 'list' ){
	if( isset( $sOption ) ){
		$content.= $oTpl->parse( 'message_done.tpl' );
	}
	if( isset( $_POST['sOption'] ) ){
		$_POST['paybynet_accname'] = $_POST['paybynet_accname_nm'] . '^NM^' . $_POST['paybynet_accname_zp'] . '^ZP^' . $_POST['paybynet_accname_ci'] . '^CI^' . $_POST['paybynet_accname_st'] . '^ST^' . $_POST['paybynet_accname_ct'] . '^CT^';
		saveVariables( $_POST, DB_CONFIG );
		saveVariables( $_POST, DB_CONFIG_LANG );
		header( 'Location: ' . $_SERVER['PHP_SELF'] . '?p=' . $p . '&sOption=save' . '&activeTabId=' . $_POST['activeTabId'] );
		exit;
	}
	$aUrl = parse_url( 'http' . ( $_SERVER['HTTPS'] ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
	if( !empty( $aUrl['path'] ) ){
		$aUrl['path'] = dirname( $aUrl['path'] );
		if( $aUrl['path'] !== "/" ){
			$aUrl['path'] = $aUrl['path'] . '/';
		}
	}
	$oTpl->assign( 'aUrl', $aUrl );
	$aConfigInfo['sPlatnosciFailLink'] = $oPage->getLinkName( $config['platnosci_page_fail'] );
	$aConfigInfo['sPlatnosciOkLink'] = $oPage->getLinkName( $config['platnosci_page_ok'] );
	$aPayByNetInfo = preg_split( '/\\^[A-Z]{2}\\^/', $config['paybynet_accname'] );
	$aConfigInfo['paybynet_accname_nm'] = $aPayByNetInfo[0];
	$aConfigInfo['paybynet_accname_zp'] = $aPayByNetInfo[1];
	$aConfigInfo['paybynet_accname_ci'] = $aPayByNetInfo[2];
	$aConfigInfo['paybynet_accname_st'] = $aPayByNetInfo[3];
	$aConfigInfo['paybynet_accname_ct'] = $aPayByNetInfo[4];
	$aConfigInfo['aStatuses'] = $oOrder->throwStatus( );
	$oTpl->assign( 'aConfigInfo', $aConfigInfo );
	$aPayments = $oOrder->throwPaymentsAdmin( );
	$oTpl->assign( 'aPayments', $aPayments );
	$content.= $oTpl->parse( 'payments_list.tpl' );
} elseif( $a == 'delete' && isset( $iPayment ) && is_numeric( $iPayment ) ){
	$oOrder->deletePayment( $iPayment );
	header( 'Location: ' . $_SERVER['PHP_SELF'] . '?p=' . $aActions['f'] . '-list&sOption=del' );
	exit;
} elseif( $a == 'form' ){
	if( isset( $_POST['sOption'] ) ){
		if( !isset( $_POST['iStatus'] ) ) $_POST['iStatus'] = 0;
		$iPayment = $oOrder->savePayment( $_POST );
		header( 'Location: ' . $_SERVER['PHP_SELF'] . '?p=' . $p . '&sOption=save&iPayment=' . $iPayment );
		exit;
	}
	if( isset( $sOption ) ) $content.= $oTpl->parse( 'message_done.tpl' );
	if( isset( $iPayment ) && is_numeric( $iPayment ) ){
		$aPayment = $oOrder->throwPayment( $iPayment );
	} else{
		$aPayment['sDescription'] = null;
		$aPayment['iPrintForm'] = 0;
	}
	if( !isset( $aPayment['iOuterSystem'] ) ) $aPayment['iOuterSystem'] = null;
	$aYesNo = Array( '0' => $lang['no'], '1' => $lang['yes'] );
	$oTpl->assign( 'aYesNo', $aYesNo );
	$oTpl->assign( 'aOuterPaymentOption', $aOuterPaymentOption );
	$oTpl->assign( 'aInvoicesPayments', $aInvoicesPayments );
	$oTpl->assign( 'aPayment', $aPayment );
	$content.= $oTpl->parse( 'payments_form.tpl' );
}
?>