<?PHP

ob_start();

session_start();

include 'connect.php';

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

{

$user=$_SESSION['adminemail'];



$gtp=mysql_query("select * from admin where username='$user'");

$gtp1=mysql_fetch_array($gtp);



include 'top.php';

?>







			<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=mysql_query("select * from financial where user='$user' order by ID desc");

$aca1=mysql_fetch_array($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>

	

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']))

{



	$id=$_POST['id'];

	$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=mysql_query("update kpi set employee='$employee',date='$date',attendance='$attendance',socialmedia='$socialmedia',crmupdate='$crmupdate',businessconversation='$businessconversation',deliveryfeedback='$deliveryfeedback',productfeedback='$productfeedback',nocalls='$nocalls',paymentcollection='$paymentcollection',tds='$tds',customerretention='$customerretention' where ID='$id'") or die(mysql_error());

	

	if($ll)

	{

		header("location:viewkpi.php?s=3");

	}

	else

	{

		header("location:viewkpi.php?s=4");

	}



}





elseif($_GET['id'])

{



$id=$_GET['id'];



$emp=mysql_query("select * from kpi where ID='$id'");

$emp1=mysql_fetch_array($emp);



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

	

	<input type='hidden' name='id' value='".$id."' />

	

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

	

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

	

	$sll=mysql_query("select * from employee order by ID asc");

	while($sll1=mysql_fetch_array($sll))

	{

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

		$semp=str_replace("<option value='".$emp1['employee']."'","<option value='".$emp1['employee']."' selected",$semp);

		echo $semp;

	}

	

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

	

	<t><td>Date</td><td style='padding:0 7px;'>:</td><td><input type='text' name='date' class='datepicker' autocomplete='off' value='".date('d-m-Y',strtotime($emp1['date']))."' /></td></tr>

	

	<t><td>Attendance</td><td style='padding:0 7px;'>:</td><td><input type='text' name='attendance' autocomplete='off' value='".$emp1['attendance']."' /></td></tr>

	

	<t><td>Social Media</td><td style='padding:0 7px;'>:</td><td><input type='text' name='socialmedia' autocomplete='off' value='".$emp1['socialmedia']."' /></td></tr>

	

	<t><td>CRM Update</td><td style='padding:0 7px;'>:</td><td><input type='text' name='crmupdate' autocomplete='off' value='".$emp1['crmupdate']."' /></td></tr>

	

	<t><td>Business Convesation</td><td style='padding:0 7px;'>:</td><td><input type='text' name='businessconversation' autocomplete='off' value='".$emp1['businessconversation']."' /></td></tr>

	

	<t><td>Delivery Feedback</td><td style='padding:0 7px;'>:</td><td><input type='text' name='deliveryfeedback' autocomplete='off' value='".$emp1['deliveryfeedback']."' /></td></tr>

	

	<t><td>Product Feedback</td><td style='padding:0 7px;'>:</td><td><input type='text' name='productfeedback' autocomplete='off' value='".$emp1['productfeedback']."' /></td></tr>

	

	<t><td>No Calls</td><td style='padding:0 7px;'>:</td><td><input type='text' name='nocalls' autocomplete='off' value='".$emp1['nocalls']."' /></td></tr>

	

	<t><td>Payment Collection</td><td style='padding:0 7px;'>:</td><td><input type='text' name='paymentcollection' autocomplete='off' value='".$emp1['paymentcollection']."' /></td></tr>

	

	<t><td>TD 6S</td><td style='padding:0 7px;'>:</td><td><input type='text' name='tds' autocomplete='off' value='".$emp1['tds']."' /></td></tr>

	

	<t><td>Customer Retention</td><td style='padding:0 7px;'>:</td><td><input type='text' name='customerretention' autocomplete='off' value='".$emp1['customerretention']."' /></td></tr>

	

	</table>

	

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

	

	</form></center>";



}



else

{

	

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

	{

	 $status=$_GET['s'];

		

		 if($status=='3')

		 {

			 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 Edited Successfully.

				  </div>';				  

		 }

		 if($status=='4')

		 {

			 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 edited.

				  </div>';				  

		 }

		 if($status=='7')

		 {

			 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 Deleted Successfully.

				  </div>';				  

		 }

	}

	

	echo'<table style="width:75%; margin:11px auto 10px auto;">

                                        

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

                                        <a href="kpi.php"><button class="btn btn-minier btn-info">+ Add New</button></a>

                                        </td>

                                        

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

                                        

                                        <td style="width:30%;">

                                        

                                        </td>

                                        

                                        </tr>

                                        

                                        </table>';



echo'<table style="width:75%; margin:auto;">



<tr><td>



<table id="dynamic-table" class="table table-striped table-bordered table-hover">';



echo"<thead><th height='25' width='5%'>S.No</th>

<th width='25%'>Employee</th><th width='10%'>Date</th>

<th width='10%' style='text-align:center;'>Actions</th></thead>

<tbody>";



$select="select * from kpi order by ID ASC";

$select1=mysql_query($select);

$sno=0;

while($value=mysql_fetch_array($select1))

{

$sno=$sno+1;



$emp=mysql_query("select * from employee where ID='$value[employee]'");

$emp1=mysql_fetch_array($emp);



echo'<tr><td>'.$sno.'</td><td>'.$emp1['name'].'</td>

<td>'.date('d-m-Y',strtotime($value['date'])).'</td>

<td>



				<div class="hidden-sm hidden-xs btn-group">



										<a href="viewkpi.php?id='.$value['ID'].'" title="Edit">

												<i class="ace-icon fa fa-pencil bigger-100 green"></i></a> &nbsp; 



										<a href="del.php?id='.$value['ID'].'&desc=kpi" title="Delete">

										<i class="ace-icon fa fa-trash-o bigger-110 dark grey"></i></a>



				</div>



</td></tr>';



}



echo"</tbody></table>



</td></tr>



</table>";



}



?>









										<!-- PAGE CONTENT ENDS -->

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

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

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

						</div>

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





<?php



include 'bottom.php';



}

else

{



 header("location:login.php");

}

ob_flush();



?>