0 ? $_COOKIE[affID] : ( $_GET[affID] > 0 ? $_GET[affID] : $_POST[affID] ); $affID = $AFF; if ( !strstr($affID,"@") ) { $affID = (int)$affID; $aff_arr = db_arr("SELECT Percent FROM aff WHERE ID=$affID"); } else { $aff_arr = db_arr("SELECT Percent FROM aff WHERE email='$affID'"); } $percent = $aff_arr[Percent]; $order_placed = ""; $trs_on = 1; $calc_on = 1; $tr[show] = $_POST[tr_show]; if ( !strlen( $tr[show] ) || ( ( $tr[show] != "trs_only" ) && ( $tr[show] != "calc_only" ) ) ) $tr[show] = "both"; switch( $tr[show] ) { case "trs_only": $trs_on = 1; $calc_on = 0; break; case "calc_only": $trs_on = 0; $calc_on = 1; break; case "both": $trs_on = 1; $calc_on = 1; break; } if ( strlen( $_POST[tr_total] ) ) { $tr[total] = "checked"; $trs_on = 0; } elseif ( strlen( $_POST[tr_order_num] ) ) { $tr[order_num] = $_POST[tr_order_num]; $tr[cond] = "ID = '$tr[order_num]'"; } elseif ( strlen( $_POST[tr_last_days] ) ) { $tr[last_days] = (int)$_POST[tr_last_days]; $tr[cond] = "( TO_DAYS( NOW() ) - TO_DAYS( Date ) <= $tr[last_days] )"; } elseif ( strlen( $_POST[tr_exact_date] ) ) { $tr[exact_date] = $_POST[tr_exact_date]; $tr[cond] = "Date = '$tr[exact_date]'"; $date_arr = explode( "-", $tr[exact_date] ); if ( !(int)( $date_arr[0] ) && !(int)( $date_arr[1] ) && !(int)( $date_arr[2] ) ) $tr[error_text] = "Please, set a valid date in the yyyy.mm.dd format"; } elseif ( strlen( $_POST[tr_between_date1] ) || strlen( $_POST[tr_between_date2] ) ) { $tr[between_date1] = $_POST[tr_between_date1]; $tr[between_date2] = $_POST[tr_between_date2]; if ( strcmp( $tr[between_date1], "start" ) ) { $tr[date_cond1] = "( TO_DAYS( '$tr[between_date1]' ) - TO_DAYS( Date ) <= 0 )"; $date1_arr = explode( "-", $tr[between_date1] ); if ( !(int)( $date1_arr[0] ) && !(int)( $date1_arr[1] ) && !(int)( $date1_arr[2] ) ) $tr[error_text] = "Please, set a valid 1st date in the yyyy.mm.dd format"; } else $tr[date_cond1] = "1"; if ( strcmp( $tr[between_date2], "now" ) ) { $tr[date_cond2] = "( TO_DAYS( '$tr[between_date2]' ) - TO_DAYS( Date ) >= 0 )"; $date2_arr = explode( "-", $tr[between_date2] ); if ( !(int)( $date2_arr[0] ) && !(int)( $date2_arr[1] ) && !(int)( $date2_arr[2] ) ) $tr[error_text] = "Please, set a valid 2nd date in the yyyy.mm.dd format"; } else $tr[date_cond2] = "1"; $tr[cond] = "( $tr[date_cond2] AND $tr[date_cond1] )"; } if ( strlen( $tr[total] ) || strlen( $tr[order_num] ) || strlen( $tr[last_days] ) || strlen( $tr[exact_date] ) || strlen( $tr[between_date1] ) || strlen( $tr[between_date2] ) ) $order_placed = 1; else $order_placed = 0; // Calculations if ( $order_placed && $calc_on ) { $psf = $tr; $fin = sales_finance_aff($affID); } // Transactions if ( $order_placed && $trs_on ) { // - Sales $trs = 0; if ( !strstr($affID,"@") ) $trs = db_res( "SELECT * FROM `Transactions` INNER JOIN aff_members ON (idProfile = Profile) WHERE $tr[cond] AND idAff = $AFF ORDER BY Date DESC" ); else $trs = db_res( "SELECT * FROM `Transactions`, `aff` INNER JOIN aff_members ON (idProfile = Profile) WHERE $tr[cond] AND aff.email = '$affID' AND aff_members.idAff = aff.ID ORDER BY Date DESC" ); //$trs = db_res( "SELECT * FROM `Transactions` WHERE $tr[cond] ORDER BY Date DESC" ); if ( $trs ) $tr_num = mysql_num_rows( $trs ); else $tr_num = 0; // - Membership if ( !strstr($affID,"@") ) $result = db_res( "SELECT * FROM `TransactionsMembership` INNER JOIN aff_members ON (idProfile = Member) WHERE $tr[cond] AND idAff = $AFF ORDER BY Date DESC" ); else $result = db_res( "SELECT * FROM `TransactionsMembership`, `aff` INNER JOIN aff_members ON (idProfile = Member) WHERE $tr[cond] AND aff.email = '$affID' AND aff_members.idAff = aff.ID ORDER BY Date DESC" ); $m_num = mysql_num_rows( $result ); } $_page[header] = "Finance"; $_page[header_text] = "Contact sales and gold membership subscriptions calculations and transactions"; send_headers_page_chaged(); if ( $logged[admin] ) TopCodeAdmin(); else TopCodeAff(); if ( !$order_placed ) echo "Place an order by one of the criteries in the form below"; ?>
 Show transactions and calculate sums 
 Total amount 
>
 For order number 
 During last 
 days (type 0 for today's transactions) 
 On the date: 
 (date format: yyyy-mm-dd
 Between dates   and (date format: yyyy-mm-dd)
The earlier date must be set first, the later one - second. Also you can use words "start" and "now" to indicate the beginning of your work and the present date. Do not use queries like "between start and now" because it can display a huge amount of transactions.
>  Calculations 
>  Total earnings   |  >  LoveCompass only   |  >
 Partner ID:  ">
Error: $tr[error_text]
"; if ( $logged[admin] ) BottomCodeAdmin(); else BottomCodeAff(); } if ( !$order_placed ) if ( $logged[admin] ) BottomCodeAdmin(); else BottomCodeAff(); if ( $calc_on ) { $odd = 1; ?>
 Calculations for the query
 Contact sales   $ 
 Premier membership subscriptions   $ 
 Total   $ 

Premier membership subscriptions transactions

"; if ( $logged[admin] ) BottomCodeAdmin(); else BottomCodeAff(); } ?>  No transactions available"; else { ?>
 Contact sales
 ID   Date   Member/Email   Profile   Sum paid, $ 
       $p_arr[Member]"; else echo $p_arr[Email]; ?>   $p_arr[Profile]"; ?> 
 Complete transactions list

 No transactions available"; else { ?>
 Premier membership subscriptions
 ID   Date   Membership type   Member   Sum paid, $ 
          $p_arr[Member]"; ?>   
 Complete transactions list