<?php
$user_id=$this->session->userdata('user_id');
//echo $user_id;
?>
<div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h3 class="page-header">Competitor List</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 }  
							if($_GET['id'])
							{
								$id=$_GET['id'];
								//echo $id;
								$sql="select * from competitor where id='$id'";
								$r=$this->db->query($sql);
								$rr=$r->result_array();
					//	print_r($rr);
									$brand=$rr[0]['brand'];
									//echo $brand;
							?>
						<form role="form" action="<?php echo site_url();?>admin/Dashboard/update_compitator" 
						method="post" role="form" class="form-horizontal">
							<input type="hidden" name="id" value="<?=$id?>">
							<div class="form-group">
								<label class="control-label col-md-2">Competitor :<font color="red">*</font></label>
								<div class="col-md-4">
								<input type="text" required name="brand" value="<?php echo set_value('brand')?set_value('brand'):$brand?>" 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/Dashboard/save_compitator" method="post" role="form" class="form-horizontal">
									<div class="form-group">
										<label class="control-label col-md-2">Competitor :<font color="red">*</font></label>
										<div class="col-md-4">
										<input type="text" required name="brand" value="<?php echo set_value('brand')?set_value('brand'):'';?>" 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>Competitor</th>
				<th>Edit</th>                
				<th>Delete</th>                
            </tr>
        </thead>
        <tbody>
		
<?php 

foreach($competitor as $r)
{
	
?>							
					<tr class="gradeX">
					<td><?php echo $r['brand']?></td>
            <?php
            if($user_id=='2')
            {
            ?>
				<td><a href="<?php echo site_url();?>admin/Dashboard/competitor?id=<?=$r['id']?>" title="Edit" class="btn btn-primary btn-circle"><i class="fa fa-pencil" aria-hidden="true"></i></td>

					<td><a href="<?php echo site_url();?>admin/Dashboard/delete_competitor/<?=$r['id']?>" title="Delete" class="btn btn-danger btn-circle"><i class="fa fa-trash" aria-hidden="true"></i></td>
			<?php
            }
            else
            {
                ?>
	<td><a href="#" title="Edit" class="btn btn-default btn-circle"><i class="fa fa-pencil" aria-hidden="true"></i></td>

					<td><a href="#" title="Delete" class="btn btn-default btn-circle"><i class="fa fa-trash" aria-hidden="true"></i></td>
                <?php
            }
            ?>
           
					</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',
        "pageLength": 50,
        "order": [[ 1, "desc" ]],
        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>
