Remove unused overdue invoice setting move master cron switch out of notificaiton and into cron

This commit is contained in:
johnnyq
2026-08-02 17:22:28 -04:00
parent ad15fabbb3
commit a27019511e
23 changed files with 154 additions and 114 deletions

View File

@@ -29,7 +29,7 @@ if ($config_enable_cron == 0) {
}
/*
* Anything an administrator started from Settings > Backup is built first. Those are
* Anything an administrator started from Maintenance > Backup is built first. Those are
* explicit requests and somebody is waiting on the notification.
*/
$queued = backupRunQueued($mysqli);

View File

@@ -9,7 +9,7 @@
*
* It wakes once a minute, works out which jobs are due, and runs them. The jobs themselves
* are listed in includes/cron_jobs.php; when and whether each one runs is held in the
* cron_jobs table and edited from Settings > Cron.
* cron_jobs table and edited from Maintenance > Cron.
*
* WHAT THE JOBS INHERIT
*
@@ -72,7 +72,7 @@ function cronJobClaim($mysqli, array $job): bool
$now = date('Y-m-d H:i:s');
// Register the job the first time it is seen, seeded with the schedule it ships with.
// From here on the row is what runs - Settings > Cron writes to it.
// From here on the row is what runs - Maintenance > Cron writes to it.
$default_schedule = escapeSql($job['schedule']);
$default_interval = intval($job['interval_minutes'] ?? 1);
$default_daily_at = isset($job['daily_at']) ? "'" . escapeSql($job['daily_at']) . ":00'" : 'NULL';
@@ -144,7 +144,7 @@ function cronJobClaim($mysqli, array $job): bool
/*
* Record how a job ended. The status is the outcome of the run that just happened; the error
* is sticky and survives later successes, because the run that failed is usually long gone by
* the time anyone goes looking. Settings > Cron clears it.
* the time anyone goes looking. Maintenance > Cron clears it.
*/
function cronJobFinished($mysqli, string $job_name, string $status, ?float $duration = null, ?string $error = null): void
{
@@ -179,7 +179,7 @@ function cronJobFinished($mysqli, string $job_name, string $status, ?float $dura
}
}
// Proof the crontab is firing, recorded before any job runs. Settings > Cron reads it to tell
// Proof the crontab is firing, recorded before any job runs. Maintenance > Cron reads it to tell
// "no job was due" apart from "nothing has run this since the server was rebuilt".
mysqli_query($mysqli, "UPDATE settings SET config_cron_last_dispatch_at = '" . date('Y-m-d H:i:s') . "' WHERE company_id = 1");

View File

@@ -43,7 +43,6 @@ $company_currency = escapeSql($row['company_currency']);
// Company Settings
$config_enable_cron = intval($row['config_enable_cron']);
$config_invoice_overdue_reminders = $row['config_invoice_overdue_reminders'];
$config_invoice_prefix = escapeSql($row['config_invoice_prefix']);
$config_invoice_from_email = escapeSql($row['config_invoice_from_email']);
$config_invoice_from_name = escapeSql($row['config_invoice_from_name']);
@@ -539,7 +538,6 @@ while ($row = mysqli_fetch_assoc($sql_resolved_tickets_to_close)) {
if ($config_send_invoice_reminders == 1) {
// PAST DUE INVOICE Notifications
//$invoiceAlertArray = [$config_invoice_overdue_reminders];
$invoiceAlertArray = [1,30,60,90,120,150,180,210,240,270,300,330,360,390,420,450,480,510,540,570,590,620,650,680,710,740];
foreach ($invoiceAlertArray as $day) {

View File

@@ -42,6 +42,12 @@ $row = mysqli_fetch_assoc($sql);
$company_name = escapeSql($row['company_name']);
$company_phone = escapeSql(formatPhoneNumber($row['company_phone'], $row['company_phone_country_code']));
// Check cron is enabled
if ($config_enable_cron == 0) {
logApp("Cron-Email-Parser", "error", "Cron Email Parser unable to run - cron not enabled in admin settings.");
cronJobStop("Cron: is not enabled -- Quitting..");
}
// Check setting enabled
if ($config_ticket_email_parse == 0) {
logApp("Cron-Email-Parser", "error", "Cron Email Parser unable to run - not enabled in admin settings.");

View File

@@ -34,6 +34,19 @@ require_once "../functions.php";
* breach until someone moves them back to a running status.
*/
// Read the master switch here rather than trusting a global. Every job shares one process
// and one global scope, so a value an earlier job happened to leave behind is not this
// script's to rely on - see the cron rules in CONTRIBUTING.md.
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT config_enable_cron FROM settings WHERE company_id = 1"));
$config_enable_cron = intval($row['config_enable_cron']);
// Check cron is enabled
if ($config_enable_cron == 0) {
logApp("Cron-Ticket-SLA", "error", "Cron Ticket SLA monitor unable to run - cron not enabled in admin settings.");
cronJobStop("Cron: is not enabled -- Quitting..");
}
$sla_settings = getSlaSettings();
$warning_percent = intval($sla_settings['warning_percent']);