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\Abstracts\Http\Controller;
|
||||||
use App\Http\Requests\Setting\Setting as Request;
|
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
|
class InvoiceTemplates extends Controller
|
||||||
{
|
{
|
||||||
use DateTime, Uploads;
|
|
||||||
|
|
||||||
public $skip_keys = ['company_id', '_method', '_token', '_prefix', '_template'];
|
public $skip_keys = ['company_id', '_method', '_token', '_prefix', '_template'];
|
||||||
|
|
||||||
public $file_keys = ['company.logo', 'invoice.logo'];
|
|
||||||
/**
|
|
||||||
* Instantiate a new controller instance.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
@ -39,17 +28,13 @@ class InvoiceTemplates extends Controller
|
|||||||
public function update(Request $request)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
$fields = $request->all();
|
$fields = $request->all();
|
||||||
$prefix = $request->get('_prefix', 'general');
|
$prefix = $request->get('_prefix', 'invoice');
|
||||||
$company_id = $request->get('company_id');
|
$company_id = $request->get('company_id');
|
||||||
|
|
||||||
if (empty($company_id)) {
|
if (empty($company_id)) {
|
||||||
$company_id = session('company_id');
|
$company_id = session('company_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
$company = Company::find($company_id);
|
|
||||||
|
|
||||||
$companies = Company::all()->count();
|
|
||||||
|
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
$real_key = $prefix . '.' . $key;
|
$real_key = $prefix . '.' . $key;
|
||||||
|
|
||||||
@ -58,32 +43,6 @@ class InvoiceTemplates extends Controller
|
|||||||
continue;
|
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);
|
setting()->set($real_key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,22 +64,4 @@ class InvoiceTemplates extends Controller
|
|||||||
|
|
||||||
return response()->json($response);
|
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.quantity_name' => 'settings.invoice.quantity',
|
||||||
'invoice.title' => trans_choice('general.invoices', 1),
|
'invoice.title' => trans_choice('general.invoices', 1),
|
||||||
'invoice.payment_terms' => '0',
|
'invoice.payment_terms' => '0',
|
||||||
|
'invoice.template' => 'default',
|
||||||
'default.payment_method' => 'offline-payments.cash.1',
|
'default.payment_method' => 'offline-payments.cash.1',
|
||||||
'default.list_limit' => '25',
|
'default.list_limit' => '25',
|
||||||
'default.use_gravatar' => '0',
|
'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',
|
'localisations' => 'Localisation|Localisations',
|
||||||
'defaults' => 'Default|Defaults',
|
'defaults' => 'Default|Defaults',
|
||||||
'widgets' => 'Widget|Widgets',
|
'widgets' => 'Widget|Widgets',
|
||||||
|
'templates' => 'Template|Templates',
|
||||||
|
|
||||||
'dashboard' => 'Dashboard',
|
'dashboard' => 'Dashboard',
|
||||||
'welcome' => 'Welcome',
|
'welcome' => 'Welcome',
|
||||||
|
@ -52,8 +52,7 @@ return [
|
|||||||
'subheading' => 'Subheading',
|
'subheading' => 'Subheading',
|
||||||
'due_receipt' => 'Due upon receipt',
|
'due_receipt' => 'Due upon receipt',
|
||||||
'due_days' => 'Due within :days days',
|
'due_days' => 'Due within :days days',
|
||||||
'invoice_template' => 'Invoice Template',
|
'choose_template' => 'Choose invoice template',
|
||||||
'choose_template' => 'Choose a template',
|
|
||||||
'default' => 'Default',
|
'default' => 'Default',
|
||||||
'classic' => 'Classic',
|
'classic' => 'Classic',
|
||||||
'modern' => 'Modern',
|
'modern' => 'Modern',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
{!! Form::open([
|
{!! Form::open([
|
||||||
'route' => 'modals.invoice-template.update',
|
'route' => 'modals.invoice-templates.update',
|
||||||
'method' => 'PATCH',
|
'method' => 'PATCH',
|
||||||
'id' => 'template',
|
'id' => 'template',
|
||||||
'@submit.prevent' => 'onSubmit',
|
'@submit.prevent' => 'onSubmit',
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4 text-center px-0">
|
<div class="col-md-4 text-center px-0">
|
||||||
<div class="bg-print border-radius-5 print-edge choose" @click="invoice_form.template='default'">
|
<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>
|
<label>
|
||||||
<input type="radio" name="template" value="default" v-model="invoice_form.template">
|
<input type="radio" name="template" value="default" v-model="invoice_form.template">
|
||||||
{{ trans('settings.invoice.default') }}
|
{{ trans('settings.invoice.default') }}
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
<div class="col-md-4 text-center px-0">
|
<div class="col-md-4 text-center px-0">
|
||||||
<div class="bg-print border-radius-5 print-edge choose" @click="invoice_form.template='classic'">
|
<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>
|
<label>
|
||||||
<input type="radio" name="template" value="classic" v-model="invoice_form.template">
|
<input type="radio" name="template" value="classic" v-model="invoice_form.template">
|
||||||
{{ trans('settings.invoice.classic') }}
|
{{ trans('settings.invoice.classic') }}
|
||||||
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<div class="col-md-4 text-center px-0">
|
<div class="col-md-4 text-center px-0">
|
||||||
<div class="bg-print border-radius-5 print-edge choose" @click="invoice_form.template='modern'">
|
<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>
|
<label>
|
||||||
<input type="radio" name="template" value="modern" v-model="invoice_form.template">
|
<input type="radio" name="template" value="modern" v-model="invoice_form.template">
|
||||||
{{ trans('settings.invoice.modern') }}
|
{{ 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) }}
|
{{ 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">
|
<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">
|
<div class="input-group">
|
||||||
<a href="#" class="btn btn-block btn-outline-primary" @click="onTemplate">
|
<a href="#" class="btn btn-block btn-outline-primary" @click="onTemplate">
|
||||||
@ -75,7 +75,7 @@
|
|||||||
:button_cancel="'{{ trans('general.button.save') }}'"
|
:button_cancel="'{{ trans('general.button.save') }}'"
|
||||||
:button_delete="'{{ trans('general.button.cancel') }}'">
|
:button_delete="'{{ trans('general.button.cancel') }}'">
|
||||||
<template #modal-body>
|
<template #modal-body>
|
||||||
@include('modals.settings.template')
|
@include('modals.settings.invoice_template')
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #card-footer>
|
<template #card-footer>
|
||||||
|
@ -203,7 +203,7 @@ Route::group(['as' => 'modals.', 'prefix' => 'modals'], function () {
|
|||||||
Route::resource('categories', 'Modals\Categories');
|
Route::resource('categories', 'Modals\Categories');
|
||||||
Route::resource('customers', 'Modals\Customers');
|
Route::resource('customers', 'Modals\Customers');
|
||||||
Route::resource('vendors', 'Modals\Vendors');
|
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('invoices/{invoice}/transactions', 'Modals\InvoiceTransactions', ['middleware' => ['date.format', 'money']]);
|
||||||
Route::resource('bills/{bill}/transactions', 'Modals\BillTransactions', ['middleware' => ['date.format', 'money']]);
|
Route::resource('bills/{bill}/transactions', 'Modals\BillTransactions', ['middleware' => ['date.format', 'money']]);
|
||||||
Route::resource('taxes', 'Modals\Taxes');
|
Route::resource('taxes', 'Modals\Taxes');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user