/home/mip/public_html_/old-website/apply_online_doc.php
<?
require_once("func_proc.php");
do_header("Apply Online: Document Attachment","online application");
do_menu();
if ($table=="web_doc_library") $personal_table = "web_personal"; else $personal_table = "personal";
if ($table=="web_doc_library") $table = "web_doc_library"; else $table = "doc_library";
$phpself = basename($PHP_SELF);
$arr_doc_type = getdata("Select * from doc_type order by name");
?>
<link href="apply.css" rel="stylesheet" type="text/css">
<div align="center">
<table width="92%" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td width="100%" height="170" align="right" valign="top">
		<table width="100%" height="159" border="0" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="100%" height="170" valign="top">
			<div style="padding-top:3px; background-color:#FFFFFF" align="left" class="applyonline"><font size=2 color=maroon><b>Apply Online</b></font>&nbsp;</div>
				<!-- start -->
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="jobs1">
				<tr>
					<td style="padding-top:10px;" align="center" class="style3">
					<? if($table=='doc_library') { ?><a href="apply_online.php?applicant_id=<?=$applicant_id?>&table=personal&action=check_again">Personal</a> | <a href="apply_online_education.php?applicant_id=<?=$applicant_id?>&table=education&action=check">Education</a> | <a href="apply_online_employment.php?applicant_id=<?=$applicant_id?>&table=employment&action=check">Work Experience</a> | <a href="apply_online_training.php?applicant_id=<?=$applicant_id?>&table=training&action=check">Trainings/Seminars </a> | <a href="apply_online_doc.php?applicant_id=<?=$applicant_id?>&table=doc_library&action=check"><?=($phpself=="apply_online_doc.php")? "<font color='#000000'>" : ""?>Document Attachment</font> </a> | <a href="apply_lineup.php?applicant_id=<?=$applicant_id?>&table=prequalify&action=check">Line-up</a>
					<? if(getWEcount("employment",$applicant_id) > '0' && getEDcount("education",$applicant_id) > '0') { ?>
					| <a href="jobs.php"> Logout </a>
					<? } else { ?>
					| <a href="#" onClick="return alertme();"> Logout </a>
					<? } } else {?>
					<a href="apply_online.php?applicant_id=<?=$applicant_id?>&table=web_personal&action=check">Personal</a> | <a href="apply_online_education.php?applicant_id=<?=$applicant_id?>&table=web_education&action=check">Education</a> | <a href="apply_online_employment.php?applicant_id=<?=$applicant_id?>&table=web_employment&action=check">Work Experience</a> | <a href="apply_online_training.php?applicant_id=<?=$applicant_id?>&table=web_training&action=check">Trainings/Seminars </a> | <a href="apply_online_doc.php?applicant_id=<?=$applicant_id?>&table=web_doc_library&action=check"><?=($phpself=="apply_online_doc.php")? "<font color='#000000'>" : ""?>Document Attachment</font> </a>
					<? if(getWEcount("web_employment",$applicant_id) > '0' && getEDcount("web_education",$applicant_id) > '0') { ?>
					| <a href="thankyou_apply.php?applicant_id=<?=$applicant_id?>&table=<?=$table?>"> Finish Application </a>
					<? } else { ?>
					| <a href="#" onClick="return alertme();"> Finish Application </a>
					<? } } ?>
				</td></tr>
				<tr><td>
				<?
				$personal = getdata_one("*",$personal_table,"applicant_id",$applicant_id); 
				$position_name = getname($personal['position_id1'],"positions","position_id"); 
	
				$formname="thisonly";
				$inputname= array("doc_name");
				$displayname= array("Document Name");
				JS_CheckRequired($formname,$inputname,$displayname,"","");		
	
				$doclibrary = getdata("select * from $table where applicant_id='$applicant_id' and id != '$id' order by date_submitted desc");										 	  
				$num_doclibrary = count($doclibrary);
										 
				if($id){
					$doclibrary1 = getdata("select * from $table where id = '$id' and applicant_id='$applicant_id'");
					echo "<form method=post action='sqlupdate.php?what=web_doc&id=$id' name='$formname' onsubmit='return CheckRequired()' enctype='MULTIPART/FORM-DATA' >";
					
				} else{
					 echo "<form method=post action='sqladd.php?what=web_doc' name='$formname' onsubmit='return CheckRequired()' enctype='MULTIPART/FORM-DATA' >";
				}
				echo "<input type='hidden' name='applicant_id' value='$applicant_id'>";
				?>
					<table width=100% border="0" cellpadding="4" cellspacing="4">
					<tr align="left">
						<td>
							<table width=100% border=0>
							<tr>
								<td align=right colspan="2">Step <b><font color="#0099FF">5</font></b> of 5</td>
							</tr>
							<tr>
								<td align="left" valign="bottom"><b>Position-</b> <?=$position_name?></td>
								<td align="right"><a href="<?=$pic_dir.$personal[picture]?>" rel="lightbox" title="<?=$personal[applicant_id]?>"><? if ($personal[picture]){echo resize_pic1(60,60,$pic_dir.$personal[picture],"","","","1");}?></a></td>
							</tr>
							<tr>
							<td colspan="2"><font size=2 color="#0099FF"><b>Document Attachment</b></font> - <?=$personal[fname]." ".$personal[mname]." ".$personal[lname]?></td>
							</tr>
							</table>
						</td>
					</tr>
					<?if ($doclibrary){?>
					<tr><td valign=top>
						<table cellpadding="5" cellspacing="1" width="100%">									
						<tr>						
							<td align="left" class="report1" width="1%"></td>					
							<td width=26% align="left" class="report1"><b>Document Name</b></td>
							<td width=20% align="left" class="report1"><b>Document Type</b></td>
							<td class="report1" align=left width=14%><b>CV and Files Attached</b></td>
							<!--<td width=15% align="left" class="report1"><b>Date Submitted</b></td>
							<td width=15% align="left" class="report1"><b>Date Withdrawn</b></td>-->
							<td class="report1" align=left width=10%><b>Action</b></td>
						</tr>
						<?for ($i=1; $i<=$num_doclibrary; $i++){?>
						<tr>						
							<td align="left" class="report"><?=$i?>.</td>
							<td align="left" class="report"><?=$doclibrary[$i][doc_name]?></td>
							<td align="left" class="report"><?=getfield("name", "doc_type", "type_id", $doclibrary[$i][type_id])?></td>
							<td align="left" class="report">
							<a href="<?=$doc_dir.$applicant_id?>/<?=$doclibrary[$i][doc_file]?>" target="_blank"><?
							if($doclibrary[$i][doc_file]){?>
							<img src="http://isdphilippines.com/irisonline/img/clip.gif" border=0><?}?>&nbsp;<font color=maroon><?=$doclibrary[$i][doc_file]?></font>
							</a>
							</td>
							<!--<td align="left" class="report"><?=dateformat($doclibrary[$i][date_submitted])?></td>
							<td align="left" class="report"><?=dateformat($doclibrary[$i][date_withdrawn])?></td>-->
							<td class="data" align=center>	
							<a href="<?=$PHP_SELF?>?what=doc_edit&id=<?=$doclibrary[$i][id]?>&applicant_id=<?=$applicant_id?>&table=<?=$table?>">Edit</a> 
							<a href="sqldelete.php?what=web_doc&id=<?=$doclibrary[$i][id]?>&applicant_id=<?=$applicant_id?>&table=<?=$table?>" onclick="return confirm('Are you sure you want to delete this?')">Delete</a></td>
						</tr>			
						<?}?>
						</table>
					</td></tr>
					<?}?>			
					<tr><td valign="top" align=center>
						<input type="hidden" name="applicant_id" value="<?=$applicant_id?>">
						<input type="hidden" name="table" value="<?=$table?>">
						<table border="0" cellpadding="4" cellspacing="4">				  					   			
						<tr>
							<td align="left"><b>Document Name:<span style="color:#FF0000;"> </span></b></td>
							<td align="left"><input type=text name="doc_name"  size=41 value="<?=$doclibrary1[1][doc_name]?>">&nbsp;</td>
						</tr>				 				
						<tr>
							<td align="left"><b>Document Type:<span style="color:#FF0000;"> </span></b></td>     				
							<td align="left">
							<select name="doc_type">
							<option value=""></option>
							<? selectcode($arr_doc_type,$doclibrary1[1][type_id],"type_id","name");?>
							</select>
							&nbsp;</td>
						</tr>				 
						<tr>				 												
							<td align="left"><b>CV and Files Attached:</b></td>
							<td align="left">
							<? if($doclibrary1[1][doc_file]){?>
								<a href="<?=$doc_dir.$applicant_id?>/<?=$doclibrary1[1][doc_file]?>" target="_blank"><img src="irisonline/img/clip.gif" border=0> <font size=1 color=maroon><?=$doclibrary1[1][doc_file]?></font></a>
								<a href="sqldelete.php?what=web_doc_library_file&id=<?=$doclibrary1[1][id]?>&applicant_id=<?=$applicant_id?>&table=<?=$table?>" onclick="return confirm('Are you sure you want to delete this?')"><font size=1 color=maroon>[delete]</font></a>
							<? }else{ ?>
								<input type="file" name="docfile" size=30>
							<? } ?>	
							</td>
						</tr>
						<!--<tr>
							<td align="left" valign=top><b>Date Submitted:</b>	</td>
							<td align="left">
							<?list ($year, $month, $day) = split ('[-]', $doclibrary1[1][date_submitted]);?>
							<?echo dateselect("day","day","$day",0,0);?>
							<?echo dateselect("month","month","$month",0,0);?>
							<?echo dateselect("year","year","$year",50,0,0);?>
							&nbsp;</td>										 
						</tr>
						<tr>
							<td align="left" valign=top><b>Date Withdrawn:</b></td>
							<td align="left">
							<?list ($wyear, $wmonth, $wday) = split ('[-]', $doclibrary1[1][date_withdrawn]);?>
							<?echo dateselect("wday","day","$wday",0,0);?>
							<?echo dateselect("wmonth","month","$wmonth",0,0);?> 						    
							<?echo dateselect("wyear","year","$wyear",50,0,0);?>
							&nbsp;</td>										 
						</tr>-->
						<tr>
							<?if ($id) $sval = "Save"; else $sval= "Add"; ?>   				 
							<td colspan=2  align=center><input type=submit value="  <?=$sval?>  " name="user" class="button">
							</form>
							<form method="post" action="thankyou_apply.php?applicant_id=<?=$applicant_id?>&table=<?=$table?>">
							<input type="hidden" name="applicant_id" value="<?=$applicant_id?>">

							<? 
							if($table=='doc_library') {
								$tab1 = 'employment';
								$tab2 = 'education';
							} else {
								$tab1 = 'web_employment';
								$tab2 = 'web_education';							
							}
							if(getWEcount($tab1,$applicant_id) > '0' && getEDcount($tab2,$applicant_id) > '0') { ?>
							<input type="submit" value=" Finish Application ">
							<? } else { ?>
							<input type="submit" value=" Finish Application " onclick="javascript:alert('At Least One Work Experience and Education Record is required'); return false;">
							<? } ?>
							</form>
							</td>
						</tr>				
						</table>
					</td></tr>
					</table>				
					</td>
				</tr>                 
				</table>
				<!-- end -->			
            </td>
        </tr>
        </table>
	</td>
</tr>
</table>
</div>
<?
do_footer(); 
if($msg) echo "<script>alert('$msg')</script>";
?>