<?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>
 ********************************************************************************/
?>

<?php if($this->configure == 'notconfigured') { ?>
<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>You cannot add a screening process to the employee as the screening configurations are not set.</div>
<?php } else 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 } ?>
<?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 } ?>

<?php if($this->displaymsg == 'nodata') { ?>
<div class="ml-alert-1-info m1-info-set"><div class="style-1-icon info"></div>No data found</div>
<?php }
else if($this->popup == 'close') { ?>
<div class="ml-alert-1-success">
<div class="style-1-icon success"></div>
Process data <?php echo $this->eventact; ?> successfully.
</div>

<?php } else { ?>

<div class="total-form-controller mrgebtm">
<?php if(isset($this->msgarray['StatusError'])){?>
  <div id="seterrorpopup" class='ml-alert-1-error set-error-popup'><div style='display:block;'><span class='style-1-icon error'></span>
			<?php echo $this->msgarray['StatusError'];?></div></div>
<?php }?>
<div id="error_message" style="display:none;"></div>
<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(); ?>">
	<input type="hidden" id="bgstatusvalue" name="bgstatusvalue" value="<?php echo $this->bgstatus;?>" />
	<?php echo $this->form->id; ?>
		
		<div class="background-check-div">
            <div class="separetor-heading"><span class="required">Screening types</span></div>
            <div class="check-div-inputs"><?php echo $this->form->checktype; ?></div>
			<?php if(isset($this->msgarray['checktype'])){?>
				   <span class="errors" id="errors-<?php echo $this->form->checktype->getId(); ?>"><?php echo $this->msgarray['checktype'];?></span>
			  <?php }?>
              
		<?php echo $this->form->checkagency; ?>
		<?php echo $this->form->agencyids; ?>
        <div class="popup-agency-selecters mrgetop20" style="display:none">
		<div id='chooseagency' style="display:none">
		<?php if(!empty($this->agencyData))
			{ ?>
        <div class="separetor-heading"><span class="required">Choose Agency</span></div>
		<div id="agencyDataDiv" class="left-block-ui-data">
			<?php 
				if(!empty($this->agencyData))
				{
					echo "<script type='text/javascript'>$('#chooseagency').css('display','block');
					$('.popup-agency-selecters').css('display','block');</script>";
				?>
				<div class="agency-ui">
					<select onchange="getPOCData(this,'2');" >			
							<?php 
								for($i=0;$i<sizeof($this->agencyData);$i++)
								{
									if(isset($this->agencyids) && $this->agencyData[$i]['id'] == $this->agencyids) $selected = "selected";else if($i == 0) $selected = "selected"; else $selected = '';
								?>
									<option <?php echo $selected;?> value="<?php echo $this->agencyData[$i]['id'];?>"><?php echo $this->agencyData[$i]['agencyname']; ?></option>
								<?php 
								} ?>
							
						</select>
				</div>
				<?php
				}
				if(isset($this->msgarray['agencyids'])){?>
				   <span class="errors" id="errors-<?php echo $this->form->agencyids->getId(); ?>"><?php echo $this->msgarray['agencyids'];?></span>
			<?php }
				?>
		</div>
		
		
			<div id="pocdataDiv" class="right-block-data">
			<?php
				if(!empty($this->agencyData) && !empty($this->agencyPOCData)) 
				{
					if(isset($this->msgarray['contactRadio'])){	
						echo "<span class='errors mrgebtm3'>".$this->msgarray['contactRadio']."</span>";
					}
					for($i=0;$i<sizeof($this->agencyPOCData);$i++)
					{
						$divid = $i+1;
						if($i==0)$val='(Primary)'; else $val='';
						if($this->agencyPOCData[$i]['pocid'] == $this->contactRadio) $radiochecked = 'checked'; else $radiochecked = ''; 
						echo "<div class='primaryset'><input type='radio' $radiochecked id='Rcontact$divid' value='".$this->agencyPOCData[$i]['pocid']."'  name='contactRadio' />Contact $divid $val</div><div class='contactset' id='contact$divid'>";
						echo '<div class="fltleft-set"><span>'.$this->agencyPOCData[$i]['first_name'].' '.$this->agencyPOCData[$i]['last_name'].'</span>';
						echo '<span>'.$this->agencyPOCData[$i]['contact_no'].',</span></div>';
						echo '<div class="fltright-set"><span>'.htmlspecialchars($this->agencyPOCData[$i]['location']).',</span>';
						echo '<span>'.$this->agencyPOCData[$i]['ccity'].',</span>';
						echo '<span>'.$this->agencyPOCData[$i]['cstate'].',';
						echo ' '.$this->agencyPOCData[$i]['ccountry'].'</span></div>';
						echo '<div class="clear-mail"><b>Email : </b><span><a>'.$this->agencyPOCData[$i]['email'].'</a></span></div>';
						echo "</div>";
					}					
				}
			?>
			</div>
		<?php } else { 
				echo "<script type='text/javascript'>$('#chooseagency').css('display','block');
							$('.popup-agency-selecters').css('display','block');
							</script>";?>
				
				<div class="no-data">No agency</div>
			<?php } ?>
      </div>
	  </div>
	</div>	
		 <div class="new-form-ui-submit mrgetop10">
				<?php $agid = '';if(!isset($this->agencyPOCData[0]['bg_agencyid'])) $agid = ''; else $agid = $this->agencyPOCData[0]['bg_agencyid']; ?>
				<input type="hidden" name="defaultagencyid" id="defaultagencyid" value="<?php echo $agid; ?>">				
				<?php echo $this->form->submit;
                                ?>
                                <input type ="button" class="clssbmtbtn" id="idbtn" value="Save" />
								<button type="button" onclick="closeiframepopup('processes','cancel');">Cancel</button>
		</div>       
	</form>
</div>  

<?php } ?>      
<script type="text/javascript">
$(document).ready(function() {		
	 setTimeout(function(){
			$('#seterrorpopup').fadeOut('slow');
		},3000);
	
	
	$('[id^="agenycnameId"]').removeClass('active');
	//$('#agenycnameId<?php //echo $agid;?>').addClass('active');
	
    	$('#idbtn').click(function() { 
			var status = $('#bgstatusvalue').val();	
            if(status == 'Complete')	
			{
                jConfirm("You are trying to re-open the background check process for the employee/candidate. Please confirm", "Confirmation", function(r) {
					if(r==true){							
						$('#submitbutton').trigger('click');
						return true;
					}else {
						return false;
					}
				 });		 
			}
			else {	
				$('#submitbutton').trigger('click');
				return true;
			}			
	});
	
});

</script>	
<script language='javascript'>
$(document).ready(function() {
	if($("li.active").is(':first-child'))
	{
		$('.right-block-data').addClass('right-over-border');
	}	
}); 
<?php if($this->popup != '') { ?>
        setTimeout(function(){
		    closeiframepopup('<?php echo $this->controllername; ?>',''); 
		},2000);
<?php } ?>

<?php if($this->statusFlag == 'exists') {  ?>
		//jAlert('Already a record with the given data exists. Please insert a new record');
<?php  } ?>
	if ($("#processform input:checkbox:checked").length == 0)
	$('.no-data').remove();
</script>