<div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h3 class="page-header">User Management</h3>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                       <!--    <a href="<?php echo site_url();?>admin/Company/user_add" class="btn btn-info"> Add User</a>-->
                    <div class="panel panel-default">
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <?php $success_message = $this->session->flashdata('success_message');
                            if (!empty($success_message)) {?>
                                <div class="alert alert-success">
                                      <a class="close" data-dismiss="alert" href="components-popups.html#" aria-hidden="true">×</a>
                                      <strong><?php echo $this->session->flashdata('success_message');  ?></strong>
                                </div> 
                            <?php }  ?>
                            <?php $failure_message = $this->session->flashdata('failure_message');
                            if (!empty($failure_message)) {?>
                                <div class="alert alert-warning">
                                      <a class="close" data-dismiss="alert" href="components-popups.html#" aria-hidden="true">×</a>
                                      <strong><?php echo $this->session->flashdata('failure_message');  ?></strong>
                                </div> 
                            <?php }  ?>
							
									<?php
					if($_GET['id'])
					{
					$id=$_GET['id'];
					$sql="select * from user where id='$id'";
					$r=$this->db->query($sql);
					$rr=$r->result_array();
					//print_r($rr);
					?>
						<form role="form" action="<?php echo site_url();?>admin/User/update_user" method="post" role="form" class="form-horizontal">
						<input type="hidden" value="<?=$id?>" name="id">
						<div class="form-group">
							<label class="control-label col-md-2">User name :<font color="red">*</font></label>
							<div class="col-md-3">
							<input type="text" required name="user" value="<?php echo set_value('user')?set_value('user'):$rr[0]['user'];?>" class="form-control">
							</div>
							<label class="control-label col-md-2">Password :<font color="red">*</font></label>
							<div class="col-md-3">
							<input type="text" required name="password" value="<?php echo set_value('password')?set_value('password'):$rr[0]['password']?>" class="form-control">
							</div>
							<div class="col-md-2">
								<button id="signupSubmit" type="submit" class="btn btn-warning btn-block">Submit</button>
							</div>
						</div>
						</form>
				<?php
					}
					else
					{
						
					?>

					<form role="form" action="<?php echo site_url();?>admin/User/save_user" method="post" role="form" class="form-horizontal">
				

						<div class="form-group">
							<label class="control-label col-md-2">User name :<font color="red">*</font></label>
							<div class="col-md-3">
							<input type="text" required name="user" value="<?php echo set_value('user')?set_value('user'):'';?>" class="form-control">
							</div>
							<label class="control-label col-md-2">Password :<font color="red">*</font></label>
							<div class="col-md-3">
							<input type="text" required name="password" value="<?php echo set_value('password')?set_value('password'):''?>" class="form-control">
							</div>
							<div class="col-md-2">
								<button id="signupSubmit" type="submit" class="btn btn-warning btn-block">Submit</button>
							</div>
						</div>
						
					
					</form>
					<?php
					}
					?>
           <div style="overflow-x:auto;">
              
     <table id="example1" class="table table-striped table-bordered responsive">
        <thead>
            <tr>
				<th>Username</th>
				<th>Password</th>				
				<th>Edit</th>                
				<th>Action</th>                
            </tr>
        </thead>
        <tbody>
			  
<?php 

foreach($category_info as $r)
{
?>							
					<tr class="gradeX">
					<td><?php echo $r['user']?></td>
					<td><?php echo $r['password']?></td>
					<td><a href="<?php echo site_url();?>admin/User/user_list?id=<?=$r['id']?>" title="Edit Product" class="btn btn-primary btn-circle"><i class="fa fa-pencil" aria-hidden="true"></i></td>
					<td><a href="<?php echo site_url();?>admin/User/delete_user/<?php echo $r['id']?>/<?php echo $r['status']?>"  class="btn ">
					<?php
					if($r['status']=='block')
					{
						echo '<font color="red">Block</font>';
					}
					else
					{
						echo '<font color="green">Active</font>';
					}
					?>
					</td>
					</tr>
<?php
}

?>			
             
        </tbody>
    </table>
	</div>
	
	    <link href="<?php echo site_url();?>assets/css/jquery.dataTables.min.css" rel="stylesheet">
	    <link href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css" rel="stylesheet">
    
	<script src="//code.jquery.com/jquery-1.12.4.js"></script> 
	<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> 
	<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script> 
	<script src="//cdn.datatables.net/buttons/1.4.2/js/buttons.flash.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script> 
	<script src="//cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script> 
	<script src="//cdn.datatables.net/buttons/1.4.2/js/buttons.print.min.js"></script> 

	<script>
$(document).ready(function() {
    $('#example1').DataTable( {
        dom: 'Bfrtip',
		"paging": false
        buttons: [
             'csv', 'excel'
        ]
    } );
} );			
	</script>              
                          
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->            
        </div>
        <!-- /#page-wrapper -->

<!-- DataTables JavaScript -->
   <script type="text/javascript">
$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'T<"clear">lfrtip',
        tableTools: {
            "sSwfPath": "../js/datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
        }
    } );
} );

</script>
<script>
function doconfirm()
{
    job=confirm("Are you sure to delete permanently?");
    if(job!=true)
    {
        return false;
    }
}
</script>
