<?php
echo 'Olá';
// include_once __dir__ . '/../connection.php';

// // Consulta SQL
// $sql = "SELECT email, date_added, signature_status, signature_plan_id, payment_link FROM leads WHERE signature_status = 'TRIAL' AND payment_link IS NULL";

// $result = $conn->query($sql);

// if ($result->num_rows > 0) {
//   while($row = $result->fetch_assoc()) {
//     // Converte a data para o formato YYYY-MM-DD
//     $date_added = substr($row["date_added"], 0, 10);
    
//     // Calcula a diferença de dias
//     $diff = abs(strtotime($date_added) - strtotime(date("Y-m-d")));
//     $days_diff = floor($diff / (60 * 60 * 24));
//     echo $days_diff;
    
//     // Verifica a diferença de dias e executa a ação correspondente
//     if ($days_diff == 14) {
//       file_put_contents('TESTE.TXT', 'ENVIA BOLETO');
//     } elseif ($days_diff == 17) {
//       // Atualize o email
//     //   $email = $row["email"];
//     //   $update_sql = "UPDATE leads SET email = '$email' WHERE signature_status = 'TRIAL' AND payment_link IS NULL AND date_added = '" . $row["date_added"] . "'";
//     //   $conn->query($update_sql);
//         file_put_contents('TESTE.TXT', 'ACABOU TRIAL');
//     }
//   }
// } else {
//   echo "0 resultados";
// }

// $conn->close();
?>
