function SendMailToAll($user_key, $parent_key, $sponsor)
{
    global $wpdb;
    $user_id = getUIDbyKey($user_key);
    $user_info = get_userdata($user_id);
    $parent_username = getusernamebykey($parent_key);
    $sponsor_username = getusernamebykey($sponsor);
    $siteownwer = get_bloginfo('name');
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html; charset=iso-8859-1" . "\r\n";
    $headers .= "From: " . get_option('admin_email') . "<" . get_option('admin_email') . ">" . "\r\n";
    $subject = get_option('networkgrowing_email_subject', true);
    $results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}mlm_leftleg where ukey='{$user_key}' UNION ALL  SELECT * FROM {$wpdb->prefix}mlm_rightleg  where ukey='{$user_key}'");
    foreach ($results as $value) {
        $pid = getUIDbyKey($value->pkey);
        $puser_info = get_userdata($pid);
        $pname = $puser_info->user_login;
        $pemail = $puser_info->user_email;
        $message = nl2br(htmlspecialchars(get_option('networkgrowing_email_message', true)));
        $message = str_replace('[pname]', $pname, $message);
        $message = str_replace('[firstname]', $user_info->first_name, $message);
        $message = str_replace('[lastname]', $user_info->last_name, $message);
        $message = str_replace('[email]', $user_info->user_email, $message);
        $message = str_replace('[username]', $user_info->user_login, $message);
        $message = str_replace('[sponsor]', $sponsor_username, $message);
        $message = str_replace('[parent]', $parent_username, $message);
        $message = str_replace('[sitename]', $siteownwer, $message);
        wp_mail($pemail, $subject, $message, $headers);
    }
}
 function prepare_items()
 {
     global $wpdb;
     global $table_prefix;
     global $date_format;
     $per_page = 30;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     //======== Search code
     $usersearch = isset($_REQUEST['search']) ? trim($_REQUEST['search']) : '';
     extract($_REQUEST);
     if (!isset($epin_status) && !isset($search) && !isset($epin_value)) {
         $sql = "SELECT * FROM {$table_prefix}mlm_epins ORDER BY id ASC";
     } else {
         if (isset($epin_status) && $epin_status != '' && isset($epin_value) && $epin_value != '' && !empty($search)) {
             $amt = $epin_value;
             $where = " WHERE status='" . $epin_status . "' AND  p_id='" . $amt . "' AND epin_no like '%" . trim($search) . "%'";
         } else {
             if (isset($epin_status) && $epin_status != '' && isset($epin_value) && $epin_value != '') {
                 $amt = $epin_value;
                 $where = " WHERE status='" . $epin_status . "' AND  p_id='" . $amt . "'";
             } else {
                 if (isset($epin_value) && $epin_value != '' && !empty($search)) {
                     $amt = $epin_value;
                     $where = " WHERE  p_id='" . $amt . "' AND epin_no like '%" . trim($search) . "%'";
                 } else {
                     if (isset($epin_status) && $epin_status != '' && !empty($search)) {
                         $where = " WHERE  status='" . $epin_status . "' AND epin_no like '%" . trim($search) . "%'";
                     } else {
                         if (isset($epin_status) && $epin_status != '') {
                             $where = " WHERE  status='" . $epin_status . "' ";
                         } else {
                             if (isset($epin_value) && $epin_value != '') {
                                 $amt = $epin_value;
                                 $where = " WHERE  p_id='" . $amt . "' ";
                             } else {
                                 if (!empty($search)) {
                                     $where = " WHERE  epin_no like '%" . trim($search) . "%' ";
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $sql = "SELECT * FROM {$table_prefix}mlm_epins  {$where}  ORDER BY id ASC";
     }
     $this->_column_headers = array($columns, $hidden, $sortable);
     $rs = mysql_query($sql);
     $i = 0;
     //$ID = 1;
     $listArr = array();
     if (mysql_num_rows($rs) > 0) {
         while ($row = mysql_fetch_array($rs)) {
             $user_id = getuseruidbykey($row['user_key']);
             $firstname = get_user_meta($user_id, 'first_name', true);
             $lastname = get_user_meta($user_id, 'last_name', true);
             $genaral_date = get_option('links_updated_date_format');
             if ($row['date_used'] == '0000-00-00 00:00:00') {
                 $used_date = '';
             } else {
                 $used_date = date("{$genaral_date}", strtotime($row['date_used']));
             }
             if ($row['date_generated'] == '0000-00-00 00:00:00') {
                 $genarated_on = '';
             } else {
                 $genarated_on = date("{$genaral_date}", strtotime($row['date_generated']));
             }
             $price = $wpdb->get_var("select product_price from {$table_prefix}mlm_product_price where p_id='" . $row['p_id'] . "'");
             $type = $row['point_status'] == '1' ? 'Regular' : 'Free';
             $listArr[$i]['epin'] = $row['epin_no'];
             $listArr[$i]['epinprice'] = $price;
             $listArr[$i]['username'] = getusernamebykey($row['user_key']);
             $listArr[$i]['firstname'] = $firstname;
             $listArr[$i]['lastname'] = $lastname;
             $listArr[$i]['type'] = $type;
             $listArr[$i]['genarated_on'] = $genarated_on;
             $listArr[$i]['date_used'] = $used_date;
             $i++;
         }
     }
     /*if(!empty($usersearch)){ 
     		
     		extract($_REQUEST);
     		$epin_status=isset($epin_status) &&!empty($epin_status)? " AND status='$epin_status'":"";
     		$this->_column_headers = array($columns, $hidden, $sortable); 
                     
                     
                      if(isset($epin_value) && ($epin_value!=''))
                     {
                         
                             $amount=10000*$epin_value;
                             $epin_status.=" AND epin_price=$amount";
                                          
                         
                     }
                     
                     
     		$sql = "SELECT * FROM {$table_prefix}mlm_epins 
     		where epin_no like '%$usersearch%' $epin_status"; 
     		
     		$rs = mysql_query($sql);
     		$listArr = array(); 
     		if(mysql_num_rows($rs)>0){
                 $i=0;
     		 	while($row = mysql_fetch_array($rs)){ 
                     $user_id=empty($row['user_key'])?'':getuseruidbykey($row['user_key']);
     				$firstname=empty($user_id)?'':get_user_meta($user_id, 'first_name', true);
     				$lastname=empty($user_id)?'':get_user_meta($user_id, 'last_name', true);
     				$genaral_date=get_option('links_updated_date_format');
     				
     				if($row['date_used']=='0000-00-00 00:00:00')
     				{
     				$used_date='';
     				}
     				else
     				{
     					$used_date=date("$genaral_date",strtotime($row['date_used']));
     				}
     				
     				if($row['date_generated']=='0000-00-00 00:00:00')
     				{
     				$genarated_on='';
     				}
     				else
     				{
     					$genarated_on=date("$genaral_date",strtotime($row['date_generated']));
     				}
     			$type=$row['point_status']=='1'?'Regular':'Free';
     			$listArr[$i]['epin'] = $row['epin_no'];
                             $listArr[$i]['epinprice'] = $row['epin_price']; 
     			$listArr[$i]['username'] = getusernamebykey($row['user_key']); 
     			$listArr[$i]['firstname'] = $firstname; 
     			$listArr[$i]['lastname'] = $lastname;
                             $listArr[$i]['type'] = $type;
     			$listArr[$i]['genarated_on'] = $genarated_on; 
     			$listArr[$i]['date_used'] = $used_date; 
     			$i++;	
     			}
     		}}
             else { 	//=search code end
             $this->_column_headers = array($columns, $hidden, $sortable);
            
     		extract($_REQUEST);
     
     		if(isset($epin_status) && !empty($epin_status))
     		{      if($epin_status==1 || $epin_status==0)
     			$status=" WHERE status=$epin_status";
     		}
     		else
     		{
     		$status="";
     		}
     		
                     if(isset($epin_value) && ($epin_value!=''))
                     {
                         if($status!='')
                         {
                             $amount=10000*$epin_value;
                           
                           $status.= " AND epin_price=$amount";
                             
                         }
                         else {
                             $amount=10000*$epin_value;
                             $status=" WHERE epin_price=$amount";
                         }
                         
                         
                     }
                     
                     
     		 $sql = "SELECT * FROM {$table_prefix}mlm_epins  $status ORDER BY id ASC";
     		
     		$rs = mysql_query($sql);
     		$i = 0; 
     		//$ID = 1;
     		
     		$listArr = array(); 
     		if(mysql_num_rows($rs)>0){
     			
     		 	while($row = mysql_fetch_array($rs))
     			{
     				$user_id=getuseruidbykey($row['user_key']);
     				$firstname=get_user_meta($user_id, 'first_name', true);
     				$lastname=get_user_meta($user_id, 'last_name', true);
     				$genaral_date=get_option('links_updated_date_format');
     				
     				if($row['date_used']=='0000-00-00 00:00:00')
     				{
     				$used_date='';
     				}
     				else
     				{
     					$used_date=date("$genaral_date",strtotime($row['date_used']));
     				}
     				
     				if($row['date_generated']=='0000-00-00 00:00:00')
     				{
     				$genarated_on='';
     				}
     				else
     				{
     					$genarated_on=date("$genaral_date",strtotime($row['date_generated']));
     				}
     				
     			$type=$row['point_status']=='1'?'Regular':'Free';
     			$listArr[$i]['epin'] = $row['epin_no']; 
                             $listArr[$i]['epinprice'] = $row['epin_price'];
     			$listArr[$i]['username'] = getusernamebykey($row['user_key']); 
     			$listArr[$i]['firstname'] = $firstname; 
     			$listArr[$i]['lastname'] = $lastname;
                             $listArr[$i]['type'] = $type;
     			$listArr[$i]['genarated_on'] = $genarated_on; 
     			$listArr[$i]['date_used'] = $used_date; 
     			$i++;
     			
     			}
     		}
             }*/
     $data = $listArr;
     /* function usort_reorder($a,$b){
            $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'id'; 
            $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'DESC'; 
            $result = strcmp($a[$orderby], $b[$orderby]); 
            return ($order==='ASC') ? $result : -$result; 
        }
        usort($data, 'usort_reorder');
        */
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->items = $data;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
Exemplo n.º 3
0
function join_network_page()
{
    global $wpdb, $current_user;
    $user_id = $current_user->ID;
    $table_prefix = mlm_core_get_table_prefix();
    $error = '';
    $chk = 'error';
    global $current_user;
    get_currentuserinfo();
    if (!empty($_GET['sp_name'])) {
        $sp_name = $_GET['sp_name'];
        ?>
        <script>$.cookie('s_name', '<?php 
        echo $sp_name;
        ?>
', {path: '/'});</script>

        <?php 
        //setcookie("s_name", $sp_name);
    } else {
        if (!empty($_GET['sp'])) {
            $sp_name = getusernamebykey($_GET['sp']);
            ?>
        <script>$.cookie('s_name', '<?php 
            echo $sp_name;
            ?>
', {path: '/'});</script>

        <?php 
        } else {
            $sp_name = $_COOKIE["s_name"];
        }
    }
    /*     * ****date format ***** */
    $date_format = get_option('date_format');
    $time_format = get_option('time_format');
    /*     * ****** end******* */
    $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');
    $mlm_method = get_option('wp_mlm_payment_method');
    if (isset($_REQUEST['sp_name']) && $_REQUEST['sp_name'] != '') {
        //$sponsorName = getusernamebykey($_REQUEST['sp']);
        $sponsorName = $_REQUEST['sp_name'];
        if (isset($sponsorName) && $sponsorName != '') {
            $readonly_sponsor = 'readonly';
            $sponsor_name = $sponsorName;
        }
    } else {
        if (isset($_COOKIE["s_name"]) && $_COOKIE["s_name"] != '') {
            $readonly_sponsor = 'readonly';
            $sponsor_name = $_COOKIE["s_name"];
        } else {
            if (isset($_REQUEST['sp']) && $_REQUEST['sp'] != '') {
                //$sponsorName = getusernamebykey($_REQUEST['sp']);
                $sponsorName = getusernamebykey($_REQUEST['sp']);
                if (isset($sponsorName) && $sponsorName != '') {
                    $readonly_sponsor = 'readonly';
                    $sponsor_name = $sponsorName;
                }
            } else {
                $readonly_sponsor = '';
            }
        }
    }
    //most outer if condition
    if (isset($_POST['submit'])) {
        $sponsor = sanitize_text_field($_POST['sponsor']);
        if (empty($sponsor)) {
            $sponsor = $wpdb->get_var("select `username` FROM {$table_prefix}mlm_users order by id asc limit 1");
        }
        $firstname = sanitize_text_field($_POST['firstname']);
        $lastname = sanitize_text_field($_POST['lastname']);
        $email = sanitize_text_field($_POST['email']);
        /*         * ***** check for the epin field ***** */
        if (isset($_POST['epin']) && !empty($_POST['epin'])) {
            $epin = sanitize_text_field($_POST['epin']);
        } else {
            if (isset($_POST['epin']) && empty($_POST['epin'])) {
                $epin = '';
            }
        }
        /*         * ***** check for the epin field ***** */
        /* $address1 = sanitize_text_field( $_POST['address1'] );
                  $address2 = sanitize_text_field( $_POST['address2'] );
        
                  $city = sanitize_text_field( $_POST['city'] );
                  $state = sanitize_text_field( $_POST['state'] );
                  $postalcode = sanitize_text_field( $_POST['postalcode'] );
                  $telephone = sanitize_text_field( $_POST['telephone'] );
                  $dob = sanitize_text_field( $_POST['dob'] ); */
        //Add usernames we don't want used
        $invalid_usernames = array('admin');
        //Do username validation
        $sql = "SELECT COUNT(*) num, `user_key` \n\t\t\t\tFROM {$table_prefix}mlm_users \n\t\t\t\tWHERE `username` = '" . $sponsor . "'";
        //Case If User is not fill the Sponser field
        $intro = $wpdb->get_row($sql);
        if (checkInputField($firstname)) {
            $error .= "\n Please enter your first name.";
        }
        if (checkInputField($lastname)) {
            $error .= "\n Please enter your last name.";
        }
        if (checkInputField($email)) {
            $error .= "\n Please enter your email address.";
        }
        /*         * ***** check for the epin field ***** */
        if (isset($epin) && !empty($epin)) {
            if (epin_exists($epin)) {
                $error .= "\n ePin already issued or wrong ePin.";
            }
        }
        if ($mlm_general_settings['sol_payment'] == 1) {
            if (isset($_POST['epin']) && empty($_POST['epin'])) {
                $error .= "\n Please enter your ePin.";
            }
        }
        /*         * ***** check for the epin field ***** */
        /* if ( checkInputField($address1) ) 
                  $error .= "\n Please enter your address.";
        
                  if ( checkInputField($city) )
                  $error .= "\n Please enter your city.";
        
                  if ( checkInputField($state) )
                  $error .= "\n Please enter your state.";
        
                  if ( checkInputField($postalcode) )
                  $error .= "\n Please enter your postal code.";
        
                  if ( checkInputField($telephone) )
                  $error .= "\n Please enter your contact number.";
        
                  if ( checkInputField($dob) )
                  $error .= "\n Please enter your date of birth."; */
        //generate random numeric key for new user registration
        $user_key = generateKey();
        //if generated key is already exist in the DB then again re-generate key
        do {
            $check = $wpdb->get_var("SELECT COUNT(*) ck \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$table_prefix}mlm_users \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_key` = '" . $user_key . "'");
            $flag = 1;
            if ($check == 1) {
                $user_key = generateKey();
                $flag = 0;
            }
        } while ($flag == 0);
        // outer if condition
        if (empty($error)) {
            // inner if condition
            if ($intro->num == 1) {
                $sponsor = $intro->user_key;
                $parent_key = $sponsor;
                // return the wp_users table inserted user's ID
                wp_update_user(array('ID' => $user_id, 'role' => 'mlm_user'));
                $username = $current_user->user_login;
                //get the selected country name from the country table
                $country = $_POST['country'];
                $sql = "SELECT name \n\t\t\t\t\t\tFROM {$table_prefix}mlm_country\n\t\t\t\t\t\tWHERE id = '" . $country . "'";
                $country1 = $wpdb->get_var($sql);
                //insert the registration form data into user_meta table
                $user = array('ID' => $user_id, 'first_name' => $firstname, 'last_name' => $lastname, 'user_email' => $email, 'role' => 'mlm_user');
                // return the wp_users table inserted user's ID
                $user_id = wp_update_user($user);
                /* add_user_meta( $user_id, 'user_address1', $address1, FALSE );  
                   add_user_meta( $user_id, 'user_address2', $address2, FALSE );
                   add_user_meta( $user_id, 'user_city', $city, FALSE );
                   add_user_meta( $user_id, 'user_state', $state, FALSE );
                   add_user_meta( $user_id, 'user_country', $country1, FALSE );
                   add_user_meta( $user_id, 'user_postalcode', $postalcode, FALSE );
                   add_user_meta( $user_id, 'user_telephone', $telephone, FALSE );
                   add_user_meta( $user_id, 'user_dob', $dob, FALSE); */
                //get the selected country name from the country table
                if (!empty($epin)) {
                    $pointResult = mysql_query("select point_status from {$table_prefix}mlm_epins where epin_no = '{$epin}'");
                    $pointStatus = mysql_fetch_row($pointResult);
                    // to epin point status 1
                    if ($pointStatus[0] == '1') {
                        $paymentStatus = '1';
                    } else {
                        if ($pointStatus[0] == '0') {
                            $paymentStatus = '2';
                        }
                    }
                } else {
                    // to non epin
                    $paymentStatus = '0';
                }
                //insert the data into fa_user table
                $insert = "INSERT INTO {$table_prefix}mlm_users\n\t\t\t\t\t\t   (\n\t\t\t\t\t\t\t\tuser_id, username, user_key, parent_key, sponsor_key, payment_status\n\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t'" . $user_id . "','" . $username . "', '" . $user_key . "', '" . $parent_key . "', '" . $sponsor . "','" . $paymentStatus . "'\n\t\t\t\t\t\t\t)";
                $wpdb->query($insert);
                //hierarchy code for genology
                InsertHierarchy($user_key, $sponsor);
                if (isset($epin) && !empty($epin)) {
                    $sql = "update {$table_prefix}mlm_epins set user_key='{$user_key}', date_used=now(), status=1 where epin_no ='{$epin}' ";
                    // Update epin according user_key (19-07-2013)
                    mysql_query($sql);
                    if ($paymentStatus == 1) {
                        UserStatusUpdate($user_id);
                    }
                }
                $chk = '';
                $msg = "<span style='color:green;'>Congratulations! You have successfully Join MLM</span>";
                $check_paid = $wpdb->get_var("SELECT payment_status FROM {$table_prefix}mlm_users WHERE user_id = '" . $user_id . "'");
                if ($check_paid == '0') {
                    PayNowOptions($user_id, 'join_net');
                }
            } else {
                $error = "\n Sponsor does not exist in the system.";
            }
        }
        //end inner if condition
    }
    //end outer if condition
    // }
    //if any error occoured
    if (!empty($error)) {
        $error = nl2br($error);
    }
    if ($chk != '') {
        //include 'js-validation-file.html';
        ?>
        <script type="text/javascript">
            var popup1, popup2, splofferpopup1;
            var bas_cal, dp_cal1, dp_cal2, ms_cal; // declare the calendars as global variables 
            window.onload = function() {
                dp_cal1 = new Epoch('dp_cal1', 'popup', document.getElementById('dob'));
            };

            function checkReferrerAvailability(str)
            {
                if (isSpclChar(str, 'sponsor') == false)
                {
                    document.getElementById('sponsor').focus();
                    return false;
                }
                var xmlhttp;

                if (str != "") {

                    if (window.XMLHttpRequest)
                    {// code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp = new XMLHttpRequest();
                    }
                    else
                    {// code for IE6, IE5
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    xmlhttp.onreadystatechange = function()
                    {
                        if (xmlhttp.status == 200 && xmlhttp.readyState == 4)
                        {
                            document.getElementById("check_referrer").innerHTML = xmlhttp.responseText;
                        }
                    }
                    xmlhttp.open("GET", "<?php 
        echo MLM_PLUGIN_URL . 'ajax/check_username.php';
        ?>
" + "?action=sponsor&q=" + str, true);
                    xmlhttp.send();

                }
            }
        </script>		

        <?php 
        if ($current_user->roles[0] == 'mlm_user') {
            echo "Your are already a MLM user";
        } else {
            $fname = get_user_meta($user_id, 'first_name', true);
            $lname = get_user_meta($user_id, 'last_name', true);
            $u_email = $current_user->user_email;
            ?>
            <span style='color:red;'><?php 
            echo $error;
            ?>
</span>
            <?php 
            if (isset($msg) && $msg != "") {
                echo $msg;
            }
            ?>
	
            <form name="frm" method="post" action="" onSubmit="return JoinNetworkformValidation();">
                <table border="0" cellpadding="0" cellspacing="0" width="100%">


                    <tr><td colspan="2">&nbsp;</td></tr>

                    <tr>
                        <td><?php 
            _e('First Name', 'unilevel-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><input type="text" name="firstname" id="firstname" value="<?php 
            if (!empty($fname)) {
                _e(htmlentities($fname));
            } elseif (!empty($_POST['firstname'])) {
                _e(htmlentities($_POST['firstname']));
            }
            ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'firstname');" ></td>
                    </tr>

                    <tr><td colspan="2">&nbsp;</td></tr>

                    <tr>
                        <td><?php 
            _e('Last Name', 'unilevel-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><input type="text" name="lastname" id="lastname" value="<?php 
            if (!empty($lname)) {
                _e(htmlentities($lname));
            } elseif (!empty($_POST['lastname'])) {
                _e(htmlentities($_POST['lastname']));
            }
            ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'lastname');"></td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>


                    <tr>
                        <td><?php 
            _e('Email', 'unilevel-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><input type="text" name="email" id="email" value="<?php 
            if (!empty($u_email)) {
                _e(htmlentities($u_email));
            } elseif (!empty($_POST['email'])) {
                _e(htmlentities($_POST['email']));
            }
            ?>
"  size="37" ></td>
                    </tr>

                    <tr><td colspan="2">&nbsp;</td></tr>

                    <tr>
            <?php 
            if (isset($sponsor_name) && $sponsor_name != '') {
                $spon = $sponsor_name;
            } else {
                if (isset($_POST['sponsor'])) {
                    $spon = htmlentities($_POST['sponsor']);
                }
            }
            ?>
                        <td><?php 
            _e('Sponsor Name', 'unilevel-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td>
                            <input type="text" name="sponsor" id="sponsor" value="<?php 
            if (!empty($spon)) {
                _e($spon);
            }
            ?>
" maxlength="20" size="37" onBlur="checkReferrerAvailability(this.value);" <?php 
            echo $readonly_sponsor;
            ?>
>
                            <br /><div id="check_referrer"></div>
                        </td>
                    </tr>
            <?php 
            if (isset($mlm_general_settings['ePin_activate']) && $mlm_general_settings['ePin_activate'] == '1' && isset($mlm_general_settings['sol_payment']) && $mlm_general_settings['sol_payment'] == '1') {
                ?>
                        <tr><td colspan="2">&nbsp;</td></tr>
                        <tr>
                            <td><?php 
                _e('Enter ePin', 'unilevel-mlm-pro');
                ?>
<span style="color:red;">*</span> :</td>
                            <td><input type="text" name="epin" id="epin" value="<?php 
                if (!empty($_POST['epin'])) {
                    _e(htmlentities($_POST['epin']));
                }
                ?>
" maxlength="20" size="37" onBlur="checkePinAvailability(this.value);"><br /><div id="check_epin"></div></td>
                        </tr>
            <?php 
            } else {
                if (isset($mlm_general_settings['ePin_activate']) && $mlm_general_settings['ePin_activate'] == '1') {
                    ?>
                        <tr><td colspan="2">&nbsp;</td></tr>
                        <tr>
                            <td><?php 
                    _e('Enter ePin', 'unilevel-mlm-pro');
                    ?>
 :</td>
                            <td><input type="text" name="epin" id="epin" value="<?php 
                    if (!empty($_POST['epin'])) {
                        _e(htmlentities($_POST['epin']));
                    }
                    ?>
" maxlength="20" size="37" onBlur="checkePinAvailability1(this.value);"><br /><div id="check_epin"></div></td>
                        </tr>
            <?php 
                }
            }
            ?>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td colspan="2"><input type="submit" name="submit" id="submit" value="<?php 
            _e('Submit', 'unilevel-mlm-pro');
            ?>
" /></td>
                    </tr>
                </table>
            </form>
            <?php 
        }
    } else {
        _e($msg);
    }
}
function register_user_html_page()
{
    global $wpdb;
    $table_prefix = mlm_core_get_table_prefix();
    $error = '';
    $chk = 'error';
    global $current_user;
    get_currentuserinfo();
    $user_roles = $current_user->roles;
    $user_role = array_shift($user_roles);
    if (!empty($_GET['sp_name'])) {
        $sp_name = $_GET['sp_name'];
        ?>
		 <script>$.cookie('s_name','<?php 
        echo $sp_name;
        ?>
',{ path: '/' });</script>
	       
	       <?php 
        //setcookie("s_name", $sp_name);
    } else {
        if (!empty($_GET['sp'])) {
            $sp_name = getusernamebykey($_GET['sp']);
            ?>
		 <script>$.cookie('s_name','<?php 
            echo $sp_name;
            ?>
',{ path: '/' });</script>
	       
	       <?php 
        } else {
            $sp_name = $_COOKIE["s_name"];
        }
    }
    //echo $_COOKIE["s_name"]."hello";
    //get no. of level
    $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');
    $mlm_method = get_option('wp_mlm_payment_method');
    if (is_user_logged_in()) {
        $sponsor_name = $current_user->user_login;
        $readonly_sponsor = 'readonly';
        $spnsr_set = 1;
    } else {
        if (isset($_REQUEST['sp_name']) && $_REQUEST['sp_name'] != '') {
            //$sponsorName = getusernamebykey($_REQUEST['sp']);
            $sponsorName = $_REQUEST['sp_name'];
            if (isset($sponsorName) && $sponsorName != '') {
                $readonly_sponsor = 'readonly';
                $sponsor_name = $sponsorName;
            } else {
                redirectPage(home_url(), array());
                exit;
            }
        } else {
            if (isset($_COOKIE["s_name"]) && $_COOKIE["s_name"] != '') {
                $readonly_sponsor = 'readonly';
                $sponsor_name = $_COOKIE["s_name"];
            } else {
                if (isset($_REQUEST['sp']) && $_REQUEST['sp'] != '') {
                    //$sponsorName = getusernamebykey($_REQUEST['sp']);
                    $sponsorName = getusernamebykey($_REQUEST['sp']);
                    if (isset($sponsorName) && $sponsorName != '') {
                        $readonly_sponsor = 'readonly';
                        $sponsor_name = $sponsorName;
                    } else {
                        redirectPage(home_url(), array());
                        exit;
                    }
                } else {
                    // $sponsor_name = get_top_level_user();
                    //$readonly_sponsor = 'readonly';
                    $readonly_sponsor = '';
                }
            }
        }
    }
    //most outer if condition
    if (isset($_POST['submit'])) {
        $firstname = sanitize_text_field($_POST['firstname']);
        $lastname = sanitize_text_field($_POST['lastname']);
        $username = sanitize_text_field($_POST['username']);
        /******* check for the epin field ******/
        if (isset($_POST['epin']) && !empty($_POST['epin'])) {
            $epin = sanitize_text_field($_POST['epin']);
        } else {
            if (isset($_POST['epin']) && empty($_POST['epin'])) {
                $epin = '';
            }
        }
        /******* check for the epin field ******/
        $password = sanitize_text_field($_POST['password']);
        $confirm_pass = sanitize_text_field($_POST['confirm_password']);
        $email = sanitize_text_field($_POST['email']);
        $confirm_email = sanitize_text_field($_POST['confirm_email']);
        $sponsor = sanitize_text_field($_POST['sponsor']);
        /*$address1 = sanitize_text_field( $_POST['address1'] );
        		$address2 = sanitize_text_field( $_POST['address2'] );
        		city = sanitize_text_field( $_POST['city'] );
        		$state = sanitize_text_field( $_POST['state'] );
        		$postalcode = sanitize_text_field( $_POST['postalcode'] );
        		$telephone = sanitize_text_field( $_POST['telephone'] );
        		$dob = sanitize_text_field( $_POST['dob'] );*/
        //Add usernames we don't want used
        $invalid_usernames = array('admin');
        //Do username validation
        $username = sanitize_user($username);
        if (!validate_username($username) || in_array($username, $invalid_usernames)) {
            $error .= "\n Username is invalid.";
        }
        if (username_exists($username)) {
            $error .= "\n Username already exists.";
        }
        /******* check for the epin field ******/
        if (!empty($epin) && epin_exists($epin)) {
            $error .= "\n ePin already issued or wrong ePin.";
        }
        if (!empty($mlm_general_settings['sol_payment']) && empty($epin)) {
            $error .= "\n Please enter your ePin.";
        } else {
            if (empty($_POST['epin_value']) && empty($epin)) {
                $error .= "\n Please either enter the ePin or select the Product.";
            }
        }
        /******* check for the epin field ******/
        if (checkInputField($password)) {
            $error .= "\n Please enter your password.";
        }
        if (confirmPassword($password, $confirm_pass)) {
            $error .= "\n Please confirm your password.";
        }
        //Do e-mail address validation
        if (!is_email($email)) {
            $error .= "\n E-mail address is invalid.";
        }
        if (email_exists($email)) {
            $error .= "\n E-mail address is already in use.";
        }
        if (confirmEmail($email, $confirm_email)) {
            $error .= "\n Please confirm your email address.";
        }
        if (checkInputField($firstname)) {
            $error .= "\n Please enter your first name.";
        }
        if (checkInputField($lastname)) {
            $error .= "\n Please enter your last name.";
        }
        if (checkInputField($sponsor) && !empty($sponsor)) {
            $error .= "\n Please enter your sponsor name.";
        }
        if (is_plugin_active('mlm-paypal-mass-pay/load-data.php')) {
            $paypalId = sanitize_text_field($_POST['paypal_id']);
            if (checkInputField($paypalId)) {
                $error .= "\n Please enter your Paypal id.";
            }
        }
        /*if ( checkInputField($address1) ) 
        			$error .= "\n Please enter your address.";
        			
        		if ( checkInputField($city) ) 
        			$error .= "\n Please enter your city.";
        			
        		if ( checkInputField($state) ) 
        			$error .= "\n Please enter your state.";
        			
        		if ( checkInputField($postalcode) ) 
        			$error .= "\n Please enter your postal code.";
        			
        		if ( checkInputField($telephone) ) 
        			$error .= "\n Please enter your contact number.";
        
        		if ( checkInputField($dob) ) 
        			$error .= "\n Please enter your date of birth.";*/
        //Case If User is not fill the Sponser field
        if (empty($_POST['sponsor'])) {
            $sponsor = get_top_level_user();
        }
        $sql = "SELECT COUNT(*) num, `user_key` \n\t\t\t\tFROM {$table_prefix}mlm_users \n\t\t\t\tWHERE `username` = '" . $sponsor . "'";
        $intro = $wpdb->get_row($sql);
        //generate random numeric key for new user registration
        $user_key = generateKey();
        //if generated key is already exist in the DB then again re-generate key
        do {
            $check = $wpdb->get_var("SELECT COUNT(*) ck \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$table_prefix}mlm_users \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_key` = '" . $user_key . "'");
            $flag = 1;
            if ($check == 1) {
                $user_key = generateKey();
                $flag = 0;
            }
        } while ($flag == 0);
        // outer if condition
        if (empty($error)) {
            // inner if condition
            if ($intro->num == 1) {
                $sponsor = $intro->user_key;
                $sponsor1 = $sponsor;
                //find parent key
                if (!empty($_GET['k']) && $_GET['k'] != '') {
                    $parent_key = $_GET['k'];
                } else {
                    $readonly_sponsor = '';
                    $parent_key = $sponsor;
                }
                $user = array('user_login' => $username, 'user_pass' => $password, 'first_name' => $firstname, 'last_name' => $lastname, 'user_email' => $email, 'role' => 'mlm_user');
                // return the wp_users table inserted user's ID
                $user_id = wp_insert_user($user);
                //get the selected country name from the country table
                $country = $_POST['country'];
                $sql = "SELECT name \n\t\t\t\t\t\tFROM {$table_prefix}mlm_country\n\t\t\t\t\t\tWHERE id = '" . $country . "'";
                $country1 = $wpdb->get_var($sql);
                //insert the registration form data into user_meta table
                /*add_user_meta( $user_id, 'user_address1', $address1, FALSE ); 
                		add_user_meta( $user_id, 'user_address2', $address2, FALSE );
                		add_user_meta( $user_id, 'user_city', $city, FALSE );
                		add_user_meta( $user_id, 'user_state', $state, FALSE );
                		add_user_meta( $user_id, 'user_country', $country1, FALSE );
                		add_user_meta( $user_id, 'user_postalcode', $postalcode, FALSE );
                		add_user_meta( $user_id, 'user_telephone', $telephone, FALSE );
                		add_user_meta( $user_id, 'user_dob', $dob, FALSE);*/
                /*Send e-mail to admin and new user - 
                		You could create your own e-mail instead of using this function*/
                wp_new_user_notification($user_id, $password);
                if (!empty($epin)) {
                    $pointResult = $wpdb->get_row("select p_id,point_status from {$table_prefix}mlm_epins where epin_no = '{$epin}'");
                    $pointStatus = $pointResult->point_status;
                    $productPrice = $wpdb->get_var("SELECT product_price FROM {$table_prefix}mlm_product_price WHERE p_id = '" . $pointResult->p_id . "'");
                    // to epin point status 1
                    if ($pointStatus[0] == '1') {
                        $paymentStatus = '1';
                    } else {
                        if ($pointStatus[0] == '0') {
                            $paymentStatus = '2';
                        }
                    }
                } else {
                    if (!empty($_POST['epin_value'])) {
                        $productPrice = $wpdb->get_var("SELECT product_price FROM {$table_prefix}mlm_product_price WHERE p_id = '" . $_POST['epin_value'] . "'");
                        $paymentStatus = '0';
                    } else {
                        // to non epin
                        $paymentStatus = '0';
                    }
                }
                //insert the data into fa_user table
                $insert = "INSERT INTO {$table_prefix}mlm_users\n\t\t\t\t\t\t   (\n\t\t\t\t\t\t\t\tuser_id, username, user_key, parent_key, sponsor_key, payment_status, product_price\n\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t'" . $user_id . "','" . $username . "', '" . $user_key . "', '" . $parent_key . "', '" . $sponsor . "','" . $paymentStatus . "','" . $productPrice . "'\n\t\t\t\t\t\t\t)";
                $wpdb->query($insert);
                //hierarchy code for genology
                InsertHierarchy($user_key, $sponsor);
                if (isset($epin) && !empty($epin)) {
                    $sql = "update {$table_prefix}mlm_epins set user_key='{$user_key}', date_used=now(), status=1 where epin_no ='{$epin}' ";
                    // Update epin according user_key (19-07-2013)
                    mysql_query($sql);
                    if ($paymentStatus == 1) {
                        UserStatusUpdate($user_id);
                    }
                }
                if (is_plugin_active('mlm-paypal-mass-pay/load-data.php')) {
                    update_user_meta($user_id, 'mlm_user_paypalid', $paypalId, FALSE);
                }
                $chk = '';
                $msg = "<span style='color:green;'>Congratulations! You have successfully registered in the system.</span>";
                $check_paid = $wpdb->get_var("SELECT payment_status FROM {$table_prefix}mlm_users WHERE user_id = '" . $user_id . "'");
                if ($check_paid == '0') {
                    PayNowOptions($user_id, 'register_user');
                }
            } else {
                $error = "\n Sponsor does not exist in the system.";
            }
        }
        //end outer if condition
    }
    //end most outer if condition
    //if any error occoured
    if (!empty($error)) {
        $error = nl2br($error);
    }
    if ($chk != '') {
        ?>

 
<script type="text/javascript">
var popup1,popup2,splofferpopup1;
var bas_cal, dp_cal1,dp_cal2, ms_cal; // declare the calendars as global variables 
window.onload = function() {
	dp_cal1 = new Epoch('dp_cal1','popup',document.getElementById('dob'));  
};

function checkUserNameAvailability(str)
{
	//alert(url); return true; 
		
	if(isSpclChar(str, 'username')==false)
	{
		document.getElementById('username').focus();
		return false;
	}
	var xmlhttp;    
	if (str!="")
  	{
	
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	if (xmlhttp.status==200 && xmlhttp.readyState==4)
	{
	 document.getElementById("check_user").innerHTML=xmlhttp.responseText;
	 //alert(xmlhttp.responseText);
	}
	}   
	
	xmlhttp.open("GET", "<?php 
        echo MLM_PLUGIN_URL . 'ajax/check_username.php';
        ?>
"+"?action=username&q="+str,true);
	xmlhttp.send();
     }

}


function checkReferrerAvailability(str)
{ 
	if(isSpclChar(str, 'sponsor')==false)
	{
		document.getElementById('sponsor').focus();
		return false;
	}
	var xmlhttp;    
	
	if (str!="") {
	
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	if (xmlhttp.status==200 && xmlhttp.readyState==4)
	{
	 document.getElementById("check_referrer").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET", "<?php 
        echo MLM_PLUGIN_URL . 'ajax/check_username.php';
        ?>
"+"?action=sponsor&q="+str,true);
	xmlhttp.send();

	}
}

function checkePinAvailability(str)
{
	var iChars = "~`!@#$%^&*()+=[]\\\';,- ./{}|\":<>?abcdefghijklmnopqrstuvwxyz";
	for (var i = 0; i < str.length; i++)
	{
    	if (iChars.indexOf(str.charAt(i)) != -1) 
		{
    		alert("<?php 
        _e('Please enter Valid ePin.', 'unilevel-mlm-pro');
        ?>
");
			document.getElementById('epin').value='';
			document.getElementById('epin').focus();
    		return false;
        }
    }
	
	var xmlhttp;    
			if (str!="")
  	{
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	if (xmlhttp.status==200 && xmlhttp.readyState==4)
	{
		document.getElementById("check_epin").innerHTML=xmlhttp.responseText;
	 //alert(xmlhttp.responseText);
	}
	}   
	
	xmlhttp.open("GET", "<?php 
        echo plugins_url() . '/' . MLM_PLUGIN_NAME . '/ajax/check_epin.php';
        ?>
"+"?q="+str,true);
	xmlhttp.send();
     }
}


function checkePinAvailability1(str)
{
	var iChars = "~`!@#$%^&*()+=[]\\\';,- ./{}|\":<>?abcdefghijklmnopqrstuvwxyz";
	for (var i = 0; i < str.length; i++)
	{
    	if (iChars.indexOf(str.charAt(i)) != -1) 
		{
    		alert("<?php 
        _e('Please enter Valid ePin.', 'unilevel-mlm-pro');
        ?>
");
			document.getElementById('epin').value='';
			document.getElementById('epin').focus();
    		return false;
        }
    }
	
	var xmlhttp;    
	/*if (str=="")
  	{
  		alert("Please enter ePin.");
		document.getElementById('epin').focus();
		return false;
  	}*/
	if (str!="")
  	{
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	if (xmlhttp.status==200 && xmlhttp.readyState==4)
	{
		
	 if(xmlhttp.responseText=='1'){
          document.getElementById("check_epin").innerHTML="<span class='msg'>Congratulations! This ePin is available.</span>";   
          document.getElementById("epin_value").disabled=true;   
         }
         else
         {
         document.getElementById("check_epin").innerHTML="<span class='errormsg'>Sorry! This ePin is not Valid or already Used .</span>";
         document.getElementById("epin_value").disabled=false;   
            }
	}
	}   
	
	xmlhttp.open("GET", "<?php 
        echo plugins_url() . '/' . MLM_PLUGIN_NAME . '/ajax/check_epin.php';
        ?>
"+"?r="+str,true);
	xmlhttp.send();
      }
}
</script>

        <?php 
        $general_setting = get_option('wp_mlm_general_settings');
        if (is_user_logged_in()) {
            if (!empty($general_setting['wp_reg']) && !empty($general_setting['reg_url']) && $user_role != 'mlm_user') {
                echo "<script>window.location ='" . site_url() . '/' . $general_setting['reg_url'] . "'</script>";
            }
        } else {
            if (!empty($general_setting['wp_reg']) && !empty($general_setting['reg_url'])) {
                echo "<script>window.location ='" . site_url() . '/' . $general_setting['reg_url'] . "'</script>";
            }
        }
        ?>
		
		
<span style='color:red;'><?php 
        echo $error;
        ?>
</span>
<?php 
        if (isset($msg) && $msg != "") {
            echo $msg;
        }
        ?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<form name="frm" method="post" action="" onSubmit="return formValidationNewVer();">
		<tr>
			<td><?php 
        _e('Create Username', 'unilevel-mlm-pro');
        ?>
<span style="color:red;">*</span> :</td>
			<td><input type="text" name="username" id="username" value="<?php 
        if (!empty($_POST['username'])) {
            _e(htmlentities($_POST['username']));
        }
        ?>
" maxlength="20" size="37" onBlur="checkUserNameAvailability(this.value);"><br /><div id="check_user"></div></td>
		</tr>
		<?php 
        if (isset($mlm_general_settings['ePin_activate']) && $mlm_general_settings['ePin_activate'] == '1' && isset($mlm_general_settings['sol_payment']) && $mlm_general_settings['sol_payment'] == '1') {
            ?>
		<tr><td colspan="2">&nbsp;</td></tr>
		<tr>
			<td><?php 
            _e('Enter ePin', 'unilevel-mlm-pro');
            ?>
<span style="color:red;">*</span> :</td>
			<td><input type="text" name="epin" id="epin" value="<?php 
            if (!empty($_POST['epin'])) {
                _e(htmlentities($_POST['epin']));
            }
            ?>
" maxlength="20" size="37" onBlur="checkePinAvailability(this.value);"><br /><div id="check_epin"></div></td>
		</tr>
		<?php 
        } else {
            if (isset($mlm_general_settings['ePin_activate']) && $mlm_general_settings['ePin_activate'] == '1') {
                ?>
		<tr><td colspan="2">&nbsp;</td></tr>
		<tr>
			<td><?php 
                _e('Enter ePin', 'unilevel-mlm-pro');
                ?>
 :</td>
			<td><input type="text" name="epin" id="epin" value="<?php 
                if (!empty($_POST['epin'])) {
                    _e(htmlentities($_POST['epin']));
                }
                ?>
" maxlength="20" size="37" onBlur="checkePinAvailability1(this.value);"><br /><div id="check_epin"></div></td>
		</tr>
		<?php 
            }
        }
        if ($mlm_general_settings['sol_payment'] != '1' || empty($mlm_general_settings['sol_payment'])) {
            ?>
                <tr><td colspan="2">&nbsp;</td></tr>
		<tr>
			<td><?php 
            _e('Product', 'unilevel-mlm-pro');
            ?>
 :</td>
			<td> <?php 
            $pro_price_settings = $wpdb->get_results("select * from {$table_prefix}mlm_product_price where p_id!='1'");
            ?>

                <select name="epin_value" id="epin_value" >
                <option value="">Select Product</option>
                <?php 
            foreach ($pro_price_settings as $pricedetail) {
                ?>
       
<option value="<?php 
                echo $pricedetail->p_id;
                ?>
" <?php 
                echo $epin_value == $pricedetail->p_id ? 'selected="selected"' : '';
                ?>
><?php 
                echo $pricedetail->product_name;
                ?>
</option>
<?php 
            }
            ?>
                </select></td>
		</tr>
                <?php 
        }
        ?>
		<tr><td colspan="2">&nbsp;</td></tr>
		
		<tr>
			<td><?php 
        _e('Create Password', 'unilevel-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
			<td>	<input type="password" name="password" id="password" maxlength="20" size="37" >
				<br /><span style="font-size:12px; font-style:italic; color:#006633"><?php 
        _e('Password length atleast 6 character', 'unilevel-mlm-pro');
        ?>
</span>
			</td>
		</tr>
		
		<tr><td colspan="2">&nbsp;</td></tr>
		
		<tr>
			<td><?php 
        _e('Confirm Password', 'unilevel-mlm-pro');
        ?>
  <span style="color:red;">*</span> :</td>
			<td><input type="password" name="confirm_password" id="confirm_password" maxlength="20" size="37" ></td>
		</tr>
		
		<tr><td colspan="2">&nbsp;</td></tr>

		
		<tr>
			<td><?php 
        _e('Email Address', 'unilevel-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
			<td><input type="text" name="email" id="email" value="<?php 
        if (!empty($_POST['email'])) {
            _e(htmlentities($_POST['email']));
        }
        ?>
"  size="37" ></td>
		</tr>
		
		<tr><td colspan="2">&nbsp;</td></tr><tr>
		
		<tr>
			<td><?php 
        _e('Confirm Email Address', 'unilevel-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
			<td><input type="text" name="confirm_email" id="confirm_email" value="<?php 
        if (!empty($_POST['confirm_email'])) {
            _e(htmlentities($_POST['confirm_email']));
        }
        ?>
" size="37" ></td>
		</tr>
		
		<tr><td colspan="2">&nbsp;</td></tr>
			<?php 
        if (is_plugin_active('mlm-paypal-mass-pay/load-data.php')) {
            ?>
				<tr>
                    <td><?php 
            _e('Paypal ID', 'unilevel-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                    <td><input type="text" name="paypal_id" id="paypal_id" value="<?php 
            if (!empty($_POST['paypal_id'])) {
                _e(htmlentities($_POST['paypal_id']));
            }
            ?>
" size="37" ></td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr>
		  <?php 
        }
        ?>
	
		<tr>
			<td><?php 
        _e('First Name', 'unilevel-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
			<td><input type="text" name="firstname" id="firstname" value="<?php 
        if (!empty($_POST['firstname'])) {
            _e(htmlentities($_POST['firstname']));
        }
        ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'firstname');" ></td>
		</tr>
		
		<tr><td colspan="2">&nbsp;</td></tr>
		
		<tr>
			<td><?php 
        _e('Last Name', 'unilevel-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
			<td><input type="text" name="lastname" id="lastname" value="<?php 
        if (!empty($_POST['lastname'])) {
            _e(htmlentities($_POST['lastname']));
        }
        ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'lastname');"></td>
		</tr>
		
		<tr><td colspan="2">&nbsp;</td></tr>
		
		<tr>
			<?php 
        if (isset($sponsor_name) && $sponsor_name != '') {
            $spon = $sponsor_name;
        } else {
            if (isset($_POST['sponsor'])) {
                $spon = htmlentities($_POST['sponsor']);
            }
        }
        ?>
			<td><?php 
        _e('Sponsor Name', 'unilevel-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
			<td>
			<input type="text" name="sponsor" id="sponsor" value="<?php 
        if (!empty($spon)) {
            _e($spon);
        }
        ?>
" maxlength="20" size="37" onBlur="checkReferrerAvailability(this.value);" <?php 
        echo $readonly_sponsor;
        ?>
>
			<br /><div id="check_referrer"></div>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			
			<input type="submit" name="submit" id="submit" value="<?php 
        _e('Submit', 'unilevel-mlm-pro');
        ?>
" /></td>
		</tr>
	</form>
</table>
<?php 
    } else {
        _e($msg);
    }
}
function register_user_html_page()
{
    global $wpdb, $current_user;
    $user_id = $current_user->ID;
    $table_prefix = mlm_core_get_table_prefix();
    $error = '';
    $chk = 'error';
    include_once ABSPATH . '/wp-admin/includes/plugin.php';
    if (!empty($_GET['sp_name'])) {
        $sp_name = $wpdb->get_var("select username from {$table_prefix}mlm_users where username='******'sp_name'] . "'");
        if ($sp_name) {
            ?>
            <script type='text/javascript'>
                $.cookie('sp_name', '<?php 
            echo $sp_name;
            ?>
', {path: '/'});
            </script>
            <?php 
        }
    } else {
        if (!empty($_REQUEST['sp'])) {
            $sp_name = getusernamebykey($_REQUEST['sp']);
            if ($sp_name) {
                ?>
            <script type='text/javascript'>
                $.cookie('sp_name', '<?php 
                echo $sp_name;
                ?>
', {path: '/'});
            </script>
            <?php 
            }
        } else {
            $sp_name = empty($_COOKIE["sp_name"]) ? '' : $_COOKIE["sp_name"];
        }
    }
    get_currentuserinfo();
    $mlm_general_settings = get_option('wp_mlm_general_settings');
    if (is_user_logged_in()) {
        $sponsor_name = $current_user->user_login;
        $readonly_sponsor = 'readonly';
    } else {
        if (isset($_REQUEST['sp']) && $_REQUEST['sp'] != '') {
            $sponsorName = getusernamebykey($_REQUEST['sp']);
            if (isset($sponsorName) && $sponsorName != '') {
                $readonly_sponsor = 'readonly';
                $sponsor_name = $sponsorName;
            } else {
                redirectPage(home_url(), array());
                exit;
            }
        } else {
            if (!empty($_REQUEST['sp_name'])) {
                $sponsorName = $_REQUEST['sp_name'];
                if (!empty($sponsorName)) {
                    $readonly_sponsor = 'readonly';
                    $sponsor_name = $sponsorName;
                } else {
                    redirectPage(home_url(), array());
                    exit;
                }
            } else {
                $readonly_sponsor = '';
            }
        }
    }
    /* script for auto insert users================================================ */
    if ($_SERVER['HTTP_HOST'] == '192.168.100.100') {
        echo '<form name="form1"action="" method="post">
      <input type="number" min="0" max="99" name="id"/>
      <input type="number" min="0" max="1" name="epin"/>
      <input type="number" min="0" max="1" name="leg"/>
      <input type="submit"/></form>';
        $epinstatus = isset($_POST['epin']) ? $_POST['epin'] : '';
        if ($epinstatus != '') {
            $epin_no = $wpdb->get_var("select epin_no from {$table_prefix}mlm_epins where  point_status='{$epinstatus}' AND status=0 limit 1 ");
        }
        if (isset($_POST['id'])) {
            $z = $_POST['id'];
            $_POST = array('firstname' => 'binary' . $z, 'lastname' => 'binary' . $z, 'username' => 'binary' . $z, 'password' => 'binary' . $z, 'confirm_password' => 'binary' . $z, 'email' => 'binary' . $z . '@gmail.com', 'confirm_email' => 'binary' . $z . '@gmail.com', 'sponsor' => !empty($sponsor_name) ? $sponsor_name : '', 'submit' => 'submit', 'leg' => $_POST['leg'], 'epin' => $epin_no, 'paypal_id' => 'binary' . $z . '@gmail.com');
        }
        //'epin'=>!empty($epin_no)?$epin_no:'',
        //echo "<pre>"; print_r($_SERVER); echo "</pre>";
    }
    /* ===========================================================Close Auto Insert. */
    //most outer if condition
    if (isset($_POST['submit'])) {
        $firstname = sanitize_text_field($_POST['firstname']);
        $lastname = sanitize_text_field($_POST['lastname']);
        $username = sanitize_text_field($_POST['username']);
        $epin = sanitize_text_field(isset($_POST['epin']) ? $_POST['epin'] : '');
        $sponsor = sanitize_text_field($_POST['sponsor']);
        $password = sanitize_text_field($_POST['password']);
        $confirm_pass = sanitize_text_field($_POST['confirm_password']);
        $email = sanitize_text_field($_POST['email']);
        $confirm_email = sanitize_text_field($_POST['confirm_email']);
        $invalid_usernames = array('admin');
        $username = sanitize_user($username);
        if (!validate_username($username) || in_array($username, $invalid_usernames)) {
            $error .= "\n Username is invalid.";
        }
        if (username_exists($username)) {
            $error .= "\n Username already exists.";
        }
        if (empty($sponsor)) {
            $sponsor = $wpdb->get_var("select `username` FROM {$table_prefix}mlm_users order by id asc limit 1");
        }
        if (!empty($epin) && epin_exists($epin)) {
            $error .= "\n ePin already issued or wrong ePin.";
        }
        if (!empty($mlm_general_settings['sol_payment']) && empty($epin)) {
            $error .= "\n Please enter your ePin.";
        } else {
            if (empty($_POST['epin_value']) && empty($epin)) {
                $error .= "\n Please either enter the ePin or select the Product.";
            }
        }
        if (checkInputField($password)) {
            $error .= "\n Please enter your password.";
        }
        if (confirmPassword($password, $confirm_pass)) {
            $error .= "\n Please confirm your password.";
        }
        if (checkInputField($sponsor)) {
            $error .= "\n Please enter your sponsor name.";
        }
        if (checkInputField($firstname)) {
            $error .= "\n Please enter your first name.";
        }
        if (checkInputField($lastname)) {
            $error .= "\n Please enter your last name.";
        }
        if (!is_email($email)) {
            $error .= "\n E-mail address is invalid.";
        }
        if (email_exists($email)) {
            $error .= "\n E-mail address is already in use.";
        }
        if (confirmEmail($email, $confirm_email)) {
            $error .= "\n Please confirm your email address.";
        }
        include_once ABSPATH . '/wp-admin/includes/plugin.php';
        if (is_plugin_active('mlm-paypal-mass-pay/load-data.php')) {
            $paypalId = sanitize_text_field($_POST['paypal_id']);
            if (checkInputField($paypalId)) {
                $error .= "\n Please enter your Paypal id.";
            }
        }
        $sql = "SELECT COUNT(*) num, `user_key` FROM {$table_prefix}mlm_users WHERE `username` = '" . $sponsor . "'";
        $intro = $wpdb->get_row($sql);
        if (isset($_GET['l']) && $_GET['l'] != '') {
            $leg = $_GET['l'];
        } else {
            @($leg = $_POST['leg']);
        }
        if (isset($leg) && $leg != '0') {
            if ($leg != '1') {
                $error .= "\n You have enter a wrong placement.";
            }
        }
        //generate random numeric key for new user registration
        $user_key = generateKey();
        //if generated key is already exist in the DB then again re-generate key
        do {
            $check = $wpdb->get_var("SELECT COUNT(*) ck FROM {$table_prefix}mlm_users WHERE `user_key` = '" . $user_key . "'");
            $flag = 1;
            if ($check == 1) {
                $user_key = generateKey();
                $flag = 0;
            }
        } while ($flag == 0);
        //check parent key exist or not
        if (isset($_GET['k']) && $_GET['k'] != '') {
            if (!checkKey($_GET['k'])) {
                $error .= "\n Parent key does't exist.";
            }
            // check if the user can be added at the current position
            $checkallow = checkallowed($_GET['k'], $leg);
            if ($checkallow >= 1) {
                $error .= "\n You have enter a wrong placement.";
            }
        }
        if (!isset($leg)) {
            $key = $wpdb->get_var("SELECT user_key FROM {$table_prefix}mlm_users WHERE user_id = '{$user_id}'");
            $l = totalLeftLegUsers($key);
            $r = totalRightLegUsers($key);
            if ($l < $r) {
                $leg = '0';
            } else {
                $leg = '1';
            }
        }
        // outer if condition
        if (empty($error)) {
            // inner if condition
            if ($intro->num == 1) {
                $sponsor = $intro->user_key;
                $sponsor1 = $sponsor;
                //find parent key
                if (isset($_GET['k']) && $_GET['k'] != '') {
                    $parent_key = $_GET['k'];
                } else {
                    $readonly_sponsor = '';
                    do {
                        $sql = "SELECT `user_key` FROM {$table_prefix}mlm_users WHERE parent_key = '" . $sponsor1 . "' AND \n\t\t\t\tleg = '" . $leg . "' AND banned = '0'";
                        $spon = $wpdb->get_var($sql);
                        $num = $wpdb->num_rows;
                        if ($num) {
                            $sponsor1 = $spon;
                        }
                    } while ($num == 1);
                    $parent_key = $sponsor1;
                }
                $user = array('user_login' => $username, 'user_pass' => $password, 'first_name' => $firstname, 'last_name' => $lastname, 'user_email' => $email, 'user_registered' => current_time('mysql'), 'role' => 'mlm_user');
                // return the wp_users table inserted user's ID
                $user_id = wp_insert_user($user);
                /* Send e-mail to admin and new user  */
                wp_new_user_notification($user_id, $password);
                $pc = isset($mlm_general_settings['product_price']) ? $mlm_general_settings['product_price'] : '0';
                //insert the data into fa_user table
                if (!empty($epin)) {
                    $pointResult = $wpdb->get_row("select p_id,point_status from {$table_prefix}mlm_epins where epin_no = '{$epin}'");
                    $pointStatus = $pointResult->point_status;
                    $productPrice = $wpdb->get_var("SELECT product_price FROM {$table_prefix}mlm_product_price WHERE p_id = '" . $pointResult->p_id . "'");
                    // to epin point status 1
                    if ($pointStatus[0] == '1') {
                        $paymentStatus = '1';
                        $payment_date = current_time('mysql');
                    } else {
                        if ($pointStatus[0] == '0') {
                            $paymentStatus = '2';
                            $payment_date = current_time('mysql');
                        }
                    }
                } else {
                    if (!empty($_POST['epin_value'])) {
                        $productPrice = $wpdb->get_var("SELECT product_price FROM {$table_prefix}mlm_product_price WHERE p_id = '" . $_POST['epin_value'] . "'");
                        $paymentStatus = '0';
                        $payment_date = '0000-00-00 00:00:00';
                    } else {
                        // to non epin
                        $paymentStatus = '0';
                        $payment_date = '0000-00-00 00:00:00';
                    }
                }
                $insert = "INSERT INTO {$table_prefix}mlm_users\n\t\t\t\t\t\t   (\n\t\t\t\t\t\t\t\tuser_id, username, user_key, parent_key, sponsor_key, leg,payment_date,payment_status,product_price\n\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t'" . $user_id . "','" . $username . "', '" . $user_key . "', '" . $parent_key . "', '" . $sponsor . "', '" . $leg . "','" . $payment_date . "','" . $paymentStatus . "','" . $productPrice . "'\n\t\t\t\t\t\t\t)";
                // if all data successfully inserted
                if ($wpdb->query($insert)) {
                    //begin most inner if condition
                    //entry on Left and Right Leg tables
                    if ($leg == 0) {
                        $insert = "INSERT INTO {$table_prefix}mlm_leftleg set  pkey='" . $parent_key . "',ukey='" . $user_key . "'";
                        $insert = $wpdb->query($insert);
                        if ($u = get_option('network_mail', true) == 1) {
                        }
                    } else {
                        if ($leg == 1) {
                            $insert = "INSERT INTO {$table_prefix}mlm_rightleg set pkey='" . $parent_key . "',ukey='" . $user_key . "'";
                            $insert = $wpdb->query($insert);
                            if ($u = get_option('network_mail', true) == 1) {
                            }
                        }
                    }
                    SendMailToAll($user_key, $parent_key, $sponsor);
                    //begin while loop
                    while ($parent_key != '0') {
                        $query = "SELECT COUNT(*) num, parent_key, leg \n\t\t\t\t\t\t\t\t  FROM {$table_prefix}mlm_users \n\t\t\t\t\t\t\t\t  WHERE user_key = '" . $parent_key . "'\n\t\t\t\t\t\t\t\t  AND banned = '0'";
                        $result = $wpdb->get_row($query);
                        if ($result->num == 1) {
                            if ($result->parent_key != '0') {
                                if ($result->leg == 1) {
                                    $tbright = "INSERT INTO {$table_prefix}mlm_rightleg set pkey='" . $result->parent_key . "',ukey='" . $user_key . "' ";
                                    $tbright = $wpdb->query($tbright);
                                    if ($u = get_option('network_mail', true) == 1) {
                                    }
                                } else {
                                    $tbleft = "INSERT INTO {$table_prefix}mlm_leftleg set pkey='" . $result->parent_key . "',ukey='" . $user_key . "' ";
                                    $tbleft = $wpdb->query($tbleft);
                                    if ($u = get_option('network_mail', true) == 1) {
                                    }
                                }
                            }
                            $parent_key = $result->parent_key;
                        } else {
                            $parent_key = '0';
                        }
                    }
                    //end while loop
                    if (isset($epin) && !empty($epin)) {
                        $sql = "update {$table_prefix}mlm_epins set user_key='{$user_key}', date_used='" . current_time('mysql') . "', status=1 where epin_no ='{$epin}' ";
                        $wpdb->query($sql);
                    }
                    if ($paymentStatus == 1) {
                        insert_refferal_commision($user_id);
                    }
                    if (is_plugin_active('mlm-paypal-mass-pay/load-data.php')) {
                        update_user_meta($user_id, 'mlm_user_paypalid', $paypalId, FALSE);
                    }
                    $chk = '';
                    $msg = "<span style='color:green;'>Congratulations! You have successfully registered in the system.</span>";
                }
                //end most inner if condition
            } else {
                $error = "\n Sponsor does not exist in the system.";
            }
        }
        //end outer if condition
    }
    //end most outer if condition
    //if any error occoured
    if (!empty($error)) {
        $error = nl2br($error);
    }
    if ($chk != '') {
        include 'js-validation-file.html';
        ?>

        <?php 
        $user_roles = $current_user->roles;
        $user_role = array_shift($user_roles);
        $general_setting = get_option('wp_mlm_general_settings');
        if (is_user_logged_in()) {
            if (!empty($general_setting['wp_reg']) && !empty($general_setting['reg_url']) && $user_role != 'mlm_user') {
                echo "<script>window.location ='" . site_url() . '/' . $general_setting['reg_url'] . "'</script>";
            }
        } else {
            if (!empty($general_setting['wp_reg']) && !empty($general_setting['reg_url'])) {
                echo "<script>window.location ='" . site_url() . '/' . $general_setting['reg_url'] . "'</script>";
            }
        }
        ?>

        <span style='color:red;'><?php 
        echo $error;
        ?>
</span>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <form name="frm" method="post" action="" onSubmit="return formValidation();">
                <tr>
                    <td><?php 
        _e('Create Username', 'binary-mlm-pro');
        ?>
<span style="color:red;">*</span> :</td>
                    <td><input type="text" name="username" id="username" value="<?php 
        if (!empty($_POST['username'])) {
            _e(htmlentities($_POST['username']));
        }
        ?>
" maxlength="20" size="37" onBlur="checkUserNameAvailability(this.value);"><br /><div id="check_user"></div></td>
                </tr>
                <?php 
        $mlm_general_settings = get_option('wp_mlm_general_settings');
        if (!empty($mlm_general_settings['ePin_activate']) && !empty($mlm_general_settings['sol_payment'])) {
            ?>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td><?php 
            _e('Enter ePin', 'binary-mlm-pro');
            ?>
<span style="color:red;">*</span> :</td>
                        <td><input type="text" name="epin" id="epin" value="<?php 
            if (!empty($_POST['epin'])) {
                _e(htmlentities($_POST['epin']));
            }
            ?>
" maxlength="20" size="37" onBlur="checkePinAvailability(this.value);"><br /><div id="check_epin"></div></td>
                    </tr>
                <?php 
        } else {
            if (!empty($mlm_general_settings['ePin_activate'])) {
                ?>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td><?php 
                _e('Enter ePin', 'binary-mlm-pro');
                ?>
 :</td>
                        <td><input type="text" name="epin" id="epin" value="<?php 
                if (!empty($_POST['epin'])) {
                    _e(htmlentities($_POST['epin']));
                }
                ?>
" maxlength="20" size="37" onBlur="checkePinAvailability(this.value);"><br /><div id="check_epin"></div></td>
                    </tr>
                    <?php 
            }
        }
        if (empty($mlm_general_settings['sol_payment'])) {
            ?>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td><?php 
            _e('Product', 'binary-mlm-pro');
            ?>
 :</td>
                        <td> <?php 
            $pro_price_settings = $wpdb->get_results("select * from {$table_prefix}mlm_product_price where p_id!='1'");
            ?>

                            <select name="epin_value" id="epin_value" >
                                <option value="">Select Product</option>
                                <?php 
            foreach ($pro_price_settings as $pricedetail) {
                ?>
       
                                    <option value="<?php 
                echo $pricedetail->p_id;
                ?>
" <?php 
                echo $epin_value == $pricedetail->p_id ? 'selected="selected"' : '';
                ?>
><?php 
                echo $pricedetail->product_name;
                ?>
</option>
                                <?php 
            }
            ?>
                            </select></td>
                    </tr>
                <?php 
        }
        ?>
                <tr><td colspan="2">&nbsp;</td></tr>
                <tr>
                    <td><?php 
        _e('Create Password', 'binary-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
                    <td>	<input type="password" name="password" id="password" maxlength="20" size="37" >
                        <br /><span style="font-size:12px; font-style:italic; color:#006633"><?php 
        _e('Password length atleast 6 character', 'binary-mlm-pro');
        ?>
</span>
                    </td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr>

                <tr>
                    <td><?php 
        _e('Confirm Password', 'binary-mlm-pro');
        ?>
  <span style="color:red;">*</span> :</td>
                    <td><input type="password" name="confirm_password" id="confirm_password" maxlength="20" size="37" ></td>
                </tr>
                <tr><td colspan="2">&nbsp;</td></tr>
                <tr>
                    <td><?php 
        _e('Email Address', 'binary-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
                    <td><input type="text" name="email" id="email" value="<?php 
        if (!empty($_POST['email'])) {
            _e(htmlentities($_POST['email']));
        }
        ?>
"  size="37" ></td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr><tr>

                <tr>
                    <td><?php 
        _e('Confirm Email Address', 'binary-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
                    <td><input type="text" name="confirm_email" id="confirm_email" value="<?php 
        if (!empty($_POST['confirm_email'])) {
            _e(htmlentities($_POST['confirm_email']));
        }
        ?>
" size="37" ></td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr>
                <?php 
        if (is_plugin_active('mlm-paypal-mass-pay/load-data.php')) {
            ?>
                    <tr>
                        <td><?php 
            _e('Paypal ID', 'binary-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><input type="text" name="paypal_id" id="paypal_id" value="<?php 
            if (!empty($_POST['paypal_id'])) {
                _e(htmlentities($_POST['paypal_id']));
            }
            ?>
" size="37" ></td>
                    </tr>

                    <tr><td colspan="2">&nbsp;</td></tr>
                <?php 
        }
        ?>
	
                <tr>
                    <td><?php 
        _e('First Name', 'binary-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
                    <td><input type="text" name="firstname" id="firstname" value="<?php 
        if (!empty($_POST['firstname'])) {
            _e(htmlentities($_POST['firstname']));
        }
        ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'firstname');" ></td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr>

                <tr>
                    <td><?php 
        _e('Last Name', 'binary-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
                    <td><input type="text" name="lastname" id="lastname" value="<?php 
        if (!empty($_POST['lastname'])) {
            _e(htmlentities($_POST['lastname']));
        }
        ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'lastname');"></td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr>

                <tr>
                    <?php 
        if (isset($sponsor_name) && $sponsor_name != '') {
            $spon = $sponsor_name;
        } else {
            if (isset($sp_name)) {
                $spon = $sp_name;
            } else {
                if (isset($_POST['sponsor'])) {
                    $spon = htmlentities($_POST['sponsor']);
                }
            }
        }
        ?>
                    <td><?php 
        _e('Sponsor Name', 'binary-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
                    <td>
                        <input type="text" name="sponsor" id="sponsor" value="<?php 
        if (!empty($spon)) {
            _e($spon);
        }
        ?>
" maxlength="20" size="37" onBlur="checkReferrerAvailability(this.value);" <?php 
        echo $readonly_sponsor;
        ?>
>
                        <br /><div id="check_referrer"></div>
                    </td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr>

                <tr>
                    <td><?php 
        _e('Placement', 'binary-mlm-pro');
        ?>
 <span style="color:red;">*</span> :</td>
                    <?php 
        if (isset($_POST['leg']) && $_POST['leg'] == '0') {
            $checked = 'checked';
        } else {
            if (isset($_GET['l']) && $_GET['l'] == '0') {
                $checked = 'checked';
                $disable_leg = 'disabled';
            } else {
                $checked = '';
            }
        }
        if (isset($_POST['leg']) && $_POST['leg'] == '1') {
            $checked1 = 'checked';
        } else {
            if (isset($_GET['l']) && $_GET['l'] == '1') {
                $checked1 = 'checked';
                $disable_leg = 'disabled';
            } else {
                $checked1 = '';
            }
        }
        ?>

                    <td><?php 
        echo __('Left', 'binary-mlm-pro');
        ?>
 <input id="left" type="radio" name="leg" value="0" <?php 
        echo $checked;
        ?>
 <?php 
        if (!empty($disable_leg)) {
            _e($disable_leg);
        }
        ?>
/>
                        <?php 
        echo __('Right', 'binary-mlm-pro');
        ?>
<input id="right" type="radio" name="leg" value="1" <?php 
        echo $checked1;
        ?>
 <?php 
        if (!empty($disable_leg)) {
            _e($disable_leg);
        }
        ?>
/>



                    </td>
                </tr>
                <tr>
                    <td colspan="2"><input type="submit" name="submit" id="submit" value="<?php 
        _e('Submit', 'binary-mlm-pro');
        ?>
" /></td>
                </tr>
            </form>
        </table>
        <?php 
    } else {
        _e($msg);
    }
}
Exemplo n.º 6
0
    function widget($args, $instance)
    {
        global $current_user;
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $textarea = $instance['textarea'];
        $ckemail = get_option('ckemail');
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        if ($textarea) {
            echo '<p>' . $textarea . '</p>';
        }
        if (is_user_logged_in()) {
            $sp_name = $current_user->user_login;
        } else {
            if (!empty($_GET['sp_name'])) {
                $sp_name = $_GET['sp_name'];
            } else {
                if (!empty($_GET['sp'])) {
                    $sp_name = getusernamebykey($_GET['sp']);
                } else {
                    $sp_name = $_COOKIE["s_name"];
                }
            }
        }
        if (is_user_logged_in()) {
            $current_user = wp_get_current_user();
            $cuserid = $current_user->ID;
            $cusername = $current_user->user_firstname . ' ' . $current_user->user_lastname;
            ?>
  
			<div class="join_box">
				<div class="join_box_left" style="width:90px;float:left;">
					<?php 
            echo get_avatar($userid, 80);
            ?>
				</div>
				<div class="join_box_right">
					<?php 
            echo '<p>' . $cusername . '</p>';
            if (!empty($ckemail)) {
                ?>
                        <span class='swemail'><?php 
                echo empty($cemail) ? '' : $cemail;
                ?>
</span><br/><br/>
                        <?php 
            } else {
                echo '<br/>';
            }
            ?>
					<a class="subscribe button-primary" href="<?php 
            echo get_post_id_or_postname('mlm_registration_page', 'unilevel-mlm-pro');
            ?>
/">Join Now</a>
				</div>
			</div>
	<?php 
        } else {
            if (!empty($sp_name)) {
                $user = get_user_by('login', $sp_name);
                if (!empty($user)) {
                    $userid = $user->ID;
                    $all_meta_for_user = get_user_meta($userid);
                    $fname = $all_meta_for_user['first_name'][0];
                    $lname = $all_meta_for_user['last_name'][0];
                    $fullname = $fname . ' ' . $lname;
                    $user_info = get_userdata($userid);
                    $email = $user_info->user_email;
                    $permalink = get_permalink(empty($_GET['page_id']) ? '' : $_GET['page_id']);
                    $postidparamalink = strstr($permalink, 'page_id');
                    $concat = $postidparamalink ? '&' : '/?';
                }
                ?>
				<div class="join_box">
					<div class="join_box_left" style="width:90px;float:left;">
						<?php 
                echo get_avatar($userid, 80);
                ?>
					</div>
					<div class="join_box_right">
						<?php 
                echo '<p>' . $fullname . '</p>';
                if (!empty($ckemail)) {
                    ?>
                            <span class='swemail'><?php 
                    echo empty($email) ? '' : $email;
                    ?>
</span><br/><br/>
                            <?php 
                } else {
                    echo '<br/>';
                }
                ?>
						<a class="subscribe button-primary" href="<?php 
                echo get_post_id_or_postname('mlm_registration_page', 'unilevel-mlm-pro');
                echo $concat;
                ?>
sp_name=<?php 
                echo $sp_name;
                ?>
">Join Now</a>
					</div>
				</div>
	<?php 
            }
        }
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        $table_prefix = mlm_core_get_table_prefix();
        global $wpdb;
        $title = apply_filters('widget_title', $instance['title']);
        $textarea = $instance['textarea'];
        $ckemail = get_option('ckemail');
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        if ($textarea) {
            echo '<p>' . $textarea . '</p>';
        }
        if (!empty($_GET['sp_name'])) {
            $sp_name = $_GET['sp_name'];
        } else {
            if (!empty($_GET['sp'])) {
                $sp_name = getusernamebykey($_GET['sp']);
            } else {
                if (!empty($_COOKIE["sp_name"])) {
                    $sp_name = $_COOKIE["sp_name"];
                }
            }
        }
        //$sp_name = empty($_COOKIE["sp_name"])?'':$_COOKIE["sp_name"];
        if (is_user_logged_in()) {
            $current_user = wp_get_current_user();
            $cuserid = $current_user->ID;
            $cusername = $current_user->user_firstname . ' ' . $current_user->user_lastname;
            $cemail = $current_user->user_email;
            $all_meta_for_user = get_user_meta($cuserid);
            ?>
  
            <div class="join_box">
                <div class="join_box_left" style="width:90px;float:left;">
                    <?php 
            echo get_avatar($cuserid, 80);
            ?>
                </div>
                <div class="join_box_right">
                    <?php 
            echo '<span class="swname">' . ucwords(empty($cusername) ? '' : $cusername) . '</span><br/>';
            if (!empty($ckemail)) {
                ?>
                        <span class='swemail'><?php 
                echo empty($cemail) ? '' : $cemail;
                ?>
</span><br/><br/>
                        <?php 
            } else {
                echo '<br/>';
            }
            ?>
                    <input type="button" value="Join Now" class="primary button" onclick="window.location = '<?php 
            echo get_post_id_or_postname('mlm_registration_page', 'binary-mlm-pro');
            ?>
'" />
                </div>
            </div>
            <?php 
        } else {
            if (!empty($sp_name)) {
                $userid = $wpdb->get_var("SELECT user_id FROM {$table_prefix}mlm_users WHERE username = '******'");
                if (!empty($userid)) {
                    $all_meta_for_user = get_user_meta($userid);
                    $fname = $all_meta_for_user['first_name'][0];
                    $lname = $all_meta_for_user['last_name'][0];
                    $fullname = $fname . ' ' . $lname;
                    $user_info = get_userdata($userid);
                    $email = $user_info->user_email;
                    $permalink = get_permalink(empty($_GET['page_id']) ? '' : $_GET['page_id']);
                    $postidparamalink = strstr($permalink, 'page_id');
                    $concat = $postidparamalink ? '&' : '/?';
                }
                ?>
                <div class="join_box">
                    <div class="join_box_left" style="width:90px;float:left;">
                        <?php 
                echo get_avatar($userid, 80);
                ?>
                    </div>
                    <div class="join_box_right">
                        <?php 
                echo '<span class="swname">' . ucwords(empty($fullname) ? '' : $fullname) . '</span><br/>';
                if (!empty($ckemail)) {
                    ?>
                            <span class='swemail'><?php 
                    echo empty($email) ? '' : $email;
                    ?>
</span><br/><br/>
                            <?php 
                } else {
                    echo '<br/>';
                }
                ?>
                        <input type="button" value="Join Now" class="primary button" onclick="window.location = '<?php 
                echo get_post_id_or_postname('mlm_registration_page', 'binary-mlm-pro');
                echo empty($concat) ? '/?' : $concat;
                ?>
sp_name=<?php 
                echo $sp_name;
                ?>
'" />
                    </div>
                </div>
                <?php 
            }
        }
        echo $after_widget;
    }
Exemplo n.º 8
0
function viewUnilevelNetworkPage()
{
    $table_prefix = mlm_core_get_table_prefix();
    //$obj = new UnilevelTree();
    global $current_user, $wpdb;
    get_currentuserinfo();
    $username1 = $current_user->user_login;
    //get no. of level
    $mlm_general_settings = get_option('wp_mlm_general_settings');
    $mlm_no_of_level = $mlm_general_settings['mlm-level'];
    $res = mysql_fetch_array(mysql_query("SELECT user_key FROM {$table_prefix}mlm_users WHERE username = '******'"));
    $total = mysql_fetch_array(mysql_query("SELECT count(*) as num FROM {$table_prefix}mlm_hierarchy WHERE pid = '" . $res['user_key'] . "'"));
    $total = $total['num'];
    $member_page_id = $wpdb->get_var("SELECT id FROM {$table_prefix}posts  WHERE `post_content` LIKE '%mlm-view-child-level-member%'\tAND `post_type` != 'revision'");
    /*	$level[0]=countLevelMember($res['user_key']);
    	$user[0]=returnMemberUserkey($res['user_key']);
    
    $total=$level[0];
    
    for($i=1;$i<$mlm_no_of_level;$i++) {
    
    $user[$i]=returnMemberUserkey($user[$i-1]);
    $level[$i]=countLevelMember($user[$i-1]);
    
    
    if($level[$i]==0 || $level[$i]=='') {
    $level[$i]="No Any Members";
    }
    else {
    $total=$level[$i]+$total;
    }
    
    }*/
    //print_r($level);
    ?>
	<style type="text/css">
		span.owner
		{
			color:#339966; 
			font-style:italic;
		}
		span.paid
		{
			color: #669966!important; 
			/*background-color:#770000; */
			font-style:normal;
		}
		span.leg
		{
			color:red; 
			font-style:italic;
		}
	</style>

<script type="text/javascript" language="javascript">
	function searchUser()
	{
		var user = document.getElementById("username").value;
		if(user=="")
		{
			alert("Please enter username then searched.");
			document.getElementById("username").focus();
			return false;
		}
	}
</script>
 		<table border="0" cellspacing="0" cellpadding="0" >
			<tr>

			<td align="center">
				<form name="usersearch" id="usersearch" action="" method="post" onSubmit="return searchUser();">
					<input type="text" name="username" id="username"> <input type="submit" name="search" value="Search">
				</form>
			</td>
		</tr>               
		</table>
		
		<?php 
    if (isset($_POST['search'])) {
        $Search = $_POST['username'];
        $qry = mysql_query("SELECT user_key,h.level as level FROM {$table_prefix}mlm_hierarchy as h INNER JOIN {$table_prefix}mlm_users as u ON u.user_key=h.cid WHERE h.pid = '" . $res['user_key'] . "' AND u.username LIKE ('%" . $Search . "%')");
        $num = mysql_num_rows($qry);
        if ($num > 0) {
            while ($result = mysql_fetch_array($qry)) {
                $user = array();
                $usr_dtls = mysql_fetch_array(mysql_query("SELECT user_id,username,sponsor_key,payment_status FROM {$table_prefix}mlm_users WHERE user_key='" . $result['user_key'] . "'"));
                $user['username'] = $usr_dtls['username'];
                $user['first_name'] = get_user_meta($usr_dtls['user_id'], 'first_name', true);
                $user['last_name'] = get_user_meta($usr_dtls['user_id'], 'last_name', true);
                $sponser_id = $usr_dtls['sponsor_key'];
                $user['sponsor'] = getusernamebykey($sponser_id);
                $email = $wpdb->get_var("SELECT user_email FROM {$table_prefix}users WHERE ID='" . $usr_dtls['user_id'] . "'");
                $user['email'] = $email;
                $user['level'] = $result['level'];
                if ($usr_dtls['payment_status'] == 1) {
                    $user['status'] = "Paid";
                } else {
                    $user['status'] = "Not Paid";
                }
                $user_data[] = $user;
            }
            $level_data = $user_data;
            //print_r($level_data);
            ?>
		

<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("Username", "unilevel-mlm-pro");
            ?>
',type:'string'},
	{id:'B',label:'<?php 
            echo _e("First Name", "unilevel-mlm-pro");
            ?>
',type:'string'},
	{id:'C',label:'<?php 
            echo _e("Last Name", "unilevel-mlm-pro");
            ?>
',type:'string'},
    {id:'D',label:'<?php 
            echo _e("Sponsor", "unilevel-mlm-pro");
            ?>
',type:'string'},
    {id:'E',label:'<?php 
            echo _e("Email", "unilevel-mlm-pro");
            ?>
',type:'string'},
	{id:'F',label:'<?php 
            echo _e("Level", "unilevel-mlm-pro");
            ?>
',type:'string'},
    {id:'G',label:'<?php 
            echo _e("Status", "unilevel-mlm-pro");
            ?>
',type:'string'}],	
  rows:[
  <?php 
            for ($i = 0; $i < count($level_data); $i++) {
                ?>
                        {c:[{v:'<?php 
                echo $level_data[$i]['username'];
                ?>
'},
                        {v:'<?php 
                echo $level_data[$i]['first_name'];
                ?>
'},
                        {v:'<?php 
                echo $level_data[$i]['last_name'];
                ?>
'},
                        {v:'<?php 
                echo $level_data[$i]['sponsor'];
                ?>
'},
                        {v:'<?php 
                echo $level_data[$i]['email'];
                ?>
'},
						{v:'<?php 
                echo $level_data[$i]['level'];
                ?>
'},
                         {v:'<?php 
                echo $level_data[$i]['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"><strong><?php 
            _e('Search Results for:' . $Search, 'unilevel-mlm-pro');
            ?>
</strong></div>
            <!--/va-headname-->
			<div class="va-admin-leg-details">
            	<!--va-admin-mid-->
				<div class="paging">
				<?php 
            if (count($level_data) > 0) {
                ?>
				  <form action="">
					<div class="left-side" style="width:30%;float:left;">
						<?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>
					<?php 
            }
            ?>
					<div class="right-members">
					<?php 
            _e('Total Records', 'unilevel-mlm-pro');
            ?>
: <strong><?php 
            echo count($level_data);
            ?>
</strong>
					</div>
					<div class="va-clear"></div>
				  </div>
				<div id="table"></div>
				<div class="va-clear"></div>
			</div>		
		</div>
	</div>
<?php 
        } else {
            ?>


<p> No Search Result Found!</p>



	
<?php 
        }
    } else {
        ?>
		<table border="0" cellspacing="0" cellpadding="0" >
			<TR>
			<TD align="center" ><strong><?php 
        _e('Levels', 'unilevel-mlm-pro');
        ?>
</strong></TD>
			<TD align="center" > <strong><?php 
        _e('No. of Members', 'unilevel-mlm-pro');
        ?>
</strong></TD>
			</TR>
		<?php 
        for ($j = 1; $j <= $mlm_no_of_level; $j++) {
            if (returncountLevelMember($res['user_key'], $j) == 0) {
                $num = "Level " . $j;
            } else {
                $num = "<a href='?page_id=" . $member_page_id . "&lvl=" . $j . "'> Level " . $j . "</a>";
            }
            ?>
		<TR>
			<TD align="center" ><strong><?php 
            _e($num, 'unilevel-mlm-pro');
            ?>
</strong></TD>
			<TD align="center" > <?php 
            _e(returncountLevelMember($res['user_key'], $j), 'unilevel-mlm-pro');
            ?>
</TD>
			</TR>
		    
			<?php 
        }
        ?>
 
        <TR>
			<TD align="center" ><strong><?php 
        _e('Total', 'unilevel-mlm-pro');
        ?>
</strong></TD>
			<TD align="center" > <?php 
        _e($total, 'unilevel-mlm-pro');
        ?>
</TD>
			</TR>			
		</table>
		
		<?php 
    }
    ?>
		
		<div style="margin:0 auto;padding:0px;clear:both; width:100%!important;" align="center">

</div>
<?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 mlm_ePins_reports()
{
    global $wpdb, $table_prefix;
    require_once 'epin-reports-list-table.php';
    $objEpinList = new EpinReports_List_Table();
    $objEpinList->prepare_items();
    extract($_REQUEST);
    if (isset($page)) {
        $url = 'page=' . $page;
    }
    if (isset($epin_status)) {
        $url .= '&epin_status=' . $epin_status;
    } else {
        $url .= '';
    }
    $epin_status1 = isset($epin_status) ? $epin_status : '';
    $epin_value1 = isset($epin_value) ? $epin_value : '';
    ?>

<div class='wrap'>
	
<div id="icon-users" class="icon32"></div><h1><?php 
    _e('ePin Report', 'unilevel-mlm-pro');
    ?>
</h1></div>	
		<div class="notibar msginfo" style="margin:10px;">
			<a class="close"></a>
			<p><?php 
    _e('The report below lists all the ePins that have been generated on your site. Filter the results to see just the Used Pins or Unused Pins. To revert back to the default listing click the Reset Button.', 'unilevel-mlm-pro');
    ?>
</p>
			<p><?php 
    _e('The <strong>Search</strong> and <strong>Export to CSV</strong> funtions will work on the currently active Recordset i.e. if you are currently on the Used ePin Filter then performing a search or Exporting to CSV will apply only to the Used ePins.', 'unilevel-mlm-pro');
    ?>
</p>
</div>
<?php 
    $mlm_settings = get_option('wp_mlm_general_settings');
    if (isset($mlm_settings['ePin_activate']) && $mlm_settings['ePin_activate'] == '1') {
        ?>
<div style="margin-left:10px;float:left;text-decoration:none;">
<a class="button" style="text-decoration: none;" href="<?php 
        echo admin_url() . "admin.php?page=" . $_REQUEST['page'] . "&tab=epinreports";
        ?>
"><?php 
        _e('Reset', 'unilevel-mlm-pro');
        ?>
</a>
</div>	
	
<div style="margin-right:10px;float:right">			
	<form action="" method="get" style="float:right;">
		<input type="hidden" name="page" value="admin-reports" />
		<input type="hidden" name="tab" value="epinreports" />
		<input type="hidden" name="epin_status" value="<?php 
        echo $epin_status1;
        ?>
" />
		<input type="hidden" name="epin_value" value="<?php 
        echo $epin_value1;
        ?>
" />
		<input type="text" name="search"/><input type="submit" value="<?php 
        _e('Search', 'unilevel-mlm-pro');
        ?>
" class="button"/>
	</form>
</div>

 <form id="project-filter" method="GET" action="">
	<input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" />
	<input type="hidden" name="tab" value="epinreports" />
        
<?php 
        $objEpinList->display();
        ?>
</form>	

<?php 
        if (!isset($epin_status) && !isset($search) && !isset($epin_value)) {
            $sql = "SELECT * FROM {$table_prefix}mlm_epins ORDER BY id ASC";
        } else {
            if (isset($epin_status) && $epin_status != '' && isset($epin_value) && $epin_value != '' && !empty($search)) {
                $amt = $epin_value;
                $where = " WHERE status='" . $epin_status . "' AND  p_id='" . $amt . "' AND epin_no like '%" . trim($search) . "%'";
            } else {
                if (isset($epin_status) && $epin_status != '' && isset($epin_value) && $epin_value != '') {
                    $amt = $epin_value;
                    $where = " WHERE status='" . $epin_status . "' AND  p_id='" . $amt . "'";
                } else {
                    if (isset($epin_value) && $epin_value != '' && !empty($search)) {
                        $amt = $epin_value;
                        $where = " WHERE  p_id='" . $amt . "' AND epin_no like '%" . trim($search) . "%'";
                    } else {
                        if (isset($epin_status) && $epin_status != '' && !empty($search)) {
                            $where = " WHERE  status='" . $epin_status . "' AND epin_no like '%" . trim($search) . "%'";
                        } else {
                            if (isset($epin_status) && $epin_status != '') {
                                $where = " WHERE  status='" . $epin_status . "' ";
                            } else {
                                if (isset($epin_value) && $epin_value != '') {
                                    $amt = $epin_value;
                                    $where = " WHERE  p_id='" . $amt . "' ";
                                } else {
                                    if (!empty($search)) {
                                        $where = " WHERE  epin_no like '%" . trim($search) . "%' ";
                                    }
                                }
                            }
                        }
                    }
                }
            }
            /*
            $status=(isset($epin_status) && $epin_status!='')? " status='$epin_status'":"";
            $usersearch =!empty($search)? " epin_no like '%".trim($search)."%'" : '';
            if(isset($epin_value) && $epin_value!='')
            {
             $amt=10000*$epin_value;
             $price="epin_price='".$amt."'";
            }
            else
            {
            $price="";
            }
            
            $where=isset($status) || !empty($usersearch) ? ' WHERE' : '';
            $and=isset($status) && !empty($usersearch) ? ' AND' : '';
            echo $status;
            if($and=='')
            {
                $epinPrice=' AND '.$price;
            }
            else
            {
                if($status=='')
                {
                $epinPrice=$price;    
                }
                else
                {
                $epinPrice=' AND '.$price; 
                }
            }*/
            //$status=" WHERE status=$epin_status";
            //$status $and $usersearch $epinPrice
            $sql = "SELECT * FROM {$table_prefix}mlm_epins  {$where}  ORDER BY id ASC";
        }
        //echo $sql;
        $rs = mysql_query($sql);
        $i = 0;
        $listArr = array();
        $listArr[-1]['epin'] = __('Pin No.', 'unilevel-mlm-pro');
        $listArr[-1]['epinprice'] = __('Pin Price', 'unilevel-mlm-pro');
        $listArr[-1]['username'] = __('User Name', 'unilevel-mlm-pro');
        $listArr[-1]['firstname'] = __('First Name', 'unilevel-mlm-pro');
        $listArr[-1]['lastname'] = __('Last Name', 'unilevel-mlm-pro');
        $listArr[-1]['type'] = __('Type', 'unilevel-mlm-pro');
        $listArr[-1]['genarated_on'] = __('Generated On', 'unilevel-mlm-pro');
        $listArr[-1]['date_used'] = __('Used Date', 'unilevel-mlm-pro');
        if (mysql_num_rows($rs) > 0) {
            while ($row = mysql_fetch_array($rs)) {
                $user_id = getuseruidbykey($row['user_key']);
                $firstname = get_user_meta($user_id, 'first_name', true);
                $lastname = get_user_meta($user_id, 'last_name', true);
                $genaral_date = get_option('links_updated_date_format');
                if ($row['date_used'] == '0000-00-00 00:00:00') {
                    $used_date = '';
                } else {
                    $used_date = date("{$genaral_date}", strtotime($row['date_used']));
                }
                if ($row['date_generated'] == '0000-00-00 00:00:00') {
                    $genarated_on = '';
                } else {
                    $genarated_on = date("{$genaral_date}", strtotime($row['date_generated']));
                }
                $price = $wpdb->get_var("select product_price from {$table_prefix}mlm_product_price where p_id='" . $row['p_id'] . "'");
                $type = $row['point_status'] == '1' ? 'Regular' : 'Free';
                $listArr[$i]['epin'] = $row['epin_no'];
                $listArr[$i]['epinprice'] = $price;
                $listArr[$i]['username'] = getusernamebykey($row['user_key']);
                $listArr[$i]['firstname'] = $firstname;
                $listArr[$i]['lastname'] = $lastname;
                $listArr[$i]['type'] = $type;
                $listArr[$i]['genarated_on'] = $genarated_on;
                $listArr[$i]['date_used'] = $used_date;
                $i++;
            }
        }
        $value = serialize($listArr);
        ?>
<form method="post" action="<?php 
        echo plugins_url();
        ?>
/unilevel-mlm-pro/mlm_html/export.php">
<input type="hidden" name ="listarray" value='<?php 
        echo $value;
        ?>
' />
<input type="hidden" name ="filename" value='epin-report' />
<input type="submit" name="export_csv" value="<?php 
        _e('Export to CSV', 'unilevel-mlm-pro');
        ?>
" class="button-primary"/></form>
<?php 
    } else {
        ?>
<div style="padding: 20px;width: 84%;margin: 0 auto;">
<?php 
        _e('It seems you have not activated the ePin functionality under Settings -> General. ePin Report is accessible only with that setting set to Yes.', 'unilevel-mlm-pro');
        ?>
<br>
<?php 
        _e('Click', 'unilevel-mlm-pro');
        ?>
&nbsp;<a href="<?php 
        echo admin_url() . "admin.php?page=admin-settings";
        ?>
"><?php 
        _e('<strong>Here</strong>', 'unilevel-mlm-pro');
        ?>
</a>&nbsp;
<?php 
        _e(' to go to Settings -> General and activate the ePin functionality.', 'unilevel-mlm-pro');
        ?>
</div>
<?php 
    }
}
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>");
    }
}
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 
}
function join_network()
{
    global $wpdb, $current_user;
    $user_id = $current_user->ID;
    $table_prefix = mlm_core_get_table_prefix();
    $error = '';
    $chk = 'error';
    if (!empty($_GET['sp_name'])) {
        $sp_name = $wpdb->get_var("select username from {$table_prefix}mlm_users where username='******'sp_name'] . "'");
        if ($sp_name) {
            ?>
            <script type='text/javascript'>
                $.cookie('sp_name', '<?php 
            echo $sp_name;
            ?>
', {path: '/'});
            </script>
            <?php 
        }
    } else {
        if (!empty($_REQUEST['sp'])) {
            $sp_name = $wpdb->get_var("select username from {$table_prefix}mlm_users where user_key='" . $_REQUEST['sp'] . "'");
            if ($sp_name) {
                ?>
            <script type='text/javascript'>
                $.cookie('sp_name', '<?php 
                echo $sp_name;
                ?>
', {path: '/'});
            </script>
            <?php 
            }
        } else {
            $sp_name = empty($_COOKIE["sp_name"]) ? '' : $_COOKIE["sp_name"];
        }
    }
    /*     * ****date format ***** */
    $date_format = get_option('date_format');
    $time_format = get_option('time_format');
    /*     * ****** end******* */
    global $current_user;
    get_currentuserinfo();
    $mlm_general_settings = get_option('wp_mlm_general_settings');
    if (isset($_REQUEST['sp']) && $_REQUEST['sp'] != '') {
        $sponsorName = getusernamebykey($_REQUEST['sp']);
        if (isset($sponsorName) && $sponsorName != '') {
            $readonly_sponsor = 'readonly';
            $sponsor_name = $sponsorName;
        } else {
            redirectPage(home_url(), array());
            exit;
        }
    } else {
        if (!empty($_REQUEST['sp_name'])) {
            $sponsorName = $_REQUEST['sp_name'];
            if (!empty($sponsorName)) {
                $readonly_sponsor = 'readonly';
                $sponsor_name = $sponsorName;
            } else {
                redirectPage(home_url(), array());
                exit;
            }
        } else {
            $readonly_sponsor = '';
        }
    }
    //most outer if condition
    if (isset($_POST['submit'])) {
        $firstname = sanitize_text_field($_POST['firstname']);
        $lastname = sanitize_text_field($_POST['lastname']);
        $email = sanitize_text_field($_POST['email']);
        $sponsor = sanitize_text_field($_POST['sponsor']);
        if (empty($sponsor)) {
            $sponsor = $wpdb->get_var("select `username` FROM {$table_prefix}mlm_users order by id asc limit 1");
        }
        if (checkInputField($firstname)) {
            $error .= "\n Please enter your first name.";
        }
        if (checkInputField($lastname)) {
            $error .= "\n Please enter your last name.";
        }
        if (!is_email($email)) {
            $error .= "\n E-mail address is invalid.";
        }
        //Add usernames we don't want used
        $invalid_usernames = array('admin');
        //Do username validation
        $sql = "SELECT COUNT(*) num, `user_key` \n\t\t\t\tFROM {$table_prefix}mlm_users \n\t\t\t\tWHERE `username` = '" . $sponsor . "'";
        $intro = $wpdb->get_row($sql);
        if (isset($_GET['l']) && $_GET['l'] != '') {
            $leg = $_GET['l'];
        } else {
            $leg = $_POST['leg'];
        }
        if (isset($leg) && $leg != '0') {
            if ($leg != '1') {
                $error .= "\n You have enter a wrong placement.";
            }
        }
        if (!isset($leg)) {
            $key = $wpdb->get_var("SELECT user_key FROM {$table_prefix}mlm_users WHERE user_id = '{$user_id}'");
            $l = totalLeftLegUsers($key);
            $r = totalRightLegUsers($key);
            if ($l < $r) {
                $leg = '0';
            } else {
                $leg = '1';
            }
        }
        //generate random numeric key for new user registration
        $user_key = generateKey();
        //if generated key is already exist in the DB then again re-generate key
        do {
            $check = $wpdb->get_var("SELECT COUNT(*) ck FROM {$table_prefix}mlm_users \n                                     WHERE `user_key` = '" . $user_key . "'");
            $flag = 1;
            if ($check == 1) {
                $user_key = generateKey();
                $flag = 0;
            }
        } while ($flag == 0);
        //check parent key exist or not
        if (isset($_GET['k']) && $_GET['k'] != '') {
            if (!checkKey($_GET['k'])) {
                $error .= "\n Parent key does't exist.";
            }
            // check if the user can be added at the current position
            $checkallow = checkallowed($_GET['k'], $leg);
            if ($checkallow >= 1) {
                $error .= "\n You have enter a wrong placement.";
            }
        }
        // outer if condition
        if (empty($error)) {
            // inner if condition
            if ($intro->num == 1) {
                $sponsor = $intro->user_key;
                $sponsor1 = $sponsor;
                //find parent key
                if (isset($_GET['k']) && $_GET['k'] != '') {
                    $parent_key = $_GET['k'];
                } else {
                    $readonly_sponsor = '';
                    do {
                        $sql = "SELECT `user_key` FROM {$table_prefix}mlm_users \n                                WHERE parent_key = '" . $sponsor1 . "' AND \n                                leg = '" . $leg . "' AND banned = '0'";
                        $spon = $wpdb->get_var($sql);
                        $num = $wpdb->num_rows;
                        if ($num) {
                            $sponsor1 = $spon;
                        }
                    } while ($num == 1);
                    $parent_key = $sponsor1;
                }
                // return the wp_users table inserted user's ID
                $user = array('ID' => $user_id, 'first_name' => $firstname, 'last_name' => $lastname, 'user_email' => $email, 'role' => 'mlm_user');
                // return the wp_users table inserted user's ID
                $user_id = wp_update_user($user);
                $username = $current_user->user_login;
                //get the selected country name from the country table
                /* Send e-mail to admin and new user - 
                   You could create your own e-mail instead of using this function */
                /**                 * ****** product Price set *************** */
                if (!empty($mlm_general_settings['product_price'])) {
                    $pc = $mlm_general_settings['product_price'];
                } else {
                    $pc = '0';
                }
                //insert the data into fa_user table
                if (!empty($epin)) {
                    $pointStatus = $wpdb->get_row("select point_status from {$table_prefix}mlm_epins where epin_no = '{$epin}'", ARRAY_N);
                    // to epin point status 1
                    if ($pointStatus[0] == '1') {
                        $paymentStatus = '1';
                        $product_price = $pc;
                    } else {
                        if ($pointStatus[0] == '0') {
                            $paymentStatus = '2';
                            $product_price = '0';
                        }
                    }
                } else {
                    // to non epin
                    $paymentStatus = '0';
                    $product_price = '0';
                }
                $insert = "INSERT INTO {$table_prefix}mlm_users(\n\t\t\tuser_id, username, user_key, parent_key, sponsor_key, leg,payment_status,product_price) \n\t\t\tVALUES(\n\t\t\t'" . $user_id . "','" . $username . "', '" . $user_key . "', '" . $parent_key . "', '" . $sponsor . "', '" . $leg . "','" . $paymentStatus . "','" . $product_price . "')";
                // if all data successfully inserted
                if ($wpdb->query($insert)) {
                    //begin most inner if condition
                    //entry on Left and Right Leg tables
                    if ($leg == 0) {
                        $insert = "INSERT INTO {$table_prefix}mlm_leftleg  (pkey, ukey) \n\t\t\t\tVALUES ('" . $parent_key . "','" . $user_key . "')";
                        $insert = $wpdb->query($insert);
                    } else {
                        if ($leg == 1) {
                            $insert = "INSERT INTO {$table_prefix}mlm_rightleg(pkey, ukey) \n\t\t\t\tVALUES('" . $parent_key . "','" . $user_key . "')";
                            $insert = $wpdb->query($insert);
                        }
                    }
                    //begin while loop
                    while ($parent_key != '0') {
                        $query = "SELECT COUNT(*) num, parent_key, leg \n                                FROM {$table_prefix}mlm_users \n                                WHERE user_key = '" . $parent_key . "'\n                                AND banned = '0'";
                        $result = $wpdb->get_row($query);
                        if ($result->num == 1) {
                            if ($result->parent_key != '0') {
                                if ($result->leg == 1) {
                                    $tbright = "INSERT INTO {$table_prefix}mlm_rightleg (pkey,ukey) \n\t\t\t\t\t\tVALUES('" . $result->parent_key . "','" . $user_key . "')";
                                    $tbright = $wpdb->query($tbright);
                                } else {
                                    $tbleft = "INSERT INTO {$table_prefix}mlm_leftleg (pkey, ukey) \n\t\t\t\t\t\tVALUES('" . $result->parent_key . "','" . $user_key . "')";
                                    $tbleft = $wpdb->query($tbleft);
                                }
                            }
                            $parent_key = $result->parent_key;
                        } else {
                            $parent_key = '0';
                        }
                    }
                    //end while loop
                    if (isset($epin) && !empty($epin)) {
                        $sql = "update {$table_prefix}mlm_epins set user_key='{$user_key}', date_used=now(), status=1 where epin_no ='{$epin}' ";
                        // Update epin according user_key (19-07-2013)
                        $wpdb->query($sql);
                        if ($paymentStatus == 1) {
                            insert_refferal_commision($user_id, $sponsor, $user_key);
                        }
                    }
                    $chk = '';
                    $msg = "<span style='color:green;'>Congratulations! You have successfully Join MLM</span>";
                }
                //end most inner if condition
            } else {
                $error = "\n Sponsor does not exist in the system.";
            }
        }
        //end outer if condition
    }
    //end most outer if condition
    //if any error occoured
    if (!empty($error)) {
        $error = nl2br($error);
    }
    if ($chk != '') {
        include 'js-validation-file.html';
        ?>
        <?php 
        if ($current_user->roles[0] == 'mlm_user') {
            echo "Your are MLM user";
        } else {
            $_POST['firstname'] = get_user_meta($user_id, 'first_name', true);
            $_POST['lastname'] = get_user_meta($user_id, 'last_name', true);
            $_POST['email'] = $current_user->user_email;
            ?>
            <script>
                function checkspname() {
                    var spname = document.getElementById('sponsor').value;
                    if (spname == '') {
                        if (!confirm('Are you sure you do not know your Sponsor\'s username? Proceed without a Sponsor?')) {
                            return false;
                        }
                    }
                }
            </script>
            <span style='color:red;'><?php 
            echo $error;
            ?>
</span>
            <?php 
            if (isset($msg) && $msg != "") {
                echo $msg;
            }
            ?>
            <form name="frm" method="post" action="" onSubmit="checkspname()">			
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr><td colspan="2">&nbsp;</td></tr>

                    <tr>
                        <td><?php 
            _e('First Name', 'binary-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><input type="text" name="firstname" id="firstname" value="<?php 
            if (!empty($_POST['firstname'])) {
                _e(htmlentities($_POST['firstname']));
            }
            ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'firstname');" ></td>
                    </tr>

                    <tr><td colspan="2">&nbsp;</td></tr>

                    <tr>
                        <td><?php 
            _e('Last Name', 'binary-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><input type="text" name="lastname" id="lastname" value="<?php 
            if (!empty($_POST['lastname'])) {
                _e(htmlentities($_POST['lastname']));
            }
            ?>
" maxlength="20" size="37" onBlur="return checkname(this.value, 'lastname');"></td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td><?php 
            _e('Email Address', 'binary-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><input type="text" name="email" id="email" value="<?php 
            if (!empty($_POST['email'])) {
                _e(htmlentities($_POST['email']));
            }
            ?>
"  size="37" ></td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td><?php 
            _e('Sponsor Name', 'binary-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td>
                            <input type="text" name="sponsor" id="sponsor" value="<?php 
            if (!empty($_POST['sponsor'])) {
                _e(htmlentities($_POST['sponsor']));
            }
            ?>
" maxlength="20" size="37" onkeyup="checkReferrerAvailability12(this.value);">
                            <br /><div id="check_referrer"></div>
                        </td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td><?php 
            _e('Placement', 'binary-mlm-pro');
            ?>
 <span style="color:red;">*</span> :</td>
                        <td><?php 
            echo __('Left', 'binary-mlm-pro');
            ?>
 <input id="left" type="radio" name="leg" value="0" <?php 
            echo isset($led) && $leg == '0' ? 'checked="checked"' : '';
            ?>
 />
                            <?php 
            echo __('Right', 'binary-mlm-pro');
            ?>
<input id="right" type="radio" name="leg" value="1" <?php 
            echo isset($led) && $leg == '0' ? 'checked="checked"' : '';
            ?>
/>
                        </td>

                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr>
                        <td colspan="2"><input type="submit" name="submit" id="submit" value="<?php 
            _e('Submit', 'binary-mlm-pro');
            ?>
" /></td>
                    </tr>
                </table>
            </form>
            <?php 
        }
        ?>
	
        <?php 
    } else {
        _e($msg);
    }
}