<?php

session_start();

include "../db.php";



// Calculate updated totals based on your conditions

$total_charges = $_SESSION["amount"];

$total_discount = $_SESSION["total_discount"];

$total_received = $_SESSION["recived"];

$total_pending = $total_charges - $total_received - $total_discount;



// Return values as JSON

echo json_encode([

    'total_charges' => $total_charges,

    'total_discount' => $total_discount,

    'total_received' => $total_received,

    'total_pending' => $total_pending

]);