<script type="text/javascript">
	$(document).ready(function(){
		
		$("#checkall").click(function(){
			if(this.checked){
				$(".check_class").attr("checked",true);					
			}else{
				$(".check_class").attr("checked",false);					
			}
		});
		
		$(".tablesorter").tablesorter({
			headers: {
				0: { sorter: false },
				8: { sorter: false },
				9: { sorter: false },
				10: { sorter: false }
			}
		});
		$(".tablesorter").tablesorterPager({container: $("#pager")}); 
	});
	
function change_status(user_id,status){

	showLoader(1);

	$.ajax({
	  url: "userlist.php",
	  data: 'act=change_status&user_id='+user_id+'&status='+status,
	  success: function(msg){
			showLoader(0);
		  	$(".info").html(msg);
		  	$("#status_msg").show();
		  	$("#status_msg").html(msg);
		  	
		  	if(status==0){
			  	$("#td_status_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_status('"+user_id+"','1')\" ><img src=\"images/publish.gif\" alt=\"Publish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}else{
			  	$("#td_status_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_status('"+user_id+"','0')\" ><img src=\"images/unpublish.gif\" alt=\"Unpublish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}
	  }
	});
}

function change_hstatus(user_id,status){

	showLoader(1);

	$.ajax({
	  url: "userlist.php",
	  data: 'act=change_hstatus&user_id='+user_id+'&status='+status,
	  success: function(msg){
			showLoader(0);
		  	$(".info").html(msg);
		  	$("#status_msg").show();
		  	$("#status_msg").html(msg);
		  	
		  	if(status==0){
			  	$("#td_hstatus_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_hstatus('"+user_id+"','1')\" ><img src=\"images/publish.gif\" alt=\"Publish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}else{
			  	$("#td_hstatus_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_hstatus('"+user_id+"','0')\" ><img src=\"images/unpublish.gif\" alt=\"Unpublish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}
	  }
	});
}
function change_pstatus(user_id,status){

	showLoader(1);

	$.ajax({
	  url: "userlist.php",
	  data: 'act=change_pstatus&user_id='+user_id+'&status='+status,
	  success: function(msg){
			showLoader(0);
		  	$(".info").html(msg);
		  	$("#status_msg").show();
		  	$("#status_msg").html(msg);
		  	
		  	if(status=='Free'){
			  	$("#td_pstatus_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_pstatus('"+user_id+"','Paid')\" ><img src=\"images/publish.gif\" alt=\"Publish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}else{
			  	$("#td_pstatus_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_pstatus('"+user_id+"','Free')\" ><img src=\"images/unpublish.gif\" alt=\"Unpublish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}
	  }
	});
}
function validate_all(){
	if($("#select_action").val()==''){
		$("#msg_select_action").html('Please Select action');
		$("#select_action").addClass('jquery_err');
		$("#select_action").focus();
		return false;
	}else{
		$("#msg_select_action").html('');
		$("#select_action").removeClass('jquery_err');
	}	

	if($(".check_class:checked").length == 0){
		$("#msg_select_action").html('Please Select atleast one checkbox');
		return false;
	}else{
		$("#msg_select_action").html('');
	}	
}
function change_hstatus(user_id,status){

	showLoader(1);

	$.ajax({
	  url: "paid_userlist.php",
	  data: 'act=change_hstatus&user_id='+user_id+'&status='+status,
	  success: function(msg){
			showLoader(0);
		  	$(".info").html(msg);
		  	$("#status_msg").show();
		  	$("#status_msg").html(msg);
		  	
		  	if(status==0){
			  	$("#td_hstatus_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_hstatus('"+user_id+"','1')\" ><img src=\"images/publish.gif\" alt=\"Publish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}else{
			  	$("#td_hstatus_"+user_id).html("<a href=\"javascript:void(0)\" onclick=\"change_hstatus('"+user_id+"','0')\" ><img src=\"images/unpublish.gif\" alt=\"Unpublish\" width=\"14\" height=\"15\" border=\"0\" /></a>");
		  	}
	  }
	});
}
</script>

<div id="content" class="box">
  <h1> Member &raquo; User List</h1>
  <?php if(isset($successMsg) && $successMsg!=''){ ?>
  <p class="msg done"><?php echo $successMsg; ?></p>
  <?php } ?>
  <?php if(isset($failedMsg) && $failedMsg!=''){ ?>
  <p class="msg error"><?php echo $failedMsg; ?></p>
  <?php } ?>
  <p id="status_msg" class="msg info" style="display:none">&nbsp;</p>
  <div class="loading_image" style="display:none"><img src="images/loading.gif" > </div>
  <form id="select_all_frm" name="select_all_frm" method="post" action="" onsubmit="return validate_all();">
    <table class="tablesorter" width="100%">
      <!-- Sort this TABLE -->
      <thead>
        <tr>
          <th width="3%" style="text-align:center"><input type="checkbox" id="checkall" name="checkall" >          </th>
          <th width="7%">Id No.</th>
          <th width="18%">Name</th>
          <th width="6%">Gender</th>
          <th width="9%">Cast</th>
          <th width="8%">Age</th>
          <th width="8%">Maritul Status</th>
          <th width="8%">Degree</th>
          <th width="9%">Status</th>
          <th width="7%">Payment Status</th>
          <th width="8%" style="text-align:center">On Homepage</th>
           <th width="9%" style="text-align:center">Registered IP</th>
          <th width="9%" style="text-align:center">Action</th>
        </tr>
      </thead>
      <tfoot>
        <tr class="bg">
          <td colspan="6" class="arrow-01" style="border-right:0px none"><select name="action_val" id="action_val" class="input-text">
              <?php if($DELETE_ACCESS && $EDIT_ACCESS){ ?>
              <option value="">Select Action</option>
              <option value="delete_all">Delete selected</option>
              <option value="activate_all">Activate selected</option>
              <option value="inactivate_all">Inactivate selected</option>
              <?php }else if($DELETE_ACCESS){ ?>
              <option value="">Select Action</option>
              <option value="delete_all">Delete selected</option>
              <?php } else if ($EDIT_ACCESS){ ?>
              <option value="activate_all">Activate selected</option>
              <option value="inactivate_all">Inactivate selected</option>
              <?php } ?>
            </select>
            &nbsp;
            <input type="submit" value="OK" id="submit" name="submit" />
            &nbsp; <span id="msg_select_action" class="message">&nbsp;</span> </td>
          <td colspan="6" class="arrow-01" style="border-left:0px none;text-align:right" ><div id="pager" class="pager"> <img src="images/first.png" class="first"/> <img src="images/prev.png" class="prev"/>
              <input type="text" disabled="disabled" class="pagedisplay"/>
              <img src="images/next.png" class="next"/> <img src="images/last.png" class="last"/>
              <select class="pagesize">
                <option selected="selected" value="20">20</option>
                <option value="50">50</option>
                <option  value="100">100</option>
                <option  value="150">150</option>
              </select>
            </div></td>
        </tr>
      </tfoot>
      <tbody>
        <?php if($userDetails && count($userDetails) > 0 ){ 
						foreach ($userDetails as $user){
						if($user->payment_status == 'Free'){
						  ?>
        <tr>
          <td class="t-center"><input type="checkbox" name="check[]" id="check[]" value="<?php echo $user->user_id; ?>" class="check_class" /></td>
          <td class="t-center"><?php echo $user->user_uniq_id;  ?></td>
          <td><?php if($EDIT_ACCESS){ ?>
            <a href="adduser.php?act=edit&user_id=<?php echo $user->user_id; ?>"><?php echo $user->user_name;  ?></a>
            <?php }else { ?>
            <?php echo $user->user_name;  ?>
            <?php } ?></td>
          <td><?php echo $user->gender;  ?></td>
          <td ><?php echo $user->user_cast ?></td>
          <td ><?php echo $user->age_in_year ?></td>
          <td ><span class="t-center"><?php echo $user->marital_status ?></span></td>
          <td><span class="t-center"><?php echo $user->last_degree ?></span></td>
          <td style="text-align:center" id="td_status_<?php echo $user->user_id ?>"><?php if($EDIT_ACCESS){ ?>
            <?php if($user->user_status=='1'){?>
            <a href="javascript:void(0)" onclick="change_status('<?php echo $user->user_id ?>','1')" ><img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" /></a>
            <?php }else{?>
            <a href="javascript:void(0)" onclick="change_status('<?php echo $user->user_id ?>','0')" ><img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" /></a>
            <?php }?>
            <?php }else{ ?>
            <?php if($user->user_status=='1'){?>
            <img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" />
            <?php }else{?>
            <img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" />
            <?php }?>
            <?php } ?>          </td>
            
          
          <td style="text-align:center" id="td_pstatus_<?php echo $user->user_id ?>"><?php if($EDIT_ACCESS){ ?>
            <?php if($user->payment_status=='Paid'){?>
            <a href="javascript:void(0)" onclick="change_pstatus('<?php echo $user->user_id ?>','Paid')" ><img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" /></a>
            <?php }else{?>
            <a href="javascript:void(0)" onclick="change_pstatus('<?php echo $user->user_id ?>','Free')" ><img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" /></a>
            <?php }?>
            <?php }else{ ?>
            <?php if($user->payment_status=='Paid'){?>
            <img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" />
            <?php }else{?>
            <img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" />
            <?php }?>
            <?php } ?>          </td>
            <td style="text-align:center" id="td_hstatus_<?php echo $user->user_id ?>"><?php if($EDIT_ACCESS){ ?>
            <?php if($user->on_home_page=='1'){?>
            <a href="javascript:void(0)" onclick="change_hstatus('<?php echo $user->user_id ?>','1')" ><img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" /></a>
            <?php }else{?>
            <a href="javascript:void(0)" onclick="change_hstatus('<?php echo $user->user_id ?>','0')" ><img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" /></a>
            <?php }?>
            <?php }else{ ?>
            <?php if($user->user_status=='1'){?>
            <img src="images/publish.gif" alt="Publish" width="14" height="15" border="0" />
            <?php }else{?>
            <img src="images/unpublish.gif" alt="Publish" width="14" height="15" border="0" />
            <?php }?>
            <?php } ?>          </td>
             <td class="t-center"><?php echo $user->user_ip_address ?></td>
          <td class="t-center"><?php if($EDIT_ACCESS){ ?>
            <a href="adduser.php?act=edit&user_id=<?php echo $user->user_id; ?>"><img src="images/edit.png" alt="Edit Record" border="0" /></a>
            <?php } ?>
            <a href="changempassword.php?status=1&user_id=<?php echo $user->user_id; ?>"><img src="images/cpassword.gif" alt="Change Password"  border="0" title="Change Password" /></a>
            <?php if($DELETE_ACCESS){ ?>
            <a onclick="javascript:if(confirm('Are you sure to delete ? ')){location.href='userlist.php?act=delete&user_id=<?php echo $user->user_id; ?>'}"><img src="images/delete.gif" alt="Delete Record"  border="0" /></a>
            <?php } ?>          </td>
        </tr>
        <?php 
						}} }else{ ?>
        <tr>
          <td colspan="12" align="center">No record Found</td>
        </tr>
        <?php } ?>
      </tbody>
    </table>
  </form>
</div>
<!-- /content -->
