<?php 
session_start();
ob_start();
include("../../pidbco/pidbjoin.php");
$sujpath="./";
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Projects</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>font-awesome/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="<?php echo $sujpath; ?>dist/css/skins/_all-skins.min.css">
   
    
    <script>
    function add_business(){
             var buscat = $('#buscat').val();
             var busststaus = $('#busststaus').val();
            
             if(buscat == ''){
                alert("Enter Business Category");   	
             }  else {                    
                  $.ajax({
                    type: "POST",
                    url: "ajaxmarket.php",
                     data: {
                          add_new_business: 1,
                          buscat          : buscat,
                          busststaus      : busststaus
                     },
                     cache: true,
                     success: function(res23)
                     {
                     	$('#buscat').val('');
                        $("#marketingdiv123").load("business.php #marketingdiv123");
                        datat2();                        
                      }
                   }); 
    	    }
    		
    }


    	
    	
   function edit_bus_cat()
   {
         var buscat = $('#buscat').val();
         var busststaus = $('#busststaus').val();
         var hidvall = $('#hidvall').val();
            
             if(buscat == ''){
                alert("Enter Business Category");   	
             }  else {                    
                  $.ajax({
                    type: "POST",
                    url: "ajaxmarket.php",
                     data: {
                          edit_business_cat: 1,
                          buscat          : buscat,
                          busststaus      : busststaus,
                          hidvall         : hidvall
                     },
                     cache: true,
                     success: function(res23)
                     {
                     	$('#buscat').val('');
                        $("#marketingdiv123").load("business.php #marketingdiv123"); 
                        datat3();                       
                      }
                   }); 
    	    }

        }
        
        
    	
    	    	
    	function delete_business(id)
    	{
    		var result = confirm("Want to delete?");
			if (result) 
			{
     		$.ajax({
			type: "POST",
			url: "ajaxmarket.php",
			data: {
			btn_delete_business: 1,
			id:id
			},
			cache: true,
			success: function(res)
			{
			      $("#marketingdiv123").load("business.php #marketingdiv123");
			      datat();
         	
			}  
			});
   			}
    	}
    	
    	
    	function edit_business(id)
    	{
    		$.ajax({
			type: "POST",
			url: "ajaxmarket.php",
			data: {
			btn_edit_bus: 1,
			id:id
			},
			cache: true,
			success: function(res)
			{
			
	         	$("#marketingdiv2").load("business.php?idd2="+id+" #marketingdiv2"); 	
			}  
			});
    	}
    </script>
    
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
     <div class="wrapper">
  <?php include("head.php");
    include("left.php"); ?> 
	 
      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper" >
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1> Business Category
          	<small>- Control panel</small>
          	</h1>
          <ol class="breadcrumb">
            <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
            <li class="active">Business Category</li> 
          </ol>
        </section>
  <!-- Main content -->
        <section class="content" >
          <div class="row" >
            <div class="col-xs-12" >





   <div class="box-body" id="marketingdiv2">
 <?php

    if(empty($_GET)){
        
      //$idd2 = strip_tags(base64_decode($_GET['idd2']));
      $business1='';
      $bstatus1='';
      }else{
      $idd2 = strip_tags(base64_decode($_GET['idd2']));
	    $sq = mysqli_query($con, "SELECT * FROM `p_business` WHERE `bid`='$idd2' " );
	    $rs = mysqli_fetch_assoc($sq);
      $bstatus1=$rs['bstatus'];	
      $business1= $rs['b_business'];
      } 
?>	  	
			  	
	<div class="box-body" >
 


<div class="row" >	
<div class="col-md-12" style="" >
	
		
<div class="col-md-3"  style="padding-left:2px;padding-right: 0px; ">			
<div class="form-group">
  <input type="text" name="buscat" id="buscat" class="form-control" placeholder="Business Category" value="<?php echo $business1; ?>" />	 
</div></div>


<div class="col-md-3" style="padding-left:2px;padding-right: 0px; ">					
<div class="form-group">
    <select class="form-control" id="busststaus" name="busststaus">
      <option value="1" <?php if($bstatus1 == '1'){ ?> selected <?php } ?>>Active</option>
      <option value="0" <?php if($bstatus1 == '0'){ ?> selected <?php } ?>>InActive</option>
    </select>
</div></div>



<div class="col-md-3"  style=" padding-left: 2px; padding-right: 0px; ">				
<div class="form-group">
  <?php if(!empty($_GET)){ ?>
	<input type="hidden" name="hidvall" id="hidvall" value="<?php echo $rs['bid']; ?>" />
<input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Update" onclick="edit_bus_cat();" style=" float: right; 
margin-right: 20px; " /> 

<?php } else { ?>
<input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Submit" onclick="add_business();" style=" float: right; 
margin-right: 20px; " />	
<?php } ?> 
</div></div>

</div>




</div>



	
	

</div>
  </div>
  
  
  
  
  
  
<div id="marketingdiv123">
	
<div class="box" >
   <div class="box-body" style="padding-left: 10px;padding-right: 10px" >
        <div class="box-body table-responsive no-padding" >
   
                  <table id="example1" class="table table-bordered table-striped" >
                    <thead >
                    <tr >
<th>#</th>                    	
<th>Business Category</th>
<th>Status</th>
<th></th>
</tr>
                    </thead>
                    <tbody>
 <?php 
    $sql2 = mysqli_query($con,"SELECT * FROM `p_business` ORDER BY bid DESC ");
	$k=1;
    while($res2 = mysqli_fetch_assoc($sql2)) { 
   ?>
 <tr>
 	<td><?php echo $k; ?></td>
 	<td><?php echo $res2['b_business']; ?></td>
 	<td><?php if($res2['bstatus'] == '1'){ echo "Active"; } else { echo "InActive"; } ?></td>
 	<td><a onClick="edit_business('<?php echo base64_encode($res2['bid']); ?>');" style=" cursor: pointer;" ><span class="fa fa-pencil" style="font-size:14px;"></span></a> &nbsp; &nbsp;
    <a onClick="delete_business('<?php echo base64_encode($res2['bid']); ?>');" style=" cursor: pointer;" ><span class="fa fa-trash-o" style="font-size:14px;"></span></a> &nbsp;	
    </td>
 </tr>

 <?php $k=$k+1; } ?>
                    </tbody>
                    </table>
  
         		  </div>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
	
	
</div>
	
		
			
			
			








                           
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
  </div><!-- /.content-wrapper -->
  </div>
 <!-- jQuery 2.1.4 -->
    <script src="<?php echo $sujpath; ?>plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="<?php echo $sujpath; ?>bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
	<script src="<?php echo $sujpath; ?>plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo $sujpath; ?>plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="<?php echo $sujpath; ?>plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="<?php echo $sujpath; ?>plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo $sujpath; ?>dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<?php echo $sujpath; ?>dist/js/demo.js"></script>
    <!-- page script -->
    
  <script type="text/javascript">
    function PreviewImage(no) {
    	var oFReader = new FileReader();
        oFReader.readAsDataURL(document.getElementById("uploadImage"+no).files[0]);
        oFReader.onload = function (oFREvent) {
            document.getElementById("uploadPreview"+no).src = oFREvent.target.result;
        };
    }
</script>

<style>
label.filebutton {
    width:120px;
    height:80px;
    overflow:hidden;
    position:relative;
}
label span input {
    z-index: 999;
    line-height: 0;
    font-size: 50px;
    position: absolute;
    top: -2px;
    left: -700px;
    opacity: 0;
    filter: alpha(opacity = 0);
    -ms-filter: "alpha(opacity=0)";
    cursor: pointer;
    _cursor: hand;
    margin: 0;
    padding:0;
}
</style>



    <script>
      $(document).ready(function() {
        $("#example1").DataTable();
      });
      
	function datat(){
	  alert("Data Deleted Successfully.");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
    function datat2(){
	  alert("Data Added Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
    function datat3(){
	  alert("Updated Successfully");
      $(document).ready(function() {
        $("#example1").DataTable();
       
      });
    }
   </script>  
   
   
   
  </body>
</html>
