<?php
include '../koneksi.php';

$barangId = $_POST['barangId'];
$custId = $_POST['custId'] ?? '';

if(empty($barang_id) || empty($custId)){
    echo '';
    exit;
}
$sql = mysqli_query($konek,"SELECT 
    urs.idbarang,
    urs.harga_barangraxi,
    rp.tgl_raxips
FROM uraianraxips_barang urs
JOIN detail_raxips dr 
    ON urs.iddetail_raxips = dr.iddetail_raxips
JOIN raxi_ps rp 
    ON dr.idraxips = rp.idraxips
WHERE rp.idcustomer = '$custid'
  AND urs.idbarang = '$barang_id'
ORDER BY rp.tgl_raxips DESC
LIMIT 1;
");

$row = mysqli_fetch_assoc($sql);
echo $row['harga_barangraxi'] ?? '';

?>