fixed invoice templates
This commit is contained in:
parent
bc547a18b4
commit
f3ac0944e2
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
@ -48,6 +48,7 @@ return [
|
||||
'localisations' => 'Localisation|Localisations',
|
||||
'defaults' => 'Default|Defaults',
|
||||
'widgets' => 'Widget|Widgets',
|
||||
'templates' => 'Template|Templates',
|
||||
|
||||
'dashboard' => 'Dashboard',
|
||||
'welcome' => 'Welcome',
|
||||
|
@ -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',
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="modal-body">
|
||||
{!! Form::open([
|
||||
'route' => 'modals.invoice-template.update',
|
||||
'route' => 'modals.invoice-templates.update',
|
||||
'method' => 'PATCH',
|
||||
'id' => 'template',
|
||||
'@submit.prevent' => 'onSubmit',
|
||||
@ -13,7 +13,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center px-0">
|
||||
<div class="bg-print border-radius-5 print-edge choose" @click="invoice_form.template='default'">
|
||||
<img src="{{ asset('public/img/print_templates/default.png') }}" class="mb-1 mt-3" height="200" alt="Default"/>
|
||||
<img src="{{ asset('public/img/invoice_templates/default.png') }}" class="mb-1 mt-3" height="200" alt="Default"/>
|
||||
<label>
|
||||
<input type="radio" name="template" value="default" v-model="invoice_form.template">
|
||||
{{ trans('settings.invoice.default') }}
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
<div class="col-md-4 text-center px-0">
|
||||
<div class="bg-print border-radius-5 print-edge choose" @click="invoice_form.template='classic'">
|
||||
<img src="{{ asset('public/img/print_templates/classic.png') }}" class="mb-1 mt-3" height="200" alt="Classic"/>
|
||||
<img src="{{ asset('public/img/invoice_templates/classic.png') }}" class="mb-1 mt-3" height="200" alt="Classic"/>
|
||||
<label>
|
||||
<input type="radio" name="template" value="classic" v-model="invoice_form.template">
|
||||
{{ trans('settings.invoice.classic') }}
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
<div class="col-md-4 text-center px-0">
|
||||
<div class="bg-print border-radius-5 print-edge choose" @click="invoice_form.template='modern'">
|
||||
<img src="{{ asset('public/img/print_templates/modern.png') }}" class="mb-1 mt-3" height="200" alt="Modern"/>
|
||||
<img src="{{ asset('public/img/invoice_templates/modern.png') }}" class="mb-1 mt-3" height="200" alt="Modern"/>
|
||||
<label>
|
||||
<input type="radio" name="template" value="modern" v-model="invoice_form.template">
|
||||
{{ trans('settings.invoice.modern') }}
|
@ -41,7 +41,7 @@
|
||||
{{ Form::invoice_text('quantity_name', trans('settings.invoice.quantity_name'), 'font', $quantity_names, null, [], 'quantity_name_input', null) }}
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
{!! Form::label('invoice_template', trans('settings.invoice.invoice_template'), ['class' => 'form-control-label']) !!}
|
||||
{!! Form::label('invoice_template', trans_choice('general.templates', 1), ['class' => 'form-control-label']) !!}
|
||||
|
||||
<div class="input-group">
|
||||
<a href="#" class="btn btn-block btn-outline-primary" @click="onTemplate">
|
||||
@ -75,7 +75,7 @@
|
||||
:button_cancel="'{{ trans('general.button.save') }}'"
|
||||
:button_delete="'{{ trans('general.button.cancel') }}'">
|
||||
<template #modal-body>
|
||||
@include('modals.settings.template')
|
||||
@include('modals.settings.invoice_template')
|
||||
</template>
|
||||
|
||||
<template #card-footer>
|
||||
|
@ -203,7 +203,7 @@ Route::group(['as' => 'modals.', 'prefix' => 'modals'], function () {
|
||||
Route::resource('categories', 'Modals\Categories');
|
||||
Route::resource('customers', 'Modals\Customers');
|
||||
Route::resource('vendors', 'Modals\Vendors');
|
||||
Route::patch('invoice-templates', 'Modals\InvoiceTemplates@update')->name('invoice-template.update');
|
||||
Route::patch('invoice-templates', 'Modals\InvoiceTemplates@update')->name('invoice-templates.update');
|
||||
Route::resource('invoices/{invoice}/transactions', 'Modals\InvoiceTransactions', ['middleware' => ['date.format', 'money']]);
|
||||
Route::resource('bills/{bill}/transactions', 'Modals\BillTransactions', ['middleware' => ['date.format', 'money']]);
|
||||
Route::resource('taxes', 'Modals\Taxes');
|
||||
|
Loading…
x
Reference in New Issue
Block a user