function myConsultantTotalSales()
{
    //get loged user's key
    $key = get_current_user_key();
    //Total Users on My left leg
    $leftLegUsers = totalLeftLegUsers($key);
    //paid users on my left leg
    $rightLegUsers = totalRightLegUsers($key);
    $totalConsultant = $leftLegUsers + $rightLegUsers;
    //show total users on left leg
    $totalUsersSales = totalSales($key);
    //_e("<pre>");print_r($totalUsersSales);exit;
    ?>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
        google.load('visualization', '1', {packages: ['table']});
    </script>
    <script type="text/javascript">
        var visualization;
        var data;
        var options = {'showRowNumber': true};
        function drawVisualization() {
            // Create and populate the data table.
            var dataAsJson =
                    {cols: [
                            {id: 'A', label: '<?php 
    echo _e("User Name", "binary-mlm-pro");
    ?>
', type: 'string'},
                            {id: 'B', label: '<?php 
    echo _e("User Key", "binary-mlm-pro");
    ?>
 ', type: 'string'},
                            {id: 'C', label: '<?php 
    echo _e("Sponsor", "binary-mlm-pro");
    ?>
', type: 'string'},
                            {id: 'D', label: '<?php 
    echo _e("Placement", "binary-mlm-pro");
    ?>
', type: 'string'},
                            {id: 'E', label: '<?php 
    echo _e("Status", "binary-mlm-pro");
    ?>
', type: 'string'}],
                        rows: [
    <?php 
    foreach ($totalUsersSales as $details) {
        foreach ($details as $row) {
            ?>
                                    {c: [{v: '<?php 
            echo $row['username'];
            ?>
'}, {v: '<?php 
            echo $row['user_key'];
            ?>
'}, {v: '<?php 
            echo $row['sponsor_key'];
            ?>
'}, {v: '<?php 
            echo $row['leg'];
            ?>
'}, {v: '<?php 
            echo $row['payment_status'];
            ?>
'}]},
            <?php 
        }
    }
    ?>
                        ]};
            data = new google.visualization.DataTable(dataAsJson);
            // Set paging configuration options
            // Note: these options are changed by the UI controls in the example.
            options['page'] = 'enable';
            options['pageSize'] = 10;
            options['pagingSymbols'] = {prev: 'prev', next: 'next'};
            options['pagingButtonsConfiguration'] = 'auto';
            //options['allowHtml'] = true;
            //data.sort({column:1, desc: false});
            // Create and draw the visualization.
            visualization = new google.visualization.Table(document.getElementById('table'));
            draw();
        }
        function draw() {
            visualization.draw(data, options);
        }
        google.setOnLoadCallback(drawVisualization);
        // sets the number of pages according to the user selection.
        function setNumberOfPages(value) {
            if (value) {
                options['pageSize'] = parseInt(value, 10);
                options['page'] = 'enable';
            } else {
                options['pageSize'] = null;
                options['page'] = null;
            }
            draw();
        }
        // Sets custom paging symbols "Prev"/"Next"
        function setCustomPagingButtons(toSet) {
            options['pagingSymbols'] = toSet ? {next: 'next', prev: 'prev'} : null;
            draw();
        }
        function setPagingButtonsConfiguration(value) {
            options['pagingButtonsConfiguration'] = value;
            draw();
        }
    </script>
    <!--va-matter-->
    <div class="va-matter">
        <!--va-matterbox-->
        <div class="va-matterbox">
            <!--va-headname-->
            <div class="va-headname"><?php 
    _e('My Consultants Details', 'binary-mlm-pro');
    ?>
</div>
            <!--/va-headname-->
            <div class="va-admin-leg-details">
                <!--va-admin-mid-->
                <div class="paging">
                    <form action="">
                        <div class="left-side">
                            <?php 
    _e('Display Number of Rows', 'binary-mlm-pro');
    ?>
 : &nbsp; 
                        </div>
                        <div class="right-side">
                            <select style="font-size: 12px" onchange="setNumberOfPages(this.value)">
                                <option value="5">5</option>
                                <option selected="selected" value="10">10</option>
                                <option value="20">20</option>
                                <option  value="50">50</option>
                                <option value="100">100</option>
                                <option value="500">500</option>
                                <option value="">All</option>
                            </select>
                        </div>	
                    </form>
                    <div class="right-members">
                        <?php 
    _e('Consultants', 'binary-mlm-pro');
    ?>
: &nbsp; <?php 
    _e('Left', 'binary-mlm-pro');
    ?>
: <strong><?php 
    echo $leftLegUsers;
    ?>
</strong>&nbsp;<?php 
    _e('Right', 'binary-mlm-pro');
    ?>
: <strong><?php 
    echo $rightLegUsers;
    ?>
</strong>
                        &nbsp; <?php 
    _e('Total', 'binary-mlm-pro');
    ?>
: <strong><?php 
    echo $totalConsultant;
    ?>
</strong>
                    </div>
                    <div class="va-clear"></div>
                </div>
                <div id="table"></div>
                <div class="va-clear"></div>
            </div>		
        </div>
    </div>	
    <?php 
}
<?php

$key = get_current_user_key();
$userId = get_current_userid();
if (isset($key)) {
    include wpmlm_get_template_file_path('classes/wpmlm-my-dashboard.class.php');
    $objMyDashboard = new MyDashboard($key);
    $userDetail = $objMyDashboard->GetUserInfoById($userId);
    $totalBus = $objMyDashboard->TotalBusiness($userId);
    $myLeftArr = $objMyDashboard->MyTop5LeftLegMember($userId);
    $myRightArr = $objMyDashboard->MyTop5RightLegMember($userId);
    $myPerSalesArr = $objMyDashboard->MyTop5PersonalSales($userId);
    $payoutArr = $objMyDashboard->MyTop5PayoutDetails($userId);
    $myRightTotal = $objMyDashboard->MyRightLegMemberTotal($userId);
    $myLeftTotal = $objMyDashboard->MyLeftLegMemberTotal($userId);
    $myPerSalesTotal = $objMyDashboard->MyPersonalSalesTotal($userId);
    //echo "<pre>";print_r($myLeftArr); exit;
    global $current_user;
    get_currentuserinfo();
    $sponsor_name = $current_user->user_login;
    $reg_page_id = wpmlm_get_the_post_id_by_shortcode('[registration]');
    $affiliateURL = get_permalink($reg_page_id) . '&sp=' . $key;
}
?>
<div class="dashboard">
	<br />
	<p class="affiliate_url"><strong>Affiliate URL :</strong> <?php 
echo $affiliateURL;
?>
 </p>
	<div class="leftSide">
    function network()
    {
        global $current_user;
        get_currentuserinfo();
        $username2 = $current_user->user_login;
        $res12 = mysql_fetch_array(mysql_query("SELECT * FROM " . WPMLM_TABLE_USER . " WHERE username = '******'"));
        if ($_POST['search']) {
            $username = $_POST['username'];
            $select = mysql_query("SELECT user_key FROM " . WPMLM_TABLE_USER . " WHERE username = '******'");
            $num = mysql_num_rows($select);
            if ($num) {
                $result = mysql_fetch_array($select);
                $left = mysql_query("SELECT pkey FROM " . WPMLM_TABLE_RIGHT_LEG . " \n\t\t\t\t\t\t\t\t\t WHERE ukey = '" . $result['user_key'] . "' AND pkey = '" . $res12['user_key'] . "'");
                $leftnum = mysql_num_rows($left);
                if ($leftnum) {
                    $key = $result['user_key'];
                } else {
                    $right = mysql_query("SELECT pkey FROM " . WPMLM_TABLE_LEFT_LEG . " \n\t\t\t\t\t\t\t\t\t\t  WHERE ukey = '" . $result['user_key'] . "' AND pkey = '" . $res12['user_key'] . "'");
                    $rightnum = mysql_num_rows($right);
                    if ($rightnum) {
                        $key = $result['user_key'];
                    } else {
                        ?>
		<p style="margin:0 auto;padding:0px;font-family:Arial, Helvetica, sans-serif;font-size:20px; text-align:center; font-weight:bold; padding:25px 0px 15px 0px;color:grey;">You can't authorized to access searched user's genealogy.</p>
		<div class="button-wrap" style="height:14px; margin-left:20px;">
<div class="red button">
<a href="javascript:history.back(1)">Back</a>
</div>
</div>
		<?php 
                        exit;
                    }
                }
            } else {
                ?>
		<p style="margin:0 auto;padding:0px;font-family:Arial, Helvetica, sans-serif;font-size:20px; text-align:center; font-weight:bold; padding:25px 0px 15px 0px;color:grey;">You have searched a wrong username.</p>
		<div class="button-wrap" style="height:14px; margin-left:20px;">
<div class="red button">
<a href="javascript:history.back(1)">Back</a>
</div>
</div>
		<?php 
                exit;
            }
        } else {
            if ($_GET['k'] != '') {
                $key = $_GET['k'];
            } else {
                $key = get_current_user_key();
            }
        }
        /*
        		$browser = getBrowser();
        		if($browser=="error")
        		{?>
        		<p style="margin:0 auto;padding:0px;font-family:Arial, Helvetica, sans-serif;font-size:20px; text-align:center; font-weight:bold; padding:25px 0px 15px 0px;color:grey;">For best results use only <a href="http://www.apple.com/safari/download/" target="_blank">Safari</a> / <a href="https://www.google.com/chrome" target="_blank">Chrome</a>.</p>
        		<?php
        			exit;
        		}*/
        if (!checkKey($key)) {
            ?>
		<p style="margin:0 auto;padding:0px;font-family:Arial, Helvetica, sans-serif;font-size:20px; text-align:center; font-weight:bold; padding:25px 0px 15px 0px;color:grey;">There has been an error while generating this tree. <br>Please contact the system admin at to report this problem.</p>
		<?php 
            exit;
        }
        /*********************************************** Root node ******************************************/
        $level = $this->buildRootNetwork($key);
        /*********************************************** First level ******************************************/
        $level = $this->buildLevelByLevelNetwork($key, $this->add_page_id, $this->view_page_id, 1, $level);
        /*********************************************** 2 and more level's ******************************************/
        if ($this->counter >= 2) {
            $j = 1;
            for ($i = 2; $i <= $this->counter; $i++) {
                $j = $j * 2;
                $level = $this->buildLevelByLevelNetwork($key, $this->add_page_id, $this->view_page_id, $j, $level);
            }
        }
        return $this->clients;
    }
function mlmNetworkDetailsPage()
{
    //get loged user's key
    $key = get_current_user_key();
    //Total my personal sales
    $personalSales = totalMyPersonalSales($key);
    //Total my personal sales active users
    $activePersonalSales = activeUsersOnPersonalSales($key);
    //show five users on personal sales
    $fivePersonalUsers = myFivePersonalUsers($key);
    //get logged in user info
    global $current_user, $wpdb;
    $table_prefix = mlm_core_get_table_prefix();
    get_currentuserinfo();
    $username = $current_user->ID;
    $user_info = get_userdata($current_user->ID);
    $_SESSION['ajax'] = 'ajax_check';
    $add_page_id = get_post_id('mlm_registration_page');
    $sponsor_name = $current_user->user_login;
    /**********Affiliate URL CODE***********************/
    $affiliateURLold = site_url() . '?page_id=' . $add_page_id . '&sp=' . $key;
    $affiliateURLnew = site_url() . '/u/' . $sponsor_name;
    $permalink = get_permalink(empty($_GET['page_id']) ? '' : $_GET['page_id']);
    $postidparamalink = strstr($permalink, 'page_id');
    $affiliateURL = $postidparamalink ? $affiliateURLold : $affiliateURLnew;
    /*********E O F Affiliate URL Code************************/
    $view_memberpage_id = $wpdb->get_var("SELECT id FROM {$table_prefix}posts  WHERE `post_content` LIKE '%mlm-view-child-level-member%'\tAND `post_type` != 'revision'");
    // Check Payment Method
    $mlm_method = get_option('wp_mlm_payment_method');
    $mlm_general_settings = get_option('wp_mlm_general_settings');
    $mlm_no_of_level = $mlm_general_settings['mlm-level'];
    $mlm_pay_settings = get_option('wp_mlm_payment_settings');
    //Check If USER is Not PAid then will show option for Payment
    $check_paid = $wpdb->get_var("SELECT payment_status FROM {$table_prefix}mlm_users WHERE user_id = '" . $username . "'");
    if ($check_paid == 0) {
        PayNowOptions($username, 'dashboard');
    }
    ?>
	     <?php 
    if (function_exists('Update_Paypal_Notification')) {
        Update_Paypal_Notification();
    }
    ?>
	
<p class="affiliate_url"><strong>Affiliate URL :</strong> <?php 
    echo $affiliateURL;
    ?>
 </p><br /> 
		<table width="100%" border="0" cellspacing="10" cellpadding="1">
		  <tr>
			<td width="40%" valign="top">
				<table width="100%" border="0" cellspacing="10" cellpadding="1">
				  <tr>
					<td colspan="2"><strong><?php 
    _e('Personal Information', 'unilevel-mlm-pro');
    ?>
</strong></td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
    _e('Title', 'unilevel-mlm-pro');
    ?>
</td>
					<td><?php 
    _e('Details', 'unilevel-mlm-pro');
    ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
    _e('Name', 'unilevel-mlm-pro');
    ?>
</td>
					<td><?php 
    echo $user_info->first_name . ' ' . $user_info->last_name;
    ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
    _e('Address', 'unilevel-mlm-pro');
    ?>
</td>
					<td style="white-space:normal;"><?php 
    echo $user_info->user_address1 . "<br>" . $user_info->user_address2;
    ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
    _e('City', 'unilevel-mlm-pro');
    ?>
</td>
					<td><?php 
    echo $user_info->user_city;
    ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
    _e('Contact No', 'unilevel-mlm-pro');
    ?>
.</td>
					<td><?php 
    echo $user_info->user_telephone;
    ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
    _e('DOB', 'unilevel-mlm-pro');
    ?>
</td>
					<td><?php 
    echo $user_info->user_dob;
    ?>
</td>
				  </tr>
				  
				  
				  
				  <tr>
		<td><a href="<?php 
    echo get_post_id_or_postname('mlm_update_profile_page', 'unilevel-mlm-pro');
    ?>
" style="text-decoration: none"><?php 
    _e('Edit', 'unilevel-mlm-pro');
    ?>
</a></td>
		<td><a href="<?php 
    echo get_post_id_or_postname('mlm_network_genealogy_page', 'unilevel-mlm-pro');
    ?>
" style="text-decoration: none"><?php 
    _e('View Genealogy', 'unilevel-mlm-pro');
    ?>
</a></td>
		</tr>
				</table> 
					<table width="100%" border="0" cellspacing="10" cellpadding="1">
				  <tr>
					<td colspan="2"><strong><?php 
    _e('My Payouts', 'unilevel-mlm-pro');
    ?>
</strong></td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
    _e('Date', 'unilevel-mlm-pro');
    ?>
</td>
					<td><?php 
    _e('Amount', 'unilevel-mlm-pro');
    ?>
</td>
       <td><?php 
    _e('Action', 'unilevel-mlm-pro');
    ?>
</td>
				  </tr>
<?php 
    $detailsArr = my_payout_function();
    //_e("<pre>");print_r($detailsArr); exit;
    //$page_id = get_post_id('mlm_my_payout_details_page');
    if (count($detailsArr) > 0) {
        $mlm_settings = get_option('wp_mlm_general_settings');
        ?>
			<?php 
        foreach ($detailsArr as $row) {
            $amount = $row->commission_amount + $row->bonus_amount;
            ?>
		<tr>
			<td><?php 
            echo $row->payoutDate;
            ?>
</td>
			<td><?php 
            echo $mlm_settings['currency'] . ' ' . $amount;
            ?>
</td>
			<td><a href="<?php 
            echo get_post_id_or_postname_for_payout('mlm_my_payout_details_page', $row->payout_id);
            ?>
">View</a></td>
			
		</tr>
		
		<?php 
        }
        ?>
	<?php 
    } else {
        ?>
	<div class="no-payout"><?php 
        _e('You have not earned any commisssions yet.', 'unilevel-mlm-pro');
        ?>
 </div>
	
	<?php 
    }
    ?>
				</table>
			</td>
			<td width="40%">
				<table width="100%" border="0" cellspacing="10" cellpadding="1">
				  <tr>
					<td><strong><?php 
    _e('Network Details', 'unilevel-mlm-pro');
    ?>
</strong></td>
				  </tr>
				  
				  

				 	<tr>
					<td>
						<table width="100%" border="0" cellspacing="10" cellpadding="1">
							<tr>
								<td colspan="2"><strong><?php 
    _e('Personal Sales', 'unilevel-mlm-pro');
    ?>
</strong></td>
							</tr>
							
							<tr>
								<td><?php 
    _e('My Personal Sales', 'unilevel-mlm-pro');
    ?>
: <?php 
    echo $personalSales;
    ?>
</td>
			<td><?php 
    _e('Active', 'unilevel-mlm-pro');
    ?>
: <?php 
    echo $activePersonalSales;
    ?>
</td>
							</tr>
							<?php 
    foreach ($fivePersonalUsers as $key => $value) {
        _e("<tr>");
        foreach ($value as $k => $val) {
            _e("<td>" . $val . "</td>");
        }
        _e("</tr>");
    }
    ?>
							<tr>
		<td colspan="2"><a href="?page_id=<?php 
    echo $view_memberpage_id;
    ?>
&lvl=1" style="text-decoration: none"><?php 
    _e('View All', 'unilevel-mlm-pro');
    ?>
</a></td>
		</tr>
							
						</table>
					</td>
				  </tr> 
				  
				</table>
			</td>
		  </tr>
		</table>

<?php 
}
function mlm_my_financial_dashboard_page($id = '')
{
    global $table_prefix;
    global $wpdb;
    global $date_format;
    global $current_user;
    $mlm_payouts = get_option('wp_mlm_payout_settings');
    $url = plugins_url();
    $userKey = get_current_user_key();
    $user_id = getuseridbykey($userKey);
    $user_name = getusernamebykey($userKey);
    $mlm_currency = get_option('wp_mlm_general_settings');
    $currency = $mlm_currency['currency'];
    $balance = $wpdb->get_var("SELECT closing_bal FROM {$table_prefix}mlm_transaction  WHERE id = (select max(id) from {$table_prefix}mlm_transaction where user_id='" . $user_id . "')");
    $withdrwl_bal = $wpdb->get_var("SELECT SUM(round(amount+withdrawal_fee+witholding_tax)) as total FROM {$table_prefix}mlm_withdrawal  where payment_processed=0 AND user_id='" . $user_id . "'");
    $Left_balance = $balance - $withdrwl_bal;
    $Left_balance = number_format($Left_balance, 2, '.', '');
    if (isset($_POST['submit'])) {
        //Check if already request for withdrawal
        $wamount = empty($_POST['wamount']) ? '' : $_POST['wamount'];
        $wcomment = empty($_POST['wcomment']) ? '' : $_POST['wcomment'];
        $withdrawalMode = empty($_POST['withdrawalMode']) ? '' : $_POST['withdrawalMode'];
        $waddress = empty($_POST['address']) ? '' : " - \n" . $_POST['address'];
        $other = empty($_POST['other']) ? '' : $_POST['other'];
        // Settings for Minimum Amount can withdraw By User
        $minAmt = unserialize(stripcslashes($_POST['withdrawalMode']));
        if ($minAmt[3] != '') {
            $min_amount = $minAmt[3];
        }
        $error = '';
        if (checkInputField($wamount)) {
            $error .= "</br> Please enter your Amount.";
        }
        if (checkInputField($withdrawalMode)) {
            $error .= "</br> Please Select Any Payment mode.";
        }
        if ($wamount > $balance) {
            $error .= "</br> Amount should be less or equal your Balance Amount.";
        }
        if ($wamount > $balance - $withdrwl_bal && isset($withdrwl_bal)) {
            $error .= "</br> Your Withdrawal Request for Amount " . $withdrwl_bal . " is Pending.You have not sufficient Amount for this Withdrawal Request.";
        }
        if ($wamount < $min_amount && isset($min_amount)) {
            $error .= "</br> Withdrawal Amount should be Minimum " . $currency . " " . $min_amount;
        }
        if (empty($error)) {
            $other_deduc = get_option('wp_mlm_other_method_settings');
            if (!empty($other_deduc)) {
                for ($i = 0; $i <= count($other_deduc['othr_mthd']) - 1; $i++) {
                    // $other_deduc['othr_mthd'][$i],$other_deduc['othr_amt'][$i],$other_deduc['othr_type'][$i];
                    if ($other_deduc['othr_type'][$i] == 'percent') {
                        $othr_mthd[] = $other_deduc['othr_mthd'][$i];
                        $deduct_amount[] = $wamount * $other_deduc['othr_amt'][$i] / 100;
                        $deduct_type[] = $other_deduc['othr_type'][$i];
                        $wamount = $wamount - $deduct_amount[$i];
                    }
                    if ($other_deduc['othr_type'][$i] == 'fixed') {
                        $othr_mthd[] = $other_deduc['othr_mthd'][$i];
                        $deduct_amount[] = $other_deduc['othr_amt'][$i];
                        $deduct_type[] = $other_deduc['othr_type'][$i];
                        $wamount = $wamount - $deduct_amount[$i];
                    }
                }
                $other_method_serialize = array($othr_mthd, $deduct_amount, $deduct_type);
                //print_r(//$other_method_serialize); die;
                $otherDeduct = array_sum($deduct_amount);
            } else {
                $other_method_serialize = 0;
                $otherDeduct = 0;
            }
            $wdrAmount = $wamount;
            $deduct = unserialize(stripcslashes($_POST['withdrawalMode']));
            if ($deduct[2] == 'percent') {
                $deduct_amount = $wdrAmount * $deduct[1] / 100;
            }
            if ($deduct[2] == 'fixed') {
                $deduct_amount = $deduct[1];
            }
            $wdr_amount = $wdrAmount - $deduct_amount;
            $sql = "INSERT {$table_prefix}mlm_withdrawal SET \n            `withdrawal_initiated`=1, \n            `withdrawal_initiated_comment` = '" . $wcomment . "', \n            `withdrawal_initiated_date` = NOW() , \n            `withdrawal_mode` = '" . $deduct[0] . $waddress . "',\n\t\t\t`other_method` = '" . serialize($other_method_serialize) . "',\n            `user_id` = '" . $user_id . "' ,\n            `amount`='" . $wdr_amount . "',\n            `withdrawal_fee`='" . $deduct_amount . "',\n            `witholding_tax`='" . $otherDeduct . "'";
            $wpdb->query($sql);
            if ($u = get_option('process_withdrawal_mail', true) == 1) {
                //Generate Mail to Admin Regarding With-drawal Amount
                WithDrawalProcessMail($user_id, $_POST);
            }
            $sucsess = 'Your Withdrawal Request Initiated';
            $sucsess .= '</br>Thanks for Patience';
            unset($wamount, $wcomment, $withdrawalMode, $waddress, $_POST['radio']);
        }
    }
    ?>
<script>
	    $(function() {
		$('#delivery').hide();
                $('#other').hide();
                $('#withdrawalMode').change(function(){ 
                $('#delivery').hide();
                
                $('#other').hide();
                $('#' + $(this).val()).show();
        });
    });
</script>
<style>.payout-summary tr { margin:10px 0px; }</style>
	<!--<script src="initiate.js" type="text/javascript"></script>-->
		<span style='color:red;'><?php 
    echo !empty($error) ? $error : '';
    ?>
</span>
        <span style='color:green;'><?php 
    echo !empty($sucsess) ? $sucsess : '';
    ?>
</span>
		<form name="form" action="" method="post" >
        <table width="100%" border="0" cellspacing="10" cellpadding="1" class="payout-summary">
		<tr><td><strong>User Name:</strong>&nbsp;&nbsp;&nbsp;<strong><?php 
    echo $user_name;
    ?>
</strong></td>
        <td><strong>Account Balance:</strong>&nbsp;&nbsp;&nbsp;<strong><?php 
    echo $currency;
    echo empty($balance) ? '0.00' : $balance;
    ?>
</strong></td></tr>
  
<tr><td>&nbsp;</td>
        <td><strong>Withdrawable Balance:</strong>&nbsp;&nbsp;&nbsp;<strong><?php 
    echo $currency;
    echo empty($Left_balance) ? '0.00' : $Left_balance;
    ?>
</strong></td></tr>
  
				<tr>
                <td><strong>Withdrawal Amount</strong></td>
                <td width="50%"><input type="text" name="wamount" id="wamount"  onblur="return numeric(this.value,'wamount');" value="<?php 
    echo empty($wamount) ? '' : $wamount;
    ?>
"  size="21" /></td>
                </tr>
                <td><strong>Comment </strong></td>
				<td width="50%" ><textarea name="wcomment" id="wcomment"><?php 
    echo empty($wcomment) ? '' : $wcomment;
    ?>
</textarea></td>
                </tr>
                <tr>
                <td><strong>Withdrawal Mode </strong></td>
                <td width="50%" ><select name="withdrawalMode" id="withdrawalMode"  onblur="" >
                        
                <option value="">Select Option</option>
                <?php 
    $deduction = get_option('wp_mlm_withdrawal_method_settings');
    for ($i = 0; $i <= count($deduction['withdwl_mthd']) - 1; $i++) {
        $value = array($deduction['withdwl_mthd'][$i], $deduction['withdwl_amt'][$i], $deduction['withdwl_type'][$i], $deduction['min_amount'][$i]);
        $values = serialize($value);
        ?>
                <option value='<?php 
        echo $values;
        ?>
' <?php 
        if (isset($_POST['withdrawalMode'])) {
            if ($deduction['withdwl_mthd'][$i] == $minAmt[0]) {
                echo 'selected';
            }
        }
        ?>
><?php 
        echo $deduction['withdwl_mthd'][$i];
        ?>
</option>
                <?php 
    }
    ?>
                </select></td></tr>
                <tr><td>&nbsp;</td><td><textarea  name="address"   onblur="return allowspace(this.value,'delivery');" id="delivery" placeholder="Enter your Address" ></textarea></td></tr>
            <tr><td>&nbsp;</td><td><input type="text"  name="other"   onblur="return allowspace(this.value,'delivery');" id="other"  /></td></tr>
           <tr><td>&nbsp;</td><td><input type="submit"name="submit" id="submit" value="Submit"  /></td></tr>
			</table></form>
        <form method="post" action="" >
        <table><tr><td><input type="submit" name="view" value="View Transaction history"></td><td></td></tr></table>
        </form>
<?php 
    if (isset($_POST['view']) && $_POST['view'] === 'View Transaction history') {
        $result = $wpdb->get_results("select * from {$table_prefix}mlm_transaction where user_id={$user_id} order by transaction_date ASC");
        $records = array_reverse($result);
        $totalrecords = count($records);
        //$othr_method = $wpdb->get_var("select other_method from {$table_prefix}mlm_withdrawal where user_id ='1' AND id=21");
        // print_r(unserialize($othr_method));
        $rowcount = 0;
        ?>
        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
  google.load('visualization', '1', {packages: ['table']});
</script>
<script type="text/javascript">
var visualization;
var data;
var options = {'showRowNumber': false};
function drawVisualization() {
  // Create and populate the data table.
  var dataAsJson =
  {cols:[
	{id:'A',label:'<?php 
        echo _e("Date", "unilevel-mlm-pro");
        ?>
',type:'string'},
	{id:'B',label:'<?php 
        echo _e("Opening Bal", "unilevel-mlm-pro");
        ?>
',type:'string'},
	{id:'C',label:'<?php 
        echo _e("Dr. Amount", "unilevel-mlm-pro");
        ?>
',type:'string'},
        {id:'C',label:'<?php 
        echo _e("Cr.Amount", "unilevel-mlm-pro");
        ?>
',type:'string'},
        {id:'C',label:'<?php 
        echo _e("Closing Bal", "unilevel-mlm-pro");
        ?>
',type:'string'},
	{id:'D',label:'<?php 
        echo _e("Comment", "unilevel-mlm-pro");
        ?>
',type:'string'}],
  rows:[
   <?php 
        foreach ($records as $row) {
            if ($row->transaction_type == 1) {
                $type = 'deposit';
            }
            if ($row->transaction_type == 2) {
                $type = 'Withdrawal';
            }
            if ($row->dr_id != '0') {
                $withdrawal_fee = $wpdb->get_var("select withdrawal_fee from {$table_prefix}mlm_withdrawal where user_id ='{$row->user_id}' AND id='{$row->dr_id}'");
                $witholding_tax = $wpdb->get_var("select witholding_tax from {$table_prefix}mlm_withdrawal where user_id ='{$row->user_id}' AND id='{$row->dr_id}'");
                $othrs_method = '';
                $othrs_method = $wpdb->get_var("select other_method from {$table_prefix}mlm_withdrawal where user_id ='{$row->user_id}' AND id='{$row->dr_id}'");
                $othr_method = unserialize($othrs_method);
            }
            //print_r($othr_method);exit;
            $wf = empty($withdrawal_fee) ? '0.0' : $withdrawal_fee;
            $wt = empty($witholding_tax) ? '0.0' : $witholding_tax;
            $type = !empty($type) ? '0.0' : $type;
            $wf_comment = empty($withdrawal_fee) ? '' : 'Withdrawal Processing Fee';
            $wt_comment = empty($witholding_tax) ? '' : 'Other Deductions:';
            ?>
			
<?php 
            if (!empty($wt) && $wt != '0.0') {
                $amt = 0;
                for ($i = 0; $i < count($othr_method[1]); $i++) {
                    if ($i == 0) {
                        $wt_opening = $row->closing_bal + $othr_method[1][$i];
                        $closing = $row->closing_bal;
                    }
                    if ($i > 0) {
                        $amt = $amt + $othr_method[1][$i - 1];
                        $wt_opening = $row->closing_bal + $othr_method[1][$i] + $amt;
                        $closing = $row->closing_bal + $amt;
                    }
                    $rowcount++;
                    ?>
      {c:[{v:'<?php 
                    echo DefaultDateFormat($row->transaction_date);
                    ?>
'},
                        {v:'<?php 
                    echo number_format($wt_opening, 2, '.', '');
                    ?>
'},
                        {v:'<?php 
                    echo number_format($othr_method[1][$i], 2, '.', '');
                    ?>
'},
                        {v:'<?php 
                    echo number_format($row->cr_amount, 2, '.', '');
                    ?>
'},
                        {v:'<?php 
                    echo number_format($closing, 2, '.', '');
                    ?>
'},
                        {v:'<?php 
                    echo 'Other Deductions: ' . $othr_method[0][$i];
                    ?>
'}]},
<?php 
                }
            }
            ?>
	
			
	<?php 
            if (!empty($wf) && $wf != '0.0') {
                $rowcount++;
                ?>
	{c:[{v:'<?php 
                echo DefaultDateFormat($row->transaction_date);
                ?>
'},
                        {v:'<?php 
                echo number_format($row->closing_bal + $wf + $wt, 2, '.', '');
                ?>
'},
                        {v:'<?php 
                echo number_format($wf, 2, '.', '');
                ?>
'},
                        {v:'<?php 
                echo number_format($row->cr_amount, 2, '.', '');
                ?>
'},
                        {v:'<?php 
                echo number_format($row->closing_bal + $wt, 2, '.', '');
                ?>
'},
                        {v:'<?php 
                echo $wf_comment;
                ?>
'}]},
	<?php 
            }
            ?>
		
		{c:[{v:'<?php 
            echo DefaultDateFormat($row->transaction_date);
            ?>
'},
                        {v:'<?php 
            echo number_format($row->opening_bal, 2, '.', '');
            ?>
'},
                        {v:'<?php 
            echo number_format($row->dr_amount - $wf - $wt, 2, '.', '');
            ?>
'},
                        {v:'<?php 
            echo number_format($row->cr_amount, 2, '.', '');
            ?>
'},
                        {v:'<?php 
            echo number_format($row->closing_bal + $wf + $wt, 2, '.', '');
            ?>
'},
                        {v:'<?php 
            echo $row->comment;
            ?>
'}]},

	
	<?php 
            $rowcount++;
            unset($withdrawal_fee, $witholding_tax, $fundTransDeduct);
        }
        ?>
  
  ]};
  data = new google.visualization.DataTable(dataAsJson);
  // Set paging configuration options
  // Note: these options are changed by the UI controls in the example.
  options['page'] = 'enable';
  options['pageSize'] = 10;
  options['pagingSymbols'] = {prev: 'prev', next: 'next'};
  options['pagingButtonsConfiguration'] = 'auto';
  //options['allowHtml'] = true;
  //data.sort({column:1, desc: false});
  // Create and draw the visualization.
  visualization = new google.visualization.Table(document.getElementById('table'));
  draw();
}
function draw() {
  visualization.draw(data, options);
}
google.setOnLoadCallback(drawVisualization);
// sets the number of pages according to the user selection.
function setNumberOfPages(value) {
  if (value) {
	options['pageSize'] = parseInt(value, 10);
	options['page'] = 'enable';
  } else {
	options['pageSize'] = null;
	options['page'] = null;  
  }
  draw();
}
// Sets custom paging symbols "Prev"/"Next"
function setCustomPagingButtons(toSet) {
  options['pagingSymbols'] = toSet ? {next: 'next', prev: 'prev'} : null;
  draw();  
}
function setPagingButtonsConfiguration(value) {
  options['pagingButtonsConfiguration'] = value;
  draw();
}
</script>
<!--va-matter-->
    <div class="va-matter">
    	<!--va-matterbox-->
    	<div class="va-matterbox">
        	<!--va-headname-->
        	<div class="va-headname"><?php 
        _e('My Transaction History (All figures below are in ' . $currency . ')', 'unilevel-mlm-pro');
        ?>
</div>
            <!--/va-headname-->
			<div class="va-admin-leg-details">
            	<!--va-admin-mid-->
				<div class="paging">
				  <form action="">
					<div class="left-side">
						<?php 
        _e('Display Number of Rows', 'unilevel-mlm-pro');
        ?>
 : &nbsp; 
					</div>
					<div class="right-side">
						<select style="font-size: 12px" onchange="setNumberOfPages(this.value)">
						  <option value="5">5</option>
						  <option selected="selected" value="10">10</option>
						  <option value="20">20</option>
						  <option  value="50">50</option>
						  <option value="100">100</option>
						  <option value="500">500</option>
						   <option value="">All</option>
						</select>
					</div>	
					</form>
					<div class="right-members">
					<?php 
        _e('Total Records', 'unilevel-mlm-pro');
        ?>
: <strong><?php 
        echo $rowcount;
        ?>
</strong>
					</div>
					<div class="va-clear"></div>
				  </div>
				<div id="table"></div>
				<div class="va-clear"></div>
			</div>		
		</div>
	</div>	
<?php 
    }
}
function mlmNetworkDetailsPage()
{
    //get loged user's key
    $key = get_current_user_key();
    //Total Users on My left leg
    $leftLegUsers = totalLeftLegUsers($key);
    //Total users on my right leg
    $rightLegUsers = totalRightLegUsers($key);
    //paid users on my left leg
    $leftLegActiveUsers = activeUsersOnLeftLeg($key);
    //paid users on my right leg
    $rightLegActiveUsers = activeUsersOnRightLeg($key);
    //Total my personal sales
    $personalSales = totalMyPersonalSales($key);
    //Total my personal sales active users
    $activePersonalSales = activeUsersOnPersonalSales($key);
    //show five users on left leg
    $fiveLeftLegUsers = myFiveLeftLegUsers($key);
    //show five users on right leg
    $fiveRightLegUsers = myFiveRightLegUsers($key);
    //show five users on personal sales
    $fivePersonalUsers = myFivePersonalUsers($key);
    //get logged in user info
    global $current_user, $wpdb;
    get_currentuserinfo();
    $username = $current_user->ID;
    $user_info = get_userdata($current_user->ID);
    $_SESSION['ajax'] = 'ajax_check';
    $add_page_id = get_post_id('mlm_registration_page');
    $sponsor_name = $current_user->user_login;
    $affiliateURLold = site_url() . '?page_id=' . $add_page_id . '&sp=' . $key;
    $affiliateURLnew = site_url() . '/u/' . getusernamebykey($key);
    $permalink = get_permalink(empty($_GET['page_id']) ? '' : $_GET['page_id']);
    $postidparamalink = strstr($permalink, 'page_id');
    $affiliateURL = $postidparamalink ? $affiliateURLold : $affiliateURLnew;
    ?>
    <?php 
    if (function_exists('Update_Paypal_Notification')) {
        Update_Paypal_Notification();
    }
    ?>
    <p class="affiliate_url"><strong>Affiliate URL :</strong> <?php 
    echo $affiliateURL;
    ?>
 </p><br />

    <table width="100%" border="0" cellspacing="10" cellpadding="1">
        <tr>
            <td width="40%" valign="top">
                <table width="100%" border="0" cellspacing="10" cellpadding="1">
                    <tr>
                        <td colspan="2"><strong> <?php 
    _e('Personal Information', 'binary-mlm-pro');
    ?>
</strong></td>
                    </tr>
                    <tr>
                        <td scope="row"><?php 
    _e('Title', 'binary-mlm-pro');
    ?>
</td>
                        <td> <?php 
    _e('Details', 'binary-mlm-pro');
    ?>
</td>
                    </tr>
                    <tr>
                        <td scope="row"> <?php 
    _e('Name', 'binary-mlm-pro');
    ?>
</td>
                        <td><?php 
    echo $user_info->first_name . ' ' . $user_info->last_name;
    ?>
</td>
                    </tr>
                    <tr>
                        <td scope="row"> <?php 
    _e('Address', 'binary-mlm-pro');
    ?>
</td>
                        <td style="white-space:normal;"><?php 
    echo $user_info->user_address1 . "<br>" . $user_info->user_address2;
    ?>
</td>
                    </tr>
                    <tr>
                        <td scope="row"> <?php 
    _e('City', 'binary-mlm-pro');
    ?>
</td>
                        <td><?php 
    echo $user_info->user_city;
    ?>
</td>
                    </tr>
                    <tr>
                        <td scope="row"> <?php 
    _e('Contact No', 'binary-mlm-pro');
    ?>
.</td>
                        <td><?php 
    echo $user_info->user_telephone;
    ?>
</td>
                    </tr>
                    <tr>
                        <td scope="row"> <?php 
    _e('DOB', 'binary-mlm-pro');
    ?>
</td>
                        <td><?php 
    echo $user_info->user_dob;
    ?>
</td>
                    </tr>



                    <tr>
                        <td><a href="<?php 
    echo get_post_id_or_postname('mlm_update_profile_page', 'binary-mlm-pro');
    ?>
" style="text-decoration: none"><?php 
    _e('Edit', 'binary-mlm-pro');
    ?>
</a></td>
                        <td><a href="<?php 
    echo get_post_id_or_postname('mlm_network_genealogy_page', 'binary-mlm-pro');
    ?>
" style="text-decoration: none"><?php 
    _e('View Genealogy', 'binary-mlm-pro');
    ?>
</a></td>
                    </tr>
                </table>
                <table width="100%" border="0" cellspacing="10" cellpadding="1">
                    <tr>
                        <td colspan="2"><strong><?php 
    _e('My Payouts', 'binary-mlm-pro');
    ?>
</strong></td>
                    </tr>
                    <tr>
                        <td scope="row"><?php 
    _e('Date', 'binary-mlm-pro');
    ?>
</td>
                        <td><?php 
    _e('Amount', 'binary-mlm-pro');
    ?>
</td>
                        <td><?php 
    _e('Action', 'binary-mlm-pro');
    ?>
</td>
                    </tr>
                    <?php 
    $detailsArr = my_payout_function();
    //_e("<pre>");print_r($detailsArr); exit;
    //$page_id = get_post_id('mlm_my_payout_details_page');
    if (count($detailsArr) > 0) {
        $mlm_settings = get_option('wp_mlm_general_settings');
        ?>
                        <?php 
        foreach ($detailsArr as $row) {
            $amount = $row->commission_amount + $row->bonus_amount + $row->referral_commission_amount - $row->tax - $row->service_charge;
            ?>
                            <tr>
                                <td><?php 
            echo $row->payoutDate;
            ?>
</td>
                                <td><?php 
            echo $mlm_settings['currency'] . ' ' . $amount;
            ?>
</td>
                                <td><a href="<?php 
            echo get_post_id_or_postname_for_payout('mlm_my_payout_details_page', $row->payout_id);
            ?>
"><?php 
            echo __('View', 'binary-mlm-pro');
            ?>
</a></td>

                            </tr>

                        <?php 
        }
        ?>
                        <?php 
    } else {
        ?>
                        <div class="no-payout"><?php 
        _e('You have not earned any commisssions yet.', 'binary-mlm-pro');
        ?>
 </div>

                        <?php 
    }
    ?>
                </table>
            </td>
            <td width="40%">
                <table width="100%" border="0" cellspacing="10" cellpadding="1">
                    <tr>
                        <td><strong><?php 
    _e('Network Details', 'binary-mlm-pro');
    ?>
</strong></td>
                    </tr>
                    <tr>
                        <td>
                            <table width="100%" border="0" cellspacing="10" cellpadding="1">
                                <tr>
                                    <td colspan="2"><strong><?php 
    _e('Left Leg Sales', 'binary-mlm-pro');
    ?>
</strong></td>
                                </tr>

                                <tr>
                                    <td><?php 
    _e('Total on Left Leg', 'binary-mlm-pro');
    ?>
: <?php 
    echo $leftLegUsers;
    ?>
</td>
                                    <td><?php 
    _e('Active', 'binary-mlm-pro');
    ?>
: <?php 
    echo $leftLegActiveUsers;
    ?>
</td>
                                </tr>
                                <?php 
    foreach ($fiveLeftLegUsers as $key => $value) {
        _e("<tr>");
        foreach ($value as $k => $val) {
            _e("<td>" . $val . "</td>");
        }
        _e("</tr>");
    }
    ?>
                                <tr>
                                    <td colspan="2"><a href="<?php 
    echo get_post_id_or_postname('mlm_left_group_details_page', 'binary-mlm-pro');
    ?>
" style="text-decoration: none"><?php 
    _e('View All', 'binary-mlm-pro');
    ?>
</a></td>
                                </tr>

                            </table>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <table width="100%" border="0" cellspacing="10" cellpadding="1">
                                <tr>
                                    <td colspan="2"><strong><?php 
    _e('Right Leg Sales', 'binary-mlm-pro');
    ?>
</strong></td>
                                </tr>

                                <tr>
                                    <td><?php 
    _e('Total on Right Leg', 'binary-mlm-pro');
    ?>
: <?php 
    echo $rightLegUsers;
    ?>
</td>
                                    <td><?php 
    _e('Active', 'binary-mlm-pro');
    ?>
: <?php 
    echo $rightLegActiveUsers;
    ?>
</td>
                                </tr>
                                <?php 
    foreach ($fiveRightLegUsers as $key => $value) {
        _e("<tr>");
        foreach ($value as $k => $val) {
            _e("<td>" . $val . "</td>");
        }
        _e("</tr>");
    }
    ?>
                                <tr>
                                    <td colspan="2"><a href="<?php 
    echo get_post_id_or_postname('mlm_right_group_details_page', 'binary-mlm-pro');
    ?>
" style="text-decoration: none"><?php 
    _e('View All', 'binary-mlm-pro');
    ?>
</a></td>
                                </tr>

                            </table>
                        </td>
                    </tr>


                    <tr>
                        <td>
                            <table width="100%" border="0" cellspacing="10" cellpadding="1">
                                <tr>
                                    <td colspan="2"><strong><?php 
    _e('Personal Sales', 'binary-mlm-pro');
    ?>
</strong></td>
                                </tr>

                                <tr>
                                    <td><?php 
    _e('My Personal Sales', 'binary-mlm-pro');
    ?>
: <?php 
    echo $personalSales;
    ?>
</td>
                                    <td><?php 
    _e('Active', 'binary-mlm-pro');
    ?>
: <?php 
    echo $activePersonalSales;
    ?>
</td>
                                </tr>
                                <?php 
    foreach ($fivePersonalUsers as $key => $value) {
        _e("<tr>");
        foreach ($value as $k => $val) {
            _e("<td>" . $val . "</td>");
        }
        _e("</tr>");
    }
    ?>
                                <tr>
                                    <td colspan="2"><a href="<?php 
    echo get_post_id_or_postname('mlm_personal_group_details_page', 'binary-mlm-pro');
    ?>
" style="text-decoration: none"><?php 
    _e('View All', 'binary-mlm-pro');
    ?>
</a></td>
                                </tr>

                            </table>
                        </td>
                    </tr> 

                </table>
            </td>
        </tr>
    </table>

    <?php 
}