<?php
session_start();
ini_set('session.cookie_secure', 1);
require_once "../../includes/db.php";
header('Content-Type: application/json');

$comp_id = isset($_GET['comp_id']) ? (int)$_GET['comp_id'] : 0;
$uid  =$_SESSION['user_id'];

        $loc_id = isset($_POST['loc_id']) ? intval($_POST['loc_id']) : 0;
        $ord_no = isset($_POST['ord_no']) ? intval($_POST['ord_no']) : 0;
        $t_type = isset($_POST['t_type']) ? trim($_POST['t_type']) : '';
        $confby = isset($_POST['confby']) ? trim($_POST['confby']) : '';

$stmt = $pdo->prepare("
    UPDATE transactions SET t_status='Confirmed', t_conf_by= :uid, t_conf_date=Now() WHERE co_id= :loc_id AND t_doc_no= :ord_no AND t_type= :t_type AND t_status='Pending'
");
    
$stmt->execute([
    'uid' => $uid,
    'loc_id' => $loc_id,
    'ord_no' => $ord_no, 't_type' => $t_type
]);

echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));


?>

