function mlm_my_payout_details_page($id = '')
{
    global $table_prefix;
    global $wpdb;
    global $date_format;
    $url = plugins_url();
    if ($id == '') {
        $detailArr = my_payout_details_function();
    } else {
        $detailArr = my_payout_details_function($id);
    }
    if (count($detailArr) > 0) {
        $memberId = $detailArr['memberId'];
        $payoutId = $detailArr['payoutId'];
        $comissionArr = getCommissionByPayoutId($memberId, $payoutId);
        $dirRefComm = getDirectReferralCommissionByPayoutId($memberId, $payoutId);
        $bonusArr = getBonusByPayoutId($memberId, $payoutId);
        $statusArray = getWithDrawal($memberId, $payoutId);
        $mlm_settings = get_option('wp_mlm_general_settings');
        $mlm_payouts = get_option('wp_mlm_payout_settings');
        $capLimitAmt = $mlm_payouts['cap_limit_amount'];
        $total_amt = $detailArr['total_amt'];
        $capped_amt = $detailArr['capped_amt'];
        $cap_limit = $detailArr['cap_limit'];
        ?>
        <!--<script src="initiate.js" type="text/javascript"></script>-->
        <table width="100%" border="0" cellspacing="10" cellpadding="1">
            <tr>
                <td colspan="2"><input type="button" value="Back" onclick="window.history.back()" class="primary"</td>
            </tr>
            <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 $detailArr['name'];
        ?>
</td>
                        </tr>
                        <tr>
                            <td scope="row"><?php 
        _e('ID', 'binary-mlm-pro');
        ?>
</td>
                            <td><?php 
        echo $detailArr['userKey'];
        ?>
</td>
                        </tr>
                        <tr>
                            <td scope="row"><?php 
        _e('Payout ID', 'binary-mlm-pro');
        ?>
</td>
                            <td><?php 
        echo $detailArr['payoutId'];
        ?>
</td>
                        </tr>
                        <tr>
                            <td scope="row"><?php 
        _e('Date', 'binary-mlm-pro');
        ?>
</td>
                            <td><?php 
        echo $detailArr['payoutDate'];
        ?>
</td>
                        </tr>
                    </table>
                </td>
                <td width="40%">
                    <table width="100%" border="0" cellspacing="10" cellpadding="1">
                        <tr>
                            <td><strong><?php 
        _e('Payout 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('Commission', 'binary-mlm-pro');
        ?>
</strong></td>
                                    </tr>

                                    <tr>
                                        <td><?php 
        _e('User Name', 'binary-mlm-pro');
        ?>
</td>
                                        <td><?php 
        _e('Amount', 'binary-mlm-pro');
        ?>
</td>
                                    </tr>
                                    <?php 
        foreach ($comissionArr as $comm) {
            ?>

                                        <tr>
                                            <td><?php 
            echo $comm['child_ids'];
            ?>
</td>
                                            <td><?php 
            echo $mlm_settings['currency'] . ' ' . $comm['amount'];
            ?>
</td>
                                        </tr>

                                    <?php 
        }
        ?>


                                </table>
                                <?php 
        if (count($dirRefComm) > 0) {
            ?>
                                    <table width="100%" border="0" cellspacing="10" cellpadding="1">
                                        <tr>
                                            <td colspan="2"><strong><?php 
            _e('Direct Referral Commission', 'binary-mlm-pro');
            ?>
</strong></td>
                                        </tr>
                                        <tr>
                                            <td><?php 
            _e('User Name', 'binary-mlm-pro');
            ?>
</td>
                                            <td><?php 
            _e('Amount', 'binary-mlm-pro');
            ?>
</td>
                                        </tr>
                                        <?php 
            foreach ($dirRefComm as $comm) {
                ?>

                                            <tr>
                                                <td><?php 
                echo $comm['username'];
                ?>
</td>
                                                <td><?php 
                echo $mlm_settings['currency'] . ' ' . $comm['amount'];
                ?>
</td>
                                            </tr>
                                        <?php 
            }
            ?>
                                    </table>
                                <?php 
        }
        ?>
                            </td>
                        </tr>
                        <?php 
        if (count($bonusArr) > 0) {
            ?>
                            <tr>
                                <td>
                                    <table width="100%" border="0" cellspacing="10" cellpadding="1">
                                        <tr>
                                            <td colspan="2"><strong><?php 
            _e('Bonus', 'binary-mlm-pro');
            ?>
</strong></td>
                                        </tr>
                                        <?php 
            foreach ($bonusArr as $bonus) {
                ?>
                                            <tr>
                                                <td><?php 
                echo $bonus['bonusDate'];
                ?>
 </td>
                                                <td><?php 
                echo $mlm_settings['currency'] . ' ' . $bonus['amount'];
                ?>
</td>
                                            </tr>
                                        <?php 
            }
            ?>

                                    </table>
                                </td>
                            </tr>
                        <?php 
        }
        ?>

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


        <table width="100%" border="0" cellspacing="10" cellpadding="1" class="payout-summary">
            <tr>
                <td colspan="2"><strong><?php 
        _e('Payout Summary', 'binary-mlm-pro');
        ?>
</strong></td>
            </tr>
            <tr>
                <td width="50%"><?php 
        _e('Commission Amount', 'binary-mlm-pro');
        ?>
</td>
                <td width="50%" class="right"><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['commamount'];
        ?>
</td>
            </tr>
            <?php 
        if ($detailArr['dirrefommamount'] != 0.0) {
            ?>
                <tr>
                    <td width="50%"><?php 
            _e('Direct Referral Commission Amount', 'binary-mlm-pro');
            ?>
</td>
                    <td width="50%" class="right"><?php 
            echo $mlm_settings['currency'] . ' ' . $detailArr['dirrefommamount'];
            ?>
</td>
                </tr>
            <?php 
        }
        ?>
            <tr>
                <td width="50%"><?php 
        _e('Bonus Amount', 'binary-mlm-pro');
        ?>
</td>
                <td width="50%" class="right" ><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['bonusamount'];
        ?>
</td>
            </tr>
            <tr>
                <td width="50%"><?php 
        _e('Sub-Total', 'binary-mlm-pro');
        ?>
</td>
                <td width="50%" class="right"><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['total_amt'];
        ?>
</td>
            </tr>
            <?php 
        if ($detailArr['total_amt'] >= $detailArr['cap_limit'] && !empty($detailArr['cap_limit'])) {
            if ($detailArr['cap_limit'] == '0.00') {
            } else {
                ?>
                    <tr>
                        <td width="50%"><?php 
                _e('Cap Limt', 'binary-mlm-pro');
                ?>
</td>
                        <td width="50%" class="right"><?php 
                echo $mlm_settings['currency'] . ' ' . $detailArr['cap_limit'];
                ?>
</td>
                    </tr>
                    <?php 
            }
        }
        ?>
            <tr>
                <td width="50%"><?php 
        _e('Service Charge', 'binary-mlm-pro');
        ?>
</td>
                <td width="50%" class="right"><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['servicecharges'];
        ?>
</td>
            </tr>
            <tr>
                <td width="50%"><?php 
        _e('Tax', 'binary-mlm-pro');
        ?>
	</td>
                <td width="50%" class="right"><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['tax'];
        ?>
</td>
            </tr>
            <tr>
                <td width="50%"><strong><?php 
        _e('Net Amount', 'binary-mlm-pro');
        echo $detailArr['total_amt'] >= $detailArr['cap_limit'] && !empty($detailArr['cap_limit']) ? $detailArr['cap_limit'] == '0.00' ? '' : '(capped)' : '';
        ?>
</strong>	</td>
                <td width="50%" class="right"><strong><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['capped_amt'];
        ?>
</strong></td>
            </tr>
            <tr>
                <td colspan="2" class="right">
                    <div id="message" style="display:none;color:#0DA443;"><?php 
        _e('Your Withdrawal Request Initiated', 'binary-mlm-pro');
        ?>
</div>
                    <div id="status_message" style="display:none;color:#FF0000;Font-weight:bold;"><?php 
        _e('Withdrawal Pending', 'binary-mlm-pro');
        ?>
</div>
                    <?php 
        if ($statusArray[0]['payment_processed'] == '0' && $statusArray[0]['withdrawal_initiated'] == '1') {
            ?>
                        <div id="status_message_pending" style="color:#FF0000;Font-weight:bold;"><?php 
            _e('Withdrawal Pending', 'binary-mlm-pro');
            ?>
</div>
                        <?php 
        } else {
            if ($statusArray[0]['payment_processed'] == '1' && $statusArray[0]['withdrawal_initiated'] == '1') {
                ?>
                        <div id="status_message_processed" style="color:green;Font-weight:bold;"><?php 
                _e('Payment Processed', 'binary-mlm-pro');
                ?>
</div>
                        <a class='view-payment' id='<?php 
                _e($memberId);
                ?>
' href='javascript:void(0);'><?php 
                _e('View Payment Detail', 'binary-mlm-pro');
                ?>
</a>

                        <?php 
            } else {
                if ($statusArray[0]['payment_processed'] == '0' && $statusArray[0]['withdrawal_initiated'] == '0') {
                    ?>

                        <div id="comment_form">
                            <form name="contact" method="post" action="">
                                <fieldset>
                                    <table>
                                        <tr>
                                            <td style="border:none"><label for="name1" id="name_label"><b><?php 
                    _e('Comment, if any', 'binary-mlm-pro');
                    ?>
:</b>&nbsp;&nbsp;</label></td>
                                            <td style="border:none"><input type="text" name="name1" id="name1" size="30" value="" class="text-input"/>
                                                <input type="hidden" name="wint_id" id="memberid" value="<?php 
                    _e($memberId);
                    ?>
"/>
                                                <input type="hidden" name="pay_id" id="payoutid" value="<?php 
                    _e($payoutId);
                    ?>
"/>
                                                <input type="hidden" name="total_amt" id="total_amt" value="<?php 
                    _e($detailArr['capped_amt']);
                    ?>
" /></td>
                                        </tr>
                                        <tr><td style="border:none;"></td>
                                            <td style="border:none; text-align: left"><input type="submit" name="submit" class="button" style="margin:0px;float:left" id="submit_btn" value="<?php 
                    _e('Initiate withdrawal', 'binary-mlm-pro');
                    ?>
" /></td></tr>
                                    </table>



                                </fieldset>
                            </form>
                        </div>

                    <?php 
                }
            }
        }
        ?>

                </td>
            </tr>
            <div class='show-payment-detail' style="display:none;">
                <tr class='show-payment-detail' style="display:none;"><td colspan='2'><?php 
        _e(paymentDeatil($memberId, $payoutId));
        ?>
</td></tr></div>
        </table>

        <script type="text/javascript">



            jQuery(document).ready(function($) {
                $(".view-payment").click(function() {
                    $(".show-payment-detail").toggle();
                });
            });

            (function($) {
                $(".button").click(function() {
                    var name = $("input#name1").val();
                    var memberid = $('#memberid').val();
                    var payoutid = $('#payoutid').val();
                    var total_amt = $('#total_amt').val();
                    var dataString = 'name=' + name + '&wint_id=' + memberid + '&pay_id=' + payoutid + '&total_amt=' + total_amt;
                    if (confirm("<?php 
        _e('This would initiate a withdrawal for this payout. Would you like to proceed?', 'binary-mlm-pro');
        ?>
")) {
                        $.ajax({
                            type: "POST",
                            url: "<?php 
        _e($url);
        ?>
/binary-mlm-pro/mlm_html/delete_withdrawal.php",
                            data: dataString,
                            success: function() {
                                $('#comment_form').html("<div id='message'></div>");
                                $('#message').html("<h3 class='initiatedmsg'><?php 
        echo __('Your Withdrawal Request Initiated.', 'binary-mlm-pro');
        ?>
</h3>")
                                        .hide()
                                        .fadeIn(1500, function() {
                                            $('#message').append("<?php 
        echo __('Thanks for Patience.', 'binary-mlm-pro');
        ?>
");
                                        });
                            }
                        });
                        return false;
                    }
                });
            })(jQuery);
        </script>

        <?php 
    } else {
        _e("<div class='notfound'>It Seems some error. Please contact adminisistrator " . get_option('admin_email') . " for this issue.</div>");
    }
}
function mlm_my_payout_details_page($id = '')
{
    global $table_prefix;
    global $wpdb;
    global $date_format;
    $url = plugins_url();
    if ($id == '') {
        $detailArr = my_payout_details_function();
    } else {
        $detailArr = my_payout_details_function($id);
    }
    if (count($detailArr) > 0) {
        $memberId = $detailArr['memberId'];
        $payoutId = $detailArr['payoutId'];
        $comissionArr = getCommissionByPayoutId($memberId, $payoutId);
        $RegularbonusArr = getRegularBonusByPayoutId($memberId, $payoutId);
        $RoyaltybonusArr = getRoyaltyBonusByPayoutId($memberId, $payoutId);
        $mlm_settings = get_option('wp_mlm_general_settings');
        $comm_ssion = array('', 'Level', 'Refferral', 'Company', 'Left over');
        ?>
		<!--<script src="initiate.js" type="text/javascript"></script>-->
		<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 $detailArr['name'];
        ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
        _e('ID', 'unilevel-mlm-pro');
        ?>
</td>
					<td><?php 
        echo $detailArr['userKey'];
        ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
        _e('Payout ID', 'unilevel-mlm-pro');
        ?>
</td>
					<td><?php 
        echo $detailArr['payoutId'];
        ?>
</td>
				  </tr>
				  <tr>
					<td scope="row"><?php 
        _e('Date', 'unilevel-mlm-pro');
        ?>
</td>
					<td><?php 
        echo $detailArr['payoutDate'];
        ?>
</td>
				  </tr>
				</table>
			</td>
			<td width="40%">
				<table width="100%" border="0" cellspacing="10" cellpadding="1">
				  <tr>
					<td><strong><?php 
        _e('Payout Details', 'unilevel-mlm-pro');
        ?>
</strong></td>
				  </tr>
				   <tr>
					<td>
						<table width="100%" border="0" cellspacing="10" cellpadding="1">
							<tr>
								<td colspan="3"><strong><?php 
        _e('Commission', 'unilevel-mlm-pro');
        ?>
</strong></td>
							</tr>
							
							<tr>
								<td><?php 
        _e('User Name', 'unilevel-mlm-pro');
        ?>
</td>
								<td><?php 
        _e('Commission Type', 'unilevel-mlm-pro');
        ?>
</td>
								<td><?php 
        _e('Amount', 'unilevel-mlm-pro');
        ?>
</td>
							</tr>
							<?php 
        foreach ($comissionArr as $comm) {
            ?>
							
							<tr>
								<td><?php 
            echo getusernamebykey($comm['child_ids']);
            ?>
</td>
								<td><?php 
            echo $comm_ssion[$comm['comm_type']];
            ?>
</td>
								<td><?php 
            echo $mlm_settings['currency'] . ' ' . $comm['amount'];
            ?>
</td>
							</tr>
							
							<?php 
        }
        ?>
							
							
						</table>
                        
					</td>
				  </tr>
				   <?php 
        if (count($RegularbonusArr) > 0) {
            ?>
				   <tr>
					<td>
						<table width="100%" border="0" cellspacing="10" cellpadding="1">
							<tr>
								<td colspan="2"><strong><?php 
            _e('Regular Bonus', 'unilevel-mlm-pro');
            ?>
</strong></td>
							</tr>
							<?php 
            foreach ($RegularbonusArr as $bonus) {
                ?>
							<tr>
								<td><?php 
                echo $bonus['bonusDate'];
                ?>
 </td>
								<td><?php 
                echo $mlm_settings['currency'] . ' ' . $bonus['amount'];
                ?>
</td>
							</tr>
							<?php 
            }
            ?>
							
						</table>
					</td>
				  </tr>
				  <?php 
        }
        ?>
				  <?php 
        if (count($RoyaltybonusArr) > 0) {
            ?>
				   <tr>
					<td>
						<table width="100%" border="0" cellspacing="10" cellpadding="1">
							<tr>
								<td colspan="3"><strong><?php 
            _e('Royalty Bonus', 'unilevel-mlm-pro');
            ?>
</strong></td>
							</tr>
							<?php 
            foreach ($RoyaltybonusArr as $bonus) {
                ?>
							<tr>
								<td><?php 
                echo $bonus['bonusDate'];
                ?>
 </td>
								<td><?php 
                echo 'Level ' . $bonus['level'];
                ?>
 </td>
								<td><?php 
                echo $mlm_settings['currency'] . ' ' . $bonus['amount'];
                ?>
</td>
							</tr>
							<?php 
            }
            ?>
							
						</table>
					</td>
				  </tr>
				  <?php 
        }
        ?>
				</table>
			</td>
		  </tr>
		</table>
		
		
		<table width="100%" border="0" cellspacing="10" cellpadding="1" class="payout-summary">
			<tr>
				<td colspan="2"><strong><?php 
        _e('Payout Summary', 'unilevel-mlm-pro');
        ?>
</strong></td>
			</tr>
			<tr>
				<td width="50%"><?php 
        _e('Commission Amount', 'unilevel-mlm-pro');
        ?>
</td>
				<td width="50%" class="right"><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['commamount'];
        ?>
</td>
			</tr>
            
			<tr>
				<td width="50%"><?php 
        _e('Bonus Amount', 'unilevel-mlm-pro');
        ?>
</td>
				<td width="50%" class="right" ><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['bonusamount'];
        ?>
</td>
			</tr>
			<tr>
				<td width="50%"><?php 
        _e('Sub-Total', 'unilevel-mlm-pro');
        ?>
</td>
				<td width="50%" class="right"><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['subtotal'];
        ?>
</td>
			</tr>
			
			<tr>
				<td width="50%"><strong><?php 
        _e('Net Amount', 'unilevel-mlm-pro');
        if (!empty($cap)) {
            _e($cap);
        }
        ?>
</strong>	</td>
				<td width="50%" class="right"><strong><?php 
        echo $mlm_settings['currency'] . ' ' . $detailArr['netamount'];
        ?>
</strong></td>
			</tr>
			<tr>
				<td colspan="2" class="right">
				
				
				
				</td>
			</tr>
			<div class='show-payment-detail' style="display:none;">
			<tr class='show-payment-detail' style="display:none;"><td colspan='2'><?php 
        _e(paymentDeatil($memberId, $payoutId));
        ?>
</td></tr></div>
		</table>
		
		<script type="text/javascript">
			jQuery(document).ready(function ($){
				$(".view-payment").click( function(){
					$(".show-payment-detail").toggle();
				});
			});

			$(function(){
				$(".button").click(function() {
					var name = $("input#name").val();
					var memberid=$('#memberid').val();
					var payoutid=$('#payoutid').val();
					var dataString = 'name='+ name + '&wint_id=' + memberid + '&pay_id=' + payoutid;

					$.ajax({
						type: "POST",
						url: "<?php 
        _e($url);
        ?>
/unilevel-mlm-pro/mlm_html/delete_withdrawal.php",
						data: dataString,
						success: function() {
							$('#comment_form').html("<div id='message'></div>");
							$('#message').html("<h3 class='initiatedmsg'>Your Withdrawal Request Initiated.</h3>")
							.hide()
							.fadeIn(1500, function() {
								$('#message').append("<?php 
        __('Thanks for Patience.', 'unilevel-mlm-pro');
        ?>
");
							});
						}
					});
					return false;
				});
			});
		</script>
			
		<?php 
    } else {
        _e("<div class='notfound'>It Seems some error. Please contact adminisistrator " . get_option('admin_email') . " for this issue.</div>");
    }
}