<script type="text/javascript">
$(document).ready(function(){
    /*$("#frm-clinicsetting").submit(function(e){
            if(!validate_practice()){
                e.preventDefault();
            }
            $("#status_msg").show();
            $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
            $("#status_msg_td").html(msg);
            return false; 
            //hideMessage();
    });*/

    $('#frm-clinicsetting').on('submit',function (e) {
            e.preventDefault();
              $.ajax({
                type: 'post',
                url: 'clinic_setting.php?act=setting',
                data: $('#frm-clinicsetting').serialize(),
                success: function () {
                    /*$("#status_msg").show();
                    $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                    //$("#status_msg_td").html(msg);
                    hideMessage();*/

                    $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: 'Communication Setting Updated successfully...',
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                }
              });
        });

    var maxField = 30; //Input fields increment limitation
    var addButton = $('.add_button'); //Add button selector
    var wrapper = $('.field_wrapper'); //Input field wrapper
    var fieldHTML = '<div><br/><input type="text" name="field_setting1[]" value="" placeholder="email"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="field_setting2[]" value="" placeholder="info@dmo.com" /><a href="javascript:void(0);" class="remove_button"><img src="<?Php echo SITE_URL."x-admin/assets/images/clinic_setting/remove-icon.png" ?>"/></a></div>'; //New input field html 
    var x = 1; //Initial field counter is 1
    //<input type="text" name="field_setting2[]" value=""/>
    //Once add button is clicked
    $(addButton).click(function(){
        //Check maximum number of input fields
        if(x < maxField){ 
            x++; //Increment field counter
            $(wrapper).append(fieldHTML); //Add field html
        }
    });
    
    //Once remove button is clicked
    $(wrapper).on('click', '.remove_button', function(e){
        e.preventDefault();
        $(this).parent('div').remove(); //Remove field html
        x--; //Decrement field counter
    });


    $('#frm-clinicsettingPractice').on('submit',function (e) {
            e.preventDefault();
            var fname = $("#fname").val();
            var lname = $("#lname").val();
            var code = $("#code").val();
            if(fname == '')
            {
                $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: 'Please provide first name',
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'error'
                        });
                return false;
            }else if(lname == '')
            {
                $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: 'Please provide last name',
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'error'
                        });
                return false;
            }else if(code == '')
            {
                $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: 'Please provide code name',
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'error'
                        });
                return false;
            }else{
                
                if(code !='')
                {
                    $("#code").removeClass('error');
                    $("#msg_code").hide();
                }

              $.ajax({
                type: 'post',
                url: 'clinic_setting.php?act=settingPractice',
                data: $('#frm-clinicsettingPractice').serialize(),
                success: function () {
                    /*$("#status_msg").show();
                    $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Successfull created demo...</div>");
                    hideMessage();*/

                    $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: 'Successfull created demo...',
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                }
              });
            }
        });

    var maxFieldPractice = 5; //Input fields increment limitation
    var addButtonPractice = $('.add_buttonPractice'); //Add button selector
    var wrapperPractice = $('.field_wrapperPractice'); //Input field wrapper
    var fieldHTMLPractice = '<div><br/><input type="text" name="fname[]" id="fname" value="" placeholder="Provider First Name"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="lname[]" value="" placeholder="Provider Last Name"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="code[]" value="" placeholder="PMS Provider Code" /><a href="javascript:void(0);" class="remove_button"><img src="<?Php echo SITE_URL."x-admin/assets/images/clinic_setting/remove-icon.png" ?>"/></a></div>'; //New input field html 
    var xPractice = 1; //Initial field counter is 1
    //<input type="text" name="field_setting2[]" value=""/>
    //Once add button is clicked
    $(addButtonPractice).click(function(){
        //Check maximum number of input fields
        if(xPractice < maxFieldPractice){ 
            xPractice++; //Increment field counter
            $(wrapperPractice).append(fieldHTMLPractice); //Add field html
        }
    });
    
    //Once remove button is clicked
    $(wrapperPractice).on('click', '.remove_button', function(e){
        e.preventDefault();
        $(this).parent('div').remove(); //Remove field html
        xPractice--; //Decrement field counter
    });

});
function validate_practice(){
    var practicename = $("#practice_name");var practicenamemsg = $("#msg_practice_name");
    var practice_xcare_id = $("#xcare_id");var xcare_idmsg = $("#msg_xcare_id");
    var pullguarantors = $("#pullguarantors_name");var pullguarantorsmsg = $("#msg_pullguarantors_name");
    var pullPatients = $("#PullPatients_name");var pullPatientsmsg = $("#msg_PullPatients_name");
    var pullAppointments = $("#PullAppointments_name");var pullAppointmentsmsg = $("#msg_PullAppointments_name");
    
    if(practicename.val()==''){practicename.addClass('error');practicename.focus();practicenamemsg.html('Please enter practice name').show();
            return false;
    }else
    {
        practicename.removeClass('error');
        practicenamemsg.hide();
    }
        
    if(practice_xcare_id.val()=='')
    {
        practice_xcare_id.addClass('error');
        practice_xcare_id.focus();
        xcare_idmsg.html('Please select xcareId').show();
        return false;
    }else
    {
        practice_xcare_id.removeClass('error');
        xcare_idmsg.hide();
    }

    if(pullguarantors.val()=='')
    {
          pullguarantors.addClass('error');
          pullguarantors.focus();
          pullguarantorsmsg.html('Please select guarantor').show();
          return false;
    }else
    {   
        pullguarantors.removeClass('error');
        pullguarantorsmsg.hide();
    }

    if(pullPatients.val()=='')
    {
          pullPatients.addClass('error');
          pullPatients.focus();
          pullPatientsmsg.html('Please select patient').show();
          return false;
    }else
    {   
        pullPatients.removeClass('error');
        pullPatientsmsg.hide();
    }

    

    if(pullAppointments.val()=='')
    {
        pullAppointments.addClass('error');
        pullAppointments.focus();
        pullAppointmentsmsg.html('Please select appoinment').show();
        return false;
    }else
    {   
        pullAppointments.removeClass('error');
        pullAppointmentsmsg.hide();
    }
    return true;
}


function messagecenter_change_status(messageaccess_id,status,msgaccess_data,clinic_id)
{
  var clinicreminder_status               = $("#mesg_reminder_"+messageaccess_id).attr('clinicstatus-data');
  var clinicmarketing_status              = $("#mesg_marketing_"+messageaccess_id).attr('clinicstatus-data');
  var clinicadministrative_status         = $("#mesg_administrative_"+messageaccess_id).attr('clinicstatus-data');
  var clinicdigitaldoc_status             = $("#mesg_digitaldoc_"+messageaccess_id).attr('clinicstatus-data');
  var clinictext_sms_status               = $("#text_sms_clinic_"+clinic_id).attr('clinicstatus-data');
  var clinicpaymentinvoice_status         = $("#mesg_paymentinvoice_"+messageaccess_id).attr('clinicstatus-data');
  var clinicreminderpaymentinvoice_status = $("#mesg_reminderpaymentinvoice_"+messageaccess_id).attr('clinicstatus-data');
  var clinicdoubleappoinment_status       = $("#mesg_doubleappoinment_"+messageaccess_id).attr('clinicstatus-data');
  var clinicviewlink_status               = $("#mesg_viewlink_"+messageaccess_id).attr('clinicstatus-data');
  var clinicprescreeninglink_status       = $("#mesg_prescreeninglink_"+messageaccess_id).attr('clinicstatus-data');
  var clinicemailtemplate_status          = $("#mesg_emailtemplate_"+messageaccess_id).attr('clinicstatus-data');
  var clinictext_note_show                = $("#note_show_clinic_"+clinic_id).attr('clinicstatus-data');
  var clinicreschedulelink_status         = $("#mesg_reschedulelink_"+messageaccess_id).attr('clinicstatus-data');
  var clinicbookappointment_status        = $("#mesg_bookappointment_"+messageaccess_id).attr('clinicstatus-data');
  var clinicpaymentfeature_status         = $("#paymentfeature_clinic_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_status         = $("#onlineScheduling_clinic_"+clinic_id).attr('clinicstatus-data');
  var cliniissrtminguarantor_status         = $("#mesg_issrtminguarantor_"+messageaccess_id).attr('clinicstatus-data');
  /*online scheduling*/
  var cliniconlineScheduling_aboutus          = $("#onlineScheduling_clinic_aboutus_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_practicephoto    = $("#onlineScheduling_clinic_practicephoto_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_prodviders       = $("#onlineScheduling_clinic_prodviders_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_reviews          = $("#onlineScheduling_clinic_reviews_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_features         = $("#onlineScheduling_clinic_features_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_services         = $("#onlineScheduling_clinic_services_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_logobanner       = $("#onlineScheduling_clinic_logobanner_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_location         = $("#onlineScheduling_clinic_location_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_pageheader       = $("#onlineScheduling_clinic_pageheader_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_flexibleschedule = $("#onlineScheduling_clinic_flexibleschedule_"+clinic_id).attr('clinicstatus-data');
  var cliniconlineScheduling_officehours = $("#onlineScheduling_clinic_officehours_"+clinic_id).attr('clinicstatus-data');
  if(clinicreminder_status == '0' || clinicmarketing_status == '0' || clinicadministrative_status == '0' || clinicdigitaldoc_status == '0' || clinictext_sms_status == '0' || clinicpaymentinvoice_status == '0' || clinicreminderpaymentinvoice_status == '0' || clinicdoubleappoinment_status == '0' || clinicviewlink_status == '0' || clinicprescreeninglink_status == '0' || clinicemailtemplate_status == '0' || clinictext_note_show == '0' || clinicreschedulelink_status == '0' || clinicbookappointment_status == '0' )
  {
      
      
      $("#mesg_reminder_"+messageaccess_id).prop('checked', false);
      $("#mesg_marketing_"+messageaccess_id).prop('checked', false);
      $("#mesg_administrative_"+messageaccess_id).prop('checked', false);
      $("#mesg_digitaldoc_"+messageaccess_id).prop('checked', false);
      $("#text_sms_clinic_"+clinic_id).prop('checked', false);
      $("#mesg_paymentinvoice_"+messageaccess_id).prop('checked', false);
      $("#mesg_reminderpaymentinvoice_"+messageaccess_id).prop('checked', false);
      $("#mesg_doubleappoinment_"+messageaccess_id).prop('checked', false);
      $("#mesg_viewlink_"+messageaccess_id).prop('checked', false);
      $("#mesg_prescreeninglink_"+messageaccess_id).prop('checked', false);
      $("#mesg_emailtemplate_"+messageaccess_id).prop('checked', false);
      $("#note_show_clinic_"+clinic_id).prop('checked', false);
      $("#mesg_reschedulelink_"+clinic_id).prop('checked', false);
      $("#mesg_bookappointment_"+clinic_id).prop('checked', false);
      $("#paymentfeature_status_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_"+clinic_id).prop('checked', false);
      $("#mesg_issrtminguarantor_"+messageaccess_id).prop('checked', false);

      /*clinic online scheduling*/
      $("#onlineScheduling_clinic_aboutus_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_practicephoto_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_prodviders_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_reviews_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_features_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_services_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_logobanner_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_location_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_pageheader_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_flexibleschedule_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_clinic_officehours_"+clinic_id).prop('checked', false);
      /*provider online scheduling*/
      $("#onlineScheduling_provider_aboutus_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_provider_practicephoto_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_provider_reviews_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_provider_logobanner_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_provider_location_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_provider_pageheader_"+clinic_id).prop('checked', false);
      $("#onlineScheduling_provider_flexibleschedule_"+clinic_id).prop('checked', false);

      return false;
  }

  if(messageaccess_id == '0')
  {
    messageaccess_id = clinic_id;
  }

  swal({
        title: 'Are you sure ?',
        text: "change status!",
        type: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#0CC27E',
        cancelButtonColor: '#FF586B',
        confirmButtonText: 'Yes, change status!',
        cancelButtonText: 'No, cancel!',
        confirmButtonClass: 'btn btn-success mr-5',
        cancelButtonClass: 'btn btn-danger',
        buttonsStyling: false
    }).then(function () {
        $.ajax({
          url: "clinic_setting.php",
          data: 'act=messagechange_status&messageaccess_id='+messageaccess_id+'&status='+status+'&status_data='+msgaccess_data,
          dataType: 'json',
          cache: false,
          success: function(data){
                      
                      $("#status_msg").show();
                      $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>Status updated successfully...</div>");
                      $("#status_msg_td").html(data.msg);
                      hideMessage();
                      $("#mesg_reminder_"+messageaccess_id).attr("reminder-data", data.reminder);
                      $("#mesg_marketing_"+messageaccess_id).attr("marketing-data", data.marketing);
                      $("#mesg_administrative_"+messageaccess_id).attr("adminstrative-data", data.adminstrative);
                      $("#mesg_digitaldoc_"+messageaccess_id).attr("digitaldoc-data", data.digitaldoc);
                      $("#text_sms_clinic_"+clinic_id).attr("text_sms_clinic-data", data.text_sms);
                      $("#mesg_paymentinvoice_"+messageaccess_id).attr("paymentinvoice-data", data.paymentinvoice);
                      $("#mesg_reminderpaymentinvoice_"+messageaccess_id).attr("reminderpaymentinvoice-data", data.reminderpaymentinvoice);
                      $("#mesg_doubleappoinment_"+messageaccess_id).attr("doubleappoinment-data", data.doubleappoinment);
                      $("#mesg_viewlink_"+messageaccess_id).attr("viewlink-data", data.viewlink);
                      $("#mesg_prescreeninglink_"+messageaccess_id).attr("prescreeninglink-data", data.prescreeninglink);
                      $("#mesg_emailtemplate_"+messageaccess_id).attr("emailtemplate-data", data.emailtemplate);
                      $("#note_show_clinic_"+clinic_id).attr("note_show_clinic-data", data.note_show);
                      $("#mesg_reschedulelink_"+messageaccess_id).attr("reschedulelink-data", data.reschedulelink);
                      $("#mesg_bookappointment_"+messageaccess_id).attr("bookappointment-data", data.bookappointment);
                      $("#paymentfeature_clinic_"+clinic_id).attr("paymentfeature_clinic-data", data.paymentfeature);
                      $("#onlineScheduling_clinic_"+clinic_id).attr("onlineScheduling_clinic-data", data.onlineScheduling);
                      $("#mesg_issrtminguarantor_"+messageaccess_id).attr("issrtminguarantor-data", data.issrtminguarantor);
                      /*clinic online scheduling*/
                      $("#onlineScheduling_clinic_aboutus_"+clinic_id).attr("onlineScheduling_clinic_aboutus-data", data.onlineSchedulingaboutus);
                      $("#onlineScheduling_clinic_practicephoto_"+clinic_id).attr("onlineScheduling_clinic_practicephoto-data", data.onlineSchedulingpracticephoto);
                      $("#onlineScheduling_clinic_prodviders_"+clinic_id).attr("onlineScheduling_clinic_prodviders-data", data.onlineSchedulingprodviders);
                      $("#onlineScheduling_clinic_reviews_"+clinic_id).attr("onlineScheduling_clinic_reviews-data", data.onlineSchedulingreviews);
                      $("#onlineScheduling_clinic_features_"+clinic_id).attr("onlineScheduling_clinic_features-data", data.onlineSchedulingfeatures);
                      $("#onlineScheduling_clinic_services_"+clinic_id).attr("onlineScheduling_clinic_services-data", data.onlineSchedulingservices);
                      $("#onlineScheduling_clinic_logobanner_"+clinic_id).attr("onlineScheduling_clinic_logobanner-data", data.onlineSchedulinglogobanner);
                      $("#onlineScheduling_clinic_location_"+clinic_id).attr("onlineScheduling_clinic_location-data", data.onlineSchedulinglocation);
                      $("#onlineScheduling_clinic_pageheader_"+clinic_id).attr("onlineScheduling_clinic_pageheader-data", data.onlineSchedulingpageheader);
                      $("#onlineScheduling_clinic_flexibleschedule_"+clinic_id).attr("onlineScheduling_clinic_flexibleschedule-data", data.onlineSchedulingflexibleschedule);
                      $("#onlineScheduling_clinic_officehours_"+clinic_id).attr("onlineScheduling_clinic_officehours-data", data.onlineSchedulingofficehours);
                      /*provider online scheduling*/
                      $("#onlineScheduling_provider_aboutus_"+clinic_id).attr("onlineScheduling_provider_aboutus-data", data.cdoctoronlineSchedulingaboutus);
                      $("#onlineScheduling_provider_practicephoto_"+clinic_id).attr("onlineScheduling_provider_practicephoto-data", data.cdoctoronlineSchedulingpracticephoto);
                      $("#onlineScheduling_provider_reviews_"+clinic_id).attr("onlineScheduling_provider_reviews-data", data.cdoctoronlineSchedulingreviews);
                      $("#onlineScheduling_provider_logobanner_"+clinic_id).attr("onlineScheduling_provider_logobanner-data", data.cdoctoronlineSchedulinglogobanner);
                      $("#onlineScheduling_provider_location_"+clinic_id).attr("onlineScheduling_provider_location-data", data.cdoctoronlineSchedulinglocation);
                      $("#onlineScheduling_provider_pageheader_"+clinic_id).attr("onlineScheduling_provider_pageheader-data", data.cdoctoronlineSchedulingpageheader);
                      $("#onlineScheduling_provider_flexibleschedule_"+clinic_id).attr("onlineScheduling_provider_flexibleschedule-data", data.cdoctoronlineSchedulingflexibleschedule);
          }
        });
    }, function (dismiss) {
      var chk_reminder                = $("#mesg_reminder_"+messageaccess_id).attr('reminder-data');
      var chk_marketing               = $("#mesg_marketing_"+messageaccess_id).attr('marketing-data');
      var chk_administrative          = $("#mesg_administrative_"+messageaccess_id).attr('adminstrative-data');
      var chk_digitaldoc              = $("#mesg_digitaldoc_"+messageaccess_id).attr('digitaldoc-data');
      var chk_text_sms_clinic         = $("#text_sms_clinic_"+clinic_id).attr('text_sms_clinic-data');
      var chk_paymentinvoice          = $("#mesg_paymentinvoice_"+messageaccess_id).attr('paymentinvoice-data');
      var chk_reminderpaymentinvoice  = $("#mesg_reminderpaymentinvoice_"+messageaccess_id).attr('reminderpaymentinvoice-data');
      var chk_doubleappoinment        = $("#mesg_doubleappoinment_"+messageaccess_id).attr('doubleappoinment-data');
      var chk_viewlink                = $("#mesg_viewlink_"+messageaccess_id).attr('viewlink-data');
      var chk_prescreeninglink        = $("#mesg_prescreeninglink_"+messageaccess_id).attr('prescreeninglink-data');
      var chk_emailtemplate           = $("#mesg_emailtemplate_"+messageaccess_id).attr('emailtemplate-data');
      var chk_note_show_clinic        = $("#note_show_clinic_"+clinic_id).attr('note_show_clinic-data');
      var chk_reschedulelink          = $("#mesg_reschedulelink_"+messageaccess_id).attr('reschedulelink-data');
      var chk_bookappointment         = $("#mesg_bookappointment_"+messageaccess_id).attr('bookappointment-data');
      var chk_paymentfeature_clinic   = $("#paymentfeature_clinic_"+clinic_id).attr('paymentfeature_clinic-data');
      var chk_onlineScheduling_clinic = $("#onlineScheduling_clinic_"+clinic_id).attr('onlineScheduling_clinic-data');
      var chk_issrtminguarantor       = $("#mesg_issrtminguarantor_"+clinic_id).attr('issrtminguarantor-data');

      /*clinic online scheduling*/
      var chk_onlineScheduling_clinic_aboutus       = $("#onlineScheduling_clinic_aboutus_"+clinic_id).attr('onlineScheduling_clinic_aboutus-data');
      var chk_onlineScheduling_clinic_practicephoto = $("#onlineScheduling_clinic_practicephoto_"+clinic_id).attr('onlineScheduling_clinic_practicephoto-data');
      var chk_onlineScheduling_clinic_prodviders    = $("#onlineScheduling_clinic_prodviders_"+clinic_id).attr('onlineScheduling_clinic_prodviders-data');
      var chk_onlineScheduling_clinic_reviews       = $("#onlineScheduling_clinic_reviews_"+clinic_id).attr('onlineScheduling_clinic_reviews-data');
      var chk_onlineScheduling_clinic_features      = $("#onlineScheduling_clinic_features_"+clinic_id).attr('onlineScheduling_clinic_features-data');
      var chk_onlineScheduling_clinic_services      = $("#onlineScheduling_clinic_services_"+clinic_id).attr('onlineScheduling_clinic_services-data');
      var chk_onlineScheduling_clinic_logobanner    = $("#onlineScheduling_clinic_logobanner_"+clinic_id).attr('onlineScheduling_clinic_logobanner-data');
      var chk_onlineScheduling_clinic_location      = $("#onlineScheduling_clinic_location_"+clinic_id).attr('onlineScheduling_clinic_location-data');
      var chk_onlineScheduling_clinic_pageheader    = $("#onlineScheduling_clinic_pageheader_"+clinic_id).attr('onlineScheduling_clinic_pageheader-data');
      var chk_onlineScheduling_clinic_flexibleschedule    = $("#onlineScheduling_clinic_flexibleschedule_"+clinic_id).attr('onlineScheduling_clinic_flexibleschedule-data');
      var chk_onlineScheduling_clinic_officehours    = $("#onlineScheduling_clinic_officehours_"+clinic_id).attr('onlineScheduling_clinic_officehours-data');
      /*provider online scheduling*/
      var chk_cdoctor_onlineScheduling_aboutus          = $("#onlineScheduling_provider_aboutus_"+clinic_id).attr('onlineScheduling_provider_aboutus-data');
      var chk_cdoctor_onlineScheduling_practicephoto    = $("#onlineScheduling_provider_practicephoto_"+clinic_id).attr('onlineScheduling_provider_practicephoto-data');
      var chk_cdoctor_onlineScheduling_reviews          = $("#onlineScheduling_provider_reviews_"+clinic_id).attr('onlineScheduling_provider_reviews-data');
      var chk_cdoctor_onlineScheduling_logobanner       = $("#onlineScheduling_provider_logobanner_"+clinic_id).attr('onlineScheduling_provider_logobanner-data');
      var chk_cdoctor_onlineScheduling_location         = $("#onlineScheduling_provider_location_"+clinic_id).attr('onlineScheduling_provider_location-data');
      var chk_cdoctor_onlineScheduling_pageheader       = $("#onlineScheduling_provider_pageheader_"+clinic_id).attr('onlineScheduling_provider_pageheader-data');
      var chk_cdoctor_onlineScheduling_flexibleschedule = $("#onlineScheduling_provider_flexibleschedule_"+clinic_id).attr('onlineScheduling_provider_flexibleschedule-data');

      if(chk_reminder == '1')
      {
        $("#mesg_reminder_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_reminder_"+messageaccess_id).prop('checked', false);
      }

      if(chk_marketing == '1')
      {
        $("#mesg_marketing_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_marketing_"+messageaccess_id).prop('checked', false);
      }

      if(chk_administrative == '1')
      {
        $("#mesg_administrative_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_administrative_"+messageaccess_id).prop('checked', false);
      }

      if(chk_digitaldoc == '1')
      {
        $("#mesg_digitaldoc_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_digitaldoc_"+messageaccess_id).prop('checked', false);
      }

      if(chk_text_sms_clinic == 'on')
      {
        $("#text_sms_clinic_"+clinic_id).prop('checked', true);
      }else{
        $("#text_sms_clinic_"+clinic_id).prop('checked', false);
      }

      if(chk_paymentinvoice == '1')
      {
        $("#mesg_paymentinvoice_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_paymentinvoice_"+messageaccess_id).prop('checked', false);
      }

      if(chk_reminderpaymentinvoice == '1')
      {
        $("#mesg_reminderpaymentinvoice_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_reminderpaymentinvoice_"+messageaccess_id).prop('checked', false);
      }

      if(chk_doubleappoinment == '1')
      {
        $("#mesg_doubleappoinment_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_doubleappoinment_"+messageaccess_id).prop('checked', false);
      }

      if(chk_viewlink == '1')
      {
        $("#mesg_viewlink_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_viewlink_"+messageaccess_id).prop('checked', false);
      }
      
      if(chk_prescreeninglink == '1')
      {
        $("#mesg_prescreeninglink_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_prescreeninglink_"+messageaccess_id).prop('checked', false); 
      }

      if(chk_emailtemplate == '1')
      {
        $("#mesg_emailtemplate_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_emailtemplate_"+messageaccess_id).prop('checked', false); 
      } 
          
      if(chk_note_show_clinic == '1')
      {
        $("#note_show_clinic_"+clinic_id).prop('checked', true);
      }else{
        $("#note_show_clinic_"+clinic_id).prop('checked', false);
      }

      if(chk_reschedulelink == '1')
      {
        $("#mesg_reschedulelink_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_reschedulelink_"+messageaccess_id).prop('checked', false); 
      }

      if(chk_bookappointment == '1')
      {
        $("#mesg_bookappointment_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_bookappointment_"+messageaccess_id).prop('checked', false); 
      }

      if(chk_paymentfeature_clinic == '1')
      {
        $("#paymentfeature_clinic_"+clinic_id).prop('checked', true);
      }else{
        $("#paymentfeature_clinic_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic == '1')
      {
        $("#onlineScheduling_clinic_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_"+clinic_id).prop('checked', false);
      }

      if(chk_issrtminguarantor == '1')
      {
        $("#mesg_issrtminguarantor_"+messageaccess_id).prop('checked', true);
      }else{
        $("#mesg_issrtminguarantor_"+messageaccess_id).prop('checked', false);
      }

      /*online scheduling*/
      if(chk_onlineScheduling_clinic_aboutus == '1')
      {
        $("#onlineScheduling_clinic_aboutus_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_aboutus_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_practicephoto == '1')
      {
        $("#onlineScheduling_clinic_practicephoto_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_practicephoto_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_prodviders == '1')
      {
        $("#onlineScheduling_clinic_prodviders_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_prodviders_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_reviews == '1')
      {
        $("#onlineScheduling_clinic_reviews_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_reviews_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_features == '1')
      {
        $("#onlineScheduling_clinic_features_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_features_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_services == '1')
      {
        $("#onlineScheduling_clinic_services_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_services_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_logobanner == '1')
      {
        $("#onlineScheduling_clinic_logobanner_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_logobanner_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_location == '1')
      {
        $("#onlineScheduling_clinic_location_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_location_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_pageheader == '1')
      {
        $("#onlineScheduling_clinic_pageheader_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_pageheader_"+clinic_id).prop('checked', false);
      }

      if(chk_onlineScheduling_clinic_flexibleschedule == '1')
      {
        $("#onlineScheduling_clinic_flexibleschedule_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_flexibleschedule_"+clinic_id).prop('checked', false);
      }
      if(chk_onlineScheduling_clinic_officehours == '1')
      {
        $("#onlineScheduling_clinic_officehours_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_clinic_officehours_"+clinic_id).prop('checked', false);
      }
      /*provider online scheduling*/
      if(chk_cdoctor_onlineScheduling_aboutus == '1')
      {
        $("#onlineScheduling_provider_aboutus_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_provider_aboutus_"+clinic_id).prop('checked', false);
      }

      if(chk_cdoctor_onlineScheduling_practicephoto == '1')
      {
        $("#onlineScheduling_provider_practicephoto_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_provider_practicephoto_"+clinic_id).prop('checked', false);
      }

      if(chk_cdoctor_onlineScheduling_reviews == '1')
      {
        $("#onlineScheduling_provider_reviews_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_provider_reviews_"+clinic_id).prop('checked', false);
      }

      if(chk_cdoctor_onlineScheduling_logobanner == '1')
      {
        $("#onlineScheduling_provider_logobanner_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_provider_logobanner_"+clinic_id).prop('checked', false);
      }

      if(chk_cdoctor_onlineScheduling_location == '1')
      {
        $("#onlineScheduling_provider_location_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_provider_location_"+clinic_id).prop('checked', false);
      }

      if(chk_cdoctor_onlineScheduling_pageheader == '1')
      {
        $("#onlineScheduling_provider_pageheader_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_provider_pageheader_"+clinic_id).prop('checked', false);
      }

      if(chk_cdoctor_onlineScheduling_flexibleschedule == '1')
      {
        $("#onlineScheduling_provider_flexibleschedule_"+clinic_id).prop('checked', true);
      }else{
        $("#onlineScheduling_provider_flexibleschedule_"+clinic_id).prop('checked', false);
      }


      return false; 
    });
}


</script>
<div class="breadcrumb">
    <h1>Clinic Setting : <?php echo $clinicDetail->clinic_name ?> </h1>
    <ul>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>">Dashboard</a></li>
        <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>/cliniclist.php">Clinic List</a></li>
    </ul>
</div>
<div class="widget-body">
    <div class="portlet-body">
                        
    <?php echo (isset($successMsg) && $successMsg!='') ? "<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>".base64_decode($successMsg)."</div>" : '' ; ?>
    <?php echo (isset($failedMsg) && $failedMsg!='') ? "<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>".base64_decode($failedMsg)."</div>" : '' ?>
   
    <div id="status_msg" style="display: none;"><div class="alert alert-success"><button data-dismiss='alert' class='close' type='button'>×</button>&nbsp;</div></div>
    <div id="alert_msg" style="display: none;"><div class="alert alert-danger"><button data-dismiss='alert' class='close' type='button'>×</button>&nbsp;</div></div>

    </div>
</div>
<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Communication Setting</div>
                <form action="" id='frm-clinicsetting' method="post" enctype="multipart/form-data">
                    <?php  if(isset($clinicDetail->clinic_id) && $clinicDetail->clinic_id!=0) { 
                        ?>
                       <input type="hidden" id="clinic_id" name="clinic_id" value="<?php echo $clinicDetail->clinic_id ?>" />
                       <input type="hidden" id="clinic_user_unique_id" name="clinic_user_unique_id" value="<?php echo $userDetail->user_unique_id ?>" />
                    <?php } ?>
                     <div class="row ">
                    
                    
                    
                    
                </div>
                    <div class="row">
                        <div>
                        </div>
                        <div class="col-md-4 mt-3 mt-md-0"  id="div_communicationprovider">
                        <!-- <label for="communicationprovider ">Communication Provider</label> -->
                        <select class="form-control" id="communicationprovider" name="communicationprovider">
                            <!-- <option value="">Select provider</option> -->
                            <?php 
                            $communiprovider = json_decode($clinicDetail->clinic_setting);
                                ?>
                            <option value="twilio" <?php echo (isset($communiprovider) && $communiprovider->communicationprovider == "twilio") ? "selected='selected'" : ""; ?>>Twilio</option>
                            <option value="goto" <?php echo (isset($communiprovider) && $communiprovider->communicationprovider == "goto") ? "selected='selected'" : ""; ?>>Goto</option>
                            <option value="mango" <?php echo (isset($communiprovider) && $communiprovider->communicationprovider == "mango") ? "selected='selected'" : ""; ?>>Mango</option>

                        </select>
                    </div>
                    
                        <?php
                            if(isset($clinicDetail) && $clinicDetail > 0)
                            {
                                //foreach ($clinicDetail as $ckey => $clinic_value) 
                                //{
                                    if(isset($clinicDetail->clinic_setting) && $clinicDetail->clinic_setting != '')
                                    {
                                        $clinicsetting = json_decode($clinicDetail->clinic_setting,1);

                                        foreach ($clinicsetting as $skey => $settingvalue) 
                                        { if($skey != 'communicationprovider'){?>
                                            
                                            <div class="col-md-8 form-group mb-3">
                                                <input type="text"  name="field_setting1[]" value="<?php echo $skey; ?>"/>&nbsp;&nbsp;&nbsp;&nbsp;
                                                <input type="text" name="field_setting2[]" id="<?php echo $skey; ?>" value="<?php echo $settingvalue; ?>"/>
                                                
                                            </div>
                                            <div class="col-md-4 form-group mb-3">
                                            </div>
                                       <?php } }
                                    }
                                    
                                //}
                                
                            }
                        ?>
                        
                        <div class="col-md-6 form-group mb-3 field_wrapper">
                            <input type="text" name="field_setting1[]" value="" placeholder="email" />&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="text" name="field_setting2[]" value="" placeholder="info@dmo.com"/>
                            <a href="javascript:void(0);" class="add_button" title="Add field"><img src=<?Php echo SITE_URL."x-admin/assets/images/clinic_setting/add-icon.png" ?>></a>
                        </div>

                        
                        
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Patient Overdue Settings</div>
                <form action="" id='frm-clinicoverdue' method="post" enctype="multipart/form-data">
                    
                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_6" name="clinic_overdueval_6" value="0-6" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>0-6</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_6" name="clinic_initiation_days_6" value="<?php echo $initiation_days_6; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_6"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_6" name="clinic_overdue_status_6" class="form-control" multiple name="clinic_overdue_status_6[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_6))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_6))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_6))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_6))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_6))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_6"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category">Procedure Category </label>
                            <select id="clinic_procedure_category_6" name="clinic_procedure_category_6" class="form-control" multiple name="clinic_procedure_category_6[]">
                                <?php
                                    $procedure_codeObj = new procedure_code();
                                    $where = "procedure_code_clinic_id = '".$_REQUEST['clinic_id']."' and procedure_code_category != ''";
                                    $groupBy = array("procedure_code_category");
                                    $procedurecodeArg    = array('where' => $where,'groupBy'=>$groupBy);
                                    $categoryDetails = $procedure_codeObj->getAllRecords($procedurecodeArg);
                                    ?>
                                    <!-- <option value="0">Select Category</option> -->
                                    <?php
                                    foreach ($categoryDetails as $key => $categoryvalue) 
                                    { ?>
                                       <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_6))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                             
                                    <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_6"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_6">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_6" name="clinic_procedure_code_6" class="form-control" multiple name="clinic_procedure_code_6[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_6){
                                        foreach($codeDetails_6 as $c6key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_6))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?> 
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_6"></div>
                        </div>
                    </div>

                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_12" name="clinic_overdueval_12" value="7-12" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>7-12</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days_12">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_12" name="clinic_initiation_days_12" value="<?php echo $initiation_days_12; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_12"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status_12">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_12" name="clinic_overdue_status_12" class="form-control" multiple name="clinic_overdue_status_12[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_12))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_12))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_12))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_12))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_12))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_12"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category_12">Procedure Category </label>
                            <select id="clinic_procedure_category_12" name="clinic_procedure_category_12" class="form-control" multiple name="clinic_procedure_category_12[]">
                                <?php
                                    $procedure_codeObj = new procedure_code();
                                    $where = "procedure_code_clinic_id = '".$_REQUEST['clinic_id']."' and procedure_code_category != ''";
                                    $groupBy = array("procedure_code_category");
                                    $procedurecodeArg    = array('where' => $where,'groupBy'=>$groupBy);
                                    $categoryDetails = $procedure_codeObj->getAllRecords($procedurecodeArg);
                                    ?>
                                    <!-- <option value="0">Select Category</option> -->
                                    <?php
                                    foreach ($categoryDetails as $key => $categoryvalue) 
                                    { ?>
                                       <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_12))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                             
                                    <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_12"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_12">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_12" name="clinic_procedure_code_12" class="form-control" multiple name="clinic_procedure_code_12[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_12){
                                        foreach($codeDetails_12 as $c12key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_12))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_12"></div>
                        </div>
                    </div>

                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_18" name="clinic_overdueval_18" value="13-18" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>13-18</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days_18">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_18" name="clinic_initiation_days_18" value="<?php echo $initiation_days_18; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_18"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status_18">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_18" name="clinic_overdue_status_18" class="form-control" multiple name="clinic_overdue_status_18[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_18))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_18))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_18))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_18))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_18))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_18"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category_18">Procedure Category </label>
                            <select id="clinic_procedure_category_18" name="clinic_procedure_category_18" class="form-control" multiple name="clinic_procedure_category_18[]">
                                <?php
                                    $procedure_codeObj = new procedure_code();
                                    $where = "procedure_code_clinic_id = '".$_REQUEST['clinic_id']."' and procedure_code_category != ''";
                                    $groupBy = array("procedure_code_category");
                                    $procedurecodeArg    = array('where' => $where,'groupBy'=>$groupBy);
                                    $categoryDetails = $procedure_codeObj->getAllRecords($procedurecodeArg);
                                    ?>
                                    <!-- <option value="0">Select Category</option> -->
                                    <?php
                                    foreach ($categoryDetails as $key => $categoryvalue) 
                                    { ?>
                                       <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_18))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                             
                                    <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_18"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_18">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_18" name="clinic_procedure_code_18" class="form-control" multiple name="clinic_procedure_code_18[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_18){
                                        foreach($codeDetails_18 as $c18key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_18))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_18"></div>
                        </div>
                    </div>

                    <div class="row">

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdueval"><span class="asterisk"></span></label>
                            <input type="hidden" class="form-control" id="clinic_overdueval_24" name="clinic_overdueval_24" value="19-24" placeholder="Enter Initiation days">
                            <br/>
                            <span><b>19-24</b></span>
                        </div>

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_initiation_days_24">Initiation days <span class="asterisk">*</span></label>
                            <input type="text" class="form-control" id="clinic_initiation_days_24" name="clinic_initiation_days_24" value="<?php echo $initiation_days_24; ?>" placeholder="Enter Initiation days">
                            <div class="invalid-tooltip" id="msg_clinic_initiation_days_24"></div>
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_overdue_status_24">Status <span class="asterisk">*</span></label>
                            <select id="clinic_overdue_status_24" name="clinic_overdue_status_24" class="form-control" multiple name="clinic_overdue_status_24[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$status_24))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$status_24))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$status_24))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$status_24))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$status_24))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_overdue_status_24"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_category_24">Procedure Category </label>
                            <select id="clinic_procedure_category_24" name="clinic_procedure_category_24" class="form-control" multiple name="clinic_procedure_category_24[]">        
                            <?php
                            foreach ($categoryDetails as $key => $categoryvalue) 
                            { ?>
                               <option value="<?php echo $categoryvalue->procedure_code_category; ?>" <?php echo (in_array($categoryvalue->procedure_code_category,$procedure_category_24))?"selected='selected'":""  ?>  ><?php echo $categoryvalue->procedure_code_category; ?></option>
                                                     
                            <?php } ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_category_24"></div>
                        </div>
                        <div class="col-md-3 form-group mb-3">
                            <label for="clinic_procedure_code_24">Procedure Code <?php echo $pr; ?> </label>
                            <select id="clinic_procedure_code_24" name="clinic_procedure_code_24" class="form-control" multiple name="clinic_procedure_code_24[]">
                                <!-- <option value="">Select Code</option> -->
                                <?php if($codeDetails_24){
                                        foreach($codeDetails_24 as $c24key => $cvalue)
                                        { ?>
                                            <option value="<?php echo $cvalue->procedure_code_sikkaId; ?>" <?php echo (in_array($cvalue->procedure_code_sikkaId,$procedure_code_24))?"selected='selected'":""  ?>  ><?php echo $cvalue->procedure_code_sikkaId; ?></option>
                                        <?php }
                                      }
                                 ?>

                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_procedure_code_24"></div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Xcare Past Appointment Status - New Patient Logic</div>
                <form action="" id='frm-clinicpatientstatus' method="post" enctype="multipart/form-data">
                    
                    <div class="row">

                        

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_patient_status">Status </label>
                            <select id="clinic_patient_status" name="clinic_patient_status" class="form-control" multiple name="clinic_patient_status[]">
                                <!-- <option value="">Select Status</option> -->
                                <option value="requested" <?php echo (in_array("requested",$clinic_patient_status))?"selected='selected'":""  ?> >Requested</option>
                                <option value="scheduled" <?php echo (in_array("scheduled",$clinic_patient_status))?"selected='selected'":""  ?> >Scheduled</option>
                                <option value="completed" <?php echo (in_array("completed",$clinic_patient_status))?"selected='selected'":""  ?> >Completed</option>
                                <option value="cancelled" <?php echo (in_array("cancelled",$clinic_patient_status))?"selected='selected'":""  ?> >Cancelled</option>
                                <option value="waitlist" <?php echo (in_array("waitlist",$clinic_patient_status))?"selected='selected'":""  ?> >Waitlist</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_patient_status"></div>
                        </div>
                        
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">GoTo API Setting</div>
                <form action="" id='frm-gotosetting' method="post" enctype="multipart/form-data">
                    
                    <div class="row">
                        <div class="col-md-6 form-group mb-3">
                            <label for="goto_clientId">Client ID <span class="asterisk">*</span></label>
                            <?php $goToSetting = json_decode($clinicDetail->clinic_setting);?>
                            <input type="text" name="goto_clientId" class="form-control" id="goto_clientId" value="<?php echo (isset($goToSetting) && isset($goToSetting->clientid)) ? $goToSetting->clientid : ""; ?>">
                            <div class="invalid-tooltip" id="msg_goto_clientId"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            
                        </div>
                        
                        <div class="col-md-6 form-group mb-3">
                            <label for="goto_client_secret">Client Secret<span class="asterisk">*</span></label>
                            <input type="text" name="goto_client_secret" class="form-control" id="goto_client_secret" value="<?php echo (isset($goToSetting) && isset($goToSetting->clientsecret)) ? $goToSetting->clientsecret : ""; ?>">
                            <div class="invalid-tooltip" id="msg_goto_client_secret"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="goto_code">Code </label>
                            <!-- <span class="asterisk">*</span> -->
                            <textarea id="goto_code" name="goto_code" class="form-control" rows="7" cols="50"></textarea>
                            <div class="invalid-tooltip" id="msg_goto_code"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            
                        </div>
                        <div class="col-md-6">
                            <input type="submit"  class="btn btn-primary" id="get_code" name="get_code" value="Get Code">
                            &emsp;&emsp;
                            <input type="submit" class="btn btn-primary" id="get_token" name="get_token" value="Get Token">

                            <!-- <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Get Token"> -->
                        </div>

                        <!-- <div class="col-md-6">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Get Token">
                        </div> -->
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">GHL API Setting</div>
                <form action="" id='frm-ghlsetting' method="post" enctype="multipart/form-data">
                    
                    <div class="row">
                        <div class="col-md-6 form-group mb-3">
                            <label for="ghl_clientId">Client ID <span class="asterisk">*</span></label>
                            <input type="text" name="ghl_clientId" class="form-control" id="ghl_clientId" value="676d49fd42a77accd78272bf-m55b2clr">
                            <div class="invalid-tooltip" id="msg_ghl_clientId"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">

                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="ghl_client_secret">Client Secret<span class="asterisk">*</span></label>
                            <input type="text" name="ghl_client_secret" class="form-control" id="ghl_client_secret" value="68fad80d-2635-4927-b768-7d4a7879e59f">
                            <div class="invalid-tooltip" id="msg_ghl_client_secret"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">

                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="ghl_code">Code </label>
                            <!-- <span class="asterisk">*</span> -->
                            <textarea id="ghl_code" name="ghl_code" class="form-control" rows="7" cols="50"></textarea>
                            <div class="invalid-tooltip" id="msg_ghl_code"></div>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            
                        </div>
                        <div class="col-md-6">
                            <input type="submit"  class="btn btn-primary" id="get_code" name="get_code" value="Get Code">
                            &emsp;&emsp;
                            <input type="submit" class="btn btn-primary" id="get_token" name="get_token" value="Get Token">

                            <!-- <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Get Token"> -->
                        </div>

                        <!-- <div class="col-md-6">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Get Token">
                        </div> -->
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">GoTo Incoming Message and Call Subscription</div>
                <form action="" id='frm-gotosubs' method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-6">
                            <input type="submit" class="btn btn-primary" id="goto_subs" name="goto_subs" value="Get GoTo Webhook Subscription">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Practice Features</div>
                <form action="" id='frm-statuschange' method="post" enctype="multipart/form-data">
                    
                    <div class="row">
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $reminder; echo $marketing;  echo $administrative;?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $digitaldoc;  echo $paymentinvoice;  echo $reminderpaymentinvoice; ?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $doubleappoinment_data; echo $viewlink_data; echo $prescreeninglink_data; ?>
                            
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $emailtemplate_data; echo $clinictextsms; echo $clinicnotesshow; ?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $reschedulelink_data;  ?>
                            <?php echo $bookappointment_data;  ?>
                            <?php echo $clinicpaymentfeature;  ?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $multiappointment_message_data;  ?>
                            <?php echo $emailtemplatemarketing_data;  ?>
                            <?php echo $confirmtextinsms_data;  ?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $issrtminguarantor;  ?>
                        </div>
                    </div>
                    <div class="separator-breadcrumb border-top"></div>
                    <div class="card-title mb-3">Online Scheduling</div>
                    <div class="row" id="onlinescheduling">

                        <div class="col-md-4 form-group mb-3">
                            <?php echo $cliniconlineScheduling;  echo $cliniconlineSchedulingaboutus; echo $cliniconlineSchedulingpracticephoto;  ?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $cliniconlineSchedulingreviews;  echo $cliniconlineSchedulingfeatures;  echo $cliniconlineSchedulingservices; echo $cliniconlineSchedulingflexibleschedule; ?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $cliniconlineSchedulinglogobanner; echo $cliniconlineSchedulinglocation; echo $cliniconlineSchedulingpageheader; echo $cliniconlineSchedulingofficehours;?>
                            
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $cliniconlineSchedulingprodviders; echo $cdoctoronlineSchedulingaboutus; echo $cdoctoronlineSchedulingpracticephoto; echo $cdoctoronlineSchedulingreviews;  ?>
                        </div>
                        <div class="col-md-4 form-group mb-3">
                            <?php echo $cdoctoronlineSchedulinglogobanner; echo $cdoctoronlineSchedulinglocation; echo $cdoctoronlineSchedulingpageheader; echo $cdoctoronlineSchedulingflexibleschedule;?>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>



<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Manual Reminder</div>
                <form action="" id='frm-manualreminder' method="post" enctype="multipart/form-data">
                    <div class="row">
                      <div class="col-md-6 form-group mb-3">
                            <label for="clinic_data">Select Clinic <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="manual_reminderclinic_id" name="manual_reminderclinic_id" required="true">
                            <option value="0">Select Client</option>
                            <?php if($clinicDetail && count($clinicDetail) > 0){ ?>
                            <option value="<?php echo $clinicDetail->clinic_id; ?>" ><?php echo $clinicDetail->clinic_name; ?></option>
                            <?php }  ?>
                           </select>
                            <div class="invalid-tooltip" id="msg_clinic_data"></div>
                      </div>

                      <div class="col-md-6 form-group mb-3">
                            <label for="reminder_template_id">Select Template <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="reminder_template_id" name="reminder_template_id" >
                            <option value="">Select Template</option>
                            
                           </select>
                            <div class="invalid-tooltip" id="msg_reminder_template_id"></div>
                      </div>
                      
                      <div class="col-md-3 form-group mb-3" id="div_manual_remider_date">
                          <label for="manual_remider_date">Date <span class="asterisk">*</span></label>
                          <input type="date" class="form-control" id="manual_remider_date" name="manual_remider_date" >
                          <div class="invalid-tooltip" id="msg_manual_remider_date"></div>
                      </div>

                      <div class="col-md-12" id="div_app_submit">
                        <br/>
                          <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                          <input type="submit" class="btn btn-danger" id="submit" name="submit" value="Clear Table">
                      </div>
                      
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>

<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Manual Follow up</div>
                <form action="" id='frm-manualfollowup' method="post" enctype="multipart/form-data">
                    <div class="row">
                      <div class="col-md-6 form-group mb-3">
                            <label for="clinic_data">Select Clinic <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="manual_followupclinic_id" name="manual_followupclinic_id" required="true">
                            <option value="0">Select Client</option>
                            <?php if($clinicDetail && count($clinicDetail) > 0){ ?>
                            <option value="<?php echo $clinicDetail->clinic_id; ?>" ><?php echo $clinicDetail->clinic_name; ?></option>
                            <?php }  ?>
                           </select>
                            <div class="invalid-tooltip" id="msg_clinic_data"></div>
                      </div>

                      <div class="col-md-6 form-group mb-3">
                            <label for="followup_template_id">Select Template <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="followup_template_id" name="followup_template_id" >
                            <option value="">Select Template</option>
                            
                           </select>
                            <div class="invalid-tooltip" id="msg_followup_template_id"></div>
                      </div>
                      
                      <div class="col-md-3 form-group mb-3" id="div_manual_remider_date">
                          <label for="manual_followup_date">Date <span class="asterisk">*</span></label>
                          <input type="date" class="form-control" id="manual_followup_date" name="manual_followup_date" >
                          <div class="invalid-tooltip" id="msg_manual_followup_date"></div>
                      </div>

                      <div class="col-md-12" id="div_app_submit">
                        <br/>
                          <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                      </div>
                      
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>

<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Manual Recall</div>
                <form action="" id='frm-manualrecall' method="post" enctype="multipart/form-data">
                    <div class="row">
                      <div class="col-md-6 form-group mb-3">
                            <label for="clinic_data">Select Clinic <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="manual_recallclinic_id" name="manual_recallclinic_id" required="true">
                            <option value="0">Select Client</option>
                            <?php if($clinicDetail && count($clinicDetail) > 0){ ?>
                            <option value="<?php echo $clinicDetail->clinic_id; ?>" ><?php echo $clinicDetail->clinic_name; ?></option>
                            <?php }  ?>
                           </select>
                            <div class="invalid-tooltip" id="msg_clinic_data"></div>
                      </div>

                      <div class="col-md-6 form-group mb-3">
                            <label for="recall_template_id">Select Template <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="recall_template_id" name="recall_template_id" >
                            <option value="">Select Template</option>
                            
                           </select>
                            <div class="invalid-tooltip" id="msg_recall_template_id"></div>
                      </div>
                      
                      <div class="col-md-3 form-group mb-3" id="div_manual_recall_date">
                          <label for="manual_recall_date">Date <span class="asterisk">*</span></label>
                          <input type="date" class="form-control" id="manual_recall_date" name="manual_recall_date" >
                          <div class="invalid-tooltip" id="msg_manual_recall_date"></div>
                      </div>

                      <div class="col-md-12" id="div_app_submit">
                        <br/>
                          <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                      </div>
                      
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>

<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Re-use Message Center Templates</div>
                <form action="" id='frm-getmsgtemplate' method="post" enctype="multipart/form-data">
                    <div class="row">
                      <div class="col-md-6 form-group mb-3">
                            <label for="clinic_data">Copy From Clinic <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="fclinic_id" name="fclinic_id" required="true">
                            <option value="">Select Client</option>
                            <option value="master">Master</option>
                            <?php if($clinicDetail && count($clinicDetail) > 0){ ?>
                            <option value="<?php echo $clinicDetail->clinic_id; ?>" ><?php echo $clinicDetail->clinic_name; ?></option>
                            <?php }  ?>
                           </select>
                            <div class="invalid-tooltip" id="msg_fclinic_id"></div>
                      </div>
                      <!-- multiple name="msgtemplate_id[]" -->
                      <div class="col-md-6 form-group mb-3">
                            <label for="msgtemplate_id">Select Template </label>
                            <br/>
                           <select class="form-control msgtemplatedata" id="msgtemplate_id" name="msgtemplate_id[]" multiple >
                          
                           </select>
                            <div class="invalid-tooltip" id="msg_msgtemplate_id"></div>
                      </div>
                      
                      <div class="col-md-6 form-group mb-3">
                            <label for="tclinic_id">Copy To Clinic <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="tclinic_id" name="tclinic_id" >
                            <option value="">Select Clinic</option>
                            <option value="master">Master</option>
                            <?php
                                  $clinicobj = new clinic;
                                  $fields = array('clinic_id,clinic_name');
                                  $clinicArg = array("fields"=>$fields);
                                  $clinicdata = $clinicobj->getAllRecords($clinicArg);
                                  foreach ($clinicdata as $ckey => $clinic_value) 
                                    { 
                                      ?>
                                        <option value="<?php echo $clinic_value->clinic_id; ?>"><?php echo $clinic_value->clinic_name; ?></option>
                              <?php }
                            ?>

                        </select>
                            <div class="invalid-tooltip" id="msg_tclinic_id"></div>
                      </div>

                      <div class="col-md-12" id="div_app_submit">
                        <br/>
                          <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                      </div>
                      
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>

<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Re-use Message Center Marketing Campaign Templates</div>
                <form action="" id='frm-getmsgtemplatemarketing' method="post" enctype="multipart/form-data">
                    <div class="row">
                      <div class="col-md-6 form-group mb-3">
                            <label for="clinic_data">Copy From Clinic <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="fmclinic_id" name="fmclinic_id" required="true">
                            <option value="">Select Client</option>
                            <option value="master">Master</option>
                            <?php if($clinicDetail && count($clinicDetail) > 0){ ?>
                            <option value="<?php echo $clinicDetail->clinic_id; ?>" ><?php echo $clinicDetail->clinic_name; ?></option>
                            <?php }  ?>
                           </select>
                            <div class="invalid-tooltip" id="msg_fmclinic_id"></div>
                      </div>
                      <!-- multiple name="msgtemplate_id[]" -->
                      <div class="col-md-6 form-group mb-3">
                            <label for="msgtemplate_id">Select Template </label>
                            <br/>
                           <select class="form-control msgmarketingtemplatedata" id="msgmarketingtemplate_id" name="msgmarketingtemplate_id[]" multiple >
                          
                           </select>
                            <div class="invalid-tooltip" id="msg_msgmarketingtemplate_id"></div>
                      </div>
                      
                      <div class="col-md-6 form-group mb-3">
                            <label for="tclinic_id">Copy To Clinic <span class="asterisk">*</span></label>
                            <br/>
                           <select class="form-control" id="tmclinic_id" name="tmclinic_id" >
                            <option value="">Select Clinic</option>
                            <option value="master">Master</option>
                            <?php
                                  $clinicobj = new clinic;
                                  $fields = array('clinic_id,clinic_name');
                                  $clinicArg = array("fields"=>$fields);
                                  $clinicdata = $clinicobj->getAllRecords($clinicArg);
                                  foreach ($clinicdata as $ckey => $clinic_value) 
                                    { 
                                      ?>
                                        <option value="<?php echo $clinic_value->clinic_id; ?>"><?php echo $clinic_value->clinic_name; ?></option>
                              <?php }
                            ?>

                        </select>
                            <div class="invalid-tooltip" id="msg_tmclinic_id"></div>
                      </div>

                      <div class="col-md-12" id="div_app_submit">
                        <br/>
                          <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                      </div>
                      
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">PMS Write Back Status for Confirmed Appointment</div>
                <form action="" id='frm-cliniccnfwritebackstatus' method="post" enctype="multipart/form-data">
                    
                    <div class="row">

                        

                        <div class="col-md-2 form-group mb-3">
                            <label for="clinic_cnfrwitebackstatus">Writeback Status </label>
                            <select id="clinic_cnfrwitebackstatus" name="clinic_cnfrwitebackstatus" class="form-control">
                                <option value="">Select Status</option>
                                <?php if($pmsAppointmentStatusDetails && count($pmsAppointmentStatusDetails) > 0){
                                foreach($pmsAppointmentStatusDetails as $cnkey => $cnvalue){ ?>
                                <option value="<?php echo $cnvalue->pmsAppointmentStatus_status; ?>" <?php echo ($cnvalue->pmsAppointmentStatus_status == $clinicDetail->clinic_cnf_writebackStatus) ? "selected='selected'" : ""; ?> ><?php echo $cnvalue->pmsAppointmentStatus_status; ?></option>

                                <?php } }  ?>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_cnfrwitebackstatus"></div>
                        </div>
                        
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Download Patient Contact</div>
                <form action="" id='frm-patientcontact' method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-2 form-group mb-3">
                            <label for="patient_contact_start_date">Start Date </label>
                            <input type="date" class="form-control" id="patient_contact_start_date" name="patient_contact_start_date" >
                            <div class="invalid-tooltip" id="msg_patient_contact_start_date"></div>
                            
                        </div>
                        <div class="col-md-2 form-group mb-3">
                            <label for="patient_contact_end_date">End Date </label>
                            <input type="date" class="form-control" id="patient_contact_end_date" name="patient_contact_end_date" >
                            <div class="invalid-tooltip" id="msg_patient_contact_end_date"></div>
                            
                        </div>
                        
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Download">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- <div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Re-onboard Clinic</div>
                <form action="" id='frm-deleteclinic' method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-danger" id="submit" name="submit" value="Delete Clinic Data">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div> -->

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Appointment Chat Pin</div>
                <form action="" id='frm-apptchatpin' method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-2 form-group mb-3">
                            <label for="apptchatpin">Enable Automatic Chat Pin </label>
                            <select id="apptchatpin" name="apptchatpin" class="form-control">
                                <option value="">Select Status</option>
                                <?php $apptChatPin = json_decode($clinicDetail->clinic_setting);?>
                                <option value="yes" <?php echo (isset($apptChatPin) && $apptChatPin->appointmentChatPin == "yes") ? "selected='selected'" : ""; ?>>Yes</option>
                                <option value="no" <?php echo (isset($apptChatPin) && $apptChatPin->appointmentChatPin == "no") ? "selected='selected'" : ""; ?>>No</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_apptchatpin"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Onboard Clinc with Card </div>
                <form action="" id='frm-subscreditcard' method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-2 form-group mb-3">
                            <label for="subscreditcard">Status </label>
                            <select id="subscreditcard" name="subscreditcard" class="form-control" name="subscreditcard">
                                <option value="">Select Option</option>
                                <?php 
                                    //echo "<pre>";print_r($iscreditcard);echo "</pre>";
                                ?>
                                <option value="yes" <?php echo (isset($iscreditcard) && $iscreditcard == "yes") ? "selected='selected'" : ""; ?>>Yes</option>
                                <option value="no" <?php echo (isset($iscreditcard) && $iscreditcard == "no") ? "selected='selected'" : ""; ?>>No</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_subscreditcard"></div>
                        </div>

                        <div class="col-md-2 form-group mb-3" id="div-nocreditcard">
                            <label for="nocreditcard">Reason For No Credit Card </label>
                            <select id="nocreditcard" name="nocreditcard" class="form-control" name="nocreditcard">
                                <option value="">Select Option</option>
                                <?php 
                                    $nocreditcardreason = json_decode($clinicDetail->clinic_onboarding_no_creditcard_reason);
                                    //echo "<pre>";print_r($iscreditcard);echo "</pre>";
                                ?>
                                <option value="pay by cheque" <?php echo (isset($nocreditcardreason) && $nocreditcardreason == "pay by cheque ") ? "selected='selected'" : ""; ?>>Pay by Cheque </option>
                                <option value="extend subscription" <?php echo (isset($nocreditcardreason) && $nocreditcardreason == "extend subscription") ? "selected='selected'" : ""; ?>>Extend Subscription</option>
                                <option value="free provider profiles" <?php echo (isset($nocreditcardreason) && $nocreditcardreason == "free provider profiles") ? "selected='selected'" : ""; ?>>Free Provider Profiles</option>
                            </select>
                            <div class="invalid-tooltip" id="msg_clinic_patient_status"></div>
                        </div>
                        
                    </div>

                    <div class="row" id="carddetails">
                      <div class="col-md-6 form-group mb-3">
                            <label for="stripecardnum">Cooperate Card Number <span class="asterisk">*</span></label>
                            <br/>
                           <input type="text" name="stripecardnum" class="form-control" id="stripecardnum" value="">
                            <div class="invalid-tooltip" id="msg_stripecardnum"></div>
                      </div>

                      <div class="col-md-6 form-group mb-3">
                            <label for="stripecardname">Cooperate Name on Card <span class="asterisk">*</span></label>
                            <br/>
                            <input type="text" name="stripecardname" class="form-control" id="stripecardname" value="">
                            <div class="invalid-tooltip" id="msg_stripecardname"></div>
                      </div>
                      
                      <div class="col-md-6 form-group mb-3">
                            <label for="stripecardexpire">Cooperate Expiration Date(mm/yy)<span class="asterisk">*</span></label>
                            <br/>
                            <input type="text" name="stripecardexpire" class="form-control" id="stripecardexpire" value="">
                            <div class="invalid-tooltip" id="msg_stripecardexpire"></div>
                      </div>

                      <div class="col-md-6 form-group mb-3">
                            <label for="stripecardcvv">CVV<span class="asterisk">*</span></label>
                            <br/>
                            <input type="text" name="stripecardcvv" class="form-control" id="stripecardcvv" value="">
                            <div class="invalid-tooltip" id="msg_stripecardcvv"></div>
                      </div>
                      
                    </div>

                    <!-- <div class="row">
                        <div class="col-md-6 form-group mb-3">
                            <label for="stripecardnum">Cooperate Card Number <span class="asterisk">*</span></label>
                                <div id="card-number-element" class="field"></div>
                                <span class="brand"><i class="pf pf-credit-card" id="brand-icon"></i></span>
                            <br/>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="stripecardnum">Expiry date<span class="asterisk">*</span></label>
                                <div id="card-expiry-element" class="field"></div>
                            <br/>
                        </div>
                        <div class="col-md-6 form-group mb-3">
                            <label for="stripecardnum">CVV<span class="asterisk">*</span></label>
                                <div id="card-cvc-element" class="field"></div>
                            <br/>
                        </div>
                          <label>
                            <span>CVC</span>
                            <div id="card-cvc-element" class="field"></div>
                          </label>
                    </div> -->

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php if (strpos(SITE_URL, 'dev') !== false || strpos(SITE_URL, 'staging') !== false ) { ?>
<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Demo Clinic Name : <?php echo $clinicDetail->clinic_name ?></div>
                <div class="card-title mb-3">Please enter provider name and pms code to set up Demo Clinic.</div>
                <?php 
                if(isset($_GET['msg']) && $_GET['msg']!=""){?>
                    <div class="card-title mb-3"><?php echo $_GET['msg']; ?></div>
                <?php }?>
                <form action="" id='frm-clinicsettingPractice' method="post" enctype="multipart/form-data">
                    <?php  if(isset($clinicDetail) && $clinicDetail->clinic_id!=0 && $clinicDetail->clinic_id!="") { ?>
                       <input type="hidden" id="clinic_id" name="clinic_id" value="<?php echo $clinicDetail->clinic_id ?>" />
                    <?php } ?>
                    <div class="row">
                        <div class="col-md-12 form-group mb-12 field_wrapperPractice">
                            <input type="text" name="fname[]" id="fname" value="" placeholder="Provider First Name" />&nbsp;&nbsp;&nbsp;&nbsp;
                            
                            <input type="text" name="lname[]" id="lname" value="" placeholder="Provider Last Name" />
                            
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="text" name="code[]" id="code" value="" placeholder="PMS Provider Code"/>
                            

                            <a href="javascript:void(0);" class="add_buttonPractice" title="Add field"><img src=<?Php echo SITE_URL."x-admin/assets/images/clinic_setting/add-icon.png" ?>></a>
                        </div>
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<?php } ?>

<div class="separator-breadcrumb border-top"></div>
<div class="row">
    <div class="col-md-12">
        <div class="card mb-4">
            <div class="card-body">
                <div class="card-title mb-3">Update DisplayRating </div>
                <form action="" id='frm-updatedisplayrating' method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-2 form-group mb-3">
                            <label for="updatedisplayrating">Rating </label>
                            <select id="updatedisplayrating" name="updatedisplayrating" class="form-control" name="updatedisplayrating">
                                <option value="">Select Option</option>
                                <?php 
                                    //echo "<pre>";print_r($iscreditcard);echo "</pre>";
                                ?>
                                <option value="1" <?php echo (isset($rating) && $rating == "1") ? "selected='selected'" : ""; ?>>1</option>
                                <option value="2" <?php echo (isset($rating) && $rating == "2") ? "selected='selected'" : ""; ?>>2</option>
                                <option value="3" <?php echo (isset($rating) && $rating == "3") ? "selected='selected'" : ""; ?>>3</option>
                                <option value="4" <?php echo (isset($rating) && $rating == "4") ? "selected='selected'" : ""; ?>>4</option>
                                <option value="5" <?php echo (isset($rating) && $rating == "5") ? "selected='selected'" : ""; ?>>5</option>
                                
                            </select>
                            <div class="invalid-tooltip" id="msg_updatedisplayrating"></div>
                        </div>
                        
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Submit">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="./assets/js/jquery.multiselect.js"></script>
<link rel="stylesheet" href="./assets/styles/css/jquery.multiselect.css">

<link rel="stylesheet" href="./assets/styles/css/jquery.toast.css">
<script src="./assets/js/jquery.toast.js"></script>

<link href="./assets/styles/css/select2.min.css" rel="stylesheet" />
<script src="./assets/js/select2.min.js"></script>

<script src="https://js.stripe.com/v3/"></script>

<script type="text/javascript">
   
    $('#clinic_overdue_status_6').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_overdue_status_12').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_overdue_status_18').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_overdue_status_24').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_category_6').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_category_12').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_category_18').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_category_24').multiselect({
            columns: 1,
            placeholder: 'Select Category',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_code_6').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_code_12').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });


    $('#clinic_procedure_code_18').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });

    $('#clinic_procedure_code_24').multiselect({
            columns: 1,
            placeholder: 'Select Code',
            search: true,
            //selectAll: true
    });

    $('#clinic_patient_status').multiselect({
            columns: 1,
            placeholder: 'Select Status',
            search: true,
            //selectAll: true
    });

    
    $("#msgtemplate_id").select2({
        tags: true
     });                    

    $("#tclinic_id").select2({
        tags: true
     });

    $("#msgmarketingtemplate_id").select2({
        tags: true
     });                    

    $("#tmclinic_id").select2({
        tags: true
     });

    $("#clinic_cnfrwitebackstatus").select2({
        tags: true
     });
    
    futureDateDisable();

    $("#manual_reminderclinic_id").on('change',function(){
          var ClinicId = $("#manual_reminderclinic_id").val();
          $(".loader").show();
          $.ajax({
                    url: "clinic_setting.php?act=getremindertemplate&ClinicId="+ClinicId, 
                    type: "POST",
                    //data: ({act:"getremindertemplate",clinic_id: ClinicId}),
                    success: function(data)
                    {  
                      $(".loader").hide();
                      $("#reminder_template_id").html(data);
                    }
               });
    });

    followupfutureDateDisable();

    $("#manual_followupclinic_id").on('change',function(){
          var ClinicId = $("#manual_followupclinic_id").val();
          $(".loader").show();
          $.ajax({
                    url: "clinic_setting.php", 
                    type: "POST",
                    data: ({act:"getfollowuptemplate",clinic_id: ClinicId}),
                    success: function(data)
                    {  
                      $(".loader").hide();
                      $("#followup_template_id").html(data);
                    }
               });
    });

    recallfutureDateDisable();

    $("#manual_recallclinic_id").on('change',function(){
          var ClinicId = $("#manual_recallclinic_id").val();
          $(".loader").show();
          $.ajax({
                    url: "clinic_setting.php",
                    type: "POST",
                    data: ({act:"getrecalltemplate",clinic_id: ClinicId}),
                    success: function(data)
                    {  
                      $(".loader").hide();
                      $("#recall_template_id").html(data);
                    }
               });
    });

    $("#fclinic_id").on('change',function(){
          var fclinicId = $("#fclinic_id").val();
          $(".loader").show();
         var rt = false;
          $.ajax({
                    url: "clinic_setting.php",
                    type: "POST",
                    data: ({act:"getallmsgtemplate",fclinicId: fclinicId}),
                    success: function(msgdata)
                    {  
                      $(".loader").hide();
                      $("#msgtemplate_id").html(msgdata);
                      
                      
                        //console.log("hi");
                         /*$('#msgtemplate_id').multiselect({
                                //columns: 1,
                                //placeholder: 'Select Template',
                                //search: true,
                                //selectAll: true,
                                nonSelectedText:'Select Template',
                        }); */
                      
                      
                    }
               });
    });

    $("#fmclinic_id").on('change',function(){
          var fmclinicId = $("#fmclinic_id").val();
          $(".loader").show();
         var rt = false;
          $.ajax({
                    url: "clinic_setting.php",
                    type: "POST",
                    data: ({act:"getallmsgmarketingtemplate",fmclinicId: fmclinicId}),
                    success: function(msgdata)
                    {  
                      $(".loader").hide();
                      $("#msgmarketingtemplate_id").html(msgdata);
                      
                      
                        //console.log("hi");
                         /*$('#msgtemplate_id').multiselect({
                                //columns: 1,
                                //placeholder: 'Select Template',
                                //search: true,
                                //selectAll: true,
                                nonSelectedText:'Select Template',
                        }); */
                      
                      
                    }
               });
    });

    $("#clinic_procedure_category_6").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_6 = $("#clinic_procedure_category_6").val();
        console.log(clinic_procedure_category_6);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_6+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_6').empty()
                    $("#clinic_procedure_code_6").html(data);  
                    $('#clinic_procedure_code_6').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });

    $("#clinic_procedure_category_12").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_12 = $("#clinic_procedure_category_12").val();
        //console.log(clinic_procedure_category_12);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_12+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_12').empty()
                    $("#clinic_procedure_code_12").html(data);  
                    $('#clinic_procedure_code_12').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });

    $("#clinic_procedure_category_18").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_18 = $("#clinic_procedure_category_18").val();
        //console.log(clinic_procedure_category_18);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_18+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_18').empty()
                    $("#clinic_procedure_code_18").html(data);  
                    $('#clinic_procedure_code_18').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });

    $("#clinic_procedure_category_24").on('change',function(){
        var clinic_id = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_procedure_category_24 = $("#clinic_procedure_category_24").val();
        //console.log(clinic_procedure_category_24);
        
        $.ajax({
                  url: "clinic_overdue.php?act=getprocedurecode&procedure_code="+clinic_procedure_category_24+"&clinic_id="+clinic_id,
                  type: "POST",
                 // dataType: 'json',
                  //cache: false,
                  //data: ({clinic_id: ClinicId}),
                  success: function(data)
                  {  
                    
                    $('#clinic_procedure_code_24').empty()
                    $("#clinic_procedure_code_24").html(data);  
                    $('#clinic_procedure_code_24').multiselect('reload');
                    /*$('#clinic_procedure_code_6').empty();
                    $.each(data, function(index, value) 
                    {
                        $("#clinic_procedure_code_6").append('<option value="' + value.procedure_code_sikkaId + '"'  +
                        '>' + value.procedure_code_sikkaId+ '</option>');
                        $('#clinic_procedure_code_6').multiselect('reload');
                    });*/
                  }
             });
    });
    
    $( "#frm-clinicoverdue" ).on( "submit", function(e) {
        e.preventDefault();
        
        var clinicId = <?php echo $_REQUEST['clinic_id'] ?>;

        var clinic_overdueval_6 = $("#clinic_overdueval_6").val();
        var clinic_overdueval_12 = $("#clinic_overdueval_12").val();
        var clinic_overdueval_18 = $("#clinic_overdueval_18").val();
        var clinic_overdueval_24 = $("#clinic_overdueval_24").val();

        var clinic_initiation_days_6 = $("#clinic_initiation_days_6").val();
        var clinic_initiation_days_12 = $("#clinic_initiation_days_12").val();
        var clinic_initiation_days_18 = $("#clinic_initiation_days_18").val();
        var clinic_initiation_days_24 = $("#clinic_initiation_days_24").val();

        var clinic_overdue_status_6 = $("#clinic_overdue_status_6").val();
        var clinic_overdue_status_12 = $("#clinic_overdue_status_12").val();
        var clinic_overdue_status_18 = $("#clinic_overdue_status_18").val();
        var clinic_overdue_status_24 = $("#clinic_overdue_status_24").val();

        var clinic_procedure_category_6 = $("#clinic_procedure_category_6").val();
        var clinic_procedure_category_12 = $("#clinic_procedure_category_12").val();
        var clinic_procedure_category_18 = $("#clinic_procedure_category_18").val();
        var clinic_procedure_category_24 = $("#clinic_procedure_category_24").val();
        var clinic_procedure_code_6 = $("#clinic_procedure_code_6").val();
        var clinic_procedure_code_12 = $("#clinic_procedure_code_12").val();
        var clinic_procedure_code_18 = $("#clinic_procedure_code_18").val();
        var clinic_procedure_code_24 = $("#clinic_procedure_code_24").val();

        if($("#clinic_initiation_days_6").val()=='')
        {
              $("#clinic_initiation_days_6").addClass('error');
              $("#clinic_initiation_days_6").focus();
              $("#msg_clinic_initiation_days_6").html('Please input initiation days').show();
              return false;
        }else if($("#clinic_overdue_status_6").val()=='')
        {
          if(clinic_initiation_days_6 !='')
          {
              $("#clinic_initiation_days_6").removeClass('error');
              $("#msg_clinic_initiation_days_6").hide();
          }

          $("#clinic_overdue_status_6").addClass('error');
          $("#clinic_overdue_status_6").focus();
          $("#msg_clinic_overdue_status_6").html('Please input select status').show();
          return false;
        }else if($("#clinic_initiation_days_12").val()=='')
        {
          if(clinic_overdue_status_6 !='')
          {
              $("#clinic_overdue_status_6").removeClass('error');
              $("#msg_clinic_overdue_status_6").hide();
          }

          $("#clinic_initiation_days_12").addClass('error');
          $("#clinic_initiation_days_12").focus();
          $("#msg_clinic_initiation_days_12").html('Please input initiation days').show();
          return false;
        }else if($("#clinic_overdue_status_12").val()=='')
        {
          if(clinic_initiation_days_12 !='')
          {
              $("#clinic_initiation_days_12").removeClass('error');
              $("#msg_clinic_initiation_days_12").hide();
          }

          $("#clinic_overdue_status_12").addClass('error');
          $("#clinic_overdue_status_12").focus();
          $("#msg_clinic_overdue_status_12").html('Please select status').show();
          return false;
        }else if($("#clinic_initiation_days_18").val()=='')
        {
          if(clinic_overdue_status_12 !='')
          {
              $("#clinic_overdue_status_12").removeClass('error');
              $("#msg_clinic_overdue_status_12").hide();
          }

          $("#clinic_initiation_days_18").addClass('error');
          $("#clinic_initiation_days_18").focus();
          $("#msg_clinic_initiation_days_18").html('Please input initiation days').show();
          return false;
        }else if($("#clinic_overdue_status_18").val()=='')
        {
          if(clinic_initiation_days_18 !='')
          {
              $("#clinic_initiation_days_18").removeClass('error');
              $("#msg_clinic_initiation_days_18").hide();
          }

          $("#clinic_overdue_status_18").addClass('error');
          $("#clinic_overdue_status_18").focus();
          $("#msg_clinic_overdue_status_18").html('Please select status').show();
          return false;
        }else if($("#clinic_initiation_days_24").val()=='')
        {
          if(clinic_overdue_status_18 !='')
          {
              $("#clinic_overdue_status_18").removeClass('error');
              $("#msg_clinic_overdue_status_18").hide();
          }

          $("#clinic_initiation_days_24").addClass('error');
          $("#clinic_initiation_days_24").focus();
          $("#msg_clinic_initiation_days_24").html('Please input initiation days').show();
          return false;
        }else if($("#clinic_overdue_status_24").val()=='')
        {
          if(clinic_initiation_days_24 !='')
          {
              $("#clinic_initiation_days_24").removeClass('error');
              $("#msg_clinic_initiation_days_24").hide();
          }

          $("#clinic_overdue_status_24").addClass('error');
          $("#clinic_overdue_status_24").focus();
          $("#msg_clinic_overdue_status_24").html('Please select status').show();
          return false;
        }else{
            console.log("else");
            if(clinic_overdue_status_24 !='')
            {
                $("#clinic_overdue_status_24").removeClass('error');
                $("#msg_clinic_overdue_status_24").hide();
            }
            $(".loader-bubble").show();

            $.ajax({      
                  //url: "clinic_overdue.php",
                  url: "clinic_setting.php",
                  data: 
                  { 
                      act:"overdueupdate",
                      clinicId:clinicId,clinic_overdueval_6:clinic_overdueval_6,clinic_overdueval_12:clinic_overdueval_12,clinic_overdueval_18:clinic_overdueval_18,clinic_overdueval_24:clinic_overdueval_24,clinic_initiation_days_6:clinic_initiation_days_6,clinic_initiation_days_12:clinic_initiation_days_12,clinic_initiation_days_18:clinic_initiation_days_18,clinic_initiation_days_24:clinic_initiation_days_24,
                          clinic_overdue_status_6:clinic_overdue_status_6,
                          clinic_overdue_status_12:clinic_overdue_status_12,
                          clinic_overdue_status_18:clinic_overdue_status_18,
                          clinic_overdue_status_24:clinic_overdue_status_24,
                          clinic_procedure_category_6:clinic_procedure_category_6,clinic_procedure_category_12:clinic_procedure_category_12,clinic_procedure_category_18:clinic_procedure_category_18,
                          clinic_procedure_category_24:clinic_procedure_category_24,
                          clinic_procedure_code_6:clinic_procedure_code_6,
                          clinic_procedure_code_12:clinic_procedure_code_12,
                          clinic_procedure_code_18:clinic_procedure_code_18,
                          clinic_procedure_code_24:clinic_procedure_code_24,
                  },
                  method: 'POST',
                  success: function(data){
                      $(".loader-bubble").hide();
                      /*$("#alert_msg").hide();
                      $("#alert_msg").html(data);*/

                      $.toast({
                                //heading: 'Positioning',
                                heading: '</em>',
                                text: 'Ovedue setting updated successfully...',
                                position: 'top-right',
                                stack: false,
                                showHideTransition: 'slide',
                                icon: 'success'
                        });
                      /*$("#status_msg").show();
                      $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                      hideMessage();*/
                      
                  }
            });

        }
        console.log(clinicId);
        return false;
    });

    $( "#frm-clinicpatientstatus" ).on( "submit", function(e) {
        e.preventDefault();

        var clinicId = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_patient_status = $("#clinic_patient_status").val();
        if($("#clinic_patient_status").val()=='')
        {
              $("#clinic_patient_status").addClass('error');
              $("#clinic_patient_status").focus();
              $("#msg_clinic_patient_status").html('Please select status').show();
              return false;
        }else{
            if(clinic_patient_status !='')
            {
                $("#clinic_patient_status").removeClass('error');
                $("#msg_clinic_patient_status").hide();
            }
            $(".loader-bubble").show();

            $.ajax({      
                  //url: "clinic_overdue.php",
                  url: "clinic_setting.php",
                  data: 
                  { 
                      act:"patient_status",
                      clinicId:clinicId,clinic_patient_status:clinic_patient_status,
                  },
                  method: 'POST',
                  success: function(data){
                      $(".loader-bubble").hide();
                      /*$("#alert_msg").hide();
                      $("#alert_msg").html(data);*/

                      /*$("#status_msg").show();
                      $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                      hideMessage();*/

                      $.toast({
                                //heading: 'Positioning',
                                heading: '</em>',
                                text: 'New Patient Status updated successfully...',
                                position: 'top-right',
                                stack: false,
                                showHideTransition: 'slide',
                                icon: 'success'
                            });
                      
                  }
            });
        }
    });


    $( "#communicationproviderFrm" ).on( "submit", function(e) {
            //console.log("provider");return false;
            e.preventDefault();

            var communicationprovider = $("#communicationprovider").val();
            var clinic_id = <?php echo $_REQUEST['clinic_id']; ?>;
            //console.log(communicationprovider+" "+clinic_id);
            /*return false;*/
            $.ajax({
                      url: "clinic_setting.php",
                      data: { act:"communicationprovider",
                            communicationprovider:communicationprovider,clinic_id:clinic_id},
                      method: 'POST',
                      success: function(msg){
                          if(msg!=''){
                              window.location='clinic_setting.php';
                              //return false;
                          }
                      }
                  });

    });


    $( "#frm-gotosetting" ).on( "submit", function(e) {
      e.preventDefault();
      
      var btn= $(this).find("input[type=submit]:focus").val();
      if(btn == 'Get Code')
      {
            var goto_clientId = $("#goto_clientId").val();
            var goto_client_secret = $("#goto_client_secret").val();

            if($("#goto_clientId").val()=='')
            {
                  $("#goto_clientId").addClass('error');
                  $("#goto_clientId").focus();
                  $("#msg_goto_clientId").html('Please input clientId').show();
                  return false;
            } 
            else if($("#goto_client_secret").val()=='')
            {
              if(goto_clientId !='')
              {
                  $("#goto_clientId").removeClass('error');
                  $("#msg_goto_clientId").hide();
              }

              $("#goto_client_secret").addClass('error');
              $("#goto_client_secret").focus();
              $("#msg_goto_client_secret").html('Please input client secret').show();
              return false;
            }
            else
            {
                if(goto_client_secret !='')
                {
                    $("#goto_client_secret").removeClass('error');
                    $("#msg_goto_client_secret").hide();
                }

                $(".loader-bubble").show();
                $.ajax({      
                        url: "clinic_setting.php",
                        data: 
                        { 
                            act:"getcode",
                            goto_clientId:goto_clientId,goto_client_secret:goto_client_secret,clinic_id:<?php echo $_REQUEST['clinic_id']; ?>,
                        },
                        method: 'POST',
                        success: function(data){
                            $(".loader-bubble").hide();
                            $("#alert_msg").hide();
                            $("#alert_msg").html(data);
                        }
                    });
            } 
      }

      if(btn == 'Get Token')
      {
         var goto_clientId = $("#goto_clientId").val();
         var goto_client_secret = $("#goto_client_secret").val();
         var goto_code = $("#goto_code").val();

           if($("#goto_clientId").val()=='')
           {
              $("#goto_clientId").addClass('error');
              $("#goto_clientId").focus();
              $("#msg_goto_clientId").html('Please input clientId').show();
              return false;
           } 
           else if($("#goto_client_secret").val()=='')
           {
              if(goto_clientId !='')
              {
                  $("#goto_clientId").removeClass('error');
                  $("#msg_goto_clientId").hide();
              }

              $("#goto_client_secret").addClass('error');
              $("#goto_client_secret").focus();
              $("#msg_goto_client_secret").html('Please input client secret').show();
              return false;
           }else if($("#goto_code").val()=='')
           {
              if(goto_client_secret !='')
              {
                  $("#goto_client_secret").removeClass('error');
                  $("#msg_goto_client_secret").hide();
              }

              $("#goto_goto_code").addClass('error');
              $("#goto_goto_code").focus();
              $("#msg_goto_code").html('Please input code').show();
              return false;
           }else
           {
                if(goto_code !='')
                {
                    $("#goto_goto_code").removeClass('error');
                    $("#msg_goto_code").hide();
                }

                $(".loader-bubble").show();
                $.ajax({      
                        url: "clinic_setting.php",
                        data: 
                        { 
                            act:"addcodetoken",
                            goto_clientId:goto_clientId,goto_client_secret:goto_client_secret,clinic_id:<?php echo $_REQUEST['clinic_id']; ?>,goto_code:goto_code,
                        },
                        method: 'POST',
                        success: function(msg){

                            if(msg=='success'){
                                $(".loader-bubble").hide();
                                /*$("#status_msg").show();
                                $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                                hideMessage();*/
                                $.toast({
                                    //heading: 'Positioning',
                                    heading: '</em>',
                                    text: 'GoToSetting updated successfully...',
                                    position: 'top-right',
                                    stack: false,
                                    showHideTransition: 'slide',
                                    icon: 'success'
                                });
                                $("#goto_code").val('');
                                $("#goto_clientId").val('');
                                $("#goto_client_secret").val('');
                               //window.location='gotosetting.php';
                            }else{
                                $(".loader-bubble").hide();
                                //$("#err_msg").html(msg);
                                /*$("#alert_msg").show();
                                $("#alert_msg").html("<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>"+msg+"</div>");
                                hideMessage();*/

                                $.toast({
                                    //heading: 'Positioning',
                                    heading: '</em>',
                                    text: msg,
                                    position: 'top-right',
                                    stack: false,
                                    showHideTransition: 'slide',
                                    icon: 'error'
                                });

                            }
                        }
                    });
           }
      }

    });

$( "#frm-ghlsetting" ).on( "submit", function(e) {
    e.preventDefault();
    var btn= $(this).find("input[type=submit]:focus").val();
    if(btn == 'Get Code'){
        var ghl_clientId = $("#ghl_clientId").val();
        var ghl_client_secret = $("#ghl_client_secret").val();

        if($("#ghl_clientId").val()==''){
            $("#ghl_clientId").addClass('error');
            $("#ghl_clientId").focus();
            $("#msg_ghl_clientId").html('Please input clientId').show();
            return false;
        }else if($("#ghl_client_secret").val()==''){
            if(ghl_clientId !=''){
                $("#ghl_clientId").removeClass('error');
                $("#msg_ghl_clientId").hide();
            }

            $("#ghl_client_secret").addClass('error');
            $("#ghl_client_secret").focus();
            $("#msg_ghl_client_secret").html('Please input client secret').show();
            return false;
        }else{
            if(ghl_client_secret !=''){
                $("#ghl_client_secret").removeClass('error');
                $("#msg_ghl_client_secret").hide();
            }

            $(".loader-bubble").show();
            $.ajax({      
                url: "clinic_setting.php",
                data: { 
                    act:"getcode",
                    ghl_clientId:ghl_clientId,ghl_client_secret:ghl_client_secret,clinic_id:<?php echo $_REQUEST['clinic_id']; ?>,
                },
                method: 'POST',
                success: function(data){
                    $(".loader-bubble").hide();
                    $("#alert_msg").hide();
                    $("#alert_msg").html(data);
                }
            });
        } 
    }

    if(btn == 'Get Token'){
        var ghl_clientId = $("#ghl_clientId").val();
        var ghl_client_secret = $("#ghl_client_secret").val();
        var ghl_code = $("#ghl_code").val();
        if($("#ghl_clientId").val()==''){
            $("#ghl_clientId").addClass('error');
            $("#ghl_clientId").focus();
            $("#msg_ghl_clientId").html('Please input clientId').show();
            return false;
        }else if($("#ghl_client_secret").val()==''){
            if(ghl_clientId !=''){
                $("#ghl_clientId").removeClass('error');
                $("#msg_ghl_clientId").hide();
            }
            $("#ghl_client_secret").addClass('error');
            $("#ghl_client_secret").focus();
            $("#msg_ghl_client_secret").html('Please input client secret').show();
            return false;
        }else if($("#ghl_code").val()==''){
            if(ghl_client_secret !=''){
                $("#ghl_client_secret").removeClass('error');
                $("#msg_ghl_client_secret").hide();
            }

            $("#ghl_code").addClass('error');
            $("#ghl_code").focus();
            $("#msg_ghl_code").html('Please input code').show();
            return false;
        }else{
            if(ghl_code !=''){
                $("#ghl_code").removeClass('error');
                $("#msg_ghl_code").hide();
            }

            $(".loader-bubble").show();
            $.ajax({      
                url: "clinic_setting.php",
                data: { 
                    act:"GHLaddcodetoken",
                    ghl_clientId:ghl_clientId,ghl_client_secret:ghl_client_secret,clinic_id:<?php echo $_REQUEST['clinic_id']; ?>,ghl_code:ghl_code,
                },
                method: 'POST',
                success: function(msg){

                    if(msg=='success'){
                        $(".loader-bubble").hide();
                        /*$("#status_msg").show();
                        $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button> Updated successfully...</div>");
                        hideMessage();*/
                        $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: 'GHL Setting updated successfully...',
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                        $("#ghl_code").val('');
                        //window.location='gotosetting.php';
                    }else{
                        $(".loader-bubble").hide();
                        //$("#err_msg").html(msg);
                        /*$("#alert_msg").show();
                        $("#alert_msg").html("<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>"+msg+"</div>");
                        hideMessage();*/

                        $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: msg,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'error'
                        });

                    }
                }
            });
        }
    }

});
    $( "#frm-gotosubs" ).on( "submit", function(e) {
        e.preventDefault();
        
        $(".loader-bubble").show();
        var btn= $(this).find("input[type=submit]:focus").val();
        if(btn == 'Get GoTo Webhook Subscription')
        {
            var goto_accesstoken = $("#gotoaccess_token").val();
            var goto_owner_phone = $("#gotoCell").val();

            $.ajax({      
                    url: "clinic_setting.php",
                    data: 
                    { 
                        act:"gotosubs",
                        goto_accesstoken:goto_accesstoken,goto_owner_phone:goto_owner_phone,clinic_id:<?php echo $_REQUEST['clinic_id']; ?>,
                    },
                    method: 'POST',
                    success: function(data){
                        $(".loader-bubble").hide();
                        $("#alert_msg").hide();
                        $("#alert_msg").html(data);
                        $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                    }
            });
        }

    });

    $( "#frm-manualreminder" ).on( "submit", function(e) {
          
          e.preventDefault();
          var btn= $(this).find("input[type=submit]:focus").val();
          var clinic_id            = $("#manual_reminderclinic_id").val();
          
          if(btn == 'Clear Table'){
              
            $.ajax({
                url: "clinic_setting.php",
                type:'POST',
                data: ({act:"clrtable",clinic_id: clinic_id}),
                success: function(data){
                    $.toast({
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  
                }
            });

          }else{
          
          var reminder_template_id = $("#reminder_template_id").val();
          var manual_remider_date  = $("#manual_remider_date").val();
        
          if(reminder_template_id == ''){
              $("#reminder_template_id").addClass('error');
              $("#reminder_template_id").focus();
              $("#msg_reminder_template_id").html('Please select template').show();
            return false;
          }
          else if(manual_remider_date == ''){

              if(reminder_template_id != '')
              {
                  $("#reminder_template_id").removeClass('error');
                  $("#msg_reminder_template_id").hide();
              }

              $("#manual_remider_date").addClass('error');
              $("#manual_remider_date").focus();
              $("#msg_manual_remider_date").html('Please input date').show();
            return false;
          }else{

            if(manual_remider_date != '')
            {
                $("#manual_remider_date").removeClass('error');
                $("#msg_manual_remider_date").hide();
            }

            $(".loader").show();
              
             $.ajax({
                url: "clinic_setting.php",
                type:'POST',
                data: ({act:"chkreminder",clinic_id: clinic_id,reminder_template_id:reminder_template_id,manual_remider_date:manual_remider_date}),
                success: function(data){
                  if(data == 'already'){
                      alredyreminderpopup(clinic_id,reminder_template_id,manual_remider_date);
                  }else if(data == 'firsttime'){
                      reminderdata(clinic_id,reminder_template_id,manual_remider_date);
                  }
                }
             });
          }
        }
    });

    function futureDateDisable()
    {
          var today = new Date().toISOString().split('T')[0];
          document.getElementsByName("manual_remider_date")[0].setAttribute('max', today);
    }

    function alredyreminderpopup(clinic_id,reminder_template_id,manual_remider_date)
    {

      swal({
            title: 'Are you sure ?',
            text: "Manual reminder notifications for this date are already sent would you still like to continue sending reminder notifications?",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#0CC27E',
            cancelButtonColor: '#FF586B',
            confirmButtonText: 'Yes, Send!',
            cancelButtonText: 'No, Cancel!',
            confirmButtonClass: 'btn btn-success mr-5',
            cancelButtonClass: 'btn btn-danger',
            buttonsStyling: false
        }).then(function () {
            $.ajax({
              url: "clinic_setting.php",
              type:'POST',
              data: ({act:"savemanualreminder",clinic_id: clinic_id,reminder_template_id:reminder_template_id,manual_remider_date:manual_remider_date}),
              success: function(data)
              {    

                  /*$("#status_msg").show();
                  $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>"+data+"</div>");
                  $("#status_msg_td").html(data.msg);
                  hideMessage();*/

                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  $("#frm-manualreminder")[0].reset();
                  $("#manual_reminderclinic_id").val("").trigger("change.select2");

                  //window.location='manual_reminder_send.php';
              }
            });
        }, function (dismiss) {
          return false; 
        });
    }

    function reminderdata(clinic_id,reminder_template_id,manual_remider_date)
    {
      $.ajax({
              url: "clinic_setting.php",
              type:'POST',
              data: ({act:"savemanualreminder",clinic_id: clinic_id,reminder_template_id:reminder_template_id,manual_remider_date:manual_remider_date}),
              success: function(data)
              {    

                  /*$("#status_msg").show();
                  $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>"+data+"</div>");
                  $("#status_msg_td").html(data.msg);
                  hideMessage();*/

                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  /*$("#clinic_id").val("");
                  $("#reminder_template_id").val("");
                  $("#manual_remider_date").val("");*/
                  $("#frm-manualreminder")[0].reset();
                  $("#manual_reminderclinic_id").val("").trigger("change.select2");
                  //window.location='manual_reminder_send.php';
              }
            });
    }

    $( "#frm-manualfollowup" ).on( "submit", function(e) {
          
          e.preventDefault();

          var clinic_id = $("#manual_followupclinic_id").val();
          var followup_template_id = $("#followup_template_id").val();
          var manual_followup_date = $("#manual_followup_date").val();
        
          if(followup_template_id == ''){
              $("#followup_template_id").addClass('error');
              $("#followup_template_id").focus();
              $("#msg_followup_template_id").html('Please select template').show();
            return false;
          }
          else if(manual_followup_date == ''){

              if(followup_template_id != '')
              {
                  $("#followup_template_id").removeClass('error');
                  $("#msg_followup_template_id").hide();
              }

              $("#manual_followup_date").addClass('error');
              $("#manual_followup_date").focus();
              $("#msg_manual_followup_date").html('Please input date').show();
            return false;
          }else{

            if(manual_followup_date != '')
            {
                $("#manual_followup_date").removeClass('error');
                $("#msg_manual_followup_date").hide();
            }

            $(".loader").show();
              
             $.ajax({
                url: "clinic_setting.php",
                type:'POST',
                data: ({act:"chkfollowup",clinic_id: clinic_id,followup_template_id:followup_template_id,manual_followup_date:manual_followup_date}),
                success: function(data){
                  if(data == 'already'){
                      alredyfollowuppopup(clinic_id,followup_template_id,manual_followup_date);
                  }else if(data == 'firsttime'){
                      followupdata(clinic_id,followup_template_id,manual_followup_date);
                  }
                }
             });
          }
    });


    function followupfutureDateDisable()
    {
          var today = new Date().toISOString().split('T')[0];
          document.getElementsByName("manual_followup_date")[0].setAttribute('max', today);
    }

    function alredyfollowuppopup(clinic_id,followup_template_id,manual_followup_date)
    {

      swal({
            title: 'Are you sure ?',
            text: "Manual follow up notifications for this date are already sent would you still like to continue sending follow up notifications?",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#0CC27E',
            cancelButtonColor: '#FF586B',
            confirmButtonText: 'Yes, Send!',
            cancelButtonText: 'No, Cancel!',
            confirmButtonClass: 'btn btn-success mr-5',
            cancelButtonClass: 'btn btn-danger',
            buttonsStyling: false
        }).then(function () {
            $.ajax({
              url: "clinic_setting.php",
              type:'POST',
              data: ({act:"savemanualfollowup",clinic_id: clinic_id,followup_template_id:followup_template_id,manual_followup_date:manual_followup_date}),
              success: function(data)
              {    

                  /*$("#status_msg").show();
                  $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>"+data+"</div>");
                  $("#status_msg_td").html(data.msg);
                  hideMessage();*/

                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  $("#frm-manualfollowup")[0].reset();
                  $("#manual_followupclinic_id").val("").trigger("change.select2");
              }
            });
        }, function (dismiss) {
          return false; 
        });
    }

    function followupdata(clinic_id,followup_template_id,manual_followup_date)
    {
      $.ajax({
              url: "clinic_setting.php",
              type:'POST',
              data: ({act:"savemanualfollowup",clinic_id: clinic_id,followup_template_id:followup_template_id,manual_followup_date:manual_followup_date}),
              success: function(data)
              {    

                  /*$("#status_msg").show();
                  $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>"+data+"</div>");
                  $("#status_msg_td").html(data.msg);
                  hideMessage();*/

                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  /*$("#clinic_id").val("");
                  $("#followup_template_id").val("");
                  $("#manual_remider_date").val("");*/
                  $("#frm-manualfollowup")[0].reset();
                  $("#manual_followupclinic_id").val("").trigger("change.select2");
              }
            });
    }


    $( "#frm-manualrecall" ).on( "submit", function(e) {
          
          e.preventDefault();

          var clinic_id = $("#manual_recallclinic_id").val();
          var recall_template_id = $("#recall_template_id").val();
          var manual_recall_date = $("#manual_recall_date").val();
        
          if(recall_template_id == ''){
              $("#recall_template_id").addClass('error');
              $("#recall_template_id").focus();
              $("#msg_recall_template_id").html('Please select template').show();
            return false;
          }
          else if(manual_recall_date == ''){

              if(recall_template_id != '')
              {
                  $("#recall_template_id").removeClass('error');
                  $("#msg_recall_template_id").hide();
              }

              $("#manual_recall_date").addClass('error');
              $("#manual_recall_date").focus();
              $("#msg_manual_recall_date").html('Please input date').show();
            return false;
          }else{

            if(manual_recall_date != '')
            {
                $("#manual_recall_date").removeClass('error');
                $("#msg_manual_recall_date").hide();
            }

            $(".loader").show();
              
             $.ajax({
                url: "clinic_setting.php",
                type:'POST',
                data: ({act:"chkrecall",clinic_id: clinic_id,recall_template_id:recall_template_id,manual_recall_date:manual_recall_date}),
                success: function(data){
                  if(data == 'already'){
                      alredyrecallpopup(clinic_id,recall_template_id,manual_recall_date);
                  }else if(data == 'firsttime'){
                      recalldata(clinic_id,recall_template_id,manual_recall_date);
                  }
                }
             });
          }
    });

    $( "#frm-patientcontact" ).on( "submit", function(e) {
          
          e.preventDefault();

          var patient_contact_start_date = $("#patient_contact_start_date").val();
          var patient_contact_end_date = $("#patient_contact_end_date").val();
          var clinic_id = $("#clinic_id").val();
        
          if(patient_contact_start_date == '' || patient_contact_end_date == ''){
              $("#msg_patient_contact_start_date").html('Please input start date').show();
              $("#msg_patient_contact_end_date").html('Please input end date').show();
            return false;
          }else{

            if(patient_contact_start_date != '' && patient_contact_end_date != '')
            {
                $("#patient_contact_start_date").removeClass('error');
                $("#patient_contact_end_date").removeClass('error');
                $("#msg_patient_contact_start_date").hide();
                $("#msg_patient_contact_end_date").hide();
            }

            $(".loader").show();
              
            $.ajax({
                url: "clinic_setting.php",
                dataType: 'json',
                data: ({act:"downloadpatient",clinic_id: clinic_id,patient_contact_start_date:patient_contact_start_date,patient_contact_end_date:patient_contact_end_date}),
                success: function(data){
                      download(data);
                      
                }
            });
          }
    });

function convertToCSV(objArray) {
    var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
    var str = '';

    for (var i = 0; i < array.length; i++) {
        var line = '';
        for (var index in array[i]) {
            if (line != '') line += ','

            line += array[i][index];
        }

        str += line + '\r\n';
    }

    return str;
}

function exportCSVFile(headers, items, fileTitle) {
    if (headers) {
        items.unshift(headers);
    }

    // Convert Object to JSON
    var jsonObject = JSON.stringify(items);
    
    var csv = this.convertToCSV(jsonObject);

    var exportedFilenmae = fileTitle + '.csv' || 'export.csv';

    var blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
    if (navigator.msSaveBlob) { // IE 10+
        navigator.msSaveBlob(blob, exportedFilenmae);
    } else {
        var link = document.createElement("a");
        if (link.download !== undefined) { // feature detection
            // Browsers that support HTML5 download attribute
            var url = URL.createObjectURL(blob);
            link.setAttribute("href", url);
            link.setAttribute("download", exportedFilenmae);
            link.style.visibility = 'hidden';
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        }
    }
}

function download(itemsNotFormatted){
 
  var headers = {
      firstname: "FirstName", 
      lastname: "LastName",
      companyname: "CompanyName",
      phonenumber: "PhoneNumber",
      emailaddress : "EmailAddress"
  };


  var itemsFormatted = [];

  // format the data
  itemsNotFormatted.forEach((item) => {
      itemsFormatted.push({
          firstname: item.firstname, // remove commas to avoid errors,
          lastname: item.lastname,
          companyname: item.companyname,
          phonenumber: item.phonenumber,
          emailaddress: item.emailaddress
      });
  });

  var fileTitle = 'patients'; // or 'my-unique-title'

  exportCSVFile(headers, itemsFormatted, fileTitle); // call the exportCSVFile() function to process the JSON and trigger the download
}
    function recallfutureDateDisable()
    {
          var today = new Date().toISOString().split('T')[0];
          document.getElementsByName("manual_recall_date")[0].setAttribute('max', today);
    }

    function alredyrecallpopup(clinic_id,recall_template_id,manual_recall_date)
    {

      swal({
            title: 'Are you sure ?',
            text: "Manual recall notifications for this date are already sent would you still like to continue sending recall notifications?",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#0CC27E',
            cancelButtonColor: '#FF586B',
            confirmButtonText: 'Yes, Send!',
            cancelButtonText: 'No, Cancel!',
            confirmButtonClass: 'btn btn-success mr-5',
            cancelButtonClass: 'btn btn-danger',
            buttonsStyling: false
        }).then(function () {
            $.ajax({
              url: "clinic_setting.php",
              type:'POST',
              data: ({act:"savemanualrecall",clinic_id: clinic_id,recall_template_id:recall_template_id,manual_recall_date:manual_recall_date}),
              success: function(data)
              {    

                  /*$("#status_msg").show();
                  $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>"+data+"</div>");
                  $("#status_msg_td").html(data.msg);
                  hideMessage();*/

                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  $("#frm-manualrecall")[0].reset();
                  $("#manual_recallclinic_id").val("").trigger("change.select2");
              }
            });
        }, function (dismiss) {
          return false; 
        });
    }

    function recalldata(clinic_id,recall_template_id,manual_recall_date)
    {
      $.ajax({
              url: "clinic_setting.php",
              type:'POST',
              data: ({act:"savemanualrecall",clinic_id: clinic_id,recall_template_id:recall_template_id,manual_recall_date:manual_recall_date}),
              success: function(data)
              {    

                  /*$("#status_msg").show();
                  $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>"+data+"</div>");
                  $("#status_msg_td").html(data.msg);
                  hideMessage();*/

                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  /*$("#clinic_id").val("");
                  $("#followup_template_id").val("");
                  $("#manual_remider_date").val("");*/
                  $("#frm-manualrecall")[0].reset();
                  $("#manual_recallclinic_id").val("").trigger("change.select2");
              }
            });
    }

    $( "#frm-getmsgtemplate" ).on( "submit", function(e) {
          
          e.preventDefault();

          var fclinic_id = $("#fclinic_id").val();
          var msgtemplate_id = $("#msgtemplate_id").val();
          var tclinic_id = $("#tclinic_id").val();
          

          if(msgtemplate_id == ''){
              $("#msgtemplate_id").addClass('error');
              $("#msgtemplate_id").focus();
              $("#msg_msgtemplate_id").html('Please select template').show();
            return false;
          }
          else if(tclinic_id == ''){

              if(msgtemplate_id != '')
              {
                  $("#msgtemplate_id").removeClass('error');
                  $("#msg_msgtemplate_id").hide();
              }

              $("#tclinic_id").addClass('error');
              $("#tclinic_id").focus();
              $("#msg_tclinic_id").html('Please select to clinic').show();
            return false;
          }else{

            if(tclinic_id != '')
            {
                $("#tclinic_id").removeClass('error');
                $("#msg_tclinic_id").hide();
            }

            $(".loader").show();
              
             $.ajax({
                url: "clinic_setting.php",
                type:'POST',
                data: ({act:"saveallmsgtemplate",fclinic_id: fclinic_id,msgtemplate_id:msgtemplate_id,tclinic_id:tclinic_id}),
                success: function(data){
                   
                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  
                  $("#msgtemplate_id").val('');
                  $("#frm-getmsgtemplate")[0].reset();
                  $("#tclinic_id").val("").trigger("change.select2");
                  setTimeout(function(){
                      location.reload();
                    }, 3000); 
                  //window.location='clinic_setting.php?clinic_id='+fclinic_id; 
                }
             });
          }
    });

    $( "#frm-cliniccnfwritebackstatus" ).on( "submit", function(e) {
        e.preventDefault();

        var clinicId = <?php echo $_REQUEST['clinic_id'] ?>;
        var clinic_cnfrwitebackstatus = $("#clinic_cnfrwitebackstatus").val();
        if($("#clinic_cnfrwitebackstatus").val()=='')
        {
              $("#clinic_cnfrwitebackstatus").addClass('error');
              $("#clinic_cnfrwitebackstatus").focus();
              $("#msg_clinic_cnfrwitebackstatus").html('Please select status').show();
              return false;
        }else{
            if(clinic_cnfrwitebackstatus !='')
            {
                $("#clinic_cnfrwitebackstatus").removeClass('error');
                $("#msg_clinic_cnfrwitebackstatus").hide();
            }
            $(".loader-bubble").show();

            $.ajax({      
                  //url: "clinic_overdue.php",
                  url: "clinic_setting.php",
                  data: 
                  { 
                      act:"cnfrwitebackstatus",
                      clinicId:clinicId,clinic_cnfrwitebackstatus:clinic_cnfrwitebackstatus,
                  },
                  method: 'POST',
                  success: function(data){
                      $(".loader-bubble").hide();
                    
                      $.toast({
                                //heading: 'Positioning',
                                heading: '</em>',
                                text: 'Confirmed writeback status updated successfully...',
                                position: 'top-right',
                                stack: false,
                                showHideTransition: 'slide',
                                icon: 'success'
                            });
                      //$("#clinic_cnfrwitebackstatus").val("").trigger("change.select2");
                  }
            });
        }
    });

    $( "#frm-getmsgtemplatemarketing" ).on( "submit", function(e) {
          
          e.preventDefault();

          var fmclinic_id = $("#fmclinic_id").val();
          var msgmarketingtemplate_id = $("#msgmarketingtemplate_id").val();
          var tmclinic_id = $("#tmclinic_id").val();
          

          if(msgmarketingtemplate_id == ''){
              $("#msg_msgmarketingtemplate_id").addClass('error');
              $("#msg_msgmarketingtemplate_id").focus();
              $("#msg_msgmarketingtemplate_id").html('Please select template').show();
            return false;
          }
          else if(tmclinic_id == ''){

              if(msgmarketingtemplate_id != '')
              {
                  $("#msg_msgmarketingtemplate_id").removeClass('error');
                  $("#msg_msgmarketingtemplate_id").hide();
              }

              $("#tmclinic_id").addClass('error');
              $("#tmclinic_id").focus();
              $("#msg_tmclinic_id").html('Please select to clinic').show();
            return false;
          }else{

            if(tmclinic_id != '')
            {
                $("#tmclinic_id").removeClass('error');
                $("#msg_tmclinic_id").hide();
            }

            $(".loader").show();
              
             $.ajax({
                url: "clinic_setting.php",
                type:'POST',
                data: ({act:"saveallmsgmarketingtemplate",fmclinic_id: fmclinic_id,msgmarketingtemplate_id:msgmarketingtemplate_id,tmclinic_id:tmclinic_id}),
                success: function(data){
                   
                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  
                  $("#msgmarketingtemplate_id").val('');
                  $("#frm-getmsgtemplatemarketing")[0].reset();
                  $("#tmclinic_id").val("").trigger("change.select2");
                  setTimeout(function(){
                      location.reload();
                    }, 3000); 
                  //window.location='clinic_setting.php?clinic_id='+fclinic_id; 
                }
             });
          }
    });

    /*$( "#frm-deleteclinic" ).on( "submit", function(e) {
          
          e.preventDefault();
          swal({
            title: 'Are you sure ?',
            text: " Are you sure you want to delete?",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#0CC27E',
            cancelButtonColor: '#FF586B',
            confirmButtonText: 'Yes, Delete!',
            cancelButtonText: 'No, Cancel!',
            confirmButtonClass: 'btn btn-success mr-5',
            cancelButtonClass: 'btn btn-danger',
            buttonsStyling: false
        }).then(function () {
            $.ajax({
              url: "clinic_setting.php",
              type:'POST',
              data: ({act:"savemanualrecall",clinic_id: clinic_id,recall_template_id:recall_template_id,manual_recall_date:manual_recall_date}),
              success: function(data)
              {    

                  $("#status_msg").show();
                  $("#status_msg").html("<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>"+data+"</div>");
                  $("#status_msg_td").html(data.msg);
                  hideMessage();

                  $.toast({
                            //heading: 'Positioning',
                            heading: '</em>',
                            text: data,
                            position: 'top-right',
                            stack: false,
                            showHideTransition: 'slide',
                            icon: 'success'
                        });
                  $("#frm-manualrecall")[0].reset();
                  $("#manual_recallclinic_id").val("").trigger("change.select2");
              }
            });
        }, function (dismiss) {
          return false; 
        });
    });*/

    $( "#frm-apptchatpin" ).on( "submit", function(e) {
            e.preventDefault();

            var apptchatpin = $("#apptchatpin").val();
            var clinic_id = <?php echo $_REQUEST['clinic_id']; ?>;
            //console.log(apptchatpin+" "+clinic_id);
            /*return false;*/
            $.ajax({
                      url: "clinic_setting.php",
                      data: { act:"apptchatpin",
                            apptchatpin:apptchatpin,clinic_id:clinic_id},
                      method: 'POST',
                      success: function(msg){

                        $(".loader-bubble").hide();
                    
                          $.toast({
                                    //heading: 'Positioning',
                                    heading: '</em>',
                                    text: 'Appointment Chat Pin status updated successfully...',
                                    position: 'top-right',
                                    stack: false,
                                    showHideTransition: 'slide',
                                    icon: 'success'
                                });
                          /*if(msg!=''){
                              window.location='clinic_setting.php';
                              //return false;
                          }*/
                      }
                  });

    });


    $( "#frm-subscreditcard" ).on( "submit", function(e) {
        
            e.preventDefault();

            var stripecardnum = $("#stripecardnum").val();
            var stripecardname = $("#stripecardname").val();
            var stripecardexpire = $("#stripecardexpire").val();
            var stripecardcvv = $("#stripecardcvv").val();
            var clinicuseruniqueid = $("#clinic_user_unique_id").val();

            var clinic_id = <?php echo $_REQUEST['clinic_id']; ?>;
            $.ajax({
                      url: "clinic_setting.php",
                      data: { act:"subscreditcard",
                            clinic_id:clinic_id,stripecardnum:stripecardnum,stripecardname:stripecardname,stripecardexpire:stripecardexpire,stripecardcvv:stripecardcvv,clinicuseruniqueid:clinicuseruniqueid},
                      method: 'POST',
                      success: function(msg){

                        $(".loader-bubble").hide();
                    
                          $.toast({
                                    //heading: 'Positioning',
                                    heading: '</em>',
                                    text: 'Card added successfully..',
                                    position: 'top-right',
                                    stack: false,
                                    showHideTransition: 'slide',
                                    icon: 'success'
                                });
                          /*if(msg!=''){
                              window.location='clinic_setting.php';
                              //return false;
                          }*/
                      }
                  });

    });


    $( "#frm-updatedisplayrating" ).on( "submit", function(e) {
            e.preventDefault();

            var updatedisplayrating = $("#updatedisplayrating").val();
            var clinic_id = <?php echo $_REQUEST['clinic_id']; ?>;
            //console.log(apptchatpin+" "+clinic_id);
            /*return false;*/
            $.ajax({
                      url: "clinic_setting.php",
                      data: { act:"updatedisplayrating",
                            updatedisplayrating:updatedisplayrating,clinic_id:clinic_id},
                      method: 'POST',
                      success: function(msg){

                        $(".loader-bubble").hide();
                    
                          $.toast({
                                    //heading: 'Positioning',
                                    heading: '</em>',
                                    text: 'Rating updated successfully...',
                                    position: 'top-right',
                                    stack: false,
                                    showHideTransition: 'slide',
                                    icon: 'success'
                                });
                          /*if(msg!=''){
                              window.location='clinic_setting.php';
                              //return false;
                          }*/
                      }
                  });

    });


    $("#div-nocreditcard").hide();
    $("#carddetails").hide();
    $("#subscreditcard").on('change',function(){
          var selectionoption = $("#subscreditcard").val();
          
          if(selectionoption == 'no'){
            $("#div-nocreditcard").show();
            $("#carddetails").show();
          }else{
            $("#div-nocreditcard").hide();
            $("#carddetails").hide();
          }
          $(".loader").show();
    });
</script>