File manager - Edit - /home/autoph/public_html/connectv1/lms/resources/views/common/scripts/lead_profile.js
Back
//START LEADS PROFILE FILE//////////////////////////////////////////////////////////////////////////////////// function init_leadprofile_page() { init_header(); if (side_menu_loaded) { init_leadprofile(); } else { $.when(init_side_content()).done(function(ajax1Results) { init_leadprofile(); }); } } var init_leadprofile = function() { return $.ajax({ url: "resources/views/lead_profile.php", data: {}, type: "POST", beforeSend: function() { show_hide_preloader(true); }, success: function(data) { document.title = 'Lead Information'; $('#center_content').html(data); add_content_close_listener('center_content'); defaultFunctions(); // $('#lead_activities_div').html(''); lead_activities_display_limit = lead_activities_display_limit_const; $('#lead_profile_back').on('click', function() { init_leadfile_page(); }); $.when(lead_profile(), lead_activities()).done(function(ajax1Results, ajax2Results) { //reset lead_activities_display_limit lead_activities_display_limit = lead_activities_display_limit + lead_activities_display_limit_const; //init objects $('#lead_activities_div').html(''); $('#lead_activity_view_more').on('click', function() { $.when(lead_activities()).done(function(ajax1Results2) { var result_lead_activities2 = ajax1Results2['data']; lead_activities_display_limit = lead_activities_display_limit + lead_activities_display_limit_const; lead_activities_display(result_lead_activities2); }); }); //ajax when area var result_lead_activities = ajax2Results[0]['data']; var result_lead_profile = ajax1Results[0]; //put profiule data to UI $.each(result_lead_profile, function(i, n) { if (i.startsWith('profile_href_')) { $("#" + i).attr("href", n); } else { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') } }); // alert(result_lead_profile['inactive_lead']) //set if active or inactive if(parseInt(result_lead_profile['inactive_lead']) === 1){ $("#profile_inactive_label").show(); } //set progress bar for (var i = 1; i <= parseInt(result_lead_profile[ 'profile_progress_type_level']); i++) { $("#lead_progress_" + i).toggleClass('text-secondary').toggleClass( 'text-primary'); } //display latest activities $.each(result_lead_activities, function(i, n) { var data = result_lead_activities[i]; $('#latest_activity_type').text(data['type'] + ':'); $('#latest_activity_owner').text(data['owner']); $('#latest_activity_description').html(data['description']); return false; }); //set html classes & attributes progress_type_class_obj = (JSON.parse(result_lead_profile.html_class)); var progress_type_class_final = progress_type_class_obj.text.join(' '); $('#profile_progress_type').addClass(progress_type_class_final); //display all lead activities lead_activities_display(result_lead_activities); // action buttons //LEAD ADD PROGRESS $('#lead_profile_add_progress').on('click', function() { display_progress_modal('lead_profile','') }); // LEAD ADD NOTE $('#lead_profile_add_notes').on('click', function() { display_note_modal('lead_profile','') }); // LEAD ADD CALL $('#lead_profile_add_call').on('click', function() { display_call_modal('lead_profile','') }); // TAG INACTIVE LEAD $('#lead_profile_action_inactive').on('click', function() { display_inactive_modal('lead_profile','') }); $('#lead_profile_view').on('click', function() { display_lead_modal('lead_profile','update'); }); $('#lead_profile_send_sms').on('click', function() { display_sms_lead_modal('lead_profile','') }); $('#lead_profile_send_email').on('click', function() { display_mail_lead_modal('lead_profile','') }); show_hide_preloader(false); }); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function lead_profile() { return $.ajax({ url: "app/models/lead.php", data: { model: 'lead_profile_v2', lead_id: selected_lead }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) {}, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function lead_activities() { console.log("offset: " + (lead_activities_display_limit - lead_activities_display_limit_const)) console.log("limit: " + (lead_activities_display_limit_const)) return $.ajax({ url: "app/models/lead.php", data: { model: 'lead_activities', inquire_id: selected_lead_inquiry, offset: lead_activities_display_limit - lead_activities_display_limit_const, limit: lead_activities_display_limit_const }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function lead_activities_display(ajaxResult) { $.each(ajaxResult, function(i, n) { var data = ajaxResult[i]; // console.log(data); var activity_action = ''; if(data['activity_type'] == 'progress' && data['description'] == 'NEW LEAD'){ activity_action = ''; }else{ activity_action = `<span onclick="view_lead_activity('`+data['id']+`','`+data['activity_type']+`')" class="cursor-pointer" activity-update ><i class="fas fa-md fa-eye mr-1"></i><u>View </u></span> <span onclick="remove_lead_activity('`+data['id']+`','`+data['activity_type']+`')" class="cursor-pointer" activity-remove ><i class="fas fa-md fa-eye mr-1"></i><u>Remove </u></span>`; } $('#lead_activities_div').append(`<div class="card-header bg-white pl-2 pr-2 pt-2 pb-1 rounded-0 border mb-2"> <div class="col-12 col-sm-12 col-md-12 d-flex align-items-stretch flex-column"> <div class="card card-default shadow-none h-100 m-0 p-0"> <!-- /.card-header --> <div class="card-body p-0 bg-white mb-0"> <div class="row"> <div class="col-sm-1 p-0"> <div class=" text-center bg-primary"> <span class="text-xl">` + data['type_letter'] + `</span> </div> </div> <div class="col-11"> <span class="text-sm mr-1"><b>` + data['type'] + `:</b></span> <span class="text-sm text-muted font-italic">` + data['owner'] + `</span> <div class="p-1 bg-light col-auto"> <!-- <div class="text-nowrap text-truncate" style="width:;"> --> <div class=""> <span class="text-wrap" >` + data['description'] + `</span> </div> </div> </div> </div> </div> <!-- /.card-body --> <div class="card-footer p-0 mt-1 bg-white"> <div class="float-right" >` +activity_action+ `</div> </div> </div> </div> </div>`); }); } function view_lead_activity(id,type){ switch(type){ case 'inactive': display_inactive_modal('lead_profile',id); break; case 'email': display_mail_lead_modal('lead_profile',id); break; case 'sms': display_sms_lead_modal('lead_profile',id); break; case 'call': display_call_modal('lead_profile',id); break; case 'note': display_note_modal('lead_profile',id) break; case 'progress': display_progress_modal('lead_profile',id) break; } } function remove_lead_activity(id,type){ Swal.fire({ icon: 'warning', html: 'Are you sure you want to remove this activity?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Yes`, cancelButtonText: `No`, denyButtonText: `Don't Confirm`, showClass: { backdrop: 'swal2-noanimation', // disable backdrop animation popup: '', // disable popup animation icon: '' // disable icon animation }, hideClass: { popup: '', // disable popup fade-out animation }, customClass: 'swal-height' }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "app/models/lead.php", method: "POST", dataType: 'json', data: { model: 'remove_activity', type : type, activity_id: id, inquire_id: selected_lead_inquiry }, beforeSend: function() { toastr.remove(); toastr.info('Removing...') }, success: function(result) { if (parseInt(result.status) === 1) { toastr.remove(); toastr.success(result.message); init_function('lead_profile'); } else { toastr.remove(); toastr.error(result.message); } } }); } else if (result.isDenied) {} else {} }) // switch(type){ // case 'inactive': // display_inactive_modal('lead_profile',id); // break; // case 'email': // display_mail_lead_modal('lead_profile',id); // break; // case 'sms': // display_sms_lead_modal('lead_profile',id); // break; // case 'call': // display_call_modal('lead_profile',id); // break; // case 'note': // display_note_modal('lead_profile',id) // break; // case 'progress': // display_progress_modal('lead_profile',id) // break; // } } function init_note_modal() { return $.ajax({ url: "resources/views/modals/note_modal.php", data: {}, type: "POST", beforeSend: function() {}, success: function(data) { $('#center_content').append(data); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function init_call_modal() { return $.ajax({ url: "resources/views/modals/call_modal.php", data: {}, type: "POST", beforeSend: function() {}, success: function(data) { $('#center_content').append(data); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function init_inactive_modal() { return $.ajax({ url: "resources/views/modals/inactive_modal.php", data: {}, type: "POST", beforeSend: function() {}, success: function(data) { $('#center_content').append(data); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function init_progress_modal() { return $.ajax({ url: "resources/views/modals/progress_modal.php", data: {}, type: "POST", beforeSend: function() {}, success: function(data) { $('#center_content').append(data); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function display_progress_modal(type,activity_id) { $.when(init_progress_modal(),progress_list_json(),get_progress_data(activity_id)).done(function(init_progress_modal_result,progress_list_json_result,progress_data_result) { $('#progress_modal').modal('show'); $('#progress_modal').on('hidden.bs.modal', function() { $('#progress_modal').remove(); }); $('#progress_type_div').html(''); $('#btn_lead_progress_save').on('click', function() { var selected_progress_type = $( 'input[name=lead_update_progress]:checked' ).val(); var lead_progress_description = $( '#txt_lead_progress_description') .val(); if (isEmpty(selected_progress_type) || parseInt(selected_progress_type) === 1 /*prevent selecting default status*/ ) { toastr.remove(); toastr.error( 'Please select a progress type'); return false; } $.when(add_lead_progress(selected_progress_type,lead_progress_description,activity_id)).done(function(ajax1Results4) { init_function(type); }); }); // $.when(progress_list_json()).done(function( // ajax1Results3) { var results = JSON.parse(progress_list_json_result[0]); $.each(results, function(i, n) { var title_class = isEmpty(n[0][ 'type_class' ]) ? '{"badge":["badge-primary"],"text":["text-primary"]}' : n[0][ 'type_class' ]; title_class_obj = (JSON.parse( title_class)); var title_class_final = title_class_obj.badge.join( ' '); $('#progress_type_div').append(` <div class="col-sm"> <div class="col-12"> <span class="radius-none text-lg rounded-0 badge px-3 py-2 ` + title_class_final + `"> ` + i + `</span> </div> <div class="pt-2" id="progress_type_` + i + `"> </div> </div> `); $.each(results[i], function(j, m) { // alert(results[i][j]['id']+' ' +results[i][j]['name']); $('#progress_type_' + i).append(` <div class="col-12 pb-2 pr-0"> <input id="progress_type_` + results[i][j]['id'] + `" value="` + results[ i][j][ 'id' ] + `" class="align-middle mr-2" type="radio" name="lead_update_progress"> <label class="font-weight-normal text-nowrap mb-0 align-middle" for="progress_type_` + results[i][ j ][ 'id' ] + `"> ` + results[i][j]['name'] + `</label> </div> `); }); }); //disable newly added lead status or default status $('#progress_type_1').prop( 'disabled', true); // }); if(!isEmpty(activity_id)){ var progress_data = progress_data_result[0][0]; $.each(progress_data, function(i, n) { // alert(i+ ' ' +n) if(i == 'progress_type'){ // alert('#progress_type_'+n) $('#progress_type_'+n).prop('checked', true); }else{ $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') } }); } }); } function get_progress_data(activity_id){ if(isEmpty(activity_id)){ return false; } return $.ajax({ url: "app/models/lead.php", data: { model: 'get_progress_data', activity_id: activity_id }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function add_lead_progress(selected_progress_type, lead_progress_description,activity_id) { var activity_type = isEmpty(activity_id) ? 'add_lead_progress' : 'update_lead_progress' ; return $.ajax({ url: "app/models/lead.php", data: { model: activity_type, progress_type: selected_progress_type, description: lead_progress_description, inquire_id: selected_lead_inquiry, activity_id:activity_id }, type: "POST", dataType: 'json', beforeSend: function() { $('#btn_lead_progress_save').prop( 'disabled', true); toastr.remove(); toastr.info("Saving..."); }, success: function(result) { if (parseInt(result.status) === 1) { toastr.remove(); toastr.success(result .message); $('#progress_modal').modal( 'hide'); $('#progress_modal') .remove(); } else { $('#btn_lead_progress_save').prop( 'disabled', false); toastr.remove(); toastr.error(result .message); } }, error: function() { $('#btn_lead_progress_save').prop( 'disabled', false); toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function display_note_modal(type,activity_id){ $.when(init_note_modal(),get_note_data(activity_id)).done(function(ajax1Results4,note_data_result) { $('#note_modal').modal('show'); $('#note_modal').on('hidden.bs.modal', function() { $('#note_modal').remove(); }); $('#txt_reminder_time_div').datetimepicker({ format: 'LT' }) $('#txt_reminder_date_div').datetimepicker({ format: 'MM/DD/YYYY', minDate:moment() }); $("[lead-note-copy]").each(function() { $(this).on('change', function() { if (this.checked) { $(this).val("1"); } else { $(this).val("0"); } }); }); $('#btn_lead_note_save').on('click', function() { if (check_if_empty_field($( '#txt_lead_note_description'), 'Note is required.')) { return false; } if (!isEmpty($('#txt_reminder_date').val() .trim()) && isEmpty($( '#txt_reminder_time').val() .trim())) { $('#txt_reminder_time').focus(); toastr.remove(); toastr.error('Please enter time.') return false; } if (isEmpty($('#txt_reminder_date').val() .trim()) && !isEmpty($( '#txt_reminder_time').val() .trim())) { $('#txt_reminder_date').focus(); toastr.remove(); toastr.error('Please enter date.') return false; } var $element = $("[json-lead-note-modal]"); var json_data = generate_json( 'json-lead-note-modal', $element); // alert(json_data); $.when(add_lead_note(json_data,activity_id)).done(function(ajax1Results5) { init_function(type); }); }); // if(!isEmpty(activity_id)){ $("[lead-note-copy]").each(function() { $(this).prop('disabled',true); }); var note_data = note_data_result[0][0]; $.each(note_data, function(i, n) { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') }); var selected_copy = JSON.parse(note_data.note_copy_json); $.each(selected_copy, function(i, n) { $.each(n, function(j, m) { if(parseInt(m) === 1){ $('#'+j).prop('checked', true); $('#'+j).val('1'); } }); }); } }); } function get_note_data(activity_id){ if(isEmpty(activity_id)){ return false; } return $.ajax({ url: "app/models/lead.php", data: { model: 'get_note_data', activity_id: activity_id }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function add_lead_note(json_data,activity_id){ var activity_type = isEmpty(activity_id) ? 'add_lead_note' : 'update_lead_note' ; return $.ajax({ url: "app/models/lead.php", data: { model: activity_type, json_data: json_data, inquire_id: selected_lead_inquiry, activity_id : activity_id }, type: "POST", dataType: 'json', beforeSend: function() { $('#btn_lead_note_save') .prop( 'disabled', true ); toastr.remove(); toastr.info( "Adding..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // init_leadprofile_page(); $('#note_modal') .modal( 'hide'); $('#note_modal') .remove(); } else { $('#btn_lead_note_save') .prop( 'disabled', false); toastr.remove(); toastr.error(result .message); } }, error: function() { $('#btn_lead_note_save') .prop( 'disabled', false); toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function display_call_modal(type,activity_id){ $.when(init_call_modal(),lead_profile(),get_call_data(activity_id)).done(function(ajax1Results1,ajax1Results2,call_data_result) { $('#call_modal').modal('show'); $('#call_modal').on('hidden.bs.modal', function() { $('#call_modal').remove(); }); // alert(ajaxResults3) var result_lead_profile = ajax1Results2[0]; //store lead contactss const lead_contacts = { mobile: result_lead_profile['profile_mobile'], viber: result_lead_profile['profile_viber'], landline: result_lead_profile['profile_landline'], email: result_lead_profile['profile_email'], }; $('#txt_follow_up_time_div').datetimepicker({ format: 'LT' }) $('#txt_follow_up_date_div').datetimepicker({ format: 'MM/DD/YYYY', minDate:moment() }); $.each(lead_contacts, function(i, n) { if (!isEmpty(n) && i != 'email') { var call_via_type = upper_first_letter(i); $('#lead_call_via_div').append(` <div class="form-check"> <input id="call_via_` + i + `" value="0" json-lead-call-modal="true" lead-call-via class="form-check-input" type="checkbox"> <label style="width:55px;" for="call_via_` + i + `" class="form-check-label">` + call_via_type + `</label> <label for="call_via_` + i + `" class="form-check-label">(` + n + `)</label> </div> `); } }); $("[lead-call-via]").each(function() { $(this).on('change', function() { if (this.checked) { $(this).val("1"); } else { $(this).val("0"); } }); }); $('#btn_lead_call_save').on('click', function() { if (check_if_empty_field($( '#txt_lead_call_description'), 'Description is required.')) { return false; } if (!isEmpty($('#txt_follow_up_date').val() .trim()) && isEmpty($( '#txt_follow_up_time').val() .trim())) { $('#txt_follow_up_time').focus(); toastr.remove(); toastr.error('Please enter time.') return false; } if (isEmpty($('#txt_follow_up_date').val() .trim()) && !isEmpty($( '#txt_follow_up_time').val() .trim())) { $('#txt_follow_up_date').focus(); toastr.remove(); toastr.error('Please enter date.') return false; } var $element = $("[json-lead-call-modal]"); var json_data = generate_json( 'json-lead-call-modal', $element); // alert(json_data); $.when(add_lead_call(json_data,activity_id)).done(function(ajax1Results6) { init_function(type); }); }); if(!isEmpty(activity_id)){ var call_data = call_data_result[0][0]; $.each(call_data, function(i, n) { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') }); var selected_via_call = JSON.parse(call_data.call_via_json); $.each(selected_via_call, function(i, n) { $.each(n, function(j, m) { if(parseInt(m) === 1){ $('#'+j).prop('checked', true); $('#'+j).val('1'); } }); }); } }); } function get_call_data(activity_id){ if(isEmpty(activity_id)){ return false; } return $.ajax({ url: "app/models/lead.php", data: { model: 'get_call_data', activity_id: activity_id }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function add_lead_call(json_data,activity_id){ var activity_type = isEmpty(activity_id) ? 'add_lead_call' : 'update_lead_call' ; return $.ajax({ url: "app/models/lead.php", data: { model: activity_type, json_data: json_data, inquire_id: selected_lead_inquiry, activity_id:activity_id }, type: "POST", dataType: 'json', beforeSend: function() { $('#btn_lead_call_save') .prop( 'disabled', true ); toastr.remove(); toastr.info( "Saving..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // init_leadprofile_page(); $('#call_modal') .modal( 'hide'); $('#call_modal') .remove(); } else { $('#btn_lead_call_save') .prop( 'disabled', false); toastr.remove(); toastr.error(result .message); } }, error: function() { $('#btn_lead_call_save') .prop( 'disabled', false); toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function formatState (state) { // console.log(state);return false; if (!state.id) { return state.text; } var $state = $( '<span> ' + state.text + '</span>'+ ' ' + '<span class="font-weight-normal font-italic text-secondary text-xs m-0"> ' + state.type + '</span>' ); return $state; } function display_mail_lead_modal(type,activity_id){ $.when(init_mail_lead_modal(),get_mail_data(activity_id)).done(function(ajax1Results1,ajax2Results) { $('#mail_lead_modal').on('shown.bs.modal', function() { }) $('#mail_lead_modal').on('hidden.bs.modal', function() { $('#mail_lead_modal').remove(); }); $('#mail_lead_modal').modal('show'); init_mail_template_list(); $('#txt_lead_mail_lead_description').summernote({ placeholder: 'Compose a message', tabsize: 2, height: 200, dialogsInBody: true, tooltip: false, toolbar: [ // [groupName, [list of button]] ['style', ['bold', 'italic', 'underline', 'clear']], ['font', ['strikethrough', 'superscript', 'subscript']], ['fontsize', ['fontsize']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['height', ['height']], ['insert', ['picture', 'video','link']], ['view', ['fullscreen']] ] }); $('#btn_lead_mail_lead_save').on('click', function() { //alert conformation if (check_if_empty_field($( '#txt_lead_mail_lead_subject' ), 'Subject is required.')) { return false; } if ( $('#txt_lead_mail_lead_description').summernote('code') == '<p><br></p>' || $('#txt_lead_mail_lead_description').summernote('code') == '') { $('#txt_lead_mail_lead_description').summernote('focus'); toastr.remove(); toastr.error('Message is required.') return false; } if ($('#txt_lead_mail_lead_description').val().trim().length <= 5) { $('#txt_lead_mail_lead_description').trigger('focus') toastr.remove(); toastr.error('Your message is too short.') return false; } var $element = $( "[json-mail-lead-modal]"); var json_data = generate_json( 'json-mail-lead-modal', $element); $.when(add_lead_mail(json_data,activity_id)).done(function(ajax1Results5) { init_function(type); }); }); $("[lead-mail-parameter]").each(function() { $(this).on('click', function() { set_mail_message($(this).text()); }); }); $('#remove_mail_lead_save_template').on('click', function() { Swal.fire({ icon: 'warning', html: 'Are you sure you want to remove this template?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Yes`, cancelButtonText: `No`, denyButtonText: `Don't Confirm`, showClass: { backdrop: 'swal2-noanimation', // disable backdrop animation popup: '', // disable popup animation icon: '' // disable icon animation }, hideClass: { popup: '', // disable popup fade-out animation }, customClass: 'swal-height' }).then((result) => { if (result.isConfirmed) { var mail_template_id = $('#dd_mail_lead_template').val(); $.ajax({ url: "app/models/lead.php", data: { model: 'remove_mail_template', mail_template_id : mail_template_id }, type: "POST", dataType: 'json', beforeSend: function() { toastr.remove(); toastr.info( "Removing..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // $('#dd_mail_lead_template').select2('destroy'); // $('#dd_mail_lead_template').off('change'); // init_mail_template_list(); $('#dd_mail_lead_template').val('').trigger('change'); } else { toastr.remove(); toastr.error(result .message); } }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } else if (result.isDenied) {} else {} }) }); $("[lead-mail-chk]").each(function() { $(this).on('change', function() { if (this.checked) { $(this).val("1"); } else { $(this).val("0"); } }); }); $('#mail_lead_save_template').on('change', function() { if (this.checked) { Swal.fire({ text: "Template name", input: 'text', showCancelButton: true, preConfirm: (value) => { if (!value) { Swal.showValidationMessage( 'Template name is required' ) }else{ $(this).val(value); } } }).then(function(result){ if(result.value){ }else if(result.isDismissed){ $('#mail_lead_save_template').prop('checked', false); } }); } else { $(this).val(""); } }); $('#clear_mail_lead_description').on('click', function() { $('#txt_lead_mail_lead_description').summernote('reset'); $('#txt_lead_mail_lead_description').summernote('focus'); $('#dd_mail_lead_template').val('').trigger('change'); }); //get activity description if any // return false; if(!isEmpty(activity_id)){ var mail_data = ajax2Results[0][0] //hide elements $('#txt_lead_mail_lead_description').summernote('destroy'); $('#txt_lead_mail_lead_subject').attr('readonly', true); $('#txt_lead_mail_lead_subject').css('background-color', 'white'); $('#mail-template-section').hide(); $('#mail-parameter-section').hide(); $('#mail-save-template-section').hide(); $('#mail-bcc-section').hide(); $('#mail-clear-section').hide(); $('#btn_lead_mail_lead_save').off('click'); $('#btn_lead_mail_lead_save').hide(); $('#btn_lead_mail_lead_cancel').html('Close'); $('#txt_lead_mail_lead_description').summernote({ placeholder: 'Compose a message', tabsize: 2, height: 350, dialogsInBody: true, tooltip: false, toolbar: [] }); $('#txt_lead_mail_lead_description').summernote('disable'); $('.note-editor.note-airframe .note-editing-area .note-editable[contenteditable=false], .note-editor.note-frame .note-editing-area .note-editable[contenteditable=false]').css('background-color', 'white'); $.each(mail_data, function(i, n) { if(i == 'txt_lead_mail_lead_description'){ $('#txt_lead_mail_lead_description').summernote('code', n); }else{ $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') } }); } }); } function get_mail_data(activity_id){ if(isEmpty(activity_id)){ return false; } return $.ajax({ url: "app/models/lead.php", data: { model: 'get_mail_data', activity_id: activity_id }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function set_mail_message(text){ $('#txt_lead_mail_lead_description').summernote('saveRange'); // // Editor loses selected range (e.g after blur) $('#txt_lead_mail_lead_description').summernote('restoreRange'); $('#txt_lead_mail_lead_description').summernote('focus'); $('#txt_lead_mail_lead_description').summernote('insertText', text); } function init_mail_template_list(){ $('#dd_mail_lead_template').select2({ placeholder: "Select Template", allowClear: true, minimumResultsForSearch: -1, templateResult: formatState, // allowClear: true, ajax: { url: 'app/models/lead.php?model=my_mail_template_list', dataType: 'json' } }); $('#dd_mail_lead_template').on('change', function(e) { var mail_template_id = $('#dd_mail_lead_template').val(); if(isEmpty(mail_template_id)){ $('#remove_mail_lead_save_template').hide(); return false; }else{ $('#remove_mail_lead_save_template').show(); } $.ajax({ url: "app/models/lead.php", data: { model: 'get_mail_template', mail_template_id : mail_template_id }, type: "POST", dataType: 'json', beforeSend: function() { toastr.remove(); toastr.info( "Fetching..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // set text to field $('#txt_lead_mail_lead_subject').val(result.subject); // set_mail_message(result.content) $('#txt_lead_mail_lead_description').summernote('code', result.content); } else { toastr.remove(); toastr.error(result .message); } }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); }); } function init_mail_lead_modal() { return $.ajax({ url: "resources/views/modals/mail_lead_modal.php", data: {}, type: "POST", beforeSend: function() {}, success: function(data) { $('#center_content').append(data); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function add_lead_mail(json_data){ return $.ajax({ url: "app/models/lead.php", data: { model: 'add_lead_mail', json_data: json_data, inquire_id: selected_lead_inquiry }, type: "POST", dataType: 'json', beforeSend: function() { $('#btn_lead_mail_lead_save') .prop( 'disabled', true ); toastr.remove(); toastr.info( "Processing..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // init_leadprofile_page(); $('#mail_lead_modal') .modal( 'hide'); $('#mail_lead_modal') .remove(); } else { $('#btn_lead_mail_lead_save') .prop( 'disabled', false); toastr.remove(); toastr.error(result .message); } }, error: function() { $('#btn_lead_mail_lead_save') .prop( 'disabled', false); toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function display_sms_lead_modal(type,activity_id){ $.when(init_sms_lead_modal(),get_sms_data(activity_id)).done(function(ajax1Results1,sms_data_result) { $('#sms_lead_modal').modal('show'); $('#sms_lead_modal').on('hidden.bs.modal', function() { $('#sms_lead_modal').remove(); }); init_sms_template_list(); $('#btn_lead_sms_lead_save').on('click', function() { //alert conformation if (check_if_empty_field($( '#txt_lead_sms_lead_description' ), 'Message is required.')) { return false; } if ($('#txt_lead_sms_lead_description').val().trim().length <= 5) { $('#txt_lead_sms_lead_description').trigger('focus') toastr.remove(); toastr.error('Your message is too short.') return false; } var $element = $( "[json-sms-lead-modal]"); var json_data = generate_json( 'json-sms-lead-modal', $element); $.when(add_lead_sms(json_data)).done(function(ajax1Results5) { init_function(type); }); }); $("[lead-sms-parameter]").each(function() { $(this).on('click', function() { // $('#txt_lead_sms_lead_description').val($('#txt_lead_sms_lead_description').val()+$(this).text()); $('#txt_lead_sms_lead_description').insertAtCaret($(this).text()); $('#txt_lead_sms_lead_description').trigger('focus'); }); }); $('#remove_sms_lead_save_template').on('click', function() { Swal.fire({ icon: 'warning', html: 'Are you sure you want to remove this template?', showDenyButton: false, showCancelButton: true, confirmButtonText: `Yes`, cancelButtonText: `No`, denyButtonText: `Don't Confirm`, showClass: { backdrop: 'swal2-noanimation', // disable backdrop animation popup: '', // disable popup animation icon: '' // disable icon animation }, hideClass: { popup: '', // disable popup fade-out animation }, customClass: 'swal-height' }).then((result) => { if (result.isConfirmed) { var sms_template_id = $('#dd_sms_lead_template').val(); $.ajax({ url: "app/models/lead.php", data: { model: 'remove_sms_template', sms_template_id : sms_template_id }, type: "POST", dataType: 'json', beforeSend: function() { toastr.remove(); toastr.info( "Removing..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // $('#dd_sms_lead_template').select2('destroy'); // $('#dd_sms_lead_template').off('change'); // init_sms_template_list(); $('#dd_sms_lead_template').val('').trigger('change'); } else { toastr.remove(); toastr.error(result .message); } }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } else if (result.isDenied) {} else {} }) }); $('#sms_lead_save_template').on('change', function() { if (this.checked) { Swal.fire({ text: "Template name", input: 'text', showCancelButton: true, preConfirm: (value) => { if (!value) { Swal.showValidationMessage( 'Template name is required' ) }else{ $(this).val(value); } } }).then(function(result){ if(result.value){ }else if(result.isDismissed){ $('#sms_lead_save_template').prop('checked', false); } }); } else { $(this).val(""); } }); $('#clear_sms_lead_description').on('click', function() { $('#txt_lead_sms_lead_description').val(''); $('#dd_sms_lead_template').val('').trigger('change'); }); if(!isEmpty(activity_id)){ var mail_data = sms_data_result[0][0]; $('#clear_sms_lead_description').hide(); $('#sms-template-section').hide(); $('#sms-save-template-section').hide(); $('#sms-parameter-section').hide(); $('#txt_lead_sms_lead_description').attr('readonly', true); $('#txt_lead_sms_lead_description').css('background-color', 'white'); $('#btn_lead_sms_lead_save').off('click'); $('#btn_lead_sms_lead_save').hide(); $('#btn_lead_sms_lead_cancel').html('Close'); $.each(mail_data, function(i, n) { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') }); } }); } function get_sms_data(activity_id){ if(isEmpty(activity_id)){ return false; } return $.ajax({ url: "app/models/lead.php", data: { model: 'get_sms_data', activity_id: activity_id }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function init_sms_lead_modal() { return $.ajax({ url: "resources/views/modals/sms_lead_modal.php", data: {}, type: "POST", beforeSend: function() {}, success: function(data) { $('#center_content').append(data); }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } function add_lead_sms(json_data){ return $.ajax({ url: "app/models/lead.php", data: { model: 'add_lead_sms', json_data: json_data, inquire_id: selected_lead_inquiry }, type: "POST", dataType: 'json', beforeSend: function() { $('#btn_lead_sms_lead_save') .prop( 'disabled', true ); toastr.remove(); toastr.info( "Processing..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // init_leadprofile_page(); $('#sms_lead_modal') .modal( 'hide'); $('#sms_lead_modal') .remove(); } else { $('#btn_lead_sms_lead_save') .prop( 'disabled', false); toastr.remove(); toastr.error(result .message); } }, error: function() { $('#btn_lead_sms_lead_save') .prop( 'disabled', false); toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function init_sms_template_list(){ $('#dd_sms_lead_template').select2({ placeholder: "Select Template", allowClear: true, minimumResultsForSearch: -1, templateResult: formatState, // allowClear: true, ajax: { url: 'app/models/lead.php?model=my_sms_template_list', dataType: 'json' } }); $('#dd_sms_lead_template').on('change', function(e) { var sms_template_id = $('#dd_sms_lead_template').val(); if(isEmpty(sms_template_id)){ $('#remove_sms_lead_save_template').hide(); return false; }else{ $('#remove_sms_lead_save_template').show(); } $.ajax({ url: "app/models/lead.php", data: { model: 'get_sms_template', sms_template_id : sms_template_id }, type: "POST", dataType: 'json', beforeSend: function() { toastr.remove(); toastr.info( "Fetching..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // set text to field $('#txt_lead_sms_lead_description').val(result.content); } else { toastr.remove(); toastr.error(result .message); } }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); }); } function display_inactive_modal(type,activity_id){ $.when(init_inactive_modal(),get_inactive_data(activity_id)).done(function(ajax1Results1,inactive_data_result) { $('#inactive_modal').modal('show'); $('#inactive_modal').on('hidden.bs.modal', function() { $('#inactive_modal').remove(); }); $('#txt_revisit_date_div').datetimepicker({ format: 'MM/DD/YYYY', minDate:moment() }); $('#btn_lead_inactive_save').on('click', function() { //alert conformation if (check_if_empty_field($( '#txt_lead_inactive_description' ), 'Reason is required.')) { return false; } var $element = $( "[json-lead-inactive-modal]"); var json_data = generate_json( 'json-lead-inactive-modal', $element); $.when(add_lead_inactive(json_data,activity_id)).done(function(ajax1Results5) { if(parseInt(ajax1Results5.status) === 1){ init_function(type); } }); }); //get activity description if any if(!isEmpty(activity_id)){ var inactive_data = inactive_data_result[0][0] $.each(inactive_data, function(i, n) { $("#" + i).text(n); $("#" + i).val(n); $("#" + i).trigger('change') }); } }); } function get_inactive_data(activity_id){ if(isEmpty(activity_id)){ return false; } return $.ajax({ url: "app/models/lead.php", data: { model: 'get_inactive_data', activity_id: activity_id }, type: "POST", dataType: 'json', beforeSend: function() {}, success: function(result) { // console.log(result) }, error: function() { toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function add_lead_inactive(json_data,activity_id){ var activity_type = isEmpty(activity_id) ? 'add_lead_inactive' : 'update_lead_inactive' ; return $.ajax({ url: "app/models/lead.php", data: { model: activity_type, json_data: json_data, inquire_id: selected_lead_inquiry, activity_id : activity_id }, type: "POST", dataType: 'json', beforeSend: function() { $('#btn_lead_inactive_save') .prop( 'disabled', true ); toastr.remove(); toastr.info( "Saving..."); }, success: function(result) { if (parseInt(result .status) === 1) { toastr.remove(); toastr.success( result .message); // init_leadprofile_page(); $('#inactive_modal') .modal( 'hide'); $('#inactive_modal') .remove(); } else { $('#btn_lead_inactive_save') .prop( 'disabled', false); toastr.remove(); toastr.error(result .message); } }, error: function() { $('#btn_lead_inactive_save') .prop( 'disabled', false); toastr.remove(); toastr.error( "Error has occurred. Try again." ) } }); } function progress_list_json() { return $.ajax({ url: "app/models/lead.php", data: { model: 'lead_progress_list' }, type: "POST", beforeSend: function() {}, success: function(data) { }, error: function() { toastr.remove(); toastr.error("Error has occurred. Try again.") } }); } //END LEADS PROFILE FILE////////////////////////////////////////////////////////////////////////////////////
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings