<?PHP

ob_start();

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysqli_query($conn,"select * from admin where username='$user'");

$gtp1=mysqli_fetch_assoc($gtp);



include 'top.php';

?>





<div id="page-wrapper" >
          <div id="page-inner">

			<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

								<i class="ace-icon fa fa-home home-icon"></i>

								<a href="#">Home</a>

							</li>

							<li class="active">KPI</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");

$aca1=mysqli_fetch_assoc($aca);



$financial=$aca1['financial'];



?>                        

                        

					<table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								KPI

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

                            </td></tr></table>

                            

						</div><!-- /.page-header -->



						<div class="row">

							<div class="col-xs-12">

                            

								<!-- PAGE CONTENT BEGINS -->



<script src="assets/js/jquery-2.1.4.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
<script>
    $(function() {
        // Initialize the datepicker
        $("#datepicker").datepicker({
            format: "mm/dd/yyyy",
            autoclose: true,
            todayHighlight: true
        });

        // Adjust the positioning of the datepicker dropdown
        $("#datepicker").on("show", function(e) {
            var inputOffset = $(this).offset();
            var inputHeight = $(this).outerHeight();
            var datepickerDropdown = $(".datepicker-dropdown");

            datepickerDropdown.css({
                top: inputOffset.top + inputHeight + 10,
                left: inputOffset.left
            });
        });
    });
</script>
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css">
  <style>
    /* Custom CSS for Chosen select */
    .chosen-container {
      width: 25ch;
    }

    .chosen-container-single .chosen-single {
      border-radius: 4px;
      border: 1px solid #f0f0f0; /* Change the border color here */
      height:34px;
	  margin-bottom:10px;
      background-color: #fff;
      background-image: none;
      box-shadow: 0 0 0 1px #c0c0c0;
    }

    .chosen-container-single .chosen-single span {
      padding: 5px;
      text-transform: uppercase;
    }

    .chosen-container-single .chosen-search input[type="text"] {
      border-radius: 4px;
      border: 1px solid #c0c0c0;
      height: 34px;
    }

    .chosen-container-active .chosen-single {
      border-color: #7f7f7f;
      box-shadow: 0 0 0 1px #7f7f7f;
    }

    .chosen-container-active .chosen-single:hover {
      border-color: #7f7f7f;
      box-shadow: 0 0 0 1px #7f7f7f;
    }

    .chosen-container-active .chosen-search input[type="text"] {
      border-color: #7f7f7f;
    }
  </style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
<script>
  $(document).ready(function() {
    $(".chosen-select").chosen({
      width: '100%',
      disable_search_threshold: 10
    });

    $(".chosen-select").change(function() {
      var empName = $(this).find('option:selected').text();
      $(this).closest('td').next().find('.emp').val(empName);
    });
  });
</script>
<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#course').submit(function(){

		

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		

		$('.' + errorcn, this).remove();			

		

		$('#required', this).each(function(){

			var parent = $(this).parent();

			if( $(this).val() == '' ){

				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		

		return valid;

		

		$('input:submit').prop('disabled', true);

		

	});

	

});	



</script>







<?php



if(isset($_POST['submit']))

{

	

	$employee=$_POST['employee'];

	$date=$_POST['date'];

	$attendance=$_POST['attendance'];

	$socialmedia=$_POST['socialmedia'];

	$crmupdate=$_POST['crmupdate'];

	$businessconversation=$_POST['businessconversation'];

	$deliveryfeedback=$_POST['deliveryfeedback'];

	$productfeedback=$_POST['productfeedback'];

	$nocalls=$_POST['nocalls'];

	$paymentcollection=$_POST['paymentcollection'];

	$tds=$_POST['tds'];

	$customerretention=$_POST['customerretention'];

	

	$date=date('Y-m-d',strtotime($date));

	

	$ll=mysqli_query($conn,"insert into kpi(employee,date,attendance,socialmedia,crmupdate,businessconversation,deliveryfeedback,productfeedback,nocalls,paymentcollection,tds,customerretention) values('$employee','$date','$attendance','$socialmedia','$crmupdate','$businessconversation','$deliveryfeedback','$productfeedback','$nocalls','$paymentcollection','$tds','$customerretention')") or die(mysqli_error($conn));

	

	if($ll)

	{

		header("location:kpi.php?s=1");

	}

	else

	{

		header("location:kpi.php?s=2");

	}

	

}

else

{

	

	if(isset($_GET['s']))

	{

	 $status=$_GET['s'];

		

		 if($status=='1')

		 {

			 echo'<div class="alert alert-block alert-success">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Values inserted successfully.

				  </div>';

		 }

		 if($status=='2')

		 {

			 echo'<div class="alert alert-block alert-danger">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Values not inserted. Please try again.

				  </div>';

		 }

	}

	

	echo"<center><form action='kpi.php' method='post'>

	

	<table style='margin:auto; line-height:35px;'>

	

	<tr><td>Employee</td><td style='padding:0 7px;'></td><td><select  name='employee' class='chosen-select'><option value=''>-- Select --</option>";

	

	$sll=mysqli_query($conn,"select * from employee order by ID asc");

	while($sll1=mysqli_fetch_assoc($sll))

	{

		echo"<option value='".$sll1['ID']."'>".$sll1['name']."</option>";

	}

	

	echo"</select></td></tr>

	

	<t><td>Date</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='date' id='datepicker' autocomplete='off' /></td></tr>

	

	<t><td>Attendance</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='attendance' autocomplete='off' /></td></tr>

	

	<t><td>Social Media</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='socialmedia' autocomplete='off' /></td></tr>

	

	<t><td>CRM Update</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='crmupdate' autocomplete='off' /></td></tr>

	

	<t><td>Business Convesation</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='businessconversation' autocomplete='off' /></td></tr>

	

	<t><td>Delivery Feedback</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='deliveryfeedback' autocomplete='off' /></td></tr>

	

	<t><td>Product Feedback</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='productfeedback' autocomplete='off' /></td></tr>

	

	<t><td>No Calls</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='nocalls' autocomplete='off' /></td></tr>

	

	<t><td>Payment Collection</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='paymentcollection' autocomplete='off' /></td></tr>

	

	<t><td>TD 6S</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='tds' autocomplete='off' /></td></tr>

	

	<t><td>Customer Retention</td><td style='padding:0 7px;'></td><td><input class='form-control' style='width: 30ch; margin-bottom:10px' type='text' name='customerretention' autocomplete='off' /></td></tr>

	

	</table>

	

	<button type='submit' class='btn btn btn-primary' name='submit' value='Submit'>Submit</button>

	

	</form></center>";

	

}



?>







										<!-- PAGE CONTENT ENDS -->

									</div><!-- /.col -->

								</div><!-- /.row -->

							</div><!-- /.page-content -->

						</div>

					</div><!-- /.main-content -->
					</div><!-- /.main-content -->
					</div><!-- /.main-content -->





<?php



include 'bottom.php';



}

else

{



 header("location:login.php");

}

ob_flush();



?>