<?php 
/********************************************************************************* 
 *  This file is part of Sentrifugo.
 *  Copyright (C) 2014 Sapplica
 *   
 *  Sentrifugo is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Sentrifugo is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Sentrifugo.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Sentrifugo Support <support@sentrifugo.com>
 ********************************************************************************/
?>

<script type="text/javascript" src="<?php echo MEDIA_PATH;?>js/emp-screeing.js" /></script>

<?php if($this->ermsg == '') { 
 if(isset($_SESSION['emp_status']))
 {
	$back_str = '/con/'.$_SESSION['emp_status'];
	unset($_SESSION['emp_status']);
 }
 else 
 {
	$back_str = '';
	unset($_SESSION['emp_status']);
 } 

?>
	
	<?php sapp_Global::generateClientValidations($this->form);?>
	<?php if(isset($this->messages['msgtype']) && isset($this->messages['message']))
	{ ?>
		<div id="dispscreeningtype" class="settingssuccess">
			<?php 
					$flag = $this->messages['msgtype'];
					echo "<div id='messageData' class='ml-alert-1-$flag'><div style='display:block;'><span class='style-1-icon $flag'></span>";
					echo $this->messages['message'];
					echo "</div></div>";
			?>
		</div>	
		
	<?php } ?>

	<div id="error_message" style="display:none;"></div>
	<div class="total-form-controller">
	<form name="<?php echo $this->form->getName(); ?>" id="<?php echo $this->form->getId(); ?>" action="<?php echo $this->form->getAction();?>" method="<?php echo $this->form->getMethod(); ?>">
		<?php if(isset($this->msgarray['StatusError'])){?>
		   <span class="errors"><?php echo $this->msgarray['StatusError'];?></span>
		<?php }?>
		<div class="position_rel">
		<div class="new-form-ui inputheight">
			<label class="required">Change Background Check Status</label>
			<div class="division new-division">
				<?php echo $this->form->bgcheck_status;	?>
				  <span class="errors" id='statuserrormsg'></span>
				  <input type="hidden" value="<?php echo $this->inprocessStatus;?>" id="inpstatus" />
			</div>
		</div>	
		
		<div class="new-form-ui-submit empedit-submit-setup">
			<div id="btnsdiv" style="display:none;">
			<?php if(isset($this->personalData[0]['backgroundchk_status']) && $this->personalData[0]['backgroundchk_status'] != 'Completed')
					{ echo $this->form->submit;	?>
					 <input type ="button" class="clssbmtbtn" id="idbtn" value="Save" />
			<?php } ?>
			</div>
			<button onclick="window.location.href='<?php echo BASE_URL; ?>empscreening<?php echo $back_str;?>';" type="button" id="Cancel" name="Cancel">Cancel</button>
		</div>
		</div>
		<?php if(!empty($this->personalData)) 
		{ ?>
	  <div id="personaldatadiv">
		<?php if($this->hrEmail == 'false' && $this->mngmntEmail == 'false'){?>
			<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>Emails will not work as the HR and Management group emails are not configured.</div>
		<?php }else if($this->hrEmail == 'false'){?>
			<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>Email will not work as the HR group email is not configured.</div>
		<?php }else if($this->mngmntEmail == 'false') { ?>
			<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>Email will not work as the Management email is not configured.</div>
		<?php } ?>
	  <div class="all-bg-ctrl">    		
		<div class="emp-screen-view">     
			<div class="display-img-div" id='displayimg' style="display:none;">
					<div class="employee-pic chg-img">
						<img id="userImage" src="<?php echo DOMAIN; ?>public/media/images/employee-deafult-pic.jpg" />				
					</div>
					<div id="loaderimg" style="display:none; clear:both; margin:0 auto; text-align: center; width:100%;"><img src="<?php echo $this->baseUrl("public/media/images/loaderwhite_21X21.gif");?>" style="width:21px; height: 21px; float: none; "/></div>			
				</div>

			<div id="personalDetailsDiv">
			<?php
					$pfimage = '';
					if(isset($this->personalData[0]['profileImage'])) $pfimage = $this->personalData[0]['profileImage'];
					if($pfimage != '')
					{
						echo "<script type='text/javascript'>
						  $('#userImage').attr('src','".$this->baseUrl()."/public/uploads/profile/$pfimage');
						  $('#displayimg').css('display','block');</script>";
					}else{
						echo "<script type='text/javascript'>
						  $('#displayimg').css('display','block');</script>";
					}
					if(isset($this->personalData[0]['name'])) echo '<p><b>Name <i>:</i></b><span class="emp-name-span">'.$this->personalData[0]['name'].'</span></p>';
					if(isset($this->personalData[0]['email']) && $this->personalData[0]['email'] != '') echo '<p><b>Email Id <i>:</i></b><span><a>'.$this->personalData[0]['email'].'</a></span></p>';
					if(isset($this->personalData[0]['contactnumber']) && $this->personalData[0]['contactnumber'] != '') echo '<p><b>Contact Number <i>:</i></b><span>'.$this->personalData[0]['contactnumber'].'</span></p>';
					if(!empty($this->addressData))
					{
						if(isset($this->addressData[0]['location']) && $this->addressData[0]['location'] != '')echo '<p><b>Address <i>:</i></b><span><u>'.htmlspecialchars($this->addressData[0]['location']).',</u>';
						if(isset($this->addressData[0]['ccity']) && $this->addressData[0]['ccity'] != '') echo '<u>'.$this->addressData[0]['ccity'].',</u>';				
						if(isset($this->addressData[0]['cstate']) && $this->addressData[0]['cstate'] != '') echo '<u>'.$this->addressData[0]['cstate'].',</u>';
						if(isset($this->addressData[0]['ccountry']) && $this->addressData[0]['ccountry'] != '') echo '<u>'.$this->addressData[0]['ccountry'].'</u>';
						if(isset($this->addressData[0]['pincode']) && $this->addressData[0]['pincode'] != '') echo '<u> - '.$this->addressData[0]['pincode'].'</u></span></p>';
					}
					if(isset($this->personalData[0]['ustatus']))
					{
						if($this->personalData[0]['ustatus'] == 'Active')
							echo '<p><b>Status <i>:</i></b><span class="emp-name-span">'.$this->personalData[0]['ustatus'].'</span></p>';
						else
							echo '<p><b>Status <i>:</i></b><span style="color:red;" class="emp-name-span">'.$this->personalData[0]['ustatus'].'</span></p>';
					}
				 ?>
			</div>
		   </div> 
		<?php 
		} ?>

		<?php if(!empty($this->personalData) && !empty($this->companyData)) { ?>
			<div class="all-grid-control mrgebtm mrgetop10">
			  <div class="table-header"><span>Previous Company Details</span></div>
				<div class="details_data_display_block newtablegrid"  id='process_table' style="overflow: hidden; height: auto; background: none repeat scroll 0% 0% rgb(204, 204, 204); padding-bottom: 10px; width: 250px;">
					<table width="100%" cellspacing="0" cellpadding="4" border="0" align="center" class="grid">
						<thead>
							<tr>
								<th style="cursor:default;">Company Name</th>
								<th style="cursor:default;">Website</th>
								<th style="cursor:default;">Designation</th>
								<th	style="cursor:default;">From Date</th>
								<th style="cursor:default;">To Date </th>
							</tr>
						</thead>
					<tbody>
						<?php if(!empty($this->companyData)) 
								{ 
									echo "<script type='text/javascript'>$('#compDetailsDiv').css('display','block');</script>";
									for($i=0; $i < sizeof($this->companyData) ; $i++)
									{
										$divid = $i+1;
										echo '<tr class="row1" id="company'.$divid.'">';    
										echo '<td>'.$this->companyData[$i]['companyname'].'</td>';
										echo '<td>'.$this->companyData[$i]['companywebsite'].'</td>';
										echo '<td>'.$this->companyData[$i]['designation'].'</td>';
										echo '<td>'.$this->companyData[$i]['fromdate'].'</td>';
										echo '<td>'.$this->companyData[$i]['todate'].'</td>';
										echo '</tr>';
									}
						} ?>
					</tbody>
				  </table>
			   </div>
		   </div> 
		 <?php } ?>
					
	</div>	
	</div>	
			
	</form>
	<?php 
	if(sizeof($this->dataArray[0]['tablecontent'])>0) { 
	if($this->call == 'ajaxcall'){
		$div = ''; $endDiv = ''; 
	} else { 
		$div = '<div id="grid_'.$this->dataArray[0]['objectname'].'" class="all-grid-control">'; $endDiv = '</div>';
	}
		echo $div.'<div id="msg" style="display:none;font-style: oblique; font-weight: bold; color: green;""></div>'.$this->grid($this->dataArray[0]).$endDiv;
	}
	?>

	<div id="processesContainer"  style="display: none; overflow: auto;">
		<div class="heading">
		   <a href="javascript:void(0)">
			<img src="<?php echo $this->baseUrl().'/public/media/';?>images/close.png" name="" align="right"	border="0" hspace="3" vspace="5" class="closeAttachPopup" style="margin: -24px 8px 0 0;">
		   </a>
		</div>

			<iframe id="processesCont" class="business_units_iframe" frameborder="0"></iframe>

	</div>

	<div id="inprocessContainer"  style="display: none; overflow: auto;">
		<div class="heading">
			<a href="javascript:void(0)">
			<img src="<?php echo $this->baseUrl().'/public/media/';?>images/close.png" name="" align="right" border="0" hspace="3" vspace="5" class="closeAttachPopup" style="margin: -24px 8px 0 0;"> </a>
		</div>

			<iframe id="statusinprocess" class="business_units_iframe" frameborder="0"></iframe>

	</div>
	</div>
<?php } else { ?>
<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>No data found.</div>
<?php }?>
<script type='text/javascript'>
$(document).ready(function() {

$( "#bgcheck_status" ).change(function () {
	$( "#bgcheck_status option:selected" ).each(function() {
		if($( this ).text() != 'Complete'){
			$('.select2-choice > span').removeClass('greendataClass');
		}else{
			$('.select2-choice > span').addClass('greendataClass');
		}
	});
	
})
.change();



	$('#idbtn').click(function() {	
			var status = $('#inpstatus').val();
			var selectedStatus = $('#bgcheck_status').val();			
            if(status == 'yes' && selectedStatus == 'Complete')	
			{	
			//You are trying to close the background check for the person. Please confirm
                jConfirm("You are trying to close the background check process. Please confirm.", "Confirmation", function(r) {
					if(r==true){							
						$('#submitbutton').trigger('click');
						return true;
					}else {
						return false;
					}
				 });		 
			}
			else {	
				$('#submitbutton').trigger('click');
				return true;
			}			
	});


/* Making window responsive*/
 	var complete_width = $('.emp-screen-view').width();
	$('#displayimg').css("width", "150");
	$('#personalDetailsDiv').css("width", (complete_width-(152)));	
		
	 function checkWidth() {
        var complete_width = $('.emp-screen-view').width();		
		$('#displayimg').css("width", "150");
		$('#personalDetailsDiv').css("width", (complete_width-(152)));		
    }
	$(window).resize(function() {
		checkWidth();
	}); 
/* END */
 $('#process_table').slimScrollHorizontal({
	  alwaysVisible: false,
	  start: 'left',
	  position: 'bottom',
	 
	}).css({ background: '#ccc', paddingBottom: '10px' }); 
<?php if($this->inprocess == 'yes') { ?>
	$("body").append('<div id="blockingdiv" class="ui-widget-overlay ui-front"></div>');	
	$('#inprocessContainer').css('display','block');
	$('#statusinprocess').attr('src', '<?php echo BASE_URL; ?>empscreening/forcedfullupdate/specimenId/'+<?php echo $this->specimenId; ?>+'/empFlag/'+<?php echo $this->empFlag;?>);
	$(".closeAttachPopup").remove();
	window.parent.$('#inprocessContainer').dialog({
						close: function() {
						 $('#blockingdiv').remove(); 
						},
						title: 'Background Check Status'
					});
<?php } else if($this->inprocess == 'samebgstatus') {?>
	$('#statuserrormsg').css('display','block');
	$('#statuserrormsg').html('Please select different option');
<?php } ?>

var spanText = $( "#bgcheck_status" ).val();
if(spanText == 'Complete')
{
	setTimeout("$('.select2-choice > span').addClass('greendataClass');",100);	
}
});//end of ready function

$('#bgcheck_status').on('change', function() {
  var oldval = '';
  var newval = $(this).val();  
  <?php if(isset($this->personalData[0]['backgroundchk_status'])) { ?>
	oldval = '<?php echo $this->personalData[0]['backgroundchk_status'];?>';
  <?php } ?>
  if( oldval != '' && oldval != newval && newval != '0')
  {	
	$('#btnsdiv').css('display','block');
  }
  else
	$('#btnsdiv').css('display','none');
});
</script>
