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.

257 lines
10 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.addSubclient{
body {
font-family: Arial, sans-serif;
overflow: hidden;
}
.container {
width: 45rem;
margin: auto;
padding: 20px;
border-radius: 10px;
overflow: hidden;
}
.two-col {
display: flex;
white-space: nowrap;
margin-left: 100px;
}
.three-col .col1,
.three-col .col2 {
flex: 0 0 22%;
}
.two-col .form-group {
margin-bottom: 15px;
}
.two-col input,
.two-col select {
width: calc(100% - 50px);
padding: 10px;
border-radius: 10px;
border: 1px solid black;
}
label.required::after {
content: "*";
color: red;
margin-left: 5px;
}
.form-group {
display: flex;
flex-direction: row-reverse;
align-items: center;
}
.form-group label {
margin-left: 10px;
}
#Address {
margin-left: 40px;
border-radius: 10px;
}
ul {
list-style-type: none;
padding: 0;
margin-bottom: 20px;
margin-left: 300px;
}
li {
float:left;
margin-bottom: 20px;
margin-left: -10px;
}
li a {
display: block;
color: black;
text-align: center;
padding: 1px;
text-decoration: underline;
margin-top: 20px;
margin-left: 60px;
}
a:hover {
color:red;
}
.container1 {
margin-left: 500px;
width: 900px;
}
.add p {
margin-left: 370px;
margin-top: 3px;
}
.add a {
text-decoration: none;
}
.container1 input[type="text"] {
width: calc(100% - 20px);
margin-right: 10px;
}
.add span {
display: inline-block;
width: 25px;
height: 25px;
border: 2px solid black;
border-radius: 50%;
text-align: center;
line-height: 30px;
margin-left: 430px;
color: black;
}
#jobPostingForm1{
margin-left: -130px;
}
#jobPostingForm{
margin-left: -130px;
}
.container1 .col2 {
margin-top: -1px;
}}
</style>
<body>
<div class="addSubclient">
<div class="container">
<form id="addSubClientForm" action="{% url 'save-details-subcompany' %}?admin_id={{ admin_id }}" method="post">
{% csrf_token %}
<div class="two-col">
<div class="col1">
<div class="form-group">
<select id="ParentCompany" name="ParentCompany" required tabindex="1">
<option value="" tabindex="1">Select Client</option>
{% for client in clients %}
<option value="{{ client.parent_company }}">{{ client.parent_company }}</option>
{% endfor %}
</select>
<label for="ParentCompany" class="required" style="width: 200px;">Parent Company:</label>
</div>
<div class="form-group">
<input type="text" id="SubCompany" name="SubCompany" required placeholder="Eg. oracle India" tabindex="3">
<label for="SubCompany" class="required" style="margin-left: 28px;">Sub Company:</label>
</div>
<div class="form-group">
<input type="text" id="Location" name="Location" required placeholder="Eg. bangalore" tabindex="5">
<label for="Location" class="required" style="margin-left: 70px;">Location:</label>
</div>
<div class="form-group">
<input type="text" id="Department" name="Department" required placeholder="Eg. Billing or Accouts or Hiring" tabindex="6">
<label for="Department" class="required" style="margin-left: 47px;">Department:</label>
</div>
</div>
<div class="col2">
<div class="form-group">
<input type="text" id="GSTNo" name="GSTNo" required placeholder="Eg.234567H23LS" tabindex="2">
<label for="GSTNo" class="required" style="margin-left: 10px;">GST No.</label>
</div>
<div class="form-group">
<textarea id="Address" rows="2" cols="30" name="Address" required style="margin-left:5px; height: 70px; padding: 5px;" tabindex="4"></textarea>
<label for="Address" class="required">Address</label>
</div>
</div>
</div>
<h3 id="subLocationHeader" style="text-align: center;">Admin Department Contact person Name for the Above office location*</h3>
<div class="two-col" style="margin-left: 170px;">
<div class="col1">
<div class="form-group">
<input type="text" id="Admin_FirstName" name="Admin_FirstName" required placeholder="First Name*" width="200px" class="required" tabindex="7">
<label for="Admin_FirstName"></label>
</div>
<div class="form-group">
<input type="text" id="Admin_PhoneNo1" name="Admin_PhoneNo1" required placeholder="Phone No1*" class="required" tabindex="9">
<label for="Admin_PhoneNo1"></label>
</div>
<div class="form-group">
<input type="email" id="Admin_CompanyEmail" name="Admin_CompanyEmail" required placeholder="Company Email*" class="required" tabindex="11">
<label for="Admin_CompanyEmail"></label>
</div>
<div class="form-group">
<input type="text" id="Admin_Designation" name="Admin_Designation" required placeholder="Designation*" class="required" tabindex="13">
<label for="Admin_Designation"></label>
</div>
</div>
<div class="col2">
<div class="form-group">
<input type="text" id="Admin_LastName" name="Admin_LastName" required placeholder="Last Name*" class="required" tabindex="8">
<label for="Admin_LastName"></label>
</div>
<div class="form-group">
<input type="text" id="Admin_PhoneNo2" name="Admin_PhoneNo2" required placeholder="Phone No2" tabindex="10">
<label for="Admin_PhoneNo2"></label>
</div>
<div class="form-group">
<input type="text" id="Admin_Location" name="Admin_Location" required placeholder="Location*" class="required" tabindex="12">
<label for="Admin_Location"></label>
</div>
<div class="form-group">
<input type="text" id="Admin_Department" name="Admin_Department" required placeholder="Department*" class="required" tabindex="14">
<label for="Admin_Department"></label>
</div>
</div>
</div>
<button type="button" onclick="saveSubClient()" style="border-radius: 5px; background-color:lightgreen; width: 100px; margin-left:330px; margin-top: -20px; padding: 5px; ma"> Save</button> </form>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var form = document.getElementById('secondForm');
form.addEventListener('submit', function(e) {
e.preventDefault(); // Prevent the default form submission
var formData = new FormData(form);
// AJAX request to the server
fetch("{% url 'save-details-subcompany' %}", {
method: 'POST',
body: formData,
headers: {
'X-CSRFToken': formData.get('csrfmiddlewaretoken') // Include CSRF token
}
})
.then(response => response.json())
.then(data => {
console.log(data.message); // Log the success message
document.getElementById('successMessage').style.display = 'block'; // Show success message
form.reset(); // Reset the form fields
})
.catch(error => console.error('Error:', error));
});
});
function saveSubClient() {
const form = document.getElementById('addSubClientForm');
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('Client saved successfully.');
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while saving the job posting.');
});
}
</script>
</body>
</html>