<?php
$id = $link->hrefquery ();

$getname = $link->hrefquery ();
if ($getname [0] === 'qualification_files') {
	
	$details = explode ( '___', $getname [1] );
	
	$e_id = $details [0];
	$filename = $details [1] . '___' . $details [2];
	$colname = $db->get_col ( 'employees', array ('e_id' => $e_id ), 'qualification_files' );
	$remove = str_replace ( $filename, '', $colname [0] );
	$update = $db->update ( 'employees', array ('qualification_files' => $remove ), array ('e_id' => $e_id ) );
	if ($update) {
		unlink ( SERVER_ROOT . '/uploads/employees/' . $e_id . '/' . $filename );
		$session->redirect ( 'employee_preview?id=' . $e_id, Admin );
	}
}
if ($getname [0] === 'resume') {
	
	$details = explode ( '___', $getname [1] );
	
	$e_id = $details [0];
	$filename = $details [1] . '___' . $details [2];
	
	$colname = $db->get_col ( 'employees', array ('e_id' => $e_id ), 'resume' );
	$remove = str_replace ( $filename, '', $colname [0] );
	$update = $db->update ( 'employees', array ('resume' => $remove ), array ('e_id' => $e_id ) );
	if ($update) {
		unlink ( SERVER_ROOT . '/uploads/employees/' . $e_id . '/' . $filename );
		$session->redirect ( 'employee_preview?id=' . $e_id, Admin );
	}
}
if ($getname [0] === 'idproof_files') {
	
	$details = explode ( '___', $getname [1] );
	
	$e_id = $details [0];
	$filename = $details [1] . '___' . $details [2];
	$colname = $db->get_col ( 'employees', array ('e_id' => $e_id ), 'idproof_files' );
	$remove = str_replace ( $filename, '', $colname [0] );
	$update = $db->update ( 'employees', array ('idproof_files' => $remove ), array ('e_id' => $e_id ) );
	if ($update) {
		unlink ( SERVER_ROOT . '/uploads/employees/' . $e_id . '/' . $filename );
		$session->redirect ( 'employee_preview?id=' . $e_id, Admin );
	}
}
if ($getname [0] === 'declaration_image') {

	$details = explode ( '&&&', $getname [1] );

	$e_id = $details [0];
	$filename = $details [1];
	$colname = $db->get_col ( 'employees', array ('e_id' => $e_id ), 'declaration' );
	$remove = str_replace ( $filename, '', $colname [0] );
	$update = $db->update ( 'employees', array ('declaration' => $remove ), array ('e_id' => $e_id ) );
	if ($update) {
		unlink ( SERVER_ROOT . '/uploads/employees/' . $e_id . '/' . $filename );
		$session->redirect ( 'employee_preview?id=' . $e_id, Admin );
	}
}
?>
<?php 
if (isset($_POST['submitdeclaration']))
{
	$image= $_FILES['file1']['name'];
	$id= $id[1];
	$get_declaration= $db->get_col("employees", array("id"=>$id), "declaration");
	$path= SERVER_ROOT. '/uploads/employees/'.$id.'/'.$get_declaration[0];
	if(file_exists($path) && $get_declaration[0] !='')
	{
		unlink($path);
	}
	
	$cli = (isset ( $argc ) && $argc > 1);
	($cli);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		print_r ( $_GET ['file'] );
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	if (! $cli && ! (isset ( $_SERVER ['HTTP_X_FILE_NAME'] ) && isset ( $_SERVER ['CONTENT_LENGTH'] )))
	
	{
			
		$files = array ();
			
		foreach ( $_FILES ['my_field'] as $k => $l ) {
			foreach ( $l as $i => $v ) {
					
				if (! array_key_exists ( $i, $files ))
					$files [$i] = array ();
					
				$files [$i] [$k] = $v;
			}
		}
			
		// now we can loop through $files, and feed each element to
		// the class
		foreach ( $files as $file ) {
			// we instanciate the class for each element of $file
			$name = mt_rand ( 15, 215 ) . "___" . mb_strtolower ( preg_replace ( '/\s+/', '', $file ['name'] ) );
			$file ['name'] = str_replace ( array ('(', ')' ), '', $name );
			$savedname .= $file ['name'] . ',';
	
			$handle = new upload ( $file );
	
			// then we check if the file has been uploaded properly
			// in its *temporary* location in the server (often, it
			// is /tmp)
	
			if ($handle->uploaded) {
					
				// now, we start the upload 'process'. That is, to
				// copy the uploaded file
				// from its temporary location to the wanted
				// location
				// It could be something like
				// $handle->Process('/home/www/my_uploads/');
				$handle->Process ( $dir_dest );
			}
				
		}
	}
	$updatedec= $db->update("employees", array("declaration"=>$savedname), array("e_id"=>$id));
	if($updatedec)
	{
		$session->redirect("employee_preview?id=".$id,Admin);
	}
	else
	{
		$session->redirect("employee_preview?id=".$id,Admin);
	}
}
?>
<?php 
if (isset($_POST['declaration1']))
{
	$id= $id[1];
	$_FILES ['my_field1'] ['name'];
	if($_POST['declaration1image']!='')
	{
		$search= $_POST['declaration1image'];
		$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'declaration' );
		$path1 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	}
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['my_field1'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['my_field1'] ['name'] ) );
		$_FILES ['my_field1'] ['name'] = str_replace ( array ('(', ')' ), '', $name );
		$handle = new upload ( $_FILES ['my_field1'] );
	
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
				
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
				
			// we now process the image a second time, with some other settings
				
			$handle->Process ( $dir_dest );
				
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['my_field1'] ['name'];
				
					$query2 = $db->get_col ( 'employees', array ('e_id' => $id ), 'declaration' );
					if($_POST['declaration1image']!=''){
						$change= str_replace($search, $photovalue, $query2[0]);
					}else
					{
						$explode= explode(",", $query2[0]);
						if($explode[1]=='')
						{
							$change= $photovalue.',,';
						}
						if($explode[1]!='')
						{
							$change= $photovalue.','.$explode[1].',';
						}
					}
				$query1 = $db->update ( 'employees', array ('declaration' => $change ), array ('e_id' => $id ) );
					
				if ($query1 && $query2 [0] != '') {
					if (file_exists ( $path1 )) {
						unlink ( $path1 );
							
					}
				}
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>
<?php 
if (isset($_POST['last_declaration1']))
{
	$id= $id[1];
	$_FILES ['my_field2'] ['name'];
	if($_POST['last_declaration1image']!='')
	{
		$search= $_POST['last_declaration1image'];
		$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'declaration' );
		$path1 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	}
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['my_field2'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['my_field2'] ['name'] ) );
		$_FILES ['my_field2'] ['name'] = str_replace ( array ('(', ')' ), '', $name );
		$handle = new upload ( $_FILES ['my_field2'] );
	
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
				
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
				
			// we now process the image a second time, with some other settings
				
			/* $handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250; */
				
			$handle->Process ( $dir_dest );
				
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['my_field2'] ['name'];
				
				$query2 = $db->get_col ( 'employees', array ('e_id' => $id ), 'declaration' );
				if($_POST['declaration1image']!=''){
					$change= str_replace($search, $photovalue, $query2[0]);
				}else
				{
					$explode= explode(",", $query2[0]);
					if($explode[0]=='')
					{
						$change= ','.$photovalue.',';
					}
					if($explode[0]!='')
					{
						$change= $explode[0].','.$photovalue.',';
					}
				}
				$query1 = $db->update ( 'employees', array ('declaration' => $change ), array ('e_id' => $id ) );
					
				if ($query1 && $query2 [0] != '') {
					if (file_exists ( $path1 )) {
						unlink ( $path1 );
							
					}
				}
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>
<?php

if (isset ( $_POST ['upload'] )) {
	$lstid = $_POST ['id'];
	
	$photo_name = $db->get_row ( 'employees', array ('e_id' => $lstid ) );
	
	$pfile = SERVER_ROOT . '/uploads/employees/' . $lstid . '/' . $photo_name ['p_photograph'];
	if (file_exists ( $pfile ) && $photo_name ['p_photograph'] != '')
		unlink ( $pfile );
	
	$cli = (isset ( $argc ) && $argc > 1);
	($cli);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $lstid);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if (! $cli && ! (isset ( $_SERVER ['HTTP_X_FILE_NAME'] ) && isset ( $_SERVER ['CONTENT_LENGTH'] ))) 

	{
		
		$files = array ();
		
		foreach ( $_FILES ['my_field'] as $k => $l ) {
			foreach ( $l as $i => $v ) {
				
				if (! array_key_exists ( $i, $files ))
					$files [$i] = array ();
				
				$files [$i] [$k] = $v;
			}
		}
		
		// now we can loop through $files, and feed each element to the class
		foreach ( $files as $file ) {
			// we instanciate the class for each element of $file
			$loop = $lstid . "___" . mb_strtolower ( preg_replace ( '/\s+/', '', $file ['name'] ) . ___ . mt_rand ( 15, 215 ) );
			$file ['name'] = str_replace ( array ('(', ')' ), '', $loop );
			$savedname = $file ['name'];
			$handle = new upload ( $file );
			
			// then we check if the file has been uploaded properly
			// in its *temporary* location in the server (often, it is /tmp)
			
			if ($handle->uploaded) {
				
				// now, we start the upload 'process'. That is, to copy the
				// uploaded file
				// from its temporary location to the wanted location
				// It could be something like
				// $handle->Process('/home/www/my_uploads/');
				// we now process the image a second time, with some other
				// settings
				
				$handle->image_resize = true;
				$handle->image_ratio_crop = true;
				$handle->image_y = 200;
				$handle->image_x = 250;
				
				$handle->Process ( $dir_dest );
				{
					// everything was fine !
					
					$update = $db->update ( 'employees', array ('p_photograph' => $savedname ), array ('e_id' => $lstid ) );
					if ($update) {
					
					} else {
						?>
<div class="hide1">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">
				<div class="gritter-close" id="gritterremove"
					style="display: inline;"></div>
				<h5>Oops! There Are Some Uploading Problem...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>

<?php
					
					}
				
				}
			}
		}
	}
}
?> 
<?php
if (isset ( $_POST ['241'] )) {
	$_FILES ['photo201'] ['name'];
	$search = $_POST ['211'];
	$id = $_POST ['201'];
	
	$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'resume' );
	$path1 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['photo201'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo201'] ['name'] ) );
		$_FILES ['photo201'] ['name'] = str_replace ( array ('(', ')' ), '', $name );
		$handle = new upload ( $_FILES ['photo201'] );
		
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
			
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
			
			// we now process the image a second time, with some other settings
			
			$handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250;
			
			$handle->Process ( $dir_dest );
			
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['photo201'] ['name'];
				
				$query2 = $db->get_col ( 'employees', array ('e_id' => $id ), 'resume' );
				
				$query1 = $db->update ( 'employees', array ('resume' => $photovalue ), array ('e_id' => $id ) );
				
				if ($query1 && $query2 [0] != '') {
					if (file_exists ( $path1 )) {
						unlink ( $path1 );
					
					}
				}
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>
<?php

if (isset ( $_POST ['41'] )) {
	$_FILES ['photo1'] ['name'];
	$search = $_POST ['11'];
	$id = $_POST ['1'];
	
	$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'qualification_files' );
	$path1 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['photo1'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name1 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo1'] ['name'] ) );
		$_FILES ['photo1'] ['name'] = str_replace ( array ('(', ')' ), '', $name1 );
		$handle = new upload ( $_FILES ['photo1'] );
		
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
			
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
			
			// we now process the image a second time, with some other settings
			
			$handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250;
			
			$handle->Process ( $dir_dest );
			
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['photo1'] ['name'];
				
				$ftime = $ftime [0];
				$explode = explode ( ',', $ftime );
				$store2 = array_pop ( $explode );
				
				if ($explode [0] != '' && file_exists ( $path1 )) {
					unlink ( $path1 );
					$first = str_replace ( $search, $photovalue, $ftime [0] );
					$remove = $first . ',' . $explode [1] . ',' . $explode [2] . ',' . $explode [3] . ',' . $explode [4] . ',';
				} else {
					$remove = $photovalue . ',' . $explode [1] . ',' . $explode [2] . ',' . $explode [3] . ',' . $explode [4] . ',';
				}
				$query1 = $db->update ( 'employees', array ('qualification_files' => $remove ), array ('e_id' => $id ) );
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>
<?php

if (isset ( $_POST ['42'] )) {
	$_FILES ['photo2'] ['name'];
	$search = $_POST ['12'];
	$id = $_POST ['2'];
	
	$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'qualification_files' );
	$path2 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['photo2'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name2 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo2'] ['name'] ) );
		$_FILES ['photo2'] ['name'] = str_replace ( array ('(', ')' ), '', $name2 );
		$handle = new upload ( $_FILES ['photo2'] );
		
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
			
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
			
			// we now process the image a second time, with some other settings
			
			$handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250;
			
			$handle->Process ( $dir_dest );
			
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['photo2'] ['name'];
				
				$ftime = $ftime [0];
				$explode = explode ( ',', $ftime );
				$store2 = array_pop ( $explode );
				
				if ($explode [1] != '' && file_exists ( $path2 )) {
					unlink ( $path2 );
					$second = str_replace ( $search, $photovalue, $ftime [0] );
					$remove = $explode [0] . ',' . $second . ',' . $explode [2] . ',' . $explode [3] . ',' . $explode [4] . ',';
				} else {
					$remove = $explode [0] . ',' . $photovalue . ',' . $explode [2] . ',' . $explode [3] . ',' . $explode [4] . ',';
				}
				$query2 = $db->update ( 'employees', array ('qualification_files' => $remove ), array ('e_id' => $id ) );
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>

<?php
if (isset ( $_POST ['43'] )) {
	$_FILES ['photo3'] ['name'];
	$search = $_POST ['13'];
	$id = $_POST ['3'];
	
	$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'qualification_files' );
	$path3 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['photo3'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name3 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo3'] ['name'] ) );
		$_FILES ['photo3'] ['name'] = str_replace ( array ('(', ')' ), '', $name3 );
		$handle = new upload ( $_FILES ['photo3'] );
		
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
			
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
			
			// we now process the image a second time, with some other settings
			
			$handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250;
			
			$handle->Process ( $dir_dest );
			
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['photo3'] ['name'];
				
				$ftime = $ftime [0];
				$explode = explode ( ',', $ftime );
				$store2 = array_pop ( $explode );
				
				if ($explode [2] != '' && file_exists ( $path3 )) {
					unlink ( $path3 );
					$third = str_replace ( $search, $photovalue, $ftime [0] );
					$remove = $explode [0] . ',' . $explode [1] . ',' . $third . ',' . $explode [3] . ',' . $explode [4] . ',';
				} else {
					$remove = $explode [0] . ',' . $explode [1] . ',' . $photovalue . ',' . $explode [3] . ',' . $explode [4] . ',';
				}
				
				$query3 = $db->update ( 'employees', array ('qualification_files' => $remove ), array ('e_id' => $id ) );
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>

<?php
if (isset ( $_POST ['44'] )) {
	$_FILES ['photo4'] ['name'];
	$search = $_POST ['14'];
	$id = $_POST ['4'];
	
	$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'qualification_files' );
	$path4 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['photo4'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name4 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo4'] ['name'] ) );
		$_FILES ['photo4'] ['name'] = str_replace ( array ('(', ')' ), '', $name4 );
		$handle = new upload ( $_FILES ['photo4'] );
		
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
			
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
			
			// we now process the image a second time, with some other settings
			
			$handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250;
			
			$handle->Process ( $dir_dest );
			
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['photo4'] ['name'];
				
				$ftime = $ftime [0];
				$explode = explode ( ',', $ftime );
				$store2 = array_pop ( $explode );
				
				if ($explode [3] != '' && file_exists ( $path4 )) {
					unlink ( $path4 );
					$fourth = str_replace ( $search, $photovalue, $ftime [0] );
					$remove = $explode [0] . ',' . $explode [1] . ',' . $explode [2] . ',' . $fourth . ',' . $explode [4] . ',';
				} else {
					$remove = $explode [0] . ',' . $explode [1] . ',' . $explode [2] . ',' . $photovalue . ',' . $explode [4] . ',';
				}
				
				$query4 = $db->update ( 'employees', array ('qualification_files' => $remove ), array ('e_id' => $id ) );
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>

								

<?php
if (isset ( $_POST ['45'] )) {
	$_FILES ['photo5'] ['name'];
	$search = $_POST ['15'];
	
	$id = $_POST ['5'];
	
	$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'qualification_files' );
	
	// $remove= str_replace($search, $replace, $ftime[0]);
	$path5 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['photo5'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name5 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo5'] ['name'] ) );
		$_FILES ['photo5'] ['name'] = str_replace ( array ('(', ')' ), '', $name5 );
		$handle = new upload ( $_FILES ['photo5'] );
		
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
			
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
			
			// we now process the image a second time, with some other settings
			
			$handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250;
			
			$handle->Process ( $dir_dest );
			
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['photo5'] ['name'];
				$ftime = $ftime [0];
				$explode = explode ( ',', $ftime );
				$store2 = array_pop ( $explode );
				
				if ($explode [4] != '' && file_exists ( $path5 )) {
					unlink ( $path5 );
					$fifth = str_replace ( $search, $photovalue, $ftime [0] );
					$remove = $explode [0] . ',' . $explode [1] . ',' . $explode [2] . ',' . $explode [3] . ',' . $fifth . ',';
				} else {
					$remove = $explode [0] . ',' . $explode [1] . ',' . $explode [2] . ',' . $explode [3] . ',' . $photovalue . ',';
				}
				
				$query5 = $db->update ( 'employees', array ('qualification_files' => $remove ), array ('e_id' => $id ) );
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>

<?php
if (isset ( $_POST ['141'] )) {
	$_FILES ['photo101'] ['name'];
	$search = $_POST ['111'];
	$id = $_POST ['101'];
	
	$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'idproof_files' );
	$path1 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
	$cli = (isset ( $argc ) && $argc > 1);
	if ($cli) {
		if (isset ( $argv [1] ))
			$_GET ['file'] = $argv [1];
		if (isset ( $argv [2] ))
			$_GET ['dir'] = $argv [2];
		if (isset ( $argv [3] ))
			$_GET ['pics'] = $argv [3];
	}
	
	// set variables
	$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
	$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
	
	if ($_FILES ['photo101'] ['name'] != '') {
		// we create an instance of the class, giving as argument the PHP object
		// corresponding to the file field from the form
		// All the uploads are accessible from the PHP object $_FILES
		
		$name6 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo101'] ['name'] ) );
		$_FILES ['photo101'] ['name'] = str_replace ( array ('(', ')' ), '', $name6 );
		$handle = new upload ( $_FILES ['photo101'] );
		
		// then we check if the file has been uploaded properly
		// in its *temporary* location in the server (often, it is /tmp)
		if ($handle->uploaded) {
			
			// yes, the file is on the server
			// now, we start the upload 'process'. That is, to copy the uploaded
			// file
			// from its temporary location to the wanted location
			// It could be something like
			// $handle->Process('/home/www/my_uploads/');
			
			// we now process the image a second time, with some other settings
			
			$handle->image_resize = true;
			$handle->image_ratio_crop = true;
			$handle->image_y = 200;
			$handle->image_x = 250;
			
			$handle->Process ( $dir_dest );
			
			// we check if everything went OK
			if ($handle->processed) {
				// everything was fine !
				$photovalue = $_FILES ['photo101'] ['name'];
				
				$ftime = $ftime [0];
				$explode = explode ( ',', $ftime );
				$store2 = array_pop ( $explode );
				
				if ($explode [0] != '' && file_exists ( $path2 )) {
					unlink ( $path2 );
					$first = str_replace ( $search, $photovalue, $ftime [0] );
					$remove = $first . ',' . $explode [1] . ',' . $explode [2] . ',';
				
				} else {
					$remove = $photovalue . ',' . $explode [1] . ',' . $explode [2] . ',';
				}
				$query1 = $db->update ( 'employees', array ('idproof_files' => $remove ), array ('e_id' => $id ) );
			}
		}
	}
	$session->redirect ( 'employee_preview?id=' . $id, Admin );
}
?>

	<?php
	if (isset ( $_POST ['142'] )) {
		$_FILES ['photo102'] ['name'];
		$search = $_POST ['112'];
		$id = $_POST ['102'];
		
		$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'idproof_files' );
		$path2 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
		$cli = (isset ( $argc ) && $argc > 1);
		if ($cli) {
			if (isset ( $argv [1] ))
				$_GET ['file'] = $argv [1];
			if (isset ( $argv [2] ))
				$_GET ['dir'] = $argv [2];
			if (isset ( $argv [3] ))
				$_GET ['pics'] = $argv [3];
		}
		
		// set variables
		$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
		$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
		
		if ($_FILES ['photo102'] ['name'] != '') {
			// we create an instance of the class, giving as argument the PHP
			// object
			// corresponding to the file field from the form
			// All the uploads are accessible from the PHP object $_FILES
			
			$name7 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo102'] ['name'] ) );
			$_FILES ['photo102'] ['name'] = str_replace ( array ('(', ')' ), '', $name7 );
			$handle = new upload ( $_FILES ['photo102'] );
			
			// then we check if the file has been uploaded properly
			// in its *temporary* location in the server (often, it is /tmp)
			if ($handle->uploaded) {
				
				// yes, the file is on the server
				// now, we start the upload 'process'. That is, to copy the
				// uploaded file
				// from its temporary location to the wanted location
				// It could be something like
				// $handle->Process('/home/www/my_uploads/');
				
				// we now process the image a second time, with some other
				// settings
				
				$handle->image_resize = true;
				$handle->image_ratio_crop = true;
				$handle->image_y = 200;
				$handle->image_x = 250;
				
				$handle->Process ( $dir_dest );
				
				// we check if everything went OK
				if ($handle->processed) {
					// everything was fine !
					$photovalue = $_FILES ['photo102'] ['name'];
					
					$ftime = $ftime [0];
					$explode = explode ( ',', $ftime );
					$store2 = array_pop ( $explode );
					
					if ($explode [1] != '' && file_exists ( $path2 )) {
						unlink ( $path2 );
						$second = str_replace ( $search, $photovalue, $ftime [0] );
						$remove = $explode [0] . ',' . $second . ',' . $explode [2] . ',';
					} else {
						$remove = $explode [0] . ',' . $photovalue . ',' . $explode [2] . ',';
					}
					
					$query2 = $db->update ( 'employees', array ('idproof_files' => $remove ), array ('e_id' => $id ) );
				}
			}
		}
		$session->redirect ( 'employee_preview?id=' . $id, Admin );
	}
	?>
	<?php
	if (isset ( $_POST ['143'] )) {
		$_FILES ['photo103'] ['name'];
		$search = $_POST ['113'];
		$id = $_POST ['103'];
		
		$ftime = $db->get_col ( 'employees', array ('e_id' => $id ), 'idproof_files' );
		
		$path3 = SERVER_ROOT . '/uploads/employees/' . $id . '/' . $search;
		$cli = (isset ( $argc ) && $argc > 1);
		if ($cli) {
			if (isset ( $argv [1] ))
				$_GET ['file'] = $argv [1];
			if (isset ( $argv [2] ))
				$_GET ['dir'] = $argv [2];
			if (isset ( $argv [3] ))
				$_GET ['pics'] = $argv [3];
		}
		
		// set variables
		$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $id);
		$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
		
		if ($_FILES ['photo103'] ['name'] != '') {
			// we create an instance of the
			// class, giving as argument the PHP
			// object
			// corresponding to the file field
			// from the form
			// All the uploads are accessible
			// from the PHP object $_FILES
			
			$name8 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['photo103'] ['name'] ) );
			$_FILES ['photo103'] ['name'] = str_replace ( array ('(', ')' ), '', $name8 );
			$handle = new upload ( $_FILES ['photo103'] );
			
			// then we check if the file has
			// been uploaded properly
			// in its *temporary* location in
			// the server (often, it is /tmp)
			if ($handle->uploaded) {
				
				// yes, the file is on the
				// server
				// now, we start the upload
				// 'process'. That is, to copy
				// the uploaded file
				// from its temporary location
				// to the wanted location
				// It could be something like
				// $handle->Process('/home/www/my_uploads/');
				
				// we now process the image a
				// second time, with some other
				// settings
				
				$handle->image_resize = true;
				$handle->image_ratio_crop = true;
				$handle->image_y = 200;
				$handle->image_x = 250;
				
				$handle->Process ( $dir_dest );
				
				// we check if everything went
				// OK
				if ($handle->processed) {
					// everything was fine !
					$photovalue = $_FILES ['photo103'] ['name'];
					$ftime = $ftime [0];
					$explode = explode ( ',', $ftime );
					$store2 = array_pop ( $explode );
					
					if ($explode [2] != '' && file_exists ( $path3 )) {
						unlink ( $path3 );
						$third = str_replace ( $search, $photovalue, $ftime [0] );
						$remove = $explode [0] . ',' . $explode [1] . ',' . $third . ',';
					} else {
						$remove = $explode [0] . ',' . $explode [1] . ',' . $photovalue . ',';
						
						// $remove=
						// str_replace($search,
						// $photovalue,
						// $photovalue);
					}
					$query3 = $db->update ( 'employees', array ('idproof_files' => $remove ), array ('e_id' => $id ) );
				}
			}
		}
		$session->redirect ( 'employee_preview?id=' . $id, Admin );
	}
	?>
									
		<?php
		if (isset ( $_POST ['submit'] )) {
			$e_id = $id [1];
			
			if ($_POST ['date1'] != '')
				$_POST ['date1'] = date ( 'Y-m-d', strtotime ( $_POST ['date1'] ) );
			if ($_POST ['date2'] != '')
				$_POST ['date2'] = date ( 'Y-m-d', strtotime ( $_POST ['date2'] ) );
			
			$date1 = strtotime ( $_POST ['date1'] );
			
			$date2 = strtotime ( $_POST ['date2'] );
			$current_date = date ( 'Y-m-d' );
			
			$office = $db->get_row ( 'office', array ('id' => 1 ) );
			
			if ($_POST ['set'] == 'present') {
				if ($e_id == '' || $_POST ['set'] == '') {
					?>
<div class="hide1">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">
				<div class="gritter-close" id="gritterremove"
					style="display: inline;"></div>
				<h5>Oops! Data Is Not Inserted...</h5>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
</div>


<?php
				
				} else {
					if ($date2 == '' && $date1 != '') {
						$date1check = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
						if ($date1check) {
							$equal = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => 0.00, 'secondhalf' => 0.00, 't_leave' => '', 'application' => '', 'date' => $_POST ['date1'] ), array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
							if ($equal) {
								?>
<div id="hide">
	<div id="gritter-notice-wrapper">
		<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
			style="">
			<div class="gritter-top"></div>
			<div class="gritter-item">

				<div class="gritter-without-image">
					<span class="gritter-title">Cheers..
						<div class="gritter-close" id="gritterremove"
							style="display: inline;"></div>
					</span>
					<p>Your Record Is Updated...</p>
				</div>
				<div style="clear: both"></div>
			</div>
			<div class="gritter-bottom"></div>
		</div>
	</div>
						<?php
							
							}
						} else {
							$equal = $db->insert ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
							
							if ($equal) {
								?>
							<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Inserted Successfully...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
						<?php
							
							} else {
								?>
							<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! Data Is Not Inserted...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
						<?php
							
							}
						}
					}
					if ($date1 == '' && $date2 != '') {
						$date2check = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
						
						if ($date2check) {
							$d2update = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => 0.00, 'secondhalf' => 0.00, 't_leave' => '', 'application' => '', 'date' => $_POST ['date2'] ), array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
							
							if ($d2update) {
								?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Register Successfully...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
							
							}
						} else {
							$equal = $db->insert ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
							if ($equal) {
								?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Register Successfully...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
							<?php
							
							} else {
								?>
								<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! Data Is Not Inserted...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
							<?php
							
							}
						}
					}
					
					if ($date1 <= $date2 && $date1 != '' && $date2 != '') {
						$a = $date1;
						$b = $date2;
						
						while ( $a <= $b ) {
							$c = date ( 'Y-m-d', $a );
							
							$whilecheck = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
							
							if ($whilecheck) {
								$zwhile = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => 0.00, 'secondhalf' => 0.00, 't_leave' => '', 'application' => '', 'date' => $c ), array ('e_id' => $e_id, 'date' => $c ) );
							
							} else {
								$ywhile = $db->insert ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
							}
							
							$d = date ( 'Y-m-d', strtotime ( $c . "+ 1 days" ) );
							$a = strtotime ( $d );
						}
						if ($zwhile) {
							?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
					<?php
						
						}
						if ($ywhile) {
							?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
					<?php
						
						}
					}
					
					if ($date1 > $date2 && $date2 != '') {
						?>
					<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! Date Range Is Wrong...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
				<?php
					
					}
				
				}
			}
			if ($_POST ['set'] == 'absent') {
				
				$check = 0;
				if ($_POST ['t_leave'] == '' || $_POST ['r_leave'] == '' || $e_id == '') {
					?>
				<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! Please Select The Type Of Leave Or Range Of Leave Or
						Select The Name Or Select The Date ...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
			<?php
				
				}
				if ($_POST ['t_leave'] == 'casual') {
					$firsthalfcasual = $db->run ( "SELECT SUM( firsthalf )FROM attendence WHERE e_id = $e_id
						and t_leave= 'casual'" )->fetchColumn ();
					
					$secondhalfcasual = $db->run ( "SELECT SUM( secondhalf )FROM attendence WHERE e_id = $e_id
								and t_leave= 'casual'" )->fetchColumn ();
					
					$casual = $firsthalfcasual + $secondhalfcasual;
					
					if ($office ['c_leave'] <= $casual) {
						?>
									<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! No Casual Leave Remaining...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
								<?php
						$check = 5;
					}
				
				} elseif ($_POST ['t_leave'] == 'sick') {
					$firsthalfsick = $db->run ( "SELECT SUM( firsthalf )FROM attendence WHERE e_id = $e_id
										and t_leave= 'sick'" )->fetchColumn ();
					$secondhalfsick = $db->run ( "SELECT SUM( secondhalf )FROM attendence WHERE e_id = $e_id
										and t_leave= 'sick'" )->fetchColumn ();
					
					$sick = $firsthalfsick + $secondhalfsick;
					if ($office ['s_leave'] <= $sick) {
						?>
											<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! No Sick Leave Remaining...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
											
										<?php
						$check = 5;
					}
				} elseif ($_POST ['t_leave'] == 'maternity') {
					$firsthalfmaternity = $db->run ( "SELECT SUM( firsthalf )FROM attendence WHERE e_id = $e_id
										and t_leave= 'maternity'" )->fetchColumn ();
					$secondhalfmaternity = $db->run ( "SELECT SUM( secondhalf )FROM attendence WHERE e_id = $e_id
										and t_leave= 'maternity'" )->fetchColumn ();
					
					$maternity = $firsthalfmaternity + $secondhalfmaternity;
					if ($office ['m_leave'] <= $maternity) {
						?>
											<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! No Maternity Leave Remaining...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										<?php
						$check = 5;
					}
				} elseif ($_POST ['t_leave'] == 'other') {
					$firsthalfother = $db->run ( "SELECT SUM( firsthalf )FROM attendence WHERE e_id = $e_id
										and t_leave= 'other'" )->fetchColumn ();
					$secondhalfother = $db->run ( "SELECT SUM( secondhalf )FROM attendence WHERE e_id = $e_id
										and t_leave= 'other'" )->fetchColumn ();
					
					$other = $firsthalfother + $secondhalfother;
					if ($office ['o_leave'] <= $other) {
						?>
											<div class="hide1">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-2" class="gritter-item-wrapper gritter-warning"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">
					<div class="gritter-close" id="gritterremove"
						style="display: inline;"></div>
					<h5>Oops! No Other Leave Remaining...</h5>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										<?php
						$check = 5;
					}
				}
				if ($check != 5) {
					
					// retrieve eventual CLI parameters
					$cli = (isset ( $argc ) && $argc > 1);
					if ($cli) {
						if (isset ( $argv [1] ))
							$_GET ['file'] = $argv [1];
						if (isset ( $argv [2] ))
							$_GET ['dir'] = $argv [2];
						if (isset ( $argv [3] ))
							$_GET ['pics'] = $argv [3];
					}
					
					// set variables
					$dir_dest = (isset ( $_GET ['dir'] ) ? $_GET ['dir'] : 'uploads/employees/' . $e_id);
					$dir_pics = (isset ( $_GET ['pics'] ) ? $_GET ['pics'] : $dir_dest);
					
					if ($date2 == '') {
						if ($_FILES ['application'] ['name'] != '') {
							// echo 'application ke andr';
							// we create an instance of the class, giving as
							// argument the PHP object
							// corresponding to the file field from the form
							// All the uploads are accessible from the PHP
							// object $_FILES
							
							$name9 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['application'] ['name'] ) );
							$_FILES ['application'] ['name'] = str_replace ( array ('(', ')' ), '', $name9 );
							$handle = new upload ( $_FILES ['application'] );
							
							// then we check if the file has been uploaded
							// properly
							// in its *temporary* location in the server (often,
							// it is /tmp)
							if ($handle->uploaded) {
								// yes, the file is on the server
								// now, we start the upload 'process'. That is,
								// to copy the uploaded file
								// from its temporary location to the wanted
								// location
								// It could be something like
								// $handle->Process('/home/www/my_uploads/');
								// we now process the image a second time, with
								// some other settings
								
								$handle->image_resize = true;
								$handle->image_ratio_crop = true;
								$handle->image_y = 200;
								$handle->image_x = 250;
								
								$handle->Process ( $dir_dest );
								
								// we check if everything went OK
								if ($handle->processed) {
									// everything was fine !
									$application = $_FILES ['application'] ['name'];
									
									if ($_POST ['r_leave'] == 'fullday') {
										
										$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
										if ($check1) {
											$full = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date1'] ), array ('date' => $_POST ['date1'], 'e_id' => $e_id ) );
											if ($full) {
												?>
											<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
											
										<?php
											
											}
										} else {
											$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date1'] ) );
											
											if ($query1) {
												?>
											<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
											
										<?php
											
											}
										}
									}
									
									if ($_POST ['r_leave'] == 'secondhalf') {
										$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
										if ($check1) {
											$sec = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.00', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date1'] ), array ('date' => $_POST ['date1'], 'e_id' => $e_id ) );
											if ($sec) {
												?>
											<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
											
										<?php
											
											}
										} else {
											$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date1'] ) );
											
											if ($query1) {
												?>
											<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
											
										<?php
											
											}
										}
									}
									if ($_POST ['r_leave'] == 'firsthalf') {
										$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
										if ($check1) {
											$first = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.00', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date1'] ), array ('date' => $_POST ['date1'], 'e_id' => $e_id ) );
											
											if ($first) {
												?>
											<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
											
										<?php
											
											}
										} else {
											$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date1'] ) );
											
											if ($query1) {
												?>
											<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
											
										<?php
											
											}
										}
									}
								
								}
							}
						} else {
							if ($_POST ['r_leave'] == 'fullday') {
								$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
								if ($check1) {
									$full1 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date1'] ), array ('date' => $_POST ['date1'], 'e_id' => $e_id ) );
									
									if ($full1) {
										?>
									<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
									
								<?php
									
									}
								} else {
									$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date1'] ) );
									
									if ($query1) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								}
							}
							
							if ($_POST ['r_leave'] == 'secondhalf') {
								$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
								if ($check1) {
									$sec1 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.00', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date1'] ), array ('date' => $_POST ['date1'], 'e_id' => $e_id ) );
									
									if ($sec1) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								} else {
									$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date1'] ) );
									if ($query1) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
								
							<?php
									
									}
								}
							}
							if ($_POST ['r_leave'] == 'firsthalf') {
								$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date1'] ) );
								if ($check1) {
									$first1 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.00', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date1'] ), array ('date' => $_POST ['date1'], 'e_id' => $e_id ) );
									if ($first1) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								} else {
									$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date1'] ) );
									
									if ($query1) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								}
							}
						}
					
					}
					if ($date1 == '') {
						
						if ($_FILES ['application'] ['name'] != '') {
							
							// echo 'application ke andr';
							// we create an instance of the class, giving as
							// argument the PHP object
							// corresponding to the file field from the form
							// All the uploads are accessible from the PHP
							// object $_FILES
							
							$name10 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['application'] ['name'] ) );
							$_FILES ['application'] ['name'] = str_replace ( array ('(', ')' ), '', $name10 );
							$handle = new upload ( $_FILES ['application'] );
							
							// then we check if the file has been uploaded
							// properly
							// in its *temporary* location in the server (often,
							// it is /tmp)
							if ($handle->uploaded) {
								// yes, the file is on the server
								// now, we start the upload 'process'. That is,
								// to copy the uploaded file
								// from its temporary location to the wanted
								// location
								// It could be something like
								// $handle->Process('/home/www/my_uploads/');
								// we now process the image a second time, with
								// some other settings
								
								$handle->image_resize = true;
								$handle->image_ratio_crop = true;
								$handle->image_y = 200;
								$handle->image_x = 250;
								
								$handle->Process ( $dir_dest );
								
								// we check if everything went OK
								if ($handle->processed) {
									// everything was fine !
									$application = $_FILES ['application'] ['name'];
									
									if ($_POST ['r_leave'] == 'fullday') {
										$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
										if ($check1) {
											$full2 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date2'] ), array ('date' => $_POST ['date2'], 'e_id' => $e_id ) );
											if ($full2) {
												?>
										<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										
									<?php
											
											}
										} else {
											$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date2'] ) );
											
											if ($query1) {
												?>
										<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										
									<?php
											
											}
										}
									}
									
									if ($_POST ['r_leave'] == 'secondhalf') {
										$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
										if ($check1) {
											$sec2 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => 0.00, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date2'] ), array ('date' => $_POST ['date2'], 'e_id' => $e_id ) );
											
											if ($sec2) {
												?>
										<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										
									<?php
											
											}
										} else {
											$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date2'] ) );
											
											if ($query1) {
												?>
										<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										
									<?php
											
											}
										}
									
									}
									
									if ($_POST ['r_leave'] == 'firsthalf') {
										$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
										if ($check1) {
											$first2 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => 0.00, 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date2'] ), array ('date' => $_POST ['date2'], 'e_id' => $e_id ) );
											
											if ($first2) {
												?>
										<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										
										
									<?php
											
											}
										} else {
											$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $_POST ['date2'] ) );
											
											if ($query1) {
												?>
										<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
										
									<?php
											
											}
										}
									}
								
								}
							}
						} else {
							if ($_POST ['r_leave'] == 'fullday') {
								$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
								if ($check1) {
									$full3 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date2'] ), array ('date' => $_POST ['date2'], 'e_id' => $e_id ) );
									
									if ($full3) {
										?>
								
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								} else {
									$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date2'] ) );
									
									if ($query1) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								}
							}
							
							if ($_POST ['r_leave'] == 'secondhalf') {
								$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
								if ($check1) {
									$sec3 = $db->update ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => 0.50, 'firsthalf' => 0.00, 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date2'] ), array ('date' => $_POST ['date2'], 'e_id' => $e_id ) );
									if ($sec3) {
										?>
								
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								} else {
									$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date2'] ) );
								}
							}
							if ($_POST ['r_leave'] == 'firsthalf') {
								$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $_POST ['date2'] ) );
								if ($check1) {
									$first3 = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => 0.50, 'secondhalf' => 0.00, 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date2'] ), array ('date' => $_POST ['date2'], 'e_id' => $e_id ) );
									if ($first3) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
							<?php
									
									}
								} else {
									$query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $_POST ['date2'] ) );
									
									if ($query1) {
										?>
								<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								
								
							<?php
									
									}
								}
							}
						}
					
					}
					
					if ($date1 <= $date2 && $date1 != '' && $date2 != '') {
						$a = $date1;
						$b = $date2;
						
						if ($_FILES ['application'] ['name'] != '') {
							
							// we create an instance of the class, giving as
							// argument the PHP object
							// corresponding to the file field from the form
							// All the uploads are accessible from the PHP
							// object $_FILES
							
							$name11 = mt_rand ( 15, 250 ) . '___' . mb_strtolower ( preg_replace ( '/\s+/', '', $_FILES ['application'] ['name'] ) );
							$_FILES ['application'] ['name'] = str_replace ( array ('(', ')' ), '', $name11 );
							$handle = new upload ( $_FILES ['application'] );
							
							// then we check if the file has been uploaded
							// properly
							// in its *temporary* location in the server (often,
							// it is /tmp)
							if ($handle->uploaded) {
								// yes, the file is on the server
								// now, we start the upload 'process'. That is,
								// to copy the uploaded file
								// from its temporary location to the wanted
								// location
								// It could be something like
								// $handle->Process('/home/www/my_uploads/');
								// we now process the image a second time, with
								// some other settings
								
								$handle->image_resize = true;
								$handle->image_ratio_crop = true;
								$handle->image_y = 200;
								$handle->image_x = 250;
								
								$handle->Process ( $dir_dest );
								
								// we check if everything went OK
								if ($handle->processed) {
									// everything was fine !
									$application = $_FILES ['application'] ['name'];
									while ( $a <= $b ) {
										
										$c = date ( 'Y-m-d', $a );
										
										if ($_POST ['r_leave'] == 'fullday') {
											$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
											if ($check1) {
												$xwhile = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $c ), array ('date' => $c, 'e_id' => $e_id ) );
											} else {
												$wwhile = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $c ) );
											}
										}
										
										if ($_POST ['r_leave'] == 'secondhalf') {
											$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
											if ($check1) {
												$xwhile = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => 0.00, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $c ), array ('date' => $c, 'e_id' => $e_id ) );
											} else {
												$wwhile = $query1 = $db->insert ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $c ) );
											}
										}
										if ($_POST ['r_leave'] == 'firsthalf') {
											$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
											if ($check1) {
												$xwhile = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => 0.00, 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $c ), array ('date' => $c, 'e_id' => $e_id ) );
											} else {
												$wwhile = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'application' => $application, 'date' => $c ) );
											}
										}
										
										$d = date ( 'Y-m-d', strtotime ( $c . "+ 1 days" ) );
										$a = strtotime ( $d );
									
									}
									if ($xwhile) {
										?>
									<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								<?php
									
									}
									if ($wwhile) {
										?>
									<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
								<?php
									
									}
								}
							}
						} else {
							while ( $a <= $b ) {
								
								$c = date ( 'Y-m-d', $a );
								
								if ($_POST ['r_leave'] == 'fullday') {
									$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
									if ($check1) {
										$xwhile = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $c ), array ('date' => $c, 'e_id' => $e_id ) );
									} else {
										$wwhile = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $c ) );
									}
								}
								
								if ($_POST ['r_leave'] == 'secondhalf') {
									$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
									if ($check1) {
										$xwhile = $db->update ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => 0.50, 'firsthalf' => 0.00, 't_leave' => $_POST ['t_leave'], 'date' => $c ), array ('date' => $c, 'e_id' => $e_id ) );
									} else {
										$wwhile = $db->insert ( 'attendence', array ('e_id' => $e_id, 'secondhalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $c ) );
									}
								}
								if ($_POST ['r_leave'] == 'firsthalf') {
									$check1 = $db->exists ( 'attendence', array ('e_id' => $e_id, 'date' => $c ) );
									if ($check1) {
										$xwhile = $db->update ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => 0.50, 'secondhalf' => 0.00, 't_leave' => $_POST ['t_leave'], 'date' => $c ), array ('date' => $c, 'e_id' => $e_id ) );
									} else {
										$wwhile = $db->insert ( 'attendence', array ('e_id' => $e_id, 'firsthalf' => '0.50', 't_leave' => $_POST ['t_leave'], 'date' => $c ) );
									}
								}
								
								$d = date ( 'Y-m-d', strtotime ( $c . "+ 1 days" ) );
								$a = strtotime ( $d );
							
							}
							if ($xwhile) {
								?>
									<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Updated...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
						<?php
							
							}
							if ($wwhile) {
								?>
									<div id="hide">
		<div id="gritter-notice-wrapper">
			<div id="gritter-item-1" class="gritter-item-wrapper gritter-success"
				style="">
				<div class="gritter-top"></div>
				<div class="gritter-item">

					<div class="gritter-without-image">
						<span class="gritter-title">Cheers..
							<div class="gritter-close" id="gritterremove"
								style="display: inline;"></div>
						</span>
						<p>Your Record Is Inserted...</p>
					</div>
					<div style="clear: both"></div>
				</div>
				<div class="gritter-bottom"></div>
			</div>
		</div>
	</div>
						<?php
							
							}
						}
					}
				
				}
			}
		}
		
		?>