<?php
include_once("include/main.inc.php");
$page_metatitle = "Career ".COMPANY_NAME;
$page_metakey = "Career ".COMPANY_NAME;
$page_metadesc = "Career ".COMPANY_NAME;
$admin_sql = mysqli_query($dbconn, "select * from admin_details");
$admin_res = mysqli_fetch_array($admin_sql);
$referer = $_SERVER['HTTP_REFERER'];
$ip=$_SERVER['REMOTE_ADDR'];
$mobileNumber = "";
if (isset($_POST['submit-careers']))
{
$name = !empty($_POST['name'])?$_POST['name']:'';
$email = !empty($_POST['email'])?$_POST['email']:'';
$mobile = !empty($_POST['mobile'])?$_POST['mobile']:'';
$location = !empty($_POST['location'])?$_POST['location']:'';
$zipcode = !empty($_POST['zipcode'])?$_POST['zipcode']:'';
$qualifications = !empty($_POST['qualifications'])?$_POST['qualifications']:'';
$experiance = !empty($_POST['experiance'])?$_POST['experiance']:'';
$jobtitle = !empty($_POST['jobtitle'])?$_POST['jobtitle']:'';
$salary = !empty($_POST['salary'])?$_POST['salary']:'';
$message = !empty($_POST['message'])?$_POST['message']:'';
    $docname = $_FILES['docname']['name'];
    $type = $_FILES['docname']['type'];
    $tmp_name = $_FILES['docname']['tmp_name'];
    $type = $_FILES['docname']['size'];
    $allowed_ext = ['pdf','docx','doc','jpeg','jpg','rtf','png'];
    $ext = pathinfo($docname, PATHINFO_EXTENSION);
    $docname_new = str_replace(' ','-',$docname);
    $target_path = SITE_DIR_PATH.'/uploaded-files/resumes/'.$docname_new;
 if(strpos($message,'#')!==false || strpos($message,'%')!==false || strpos($message,'@')!==false || strpos($message,'&')!==false || strpos($message,'~')!==false || strpos($message,'https')!==false || strpos($message,'http')!==false || strpos($message,'www')!==false || strpos($message,'?')!==false){
      $errMsg ='URL(s) and special characters are not allowed!';
  } else {    
if($name != '' && $email != '' && $mobile != '' && $message != '' && $location != '' && $zipcode != '' && $qualifications != '' && $experiance != '' && $jobtitle != '' && $salary != ''){
     if(in_array($ext,$allowed_ext))
     {
//reCAPTCHA validation
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {    
     $secret =  secret_key;
    //get verify response data
    $data = array( 'secret' => $secret, 'response' => $_POST['g-recaptcha-response'] ); $verify = curl_init(); curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify"); curl_setopt($verify, CURLOPT_POST, true); curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($verify); //var_dump($response);
    $response = json_decode($response);        
if (!$response->success) { $errMsgs = 'Please click on the reCAPTCHA box.'; }         
if($response->success) { $sql_ens="insert into tbl_careerEnquiry set en_name='$name', en_email='$email', en_mobile='$mobile', en_comment='$message', en_doc_name='$docname_new', en_url='$referer', en_zip='$zipcode', en_country='$location', en_qualification='$qualifications',en_experience='$experiance',en_jobTitle	='$jobtitle',en_salary='$salary', en_ip='$ip', en_date=now()";
$qry=mysqli_query($dbconn,$sql_ens);
move_uploaded_file($tmp_name, $target_path);
$subject = utf8_encode('Career Enquiry from '.site_url);
$htmlContent = "
Customer Details:
Url: ".$referer."
Name: ".$name."
Email: ".$email."
Mobile: ".$mobile."
Message: ".$message."
Location: ".$location."
Qualification: ".$qualifications."
Experience: ".$experiance."
";            
$to = $admin_res['email'];
$to2 = $admin_res['cc'];
$to3 = $admin_res['bcc']; 
// $to3 = 'vicky.wpsranchi@gmail.com';
$headers = 'From: '.'Webpulseindia.com'.' enquiry@webpulseindia.com' . "\r\n" .
'Reply-To:  '.$name.'<'.$email.'>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($to,$subject,$htmlContent,$headers);
@mail($to2,$subject,$htmlContent,$headers);
@mail($to3,$subject,$htmlContent,$headers);
$succMsgs = 'Thank you for your enquiry. Our team will contact you soon.';
$name = '';
$email = '';
$mobile = '';
$message = ''; }  
} else { $errMsgs ='Robot verification failed, please try again.';}
         } else { $errMsgs ='Please upload valid file(pdf,doc,jpeg)';}
} else { $errMsgs ='All the fields are Mandatory!';}
}
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <?php include "app_top.php"; ?>
</head>

<body>

    <?php include "app_header.php"; ?>

    <section class="heading_banner" style="background-image: url(<?=site_url;?>/designer/images/about-banner.jpg)">
        <div class="container">
            <div class="row">
                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 text-center">
                    <h1 class="cat_title">Apply Now </h1>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </section>

    <div class="inner_breadcrumb hidden_xs">
        <div class="container">
            <div class="row">
                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <ul class="breadcrumb">
                        <li><a href="<?=site_url;?>" title="Home">Home</a></li>
                        <li class="active"> Apply Now </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <section class="career_page">
        <div class="container">
            <h2 class="title_4"><span> Apply Now </span></h2>
            <div class="clearfix"></div>
            <div class="row mt-5">

                <div class="col-xxl-12 col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <p>Please submit the application for according your location area. Our admin staff of location contact you call back to you.</p>
                    <form id="apply_form" method="post" enctype="multipart/form-data">
                    <?php if(!empty($errMsgs)): ?><div class="alert alert-danger"><?php echo $errMsgs; ?></div>
                                <?php endif; ?>
                                <?php if(!empty($succMsgs)): ?><div class="alert alert-success"><?php echo $succMsgs; ?></div>
                                <?php endif; ?>
                        <div class="row">
                          <div class="col-md-6">
                            <div class="form-group">
                              <input tabindex="201" class="form-control" name="name" type="text" placeholder="Your Name*" onkeypress="return ValidateAlpha(event)" required="">
                            </div>
                          </div>
                          <div class="col-md-6">
                            <div class="form-group">
                              <input tabindex="202" class="form-control" name="mobile" type="tel" maxlength="10" onkeypress="return isNumberKey(event)" placeholder="Your Phone No*" required="">
                            </div>
                          </div>
                          <div class="col-md-6">
                            <div class="form-group">
                              <input tabindex="203" class="form-control" name="email" type="email" placeholder="Your Email ID*" required="">
                            </div>
                          </div>
                          <div class="col-md-6">
                            <div class="form-group">
                              <input tabindex="204" class="form-control" name="location" type="text" placeholder="Your Location*" onkeypress="return ValidateAlpha(event)" required="">
                            </div>
                          </div>
                         
                          <div class="col-md-6">
                            <div class="form-group">
                              <input tabindex="206" class="form-control" name="zipcode" type="number" placeholder="Zip code*" maxlength="6" required="">
                            </div>
                          </div>
                          <div class="col-md-6">
                            <div class="form-group">
                              <input tabindex="207" class="form-control" type="file" name="docname" id="docname" required="">
                              <p class="upload">Upload Resume</p>
                            </div>
                          </div>
                          <div class="col-md-6">
                            
                            <div class="form-group">
                              <input tabindex="208" class="form-control" name="qualifications" type="text" placeholder="Your Qualifications*" required="">
                            </div>
                             
                          </div>
                          <div class="col-md-6">
                            
                            <div class="form-group">
                              <select tabindex="209" name="experiance" class="form-control" required="">
                                <option selected="">Experiance Years</option>
                                <option value="2 year">1-2 year</option>
                                <option value="3 year">3-5 year</option>
                                <option value="5 year">5-10 year</option>
                                <option value="10 year">More than 10 year</option>
                              </select>
                            </div>
                          </div>
                          <div class="col-md-6">
                          <div class="form-group">
                              <input tabindex="210" class="form-control" name="jobtitle" type="text" onkeypress="return ValidateAlpha(event)" placeholder="Job Title*" required="">
                            </div>
                          </div>
                          <div class="col-md-6">
                          <div class="form-group">
                              <input tabindex="211" class="form-control" name="salary" type="text" placeholder="Salary Expectation*" required="">
                            </div>
                           
                          </div>
                          <div class="col-md-12">
                            <div class="form-group">
                              <textarea tabindex="212" class="form-control" name="message" placeholder="Your Message*" rows="9"></textarea>
                            </div>
                          </div>
                          <div class="col-md-12">
                            <div class="form-group" style="margin-bottom: 0;">
                              <div tabindex="113" class="g-recaptcha" data-sitekey="<?=site_key;?>">
                               </div>
                            </div>
                          </div>
                          <div class="col-md-12">
                            <div class="form-group">
                                <button class="read_more01" type="submit" name="submit-careers">Submit</button>
                            </div>
                          </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
    
    <?php include "app_faq.php"; ?>
    <?php include "app_testimonials.php"; ?>
    <?php include "app_clients.php"; ?>
    <?php include "app_footer.php"; ?>
    <?php include "app_bottom.php"; ?>
</body>

</html>