<?php
include("../db.php");
error_reporting(0);

$q = strtolower($_GET["q"]);
if (!$q) exit;

$q_safe = mysql_real_escape_string($q);

$sql = "SELECT party_name, confirmrate, status_type 
        FROM party_creation 
        WHERE party_name LIKE '%$q_safe%' 
          AND party_type='Customer' 
          AND delete_status!='1' 
          AND approve_status='1'
        ORDER BY party_name ASC";

$rsd = mysql_query($sql);
if (!$rsd) die("Error in query: " . mysql_error());

if (mysql_num_rows($rsd) > 0) {
    while ($rs = mysql_fetch_array($rsd)) {
        $party_name = trim($rs['party_name']);
        $confirmrate = trim($rs['confirmrate']);
        $status_type = strtolower(trim($rs['status_type']));

        // If inactive → send INACTIVE marker
        if ($status_type == 'in-active' || $status_type == 'inactive') {
            echo "$party_name|INACTIVE\n"; 
        } else {
            echo "$party_name|$confirmrate\n";
        }
    }
} else {
    echo "Party_name Name Not Exist\n";
}
?>
