<?php    
	include_once("../view/header-footer/header.php");     
	include_once("../all-ajax/inner-header.php");
?>    

<script type="text/javascript" src="<?php echo ROOTPATH;?>/view/js/tab/complete_profile.js"> </script>
<script>

$(document).ready(function() { 
            
		$('#upload_resume').on('change', function(){
		   var r = confirm("Do you really want to upload resume");
		   if (r == true) 
		   {  
		    
			var fd = new FormData(); 
			var img_name= $('#img_name').val();
			fd.append('img_name', img_name);				
			var files = $('#upload_resume')[0].files[0];
			//var filestype = ($('#upload_resume')[0].files[0]['type']).split("/");
			fd.append('file', files);

			var iSize = $('#upload_resume')[0].files[0].size/1024; 
			mb_size = iSize/1024;		
			if(mb_size <= 2) 
			{
				$.ajax({ 
					url: URL+"/MyDetails/upload_resume.php", 
					type: 'post', 
					data: fd, 
					contentType: false, 
					processData: false, 
					success: function(response){ 
						if(response==1)
						{ 
						   alert('Resume uploaded successfully'); 
						   location.reload();
						}
						else if(response==2)
						{ 
						   $("#upload_resume").val("");
		                   $("#img_name").val(""); 
						   alert('Only pdf,doc,docx resume formats are allowed');
						}
						else if(response==0)
						{ 
							alert('Resume not uploaded'); 
							$("#upload_resume").val("");
		                    $("#img_name").val("");
						}
					}, 
				}); 
			}
			else 
			{
				$("#upload_resume").val("");
		        $("#img_name").val("");
				alert("Up to 2 MB file size is allow!");
			}
		   }
		   else
		   {
		       $("#upload_resume").val("");
		       $("#img_name").val("");
		   }
		}); 
		
		
	var  role_preference  =  "<?php echo $prefredRoles->user_type; ?>";
    $("#role_preference").hide();
    if((role_preference==2)) 
    {
        $("#role_preference").show();
    }
    else if(role_preference==1)
    {
        $("#role_preference").hide();
    }	
    
    $("#user_type").change(function() 
    {
		 if($(this).val()==1)
	     {
	        //$("#locations_val").val(""); 
	        $("#role_preference").hide();
	        //$("#role_preference1").hide();
	     }
	     else if($(this).val()==2)
	     {
	       $("#role_preference").show();
	       //$("#role_preference1").show();
	     }
    });
    
    $("#complete_profile").submit(function(event)  
	{ 	 
		if ($('#complete_profile').valid())  
		{ 
	        if($("#all_city_val").val()=='')               
            {
                alert("Atleast one city required");
                event.preventDefault();  
            }
            else
            {
                if(($("#user_type").val())==2)
                {
                    if($("#locations_val").val()=='')               
                    {
                        alert("At least one job preference required");
                        event.preventDefault();  
                    }
                }
            }
	    }    
	});
}); 

    function Remove_select_loc_id(type,catId,id,key)
    {
        var r = confirm("Do you really want to remove job preferences");
	    if (r == true) 
	    {
	        $.ajax({	
    			type: "POST",
    			url: URL+"/all-ajax/complete_profile.php", 
    			data: {Get_CategoryCnt:1,type:type,catId:catId,id:id},
    			beforeSend: function(){ 
    			},
    			success: function(cnt)
    			{
        	        if(cnt > 1)
            	    {
            	        $.ajax({	
                			type: "POST",
                			url: URL+"/all-ajax/complete_profile.php", 
                			data: {Remove_select_loc_id:1,type:type,catId:catId,id:id},
                			beforeSend: function(){ 
                			},
                			success: function(res)
                			{
                			    if(res==1)
                			    {
                			        $.ajax({	
                            			type: "POST",
                            			url: URL+"/all-ajax/complete_profile.php", 
                            			data: {Get_remove_loc_id:1,type:type},
                            			beforeSend: function(){ 
                            			},
                            			success: function(rec)
                            			{
                        			        $("#RemoveSubId"+key).remove();
                        			        $('#RemoveSubId'+key).hide();
                        			        if(type==1)
                        			        {
                        			            $("#locations_val").val(rec);
                        			        }
                        			        else if(type==2)
                        			        {
                        			            $("#SubRole_val").val(rec); 
                        			            $.ajax({	
                                        			type: "POST",
                                        			url: URL+"/all-ajax/complete_profile.php", 
                                        			data: {Get_remove_loc_id:1,type:1},
                                        			beforeSend: function(){ 
                                        			},
                                        			success: function(CatRec)
                                        			{
                                        			    $("#locations_val").val(CatRec);
                                        			}
                        			            });
                        			        }
                            			}
                			        });
                			    }
                			}
                	   }); 
            	    }
            	    else alert("At least one job preference required");
    			}
           }); 
	   }      
    }

function goBack() {
  window.history.back();
}
</script>

<div id="body" class="grey-bg">
<div class="wrapper"> 
<div class="col-md-10 bottom leftData plr">
    <div class="white-box">
        
    <div>
<div id="dataRight" class="noRightBor job-filter">

    	<ul class="resList">
<li class="completeProf">
	            <h3 class="postJob pdlr7">Your Advanced Profile <a href="javascript:void(0);"><i class="fa fa-long-arrow-left pull-right" onclick="goBack()"></i></a></h3>	

	<form method="post"  id="complete_profile" autocomplete="off" enctype="multipart/form-data">  <br>
	<div class="row postJobForm pdlr7">
		<div class="col-lg-12 feild-group">
			<label>What is your expected monthly salary (in rupees)?</label>
			<input type="text"  name="salary" Placeholder="Enter your monthly salary" value="<?php if($row->salary!='') echo $row->salary;else echo '';?>"   class="salary">
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>ID Proof</label>
                <ul class="innUl"> 
				 <li>
				  <span> <?php if(in_array("PAN Card", $id_proof)){ ?><input type="checkbox"  name="idproof[]"   checked==checked value="PAN Card"/> PAN Card <?php } else {?><input type="checkbox"  name="idproof[]" value="PAN Card" > PAN Card <?php }?></span>
				 <span><?php if(in_array("Aadhar Card", $id_proof)){ ?><input type="checkbox" name="idproof[]" checked==checked value="Aadhar Card"/> Adhar Card <?php } else {?><input type="checkbox" name="idproof[]" value="Aadhar Card">Adhar Card <?php }?></span>
				<span><?php if(in_array("Voter ID", $id_proof)){ ?><input type="checkbox"  name="idproof[]" checked==checked value="Voter ID"/>Voter ID<?php } else {?> <input type="checkbox"  name="idproof[]" value="Voter ID"> Voter ID <?php } ?></span>
				<span><?php if(in_array("Driving License", $id_proof)){ ?><input type="checkbox"  name="idproof[]" checked==checked value="Driving License"/>Driving License <?php } else {?><input type="checkbox"  name="idproof[]" value="Driving License"> Driving License <?php } ?></span>
				</li>				
			   </ul>
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>Designation e.g. (Marketing Expert)</label>
			<input type="text"  name="designation" Placeholder="Enter your designation" value="<?php if($row->designation!='') echo $row->designation;else echo '';?>"   class="salary">
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>Worked For e.g. (Tata Motors. Ltd)</label>
			<input type="text"  name="workedfor" Placeholder="worked for e.g. (Tata Motors. Ltd)" value="<?php if($row->workedfor!='') echo $row->workedfor;else echo '';?>"   class="salary">
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>Specialization e.g. (Management)</label>
			<input type="text"  name="special" Placeholder="Specialization e.g.(Management)" value="<?php if($row->special!='')echo $row->special;else echo '';?>"   class="salary">
		</div>
		
		<div class="col-xs-12 col-md-4 col-lg-6 feild-group">
			<label>Year of Working e.g.(5)</label>  
			<select name="yearsofworking"  id="yearsofworking" class="salary">
			   <option value="" <?php  if($row->yearsofworking=='') echo "selected=selected";?> >Select Year</option>
			<?php 
				for($i=0;$i<=30;$i++)
				{
			 ?>
			 <option value="<?php echo $i;?>" <?php  if($row->yearsofworking==$i) echo "selected=selected";?> ><?php echo $i;?></option>
			<?php } ?>
			</select>
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>Are you comfortable with working Full Time and Part Time? </label>
			  <ul class="innUl">  
				<li>
                    <span> <?php if(in_array(1, $job_comfort)){ ?><input type="checkbox"  name="job_comfort[]"   checked==checked value="1"/> Full Time <?php } else {?><input type="checkbox"  name="job_comfort[]" value="1" > Full Time<?php }?></span>
                    <span> <?php if(in_array(2, $job_comfort)){ ?><input type="checkbox"  name="job_comfort[]"   checked==checked value="2"/> Part Time <?php } else {?><input type="checkbox"  name="job_comfort[]" value="2" > Part Time<?php }?></span> 
				</li>
			  </ul>
		</div>
		
		<div class="col-lg-12 feild-group ">
			<label>Which languages do you know?</label> 
			<ul class="innUl lang">                 			
			   <li>
				  <span><?php if(in_array("Hindi", $language)){ ?><input type="checkbox"  name="language[]" checked==checked value="Hindi"/> Hindi <?php } else {?><input type="checkbox"  name="language[]" value="Hindi"> Hindi <?php } ?></span>
				  <span><?php if(in_array("English", $language)){ ?><input type="checkbox" name="language[]" checked==checked value="English"/> English <?php } else {?> <input type="checkbox" name="language[]" value="English"> English <?php } ?></span>
				  <span><?php if(in_array("Marathi", $language)){ ?><input type="checkbox"  name="language[]" checked==checked  value="Marathi"/> Marathi <?php } else {?> <input type="checkbox"  name="language[]" value="Marathi"> Marathi <?php } ?></span>
				  <span><?php if(in_array("Tamil", $language)){ ?><input type="checkbox"  name="language[]" checked==checked value="Tamil"/> Tamil <?php } else {?> <input type="checkbox"  name="language[]" value="Tamil"> Tamil <?php } ?></span>
				  <span><?php if(in_array("Telgu", $language)){ ?><input type="checkbox"  name="language[]" checked==checked value="Telgu" /> Telgu <?php } else {?> <input type="checkbox"  name="language[]" value="Telgu"> Telgu <?php } ?></span>
				  <span><?php if(in_array("Bengali", $language)){ ?><input type="checkbox" name="language[]" checked==checked value="Bengali"/> Bengali <?php } else {?> <input type="checkbox"  name="language[]" value="Bengali"> Bengali <?php } ?></span>
				 <span><?php if (in_array("Gujarati", $language)){?> <input type="checkbox"  name="language[]" checked==checked value="Gujarati"/> Gujarati <?php } else {?> <input type="checkbox"  name="language[]" value="Gujarati"> Gujarati <?php } ?></span>
				  <span><?php if(in_array("Kannada", $language)){ ?><input type="checkbox"  name="language[]" checked==checked /> Kannada <?php } else {?> <input type="checkbox"  name="language[]" value="Kannada"> Kannada <?php } ?></span>
				  <span><?php if(in_array("Punjabi", $language)){ ?><input type="checkbox"  name="language[]" checked==checked value="Punjabi"/> Punjabi <?php } else {?> <input type="checkbox"  name="language[]" value="Punjabi"> Punjabi <?php } ?></span>
				  <span><?php if(in_array("Odia", $language)){ ?><input type="checkbox" name="language[]" checked==checked value="Odia"/> Odia <?php } else {?> <input type="checkbox"  name="language[]" value="Odia"> Odia <?php } ?></span>
				  <span><?php if(in_array("Malayalam", $language)){ ?><input type="checkbox"  name="language[]" checked==checked value="Malayalam"/> Malayalam <?php } else {?> <input type="checkbox"  name="language[]" value="Malayalam"> Malayalam <?php } ?></span>
				 <span> <?php if(in_array("Assamese", $language)){ ?><input type="checkbox"  name="language[]" checked==checked value="Assamese"/> Assamese <?php } else {?> <input type="checkbox"  name="language[]" value="Assamese"> Assamese <?php } ?></span>
			  </li>			
			</ul>
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>What is your highest education qualifications ? e.g. (BEIT, MBA)</label>
			<input type="text"  name="education" Placeholder="Enter your eduction e.g.(BEIT, MBA)" value="<?php if($row->education!='')echo $row->education;else echo '';?>"  class="salary">
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>Do You have a passport </label>
			   <ul class="innUl">   
				<li>
				 <?php if($row->passport==1){ ?><span><input type="radio"  name="passport" checked==checked value="1"/> Yes</span>  
				 <span><input type="radio"  name="passport"  value="0" /> No </span>
				 <?php } else { ?><span><input type="radio"  name="passport"  value="1"/> Yes</span>  
				 <span><input type="radio"  name="passport" checked==checked value="0" /> No </span> 
				 <?php } ?> 
				</li>
			  </ul>
		</div>		
		
		<!--<div class="col-xs-12 col-md-4 col-lg-6 comboOut">
			<label>Select cities where you wants to highlight your profile </label>   
			<input type="text"  placeholder="E.q. Nashik" id="all_city_id" name="all_city_id" value="<?php echo $_COOKIE['search_city_name'];?>"  class="inputText">  
			<ul id="ul-city-ajax">
					<?php 
					foreach($city_id as $dt)
					{
					?>
					<a href="javascript:void(0)">
						<li onclick="select_sub_locns('<?php echo $dt->name;?>',<?php echo $dt->id;?>)" ><?php echo $dt->name;?></li> 
					</a>
				<?php } ?>
			</ul> 
			<input type="hidden"   id="search_city_id_hidden" name="search_city_id_hidden" value="<?php echo $_COOKIE['search_city_id'];?>"  class="inputText">
		</div>
		<div id="city-ajax"></div>-->
		<?php
		$stmt =  $conn->prepare("select id,name from all_cities where id=:id");
		$stmt->bindValue(':id', $row->all_city_id, PDO::PARAM_INT);	
		$stmt->execute();   
		$city_details = $stmt->fetch(PDO::FETCH_OBJ); 
		$city_name=$city_details->name;					
		?>
		
		<div class="col-lg-12 feild-group">
			<label>Select cities where you wants to highlight your profile </label>   
			<input type="text"  placeholder="E.q. Nashik" name="all_city_id" id="profile_city_search" class="salary">
			
			<ul id="city_next" class="menu-box-2">
					<?php 
					$stmt =  $conn->prepare("select id,name from all_cities order by  state_code desc ");          
					$stmt->execute();   
					$city_id = $stmt->fetchAll(PDO::FETCH_OBJ);					
					foreach($city_id as $dt)
					{
					?>
					<a href="javascript:void(0)"><li onclick="select_city('<?php echo $dt->name;?>',<?php echo $dt->id;?>)"><?php echo $dt->name;?></li> 
					</a>
				<?php } ?>
			</ul> 	
			<div id="city-ajax"></div>
		<input type="hidden" name="city_search_cityid_hidden" id="city_search_cityid_hidden"  value="<?php echo $_COOKIE['site_city'];?>" />
		</div>
		
		<?php 
			$city_test_array = explode(",",$row->all_city_id);
			foreach($city_test_array as $ky=>$dt) 
			{
				$stmt =  $conn->prepare("select name, id  from all_cities where id=:id");   
				$stmt->bindValue(':id',$dt, PDO::PARAM_INT); 
				$stmt->execute();   
				$city_res = $stmt->fetch(PDO::FETCH_OBJ);  
				$city_name=$city_res->name;
			?>
				<script>   
                    AddCity('<?php echo $city_name;?>',<?php echo $dt;?>);
                </script> 
            <?php
				$all_city_placed .= '<a  href=javascript:void(0) onclick=select_city_id("'.$ky.'")>'.$city_name.' X</a>';
			}     
		?>
		
		<div class="col-md-12 feild-group" >
		      <span id="all_city_placed" class="local-tabs">
    		      <?php echo $all_city_placed; ?>  
		      </span>	 
			<input type="hidden"  id="all_city_val" name="all_city_val"  value="<?php echo $row->all_city_id; ?>"/>  
		</div>
		
		<div class="col-lg-12 feild-group">
			<label>Update Resume</label>
			<input type="file" value="<?php if($row->upload_resume!=''){ echo $row->upload_resume;}?>"  name="upload_resume" id="upload_resume" Placeholder="Enter your eduction e.g.(BEIT, MBA)" class="salary" style="padding:10px 0px;">
			<input type="hidden" name="img_name" id="img_name" value="<?php echo $row->upload_resume;?>" />
		</div>
		
		<!------------------------>
		<div class="col-xs-12 col-md-4 col-lg-6 feild-group">
		    <label>Type</label>
		    <select name="user_type" id="user_type" class="gender inputText">
                <?php if($prefredRoles->user_type==1) { ?>
                <option value="1" <?php if($prefredRoles->user_type==1) echo "selected=selected";?>>I dont need job</option>
                <?php } else if($prefredRoles->user_type==2) { ?>
                <option value="2" <?php if($prefredRoles->user_type==2) echo "selected=selected";?>>I  need  job</option>
                <?php } else if(($prefredRoles->user_type==0) || ($prefredRoles->user_type=='')) { ?>
                <option value="" <?php if(($prefredRoles->user_type==0) || ($prefredRoles->user_type=='')) echo "selected=selected";?>>Please Select User Type</option>
                <option value="1" <?php if($prefredRoles->user_type==1) echo "selected=selected";?>>I Have Business</option>
                 <option value="2" <?php if($prefredRoles->user_type==2) echo "selected=selected";?>>I Need Job</option>
                <?php } ?>
            </select>
		</div>    
		<div class="clear"></div>
		
		<div class="col-lg-12 feild-group" id="role_preference">
		    <label>Job Preferences</label>
		    <input class="salary"  placeholder="Your Job Preferences  E.q. Marketing , Account " id="job-category"  name="job_category">
			<ul id="job-category-sugeetion" class="menu-box">
				<?php 
				
                $test_array = explode(",",$prefredRoles->prefredRoles);	
                if($prefredRoles->sub_prefredRoles!="")
                {
                  $test_array1 = explode(",",$prefredRoles->sub_prefredRoles);	
                }
                else $test_array1="";
                
                if($prefredRoles->prefredRoles!='')
                {
                    $sr=0;
                    $tt=0;
                    foreach($test_array as $ky=>$dt) 
                    {
                        
                        $stmt =  $conn->prepare("select name  from  job_categories where id=:id");   
                        $stmt->bindValue(':id',$dt, PDO::PARAM_INT); 
                        $stmt->execute();   
                        $location_name = $stmt->fetch(PDO::FETCH_OBJ);  
                        $loc_name=$location_name->name; 
                        
                        
                        $stmt =  $conn->prepare("select name,id from sub_job_categories where category_id=$dt  ");          
            	        $stmt->execute();
            	        $sub_job_categories_cnt = $stmt->rowCount();
            	        if($sub_job_categories_cnt > 0)
            	        {
                	        $sub_job_categories=$stmt->fetchAll(PDO::FETCH_OBJ);
                	        foreach($sub_job_categories as $sub_key=>$sub_dt)
                	        {
                	            if(!empty($test_array1))
                	            {
                    	            if(in_array($sub_dt->id, $test_array1))
                    	            {
                    	                $sr++;
                    	                
                    	                $cat_id=$dt;
                    	           ?>
                    	            <script>   
                                        SubAddlocation('<?php echo $sub_dt->name;?>',<?php echo $sub_dt->id;?>);
                                    </script> 
                    	           <?php
                    	                $Locations .= '<a  href=javascript:void(0) id="RemoveSubId'.$sr.'" onclick=Remove_select_loc_id(2,"'.$dt.'","'.$sub_dt->id.'","'.$sr.'")>'.$sub_dt->name.' X</a>';
                    	                ///$Locations .= '<a  href=javascript:void(0) onclick=select_Subloc_id("'.$sub_key.'")>'.$sub_dt->name.' X</a>';
                    	            }
                	            }
                	        }
            	        }
            	        
            	        $sr++;
                    ?>
                    <script>   
                        Addlocation('<?php echo $loc_name;?>',<?php echo $dt;?>);
                    </script> 
                    <?php   
                        if($dt!=$cat_id)
            	        {
                          $Locations .= '<a  href=javascript:void(0) id="RemoveSubId'.$sr.'" onclick=Remove_select_loc_id(1,"'.$dt.'","'.$dt.'","'.$sr.'")>'.$loc_name.' X</a>';
                        }
                    }
                }
                
                $stmt =  $conn->prepare("select name, id  from job_categories ORDER BY name");	
            	$stmt->execute();   
            	$affected_rows_job_category = $stmt->rowCount();  
            	$job_categories = $stmt->fetchAll(PDO::FETCH_OBJ);
				foreach($job_categories as $key=>$job_dtt)
				{ 
				?> 
					<a href="javascript:void(0)">
						<li onclick="select_role_post_job('<?php echo $job_dtt->name;?>',<?php echo $job_dtt->id;?>,<?php echo $job_dtt->id;?>)" ><?php echo $job_dtt->name;?></li> 
					</a>
				<?php } ?>
			</ul> 
			<div id="job-category-sugeetion-ajax"></div>
		</div>    
		
		<div class="clearfix"></div>
		<div class="col-md-12">
		    <div id="job-sub-category" class="job-sub job-filter"></div> 
		</div>
		
		<div class="col-lg-12 feild-group" id="role_preference1">
		    <span id="locality_placed" class="local-tabs"> <?php echo $Locations; ?>  	</span>	 
		    
            <input type="hidden"  id="locations_val" name="locations_val"  value="<?php echo $prefredRoles->prefredRoles; ?>"/>
            <input type="hidden" id="job_cat_val" name="job_cat_val" value=""/>
            <input type="hidden"  id="SubRole_val" name="SubRole_val"  value="<?php echo $prefredRoles->sub_prefredRoles; ?>"/>
        </div>
		
		
		<!------------------------>
		
		<div class="col-lg-12 feild-group">
			<label>Profile Status</label>  
			<select name="job_profile_status"  id="job_profile_status" class="salary">
			   <option value="" <?php  if($login_details->job_profile_status=='') echo "selected=selected";?> >Select Status</option>
			   <option value="0" <?php  if($login_details->job_profile_status==0) echo "selected=selected";?> >Inactive</option>
			   <option value="1" <?php  if($login_details->job_profile_status==1) echo "selected=selected";?> >Active</option>
			</select>
		</div>
		
		<div class="clear"></div>
		<div class="col-lg-12">
		    <input type="submit" name="submit" value="Update Advanced Profile" class="btn btn52"> 
		  <?php if($row->upload_resume!=''){ ?><a href="<?php echo $download_file;?>" class="btn btn47 ml16" download><!--target="_blank"  -->Download Resume<!--<h3 class="postJob">Download Resume</h3>--></a><?php } ?>
		</div> 
		
		
	</div>
	</form>
	<div class="clear"></div>	
</li> 
        </ul>
    </div>
    <div class="clearfix"></div>
    </div>
    </div>
</div>

<!--div class="col-md-2 rightAdd">
         <div class="add-box">
		<?php 
            foreach($RightImagesResult as $images)
            {  
        ?>  
            <img src="<?php echo ROOTPATH.'/uploads/advertise/service/full-screen/'.$images->name;?>" width="100%"> 
        <?php } ?>  
	</div>
     </div-->

<div class="clear"></div>
</div>
<br>

</div>

<?php include_once("../view/header-footer/footer.php");  