67 lines
2.2 KiB
PHP
67 lines
2.2 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
Route::get('/', fn () => redirect('/admin'));
|
|
|
|
Route::get('/locale/{locale}', function (string $locale) {
|
|
if (in_array($locale, config('app.available_locales', ['fa', 'en']))) {
|
|
session(['locale' => $locale]);
|
|
}
|
|
return redirect()->back();
|
|
})->name('locale.switch');
|
|
|
|
Route::middleware(['web', 'auth'])->group(function () {
|
|
Route::get('/prescription/{prescription}/print', [\App\Http\Controllers\PrescriptionPrintController::class, 'print'])
|
|
->name('prescription.print');
|
|
|
|
Route::get('/patient/{patient}/print-lab', [\App\Http\Controllers\PrescriptionPrintController::class, 'printPatientLab'])
|
|
->name('patient.print.lab');
|
|
|
|
Route::get('/prescription/{prescription}/print-admission', [\App\Http\Controllers\PrescriptionPrintController::class, 'printAdmission'])
|
|
->name('prescription.print.admission');
|
|
|
|
Route::get('/surgery-appointment/{patient}/print-admission', [\App\Http\Controllers\PrescriptionPrintController::class, 'printSurgeryAdmission'])
|
|
->name('surgery-appointment.print.admission');
|
|
|
|
Route::post('/admin/sync/run', function () {
|
|
$service = \App\Services\SyncService::fromConfig();
|
|
|
|
if (! $service->isConfigured()) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'report' => [__('navigation.sync.error_not_configured')],
|
|
], 422);
|
|
}
|
|
|
|
$result = $service->sync();
|
|
|
|
return response()->json($result);
|
|
})->name('sync.run');
|
|
|
|
Route::get('/admin/backup/download', function () {
|
|
$dbPath = database_path('database.sqlite');
|
|
|
|
if (! file_exists($dbPath)) {
|
|
abort(404, 'Database file not found.');
|
|
}
|
|
|
|
$backupDir = storage_path('app/backups');
|
|
|
|
if (! is_dir($backupDir)) {
|
|
mkdir($backupDir, 0755, true);
|
|
}
|
|
|
|
foreach (glob($backupDir . '/matab-backup-*.sqlite') as $oldFile) {
|
|
unlink($oldFile);
|
|
}
|
|
|
|
$filename = 'matab-backup-' . now()->format('Y-m-d_H-i-s') . '.sqlite';
|
|
$backupPath = $backupDir . '/' . $filename;
|
|
|
|
copy($dbPath, $backupPath);
|
|
|
|
return response()->json(['success' => true, 'filename' => $filename]);
|
|
})->name('backup.download');
|
|
});
|