<?php 
session_start();
ob_start();
include("../../pidbco/pidbjoin.php");
if(!isset($_SESSION['franchiseelogin']['user_name'])){
	header("Location : index.php");
}
$sujpath="./";
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php echo $pageTitle; ?></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 testi_top(){
      var tname = $('#tname').val();
      var tdesign = $('#tdesign').val();
      var testimonial = $('#testimonial').val();
      var testimonial_add =1;
      var input = document.getElementById("uploadImage1");
      file = input.files[0];
      if(file != undefined){
      formData= new FormData();
      if(!!file.type.match(/image.*/)){
      formData.append("image", file);
      formData.append("testimonial_add", testimonial_add);
      formData.append("tname", tname);
      formData.append("tdesign", tdesign);
      formData.append("testimonial", testimonial);
      
        $.ajax({
        url: "ajaxmarket.php",
        type: "POST",
        data: formData,
        processData: false,
        contentType: false,
        cache: false,
        success: function(data){
        	$('#tname').val('');
        	$('#tdesign').val('');
        	$('#testimonial').val('');
        	$("#marketingdiv2").load("testimonials.php #marketingdiv2");
            $("#marketingdiv123").load("testimonials.php #marketingdiv123");
           datat2();
        }
     });   
   		
    }else{
      alert('Not a valid image!');
    }
  }else{
    alert('Please Enter Values');
  }  
    		
 }


    	
    	
   function edit_testi_top()
   {
      var tname = $('#tname').val();
      var tdesign = $('#tdesign').val();
      var testimonial = $('#testimonial').val();
      var hidvall = $('#hidvall').val();
      var testimonial_edit =1;
      var input = document.getElementById("uploadImage1");
      file = input.files[0];
     // if(file != undefined){
      formData= new FormData();
      //if(!!file.type.match(/image.*/)){
      formData.append("image", file);
      formData.append("testimonial_edit", testimonial_edit);
      formData.append("tname", tname);
      formData.append("tdesign", tdesign);
      formData.append("testimonial", testimonial);
      formData.append("hidvall", hidvall);
      
        $.ajax({
        url: "ajaxmarket.php",
        type: "POST",
        data: formData,
        processData: false,
        contentType: false,
        cache: false,
        success: function(data){
        	$('#tname').val('');
        	$('#tdesign').val('');
        	$('#testimonial').val('');
        	$("#marketingdiv2").load("testimonials.php #marketingdiv2");
            $("#marketingdiv123").load("testimonials.php #marketingdiv123");
           datat3();
        }
     });   
   		
   /*  }else{
      alert('Not a valid image!');
    }
  }else{
    alert('Please Enter Values');
  }   */ 

        }
        
        
    	
    	    	
    	function delete_testi(id)
    	{
    		var result = confirm("Want to delete?");
			if (result) 
			{
     		$.ajax({
			type: "POST",
			url: "ajaxmarket.php",
			data: {
			btn_delete_testi : 1,
			id:id
			},
			cache: true,
			success: function(res)
			{
			      $("#marketingdiv123").load("testimonials.php #marketingdiv123");
			      datat();
         	
			}  
			});
   			}
    	}
    	
    	
    	function edit_testi(id)
    	{
    		$.ajax({
			type: "POST",
			url: "ajaxmarket.php",
			data: {
			btn_edit_market: 1,
			id:id
			},
			cache: true,
			success: function(res)
			{
			
	         	$("#marketingdiv2").load("testimonials.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>Testimonial
          	<small>- Control panel</small>
          	</h1>
          <ol class="breadcrumb">
            <li><a href="dash_board.php"><i class="fa fa-dashboard"></i> Home</a></li>
            <li class="active">Testimonial</li> 
          </ol>
        </section>
<?php
if(isset($_SESSION['SUCMSG'])){
	echo $_SESSION['SUCMSG'];
	unset($_SESSION['SUCMSG']);
}
?>     <!-- Main content -->
        <section class="content" >
          <div class="row" >
            <div class="col-xs-12" >





   <div class="box-body" id="marketingdiv2">
<?php
      $idd2 = strip_tags(base64_decode($_GET['idd2']));
	  $sql2= $db_con->prepare("SELECT * FROM `gtestimonial` WHERE `tid`='$idd2' ");
      $sql2->execute();
	  $resul2=$sql2->fetch(PDO::FETCH_ASSOC);	  
?>	  	
			  	
	<div class="box-body" >
	
<div class="col-md-12" style="" >
	
<div class="col-md-6"  style=" padding-left: 2px; padding-right: 0px; ">					
<div class="form-group">
	<input type="text" name="tname" id="tname" class="form-control" placeholder="Name" value="<?php echo $resul2['tname']; ?>"/>	
</div></div>
	
 <div class="col-md-6" >					
  <div class="form-group">
<input type="text" name="tdesign" id="tdesign" class="form-control" placeholder="Designation" value="<?php echo $resul2['tdesign']; ?>" />
 </div></div>			

</div>	




<div class="col-md-12" style="" >
<div class="col-md-6"  style=" padding-left: 2px; padding-right: 0px; ">					
<div class="form-group">
   <textarea name="testimonial" id="testimonial" class="form-control" style="height: 90px; " placeholder="Testimonial"><?php echo $resul2['tcomment']; ?></textarea>
</div></div>


<div class="col-md-6"  style=" padding-left: 2px; padding-right: 0px; ">					
<div class="form-group">
	
	
    <div style=" float: left; width:120px; margin-left: 15px; ">
		   	<img src="mainimg.png" />
	</div> 	&nbsp; &nbsp;
	<div style=" float: left; width:80px; margin-left: 15px;">
		   	<label class="filebutton" >
		   	<?php if($resul2['tpic'] != ''){ ?>
		   	<img id="uploadPreview1" src="../images/testimonial/<?php echo $resul2['tpic']; ?>" style="width:65px;" /><br />	
		   	<?php } else { ?> 	
		    <img id="uploadPreview1" src="noimage.png" style="width:85px; height:70px;" /><br />
		    <?php } ?> 
			<span><input id="uploadImage1" type="file" name="uploadImage1" onchange="PreviewImage(1);" /></span>
			</label>
	</div>
		   
<?php if($idd2 != ''){ ?>
	<input type="hidden" name="hidvall" id="hidvall" value="<?php echo $resul2['tid']; ?>" />
<input type="submit" class="btn btn-primary" name="frasubmit" id="frasubmit" value="Update" onclick="edit_testi_top();" style=" float: right; 
margin-right: 20px; " /> 

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

 
</div></div>


</div>



	
	

</div>
  </div>
  
  
  
  
  
  
<div id="marketingdiv123">


<div class="box" >
   <div class="box-body" >
        <div class="box-body table-responsive no-padding" >
   
  	                 	
                  <table id="example1" class="table table-bordered table-striped" >
                    <thead >
                    <tr >
                    <th>#</th>                    	
<th>Photo</th>
<th>Name</th>
<th>Designation</th>

<th></th>
</tr>
                    </thead>
                    <tbody>
<?php 
    $sqnw = $db_con->prepare("SELECT * FROM `gtestimonial` ");
	$sqnw->execute();
	$n=1;
	while($rst = $sqnw->fetch(PDO::FETCH_ASSOC)){
    ?>                	
 
 <tr>
 	<td><?php echo $n; ?></td>
 	<td><img src="../images/testimonial/<?php echo $rst['tpic']; ?>" height="50" width="50" ></td>
 	
 	<!--<td>
 	<?php $addcount=strlen($rst['nw_news']);
    if($addcount <= 80) { echo substr($rst['nw_news'], 0, 80);  } else {  echo substr($rst['nw_news'], 0, 80); echo '..';}?>	
 	</td> -->
 	<td><?php echo $rst['tname']; ?></td>
 	<td><?php echo $rst['tdesign']; ?></td>
 	<td>
 	<a onClick="edit_testi('<?php echo base64_encode($rst['tid']); ?>');" style=" cursor: pointer;" ><span class="fa fa-pencil" style="font-size:14px;"></span></a> &nbsp; &nbsp;
    <a onClick="delete_testi('<?php echo base64_encode($rst['tid']); ?>');" style=" cursor: pointer;" ><span class="fa fa-trash-o" style="font-size:14px;"></span></a> &nbsp;	
 	</td>
 </tr>
 <?php $n=$n+1; } ?>
                    </tbody>
                    </table>
  
         		  </div>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
	
	
</div>
	
		
			
			
			








                           
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
  </div><!-- /.content-wrapper -->
  </div>
	<!-- <?php include("footer.php"); ?> -->
 <!-- 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>
