2023-01-08 06:15:33 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @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-01-13 23:46:17 +01:00
|
|
|
use App\Models\Client;
|
2023-01-13 02:43:38 +01:00
|
|
|
use App\Models\Scheduler;
|
2023-01-13 23:46:17 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Support\Str;
|
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;
|
|
|
|
|
|
|
|
private string $method;
|
2023-01-08 06:15:33 +01:00
|
|
|
|
|
|
|
public function __construct(public Scheduler $scheduler) {}
|
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
/**
|
|
|
|
* Called from the TaskScheduler Cron
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function runTask(): void
|
2023-01-08 06:15:33 +01:00
|
|
|
{
|
2023-01-13 23:46:17 +01:00
|
|
|
$this->{$this->scheduler->template}();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function client_statement()
|
|
|
|
{
|
|
|
|
$query = Client::query()
|
|
|
|
->where('company_id', $this->scheduler->company_id);
|
|
|
|
|
|
|
|
//Email only the selected clients
|
|
|
|
if(count($this->scheduler->parameters['clients']) >= 1)
|
|
|
|
$query->where('id', $this->transformKeys($this->scheduler->parameters['clients']));
|
|
|
|
|
|
|
|
$query->cursor()
|
|
|
|
->each(function ($client){
|
|
|
|
|
|
|
|
//work out the date range
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// public function scheduleStatement()
|
|
|
|
// {
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// //Is it for one client
|
|
|
|
// //Is it for all clients
|
|
|
|
// //Is it for all clients excluding these clients
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// //Frequency
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// //show aging
|
|
|
|
// //show payments
|
|
|
|
// //paid/unpaid
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// //When to send? 1st of month
|
|
|
|
// //End of month
|
|
|
|
// //This date
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// }
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// public function scheduleReport()
|
|
|
|
// {
|
|
|
|
// //Report type
|
|
|
|
// //same schema as ScheduleStatement
|
|
|
|
// }
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// public function scheduleEntitySend()
|
|
|
|
// {
|
|
|
|
// //Entity
|
|
|
|
// //Entity Id
|
|
|
|
// //When
|
|
|
|
// }
|
2023-01-08 06:15:33 +01:00
|
|
|
|
2023-01-13 23:46:17 +01:00
|
|
|
// public function projectStatus()
|
|
|
|
// {
|
|
|
|
// //Project ID
|
|
|
|
// //Tasks - task statuses
|
|
|
|
// }
|
2023-01-08 06:15:33 +01:00
|
|
|
|
|
|
|
}
|