<?php 
$PageSecurity = 2;
$title = _('Employee Master') ;
include('includes/SQL_CommonFunctions.inc');
include('includes/othrs.php');
?>

<?php
if($_REQUEST['save'])
{
	function extension($filename)
		{
			$name_brk=explode('.',$filename);
			return  $name_brk[1];
		}
		
       $qty=$_FILES['docmnt']['name'];
		 $FinempCode1=rand(0,9999);
		for($i=0;$i<count($qty);$i++)
		{ 
			if($_FILES['docmnt']['name'][$i]!='')
			{
					$tmp_name=$_FILES['docmnt']['tmp_name'][$i];
					$name=$_FILES['docmnt']['name'][$i];

					echo $type=extension($name);
					//$new_name2[]=$name;
			  	   $path="uploaded_docs/HR/applicant/".$name;
					$file_copy=move_uploaded_file($tmp_name,$path);

					if(!$file_copy)
					{
						echo "<strong>Copy Unsuccessful</strong>";
						$flag=1;
					}
					else
					{
						$dataArr1['hr_applcnt_rgstn_id']=$_REQUEST['id'];
						$dataArr1['hr_applcnt_rgstn_appointment_id']=$_REQUEST['appid'];
					    $dataArr1['document']=$name;
					    $dataArr1['created_by']=$_SESSION['UserID'];    
					    $dataArr1['created_date']=date('Y-m-d H:i:s');
					    $s->RecordInsert('hr_applcnt_rgstn_doc',$dataArr1);
					}
//print_r($file_copy);
				//$file_copy=move_uploaded_file($tmp_name,$path);
				//if(!$file_copy)
				//{
				//	echo "<strong>Copy Unsuccessful</strong>";
					//$flag=1;
				//}	    
			}
		}
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">

<form method="post" name="uploadfile" action="" enctype="multipart/form-data">
<div class="body_contain">
<div class="tab_div"> 
		<!--Uploads box-->
		<input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>">
		<input type="hid" name="appid" value="<?php echo $_REQUEST['appid'];?>">
	<div class="box">
	<h3>Document Uploading</h3>
	<table width="100%" border="0" cellpadding="3" cellspacing="0">
	<tr class="row1">
		<td colspan="3" style="text-align:left;">
		<input type="button" onclick="addRow('dataTable')" class="search" value="Add More" />
		<input type="button" onclick="deleteRow('dataTable')" class="search" value="Delete Row" />
		</td>
	</tr>
	<tbody id="dataTable">
	<tr class="row1">
		<td width="5%"><input type="checkbox" name="chk" /></td>	
		<td width="10%"><strong>Upload Document</strong></td>
		<td><input type="file" name="docmnt[]" id="docmnt"  tabindex="69" style="width:98%;" />
		<input type="hidden" name="docmnt1" id="docmnt1" value="<?php echo $document;?>" tabindex="70"/></td>
	</tr>
	</tbody>
	<input type="hidden" id="hiditemcount" />
	</table>
	<table>
		<tr>
			<td><input class="search" type="submit" value="Save" name="save">
		<input class="search" type="submit" value="cancel" name="calcel"></td>
			
		</tr>
	</table>
	</div>
	</div>
	</div>
	</form>
