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

// Auto Active → In-active (no job in 60 days)
$sql = "SELECT party_name 
        FROM party_creation 
        WHERE status_type = 'Active' 
          AND delete_status = '0' 
          AND approve_status = '1'";
$rs = mysql_query($sql);

while($row = mysql_fetch_assoc($rs)) {
    $partyName = $row['party_name'];

    $check = "SELECT COUNT(*) AS cnt 
              FROM jobcard_sublist 
              WHERE customer_name = '$partyName'
                AND job_date >= DATE_SUB(CURDATE(), INTERVAL 60 DAY)";
    $rsCheck = mysql_query($check);
    $result = mysql_fetch_assoc($rsCheck);

    if ($result['cnt'] == 0) {
        $update = "UPDATE party_creation 
                   SET status_type = 'In-active' 
                   WHERE party_name = '$partyName'";
        mysql_query($update);
        echo "Updated: {$partyName} → In-active<br>";
    }
}
?>
