mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-24 15:04:19 +00:00
Merge branch 'bulk-download-invoices' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into development
# Conflicts: # app/Classes/Modules/Companies/ControllersLogic/BulkDownloadCustomerInvoicesLogic.php # app/Console/Kernel.php
This commit is contained in:
+1
-5
@@ -74,11 +74,7 @@ class BulkDownloadCustomerInvoicesLogic
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
$response = response()->download($zip_file);
|
||||
|
||||
File::delete($zip_file);
|
||||
|
||||
return $response;
|
||||
return response()->download($zip_file);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => 'Failed',
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class DeleteBulkInvoiceFiles extends Command
|
||||
{
|
||||
protected $signature = 'delete:bulk-invoice-files';
|
||||
|
||||
protected $description = 'Delete all files in the storage/app/bulk_invoice directory';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$start = new Carbon();
|
||||
$this->logOutput('Process started');
|
||||
|
||||
$directory = storage_path('app/bulk_invoice');
|
||||
|
||||
if (File::isDirectory($directory)) {
|
||||
File::cleanDirectory($directory);
|
||||
$this->info('All files in the bulk_invoice directory have been deleted.');
|
||||
} else {
|
||||
$this->error('The bulk_invoice directory does not exist.');
|
||||
}
|
||||
|
||||
$end = new Carbon();
|
||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||
|
||||
$this->logOutput('Process ended. ElapsedTime: ' . $elapsedTime);
|
||||
}
|
||||
|
||||
public function logOutput($text)
|
||||
{
|
||||
if (is_array($text)) {
|
||||
$text = implode(', ', $text);
|
||||
}
|
||||
|
||||
$this->info(Carbon::now() . ' : ' . $text);
|
||||
|
||||
$filePath = storage_path('logs/delete-orders.log');
|
||||
$textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $text . PHP_EOL;
|
||||
file_put_contents($filePath, $textToAppend, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,16 @@ class Kernel extends ConsoleKernel
|
||||
->hourly()
|
||||
->appendOutputTo(storage_path().'/logs/soft-delete-seasonal-segmant-company.log')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('regenerateInvoice')
|
||||
->everyMinute()
|
||||
->appendOutputTo(storage_path().'/logs/regenerateInvoice.log')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('delete:bulk-invoice-files')
|
||||
->dailyAt('00:00')
|
||||
->appendOutputTo(storage_path().'/logs/delete-bulk-invoice-files.log')
|
||||
->withoutOverlapping();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user