initial commit

master
VARUN 8 months ago
parent d15859c61d
commit 7345b77a8e

@ -21,5 +21,7 @@ urlpatterns = [
path('save-details-subcompany/', views.save_details_subcompany, name='save-details-subcompany'), path('save-details-subcompany/', views.save_details_subcompany, name='save-details-subcompany'),
path('api/get_subcompanies/', views.get_locations, name='get_subcompanies'), path('api/get_subcompanies/', views.get_locations, name='get_subcompanies'),
path('get_subcompany_details/', views.get_combined_details, name='get_subcompany_details'), path('get_subcompany_details/', views.get_combined_details, name='get_subcompany_details'),
path('add_contact/', views.add_contact, name='add_contact'),
] ]

@ -10,7 +10,7 @@ from django.http import JsonResponse
import json import json
from django.core.serializers.json import DjangoJSONEncoder from django.core.serializers.json import DjangoJSONEncoder
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods
def home(request): def home(request):
return render(request, 'skyonnadmin/home.html') return render(request, 'skyonnadmin/home.html')
@ -332,3 +332,29 @@ def get_contacts(request):
} for contact in contacts] } for contact in contacts]
return JsonResponse({"contacts": contacts_data}) return JsonResponse({"contacts": contacts_data})
@csrf_exempt
@require_http_methods(["POST"])
def add_contact(request):
print("hii")
# Extract information from the request
department = request.POST.get('department')
# Assume 'sub_company_id' is passed to identify which SubcompanyDetails to update
sub_company_id = request.POST.get('sub_company_id')
# Create the Contact instance (simplified, add validation and error handling)
contact = Contact(
first_name=request.POST.get('first_name'),
last_name=request.POST.get('last_name'),
# Add other fields as necessary
)
contact.save()
# Add the contact to the appropriate department of the SubcompanyDetails instance
sub_company = SubcompanyDetails.objects.get(id=sub_company_id)
if department == 'HR':
sub_company.hr_contacts.add(contact)
elif department == 'Accounts':
sub_company.accounts_contacts.add(contact)
# Add conditions for other departments as needed
return JsonResponse({"success": True, "message": "Contact added successfully."})

@ -210,12 +210,12 @@ a {
<ul class="sidebar--items"> <ul class="sidebar--items">
<li><a href="#" onclick="showClientDetails()">Existing Client</a></li> <li><a href="#" onclick="showClientDetails()">Existing Client</a></li>
<li> <li>
<a href="#" class="sidebar-link" onclick="activateLink(this)"> <a href="#" class="sidebar-link" onclick="loadPage('/new_job_postings/'); hideClientDetails()">
<span class="sidebar--item">Team Details</span> <span class="sidebar--item">Team Details</span>
</a> </a>
</li> </li>
<li> <li>
<a href="#" class="sidebar-link" onclick="loadPage('/new_job_postings/')"> <a href="#" class="sidebar-link" onclick="loadPage('/new_job_postings/'); hideClientDetails()">
<span class="sidebar--item">New Job Postings</span> <span class="sidebar--item">New Job Postings</span>
</a> </a>
</li> </li>
@ -553,6 +553,13 @@ function saveJobPosting() {
alert('An error occurred while saving the job posting.'); alert('An error occurred while saving the job posting.');
}); });
} }
function hideClientDetails() {
// Example implementation
var clientDetailsContainer = document.getElementById('clientDetailsContainer');
if (clientDetailsContainer) {
clientDetailsContainer.style.display = 'none';
}
}
</script> </script>
</section> </section>

@ -173,81 +173,7 @@
</a> </a>
</div> </div>
<script> <script>
<!--document.addEventListener('DOMContentLoaded', function () {-->
<!-- const getDetailsButton = document.getElementById('getDetailsButton');-->
<!-- if (getDetailsButton) {-->
<!-- console.log('Button found, adding event listener.'); // This should print if the button is successfully found-->
<!-- getDetailsButton.addEventListener('click', function() {-->
<!-- console.log('Get Details clicked'); // This should print when the button is clicked-->
<!-- const clientId = document.getElementById('ClientDropdown').value;-->
<!-- const department = 'hiring_managers'; // Example, adjust as necessary-->
<!-- fetchContacts(clientId, department);-->
<!-- });-->
<!-- } else {-->
<!-- console.log('Get Details button not found.'); // This helps identify if there's a problem in finding the button-->
<!-- }-->
<!--});-->
<!-- // Initialize with hiring managers data-->
<!-- fetchContacts(clientDropdown.value, currentDepartment);-->
<!-- // Event listener for "Get Details" button-->
<!-- getDetailsButton.addEventListener('click', () => {-->
<!-- fetchContacts(clientDropdown.value, currentDepartment);-->
<!-- });-->
<!-- // Event listeners for department links-->
<!-- departmentLinks.forEach(link => {-->
<!-- link.addEventListener('click', (e) => {-->
<!-- e.preventDefault();-->
<!-- currentDepartment = e.target.getAttribute('data-department');-->
<!-- fetchContacts(clientDropdown.value, currentDepartment);-->
<!-- // Update active class-->
<!-- departmentLinks.forEach(lnk => lnk.classList.remove('active'));-->
<!-- e.target.classList.add('active');-->
<!-- });-->
<!-- });-->
<!-- const updateContactsDisplay = (contacts) => {-->
<!-- const tableBody = document.querySelector('#originalEmployeeTable tbody');-->
<!-- tableBody.innerHTML = ''; // Clear existing rows-->
<!-- contacts.forEach(contact => {-->
<!-- const row = tableBody.insertRow();-->
<!-- Object.values(contact).forEach(text => {-->
<!-- const cell = row.insertCell();-->
<!-- cell.textContent = text;-->
<!-- });-->
<!-- // Add action buttons if needed-->
<!-- });-->
<!-- // Show a message if no contacts found-->
<!-- if (contacts.length === 0) {-->
<!-- const row = tableBody.insertRow();-->
<!-- const cell = row.insertCell();-->
<!-- cell.textContent = "No data available";-->
<!-- cell.colSpan = 7;-->
<!-- }-->
<!-- };-->
<!--});-->
document.addEventListener('DOMContentLoaded', () => {
// Console log to confirm the script is running
console.log('Script is running');
// Function to be called when the button is clicked
function buttonClicked() {
console.log('Get Details button was clicked');
// You can place your fetchContacts logic here
}
// Attach the event listener to the button
const getDetailsButton = document.getElementById('getDetailsButton');
if (getDetailsButton) {
getDetailsButton.addEventListener('click', buttonClicked);
} else {
console.log('Get Details button not found');
}
});
</script> </script>
</body> </body>

Loading…
Cancel
Save