? GR0V Shell

GR0V shell

Linux in-mum-web921.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64

Path : /home/u949514618/domains/drpktiwari.com/public_html/admin/
File Upload :
Current File : /home/u949514618/domains/drpktiwari.com/public_html/admin/insert_patient.php

<?php
include 'db.php';

$date = $_POST['date'];
$centre_id = $_POST['centre_id'];
$patient_name = $_POST['patient_name'];
$contact_number = "+91".$_POST['contact_number'];
$referby = $_POST['referby'];
$doctor_id = isset($_POST['doctor_id']) && $_POST['doctor_id'] != "" ? $_POST['doctor_id'] : NULL;
$password = "123";
$discount = isset($_POST['discount']) ? $_POST['discount'] : 0;
$discount_type = $_POST['discount_type'];

// Insert Patient Data
$insert_patient = mysqli_query($conn, "INSERT INTO patient_registration (date, centre_id, patient_name, contact_number, referby, doctor_id, password) 
VALUES ('$date', '$centre_id', '$patient_name', '$contact_number', '$referby', " . ($doctor_id ? "'$doctor_id'" : "NULL") . ", '$password')");

if (!$insert_patient) {
    echo "Error: " . mysqli_error($conn);
    exit;
}

$patient_id = mysqli_insert_id($conn);

$total_commission = 0;

foreach ($_POST['test_id'] as $key => $test_id) {
    $test_rate = $_POST['test_rate'][$key];

    // Insert into patient_test_entry
    $insert_test = mysqli_query($conn, "INSERT INTO patient_test_entry (patient_id, test_id, payable_amount, discount, discount_type) 
    VALUES ('$patient_id', '$test_id', '$test_rate', '$discount', '$discount_type')");

    if (!$insert_test) {
        echo "Error: " . mysqli_error($conn);
        exit;
    }

    // Doctor commission calculation only if referby = Doctor
    if ($referby == "Doctor" && $doctor_id) {
        $doctor_query = mysqli_query($conn, "SELECT doctor_commission FROM doctorentry WHERE id = '$doctor_id'");
        $doctor_data = mysqli_fetch_assoc($doctor_query);
        $doctor_commission_rate = $doctor_data['doctor_commission']; // Assume this is a percentage

        // Calculate commission for this test
        $test_commission = ($test_rate * $doctor_commission_rate) / 100;
        $total_commission += $test_commission;
    }
}

// Insert into doctor_commission_table only if referby = Doctor
if ($referby == "Doctor" && $doctor_id) {
    // If discount type is "Doctor", subtract discount from commission
    if ($discount_type == "Doctor") {
        $total_commission -= $discount;
        if ($total_commission < 0) {
            $total_commission = 0; // Avoid negative commission
        }
    }

    // Insert into doctor_commission_table
    $insert_commission = mysqli_query($conn, "INSERT INTO doctor_commission_table (doctor_id, patient_id, date, total_commission, centre_id) 
    VALUES ('$doctor_id', '$patient_id', '$date', '$total_commission', '$centre_id')");

    if (!$insert_commission) {
        echo "Error: " . mysqli_error($conn);
        exit;
    }
}

echo "success";
?>

T1KUS90T
  root-grov@89.117.188.241:~$