/***************************************************************************
* Dolphin Smart Community Builder
* -----------------
* begin : Mon Mar 23 2006
* copyright : (C) 2006 BoonEx Group
* website : http://www.boonex.com/
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
* http://creativecommons.org/licenses/by/3.0/
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Creative Commons Attribution 3.0 License for more details.
* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/
require_once( '../inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'checkout.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
$sHead = '';
if (getParam("enable_aff") != 'on')
{
$sHead = "("._t("_affiliate_system_was_disabled").")";
}
if ( !($logged['aff'] = member_auth( 2, false)) )
$logged['admin'] = member_auth( 1 );
$AFF = $_COOKIE['affID'] > 0 ? $_COOKIE['affID'] : ( $_GET['affID'] > 0 ? $_GET['affID'] : $_POST['affID'] );
if ( !strstr($AFF, "@") )
{
$affID = (int)$AFF;
$aff_arr = db_arr("SELECT `Percent` FROM `aff` WHERE `ID` = $affID");
}
else
{
$AFF = process_db_input($AFF);
$aff_arr = db_arr("SELECT `ID`, `Percent` FROM `aff` WHERE `email` = '$AFF'");
$affID = (int)$aff_arr['ID'];
}
$percent = (float)$aff_arr['Percent'] / 100.0;
$tr = array();
$tr_query = "";
$order_num_disabled = 'disabled="disabled"';
$last_disabled = 'disabled="disabled"';
$date_disabled = 'disabled="disabled"';
$between_disabled = 'disabled="disabled"';
switch ( $_POST['calculation_type'] )
{
case 'total':
$tr_query = "SELECT `ID`, `IDMember`, `IDProvider`, `gtwTransactionID`, DATE_FORMAT(`Date`, '$date_format' ) AS 'Date', `Amount`, `Currency`, `Status`, `Data`, `Description`, `Note` FROM `Transactions` INNER JOIN `aff_members` ON (`idProfile` = `IDMember`) WHERE `idAff` = $affID AND `Status` = 'approved' ORDER BY `Date` DESC";
break;
case 'order_num':
$order_id = process_db_input( $_POST['tr_order_num'] );
$tr['order_num'] = process_pass_data( $_POST['tr_order_num'] );
$tr_query = "SELECT `ID`, `IDMember`, `IDProvider`, `gtwTransactionID`, DATE_FORMAT(`Date`, '$date_format' ) AS 'Date', `Amount`, `Currency`, `Status`, `Data`, `Description`, `Note` FROM `Transactions` INNER JOIN `aff_members` ON (`idProfile` = `IDMember`) WHERE `idAff` = $affID AND `gtwTransactionID` = '$order_id' AND `Status` = 'approved' ORDER BY `Date` DESC";
$order_num_disabled = "";
break;
case 'last':
$last_days = (int)$_POST['tr_last_days'];
$tr['last_days'] = process_pass_data( $_POST['tr_last_days'] );
$tr_query = "SELECT `ID`, `IDMember`, `IDProvider`, `gtwTransactionID`, DATE_FORMAT(`Date`, '$date_format' ) AS 'Date', `Amount`, `Currency`, `Status`, `Data`, `Description`, `Note` FROM `Transactions` INNER JOIN `aff_members` ON (`idProfile` = `IDMember`) WHERE `idAff` = $affID AND ( TO_DAYS( NOW() ) - TO_DAYS( `Date` ) <= $last_days ) AND `Status` = 'approved' ORDER BY `Date` DESC";
$last_disabled = "";
break;
case 'date':
$exact_date = strtotime( $_POST['tr_exact_date'] );
$tr['exact_date'] = process_pass_data( $_POST['tr_exact_date'] );
if ( $exact_date != -1 )
{
$tr_query = "SELECT `ID`, `IDMember`, `IDProvider`, `gtwTransactionID`, DATE_FORMAT(`Date`, '$date_format' ) AS 'Date', `Amount`, `Currency`, `Status`, `Data`, `Description`, `Note` FROM `Transactions` INNER JOIN `aff_members` ON (`idProfile` = `IDMember`) WHERE `idAff` = $affID AND TO_DAYS( FROM_UNIXTIME($exact_date) ) = TO_DAYS( `Date` ) AND `Status` = 'approved' ORDER BY `Date` DESC";
}
else
{
$tr_query = "";
$tr['error_text'] = "Please specify correct dates";
}
$date_disabled = "";
break;
case 'between':
// First date parse
if ( $_POST['tr_between_date1'] == 'start' )
$between_date1 = 0;
elseif ( $_POST['tr_between_date1'] == 'now' )
$between_date1 = time();
else
$between_date1 = strtotime( $_POST['tr_between_date1'] );
// Second date parse
if ( $_POST['tr_between_date2'] == 'start' )
$between_date2 = 0;
elseif ( $_POST['tr_between_date2'] == 'now' )
$between_date2 = time();
else
$between_date2 = strtotime( $_POST['tr_between_date2'] );
$tr['between_date1'] = process_pass_data( $_POST['tr_between_date1'] );
$tr['between_date2'] = process_pass_data( $_POST['tr_between_date2'] );
if ( $between_date1 != -1 && $between_date2 != -1 )
{
$tr_query = "SELECT `ID`, `IDMember`, `IDProvider`, `gtwTransactionID`, DATE_FORMAT(`Date`, '$date_format' ) AS 'Date', `Amount`, `Currency`, `Status`, `Data`, `Description`, `Note` FROM `Transactions` INNER JOIN `aff_members` ON (`idProfile` = `IDMember`) WHERE `idAff` = $affID AND ( TO_DAYS( FROM_UNIXTIME($between_date1) ) <= TO_DAYS( `Date` ) AND TO_DAYS( FROM_UNIXTIME($between_date2) ) >= TO_DAYS( `Date` ) ) AND `Status` = 'approved' ORDER BY `Date` DESC";
}
else
{
$tr_query = "";
$tr['error_text'] = "Please specify correct dates";
}
$between_disabled = "";
break;
}
// Calculations
if ( strlen($tr_query) )
{
$fin = getFinanceAffStat( $affID, $tr );
}
// Transactions
if ( strlen($tr_query) )
{
$tr_res = db_res( $tr_query );
$tr_num = mysql_num_rows( $tr_res );
}
else
{
$tr_num = 0;
}
$_page['header'] = "Finance";
$_page['header_text'] = "Calculations and transactions";
send_headers_page_changed();
ob_start();
?>
$helpDivCode = ob_get_contents();
ob_end_clean();
/*
if ( $logged['admin'] )
TopCodeAdmin( $helpDivCode );
else
TopCodeAff( $helpDivCode );
*/
TopCodeAdmin( $helpDivCode );
ContentBlockHead("Finance ".$sHead);
if ( strlen($tr['error_text']) )
echo "
{$tr['error_text']}
";
?>
if ( strlen($tr_query) )
{
?>
Please Pay Attention
NOTE: Only transactions with site's current currency will be shown here.
Transactions and Calculations
Calculations for the query |
Membership subscriptions |
= $doll.$fin['membership_amount']; ?> |
Contact sales |
= $doll.$fin['sales_amount']; ?> |
Events tickets |
= $doll.$fin['sdating_amount']; ?> |
Total |
= $doll.$fin['total']; ?> |
Transactions |
if ( $tr_num == 0 )
{
echo "
No transactions available |
";
}
else
{
$paymentProviders = getPaymentProviders( false );
?>
Order number |
Date |
Member |
Provider |
Info |
Sum paid, = $currency_code ?> |
while( $tr_arr = mysql_fetch_array( $tr_res ) )
{
$tranDataArray = transStringToData( $tr_arr['Data'] );
$tranTypeString = 'Type: ' . $tranDataArray['action'];
$tranDataString = 'Description: ' . returnDescByAction( $tranDataArray['action'], $tranDataArray['data'], false );
$tranNoteString = strlen($tr_arr['Note']) ? 'Note: ' . $tr_arr['Note'] : '';
?>
= $tr_arr['gtwTransactionID'] ?> |
= $tr_arr['Date'] ?> |
= "{$tr_arr['IDMember']}" ?> |
= $paymentProviders[$tr_arr['IDProvider']]['Caption'] ?> |
Info |
= sprintf( "%.2f", $percent * (float)$tr_arr['Amount'] ) ?> |
}
}
?>
ContentBlockFoot();
}
BottomCode();
?>