<?php include('../inc/header.php'); 
$clientObj->select($org_id);
if(isset($_GET['id']))
{
	$id=sanitize($_GET['id']);
	$check_leave=$emp_leaveObj->check_leave($id);
	
	if($check_leave==-1)
	{
	$checkerror=1;
	}
	else
	{
	$emp_leaveObj->select($id);
	}
}
if(isset($_POST['editleave']))
{   $emp_leaveObj->leavetype=sanitize($_POST['leavetype']);
	$emp_leaveObj->code=sanitize($_POST['code']);
	$emp_leaveObj->leave_count=sanitize($_POST['count']);
	$emp_leaveObj->carry_forward=1;
	$emp_leaveObj->org_id=$org_id;
	$emp_leaveObj->update($check_leave);
	$msg=1;	
}
/* Delete  */ 
if(isset($_POST['delsubmit']))
{
	$id=sanitize($_POST['del_id']);
	$emp_leaveObj->select($id);
	$emp_leaveObj->delete($id);
	$deletemsg=1;
}
/* Delete  */
?>

<!-- mobile navigation -->
<!--Delete Form-->             
<form action="#" name="delete_leaveform" id="delete_leaveform" method="POST">
<input type="hidden" name="del_id" id="del_id" value="" />
<input type="hidden" name="delsubmit" value="<?php echo time(); ?>" />
</form>
<!--Delete Form-->
<nav id="mobile_navigation"></nav>
<section id="breadcrumbs">
  <div class="container">
    <ul>
      <li><a href="#">Web School</a></li>
      <li><a href="#">Human Resource</a></li>
      <li><a href="<?php echo SITE_URL; ?>emp_leave.php">Leave Management</a></li>
      <li><span>View / Edit Leave</span></li>
    </ul>
  </div>
</section>
<section class="container clearfix main_section">
  <div id="main_content_outer" class="clearfix">
    <div id="main_content">
      <div class="alert alert-info"><strong> View / Edit Leave </strong></div>
      <!-- main content --> 
      <!--Message-->
      <?php if($msg==1){ ?>
      <div class="success">Leave has been updated successfully</div>
      <?php } ?>
       <?php if(!$deletemsg==1){ ?>
      
      <!--Message-->
      <?php  if(!$checkerror==1)
						 { ?>
      <div class="row">
        <div class="col-sm-12">
          <div class="user_heading">
            <div class="row">
              <div class="col-sm-2 hidden-xs"> 
                
                <!--<img src="<?php //echo SITE_URL; ?><?php //echo $userphotoObj->path; ?>" alt="" class="img-thumbnail user_avatar">--> 
              </div>
              <div class="col-sm-10">
                <div class="user_heading_info">
                  <div class="user_actions pull-right"> <a href="#" class="edit_form" data-toggle="tooltip" data-placement="top auto" title="Edit Leave"><span class="icon-edit"></span></a> 
                    <a href="#" class="deleteempleave"  del_id="<?php echo $emp_leaveObj->id; ?>" data-toggle="tooltip" data-placement="top auto" title="Remove Leave"><span class="icon-remove"></span></a> 
                  </div>
                  <h1><?php echo $clientObj->school_name; ?></h1>
                  <h2>View / Edit Leave Details</h2>
                </div>
              </div>
            </div>
          </div>
          <div class="user_content">
            <div class="row">
              <div class="col-sm-10 col-sm-offset-2">
                <form name="edit_leave" id="edit_leave" class="form-horizontal user_form" action="#" method="POST" enctype="multipart/form-data">
                  
                  
                  <div class="form-group">
                    <label class="col-sm-2 control-label req" >Leave Name </label>
                    <div class="col-sm-10 editable">
                      <p class="form-control-static"><?php echo $emp_leaveObj->leavetype; ?></p>
                      <div class="hidden_control">
                        <input type="text" id="leavetype" name="leavetype" class="form-control" data-required="true" value="<?php echo $emp_leaveObj->leavetype; ?>" >
                      </div>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label req" >Code </label>
                    <div class="col-sm-10 editable">
                      <p class="form-control-static"><?php echo $emp_leaveObj->code;  ?></p>
                      <div class="hidden_control">
                       <input type="text" id="code" name="code" class="form-control" data-required="true" data-type="number" value="<?php echo $emp_leaveObj->code;  ?>" >
                      </div>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label req" >Count </label>
                    <div class="col-sm-10 editable">
                      <p class="form-control-static"><?php echo $emp_leaveObj->leave_count;  ?></p>
                      <div class="hidden_control">
                        <input type="text" id="count" name="count" class="form-control" data-required="true" data-type="number" value="<?php echo $emp_leaveObj->leave_count;  ?>" >
                      </div>
                    </div>
                  </div>
                  <div class="form_submit clearfix" style="display:none">
                    <div class="row">
                      <div class="col-sm-10 col-sm-offset-2">
                        <button type="submit" class="btn btn-success" name="editleave" id="editleave">Save</button>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
      <?php } else { ?>
      <div class="error">Unauthorized Access</div>
      <?php 
						header('location:../index.php');
						} ?>
                        
                        
                        <?php } else { ?>
                        <div class="success">Leave has been deleted successfully</div>
      					<?php } ?>
    </div>
  </div>
</section>
<div id="footer_space"></div>
</div>
<?php include('../inc/footer.php'); ?>