diff --git a/app/Http/Controllers/Modals/InvoiceTemplates.php b/app/Http/Controllers/Modals/InvoiceTemplates.php index 29c1e85a0..087a275d6 100644 --- a/app/Http/Controllers/Modals/InvoiceTemplates.php +++ b/app/Http/Controllers/Modals/InvoiceTemplates.php @@ -4,22 +4,11 @@ namespace App\Http\Controllers\Modals; use App\Abstracts\Http\Controller; use App\Http\Requests\Setting\Setting as Request; -use App\Models\Common\Company; -use App\Models\Module\Module; -use App\Traits\DateTime; -use App\Traits\Uploads; -use Illuminate\Support\Str; class InvoiceTemplates extends Controller { - use DateTime, Uploads; - public $skip_keys = ['company_id', '_method', '_token', '_prefix', '_template']; - public $file_keys = ['company.logo', 'invoice.logo']; - /** - * Instantiate a new controller instance. - */ public function __construct() { // Add CRUD permission check @@ -39,17 +28,13 @@ class InvoiceTemplates extends Controller public function update(Request $request) { $fields = $request->all(); - $prefix = $request->get('_prefix', 'general'); + $prefix = $request->get('_prefix', 'invoice'); $company_id = $request->get('company_id'); if (empty($company_id)) { $company_id = session('company_id'); } - $company = Company::find($company_id); - - $companies = Company::all()->count(); - foreach ($fields as $key => $value) { $real_key = $prefix . '.' . $key; @@ -58,32 +43,6 @@ class InvoiceTemplates extends Controller continue; } - // Process file uploads - if (in_array($real_key, $this->file_keys)) { - // Upload attachment - if ($request->file($key)) { - $media = $this->getMedia($request->file($key), 'settings'); - - $company->attachMedia($media, Str::snake($real_key)); - - $value = $media->id; - } - - // Prevent reset - if (empty($value)) { - continue; - } - } - - if ($real_key == 'default.locale') { - user()->setAttribute('locale', $value)->save(); - } - - // If only 1 company - if ($companies == 1) { - $this->oneCompany($real_key, $value); - } - setting()->set($real_key, $value); } @@ -105,22 +64,4 @@ class InvoiceTemplates extends Controller return response()->json($response); } - - protected function oneCompany($real_key, $value) - { - switch ($real_key) { - case 'company.name': - Installer::updateEnv(['MAIL_FROM_NAME' => '"' . $value . '"']); - break; - case 'company.email': - Installer::updateEnv(['MAIL_FROM_ADDRESS' => $value]); - break; - case 'default.locale': - Installer::updateEnv(['APP_LOCALE' => $value]); - break; - case 'schedule.time': - Installer::updateEnv(['APP_SCHEDULE_TIME' => '"' . $value . '"']); - break; - } - } } diff --git a/database/seeds/Settings.php b/database/seeds/Settings.php index 272ee4930..d95b1f806 100644 --- a/database/seeds/Settings.php +++ b/database/seeds/Settings.php @@ -42,6 +42,7 @@ class Settings extends Seeder 'invoice.quantity_name' => 'settings.invoice.quantity', 'invoice.title' => trans_choice('general.invoices', 1), 'invoice.payment_terms' => '0', + 'invoice.template' => 'default', 'default.payment_method' => 'offline-payments.cash.1', 'default.list_limit' => '25', 'default.use_gravatar' => '0', diff --git a/public/img/print_templates/classic.png b/public/img/invoice_templates/classic.png similarity index 100% rename from public/img/print_templates/classic.png rename to public/img/invoice_templates/classic.png diff --git a/public/img/print_templates/default.png b/public/img/invoice_templates/default.png similarity index 100% rename from public/img/print_templates/default.png rename to public/img/invoice_templates/default.png diff --git a/public/img/print_templates/modern.png b/public/img/invoice_templates/modern.png similarity index 100% rename from public/img/print_templates/modern.png rename to public/img/invoice_templates/modern.png diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index 537d0818c..e73473ba8 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -48,6 +48,7 @@ return [ 'localisations' => 'Localisation|Localisations', 'defaults' => 'Default|Defaults', 'widgets' => 'Widget|Widgets', + 'templates' => 'Template|Templates', 'dashboard' => 'Dashboard', 'welcome' => 'Welcome', diff --git a/resources/lang/en-GB/settings.php b/resources/lang/en-GB/settings.php index 07716b360..044061471 100644 --- a/resources/lang/en-GB/settings.php +++ b/resources/lang/en-GB/settings.php @@ -52,8 +52,7 @@ return [ 'subheading' => 'Subheading', 'due_receipt' => 'Due upon receipt', 'due_days' => 'Due within :days days', - 'invoice_template' => 'Invoice Template', - 'choose_template' => 'Choose a template', + 'choose_template' => 'Choose invoice template', 'default' => 'Default', 'classic' => 'Classic', 'modern' => 'Modern', diff --git a/resources/views/modals/settings/template.blade.php b/resources/views/modals/settings/invoice_template.blade.php similarity index 80% rename from resources/views/modals/settings/template.blade.php rename to resources/views/modals/settings/invoice_template.blade.php index 7be9be62e..aad1aae08 100644 --- a/resources/views/modals/settings/template.blade.php +++ b/resources/views/modals/settings/invoice_template.blade.php @@ -1,6 +1,6 @@