You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
11 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Job Posting</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
width: 55rem;
margin: auto;
padding: 20px;
border-radius: 10px;
overflow: hidden;
}
.three-col {
display: flex;
justify-content: space-between;
gap: 0;
}
.three-col .col1,
.three-col .col2,
.three-col .col3,
.three-col .col4 {
flex: 0 0 22%;
}
.three-col .form-group {
margin-bottom: 15px;
}
.three-col input,
.three-col select {
width: calc(100% - 30px);
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
label.required::after {
content: "*";
color: red;
margin-left: 5px;
}
h1 {
margin-left: 180px;
margin-top: 20px;
margin-bottom: 20px;
}
.footer {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
#JobDescription {
width:380%;
padding: 10px;
border-radius: 15px;
border: 1px solid #ccc;
margin-bottom: 15px;
height: 70px;
margin-top: 20px;
}
#SpecialInstructions {
width:380%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
margin-bottom: 15px;
height: 40px;
}
#popup {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 999;
}
#popup-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
padding: 20px;
border-radius: 10px;
}
.col4 .form-group {
margin-top: 165px;
margin-left: -40px;
}
</style>
</head>
<body>
<div class="container">
<h1>New Job Posting</h1>
<form id="jobPostingForm" action="{% url 'save_job_posting' %}" method="post">
{% csrf_token %}
<div class="form-group">
<label for="JD" class="required">Upload JD:</label>
<input type="file" id="JD" name="JD" required accept=".pdf,.doc,.docx">
</div>
<br>
<div class="three-col">
<div class="col1">
<div class="form-group">
<label for="Client" class="required">Client:</label>
<select id="Client" name="Client" required style="width: 90%;" tabindex="1">
<option value="">Select Client</option>
{% for client in clients %}
<option value="{{ client.parent_company }}">{{ client.parent_company }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="SPOC">SPOC:</label>
<select id="SPOC" name="SPOC" style="width: 90%;" tabindex="4">
<option value="" >Select SPOC</option>
<option value="spoc1">SPOC 1</option>
<option value="spoc2">SPOC 2</option>
</select>
</div>
<div class="form-group">
<label for="StartDate" class="required">Start Date:</label>
<!-- <input type="date" id="StartDate" name="StartDate" required placeholder="" style="width: 80%;">-->
<input type="date" id="StartDate" name="StartDate" required tabindex="7">
</div>
<div class="form-group">
<label for="BudgetMin" class="required">Budget Min Rs:</label>
<input type="number" id="BudgetMin" name="BudgetMin" required placeholder="" style="width: 80%;" tabindex="11" onchange="validateBudget()">
</div>
<div class="form-group">
<label for="JobDescription" class="required">Job Description:</label>
<textarea id="JobDescription" name="JobDescription" required placeholder="" style="margin-top: -0px;" tabindex="14"></textarea>
</div>
<div class="form-group">
<label for="SpecialInstructions" style="white-space: nowrap;">Special Instructions If any:</label>
<input type="text" id="SpecialInstructions" name="SpecialInstructions" placeholder="" style="width: 380%;" tabindex="15">
</div>
</div>
<div class="col2">
<div class="form-group">
<label for="JobID" class="required" style="margin-left: -10px; " >Job ID:</label>
<input type="text" id="JobID" name="JobID" required placeholder="" style="width: 90%; margin-left: -10px;" tabindex="2">
</div>
<div class="form-group">
<label for="SPOC 2" style="margin-left: 10px;">SPOC 2:</label>
<select id="SPOC 2" name="SPOC2" style="width: 90%;" tabindex="5">
<option value="">Select SPOC 2</option>
<option value="spoc1">SPOC 1</option>
<option value="spoc2">SPOC 2</option>
</select>
</div>
<div class="form-group">
<label for="CloseDate" class="required" >Close Date:</label>
<!-- <input type="date" id="CloseDate" name="CloseDate" required placeholder="" style="width: 85%;">-->
<input type="date" id="CloseDate" name="CloseDate" required tabindex="8">
</div>
<div class="form-group">
<label for="BudgetMax" class="required">Budget Max Rs:</label>
<input type="number" id="BudgetMax" name="BudgetMax" required placeholder="" style="width: 80%;" tabindex="12" onchange="validateBudget()">
</div>
</div>
<div class="col3">
<div class="form-group">
<label for="Location" class="required" style="margin-left: 10px;">Location:</label>
<select id="Location" name="Location" required style="width: 90%; height: 40px;" tabindex="3">
<option value="">Select State</option>
<option value="Telangana">Telangana</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Gujarat">Gujarat</option>
</select>
</div>
<div class="form-group">
<label for="NoOfPosting" class="required" style="margin-left: 1px;">No of Posting:</label>
<input type="number" id="NoOfPosting" name="NoOfPosting" required placeholder="Ex. 5" style="width: 75%; margin-left: 1px;" tabindex="6" oninput="limitNumberOfPostings(this)">
</div>
<div class="form-group">
<label for="Type" class="required">Type:</label>
<select id="Type" name="Type" required style="width: 85%;" tabindex="9">
<option value="">Select</option>
<option value="Full-Time">Full-Time</option>
<option value="Part-Time">Part-Time</option>
<option value="Contract">Contract</option>
</select>
</div>
<div class="form-group">
<label for="Header" class="required">Header:</label>
<input type="text" id="BudgetMin" name="Header" required placeholder="Ex.oracle Technical developer" style="width: 180%;" tabindex="13">
</div>
</div>
<div class="col4">
<div></div>
<div></div>
<div class="form-group">
<label for="Experience" class="required">Experience in Yrs:</label>
<input type="text" id="Experience" name="Experience_in_Yrs" required placeholder="" style="width:16%;" tabindex="10">
</div>
</div>
</div>
<div class="footer">
<button type="button" onclick="saveJobPosting()" style="border-radius: 5px; background-color:lightgreen; width: 70px; margin-top: -20px; padding: 5px;">Save</button>
</div>
</form>
</div>
<div id="popup">
<div id="popup-content">
<p>Are you sure you want to save?</p>
<button onclick="saveForm()">Yes</button>
<button onclick="hidePopup()">No</button>
</div>
</div>
<script>
function showPopup() {
document.getElementById('popup').style.display = 'block';
}
function hidePopup() {
document.getElementById('popup').style.display = 'none';
}
function saveForm() {
if (validateForm()) {
document.getElementById('jobPostingForm').submit();
hidePopup();
}
}
function validateForm() {
var requiredFields = document.querySelectorAll('input[required], select[required], textarea[required]');
var isValid = true;
requiredFields.forEach(function(field) {
if (!field.value.trim()) {
isValid = false;
field.style.border = '2px solid red';
} else {
field.style.border = '1px solid #ccc';
}
});
if (!isValid) {
alert('Please fill in all required fields.');
}
return isValid;
}
function saveJobPosting() {
const form = document.getElementById('jobPostingForm');
const formData = new FormData(form);
// Ensure this retrieves the correct URL
const url = form.getAttribute('action');
console.log('CSRF Token:', '{{ csrf_token }}');
console.log('Form action URL:', url);
fetch(url, {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': '{{ csrf_token }}', // Assuming you have CSRF token available
},
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log('Success:', data);
alert('Job posting saved successfully.');
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while saving the job posting.');
});
}
</script>
</body>
</html>