<?php
	include "admin_top_menu.php";
	include "admin_side_menu.php";
	
	if($temp_id = isset($_GET['temp_id']) ? $_GET['temp_id'] : '')
	{
	   $row=mysqli_query($conn,"SELECT * FROM `color` WHERE cid='$temp_id'");
		$data=mysqli_fetch_array($row);
	}
	else{
		$data['cid']="";
		$data['cname']="";
		$data['hex']="";
		$data['cstatus']="";
	}
?>
  
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Color
        <small>Color List</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Color</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
	<form name="frmcolor" action="code.php" method="post" enctype="multipart/form-data">
      <!--<div class="panel-body" align="right">
        <a href="" data-toggle="tooltip" class="btn btn-primary btn-md"><i class="fa fa-book"></i> Create Category</a>
      </div>-->
	  <div class="box box-info">
        <div class="box-header with-border">
          <h3 class="box-title">Color List</h3>
		  
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
          </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <div class="row">
            <div class="col-md-4">
              <div class="form-group">
                <label>Color Name</label>
				        <input type="hidden" name="txt_cid" value="<?php echo $data['cid'];?>">
                <input type="text" class="form-control" name="txt_cname" value="<?php echo $data['cname'];?>" required="" >
              </div>
            </div>
			
			     <div class="col-md-4">
              <div class="form-group">
                <label>Hex Color</label>
                <input type="text" class="form-control" name="txt_hex" value="<?php echo $data['hex'];?>" required="" >
              </div>
            </div>
			
			     <div class="col-md-4">
              <div class="form-group">
                <label>Status</label>
          				<select class="form-control" name="txt_cstatus">
          					<option value="<?php echo $data['cstatus'];?>"><?php echo $data['cstatus'];?></option>
          					<option value="Active">Active</option>
          					<option value="Deactive">Deactive</option>
          				</select>
              </div>
            </div>
			
		  </div>
		</div>
		
		<div class="box-footer">
		<?php if($data['cid']==''){ ?>
            <button type="submit" name="btn_csubmit" class="btn btn-info pull-right">Submit</button>
		<?php } else {?>
			<button type="submit" name="btn_cupdate" class="btn btn-info pull-right">Update</button>
		<?php } ?>
        </div>
	</div>
		<?php   
			if(isset($_GET['status'])&&$_GET['status']==1)
			echo "<font color=green>Data Successfully Insert..</font>";
				
			if(isset($_GET['status'])&&$_GET['status']==2)
			echo "<font color=green>Data Successfully Update..</font>";
				
			if(isset($_GET['status'])&&$_GET['status']==3)
			echo "<font color=red>Wrong click...</font>";   
		?>
	</form>
	

        <div class="box">
            <div class="box-header">
              <h3 class="box-title">Color List</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>Id</th> 
				  <th>Color Name</th> 
				  <th>Hex Color</th>
				  <th>Status</th> 
				  <th>Edit</th> 
				  <th>Delete</th> 
                </tr>
                </thead>
                <tbody>
                  <?php 
					$qry=mysqli_query($conn,"SELECT * FROM `color`")or die(mysqli_error($conn));
					$count=1;
					while($row=mysqli_fetch_array($qry))
					{?>
                    <tr>
						<td><?php echo $count++;?></td>
						<td><?php echo $row['cname'];?></td>
						<td><button class="btn btn-lg" style="background-color: <?php echo $row['hex'];?>"></button></td>
						<td><?php echo $row['cstatus'];?></td>
						<td><?php echo "<a href='color.php?temp_id=".$row['cid']."'><i class='fa fa-edit fa-fw'></i></a>"; ?> </td>
						<td><?php echo "<a href='delete_code.php?dc_id=".$row['cid']."' onClick=\"javascript:return confirm('are you sure you want to delete this?');\"><i class='fa fa-times fa-fw'></i></a>"; ?></td>
					</tr>              
             <?php  } ?>
                </tbody>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->


<?php
	include "admin_footer.php";
?>
