HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/assets/scripts/mobile/contact_leads.js
$(() => {
    var call_uri;
    getContactList();
    $(".add-btn").attr("href", "/mobile/contact_add/" + location.search);
    $( "#leadspickerFrom" ).datepicker(
        {
            format: "mm/dd/yyyy",
            autoclose: true
        }
    );
    $( "#leadspickerTo" ).datepicker(
        {
            format: "mm/dd/yyyy",
            autoclose: true
        }
    );
})

function getContactList() {
    params = new URLSearchParams(location.search);
    search = $('#search').val();
    username = params.get('username');
    password = params.get('password');
    status = $("#status-filter").val();
    agent = $("#agent-filter").val();
    start_date = $("#leadspickerFrom").val();
    end_date = $("#leadspickerTo").val();
    unassigned_agent = $("#unassigned-contacts").hasClass("active");
    $.ajax({
        type: "GET",
        url: "/mobile/contact_leads_list/",
        data: {
            "username": username, "password": password, "search": search, "agent": agent,
            "status": status, "start_date": start_date, "end_date": end_date, "unassigned_agent": unassigned_agent
        },
        success: function (result) {
            $("#contactsList").html(result.html_content);
            call_uri = result.call_uri;
            $(".add-btn").attr("href", "/mobile/contact_add/" + location.search)
        }
    });
}

$('#search').on("keyup", () => {
    getContactList();
})

$('.clr-search').on("click", () => {
    $('#search').val("");
    getContactList();
})

$('#filter-apply').on("click", () => {
    getContactList();
    $('#filter-span').addClass("active");
    $('#filterLeadsModal').modal('hide');
})

$('#reset-filter').on("click", () => {
    $('#filter-span').removeClass("active");
    $('#filterLeadsModal').find("input, select[name='agent']").val('');
    $('#filterLeadsModal').find("select[name='status']").val('no status');
    $('#filterLeadsModal').modal('hide');
    getContactList();
})

$('#viewLeadsModal').on('shown.bs.modal', function (event) {
    phoneNumber = event.relatedTarget.dataset.attr;
    contact_id = event.relatedTarget.dataset.id;
    $("#modal-call").attr("href", call_uri + ":" + phoneNumber + '?dialAction=voiceCall');
    $("#modal-text").attr("href", call_uri + ":" + phoneNumber + '?dialAction=text');
    $("#modal-detail").attr("href", "/mobile/contact_detail/" + contact_id + "/" + location.search)
})

$('#unassigned-contacts').on("click", () => {
    if($("#unassigned-contacts").hasClass('active') == false){
        $("#unassigned-contacts").addClass('active');
        $("#my-contacts").removeClass('active');
        getContactList();
    }    
})

$('#my-contacts').on("click", () => {
    if($("#my-contacts").hasClass('active') == false){
        $("#my-contacts").addClass('active');
        $("#unassigned-contacts").removeClass('active');
        getContactList();
    }    
})