Server : LiteSpeed
System : Linux premium92.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : rbnsfqys ( 805)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /home/rbnsfqys/ali.rbn.services/wp-content/plugins/Repairplugin-pro/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : /home/rbnsfqys/ali.rbn.services/wp-content/plugins/Repairplugin-pro/appointment_checklist.php
<?php

// Exit if accessed directly

defined( 'ABSPATH' ) || exit;


function rp_get_all_checklist_translated_items( $selected = 'default' ) {

    global $rpQuery;

    $table_rs_appointment_checklist = $rpQuery->prefix . "rs_appointment_checklist";

    $checklist_items = $rpQuery->get_results("SELECT * FROM $table_rs_appointment_checklist ORDER BY `position` ASC, `id` ASC");

    $items = array();

    foreach ($checklist_items as $item) {

        if( $selected == 'selected' ) {

            $item->title = rp_get_static_translations_of_checklist_selected('li_name', $item->id, 'selected');

        } else {

            $item->title = rp_get_static_translations_of_checklist('li_name', $item->id);

        }

        $items[] = array('r_id' => $item->id, 'checklist_item' => $item->title);

    }

    return $items;

}

function rp_need_to_show_checkilist() {

    if(rp_get_option('rp_enable_pre_appointment_checklist', '0') == '1') {

        global $rpQuery;

        $table_rs_appointment_checklist = $rpQuery->prefix . "rs_appointment_checklist";

        $checklist_items = $rpQuery->get_results("SELECT * FROM $table_rs_appointment_checklist");

        if( !empty( $checklist_items ) ) {

            return TRUE;

        }

        return FALSE;

    }

    return FALSE;

}

function rp_update_pre_appointment_checklist_status() {

    rp_verify_csrf_token_for_ajax('styling');

    $checklist_status = ( $_POST['status'] ?? '0' );

    if( $checklist_status != "1" ) {

        $checklist_status = "0";

    }

    if(rp_get_option('rp_enable_pre_appointment_checklist', FALSE) === FALSE) {

        rp_add_option('rp_enable_pre_appointment_checklist', $checklist_status);

    } else {

        rp_update_option('rp_enable_pre_appointment_checklist', $checklist_status);

    }

    echo json_encode(Array('status'=> true, 'message'  => 'Successfully Updated'));

    exit;

}

rp_ajax_for_admin('rp_update_pre_appointment_checklist_status', 'rp_update_pre_appointment_checklist_status');

function rp_delete_pre_appointment_checklist_item() {

    rp_verify_csrf_token_for_ajax('styling');

    $item_id = ( $_POST['item_id'] ?? '' );

    if( empty( $item_id ) ) {

        echo json_encode(Array('status'=> false, 'message'  => 'Invalid Request'));

        exit;

    }

    global $rpQuery;

    $table_rs_appointment_checklist = $rpQuery->prefix . "rs_appointment_checklist";

    $table_rs_general_translations = $rpQuery->prefix . "rs_general_translations";

    $rpQuery->query("DELETE FROM $table_rs_appointment_checklist WHERE id = '".rp_escape_sql($item_id)."'");

    $rpQuery->query("DELETE FROM $table_rs_general_translations WHERE `key` = '".rp_escape_sql($item_id)."_li_name'");

    echo json_encode(Array('status'=> true, 'message'  => 'Successfully Deleted'));

    exit;

}

rp_ajax_for_admin('rp_delete_pre_appointment_checklist_item', 'rp_delete_pre_appointment_checklist_item');


function rp_update_pre_appointment_checklist_items() {

    rp_verify_csrf_token_for_ajax('styling');

    global $rpQuery;

    $table_rs_appointment_checklist = $rpQuery->prefix . "rs_appointment_checklist";

    $rids = $_POST['rid'] ?? array();

    $li_names = $_POST['li_name'] ?? array();

    if( !empty( $rids ) && !empty( $li_names ) && count( $rids ) == count( $li_names ) ) {

        foreach( $rids as $key => $rid ) {

            $li_name = $li_names[$key] ?? '';

            if( $rid == 'NEW' ) {

                // create
                $rpQuery->query("INSERT INTO `$table_rs_appointment_checklist` (`title`) VALUES ('".rp_escape_sql($li_name)."')");

                $rids[$key] = $rpQuery->insert_id;

            } else {

                // update
                $rpQuery->query("UPDATE `$table_rs_appointment_checklist` SET `title` = '".rp_escape_sql($li_name)."' WHERE `id` = '".rp_escape_sql($rid)."'");

            }

        }

        $position = 0;

        foreach( $rids as $rid ) {

            $position++;

            $rpQuery->query("UPDATE `$table_rs_appointment_checklist` SET `position` = '".rp_escape_sql($position)."' WHERE `id` = '".rp_escape_sql($rid)."'");

        }

    }

    // get all items
    $items = rp_get_all_checklist_translated_items();

    echo json_encode(Array('status'=> true, 'message'  => 'Successfully Updated', 'table_rows' => $items));

    exit;

}

rp_ajax_for_admin('rp_update_pre_appointment_checklist_items', 'rp_update_pre_appointment_checklist_items');

F1le Man4ger