2023-01-08 06:15:33 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2023-01-08 06:15:33 +01:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
2023-01-13 02:43:38 +01:00
|
|
|
namespace App\Services\Scheduler;
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-02-17 22:36:51 +01:00
|
|
|
use App\Models\Scheduler;
|
2023-04-13 05:31:19 +02:00
|
|
|
use App\Utils\Traits\MakesDates;
|
2023-10-26 04:57:44 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2023-01-13 02:43:38 +01:00
|
|
|
|
2023-01-13 12:24:23 +01:00
|
|
|
class SchedulerService
|
2023-01-08 06:15:33 +01:00
|
|
|
{
|
2023-01-13 23:46:17 +01:00
|
|
|
use MakesHash;
|
2023-01-14 12:00:22 +01:00
|
|
|
use MakesDates;
|
2023-01-13 23:46:17 +01:00
|
|
|
|
2023-02-16 02:36:09 +01:00
|
|
|
public function __construct(public Scheduler $scheduler)
|
|
|
|
{
|
|
|
|
}
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
/**
|
|
|
|
* Called from the TaskScheduler Cron
|
2023-02-16 02:36:09 +01:00
|
|
|
*
|
|
|
|
* @return void
|
2023-01-13 23:46:17 +01:00
|
|
|
*/
|
|
|
|
public function runTask(): void
|
2023-01-08 06:15:33 +01:00
|
|
|
{
|
2023-03-18 08:24:56 +01:00
|
|
|
if (method_exists($this, $this->scheduler->template)) {
|
2023-03-08 07:43:52 +01:00
|
|
|
$this->{$this->scheduler->template}();
|
2023-03-18 08:24:56 +01:00
|
|
|
}
|
2023-01-13 23:46:17 +01:00
|
|
|
}
|
|
|
|
|
2023-03-21 22:00:20 +01:00
|
|
|
private function email_record()
|
2023-02-16 02:36:09 +01:00
|
|
|
{
|
2023-03-21 22:00:20 +01:00
|
|
|
(new EmailRecord($this->scheduler))->run();
|
2023-01-14 08:47:14 +01:00
|
|
|
}
|
|
|
|
|
2023-03-18 09:06:32 +01:00
|
|
|
private function email_statement()
|
2023-01-14 08:47:14 +01:00
|
|
|
{
|
2023-03-18 09:06:32 +01:00
|
|
|
(new EmailStatementService($this->scheduler))->run();
|
2023-01-13 23:46:17 +01:00
|
|
|
}
|
|
|
|
|
2023-04-14 07:46:49 +02:00
|
|
|
private function email_report()
|
2023-04-13 05:31:19 +02:00
|
|
|
{
|
2023-04-14 08:44:04 +02:00
|
|
|
(new EmailReport($this->scheduler))->run();
|
2023-04-13 05:31:19 +02:00
|
|
|
}
|
2023-03-18 09:06:32 +01:00
|
|
|
|
2023-04-14 07:46:49 +02:00
|
|
|
|
2023-01-17 10:48:10 +01:00
|
|
|
/**
|
|
|
|
* Sets the next run date of the scheduled task
|
2023-02-16 02:36:09 +01:00
|
|
|
*
|
2023-01-17 10:48:10 +01:00
|
|
|
*/
|
2023-01-17 09:42:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
//handle when the scheduler has been paused.
|
2023-02-16 02:36:09 +01:00
|
|
|
}
|