akaunting 3.0 (the last dance)
This commit is contained in:
@@ -18,28 +18,54 @@ abstract class BulkAction
|
||||
public $model = false;
|
||||
|
||||
public $actions = [
|
||||
'enable' => [
|
||||
'name' => 'general.enable',
|
||||
'message' => 'bulk_actions.message.enable',
|
||||
'permission' => 'update-common-items',
|
||||
'enable' => [
|
||||
'name' => 'general.enable',
|
||||
'message' => 'bulk_actions.message.enable',
|
||||
'permission' => 'update-common-items',
|
||||
],
|
||||
'disable' => [
|
||||
'name' => 'general.disable',
|
||||
'message' => 'bulk_actions.message.disable',
|
||||
'permission' => 'update-common-items',
|
||||
'disable' => [
|
||||
'name' => 'general.disable',
|
||||
'message' => 'bulk_actions.message.disable',
|
||||
'permission' => 'update-common-items',
|
||||
],
|
||||
'delete' => [
|
||||
'name' => 'general.delete',
|
||||
'message' => 'bulk_actions.message.delete',
|
||||
'permission' => 'delete-common-items',
|
||||
'delete' => [
|
||||
'name' => 'general.delete',
|
||||
'message' => 'bulk_actions.message.delete',
|
||||
'permission' => 'delete-common-items',
|
||||
],
|
||||
'export' => [
|
||||
'name' => 'general.export',
|
||||
'message' => 'bulk_actions.message.export',
|
||||
'type' => 'download'
|
||||
'export' => [
|
||||
'name' => 'general.export',
|
||||
'message' => 'bulk_actions.message.export',
|
||||
'type' => 'download'
|
||||
],
|
||||
];
|
||||
|
||||
public $icons = [
|
||||
'enable' => 'check_circle',
|
||||
'disable' => 'hide_source',
|
||||
'delete' => 'delete',
|
||||
'export' => 'file_download',
|
||||
'reconcile' => 'published_with_changes',
|
||||
'unreconcile' => 'layers_clear',
|
||||
'received' => 'call_received',
|
||||
'cancelled' => 'cancel',
|
||||
'sent' => 'send',
|
||||
'approved' => 'approval',
|
||||
'refused' => 'do_not_disturb_on',
|
||||
'issued' => 'mark_email_read',
|
||||
'confirmed' => 'thumb_up_alt',
|
||||
];
|
||||
|
||||
public $messages = [
|
||||
'general' => 'bulk_actions.success.general',
|
||||
'enable' => 'messages.success.enabled',
|
||||
'disable' => 'messages.success.disabled',
|
||||
'delete' => 'messages.success.deleted',
|
||||
'duplicate' => 'messages.success.duplicated',
|
||||
'invite' => 'messages.success.invited',
|
||||
'end' => 'messages.success.ended',
|
||||
];
|
||||
|
||||
public function getSelectedRecords($request, $relationships = null)
|
||||
{
|
||||
if (empty($relationships)) {
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Abstracts;
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Common\Company;
|
||||
use App\Traits\Jobs;
|
||||
use Closure;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory as BaseFactory;
|
||||
use Illuminate\Database\Eloquent\Model as EloquentModel;
|
||||
|
||||
@@ -28,16 +29,46 @@ abstract class Factory extends BaseFactory
|
||||
|
||||
config(['mail.default' => 'array']);
|
||||
|
||||
$this->user = User::first();
|
||||
$this->company = $this->user->companies()->first();
|
||||
// TODO: this location was put to make US | for "gmail.co.uk" issue
|
||||
$this->faker = \Faker\Factory::create();
|
||||
|
||||
company($this->company->id)->makeCurrent();
|
||||
$this->setUser();
|
||||
|
||||
$this->setCompany();
|
||||
}
|
||||
|
||||
public function getCompanyUsers(): array
|
||||
{
|
||||
return $this->company->users()->enabled()->get()->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public function company(int $id): static
|
||||
{
|
||||
return $this->state([
|
||||
'company_id' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function setUser(): void
|
||||
{
|
||||
$this->user = User::first();
|
||||
}
|
||||
|
||||
public function setCompany(): void
|
||||
{
|
||||
$company_id = $this->getRawAttribute('company_id');
|
||||
|
||||
$this->company = !empty($company_id) ? Company::find($company_id) : $this->user->companies()->first();
|
||||
|
||||
$this->company->makeCurrent();
|
||||
|
||||
app('url')->defaults(['company_id' => company_id()]);
|
||||
}
|
||||
|
||||
public function getCompanyUsers()
|
||||
public function getRawAttribute($key)
|
||||
{
|
||||
return $this->company->users()->enabled()->get()->pluck('id')->toArray();
|
||||
$raw = $this->state([])->getExpandedAttributes(null);
|
||||
|
||||
return $raw[$key] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,18 @@ namespace App\Abstracts\Http;
|
||||
use App\Traits\Jobs;
|
||||
use App\Traits\Permissions;
|
||||
use App\Traits\Relationships;
|
||||
use Dingo\Api\Exception\ResourceException;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
use App\Exceptions\Http\Resource as ResourceException;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
abstract class ApiController extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, Jobs, Helpers, Permissions, Relationships, ValidatesRequests;
|
||||
use AuthorizesRequests, Jobs, Permissions, Relationships, ValidatesRequests;
|
||||
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
@@ -39,4 +41,146 @@ abstract class ApiController extends BaseController
|
||||
|
||||
return redirect()->to($this->getRedirectUrl())->withInput($request->input())->withErrors($errors, $this->errorBag());
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with a location and a created resource.
|
||||
*
|
||||
* @param string $location
|
||||
* @param object $resource
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function created($location, $resource): JsonResponse
|
||||
{
|
||||
return $resource
|
||||
->response()
|
||||
->setStatusCode(201)
|
||||
->header('Location', $location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with a location and an accepted resource.
|
||||
*
|
||||
* @param string $location
|
||||
* @param object $resource
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accepted($location, $resource): JsonResponse
|
||||
{
|
||||
return $resource
|
||||
->response()
|
||||
->setStatusCode(202)
|
||||
->header('Location', $location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with empty content.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function noContent(): Response
|
||||
{
|
||||
return (new Response)
|
||||
->setStatusCode(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an error response.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $statusCode
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function error($message, $statusCode)
|
||||
{
|
||||
throw new HttpException($statusCode, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 404 not found error.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function errorNotFound($message = 'Not Found')
|
||||
{
|
||||
$this->error($message, 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 400 bad request error.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function errorBadRequest($message = 'Bad Request')
|
||||
{
|
||||
$this->error($message, 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 403 forbidden error.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function errorForbidden($message = 'Forbidden')
|
||||
{
|
||||
$this->error($message, 403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 500 internal server error.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function errorInternal($message = 'Internal Error')
|
||||
{
|
||||
$this->error($message, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 401 unauthorized error.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function errorUnauthorized($message = 'Unauthorized')
|
||||
{
|
||||
$this->error($message, 401);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a 405 method not allowed error.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function errorMethodNotAllowed($message = 'Method Not Allowed')
|
||||
{
|
||||
$this->error($message, 405);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class FormRequest extends BaseFormRequest
|
||||
* @param string $offset
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return Arr::has(
|
||||
$this->route() ? $this->all() + $this->route()->parameters() : $this->all(),
|
||||
|
||||
@@ -41,16 +41,18 @@ abstract class PaymentController extends BaseController
|
||||
});
|
||||
}
|
||||
|
||||
public function show(Document $invoice, PaymentRequest $request)
|
||||
public function show(Document $invoice, PaymentRequest $request, $cards = [])
|
||||
{
|
||||
$this->setContactFirstLastName($invoice);
|
||||
|
||||
$confirm_url = $this->getConfirmUrl($invoice);
|
||||
|
||||
$html = view('partials.portal.payment_method.' . $this->type, [
|
||||
$html = view('components.payment_method.' . $this->type, [
|
||||
'setting' => $this->setting,
|
||||
'invoice' => $invoice,
|
||||
'confirm_url' => $confirm_url,
|
||||
'store_card' => !empty($this->setting['store_card']) ? true : false,
|
||||
'cards' => $cards,
|
||||
])->render();
|
||||
|
||||
return response()->json([
|
||||
@@ -101,15 +103,15 @@ abstract class PaymentController extends BaseController
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
$invoice_url = $this->getInvoiceUrl($invoice);
|
||||
$finish_url = $this->getFinishUrl($invoice);
|
||||
|
||||
if ($force_redirect || ($this->type == 'redirect')) {
|
||||
return redirect($invoice_url);
|
||||
return redirect($finish_url);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => $message,
|
||||
'redirect' => $invoice_url,
|
||||
'redirect' => $finish_url,
|
||||
'success' => true,
|
||||
'data' => false,
|
||||
]);
|
||||
@@ -122,6 +124,13 @@ abstract class PaymentController extends BaseController
|
||||
: URL::signedRoute('signed.invoices.show', [$invoice->id]);
|
||||
}
|
||||
|
||||
public function getFinishUrl($invoice)
|
||||
{
|
||||
return request()->isPortal($invoice->company_id)
|
||||
? route('portal.invoices.finish', $invoice->id)
|
||||
: URL::signedRoute('signed.invoices.finish', [$invoice->id]);
|
||||
}
|
||||
|
||||
public function getConfirmUrl($invoice)
|
||||
{
|
||||
return $this->getModuleUrl($invoice, 'confirm');
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\Http;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Setting\Setting as Request;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Uploads;
|
||||
use App\Utilities\Installer;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class SettingController extends Controller
|
||||
{
|
||||
use DateTime, Uploads;
|
||||
|
||||
public $redirect_route = '';
|
||||
|
||||
public $skip_keys = ['company_id', '_method', '_token', '_prefix'];
|
||||
|
||||
public $file_keys = ['company.logo', 'invoice.logo'];
|
||||
|
||||
public $uploaded_file_keys = ['company.uploaded_logo', 'invoice.uploaded_logo'];
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$fields = $request->all();
|
||||
$prefix = $request->get('_prefix', 'general');
|
||||
$company_id = $request->get('company_id');
|
||||
|
||||
if (empty($company_id)) {
|
||||
$company_id = company_id();
|
||||
}
|
||||
|
||||
$company = Company::find($company_id);
|
||||
|
||||
$total_companies = Company::count();
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
$real_key = $prefix . '.' . $key;
|
||||
|
||||
// Don't process unwanted keys
|
||||
if (in_array($key, $this->skip_keys)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// change dropzone middleware already uploaded file
|
||||
if (in_array($real_key, $this->uploaded_file_keys)) {
|
||||
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') {
|
||||
if (!in_array($value, config('language.allowed'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
user()->setAttribute('locale', $value)->save();
|
||||
}
|
||||
|
||||
if ($real_key == 'default.currency') {
|
||||
$currencies = Currency::enabled()->pluck('code')->toArray();
|
||||
|
||||
if (!in_array($value, $currencies)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$currency = Currency::code($value)->first();
|
||||
$currency->rate = '1';
|
||||
$currency->save();
|
||||
}
|
||||
|
||||
// If only 1 company
|
||||
if ($total_companies == 1) {
|
||||
$this->oneCompany($real_key, $value);
|
||||
}
|
||||
|
||||
setting()->set($real_key, $value);
|
||||
}
|
||||
|
||||
// Save all settings
|
||||
setting()->save();
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.settings', 2)]);
|
||||
|
||||
$redirect_url = !empty($this->redirect_route) ? route($this->redirect_route) : url()->previous();
|
||||
|
||||
$response = [
|
||||
'status' => null,
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => $message,
|
||||
'data' => null,
|
||||
'redirect' => $redirect_url,
|
||||
];
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
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;
|
||||
case 'email.protocol':
|
||||
Installer::updateEnv(['MAIL_MAILER' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_host':
|
||||
Installer::updateEnv(['MAIL_HOST' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_port':
|
||||
Installer::updateEnv(['MAIL_PORT' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_username':
|
||||
Installer::updateEnv(['MAIL_USERNAME' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_password':
|
||||
Installer::updateEnv(['MAIL_PASSWORD' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_encryption':
|
||||
Installer::updateEnv(['MAIL_ENCRYPTION' => '"' . $value . '"']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ abstract class Report
|
||||
|
||||
public function getCategories($types, $limit = false)
|
||||
{
|
||||
$model = Category::type($types)->orderBy('name');
|
||||
$model = Category::withSubCategory()->type($types)->orderBy('name');
|
||||
|
||||
if ($limit !== false) {
|
||||
$model->take(setting('default.select_limit'));
|
||||
@@ -183,14 +183,69 @@ abstract class Report
|
||||
|
||||
public function setRowNamesAndValues($event, $rows)
|
||||
{
|
||||
$nodes = [];
|
||||
|
||||
foreach ($event->class->dates as $date) {
|
||||
foreach ($event->class->tables as $table) {
|
||||
foreach ($event->class->tables as $table_key => $table_name) {
|
||||
foreach ($rows as $id => $name) {
|
||||
$event->class->row_names[$table][$id] = $name;
|
||||
$event->class->row_values[$table][$id][$date] = 0;
|
||||
$event->class->row_names[$table_key][$id] = $name;
|
||||
$event->class->row_values[$table_key][$id][$date] = 0;
|
||||
|
||||
$nodes[$id] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->setTreeNodes($event, $nodes);
|
||||
}
|
||||
|
||||
public function setTreeNodes($event, $nodes)
|
||||
{
|
||||
foreach ($event->class->tables as $table_key => $table_name) {
|
||||
foreach ($nodes as $id => $node) {
|
||||
$event->class->row_tree_nodes[$table_key][$id] = $node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategoriesNodes($categories)
|
||||
{
|
||||
$nodes = [];
|
||||
|
||||
foreach ($categories as $id => $name) {
|
||||
$category = Category::withSubCategory()->find($id);
|
||||
|
||||
if (!is_null($category->parent_id)) {
|
||||
unset($categories[$id]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$nodes[$id] = $this->getSubCategories($category);
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
public function getSubCategories($category)
|
||||
{
|
||||
if ($category->sub_categories->count() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sub_categories = [];
|
||||
|
||||
foreach ($category->sub_categories as $sub_category) {
|
||||
$sub_category->load('sub_categories');
|
||||
|
||||
$sub_categories[$sub_category->id] = $this->getSubCategories($sub_category);
|
||||
}
|
||||
|
||||
if (!empty($sub_categories)) {
|
||||
$sub_categories[$category->id] = null;
|
||||
}
|
||||
|
||||
return $sub_categories;
|
||||
}
|
||||
|
||||
public function getFormattedDate($event, $date)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+18
-19
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use Akaunting\Sortable\Traits\Sortable;
|
||||
use App\Events\Common\SearchStringApplied;
|
||||
use App\Events\Common\SearchStringApplying;
|
||||
use App\Traits\DateTime;
|
||||
@@ -9,9 +10,9 @@ use App\Traits\Owners;
|
||||
use App\Traits\Sources;
|
||||
use App\Traits\Tenants;
|
||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Laratrust\Contracts\Ownable;
|
||||
use Lorisleiva\LaravelSearchString\Concerns\SearchString;
|
||||
|
||||
@@ -30,30 +31,18 @@ abstract class Model extends Eloquent implements Ownable
|
||||
public $allAttributes = [];
|
||||
|
||||
/**
|
||||
* Create a new Eloquent model instance.
|
||||
* Fill the model with an array of attributes.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return void
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\MassAssignmentException
|
||||
*/
|
||||
public function __construct(array $attributes = [])
|
||||
public function fill(array $attributes)
|
||||
{
|
||||
$this->allAttributes = $attributes;
|
||||
|
||||
parent::__construct($attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the model in the database.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $options
|
||||
* @return bool
|
||||
*/
|
||||
public function update(array $attributes = [], array $options = [])
|
||||
{
|
||||
$this->allAttributes = $attributes;
|
||||
|
||||
return parent::update($attributes, $options);
|
||||
return parent::fill($attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,6 +220,16 @@ abstract class Model extends Eloquent implements Ownable
|
||||
return $query->where($this->qualifyColumn('created_by'), '<>', user_id());
|
||||
}
|
||||
|
||||
public function scopeIsRecurring(Builder $query): Builder
|
||||
{
|
||||
return $query->where($this->qualifyColumn('type'), 'like', '%-recurring');
|
||||
}
|
||||
|
||||
public function scopeIsNotRecurring(Builder $query): Builder
|
||||
{
|
||||
return $query->where($this->qualifyColumn('type'), 'not like', '%-recurring');
|
||||
}
|
||||
|
||||
public function ownerKey($owner)
|
||||
{
|
||||
if ($this->isNotOwnable()) {
|
||||
|
||||
@@ -6,11 +6,19 @@ use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification as BaseNotification;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class Notification extends BaseNotification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Custom mail subject, body, etc.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $custom_mail;
|
||||
|
||||
/**
|
||||
* Create a notification instance.
|
||||
*/
|
||||
@@ -33,31 +41,38 @@ abstract class Notification extends BaseNotification implements ShouldQueue
|
||||
/**
|
||||
* Initialise the mail representation of the notification.
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function initMessage()
|
||||
public function initMailMessage(): MailMessage
|
||||
{
|
||||
app('url')->defaults(['company_id' => company_id()]);
|
||||
|
||||
$message = (new MailMessage)
|
||||
->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject($this->getSubject())
|
||||
->view('partials.email.body', ['body' => $this->getBody()]);
|
||||
->view('components.email.body', ['body' => $this->getBody()]);
|
||||
|
||||
if (!empty($this->custom_mail['cc'])) {
|
||||
$message->cc($this->custom_mail['cc']);
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
public function getSubject()
|
||||
public function getSubject(): string
|
||||
{
|
||||
return $this->replaceTags($this->template->subject);
|
||||
return !empty($this->custom_mail['subject'])
|
||||
? $this->custom_mail['subject']
|
||||
: $this->replaceTags($this->template->subject);
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->replaceTags($this->template->body);
|
||||
$body = !empty($this->custom_mail['body']) ? $this->custom_mail['body'] : $this->replaceTags($this->template->body);
|
||||
|
||||
return $body . $this->getFooter();
|
||||
}
|
||||
|
||||
public function replaceTags($content)
|
||||
public function replaceTags(string $content): string
|
||||
{
|
||||
$pattern = $this->getTagsPattern();
|
||||
$replacement = $this->applyQuote($this->getTagsReplacement());
|
||||
@@ -65,7 +80,16 @@ abstract class Notification extends BaseNotification implements ShouldQueue
|
||||
return $this->revertQuote(preg_replace($pattern, $replacement, $content));
|
||||
}
|
||||
|
||||
public function getTagsPattern()
|
||||
public function getFooter()
|
||||
{
|
||||
$url = 'https://akaunting.com/lp/accounting-software?utm_source=email&utm_medium=software&utm_campaign=footer&utm_content=' . $this->template->alias;
|
||||
|
||||
$get_started = '<a href="' . $url . '" style="color: #676ba2; text-decoration: none;">' . trans('footer.get_started') . '</a>';
|
||||
|
||||
return view('components.email.footer', compact('url', 'get_started'));
|
||||
}
|
||||
|
||||
public function getTagsPattern(): array
|
||||
{
|
||||
$pattern = [];
|
||||
|
||||
@@ -76,17 +100,35 @@ abstract class Notification extends BaseNotification implements ShouldQueue
|
||||
return $pattern;
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getTagsReplacement()
|
||||
public function getTagsReplacement(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function applyQuote($vars)
|
||||
public function getTagsBinding(): array
|
||||
{
|
||||
$bindings = [];
|
||||
|
||||
$tags = $this->getTags();
|
||||
$replacements = $this->getTagsReplacement();
|
||||
|
||||
$wrappers = ['{', '}'];
|
||||
|
||||
foreach ($tags as $index => $tag) {
|
||||
$key = Str::replace($wrappers, '', $tag);
|
||||
|
||||
$bindings[$key] = $replacements[$index];
|
||||
}
|
||||
|
||||
return $bindings;
|
||||
}
|
||||
|
||||
public function applyQuote(array $vars): array
|
||||
{
|
||||
$new_vars = [];
|
||||
|
||||
@@ -97,8 +139,16 @@ abstract class Notification extends BaseNotification implements ShouldQueue
|
||||
return $new_vars;
|
||||
}
|
||||
|
||||
public function revertQuote($content)
|
||||
public function revertQuote(string $content): string
|
||||
{
|
||||
return str_replace('\\', '', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.0
|
||||
*/
|
||||
public function initMessage()
|
||||
{
|
||||
return $this->initMailMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use Monooso\Unobserve\CanMute;
|
||||
use Akaunting\MutableObserver\Traits\Mutable;
|
||||
|
||||
abstract class Observer
|
||||
{
|
||||
use CanMute;
|
||||
use Mutable;
|
||||
}
|
||||
|
||||
+123
-83
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use Akaunting\Apexcharts\Charts as Apexcharts;
|
||||
use App\Events\Report\DataLoaded;
|
||||
use App\Events\Report\DataLoading;
|
||||
use App\Events\Report\FilterApplying;
|
||||
@@ -12,17 +13,18 @@ use App\Events\Report\RowsShowing;
|
||||
use App\Exports\Common\Reports as Export;
|
||||
use App\Models\Common\Report as Model;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Traits\Charts;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\SearchString;
|
||||
use App\Utilities\Chartjs;
|
||||
use App\Traits\Translations;
|
||||
use App\Utilities\Date;
|
||||
use App\Utilities\Export as ExportHelper;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class Report
|
||||
{
|
||||
use Charts, DateTime, SearchString;
|
||||
use Charts, DateTime, SearchString, Translations;
|
||||
|
||||
public $model;
|
||||
|
||||
@@ -30,7 +32,9 @@ abstract class Report
|
||||
|
||||
public $category = 'reports.income_expense';
|
||||
|
||||
public $icon = 'fa fa-chart-pie';
|
||||
public $icon = 'donut_small';
|
||||
|
||||
public $type = 'detail';
|
||||
|
||||
public $has_money = true;
|
||||
|
||||
@@ -53,23 +57,21 @@ abstract class Report
|
||||
public $loaded = false;
|
||||
|
||||
public $chart = [
|
||||
'line' => [
|
||||
'width' => '0',
|
||||
'height' => '300',
|
||||
'options' => [
|
||||
'color' => '#6da252',
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
'bar' => [
|
||||
'colors' => [
|
||||
'#6da252',
|
||||
],
|
||||
],
|
||||
'dates' => [],
|
||||
'datasets' => [],
|
||||
'donut' => [
|
||||
//
|
||||
],
|
||||
];
|
||||
|
||||
public $column_name_width = 'report-column-name';
|
||||
public $column_value_width = 'report-column-value';
|
||||
|
||||
public $row_tree_nodes = [];
|
||||
|
||||
public function __construct(Model $model = null, $load_data = true)
|
||||
{
|
||||
$this->setGroups();
|
||||
@@ -126,6 +128,18 @@ abstract class Report
|
||||
return trans($this->category);
|
||||
}
|
||||
|
||||
public function getCategoryDescription()
|
||||
{
|
||||
if (!empty($this->category_description)) {
|
||||
return trans($this->category_description);
|
||||
}
|
||||
|
||||
return $this->findTranslation([
|
||||
$this->category . '_desc',
|
||||
$this->category . '_description',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
@@ -152,47 +166,77 @@ abstract class Report
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getChart()
|
||||
public function getCharts($table_key)
|
||||
{
|
||||
$chart = new Chartjs();
|
||||
return [
|
||||
'bar' => $this->getBarChart($table_key),
|
||||
'donut' => $this->getDonutChart($table_key),
|
||||
];
|
||||
}
|
||||
|
||||
if (!$type = $this->getSetting('chart')) {
|
||||
public function getBarChart($table_key)
|
||||
{
|
||||
$chart = new Apexcharts();
|
||||
|
||||
if (empty($this->chart)) {
|
||||
return $chart;
|
||||
}
|
||||
|
||||
$config = $this->chart[$type];
|
||||
$options = !empty($this->chart[$table_key]) ? $this->chart[$table_key]['bar'] : $this->chart['bar'];
|
||||
|
||||
$default_options = $this->getLineChartOptions();
|
||||
$chart->setType('bar')
|
||||
->setOptions($options)
|
||||
->setLabels(array_values($this->dates))
|
||||
->setDataset($this->tables[$table_key], 'column', array_values($this->footer_totals[$table_key]));
|
||||
|
||||
$options = array_merge($default_options, (array) $config['options']);
|
||||
return $chart;
|
||||
}
|
||||
|
||||
$chart->type($type)
|
||||
->width((int) $config['width'])
|
||||
->height((int) $config['height'])
|
||||
->options($options)
|
||||
->labels(!empty($config['dates']) ? array_values($config['dates']) : array_values($this->dates));
|
||||
public function getDonutChart($table_key)
|
||||
{
|
||||
$chart = new Apexcharts();
|
||||
|
||||
if (!empty($config['datasets'])) {
|
||||
foreach ($config['datasets'] as $dataset) {
|
||||
$chart->dataset($dataset['name'], 'line', array_values($dataset['totals']))
|
||||
->backgroundColor(isset($dataset['backgroundColor']) ? $dataset['backgroundColor'] : '#6da252')
|
||||
->color(isset($dataset['color']) ? $dataset['color'] : '#6da252')
|
||||
->options((array) $dataset['options'])
|
||||
->fill(false);
|
||||
}
|
||||
} else {
|
||||
foreach ($this->footer_totals as $total) {
|
||||
$chart->dataset($this->model->name, 'line', array_values($total))
|
||||
->backgroundColor(isset($config['backgroundColor']) ? $config['backgroundColor'] : '#6da252')
|
||||
->color(isset($config['color']) ? $config['color'] : '#6da252')
|
||||
->options([
|
||||
'borderWidth' => 4,
|
||||
'pointStyle' => 'line',
|
||||
])
|
||||
->fill(false);
|
||||
if (empty($this->chart)) {
|
||||
return $chart;
|
||||
}
|
||||
|
||||
$tmp_values = [];
|
||||
|
||||
if (! empty($this->row_values[$table_key])) {
|
||||
foreach ($this->row_values[$table_key] as $id => $dates) {
|
||||
$tmp_values[$id] = 0;
|
||||
|
||||
foreach ($dates as $date) {
|
||||
$tmp_values[$id] += $date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_values = collect($tmp_values)->sort()->reverse()->take(10)->all();
|
||||
|
||||
$total = array_sum($tmp_values);
|
||||
$total = !empty($total) ? $total : 1;
|
||||
|
||||
$group = $this->getSetting('group');
|
||||
|
||||
$labels = $colors = $values = [];
|
||||
|
||||
foreach ($tmp_values as $id => $value) {
|
||||
$labels[$id] = $this->row_names[$table_key][$id];
|
||||
|
||||
$colors[$id] = ($group == 'category') ? Category::find($id)?->color : '#' . dechex(rand(0x000000, 0xFFFFFF));
|
||||
|
||||
$values[$id] = round(($value * 100 / $total), 0);
|
||||
}
|
||||
|
||||
$options = !empty($this->chart[$table_key]) ? $this->chart[$table_key]['donut'] : $this->chart['donut'];
|
||||
|
||||
$chart->setType('donut')
|
||||
->setOptions($options)
|
||||
->setLabels(array_values($labels))
|
||||
->setColors(array_values($colors))
|
||||
->setDataset($this->tables[$table_key], 'donut', array_values($values));
|
||||
|
||||
return $chart;
|
||||
}
|
||||
|
||||
@@ -208,7 +252,7 @@ abstract class Report
|
||||
|
||||
public function export()
|
||||
{
|
||||
return ExportHelper::toExcel(new Export($this->views['content'], $this), $this->model->name);
|
||||
return ExportHelper::toExcel(new Export($this->views[$this->type], $this), $this->model->name);
|
||||
}
|
||||
|
||||
public function setColumnWidth()
|
||||
@@ -221,10 +265,10 @@ abstract class Report
|
||||
|
||||
switch ($period) {
|
||||
case 'quarterly':
|
||||
$width = 'col-sm-2';
|
||||
$width = 'w-2/12 col-2';
|
||||
break;
|
||||
case 'yearly':
|
||||
$width = 'col-sm-4';
|
||||
$width = 'w-4/12 col-4';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -243,31 +287,41 @@ abstract class Report
|
||||
public function setViews()
|
||||
{
|
||||
$this->views = [
|
||||
'chart' => 'partials.reports.chart',
|
||||
'content' => 'partials.reports.content',
|
||||
'content.header' => 'partials.reports.content.header',
|
||||
'content.footer' => 'partials.reports.content.footer',
|
||||
'show' => 'partials.reports.show',
|
||||
'header' => 'partials.reports.header',
|
||||
'filter' => 'partials.reports.filter',
|
||||
'print' => 'partials.reports.print',
|
||||
'table' => 'partials.reports.table',
|
||||
'table.footer' => 'partials.reports.table.footer',
|
||||
'table.header' => 'partials.reports.table.header',
|
||||
'table.rows' => 'partials.reports.table.rows',
|
||||
'show' => 'components.reports.show',
|
||||
'print' => 'components.reports.print',
|
||||
'filter' => 'components.reports.filter',
|
||||
|
||||
'detail' => 'components.reports.detail',
|
||||
'detail.content.header' => 'components.reports.detail.content.header',
|
||||
'detail.content.footer' => 'components.reports.detail.content.footer',
|
||||
'detail.table' => 'components.reports.detail.table',
|
||||
'detail.table.header' => 'components.reports.detail.table.header',
|
||||
'detail.table.body' => 'components.reports.detail.table.body',
|
||||
'detail.table.row' => 'components.reports.detail.table.row',
|
||||
'detail.table.footer' => 'components.reports.detail.table.footer',
|
||||
|
||||
'summary' => 'components.reports.summary',
|
||||
'summary.content.header' => 'components.reports.summary.content.header',
|
||||
'summary.content.footer' => 'components.reports.summary.content.footer',
|
||||
'summary.table' => 'components.reports.summary.table',
|
||||
'summary.table.header' => 'components.reports.summary.table.header',
|
||||
'summary.table.body' => 'components.reports.summary.table.body',
|
||||
'summary.table.row' => 'components.reports.summary.table.row',
|
||||
'summary.table.footer' => 'components.reports.summary.table.footer',
|
||||
'summary.chart' => 'components.reports.summary.chart',
|
||||
];
|
||||
}
|
||||
|
||||
public function setTables()
|
||||
{
|
||||
$this->tables = [
|
||||
'default' => 'default',
|
||||
'default' => trans_choice('general.totals', 1),
|
||||
];
|
||||
}
|
||||
|
||||
public function setDates()
|
||||
{
|
||||
if (!$period = $this->getSetting('period')) {
|
||||
if (! $period = $this->getSetting('period')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -299,8 +353,8 @@ abstract class Report
|
||||
|
||||
$this->dates[] = $date;
|
||||
|
||||
foreach ($this->tables as $table) {
|
||||
$this->footer_totals[$table][$date] = 0;
|
||||
foreach ($this->tables as $table_key => $table_name) {
|
||||
$this->footer_totals[$table_key][$date] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -498,13 +552,17 @@ abstract class Report
|
||||
return $this->model->settings->$name ?? $default;
|
||||
}
|
||||
|
||||
public function getBasis()
|
||||
{
|
||||
return $this->getSearchStringValue('basis', $this->getSetting('basis'));
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
return [
|
||||
$this->getGroupField(),
|
||||
$this->getPeriodField(),
|
||||
$this->getBasisField(),
|
||||
$this->getChartField(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -513,7 +571,7 @@ abstract class Report
|
||||
$this->setGroups();
|
||||
|
||||
return [
|
||||
'type' => 'selectGroup',
|
||||
'type' => 'select',
|
||||
'name' => 'group',
|
||||
'title' => trans('general.group_by'),
|
||||
'icon' => 'folder',
|
||||
@@ -528,7 +586,7 @@ abstract class Report
|
||||
public function getPeriodField()
|
||||
{
|
||||
return [
|
||||
'type' => 'selectGroup',
|
||||
'type' => 'select',
|
||||
'name' => 'period',
|
||||
'title' => trans('general.period'),
|
||||
'icon' => 'calendar',
|
||||
@@ -547,7 +605,7 @@ abstract class Report
|
||||
public function getBasisField()
|
||||
{
|
||||
return [
|
||||
'type' => 'selectGroup',
|
||||
'type' => 'select',
|
||||
'name' => 'basis',
|
||||
'title' => trans('general.basis'),
|
||||
'icon' => 'file',
|
||||
@@ -561,22 +619,4 @@ abstract class Report
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getChartField()
|
||||
{
|
||||
return [
|
||||
'type' => 'selectGroup',
|
||||
'name' => 'chart',
|
||||
'title' => trans_choice('general.charts', 1),
|
||||
'icon' => 'chart-pie',
|
||||
'values' => [
|
||||
'0' => trans('general.disabled'),
|
||||
'line' => trans('reports.charts.line'),
|
||||
],
|
||||
'selected' => '0',
|
||||
'attributes' => [
|
||||
'required' => 'required',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View;
|
||||
|
||||
use Illuminate\View\Component as BaseComponent;
|
||||
|
||||
abstract class Component extends BaseComponent
|
||||
{
|
||||
public function getParentData($key, $default = null)
|
||||
{
|
||||
return app('view')->getConsumableComponentData($key, $default);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,503 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components\Contacts;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
abstract class Form extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'contact';
|
||||
public const DEFAULT_TYPE = 'customer';
|
||||
public const DEFAULT_PLURAL_TYPE = 'customers';
|
||||
|
||||
/* -- Main Start -- */
|
||||
public $type;
|
||||
|
||||
public $contact;
|
||||
|
||||
public $model;
|
||||
/* -- Main End -- */
|
||||
|
||||
/* -- Content Start -- */
|
||||
public $formId;
|
||||
|
||||
public $formRoute;
|
||||
|
||||
public $formMethod;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSectionGeneral;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSectionBilling;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSectionAddress;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionGeneralTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionGeneralDescription;
|
||||
|
||||
/** @var bool */
|
||||
public $hideName;
|
||||
|
||||
/** @var string */
|
||||
public $textName;
|
||||
|
||||
/** @var string */
|
||||
public $classNameFromGroupClass;
|
||||
|
||||
/** @var bool */
|
||||
public $hideEmail;
|
||||
|
||||
/** @var string */
|
||||
public $textEmail;
|
||||
|
||||
/** @var bool */
|
||||
public $hidePhone;
|
||||
|
||||
/** @var string */
|
||||
public $textPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideWebsite;
|
||||
|
||||
/** @var string */
|
||||
public $textWebsite;
|
||||
|
||||
/** @var bool */
|
||||
public $hideReference;
|
||||
|
||||
/** @var string */
|
||||
public $textReference;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCanLogin;
|
||||
|
||||
/** @var bool */
|
||||
public $hideLogo;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionBillingTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionBillingDescription;
|
||||
|
||||
/** @var bool */
|
||||
public $hideTaxNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textTaxNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCurrency;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionAddressTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textSectionAddressDescription;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAddress;
|
||||
|
||||
/** @var string */
|
||||
public $textAddress;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCity;
|
||||
|
||||
/** @var string */
|
||||
public $textCity;
|
||||
|
||||
/** @var bool */
|
||||
public $hideZipCode;
|
||||
|
||||
/** @var string */
|
||||
public $textZipCode;
|
||||
|
||||
/** @var bool */
|
||||
public $hideState;
|
||||
|
||||
/** @var string */
|
||||
public $textState;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCountry;
|
||||
|
||||
/** @var string */
|
||||
public $cancelRoute;
|
||||
/* -- Content End -- */
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, $model = false, $contact = false,
|
||||
string $formId = 'contact', $formRoute = '', $formMethod = '',
|
||||
bool $hideSectionGeneral = false, bool $hideSectionBilling = false, bool $hideSectionAddress = false,
|
||||
string $textSectionGeneralTitle = '', string $textSectionGeneralDescription = '',
|
||||
bool $hideName = false, string $textName = '', string $classNameFromGroupClass = '',
|
||||
bool $hideEmail = false, string $textEmail = '',
|
||||
bool $hidePhone = false, string $textPhone = '',
|
||||
bool $hideWebsite = false, string $textWebsite = '',
|
||||
bool $hideReference = false, string $textReference = '',
|
||||
bool $hideCanLogin = false,
|
||||
bool $hideLogo = false,
|
||||
string $textSectionBillingTitle = '', string $textSectionBillingDescription = '',
|
||||
bool $hideTaxNumber = false, string $textTaxNumber = '',
|
||||
bool $hideCurrency = false,
|
||||
string $textSectionAddressTitle = '', string $textSectionAddressDescription = '',
|
||||
bool $hideAddress = false, string $textAddress = '',
|
||||
bool $hideCity = false, string $textCity = '',
|
||||
bool $hideZipCode = false, string $textZipCode = '',
|
||||
bool $hideState = false, string $textState = '',
|
||||
bool $hideCountry = false,
|
||||
string $cancelRoute = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
|
||||
$this->model = ! empty($model) ? $model : $contact;
|
||||
$this->contact = $this->model;
|
||||
|
||||
/* -- Content Start -- */
|
||||
$this->formId = $formId;
|
||||
$this->formRoute = $this->getFormRoute($type, $formRoute, $this->model);
|
||||
$this->formMethod = $this->getFormMethod($type, $formMethod, $this->model);
|
||||
|
||||
$this->hideSectionGeneral = $hideSectionGeneral;
|
||||
$this->hideSectionBilling = $hideSectionBilling;
|
||||
$this->hideSectionAddress = $hideSectionAddress;
|
||||
|
||||
/* -- General Start -- */
|
||||
$this->textSectionGeneralTitle = $this->getTextSectionGeneralTitle($type, $textSectionGeneralTitle);
|
||||
$this->textSectionGeneralDescription = $this->getTextSectionGeneralDescription($type, $textSectionGeneralDescription);
|
||||
|
||||
$this->hideName = $hideName;
|
||||
$this->textName = $this->getTextName($type, $textName);
|
||||
$this->classNameFromGroupClass = $this->getClassNameFormGroupClass($type, $classNameFromGroupClass);
|
||||
|
||||
$this->hideEmail = $hideEmail;
|
||||
$this->textEmail = $this->getTextEmail($type, $textEmail);
|
||||
|
||||
$this->hidePhone = $hidePhone;
|
||||
$this->textPhone = $this->getTextPhone($type, $textPhone);
|
||||
|
||||
$this->hideWebsite = $hideWebsite;
|
||||
$this->textWebsite = $this->getTextWebsite($type, $textWebsite);
|
||||
|
||||
$this->hideReference = $hideReference;
|
||||
$this->textReference = $this->getTextReference($type, $textReference);
|
||||
|
||||
$this->hideCanLogin = $hideCanLogin;
|
||||
$this->hideLogo = $hideLogo;
|
||||
/* -- General End -- */
|
||||
|
||||
/* -- Billing Start -- */
|
||||
$this->textSectionBillingTitle = $this->getTextSectionBillingTitle($type, $textSectionBillingTitle);
|
||||
$this->textSectionBillingDescription = $this->getTextSectionBillingDescription($type, $textSectionBillingDescription);
|
||||
|
||||
$this->hideTaxNumber = $hideTaxNumber;
|
||||
$this->textTaxNumber = $this->getTextTaxNumber($type, $textTaxNumber);
|
||||
|
||||
$this->hideCurrency = $hideCurrency;
|
||||
/* -- Billing End -- */
|
||||
|
||||
/* -- Address Start -- */
|
||||
$this->textSectionAddressTitle = $this->getTextSectionAddressTitle($type, $textSectionAddressTitle);
|
||||
$this->textSectionAddressDescription = $this->getTextSectionAddressDescription($type, $textSectionAddressDescription);
|
||||
|
||||
$this->hideAddress = $hideAddress;
|
||||
$this->textAddress = $this->getTextAddress($type, $textAddress);
|
||||
|
||||
$this->hideCity = $hideCity;
|
||||
$this->textCity = $this->getTextCity($type, $textCity);
|
||||
|
||||
$this->hideZipCode = $hideZipCode;
|
||||
$this->textZipCode = $this->getTextZipCode($type, $textZipCode);
|
||||
|
||||
$this->hideState = $hideState;
|
||||
$this->textState = $this->getTextState($type, $textState);
|
||||
|
||||
$this->hideState = $hideTaxNumber;
|
||||
/* -- Address End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
$this->cancelRoute = $this->getCancelRoute($type, $cancelRoute);
|
||||
/* -- Buttons End -- */
|
||||
/* -- Content End -- */
|
||||
|
||||
// Set Parent data
|
||||
$this->setParentData();
|
||||
}
|
||||
|
||||
/* -- Content Start -- */
|
||||
/* -- General Start -- */
|
||||
protected function getTextSectionGeneralTitle($type, $textSectionGeneralTitle)
|
||||
{
|
||||
if (! empty($textSectionGeneralTitle)) {
|
||||
return $textSectionGeneralTitle;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_general_title', 'general');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.general';
|
||||
}
|
||||
|
||||
protected function getTextSectionGeneralDescription($type, $textSectionGeneralDescription)
|
||||
{
|
||||
if (! empty($textSectionGeneralDescription)) {
|
||||
return $textSectionGeneralDescription;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_general_description', 'form_description.general');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'customers.form_description.general';
|
||||
}
|
||||
|
||||
protected function getTextName($type, $textName)
|
||||
{
|
||||
if (! empty($textName)) {
|
||||
return $textName;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'name', 'name');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.name';
|
||||
}
|
||||
|
||||
protected function getClassNameFormGroupClass($type, $classNameFromGroupClass)
|
||||
{
|
||||
if (! empty($classNameFromGroupClass)) {
|
||||
return $classNameFromGroupClass;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'name');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'sm:col-span-6';
|
||||
}
|
||||
|
||||
protected function getTextEmail($type, $textEmail)
|
||||
{
|
||||
if (! empty($textEmail)) {
|
||||
return $textEmail;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'email', 'email');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.email';
|
||||
}
|
||||
|
||||
protected function getTextPhone($type, $textPhone)
|
||||
{
|
||||
if (! empty($textPhone)) {
|
||||
return $textPhone;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'phone', 'phone');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.phone';
|
||||
}
|
||||
|
||||
protected function getTextWebsite($type, $textWebsite)
|
||||
{
|
||||
if (! empty($textWebsite)) {
|
||||
return $textWebsite;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'website', 'website');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.website';
|
||||
}
|
||||
|
||||
protected function getTextReference($type, $textReference)
|
||||
{
|
||||
if (! empty($textReference)) {
|
||||
return $textReference;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'reference', 'reference');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.reference';
|
||||
}
|
||||
/* -- General End -- */
|
||||
|
||||
/* -- Billing Start -- */
|
||||
protected function getTextSectionBillingTitle($type, $textSectionBillingTitle)
|
||||
{
|
||||
if (! empty($textSectionBillingTitle)) {
|
||||
return $textSectionBillingTitle;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_billing_title');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'items.billing';
|
||||
}
|
||||
|
||||
protected function getTextSectionBillingDescription($type, $textSectionBillingDescription)
|
||||
{
|
||||
if (! empty($textSectionBillingDescription)) {
|
||||
return $textSectionBillingDescription;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_billing_description');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'customers.form_description.billing';
|
||||
}
|
||||
|
||||
protected function getTextTaxNumber($type, $textTaxNumber)
|
||||
{
|
||||
if (! empty($textTaxNumber)) {
|
||||
return $textTaxNumber;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'tax_number', 'tax_number');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.tax_number';
|
||||
}
|
||||
/* -- Billing End -- */
|
||||
|
||||
/* -- Address Start -- */
|
||||
protected function getTextSectionAddressTitle($type, $textSectionAddressTitle)
|
||||
{
|
||||
if (! empty($textSectionAddressTitle)) {
|
||||
return $textSectionAddressTitle;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_address_title', 'address');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.address';
|
||||
}
|
||||
|
||||
protected function getTextSectionAddressDescription($type, $textSectionAddressDescription)
|
||||
{
|
||||
if (! empty($textSectionAddressDescription)) {
|
||||
return $textSectionAddressDescription;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'section_address_description');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'customers.form_description.address';
|
||||
}
|
||||
|
||||
protected function getTextAddress($type, $textAddress)
|
||||
{
|
||||
if (! empty($textAddress)) {
|
||||
return $textAddress;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'address', 'address');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.address';
|
||||
}
|
||||
|
||||
protected function getTextCity($type, $textCity)
|
||||
{
|
||||
if (! empty($textCity)) {
|
||||
return $textCity;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'city', 'cities');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.cities';
|
||||
}
|
||||
|
||||
protected function getTextZipCode($type, $textZipCode)
|
||||
{
|
||||
if (! empty($textZipCode)) {
|
||||
return $textZipCode;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'zip_code', 'zip_code');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.zip_code';
|
||||
}
|
||||
|
||||
protected function getTextState($type, $textState)
|
||||
{
|
||||
if (! empty($textState)) {
|
||||
return $textState;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'state', 'state');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.state';
|
||||
}
|
||||
/* -- Address End -- */
|
||||
/* -- Content End -- */
|
||||
}
|
||||
@@ -0,0 +1,492 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components\Contacts;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\Documents;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
abstract class Index extends Component
|
||||
{
|
||||
use Documents, ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'contact';
|
||||
public const DEFAULT_TYPE = 'customer';
|
||||
public const DEFAULT_PLURAL_TYPE = 'customers';
|
||||
|
||||
/* -- Main Start -- */
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
public $contacts;
|
||||
|
||||
/** @var string */
|
||||
public $textPage;
|
||||
|
||||
/** @var string */
|
||||
public $group;
|
||||
|
||||
/** @var string */
|
||||
public $page;
|
||||
|
||||
public $permissionCreate;
|
||||
/* -- Main End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
public $checkPermissionCreate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCreate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideImport;
|
||||
|
||||
/** @var bool */
|
||||
public $hideExport;
|
||||
|
||||
/** @var string */
|
||||
public $createRoute;
|
||||
|
||||
/** @var string */
|
||||
public $importRoute;
|
||||
|
||||
/** @var array */
|
||||
public $importRouteParameters;
|
||||
|
||||
/** @var string */
|
||||
public $exportRoute;
|
||||
/* -- Buttons End -- */
|
||||
|
||||
/* -- Content Start -- */
|
||||
/** @var bool */
|
||||
public $hideEmptyPage;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSummary;
|
||||
|
||||
public $summaryItems;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSearchString;
|
||||
|
||||
/** @var bool */
|
||||
public $hideBulkAction;
|
||||
|
||||
/** @var string */
|
||||
public $searchStringModel;
|
||||
|
||||
/** @var string */
|
||||
public $bulkActionClass;
|
||||
|
||||
/** @var array */
|
||||
public $bulkActionRouteParameters;
|
||||
|
||||
/** @var string */
|
||||
public $searchRoute;
|
||||
|
||||
/** @var string */
|
||||
public $classBulkAction;
|
||||
|
||||
/** @var bool */
|
||||
public $showPicture;
|
||||
|
||||
/** @var bool */
|
||||
public $hideName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideTaxNumber;
|
||||
|
||||
/** @var string */
|
||||
public $classNameAndTaxNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textName;
|
||||
|
||||
/** @var string */
|
||||
public $textTaxNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideEmail;
|
||||
|
||||
/** @var bool */
|
||||
public $hidePhone;
|
||||
|
||||
/** @var string */
|
||||
public $classEmailAndPhone;
|
||||
|
||||
/** @var string */
|
||||
public $textEmail;
|
||||
|
||||
/** @var string */
|
||||
public $textPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCountry;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCurrencyCode;
|
||||
|
||||
/** @var string */
|
||||
public $classCountryAndCurrencyCode;
|
||||
|
||||
/** @var string */
|
||||
public $textCountry;
|
||||
|
||||
/** @var string */
|
||||
public $textCurrencyCode;
|
||||
|
||||
/** @var bool */
|
||||
public $hideOpen;
|
||||
|
||||
/** @var bool */
|
||||
public $hideOverdue;
|
||||
|
||||
/** @var string */
|
||||
public $classOpenAndOverdue;
|
||||
|
||||
/** @var string */
|
||||
public $textOpen;
|
||||
|
||||
/** @var string */
|
||||
public $textOverdue;
|
||||
/* -- Content End -- */
|
||||
|
||||
/* -- Empty Start -- */
|
||||
/** @var string */
|
||||
public $imageEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $textEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $urlDocsPath;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonShow;
|
||||
/* -- Empty End -- */
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, $contacts = [], string $textPage = '', string $group = '', string $page = '',
|
||||
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
|
||||
bool $checkPermissionCreate = true,
|
||||
bool $hideCreate = false, bool $hideImport = false, bool $hideExport = false,
|
||||
string $createRoute = '', string $importRoute = '', array $importRouteParameters = [], string $exportRoute = '',
|
||||
bool $hideEmptyPage = false, bool $hideSummary = false, $summaryItems = [], bool $hideSearchString = false, bool $hideBulkAction = false,
|
||||
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '',
|
||||
string $classBulkAction = '',
|
||||
bool $showPicture = false, bool $hideName = false, bool $hideTaxNumber = false, string $classNameAndTaxNumber = '', string $textName = '', string $textTaxNumber = '',
|
||||
bool $hideEmail = false, bool $hidePhone = false, string $classEmailAndPhone = '', string $textEmail = '', string $textPhone = '',
|
||||
bool $hideCountry = false, bool $hideCurrencyCode = false, string $classCountryAndCurrencyCode = '', string $textCountry = '', string $textCurrencyCode = '',
|
||||
bool $hideOpen = false, bool $hideOverdue = false, string $classOpenAndOverdue = '', string $textOpen = '', string $textOverdue = '',
|
||||
string $imageEmptyPage = '', string $textEmptyPage = '', string $urlDocsPath = '', string $routeButtonShow = '',
|
||||
) {
|
||||
/* -- Main Start -- */
|
||||
$this->type = $type;
|
||||
$this->group = $this->getGroup($type, $group);
|
||||
$this->page = $this->getPage($type, $page);
|
||||
$this->contacts = ($contacts) ? $contacts : collect();
|
||||
$this->textPage = $this->getTextPage($type, $textPage);
|
||||
|
||||
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
|
||||
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
|
||||
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
|
||||
/* -- Main End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
$this->checkPermissionCreate = $checkPermissionCreate;
|
||||
|
||||
$this->hideCreate = $hideCreate;
|
||||
$this->hideImport = $hideImport;
|
||||
$this->hideExport = $hideExport;
|
||||
|
||||
$this->routeButtonShow = $this->getRouteButtonShow($type, $routeButtonShow);
|
||||
$this->createRoute = $this->getCreateRoute($type, $createRoute);
|
||||
$this->importRoute = $this->getImportRoute($importRoute);
|
||||
$this->importRouteParameters = $this->getImportRouteParameters($type, $importRouteParameters);
|
||||
$this->exportRoute = $this->getExportRoute($type, $exportRoute);
|
||||
/* -- Buttons End -- */
|
||||
|
||||
/* -- Content Start -- */
|
||||
$this->hideEmptyPage = $hideEmptyPage;
|
||||
|
||||
$this->hideSummary = $hideSummary;
|
||||
$this->summaryItems = $this->getSummaryItems($type, $summaryItems);
|
||||
|
||||
$this->hideSearchString = $hideSearchString;
|
||||
$this->hideBulkAction = $hideBulkAction;
|
||||
|
||||
$this->searchStringModel = $this->getSearchStringModel($type, $searchStringModel);
|
||||
|
||||
$this->bulkActionClass = $this->getBulkActionClass($type, $bulkActionClass);
|
||||
$this->bulkActionRouteParameters = $this->getBulkActionRouteParameters($type, $bulkActionRouteParameters);
|
||||
|
||||
$this->searchRoute = $this->getIndexRoute($type, $searchRoute);
|
||||
|
||||
$this->classBulkAction = $this->getClassBulkAction($type, $classBulkAction);
|
||||
|
||||
$this->showPicture = $showPicture;
|
||||
$this->hideName = $hideName;
|
||||
$this->hideTaxNumber = $hideTaxNumber;
|
||||
$this->classNameAndTaxNumber = $this->getClassNameAndTaxNumber($type, $classNameAndTaxNumber);
|
||||
$this->textName = $this->getTextName($type, $textName);
|
||||
$this->textTaxNumber = $this->getTextTaxNumber($type, $textTaxNumber);
|
||||
|
||||
$this->hideEmail = $hideEmail;
|
||||
$this->hidePhone = $hidePhone;
|
||||
$this->classEmailAndPhone = $this->getClassEmailAndPhone($type, $classEmailAndPhone);
|
||||
$this->textEmail = $this->getTextEmail($type, $textEmail);
|
||||
$this->textPhone = $this->getTextPhone($type, $textPhone);
|
||||
|
||||
$this->hideCountry = $hideCountry;
|
||||
$this->hideCurrencyCode = $hideCurrencyCode;
|
||||
$this->classCountryAndCurrencyCode = $this->getClassCountryAndCurrencyCode($type, $classCountryAndCurrencyCode);
|
||||
$this->textCountry = $this->getTextCountry($type, $textCountry);
|
||||
$this->textCurrencyCode = $this->getTextCurrencyCode($type, $textCurrencyCode);
|
||||
|
||||
$this->hideOpen = $hideOpen;
|
||||
$this->hideOverdue = $hideOverdue;
|
||||
$this->classOpenAndOverdue = $this->getClassOpenAndOverdue($type, $classOpenAndOverdue);
|
||||
$this->textOpen = $this->getTextOpen($type, $textOpen);
|
||||
$this->textOverdue = $this->getTextOverdue($type, $textOverdue);
|
||||
/* -- Content End -- */
|
||||
|
||||
/* -- Empty Start -- */
|
||||
$this->imageEmptyPage = $this->getImageEmptyPage($type, $imageEmptyPage);
|
||||
$this->textEmptyPage = $this->getTextEmptyPage($type, $textEmptyPage);
|
||||
$this->urlDocsPath = $this->getUrlDocsPath($type, $urlDocsPath);
|
||||
/* -- Empty End -- */
|
||||
|
||||
// Set Parent data
|
||||
$this->setParentData();
|
||||
}
|
||||
|
||||
public function getSummaryItems($type, $summaryItems)
|
||||
{
|
||||
if (! empty($summaryItems)) {
|
||||
return $summaryItems;
|
||||
}
|
||||
|
||||
$route = $this->getIndexRoute($type, null);
|
||||
|
||||
$document_type = config('type.contact.' . $type . '.document_type', 'invoice');
|
||||
|
||||
$totals = $this->getTotalsForFutureDocuments($document_type);
|
||||
|
||||
$items = [];
|
||||
|
||||
foreach ($totals as $key => $total) {
|
||||
$items[] = [
|
||||
'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key),
|
||||
'href' => route($route, ['search' => 'status:' . $key]),
|
||||
'amount' => money($total, setting('default.currency'), true),
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/* -- Content Start -- */
|
||||
protected function getClassNameAndTaxNumber($type, $classNameAndTaxNumber)
|
||||
{
|
||||
if (! empty($classNameAndTaxNumber)) {
|
||||
return $classNameAndTaxNumber;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'name_and_tax_number');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-6/12 sm:w-3/12 truncate';
|
||||
}
|
||||
|
||||
protected function getTextName($type, $textName)
|
||||
{
|
||||
if (! empty($textName)) {
|
||||
return $textName;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'name', 'name');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.name';
|
||||
}
|
||||
|
||||
protected function getTextTaxNumber($type, $textTaxNumber)
|
||||
{
|
||||
if (! empty($textTaxNumber)) {
|
||||
return $textTaxNumber;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'tax_number', 'tax_number');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.tax_number';
|
||||
}
|
||||
|
||||
protected function getClassEmailAndPhone($type, $classEmailAndPhone)
|
||||
{
|
||||
if (! empty($classEmailAndPhone)) {
|
||||
return $classEmailAndPhone;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'email_and_phone');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-3/12 hidden sm:table-cell';
|
||||
}
|
||||
|
||||
protected function getTextEmail($type, $textEmail)
|
||||
{
|
||||
if (! empty($textEmail)) {
|
||||
return $textEmail;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'email', 'email');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.email';
|
||||
}
|
||||
|
||||
protected function getTextPhone($type, $textPhone)
|
||||
{
|
||||
if (! empty($textPhone)) {
|
||||
return $textPhone;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'phone', 'phone');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.phone';
|
||||
}
|
||||
|
||||
protected function getClassCountryAndCurrencyCode($type, $classCountryAndCurrencyCode)
|
||||
{
|
||||
if (! empty($classCountryAndCurrencyCode)) {
|
||||
return $classCountryAndCurrencyCode;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'country_and_currency_code');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-3/12 hidden sm:table-cell';
|
||||
}
|
||||
|
||||
protected function getTextCountry($type, $textCountry)
|
||||
{
|
||||
if (! empty($textCountry)) {
|
||||
return $textCountry;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'country', 'countries');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.countries';
|
||||
}
|
||||
|
||||
protected function getTextCurrencyCode($type, $textCurrencyCode)
|
||||
{
|
||||
if (! empty($textCurrencyCode)) {
|
||||
return $textCurrencyCode;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'currency_code', 'currencies');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.currencies';
|
||||
}
|
||||
|
||||
protected function getClassOpenAndOverdue($type, $classOpenAndOverdue)
|
||||
{
|
||||
if (! empty($classOpenAndOverdue)) {
|
||||
return $classOpenAndOverdue;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'open_and_overdue');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-6/12 sm:w-3/12';
|
||||
}
|
||||
|
||||
protected function getTextOpen($type, $textOpen)
|
||||
{
|
||||
if (! empty($textOpen)) {
|
||||
return $textOpen;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'open', 'open');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.open';
|
||||
}
|
||||
|
||||
protected function getTextOverdue($type, $textOverdue)
|
||||
{
|
||||
if (! empty($textOverdue)) {
|
||||
return $textOverdue;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'overdue', 'overdue');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.overdue';
|
||||
}
|
||||
|
||||
protected function getRouteButtonShow($type, $routeButtonShow)
|
||||
{
|
||||
if (!empty($routeButtonShow)) {
|
||||
return $routeButtonShow;
|
||||
}
|
||||
|
||||
//example route parameter.
|
||||
$parameter = 1;
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'show', $parameter);
|
||||
|
||||
if (!empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'customer.show';
|
||||
}
|
||||
/* -- Content End -- */
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components\Contacts;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
abstract class Show extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'contact';
|
||||
public const DEFAULT_TYPE = 'customer';
|
||||
public const DEFAULT_PLURAL_TYPE = 'customers';
|
||||
|
||||
/* -- Main Start -- */
|
||||
public $type;
|
||||
|
||||
public $contact;
|
||||
|
||||
public $model;
|
||||
|
||||
public $permissionCreate;
|
||||
|
||||
public $permissionUpdate;
|
||||
|
||||
public $permissionDelete;
|
||||
/* -- Main End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
public $hideNewDropdown;
|
||||
|
||||
public $hideButtonDocument;
|
||||
|
||||
public $hideButtonTransaction;
|
||||
|
||||
public $permissionCreateDocument;
|
||||
|
||||
public $permissionCreateTransaction;
|
||||
|
||||
public $routeButtonDocument;
|
||||
|
||||
public $routeButtonTransaction;
|
||||
|
||||
public $textDocument;
|
||||
|
||||
public $textTransaction;
|
||||
|
||||
public $hideButtonEdit;
|
||||
|
||||
public $routeButtonEdit;
|
||||
|
||||
public $hideActionsDropdown;
|
||||
|
||||
public $hideButtonDuplicate;
|
||||
|
||||
public $routeButtonDuplicate;
|
||||
|
||||
public $hideButtonDelete;
|
||||
|
||||
public $routeButtonDelete;
|
||||
|
||||
public $textDeleteModal;
|
||||
/* -- Buttons End -- */
|
||||
|
||||
/* -- Profile Start -- */
|
||||
public $hideTopLeft;
|
||||
|
||||
public $hideAvatar;
|
||||
|
||||
public $hideEmail;
|
||||
|
||||
public $hidePhone;
|
||||
|
||||
public $hideTopRight;
|
||||
|
||||
public $hideOverdue;
|
||||
|
||||
public $hideOpen;
|
||||
|
||||
public $hidePaid;
|
||||
|
||||
public $hideBottomLeft;
|
||||
|
||||
public $hideAddress;
|
||||
|
||||
public $hideTaxNumber;
|
||||
|
||||
public $hideWebsite;
|
||||
|
||||
public $hideReference;
|
||||
|
||||
public $hideUser;
|
||||
|
||||
public $hideBottomRight;
|
||||
/* -- Profile End -- */
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, $model = false, $contact = false,
|
||||
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
|
||||
bool $hideNewDropdown = false, bool $hideButtonDocument = false, $hideButtonTransaction = false,
|
||||
string $permissionCreateDocument = '', string $permissionCreateTransaction = '',
|
||||
$routeButtonDocument = '', $routeButtonTransaction = '',
|
||||
string $textDocument = '', string $textTransaction = '',
|
||||
bool $hideButtonEdit = false, $routeButtonEdit = '',
|
||||
bool $hideActionsDropdown = false, bool $hideButtonDuplicate = false, $routeButtonDuplicate = '',
|
||||
bool $hideButtonDelete = false, $routeButtonDelete = '', $textDeleteModal = '',
|
||||
bool $hideTopLeft = false, bool $hideAvatar = false, bool $hideEmail = false, bool $hidePhone = false,
|
||||
bool $hideTopRight = false, bool $hideOverdue = false, bool $hideOpen = false, bool $hidePaid = false,
|
||||
bool $hideBottomLeft = false, bool $hideAddress = false, bool $hideTaxNumber = false , bool $hideWebsite = false, bool $hideReference = false, bool $hideUser = false,
|
||||
bool $hideBottomRight = false
|
||||
) {
|
||||
/* -- Main Start -- */
|
||||
$this->type = $type;
|
||||
|
||||
$this->model = ! empty($model) ? $model : $contact;
|
||||
$this->contact = $this->model;
|
||||
|
||||
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
|
||||
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
|
||||
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
|
||||
/* -- Main End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
$this->hideNewDropdown = $hideNewDropdown;
|
||||
$this->hideButtonDocument = $hideButtonDocument;
|
||||
$this->hideButtonTransaction = $hideButtonTransaction;
|
||||
|
||||
$this->permissionCreateDocument = $this->getPermissionCreateDocument($type, $permissionCreateDocument);
|
||||
$this->permissionCreateTransaction = $this->getPermissionCreateTransaction($type, $permissionCreateTransaction);
|
||||
|
||||
$this->routeButtonDocument = $this->getCreateDocumentRoute($type, $routeButtonDocument);
|
||||
$this->routeButtonTransaction = $this->getCreateTransactionRoute($type, $routeButtonTransaction);
|
||||
|
||||
$this->textDocument = $this->getTextDocument($type, $textDocument);
|
||||
$this->textTransaction = $this->getTextTransaction($type, $textTransaction);
|
||||
|
||||
$this->hideButtonEdit = $hideButtonEdit;
|
||||
$this->routeButtonEdit = $this->getEditRoute($type, $routeButtonEdit);
|
||||
|
||||
$this->hideActionsDropdown = $hideActionsDropdown;
|
||||
$this->hideButtonDuplicate = $hideButtonDuplicate;
|
||||
$this->routeButtonDuplicate = $this->getDuplicateRoute($type, $routeButtonDuplicate);
|
||||
|
||||
$this->hideButtonDelete = $hideButtonDelete;
|
||||
$this->routeButtonDelete = $this->getDeleteRoute($type, $routeButtonDelete);
|
||||
$this->textDeleteModal = $this->getTextDeleteModal($type, $textDeleteModal);
|
||||
/* -- Buttons End -- */
|
||||
|
||||
/* -- Profile Start -- */
|
||||
$this->hideProfile = $hideTopLeft;
|
||||
$this->hideAvatar = $hideAvatar;
|
||||
$this->hideEmail = $hideEmail;
|
||||
$this->hidePhone = $hidePhone;
|
||||
|
||||
$this->hideDetails = $hideTopRight;
|
||||
$this->hideOverdue = $hideOverdue;
|
||||
$this->hideOpen = $hideOpen;
|
||||
$this->hidePaid = $hidePaid;
|
||||
|
||||
$this->hideSummary = $hideBottomLeft;
|
||||
$this->hideAddress = $hideAddress;
|
||||
$this->hideTaxNumber = $hideTaxNumber;
|
||||
$this->hideWebsite = $hideWebsite;
|
||||
$this->hideReference = $hideReference;
|
||||
$this->hideUser = $hideUser;
|
||||
|
||||
$this->hideContent = $hideBottomRight;
|
||||
/* -- Profile End -- */
|
||||
}
|
||||
|
||||
protected function getPermissionCreateDocument($type, $permissionCreateDocument)
|
||||
{
|
||||
if (! empty($permissionCreateDocument)) {
|
||||
return $permissionCreateDocument;
|
||||
}
|
||||
|
||||
$document_type = config('type.contact.' . $type . '.document_type', 'invoice');
|
||||
|
||||
$permission = '';
|
||||
$config_key = 'create';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($permission = config('type.document.' . $document_type . '.permission.' . $config_key)) {
|
||||
return $permission;
|
||||
}
|
||||
|
||||
$alias = config('type.document.' . $document_type . '.alias');
|
||||
$group = config('type.document.' . $document_type . '.group');
|
||||
$prefix = config('type.document.' . $document_type . '.permission.prefix');
|
||||
|
||||
$permission = $config_key . '-';
|
||||
|
||||
// if use module set module alias
|
||||
if (! empty($alias)) {
|
||||
$permission .= $alias . '-';
|
||||
}
|
||||
|
||||
// if controller in folder it must
|
||||
if (! empty($group)) {
|
||||
$permission .= $group . '-';
|
||||
}
|
||||
|
||||
$permission .= $prefix;
|
||||
|
||||
$permissionCreateDocument = $permission;
|
||||
|
||||
return $permissionCreateDocument;
|
||||
}
|
||||
|
||||
protected function getPermissionCreateTransaction($type, $permissionCreateTransaction)
|
||||
{
|
||||
if (! empty($permissionCreateTransaction)) {
|
||||
return $permissionCreateTransaction;
|
||||
}
|
||||
|
||||
$permissionCreateTransaction = 'create-banking-transactions';
|
||||
|
||||
return $permissionCreateTransaction;
|
||||
}
|
||||
|
||||
protected function getCreateDocumentRoute($type, $routeButtonDocument)
|
||||
{
|
||||
if (! empty($routeButtonDocument)) {
|
||||
return $routeButtonDocument;
|
||||
}
|
||||
|
||||
$prefix = config('type.contact.' . $type . '.route.prefix');
|
||||
$document_type = config('type.contact.' . $type . '.document_type');
|
||||
|
||||
return $prefix . '.create-' . $document_type;
|
||||
}
|
||||
|
||||
protected function getCreateTransactionRoute($type, $routeButtonDocument)
|
||||
{
|
||||
if (! empty($routeButtonDocument)) {
|
||||
return $routeButtonDocument;
|
||||
}
|
||||
|
||||
$prefix = config('type.contact.' . $type . '.route.prefix');
|
||||
$transaction_type = config('type.contact.' . $type . '.transaction_type');
|
||||
|
||||
return $prefix . '.create-' . $transaction_type;
|
||||
}
|
||||
|
||||
protected function getTextDocument($type, $textDocument)
|
||||
{
|
||||
if (! empty($textDocument)) {
|
||||
return $textDocument;
|
||||
}
|
||||
|
||||
$document_type = config('type.contact.' . $type . '.document_type');
|
||||
|
||||
switch ($document_type) {
|
||||
case 'invoice':
|
||||
$text = 'general.invoices';
|
||||
break;
|
||||
case 'bill':
|
||||
$text = 'general.bills';
|
||||
break;
|
||||
default:
|
||||
$text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.route.prefix');
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
protected function getTextTransaction($type, $textTransaction)
|
||||
{
|
||||
if (! empty($textTransaction)) {
|
||||
return $textTransaction;
|
||||
}
|
||||
|
||||
$document_type = config('type.contact.' . $type . '.document_type');
|
||||
|
||||
switch ($document_type) {
|
||||
case 'invoice':
|
||||
$text = 'general.incomes';
|
||||
break;
|
||||
case 'bill':
|
||||
$text = 'general.expenses';
|
||||
break;
|
||||
default:
|
||||
$text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.transaction_type') . 's';
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
protected function getTextDeleteModal($type, $textDeleteModal)
|
||||
{
|
||||
if (! empty($textDeleteModal)) {
|
||||
return $textDeleteModal;
|
||||
}
|
||||
|
||||
$document_type = config('type.contact.' . $type . '.document_type');
|
||||
|
||||
switch ($document_type) {
|
||||
case 'invoice':
|
||||
$text = 'general.incomes';
|
||||
break;
|
||||
case 'bill':
|
||||
$text = 'general.expenses';
|
||||
break;
|
||||
default:
|
||||
$text = config('type.contact.' . $type . '.translation.prefix') . '.' . config('type.contact.' . $type . '.transaction_type') . 's';
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class Document extends Component
|
||||
{
|
||||
public function getTextFromConfig($type, $config_key, $default_key = '', $trans_type = 'trans')
|
||||
{
|
||||
$translation = '';
|
||||
|
||||
// if set config translation config_key
|
||||
if ($translation = config('type.' . $type . '.translation.' . $config_key)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$prefix = config('type.' . $type . '.translation.prefix');
|
||||
|
||||
if (!empty($alias)) {
|
||||
$alias .= '::';
|
||||
}
|
||||
|
||||
// This magic trans key..
|
||||
$translations = [
|
||||
'general' => $alias . 'general.' . $default_key,
|
||||
'prefix' => $alias . $prefix . '.' . $default_key,
|
||||
'config_general' => $alias . 'general.' . $config_key,
|
||||
'config_prefix' => $alias . $prefix . '.' . $config_key,
|
||||
];
|
||||
|
||||
switch ($trans_type) {
|
||||
case 'trans':
|
||||
foreach ($translations as $trans) {
|
||||
if (trans($trans) !== $trans) {
|
||||
return $trans;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'trans_choice':
|
||||
foreach ($translations as $trans_choice) {
|
||||
if (trans_choice($trans_choice, 1) !== $trans_choice) {
|
||||
return $trans_choice;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $translation;
|
||||
}
|
||||
|
||||
public function getRouteFromConfig($type, $config_key, $config_parameters = [])
|
||||
{
|
||||
$route = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($route = config('type.' . $type . '.route.' . $config_key)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$prefix = config('type.' . $type . '.route.prefix');
|
||||
|
||||
// if use module set module alias
|
||||
if (!empty($alias)) {
|
||||
$route .= $alias . '.';
|
||||
}
|
||||
|
||||
if (!empty($prefix)) {
|
||||
$route .= $prefix . '.';
|
||||
}
|
||||
|
||||
$route .= $config_key;
|
||||
|
||||
try {
|
||||
route($route, $config_parameters);
|
||||
} catch (\Exception $e) {
|
||||
try {
|
||||
$route = Str::plural($type, 2) . '.' . $config_key;
|
||||
|
||||
route($route, $config_parameters);
|
||||
} catch (\Exception $e) {
|
||||
$route = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
public function getPermissionFromConfig($type, $config_key)
|
||||
{
|
||||
$permission = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($permission = config('type.' . $type . '.permission.' . $config_key)) {
|
||||
return $permission;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$group = config('type.' . $type . '.group');
|
||||
$prefix = config('type.' . $type . '.permission.prefix');
|
||||
|
||||
$permission = $config_key . '-';
|
||||
|
||||
// if use module set module alias
|
||||
if (!empty($alias)) {
|
||||
$permission .= $alias . '-';
|
||||
}
|
||||
|
||||
// if controller in folder it must
|
||||
if (!empty($group)) {
|
||||
$permission .= $group . '-';
|
||||
}
|
||||
|
||||
$permission .= $prefix;
|
||||
|
||||
return $permission;
|
||||
}
|
||||
|
||||
public function getHideFromConfig($type, $config_key)
|
||||
{
|
||||
$hide = false;
|
||||
|
||||
$hides = config('type.' . $type . '.hide');
|
||||
|
||||
if (!empty($hides) && (in_array($config_key, $hides))) {
|
||||
$hide = true;
|
||||
}
|
||||
|
||||
return $hide;
|
||||
}
|
||||
|
||||
public function getClassFromConfig($type, $config_key)
|
||||
{
|
||||
$class_key = 'type.' . $type . '.class.' . $config_key;
|
||||
|
||||
return config($class_key, '');
|
||||
}
|
||||
|
||||
public function getCategoryFromConfig($type)
|
||||
{
|
||||
$category_type = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($category_type = config('type.' . $type . '.category_type')) {
|
||||
return $category_type;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$category_type = 'expense';
|
||||
break;
|
||||
case 'item':
|
||||
$category_type = 'item';
|
||||
break;
|
||||
case 'other':
|
||||
$category_type = 'other';
|
||||
break;
|
||||
case 'transfer':
|
||||
$category_type = 'transfer';
|
||||
break;
|
||||
default:
|
||||
$category_type = 'income';
|
||||
break;
|
||||
}
|
||||
|
||||
return $category_type;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+696
-549
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,642 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components\Documents;
|
||||
|
||||
use Akaunting\Module\Module;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Events\Common\BulkActionsAdding;
|
||||
use App\Traits\Documents;
|
||||
use App\Traits\Modules;
|
||||
use App\Traits\ViewComponents;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
abstract class Index extends Component
|
||||
{
|
||||
use Documents, Modules, ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'document';
|
||||
public const DEFAULT_TYPE = 'invoice';
|
||||
public const DEFAULT_PLURAL_TYPE = 'invoices';
|
||||
|
||||
/* -- Main Start -- */
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $alias;
|
||||
|
||||
public $documents;
|
||||
|
||||
/** @var string */
|
||||
public $group;
|
||||
|
||||
/** @var string */
|
||||
public $page;
|
||||
|
||||
/** @var string */
|
||||
public $textTabDocument;
|
||||
|
||||
/** @var string */
|
||||
public $routeTabDocument;
|
||||
|
||||
/** @var string */
|
||||
public $routeTabRecurring;
|
||||
|
||||
/** @var string */
|
||||
public $textPage;
|
||||
|
||||
/** @var string */
|
||||
public $permissionCreate;
|
||||
|
||||
/** @var string */
|
||||
public $permissionUpdate;
|
||||
|
||||
/** @var string */
|
||||
public $permissionDelete;
|
||||
/* -- Main End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
/** @var bool */
|
||||
public $hideAcceptPayment;
|
||||
|
||||
/** @var bool */
|
||||
public $checkPermissionCreate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCreate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideImport;
|
||||
|
||||
/** @var bool */
|
||||
public $hideExport;
|
||||
|
||||
/** @var string */
|
||||
public $createRoute;
|
||||
|
||||
/** @var string */
|
||||
public $importRoute;
|
||||
|
||||
/** @var array */
|
||||
public $importRouteParameters;
|
||||
|
||||
/** @var string */
|
||||
public $exportRoute;
|
||||
/* -- Buttons End -- */
|
||||
|
||||
/* -- Content Start -- */
|
||||
/** @var bool */
|
||||
public $hideEmptyPage;
|
||||
|
||||
/** @var array */
|
||||
public $emptyPageButtons;
|
||||
|
||||
/** @var string */
|
||||
public $imageEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $textEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $urlDocsPath;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSummary;
|
||||
|
||||
/** @var array */
|
||||
public $summaryItems;
|
||||
|
||||
/** @var bool */
|
||||
public $withoutTabs;
|
||||
|
||||
/** @var string */
|
||||
public $tabActive;
|
||||
|
||||
/** @var bool */
|
||||
public $hideRecurringTemplates;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSearchString;
|
||||
|
||||
/** @var bool */
|
||||
public $hideBulkAction;
|
||||
|
||||
/** @var string */
|
||||
public $searchStringModel;
|
||||
|
||||
/** @var string */
|
||||
public $bulkActionClass;
|
||||
|
||||
/** @var array */
|
||||
public $bulkActionRouteParameters;
|
||||
|
||||
/** @var string */
|
||||
public $searchRoute;
|
||||
|
||||
/** @var string */
|
||||
public $classBulkAction;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDueAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideIssuedAt;
|
||||
|
||||
/** @var string */
|
||||
public $classDueAtAndIssueAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDueAt;
|
||||
|
||||
/** @var string */
|
||||
public $textIssuedAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideStatus;
|
||||
|
||||
/** @var string */
|
||||
public $classStatus;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContactName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $classContactNameAndDocumentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textContactName;
|
||||
|
||||
/** @var string */
|
||||
public $showContactRoute;
|
||||
|
||||
/** @var string */
|
||||
public $textDocumentNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAmount;
|
||||
|
||||
/** @var string */
|
||||
public $classAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideShow;
|
||||
|
||||
/** @var string */
|
||||
public $showRoute;
|
||||
|
||||
/** @var bool */
|
||||
public $hideEdit;
|
||||
|
||||
/** @var string */
|
||||
public $editRoute;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDuplicate;
|
||||
|
||||
/** @var string */
|
||||
public $duplicateRoute;
|
||||
|
||||
/** @var string */
|
||||
public $textDocumentStatus;
|
||||
|
||||
/** @var bool */
|
||||
public $checkButtonReconciled;
|
||||
|
||||
/** @var bool */
|
||||
public $checkButtonCancelled;
|
||||
/* -- Content End -- */
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, string $alias = '', $documents = [], string $group = '', string $page = '', string $textTabDocument = '', string $textPage = '',
|
||||
string $routeTabDocument = '', string $routeTabRecurring = '',
|
||||
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
|
||||
bool $hideAcceptPayment = false, bool $checkPermissionCreate = true,
|
||||
bool $hideCreate = false, bool $hideImport = false, bool $hideExport = false,
|
||||
string $createRoute = '', string $importRoute = '', array $importRouteParameters = [], string $exportRoute = '',
|
||||
bool $hideEmptyPage = false, array $emptyPageButtons = [], string $imageEmptyPage = '', string $textEmptyPage = '', string $urlDocsPath = '',
|
||||
bool $hideSummary = false, array $summaryItems = [],
|
||||
bool $withoutTabs = false, string $tabActive = '', bool $hideRecurringTemplates = false,
|
||||
bool $hideSearchString = false, bool $hideBulkAction = false,
|
||||
string $searchStringModel = '', string $bulkActionClass = '', array $bulkActions = [], array $bulkActionRouteParameters = [], string $searchRoute = '', string $classBulkAction = '',
|
||||
bool $hideDueAt = false, bool $hideIssuedAt = false, string $classDueAtAndIssueAt = '', string $textDueAt = '', string $textIssuedAt = '',
|
||||
bool $hideStatus = false, string $classStatus = '',
|
||||
bool $hideContactName = false, bool $hideDocumentNumber = false, string $classContactNameAndDocumentNumber = '', string $textContactName = '', string $showContactRoute = '', string $textDocumentNumber = '',
|
||||
bool $hideAmount = false, string $classAmount = '',
|
||||
bool $hideShow = false, string $showRoute = '', bool $hideEdit = false, string $editRoute = '', bool $hideDuplicate = false, string $duplicateRoute = '',
|
||||
string $textDocumentStatus = '',
|
||||
bool $checkButtonReconciled = true, bool $checkButtonCancelled = true
|
||||
) {
|
||||
/* -- Main Start -- */
|
||||
$this->type = $type;
|
||||
$this->alias = $this->getAlias($type, $alias);
|
||||
$this->documents = ($documents) ? $documents : collect();
|
||||
$this->group = $this->getGroup($type, $group);
|
||||
$this->page = $this->getPage($type, $page);
|
||||
$this->textTabDocument = $this->getTextTabDocument($type, $textTabDocument);
|
||||
$this->textPage = $this->getTextPage($type, $textPage);
|
||||
|
||||
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
|
||||
$this->permissionUpdate = $this->getPermissionUpdate($type, $permissionUpdate);
|
||||
$this->permissionDelete = $this->getPermissionDelete($type, $permissionDelete);
|
||||
|
||||
$this->routeTabDocument = $this->getRouteTabDocument($type, $routeTabDocument);
|
||||
$this->routeTabRecurring = $this->getRouteTabRecurring($type, $routeTabRecurring);
|
||||
/* -- Main End -- */
|
||||
|
||||
/* -- Buttons Start -- */
|
||||
$this->hideAcceptPayment = $hideAcceptPayment;
|
||||
|
||||
$this->checkPermissionCreate = $checkPermissionCreate;
|
||||
|
||||
$this->hideCreate = $hideCreate;
|
||||
$this->hideImport = $hideImport;
|
||||
$this->hideExport = $hideExport;
|
||||
|
||||
$this->createRoute = $this->getCreateRoute($type, $createRoute);
|
||||
$this->importRoute = $this->getImportRoute($importRoute);
|
||||
$this->importRouteParameters = $this->getImportRouteParameters($type, $importRouteParameters);
|
||||
$this->exportRoute = $this->getExportRoute($type, $exportRoute);
|
||||
/* -- Buttons End -- */
|
||||
|
||||
/* -- Content Start -- */
|
||||
/* -- Empty Page Start -- */
|
||||
$this->hideEmptyPage = $hideEmptyPage;
|
||||
|
||||
$this->emptyPageButtons = $this->getEmptyPageButtons($type, $emptyPageButtons);
|
||||
$this->imageEmptyPage = $this->getImageEmptyPage($type, $imageEmptyPage);
|
||||
$this->textEmptyPage = $this->getTextEmptyPage($type, $textEmptyPage);
|
||||
$this->urlDocsPath = $this->getUrlDocsPath($type, $urlDocsPath);
|
||||
/* -- Empty Page End -- */
|
||||
|
||||
/* -- Summary Start -- */
|
||||
$this->hideSummary = $hideSummary;
|
||||
$this->summaryItems = $this->getSummaryItems($type, $summaryItems);
|
||||
/* -- Sumamry End -- */
|
||||
|
||||
/* Container Start */
|
||||
$this->withoutTabs = $withoutTabs;
|
||||
$this->tabActive = $this->getTabActive($type, $tabActive);
|
||||
|
||||
$this->hideRecurringTemplates = $hideRecurringTemplates;
|
||||
|
||||
$this->hideSearchString = $hideSearchString;
|
||||
$this->hideBulkAction = $hideBulkAction;
|
||||
|
||||
$this->searchStringModel = $this->getSearchStringModel($type, $searchStringModel);
|
||||
|
||||
$this->bulkActionClass = $this->getBulkActionClass($type, $bulkActionClass);
|
||||
$this->bulkActionRouteParameters = $this->getBulkActionRouteParameters($type, $bulkActionRouteParameters);
|
||||
|
||||
$this->searchRoute = $this->getIndexRoute($type, $searchRoute);
|
||||
|
||||
$this->classBulkAction = $this->getClassBulkAction($type, $classBulkAction);
|
||||
|
||||
/* Document Start */
|
||||
$this->hideDueAt = $hideDueAt;
|
||||
$this->hideIssuedAt = $hideIssuedAt;
|
||||
$this->classDueAtAndIssueAt = $this->getClassDueAtAndIssueAt($type, $classDueAtAndIssueAt);
|
||||
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
|
||||
$this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt);
|
||||
|
||||
$this->hideStatus = $hideStatus;
|
||||
$this->classStatus = $this->getClassStatus($type, $classStatus);
|
||||
|
||||
$this->hideContactName = $hideContactName;
|
||||
$this->hideDocumentNumber = $hideDocumentNumber;
|
||||
$this->classContactNameAndDocumentNumber = $this->getClassContactNameAndDocumentNumber($type, $classContactNameAndDocumentNumber);
|
||||
$this->textContactName = $this->getTextContactName($type, $textContactName);
|
||||
$this->showContactRoute = $this->getShowContactRoute($type, $showContactRoute);
|
||||
$this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
|
||||
|
||||
$this->hideAmount = $hideAmount;
|
||||
$this->classAmount = $this->getClassAmount($type, $classAmount);
|
||||
|
||||
$this->hideShow = $hideShow;
|
||||
$this->showRoute = $this->getShowRoute($type, $showRoute);
|
||||
|
||||
$this->hideEdit = $hideEdit;
|
||||
$this->editRoute = $this->getEditRoute($type, $editRoute);
|
||||
|
||||
$this->hideDuplicate = $hideDuplicate;
|
||||
$this->duplicateRoute = $this->getDuplicateRoute($type, $duplicateRoute);
|
||||
|
||||
$this->textDocumentStatus = $this->getTextDocumentStatus($type, $textDocumentStatus);
|
||||
|
||||
$this->checkButtonReconciled = $checkButtonReconciled;
|
||||
$this->checkButtonCancelled = $checkButtonCancelled;
|
||||
/* Document End */
|
||||
/* Container End */
|
||||
/* -- Content End -- */
|
||||
|
||||
// Set Parent data
|
||||
$this->setParentData();
|
||||
}
|
||||
|
||||
protected function getEmptyPageButtons($type, $emptyPageButtons)
|
||||
{
|
||||
if (! empty($emptyPageButtons)) {
|
||||
return $emptyPageButtons;
|
||||
}
|
||||
|
||||
$prefix = config('type.' . static::OBJECT_TYPE . '.' . $type . '.route.prefix', 'invoices');
|
||||
|
||||
$buttons = [];
|
||||
|
||||
if (! $this->hideCreate) {
|
||||
$route = $this->getRouteFromConfig($type, 'create');
|
||||
|
||||
$buttons[] = [
|
||||
'permission' => $this->permissionCreate,
|
||||
'url' => route($this->createRoute),
|
||||
'text' => trans('general.title.new', ['type' => trans_choice($this->textPage ?? 'general.' . $prefix, 1)]),
|
||||
'description' => trans('general.empty.actions.new', ['type' => strtolower(trans_choice($this->textPage ?? 'general.' . $prefix, 1))]),
|
||||
'active_badge' => true,
|
||||
];
|
||||
}
|
||||
|
||||
if (! $this->hideImport) {
|
||||
$route = $this->getRouteFromConfig($type, 'import');
|
||||
|
||||
$buttons[] = [
|
||||
'permission' => $this->permissionCreate,
|
||||
'url' => route($this->importRoute, $this->importRouteParameters),
|
||||
'text' => trans('import.title', ['type' => trans_choice($this->textPage ?? 'general.' . $prefix, 1)]),
|
||||
'description' => trans('general.empty.actions.import', ['type' => strtolower(trans_choice($this->textPage ?? 'general.' . $prefix, 1))]),
|
||||
];
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
public function getSummaryItems($type, $summaryItems)
|
||||
{
|
||||
if (! empty($summaryItems)) {
|
||||
return $summaryItems;
|
||||
}
|
||||
|
||||
$route = $this->getIndexRoute($type, null);
|
||||
|
||||
$totals = $this->getTotalsForFutureDocuments($type);
|
||||
|
||||
$items = [];
|
||||
|
||||
foreach ($totals as $key => $total) {
|
||||
$title = ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key);
|
||||
$href = route($route, ['search' => 'status:' . $key]);
|
||||
$amount = money($total, setting('default.currency'), true);
|
||||
|
||||
$items[] = [
|
||||
'title' => $title,
|
||||
'href' => $href,
|
||||
'amount' => $amount,
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
protected function getTextTabDocument($type, $textTabDocument)
|
||||
{
|
||||
if (! empty($textTabDocument)) {
|
||||
return $textTabDocument;
|
||||
}
|
||||
|
||||
$default_key = config('type.' . static::OBJECT_TYPE . '.' . $type . '.translation.prefix');
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'tab_document', $default_key);
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.invoices';
|
||||
}
|
||||
|
||||
public function getTabActive($type, $tabActive)
|
||||
{
|
||||
if (! empty($tabActive)) {
|
||||
return $tabActive;
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
protected function getRouteTabDocument($type, $routeTabDocument)
|
||||
{
|
||||
if (! empty($routeTabDocument)) {
|
||||
return $routeTabDocument;
|
||||
}
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'document', 'invoices');
|
||||
|
||||
if (! empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'invoices.index';
|
||||
}
|
||||
|
||||
protected function getRouteTabRecurring($type, $routeTabDocument)
|
||||
{
|
||||
if (! empty($routeTabDocument)) {
|
||||
return $routeTabDocument;
|
||||
}
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'recurring', 'recurring-invoices');
|
||||
|
||||
if (! empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'recurring-invoices.index';
|
||||
}
|
||||
|
||||
protected function getClassDueAtAndIssueAt($type, $classDueAtAndIssueAt)
|
||||
{
|
||||
if (! empty($classDueAtAndIssueAt)) {
|
||||
return $classDueAtAndIssueAt;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'due_at_and_issue_at');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-4/12 table-title hidden sm:table-cell';
|
||||
}
|
||||
|
||||
protected function getTextDueAt($type, $textDueAt)
|
||||
{
|
||||
if (! empty($textDueAt)) {
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.due_date';
|
||||
}
|
||||
|
||||
protected function getTextIssuedAt($type, $textIssuedAt)
|
||||
{
|
||||
if (! empty($textIssuedAt)) {
|
||||
return $textIssuedAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$default_key = 'bill_date';
|
||||
break;
|
||||
default:
|
||||
$default_key = 'invoice_date';
|
||||
break;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.invoice_date';
|
||||
}
|
||||
|
||||
protected function getClassStatus($type, $classStatus)
|
||||
{
|
||||
if (! empty($classStatus)) {
|
||||
return $classStatus;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'status');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-3/12 table-title hidden sm:table-cell';
|
||||
}
|
||||
|
||||
protected function getClassContactNameAndDocumentNumber($type, $classContactNameAndDocumentNumber)
|
||||
{
|
||||
if (! empty($classContactNameAndDocumentNumber)) {
|
||||
return $classContactNameAndDocumentNumber;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'contact_name');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-6/12 sm:w-3/12 table-title';
|
||||
}
|
||||
|
||||
protected function getTextContactName($type, $textContactName)
|
||||
{
|
||||
if (! empty($textContactName)) {
|
||||
return $textContactName;
|
||||
}
|
||||
|
||||
$default_key = Str::plural(config('type.' . static::OBJECT_TYPE . '.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'contact_name', $default_key, 'trans_choice');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.customers';
|
||||
}
|
||||
|
||||
protected function getShowContactRoute($type, $showContactRoute)
|
||||
{
|
||||
if (! empty($showContactRoute)) {
|
||||
return $showContactRoute;
|
||||
}
|
||||
|
||||
|
||||
if (! empty($showRoute)) {
|
||||
return $showRoute;
|
||||
}
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'contact.show', 1);
|
||||
|
||||
if (!empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
$default_key = Str::plural(config('type.' . static::OBJECT_TYPE . '.' . $type . '.contact_type'), 2);
|
||||
|
||||
return $default_key . '.show';
|
||||
}
|
||||
|
||||
protected function getTextDocumentNumber($type, $textDocumentNumber)
|
||||
{
|
||||
if (! empty($textDocumentNumber)) {
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'document_number', 'numbers');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.numbers';
|
||||
}
|
||||
|
||||
protected function getClassAmount($type, $classAmount)
|
||||
{
|
||||
if (! empty($classAmount)) {
|
||||
return $classAmount;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'amount');
|
||||
|
||||
if (! empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'w-6/12 sm:w-2/12';
|
||||
}
|
||||
|
||||
protected function getTextDocumentStatus($type, $textDocumentStatus)
|
||||
{
|
||||
if (! empty($textDocumentStatus)) {
|
||||
return $textDocumentStatus;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'document_status', 'statuses.');
|
||||
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
$alias = config('type.' . static::OBJECT_TYPE . '.' . $type . '.alias');
|
||||
|
||||
if (! empty($alias)) {
|
||||
$translation = $alias . '::' . config('type.' . static::OBJECT_TYPE . '.' . $type . '.translation.prefix') . '.statuses';
|
||||
|
||||
if (is_array(trans($translation))) {
|
||||
return $translation . '.';
|
||||
}
|
||||
}
|
||||
|
||||
return 'documents.statuses.';
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+66
-53
@@ -1,22 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
namespace App\Abstracts\View\Components\Documents;
|
||||
|
||||
use App\Abstracts\View\Components\Document as Base;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Media;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Documents;
|
||||
use File;
|
||||
use App\Traits\ViewComponents;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Image;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Image;
|
||||
|
||||
abstract class DocumentTemplate extends Base
|
||||
abstract class Template extends Component
|
||||
{
|
||||
use DateTime;
|
||||
use Documents;
|
||||
use DateTime, Documents, ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'document';
|
||||
public const DEFAULT_TYPE = 'invoice';
|
||||
public const DEFAULT_PLURAL_TYPE = 'invoices';
|
||||
|
||||
public $type;
|
||||
|
||||
@@ -180,15 +185,18 @@ abstract class DocumentTemplate extends Base
|
||||
$this->textQuantity = $this->getTextQuantity($type, $textQuantity);
|
||||
$this->textPrice = $this->getTextPrice($type, $textPrice);
|
||||
$this->textAmount = $this->getTextAmount($type, $textAmount);
|
||||
|
||||
// Set Parent data
|
||||
//$this->setParentData();
|
||||
}
|
||||
|
||||
protected function getDocumentTemplate($type, $documentTemplate)
|
||||
{
|
||||
if (!empty($documentTemplate)) {
|
||||
if (! empty($documentTemplate)) {
|
||||
return $documentTemplate;
|
||||
}
|
||||
|
||||
if ($template = config('type.' . $type . 'template', false)) {
|
||||
if ($template = config('type.document.' . $type . '.template', false)) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
@@ -199,15 +207,15 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getLogo($logo)
|
||||
{
|
||||
if (!empty($logo)) {
|
||||
if (! empty($logo)) {
|
||||
return $logo;
|
||||
}
|
||||
|
||||
$media_id = (!empty($this->document->contact->logo) && !empty($this->document->contact->logo->id)) ? $this->document->contact->logo->id : setting('company.logo');
|
||||
$media_id = (! empty($this->document->contact->logo) && ! empty($this->document->contact->logo->id)) ? $this->document->contact->logo->id : setting('company.logo');
|
||||
|
||||
$media = Media::find($media_id);
|
||||
|
||||
if (!empty($media)) {
|
||||
if (! empty($media)) {
|
||||
$path = $media->getDiskPath();
|
||||
|
||||
if (Storage::missing($path)) {
|
||||
@@ -253,14 +261,19 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getBackgroundColor($type, $backgroundColor)
|
||||
{
|
||||
if (!empty($backgroundColor)) {
|
||||
if (! empty($backgroundColor)) {
|
||||
return $backgroundColor;
|
||||
}
|
||||
|
||||
if ($background_color = config('type.' . $type . 'color', false)) {
|
||||
if ($background_color = config('type.document.' . $type . '.color', false)) {
|
||||
return $background_color;
|
||||
}
|
||||
|
||||
|
||||
if (! empty($alias = config('type.document.' . $type . '.alias'))) {
|
||||
$type = $alias . '.' . str_replace('-', '_', $type);
|
||||
}
|
||||
|
||||
$backgroundColor = setting($this->getSettingKey($type, 'color'), '#55588b');
|
||||
|
||||
return $backgroundColor;
|
||||
@@ -268,19 +281,19 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextDocumentTitle($type, $textDocumentTitle)
|
||||
{
|
||||
if (!empty($textDocumentTitle)) {
|
||||
if (! empty($textDocumentTitle)) {
|
||||
return $textDocumentTitle;
|
||||
}
|
||||
|
||||
$key = $this->getSettingKey($type, 'title');
|
||||
|
||||
if (!empty(setting($key))) {
|
||||
if (! empty(setting($key))) {
|
||||
return setting($key);
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'document_title', Str::plural($type));
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return trans_choice($translation, 1);
|
||||
}
|
||||
|
||||
@@ -289,19 +302,19 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextDocumentSubheading($type, $textDocumentSubheading)
|
||||
{
|
||||
if (!empty($textDocumentSubheading)) {
|
||||
if (! empty($textDocumentSubheading)) {
|
||||
return $textDocumentSubheading;
|
||||
}
|
||||
|
||||
$key = $this->getSettingKey($type, 'subheading');
|
||||
|
||||
if (!empty(setting($key))) {
|
||||
if (! empty(setting($key))) {
|
||||
return setting($key);
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'document_subheading', 'subheading');
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return trans($translation);
|
||||
}
|
||||
|
||||
@@ -310,7 +323,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextDocumentNumber($type, $textDocumentNumber)
|
||||
{
|
||||
if (!empty($textDocumentNumber)) {
|
||||
if (! empty($textDocumentNumber)) {
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
@@ -327,7 +340,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'document_number', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -336,13 +349,13 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextOrderNumber($type, $textOrderNumber)
|
||||
{
|
||||
if (!empty($textOrderNumber)) {
|
||||
if (! empty($textOrderNumber)) {
|
||||
return $textOrderNumber;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'order_number');
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -351,7 +364,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextContactInfo($type, $textContactInfo)
|
||||
{
|
||||
if (!empty($textContactInfo)) {
|
||||
if (! empty($textContactInfo)) {
|
||||
return $textContactInfo;
|
||||
}
|
||||
|
||||
@@ -368,7 +381,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'contact_info', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -377,7 +390,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextIssuedAt($type, $textIssuedAt)
|
||||
{
|
||||
if (!empty($textIssuedAt)) {
|
||||
if (! empty($textIssuedAt)) {
|
||||
return $textIssuedAt;
|
||||
}
|
||||
|
||||
@@ -394,7 +407,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -403,13 +416,13 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextDueAt($type, $textDueAt)
|
||||
{
|
||||
if (!empty($textDueAt)) {
|
||||
if (! empty($textDueAt)) {
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -418,7 +431,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextItems($type, $textItems)
|
||||
{
|
||||
if (!empty($textItems)) {
|
||||
if (! empty($textItems)) {
|
||||
return $textItems;
|
||||
}
|
||||
|
||||
@@ -431,15 +444,15 @@ abstract class DocumentTemplate extends Base
|
||||
return $textItems;
|
||||
}
|
||||
|
||||
if (setting($this->getSettingKey($type, 'item_name')) !== null &&
|
||||
(trans(setting($this->getSettingKey($type, 'item_name'))) != setting($this->getSettingKey($type, 'item_name')))
|
||||
if (setting($this->getSettingKey($type, 'item_name')) !== null
|
||||
&& (trans(setting($this->getSettingKey($type, 'item_name'))) != setting($this->getSettingKey($type, 'item_name')))
|
||||
) {
|
||||
return setting($this->getSettingKey($type, 'item_name'));
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'items');
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -448,7 +461,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextQuantity($type, $textQuantity)
|
||||
{
|
||||
if (!empty($textQuantity)) {
|
||||
if (! empty($textQuantity)) {
|
||||
return $textQuantity;
|
||||
}
|
||||
|
||||
@@ -461,15 +474,15 @@ abstract class DocumentTemplate extends Base
|
||||
return $textQuantity;
|
||||
}
|
||||
|
||||
if (setting($this->getSettingKey($type, 'quantity_name')) !== null &&
|
||||
(trans(setting($this->getSettingKey($type, 'quantity_name'))) != setting($this->getSettingKey($type, 'quantity_name')))
|
||||
if (setting($this->getSettingKey($type, 'quantity_name')) !== null
|
||||
&& (trans(setting($this->getSettingKey($type, 'quantity_name'))) != setting($this->getSettingKey($type, 'quantity_name')))
|
||||
) {
|
||||
return setting($this->getSettingKey($type, 'quantity_name'));
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'quantity');
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -478,7 +491,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextPrice($type, $textPrice)
|
||||
{
|
||||
if (!empty($textPrice)) {
|
||||
if (! empty($textPrice)) {
|
||||
return $textPrice;
|
||||
}
|
||||
|
||||
@@ -491,15 +504,15 @@ abstract class DocumentTemplate extends Base
|
||||
return $textPrice;
|
||||
}
|
||||
|
||||
if (setting($this->getSettingKey($type, 'price_name')) !== null &&
|
||||
(trans(setting($this->getSettingKey($type, 'price_name'))) != setting($this->getSettingKey($type, 'price_name')))
|
||||
if (setting($this->getSettingKey($type, 'price_name')) !== null
|
||||
&& (trans(setting($this->getSettingKey($type, 'price_name'))) != setting($this->getSettingKey($type, 'price_name')))
|
||||
) {
|
||||
return setting($this->getSettingKey($type, 'price_name'));
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'price');
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -508,13 +521,13 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getTextAmount($type, $textAmount)
|
||||
{
|
||||
if (!empty($textAmount)) {
|
||||
if (! empty($textAmount)) {
|
||||
return $textAmount;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'amount');
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
@@ -523,7 +536,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
|
||||
{
|
||||
if (!empty($hideItems)) {
|
||||
if (! empty($hideItems)) {
|
||||
return $hideItems;
|
||||
}
|
||||
|
||||
@@ -540,7 +553,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getHideName($type, $hideName)
|
||||
{
|
||||
if (!empty($hideName)) {
|
||||
if (! empty($hideName)) {
|
||||
return $hideName;
|
||||
}
|
||||
|
||||
@@ -561,7 +574,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getHideDescription($type, $hideDescription)
|
||||
{
|
||||
if (!empty($hideDescription)) {
|
||||
if (! empty($hideDescription)) {
|
||||
return $hideDescription;
|
||||
}
|
||||
|
||||
@@ -582,7 +595,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getHideQuantity($type, $hideQuantity)
|
||||
{
|
||||
if (!empty($hideQuantity)) {
|
||||
if (! empty($hideQuantity)) {
|
||||
return $hideQuantity;
|
||||
}
|
||||
|
||||
@@ -603,7 +616,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getHidePrice($type, $hidePrice)
|
||||
{
|
||||
if (!empty($hidePrice)) {
|
||||
if (! empty($hidePrice)) {
|
||||
return $hidePrice;
|
||||
}
|
||||
|
||||
@@ -624,7 +637,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getHideDiscount($type, $hideDiscount)
|
||||
{
|
||||
if (!empty($hideDiscount)) {
|
||||
if (! empty($hideDiscount)) {
|
||||
return $hideDiscount;
|
||||
}
|
||||
|
||||
@@ -645,7 +658,7 @@ abstract class DocumentTemplate extends Base
|
||||
|
||||
protected function getHideAmount($type, $hideAmount)
|
||||
{
|
||||
if (!empty($hideAmount)) {
|
||||
if (! empty($hideAmount)) {
|
||||
return $hideAmount;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
abstract class Form extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $name;
|
||||
|
||||
/** @var string */
|
||||
public $label;
|
||||
|
||||
/** @var string */
|
||||
public $id;
|
||||
|
||||
public $value;
|
||||
|
||||
/** @var string */
|
||||
public $valueKey;
|
||||
|
||||
/** @var string */
|
||||
public $placeholder;
|
||||
|
||||
/** @var array */
|
||||
public $options;
|
||||
|
||||
/** @var array */
|
||||
public $option;
|
||||
|
||||
/** @var string */
|
||||
public $optionKey;
|
||||
|
||||
/** @var string */
|
||||
public $optionValue;
|
||||
|
||||
/** @var string */
|
||||
public $checked;
|
||||
|
||||
/** @var string */
|
||||
public $checkedKey;
|
||||
|
||||
/** @var string */
|
||||
public $selected;
|
||||
|
||||
/** @var string */
|
||||
public $selectedKey;
|
||||
|
||||
/** @var string */
|
||||
public $rows;
|
||||
|
||||
/** @var bool */
|
||||
public $remote;
|
||||
|
||||
/** @var bool */
|
||||
public $multiple;
|
||||
|
||||
/** @var bool */
|
||||
public $addNew;
|
||||
|
||||
/** @var bool */
|
||||
public $group;
|
||||
|
||||
/** @var bool */
|
||||
public $disabled;
|
||||
|
||||
/** @var bool */
|
||||
public $readonly;
|
||||
|
||||
/** @var bool */
|
||||
public $required;
|
||||
|
||||
/** @var bool */
|
||||
public $notRequired;
|
||||
|
||||
/** @var string */
|
||||
public $formGroupClass = 'sm:col-span-3';
|
||||
|
||||
/** @var string */
|
||||
public $inputGroupClass = '';
|
||||
|
||||
/** @var array */
|
||||
public $custom_attributes = [];
|
||||
|
||||
/** @var array */
|
||||
public $dynamicAttributes = [];
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $name = '', string $type = 'text', string $label = '', string $id = null, $value = '', $valueKey = null, string $placeholder = '',
|
||||
$options = [], $option = [], string $optionKey = 'id', string $optionValue = 'name', $checked = null, $checkedKey = null, $selected = null, $selectedKey = null, $rows = '3',
|
||||
$remote = false, $multiple = false, $addNew = false, $group = false,
|
||||
bool $disabled = false, bool $readonly = false, bool $required = true, bool $notRequired = false,
|
||||
string $formGroupClass = '', string $inputGroupClass = '',
|
||||
$dynamicAttributes = '',
|
||||
) {
|
||||
$this->type = $this->getType($type);
|
||||
$this->name = $this->getName($name);
|
||||
$this->label = $label;
|
||||
$this->id = $id ?? $name;
|
||||
$this->value = $this->getValue($value, $valueKey);
|
||||
$this->placeholder = $this->getPlaceholder($placeholder);
|
||||
$this->rows = $rows;
|
||||
|
||||
$this->remote = $remote;
|
||||
$this->multiple = $multiple;
|
||||
$this->addNew = $addNew;
|
||||
$this->group = $group;
|
||||
|
||||
$this->disabled = $disabled;
|
||||
$this->readonly = $readonly;
|
||||
$this->required = $this->getRequired($required, $notRequired);
|
||||
|
||||
$this->options = $this->getOptions($options);
|
||||
$this->option = $option;
|
||||
$this->optionKey = $optionKey;
|
||||
$this->optionValue = $optionValue;
|
||||
$this->checked = $this->getChecked($checked, $checkedKey);
|
||||
$this->selected = $this->getSelected($selected, $selectedKey);
|
||||
|
||||
$this->formGroupClass = $this->getFromGroupClass($formGroupClass);
|
||||
$this->inputGroupClass = $this->getInputGroupClass($inputGroupClass);
|
||||
|
||||
$this->custom_attributes = $this->getCustomAttributes();
|
||||
|
||||
$this->setDynamicAttributes($dynamicAttributes);
|
||||
}
|
||||
|
||||
protected function getType($type)
|
||||
{
|
||||
if (! empty($type) && (! empty($this->type) && $type != 'text')) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
if (! empty($this->type)) {
|
||||
return $this->type;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getName($name)
|
||||
{
|
||||
if (! empty($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
protected function getValue($value, $valueKey)
|
||||
{
|
||||
if ($value != '') {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (empty($valueKey)) {
|
||||
$valueKey = $this->name;
|
||||
}
|
||||
|
||||
if (empty($valueKey)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// set model value.
|
||||
$model = $this->getParentData('model');
|
||||
|
||||
$value_keys = explode('.', $valueKey);
|
||||
|
||||
if (count($value_keys) > 1) {
|
||||
$valueKey = $value_keys[0];
|
||||
}
|
||||
|
||||
if (! empty($model->{$valueKey})) {
|
||||
$value = $model->{$valueKey};
|
||||
}
|
||||
|
||||
if ($model instanceof Collection) {
|
||||
$value = $model->get($valueKey);
|
||||
}
|
||||
|
||||
if (count($value_keys) > 1) {
|
||||
$value = $value[0]->{$value_keys[1]};
|
||||
}
|
||||
|
||||
if (empty($value) && request()->has($valueKey)) {
|
||||
$value = request()->get($valueKey);
|
||||
}
|
||||
|
||||
return old($valueKey, $value);
|
||||
}
|
||||
|
||||
protected function getPlaceholder($placeholder)
|
||||
{
|
||||
if (! empty($placeholder)) {
|
||||
return $placeholder;
|
||||
}
|
||||
|
||||
$label = $this->label;
|
||||
|
||||
if (! empty($this->label) && ! empty($this->label->contents)) {
|
||||
$label = $this->name;
|
||||
}
|
||||
|
||||
return trans('general.form.enter', ['field' => $label]);
|
||||
}
|
||||
|
||||
protected function getOptions($options)
|
||||
{
|
||||
if (! empty($options)) {
|
||||
if (is_array($options) && ! $this->group) {
|
||||
$o = collect();
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$o->push((object) $value);
|
||||
} else {
|
||||
$o->push((object) [
|
||||
'id' => $key,
|
||||
'name' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$options = $o;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function getChecked($checked, $checkedKey)
|
||||
{
|
||||
return $this->getValue($checked, $checkedKey);
|
||||
}
|
||||
|
||||
protected function getSelected($selected, $selectedKey)
|
||||
{
|
||||
return $this->getValue($selected, $selectedKey);
|
||||
}
|
||||
|
||||
protected function getRequired($required, $notRequired)
|
||||
{
|
||||
if (! empty($notRequired)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $required;
|
||||
}
|
||||
|
||||
protected function getFromGroupClass($formGroupClass)
|
||||
{
|
||||
if (! empty($formGroupClass)) {
|
||||
return $formGroupClass;
|
||||
}
|
||||
|
||||
return $this->formGroupClass;
|
||||
}
|
||||
|
||||
protected function getInputGroupClass($inputGroupClass)
|
||||
{
|
||||
if (! empty($inputGroupClass)) {
|
||||
return $inputGroupClass;
|
||||
}
|
||||
|
||||
return $this->inputGroupClass;
|
||||
}
|
||||
|
||||
protected function getCustomAttributes()
|
||||
{
|
||||
$attributes = [];
|
||||
|
||||
if (! empty($this->required)) {
|
||||
$attributes['required'] = $this->required;
|
||||
}
|
||||
|
||||
if (! empty($this->disabled)) {
|
||||
$attributes['disabled'] = $this->disabled;
|
||||
}
|
||||
|
||||
if (! empty($this->readonly)) {
|
||||
$attributes['readonly'] = $this->readonly;
|
||||
}
|
||||
|
||||
foreach ($this->custom_attributes as $key => $value) {
|
||||
$attributes[$key] = $value;
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
protected function setDynamicAttributes($dynamicAttributes)
|
||||
{
|
||||
if (! empty($dynamicAttributes)) {
|
||||
$this->dynamicAttributes = $dynamicAttributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class Transaction extends Component
|
||||
{
|
||||
public function getTextFromConfig($type, $config_key, $default_key = '', $trans_type = 'trans')
|
||||
{
|
||||
$translation = '';
|
||||
|
||||
// if set config translation config_key
|
||||
if ($translation = config('type.' . $type . '.translation.' . $config_key)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$prefix = config('type.' . $type . '.translation.prefix');
|
||||
|
||||
if (!empty($alias)) {
|
||||
$alias .= '::';
|
||||
}
|
||||
|
||||
// This magic trans key..
|
||||
$translations = [
|
||||
'general' => $alias . 'general.' . $default_key,
|
||||
'prefix' => $alias . $prefix . '.' . $default_key,
|
||||
'config_general' => $alias . 'general.' . $config_key,
|
||||
'config_prefix' => $alias . $prefix . '.' . $config_key,
|
||||
];
|
||||
|
||||
switch ($trans_type) {
|
||||
case 'trans':
|
||||
foreach ($translations as $trans) {
|
||||
if (trans($trans) !== $trans) {
|
||||
return $trans;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'trans_choice':
|
||||
foreach ($translations as $trans_choice) {
|
||||
if (trans_choice($trans_choice, 1) !== $trans_choice) {
|
||||
return $trans_choice;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $translation;
|
||||
}
|
||||
|
||||
public function getRouteFromConfig($type, $config_key, $config_parameters = [])
|
||||
{
|
||||
$route = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($route = config('type.' . $type . '.route.' . $config_key)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$prefix = config('type.' . $type . '.route.prefix');
|
||||
|
||||
// if use module set module alias
|
||||
if (!empty($alias)) {
|
||||
$route .= $alias . '.';
|
||||
}
|
||||
|
||||
if (!empty($prefix)) {
|
||||
$route .= $prefix . '.';
|
||||
}
|
||||
|
||||
$route .= $config_key;
|
||||
|
||||
try {
|
||||
route($route, $config_parameters);
|
||||
} catch (\Exception $e) {
|
||||
try {
|
||||
$route = Str::plural($type, 2) . '.' . $config_key;
|
||||
|
||||
route($route, $config_parameters);
|
||||
} catch (\Exception $e) {
|
||||
$route = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
public function getPermissionFromConfig($type, $config_key)
|
||||
{
|
||||
$permission = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($permission = config('type.' . $type . '.permission.' . $config_key)) {
|
||||
return $permission;
|
||||
}
|
||||
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$group = config('type.' . $type . '.group');
|
||||
$prefix = config('type.' . $type . '.permission.prefix');
|
||||
|
||||
$permission = $config_key . '-';
|
||||
|
||||
// if use module set module alias
|
||||
if (!empty($alias)) {
|
||||
$permission .= $alias . '-';
|
||||
}
|
||||
|
||||
// if controller in folder it must
|
||||
if (!empty($group)) {
|
||||
$permission .= $group . '-';
|
||||
}
|
||||
|
||||
$permission .= $prefix;
|
||||
|
||||
return $permission;
|
||||
}
|
||||
|
||||
public function getHideFromConfig($type, $config_key)
|
||||
{
|
||||
$hide = false;
|
||||
|
||||
$hides = config('type.' . $type . '.hide');
|
||||
|
||||
if (!empty($hides) && (in_array($config_key, $hides))) {
|
||||
$hide = true;
|
||||
}
|
||||
|
||||
return $hide;
|
||||
}
|
||||
|
||||
public function getClassFromConfig($type, $config_key)
|
||||
{
|
||||
$class_key = 'type.' . $type . '.class.' . $config_key;
|
||||
|
||||
return config($class_key, '');
|
||||
}
|
||||
|
||||
public function getCategoryFromConfig($type)
|
||||
{
|
||||
$category_type = '';
|
||||
|
||||
// if set config trasnlation config_key
|
||||
if ($category_type = config('type.' . $type . '.category_type')) {
|
||||
return $category_type;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$category_type = 'expense';
|
||||
break;
|
||||
case 'item':
|
||||
$category_type = 'item';
|
||||
break;
|
||||
case 'other':
|
||||
$category_type = 'other';
|
||||
break;
|
||||
case 'transfer':
|
||||
$category_type = 'transfer';
|
||||
break;
|
||||
default:
|
||||
$category_type = 'income';
|
||||
break;
|
||||
}
|
||||
|
||||
return $category_type;
|
||||
}
|
||||
}
|
||||
+157
-374
@@ -1,23 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
namespace App\Abstracts\View\Components\Transactions;
|
||||
|
||||
use App\Abstracts\View\Components\Transaction as Base;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Media;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Modules;
|
||||
use File;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Str;
|
||||
use Image;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
abstract class TransactionShow extends Base
|
||||
abstract class Show extends Component
|
||||
{
|
||||
use DateTime, Transactions;
|
||||
use DateTime, Transactions, ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'transaction';
|
||||
public const DEFAULT_TYPE = 'transaction';
|
||||
public const DEFAULT_PLURAL_TYPE = 'transactions';
|
||||
|
||||
public $type;
|
||||
|
||||
@@ -34,9 +39,6 @@ abstract class TransactionShow extends Base
|
||||
|
||||
public $date_format;
|
||||
|
||||
/** @var string */
|
||||
public $routePrefix;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonAddNew;
|
||||
|
||||
@@ -49,6 +51,9 @@ abstract class TransactionShow extends Base
|
||||
/** @var bool */
|
||||
public $hideButtonDuplicate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonConnect;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonPrint;
|
||||
|
||||
@@ -61,6 +66,9 @@ abstract class TransactionShow extends Base
|
||||
/** @var bool */
|
||||
public $hideButtonPdf;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonEnd;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonDelete;
|
||||
|
||||
@@ -68,13 +76,16 @@ abstract class TransactionShow extends Base
|
||||
public $checkButtonReconciled;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonGroupDivider1;
|
||||
public $hideDivider1;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonGroupDivider2;
|
||||
public $hideDivider2;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonGroupDivider3;
|
||||
public $hideDivider3;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDivider4;
|
||||
|
||||
/** @var string */
|
||||
public $permissionCreate;
|
||||
@@ -100,6 +111,9 @@ abstract class TransactionShow extends Base
|
||||
/** @var string */
|
||||
public $routeContactShow;
|
||||
|
||||
/** @var string */
|
||||
public $shareRoute;
|
||||
|
||||
/** @var string */
|
||||
public $signedUrl;
|
||||
|
||||
@@ -109,60 +123,15 @@ abstract class TransactionShow extends Base
|
||||
/** @var string */
|
||||
public $routeButtonPdf;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonEnd;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonDelete;
|
||||
|
||||
/** @var string */
|
||||
public $textDeleteModal;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeader;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderAccount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderCategory;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderContact;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderPaidAt;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderAccount;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderCategory;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderContact;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderAmount;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderPaidAt;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderAccount;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderCategory;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderContact;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderAmount;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderPaidAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompany;
|
||||
|
||||
@@ -190,6 +159,9 @@ abstract class TransactionShow extends Base
|
||||
/** @var bool */
|
||||
public $hideContentTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hidePaidAt;
|
||||
|
||||
@@ -211,9 +183,15 @@ abstract class TransactionShow extends Base
|
||||
/** @var bool */
|
||||
public $hideAmount;
|
||||
|
||||
/** @var string */
|
||||
public $textButtonAddNew;
|
||||
|
||||
/** @var string */
|
||||
public $textContentTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textPaidAt;
|
||||
|
||||
@@ -298,24 +276,19 @@ abstract class TransactionShow extends Base
|
||||
/** @var string */
|
||||
public $routeDocumentShow;
|
||||
|
||||
/** @var bool */
|
||||
public $hideSchedule;
|
||||
|
||||
/** @var bool */
|
||||
public $hideChildren;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAttachment;
|
||||
|
||||
public $attachment;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFooter;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFooterHistories;
|
||||
|
||||
public $histories;
|
||||
|
||||
/** @var string */
|
||||
public $textHistories;
|
||||
|
||||
/** @var string */
|
||||
public $classFooterHistories;
|
||||
/** @var array */
|
||||
public $connectTranslations;
|
||||
|
||||
/** @var string */
|
||||
public $textRecurringType;
|
||||
@@ -330,32 +303,28 @@ abstract class TransactionShow extends Base
|
||||
*/
|
||||
public function __construct(
|
||||
$type, $transaction, $transactionTemplate = '', $logo = '', array $payment_methods = [],
|
||||
bool $hideButtonAddNew = false, bool $hideButtonMoreActions = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonPrint = false, bool $hideButtonShare = false,
|
||||
bool $hideButtonEmail = false, bool $hideButtonPdf = false, bool $hideButtonDelete = false, bool $checkButtonReconciled = true,
|
||||
bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false,
|
||||
bool $hideButtonAddNew = false, bool $hideButtonMoreActions = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonConnect = false, bool $hideButtonPrint = false, bool $hideButtonShare = false,
|
||||
bool $hideButtonEmail = false, bool $hideButtonPdf = false, bool $hideButtonEnd = false, bool $hideButtonDelete = false, bool $checkButtonReconciled = true,
|
||||
bool $hideDivider1 = false, bool $hideDivider2 = false, bool $hideDivider3 = false, bool $hideDivider4 = false,
|
||||
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
|
||||
string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $signedUrl = '',
|
||||
string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonDelete = '', string $routeContactShow = '',
|
||||
string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $shareRoute = '', string $signedUrl = '',
|
||||
string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonEnd = '', string $routeButtonDelete = '', string $routeContactShow = '',
|
||||
string $textDeleteModal = '',
|
||||
bool $hideHeader = false, bool $hideHeaderAccount = false, bool $hideHeaderCategory = false, bool $hideHeaderContact = false, bool $hideHeaderAmount = false, bool $hideHeaderPaidAt = false,
|
||||
string $textHeaderAccount = '', string $textHeaderCategory = '', string $textHeaderContact = '', string $textHeaderAmount = '', string $textHeaderPaidAt = '',
|
||||
string $classHeaderAccount = '', string $classHeaderCategory = '', string $classHeaderContact = '', string $classHeaderAmount = '', string $classHeaderPaidAt = '',
|
||||
|
||||
bool $hideCompany = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false,
|
||||
bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false,
|
||||
bool $hideContentTitle = false,bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false, bool $hideDescription = false,
|
||||
bool $hideAmount = false,
|
||||
string $textContentTitle = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '',
|
||||
bool $hideContentTitle = false, bool $hideNumber = false, bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false,
|
||||
bool $hideDescription = false, bool $hideAmount = false,
|
||||
string $textContentTitle = '', string $textNumber = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '',
|
||||
string $textAmount = '', string $textPaidBy = '',
|
||||
bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false,
|
||||
bool $hideContactPhone = false, bool $hideContactEmail = false,
|
||||
bool $hideRelated = false, bool $hideRelatedDocumentNumber = false, bool $hideRelatedContact = false, bool $hideRelatedDocumentDate = false, bool $hideRelatedDocumentAmount = false, bool $hideRelatedAmount = false,
|
||||
string $textRelatedTransansaction = '', string $textRelatedDocumentNumber = '', string $textRelatedContact = '', string $textRelatedDocumentDate = '', string $textRelatedDocumentAmount = '', string $textRelatedAmount = '',
|
||||
string $routeDocumentShow = '',
|
||||
string $routeDocumentShow = '', string $textButtonAddNew = '',
|
||||
|
||||
bool $hideAttachment = false, $attachment = [],
|
||||
bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [],
|
||||
string $textHistories = '', string $classFooterHistories = '', string $textRecurringType = '', bool $hideRecurringMessage = false
|
||||
bool $hideSchedule = false, bool $hideChildren = false, bool $hideAttachment = false, $attachment = [],
|
||||
array $connectTranslations = [], string $textRecurringType = '', bool $hideRecurringMessage = false
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->transaction = $transaction;
|
||||
@@ -363,24 +332,25 @@ abstract class TransactionShow extends Base
|
||||
$this->logo = $this->getLogo($logo);
|
||||
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
|
||||
$this->date_format = $this->getCompanyDateFormat();
|
||||
$this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType);
|
||||
$this->hideRecurringMessage = $hideRecurringMessage;
|
||||
$this->routePrefix = $this->getRoutePrefix($type);
|
||||
|
||||
// Navbar Hide
|
||||
$this->hideButtonAddNew = $hideButtonAddNew;
|
||||
$this->hideButtonMoreActions = $hideButtonMoreActions;
|
||||
$this->hideButtonEdit = $hideButtonEdit;
|
||||
$this->hideButtonDuplicate = $hideButtonDuplicate;
|
||||
$this->hideButtonPrint = $hideButtonPrint;
|
||||
$this->hideButtonDuplicate = $hideButtonDuplicate;
|
||||
$this->hideButtonConnect = $hideButtonConnect;
|
||||
$this->hideButtonPrint = $hideButtonPrint;
|
||||
$this->hideButtonShare = $hideButtonShare;
|
||||
$this->hideButtonEmail = $hideButtonEmail;
|
||||
$this->hideButtonPdf = $hideButtonPdf;
|
||||
$this->hideButtonPdf = $hideButtonPdf;
|
||||
$this->hideButtonEnd = $hideButtonEnd;
|
||||
$this->hideButtonDelete = $hideButtonDelete;
|
||||
$this->checkButtonReconciled = $checkButtonReconciled;
|
||||
$this->hideButtonGroupDivider1 = $hideButtonGroupDivider1;
|
||||
$this->hideButtonGroupDivider2 = $hideButtonGroupDivider2;
|
||||
$this->hideButtonGroupDivider3 = $hideButtonGroupDivider3;
|
||||
|
||||
$this->hideDivider1 = $hideDivider1;
|
||||
$this->hideDivider2 = $hideDivider2;
|
||||
$this->hideDivider3 = $hideDivider3;
|
||||
$this->hideDivider4 = $hideDivider4;
|
||||
|
||||
// Navbar Permission
|
||||
$this->permissionCreate = $this->getPermissionCreate($type, $permissionCreate);
|
||||
@@ -392,38 +362,23 @@ abstract class TransactionShow extends Base
|
||||
$this->routeButtonEdit = $this->getRouteButtonEdit($type, $routeButtonEdit);
|
||||
$this->routeButtonDuplicate = $this->getRouteButtonDuplicate($type, $routeButtonDuplicate);
|
||||
$this->routeButtonPrint = $this->getRouteButtonPrint($type, $routeButtonPrint);
|
||||
$this->shareRoute = $this->getShareRoute($type, $shareRoute);
|
||||
$this->signedUrl = $this->getSignedUrl($type, $signedUrl);
|
||||
$this->routeButtonEmail = $this->getRouteButtonEmail($type, $routeButtonEmail);
|
||||
$this->routeButtonPdf = $this->getRouteButtonPdf($type, $routeButtonPdf);
|
||||
$this->routeButtonEnd = $this->getRouteButtonEnd($type, $routeButtonEnd);
|
||||
$this->routeButtonDelete = $this->getRouteButtonDelete($type, $routeButtonDelete);
|
||||
$this->routeContactShow = $this->getRouteContactShow($type, $routeContactShow);
|
||||
|
||||
// Navbar Text
|
||||
$this->textButtonAddNew = $this->getTextButtonAddNew($type, $textButtonAddNew);
|
||||
$this->textDeleteModal = $textDeleteModal;
|
||||
|
||||
// Header Hide
|
||||
$this->hideHeader = $hideHeader;
|
||||
// Hide Schedule
|
||||
$this->hideSchedule = $hideSchedule;
|
||||
|
||||
$this->hideHeaderAccount = $hideHeaderAccount;
|
||||
$this->hideHeaderCategory = $hideHeaderCategory;
|
||||
$this->hideHeaderContact = $hideHeaderContact;
|
||||
$this->hideHeaderCategory = $hideHeaderCategory;
|
||||
$this->hideHeaderAmount = $hideHeaderAmount;
|
||||
$this->hideHeaderPaidAt = $hideHeaderPaidAt;
|
||||
|
||||
// Header Text
|
||||
$this->textHeaderAccount = $this->getTextHeaderAccount($type, $textHeaderAccount);
|
||||
$this->textHeaderCategory = $this->getTextHeaderCategory($type, $textHeaderCategory);
|
||||
$this->textHeaderContact = $this->getTextHeaderContact($type, $textHeaderContact);
|
||||
$this->textHeaderAmount = $this->getTextHeaderAmount($type, $textHeaderAmount);
|
||||
$this->textHeaderPaidAt = $this->gettextHeaderPaidAt($type, $textHeaderPaidAt);
|
||||
|
||||
// Header Class
|
||||
$this->classHeaderAccount = $this->getClassHeaderAccount($type, $classHeaderAccount);
|
||||
$this->classHeaderContact = $this->getClassHeaderContact($type, $classHeaderContact);
|
||||
$this->classHeaderCategory = $this->getClassHeaderCategory($type, $classHeaderCategory);
|
||||
$this->classHeaderAmount = $this->getClassHeaderAmount($type, $classHeaderAmount);
|
||||
$this->classHeaderPaidAt = $this->getClassHeaderPaidAt($type, $classHeaderPaidAt);
|
||||
// Hide Children
|
||||
$this->hideChildren = $hideChildren;
|
||||
|
||||
// Hide Attachment
|
||||
$this->hideAttachment = $hideAttachment;
|
||||
@@ -440,6 +395,7 @@ abstract class TransactionShow extends Base
|
||||
|
||||
// Transaction Information Hide checker
|
||||
$this->hideContentTitle = $hideContentTitle;
|
||||
$this->hideNumber = $hideNumber;
|
||||
$this->hidePaidAt = $hidePaidAt;
|
||||
$this->hideAccount = $hideAccount;
|
||||
$this->hideCategory = $hideCategory;
|
||||
@@ -450,6 +406,7 @@ abstract class TransactionShow extends Base
|
||||
|
||||
// Transaction Information Text
|
||||
$this->textContentTitle = $this->getTextContentTitle($type, $textContentTitle);
|
||||
$this->textNumber = $this->getTextNumber($type, $textNumber);
|
||||
$this->textPaidAt = $this->getTextPaidAt($type, $textPaidAt);
|
||||
$this->textAccount = $this->getTextAccount($type, $textAccount);
|
||||
$this->textCategory = $this->getTextCategory($type, $textCategory);
|
||||
@@ -495,14 +452,11 @@ abstract class TransactionShow extends Base
|
||||
$this->attachment = $transaction->attachment;
|
||||
}
|
||||
|
||||
// Histories Hide
|
||||
$this->hideFooter = $hideFooter;
|
||||
$this->hideFooterHistories = $hideFooterHistories;
|
||||
// Connect translations
|
||||
$this->connectTranslations = $this->getTranslationsForConnect($type);
|
||||
|
||||
// Histories
|
||||
$this->histories = $this->getHistories($histories);
|
||||
$this->textHistories = $this->getTextHistories($type, $textHistories);
|
||||
$this->classFooterHistories = $this->getClassFooterHistories($type, $classFooterHistories);
|
||||
$this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType);
|
||||
$this->hideRecurringMessage = $hideRecurringMessage;
|
||||
}
|
||||
|
||||
protected function getTransactionTemplate($type, $transactionTemplate)
|
||||
@@ -511,7 +465,7 @@ abstract class TransactionShow extends Base
|
||||
return $transactionTemplate;
|
||||
}
|
||||
|
||||
if ($template = config('type.' . $type . 'template', false)) {
|
||||
if ($template = config('type.transaction.' . $type . '.template', false)) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
@@ -580,13 +534,16 @@ abstract class TransactionShow extends Base
|
||||
return $routeButtonAddNew;
|
||||
}
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'create');
|
||||
//example route parameter.
|
||||
$parameter = 1;
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'create', $parameter);
|
||||
|
||||
if (!empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'revenues.create';
|
||||
return 'transactions.create';
|
||||
}
|
||||
|
||||
protected function getRouteButtonEdit($type, $routeButtonEdit)
|
||||
@@ -604,7 +561,7 @@ abstract class TransactionShow extends Base
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'revenues.edit';
|
||||
return 'transactions.edit';
|
||||
}
|
||||
|
||||
protected function getRouteButtonDuplicate($type, $routeButtonDuplicate)
|
||||
@@ -622,7 +579,7 @@ abstract class TransactionShow extends Base
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'revenues.duplicate';
|
||||
return 'transactions.duplicate';
|
||||
}
|
||||
|
||||
protected function getRouteButtonPrint($type, $routeButtonPrint)
|
||||
@@ -640,7 +597,25 @@ abstract class TransactionShow extends Base
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'revenues.print';
|
||||
return 'transactions.print';
|
||||
}
|
||||
|
||||
protected function getShareRoute($type, $shareRoute)
|
||||
{
|
||||
if (! empty($shareRoute)) {
|
||||
return $shareRoute;
|
||||
}
|
||||
|
||||
//example route parameter.
|
||||
$parameter = 1;
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'share', $parameter);
|
||||
|
||||
if (! empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'modals.transactions.share.create';
|
||||
}
|
||||
|
||||
protected function getSignedUrl($type, $signedUrl)
|
||||
@@ -649,8 +624,8 @@ abstract class TransactionShow extends Base
|
||||
return $signedUrl;
|
||||
}
|
||||
|
||||
$page = config('type.' . $type . '.route.prefix');
|
||||
$alias = config('type.' . $type . '.alias');
|
||||
$page = config('type.transaction.' . $type . '.route.prefix');
|
||||
$alias = config('type.transaction.' . $type . '.alias');
|
||||
|
||||
$route = '';
|
||||
|
||||
@@ -673,20 +648,20 @@ abstract class TransactionShow extends Base
|
||||
|
||||
protected function getRouteButtonEmail($type, $routeButtonEmail)
|
||||
{
|
||||
if (!empty($routeButtonEmail)) {
|
||||
if (! empty($routeButtonEmail)) {
|
||||
return $routeButtonEmail;
|
||||
}
|
||||
|
||||
//example route parameter.
|
||||
$parameter = 1;
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'email', $parameter);
|
||||
$route = $this->getRouteFromConfig($type, 'emails.create', $parameter, true);
|
||||
|
||||
if (!empty($route)) {
|
||||
if (! empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'revenues.email';
|
||||
return 'modals.transactions.emails.create';
|
||||
}
|
||||
|
||||
protected function getRouteButtonPdf($type, $routeButtonPdf)
|
||||
@@ -704,7 +679,25 @@ abstract class TransactionShow extends Base
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'revenues.pdf';
|
||||
return 'transactions.pdf';
|
||||
}
|
||||
|
||||
protected function getRouteButtonEnd($type, $routeButtonEnd)
|
||||
{
|
||||
if (!empty($routeButtonEnd)) {
|
||||
return $routeButtonEnd;
|
||||
}
|
||||
|
||||
//example route parameter.
|
||||
$parameter = 1;
|
||||
|
||||
$route = $this->getRouteFromConfig($type, 'end', $parameter);
|
||||
|
||||
if (!empty($route)) {
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'recurring-transactions.end';
|
||||
}
|
||||
|
||||
protected function getRouteButtonDelete($type, $routeButtonDelete)
|
||||
@@ -722,7 +715,7 @@ abstract class TransactionShow extends Base
|
||||
return $route;
|
||||
}
|
||||
|
||||
return 'revenues.destroy';
|
||||
return 'transactions.destroy';
|
||||
}
|
||||
|
||||
protected function getRouteContactShow($type, $routeContactShow)
|
||||
@@ -734,7 +727,7 @@ abstract class TransactionShow extends Base
|
||||
//example route parameter.
|
||||
$parameter = 1;
|
||||
|
||||
$route = Str::plural(config('type.' . $type . '.contact_type'), 2) . '.show';
|
||||
$route = Str::plural(config('type.transaction.' . $type . '.contact_type'), 2) . '.show';
|
||||
|
||||
try {
|
||||
route($route, $parameter);
|
||||
@@ -755,189 +748,19 @@ abstract class TransactionShow extends Base
|
||||
return 'customers.show';
|
||||
}
|
||||
|
||||
protected function getPermissionCreate($type, $permissionCreate)
|
||||
protected function getTextButtonAddNew($type, $textButtonAddNew)
|
||||
{
|
||||
if (!empty($permissionCreate)) {
|
||||
return $permissionCreate;
|
||||
if (!empty($textButtonAddNew)) {
|
||||
return $textButtonAddNew;
|
||||
}
|
||||
|
||||
$permissionCreate = $this->getPermissionFromConfig($type, 'create');
|
||||
|
||||
return $permissionCreate;
|
||||
}
|
||||
|
||||
protected function getPermissionUpdate($type, $permissionUpdate)
|
||||
{
|
||||
if (!empty($permissionUpdate)) {
|
||||
return $permissionUpdate;
|
||||
}
|
||||
|
||||
$permissionUpdate = $this->getPermissionFromConfig($type, 'update');
|
||||
|
||||
return $permissionUpdate;
|
||||
}
|
||||
|
||||
protected function getPermissionDelete($type, $permissionDelete)
|
||||
{
|
||||
if (!empty($permissionDelete)) {
|
||||
return $permissionDelete;
|
||||
}
|
||||
|
||||
$permissionDelete = $this->getPermissionFromConfig($type, 'delete');
|
||||
|
||||
return $permissionDelete;
|
||||
}
|
||||
|
||||
protected function getTextHeaderAccount($type, $textHeaderAccount)
|
||||
{
|
||||
if (!empty($textHeaderAccount)) {
|
||||
return $textHeaderAccount;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_account', 'accounts', 'trans_choice');
|
||||
$translation = $this->getTextFromConfig($type, 'transactions');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
return trans('general.title.new', ['type' => trans_choice($translation, 1)]);
|
||||
}
|
||||
|
||||
return 'general.accounts';
|
||||
}
|
||||
|
||||
protected function getTextHeaderCategory($type, $textHeaderCategory)
|
||||
{
|
||||
if (!empty($textHeaderCategory)) {
|
||||
return $textHeaderCategory;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_category', 'categories', 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.categories';
|
||||
}
|
||||
|
||||
protected function getTextHeaderContact($type, $textHeaderContact)
|
||||
{
|
||||
if (!empty($textHeaderContact)) {
|
||||
return $textHeaderContact;
|
||||
}
|
||||
|
||||
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_contact', $default_key, 'trans_choice');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.customers';
|
||||
}
|
||||
|
||||
protected function getTextHeaderAmount($type, $textHeaderAmount)
|
||||
{
|
||||
if (!empty($textHeaderAmount)) {
|
||||
return $textHeaderAmount;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_amount', 'amount');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
|
||||
protected function getTextHeaderPaidAt($type, $textHeaderPaidAt)
|
||||
{
|
||||
if (!empty($textHeaderPaidAt)) {
|
||||
return $textHeaderPaidAt;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'header_paid_at', 'date');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.date';
|
||||
}
|
||||
|
||||
protected function getClassHeaderAccount($type, $classHeaderAccount)
|
||||
{
|
||||
if (!empty($classHeaderAccount)) {
|
||||
return $classHeaderAccount;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'header_account');
|
||||
|
||||
if (!empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-3';
|
||||
}
|
||||
|
||||
protected function getClassHeaderContact($type, $classHeaderContact)
|
||||
{
|
||||
if (!empty($classHeaderContact)) {
|
||||
return $classHeaderContact;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'header_contact');
|
||||
|
||||
if (!empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-2';
|
||||
}
|
||||
|
||||
protected function getClassHeaderCategory($type, $classHeaderCategory)
|
||||
{
|
||||
if (!empty($classHeaderCategory)) {
|
||||
return $classHeaderCategory;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'header_category');
|
||||
|
||||
if (!empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-3';
|
||||
}
|
||||
|
||||
protected function getClassHeaderAmount($type, $classHeaderAmount)
|
||||
{
|
||||
if (!empty($classHeaderAmount)) {
|
||||
return $classHeaderAmount;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'header_amount');
|
||||
|
||||
if (!empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-2';
|
||||
}
|
||||
|
||||
protected function getClassHeaderPaidAt($type, $classHeaderPaidAt)
|
||||
{
|
||||
if (!empty($classHeaderPaidAt)) {
|
||||
return $classHeaderPaidAt;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'header_paid_at');
|
||||
|
||||
if (!empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-2';
|
||||
return trans('general.title.new', ['type' => trans_choice('general.' . Str::plural($type), 1)]);
|
||||
}
|
||||
|
||||
protected function getTextContentTitle($type, $textContentTitle)
|
||||
@@ -953,7 +776,7 @@ abstract class TransactionShow extends Base
|
||||
$default_key = 'payment_made';
|
||||
break;
|
||||
default:
|
||||
$default_key = 'revenue_received';
|
||||
$default_key = 'receipts';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -963,7 +786,16 @@ abstract class TransactionShow extends Base
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.revenue_received';
|
||||
return 'general.receipts';
|
||||
}
|
||||
|
||||
protected function getTextNumber($type, $textNumber)
|
||||
{
|
||||
if (!empty($textNumber)) {
|
||||
return $textNumber;
|
||||
}
|
||||
|
||||
return 'general.numbers';
|
||||
}
|
||||
|
||||
protected function getTextPaidAt($type, $textPaidAt)
|
||||
@@ -1094,7 +926,7 @@ abstract class TransactionShow extends Base
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.paid_by';
|
||||
return 'transactions.paid_by';
|
||||
}
|
||||
|
||||
protected function getTextRelatedTransansaction($type, $textRelatedTransansaction)
|
||||
@@ -1120,7 +952,7 @@ abstract class TransactionShow extends Base
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.related_invoice';
|
||||
return 'transactions.related_invoice';
|
||||
}
|
||||
|
||||
protected function getTextRelatedDocumentNumber($type, $textRelatedDocumentNumber)
|
||||
@@ -1144,7 +976,7 @@ abstract class TransactionShow extends Base
|
||||
return $textRelatedContact;
|
||||
}
|
||||
|
||||
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
||||
$default_key = Str::plural(config('type.transaction.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'related_contact', $default_key, 'trans_choice');
|
||||
|
||||
@@ -1244,50 +1076,9 @@ abstract class TransactionShow extends Base
|
||||
return 'invoices.show';
|
||||
}
|
||||
|
||||
protected function getHistories($histories)
|
||||
{
|
||||
if (!empty($histories)) {
|
||||
return $histories;
|
||||
}
|
||||
|
||||
$histories[] = $this->transaction;
|
||||
|
||||
return $histories;
|
||||
}
|
||||
|
||||
protected function getTextHistories($type, $textHistories)
|
||||
{
|
||||
if (!empty($textHistories)) {
|
||||
return $textHistories;
|
||||
}
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'histories', 'histories');
|
||||
|
||||
if (!empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'invoices.histories';
|
||||
}
|
||||
|
||||
protected function getClassFooterHistories($type, $classFooterHistories)
|
||||
{
|
||||
if (!empty($classFooterHistories)) {
|
||||
return $classFooterHistories;
|
||||
}
|
||||
|
||||
$class = $this->getClassFromConfig($type, 'footer_histories');
|
||||
|
||||
if (!empty($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
|
||||
}
|
||||
|
||||
protected function getTextRecurringType($type, $textRecurringType)
|
||||
{
|
||||
if (!empty($textRecurringType)) {
|
||||
if (! empty($textRecurringType)) {
|
||||
return $textRecurringType;
|
||||
}
|
||||
|
||||
@@ -1295,18 +1086,10 @@ abstract class TransactionShow extends Base
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key);
|
||||
|
||||
if (!empty($translation)) {
|
||||
if (! empty($translation)) {
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'general.revenues';
|
||||
}
|
||||
|
||||
protected function getRoutePrefix($type) {
|
||||
if ($prefix = config('type.' . $type . '.route.prefix', false)){
|
||||
return 'revenues';
|
||||
}
|
||||
|
||||
return $prefix;
|
||||
}
|
||||
}
|
||||
+59
-38
@@ -1,23 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
namespace App\Abstracts\View\Components\Transactions;
|
||||
|
||||
use App\Abstracts\View\Components\Transaction as Base;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Media;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Modules;
|
||||
use File;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Image;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Storage;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
abstract class TransactionTemplate extends Base
|
||||
abstract class Template extends Component
|
||||
{
|
||||
use DateTime;
|
||||
use Transactions;
|
||||
use DateTime, Transactions, ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'transaction';
|
||||
public const DEFAULT_TYPE = 'transaction';
|
||||
public const DEFAULT_PLURAL_TYPE = 'transactions';
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
@@ -56,6 +60,9 @@ abstract class TransactionTemplate extends Base
|
||||
/** @var bool */
|
||||
public $hideContentTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hidePaidAt;
|
||||
|
||||
@@ -80,6 +87,9 @@ abstract class TransactionTemplate extends Base
|
||||
/** @var string */
|
||||
public $textContentTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textPaidAt;
|
||||
|
||||
@@ -176,10 +186,10 @@ abstract class TransactionTemplate extends Base
|
||||
$type, $transaction, $logo = '', array $payment_methods = [],
|
||||
bool $hideCompany = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false,
|
||||
bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false,
|
||||
bool $hideContentTitle = false,bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false, bool $hideDescription = false,
|
||||
bool $hideAmount = false,
|
||||
string $textContentTitle = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '',
|
||||
string $textAmount = '', string $textPaidBy = '', string $textContactInfo = '',
|
||||
bool $hideContentTitle = false, bool $hideNumber = false, bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false,
|
||||
bool $hideDescription = false, bool $hideAmount = false,
|
||||
string $textContentTitle = '', string $textNumber = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '',
|
||||
string $textDescription = '', string $textAmount = '', string $textPaidBy = '', string $textContactInfo = '',
|
||||
bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false,
|
||||
bool $hideContactPhone = false, bool $hideContactEmail = false,
|
||||
bool $hideRelated = false, bool $hideRelatedDocumentNumber = false, bool $hideRelatedContact = false, bool $hideRelatedDocumentDate = false, bool $hideRelatedDocumentAmount = false, bool $hideRelatedAmount = false,
|
||||
@@ -204,6 +214,7 @@ abstract class TransactionTemplate extends Base
|
||||
|
||||
// Transaction Information Hide checker
|
||||
$this->hideContentTitle = $hideContentTitle;
|
||||
$this->hideNumber = $hideNumber;
|
||||
$this->hidePaidAt = $hidePaidAt;
|
||||
$this->hideAccount = $hideAccount;
|
||||
$this->hideCategory = $hideCategory;
|
||||
@@ -214,6 +225,7 @@ abstract class TransactionTemplate extends Base
|
||||
|
||||
// Transaction Information Text
|
||||
$this->textContentTitle = $this->getTextContentTitle($type, $textContentTitle);
|
||||
$this->textNumber = $this->getTextNumber($type, $textNumber);
|
||||
$this->textPaidAt = $this->getTextPaidAt($type, $textPaidAt);
|
||||
$this->textAccount = $this->getTextAccount($type, $textAccount);
|
||||
$this->textCategory = $this->getTextCategory($type, $textCategory);
|
||||
@@ -252,26 +264,6 @@ abstract class TransactionTemplate extends Base
|
||||
$this->routeDocumentShow = $this->routeDocumentShow($type, $routeDocumentShow);
|
||||
}
|
||||
|
||||
protected function getTextContactInfo($type, $textContactInfo)
|
||||
{
|
||||
if (!empty($textContactInfo)) {
|
||||
return $textContactInfo;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textContactInfo = 'bills.bill_from';
|
||||
break;
|
||||
default:
|
||||
$textContactInfo = 'invoices.bill_to';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textContactInfo;
|
||||
}
|
||||
|
||||
protected function getLogo($logo)
|
||||
{
|
||||
if (!empty($logo)) {
|
||||
@@ -339,7 +331,7 @@ abstract class TransactionTemplate extends Base
|
||||
$default_key = 'payment_made';
|
||||
break;
|
||||
default:
|
||||
$default_key = 'revenue_received';
|
||||
$default_key = 'receipts';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -349,7 +341,16 @@ abstract class TransactionTemplate extends Base
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.revenue_received';
|
||||
return 'general.receipts';
|
||||
}
|
||||
|
||||
protected function getTextNumber($type, $textNumber)
|
||||
{
|
||||
if (!empty($textNumber)) {
|
||||
return $textNumber;
|
||||
}
|
||||
|
||||
return 'general.numbers';
|
||||
}
|
||||
|
||||
protected function getTextPaidAt($type, $textPaidAt)
|
||||
@@ -480,7 +481,27 @@ abstract class TransactionTemplate extends Base
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.paid_by';
|
||||
return 'transactions.paid_by';
|
||||
}
|
||||
|
||||
protected function getTextContactInfo($type, $textContactInfo)
|
||||
{
|
||||
if (!empty($textContactInfo)) {
|
||||
return $textContactInfo;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textContactInfo = 'bills.bill_from';
|
||||
break;
|
||||
default:
|
||||
$textContactInfo = 'invoices.bill_to';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textContactInfo;
|
||||
}
|
||||
|
||||
protected function getTextRelatedTransansaction($type, $textRelatedTransansaction)
|
||||
@@ -506,7 +527,7 @@ abstract class TransactionTemplate extends Base
|
||||
return $translation;
|
||||
}
|
||||
|
||||
return 'revenues.related_invoice';
|
||||
return 'transactions.related_invoice';
|
||||
}
|
||||
|
||||
protected function getTextRelatedDocumentNumber($type, $textRelatedDocumentNumber)
|
||||
@@ -530,7 +551,7 @@ abstract class TransactionTemplate extends Base
|
||||
return $textRelatedContact;
|
||||
}
|
||||
|
||||
$default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
|
||||
$default_key = Str::plural(config('type.transaction.' . $type . '.contact_type'), 2);
|
||||
|
||||
$translation = $this->getTextFromConfig($type, 'related_contact', $default_key, 'trans_choice');
|
||||
|
||||
@@ -1,747 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use App\Models\Common\Media;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Modules;
|
||||
use File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Str;
|
||||
use Image;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
abstract class TransferShow extends Component
|
||||
{
|
||||
use DateTime, Transactions;
|
||||
|
||||
public $transfer;
|
||||
|
||||
/** @var string */
|
||||
public $transferTemplate;
|
||||
|
||||
/** @var array */
|
||||
public $payment_methods;
|
||||
|
||||
public $date_format;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonAddNew;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonMoreActions;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonEdit;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonDuplicate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonPrint;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonShare;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonEmail;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonPdf;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonDelete;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonGroupDivider1;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonGroupDivider2;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonGroupDivider3;
|
||||
|
||||
/** @var string */
|
||||
public $permissionCreate;
|
||||
|
||||
/** @var string */
|
||||
public $permissionUpdate;
|
||||
|
||||
/** @var string */
|
||||
public $permissionDelete;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonAddNew;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonEdit;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonDuplicate;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonPrint;
|
||||
|
||||
/** @var string */
|
||||
public $signedUrl;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonEmail;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonPdf;
|
||||
|
||||
/** @var string */
|
||||
public $hideButtonTemplate;
|
||||
|
||||
/** @var string */
|
||||
public $routeButtonDelete;
|
||||
|
||||
/** @var string */
|
||||
public $routeFromAccountShow;
|
||||
|
||||
/** @var string */
|
||||
public $routeToAccountShow;
|
||||
|
||||
/** @var string */
|
||||
public $textDeleteModal;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeader;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderFromAccount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderToAccount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideHeaderPaidAt;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderFromAccount;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderToAccount;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderAmount;
|
||||
|
||||
/** @var string */
|
||||
public $textHeaderPaidAt;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderFromAccount;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderToAccount;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderAmount;
|
||||
|
||||
/** @var string */
|
||||
public $classHeaderPaidAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountBankName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountBankPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountBankAddress;
|
||||
|
||||
/** @var string */
|
||||
public $textFromAccountTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textFromAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountBankName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountBankPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountBankAddress;
|
||||
|
||||
/** @var string */
|
||||
public $textToAccountTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textToAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetails;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailDate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailPaymentMethod;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailReference;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailDescription;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailAmount;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailDate;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailPaymentMethod;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailReference;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailDescription;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAttachment;
|
||||
|
||||
public $attachment;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFooter;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFooterHistories;
|
||||
|
||||
public $histories;
|
||||
|
||||
/** @var string */
|
||||
public $textHistories;
|
||||
|
||||
/** @var string */
|
||||
public $classFooterHistories;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$transfer, $transferTemplate = '', array $payment_methods = [],
|
||||
bool $hideButtonAddNew = false, bool $hideButtonMoreActions = false, bool $hideButtonEdit = false, bool $hideButtonDuplicate = false, bool $hideButtonPrint = false, bool $hideButtonShare = false,
|
||||
bool $hideButtonEmail = false, bool $hideButtonPdf = false, bool $hideButtonTemplate = false, bool $hideButtonDelete = false,
|
||||
bool $hideButtonGroupDivider1 = false, bool $hideButtonGroupDivider2 = false, bool $hideButtonGroupDivider3 = false,
|
||||
string $permissionCreate = '', string $permissionUpdate = '', string $permissionDelete = '',
|
||||
string $routeButtonAddNew = '', string $routeButtonEdit = '', string $routeButtonDuplicate = '', string $routeButtonPrint = '', string $signedUrl = '',
|
||||
string $routeButtonEmail = '', string $routeButtonPdf = '', string $routeButtonDelete = '', string $routeFromAccountShow = '', string $routeToAccountShow = '',
|
||||
string $textDeleteModal = '',
|
||||
bool $hideHeader = false, bool $hideHeaderFromAccount = false, bool $hideHeaderToAccount = false, bool $hideHeaderAmount = false, bool $hideHeaderPaidAt = false,
|
||||
string $textHeaderFromAccount = '', string $textHeaderToAccount = '', string $textHeaderAmount = '', string $textHeaderPaidAt = '',
|
||||
string $classHeaderFromAccount = '', string $classHeaderToAccount = '', string $classHeaderAmount = '', string $classHeaderPaidAt = '',
|
||||
|
||||
bool $hideFromAccount = false, bool $hideFromAccountTitle = false, bool $hideFromAccountName = false, bool $hideFromAccountNumber = false,
|
||||
bool $hideFromAccountBankName = false, bool $hideFromAccountBankPhone = false, bool $hideFromAccountBankAddress = false,
|
||||
string $textFromAccountTitle = '', string $textFromAccountNumber = '',
|
||||
|
||||
bool $hideToAccount = false, bool $hideToAccountTitle = false, bool $hideToAccountName = false, bool $hideToAccountNumber = false,
|
||||
bool $hideToAccountBankName = false, bool $hideToAccountBankPhone = false, bool $hideToAccountBankAddress = false,
|
||||
string $textToAccountTitle = '', string $textToAccountNumber = '',
|
||||
|
||||
bool $hideDetails = false, bool $hideDetailTitle = false, bool $hideDetailDate = false, bool $hideDetailPaymentMethod = false,
|
||||
bool $hideDetailReference = false, bool $hideDetailDescription = false, bool $hideDetailAmount = false,
|
||||
string $textDetailTitle = '', string $textDetailDate = '', string $textDetailPaymentMethod = '', string $textDetailReference = '',
|
||||
string $textDetailDescription = '', string $textDetailAmount = '',
|
||||
|
||||
bool $hideAttachment = false, $attachment = [],
|
||||
bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [],
|
||||
string $textHistories = '', string $classFooterHistories = ''
|
||||
) {
|
||||
$this->transfer = $transfer;
|
||||
$this->transferTemplate = $this->getTransferTemplate($transferTemplate);
|
||||
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
|
||||
$this->date_format = $this->getCompanyDateFormat();
|
||||
|
||||
// Navbar Hide
|
||||
$this->hideButtonAddNew = $hideButtonAddNew;
|
||||
$this->hideButtonMoreActions = $hideButtonMoreActions;
|
||||
$this->hideButtonEdit = $hideButtonEdit;
|
||||
$this->hideButtonDuplicate = $hideButtonDuplicate;
|
||||
$this->hideButtonPrint = $hideButtonPrint;
|
||||
$this->hideButtonShare = $hideButtonShare;
|
||||
$this->hideButtonEmail = $hideButtonEmail;
|
||||
$this->hideButtonPdf = $hideButtonPdf;
|
||||
$this->hideButtonTemplate = $hideButtonTemplate;
|
||||
$this->hideButtonDelete = $hideButtonDelete;
|
||||
$this->hideButtonGroupDivider1 = $hideButtonGroupDivider1;
|
||||
$this->hideButtonGroupDivider2 = $hideButtonGroupDivider2;
|
||||
$this->hideButtonGroupDivider3 = $hideButtonGroupDivider3;
|
||||
|
||||
// Navbar Permission
|
||||
$this->permissionCreate = $this->getPermissionCreate($permissionCreate);
|
||||
$this->permissionUpdate = $this->getPermissionUpdate($permissionUpdate);
|
||||
$this->permissionDelete = $this->getPermissionDelete($permissionDelete);
|
||||
|
||||
// Navbar route
|
||||
$this->routeButtonAddNew = $this->getRouteButtonAddNew($routeButtonAddNew);
|
||||
$this->routeButtonEdit = $this->getRouteButtonEdit($routeButtonEdit);
|
||||
$this->routeButtonDuplicate = $this->getRouteButtonDuplicate($routeButtonDuplicate);
|
||||
$this->routeButtonPrint = $this->getRouteButtonPrint($routeButtonPrint);
|
||||
$this->signedUrl = $this->getSignedUrl($signedUrl);
|
||||
$this->routeButtonEmail = $this->getRouteButtonEmail($routeButtonEmail);
|
||||
$this->routeButtonPdf = $this->getRouteButtonPdf($routeButtonPdf);
|
||||
$this->routeButtonDelete = $this->getRouteButtonDelete($routeButtonDelete);
|
||||
$this->routeFromAccountShow = $this->getRouteFromAccountShow($routeFromAccountShow);
|
||||
$this->routeToAccountShow = $this->getRouteToAccountShow($routeToAccountShow);
|
||||
|
||||
// Navbar Text
|
||||
$this->textDeleteModal = $textDeleteModal;
|
||||
|
||||
// Header Hide
|
||||
$this->hideHeader = $hideHeader;
|
||||
|
||||
$this->hideHeaderFromAccount = $hideHeaderFromAccount;
|
||||
$this->hideHeaderToAccount = $hideHeaderToAccount;
|
||||
$this->hideHeaderToAccount = $hideHeaderToAccount;
|
||||
$this->hideHeaderAmount = $hideHeaderAmount;
|
||||
$this->hideHeaderPaidAt = $hideHeaderPaidAt;
|
||||
|
||||
// Header Text
|
||||
$this->textHeaderFromAccount = $this->getTextHeaderFromAccount($textHeaderFromAccount);
|
||||
$this->textHeaderToAccount = $this->getTextHeaderToAccount($textHeaderToAccount);
|
||||
$this->textHeaderAmount = $this->getTextHeaderAmount($textHeaderAmount);
|
||||
$this->textHeaderPaidAt = $this->gettextHeaderPaidAt($textHeaderPaidAt);
|
||||
|
||||
// Header Class
|
||||
$this->classHeaderFromAccount = $this->getclassHeaderFromAccount($classHeaderFromAccount);
|
||||
$this->classHeaderToAccount = $this->getClassHeaderToAccount($classHeaderToAccount);
|
||||
$this->classHeaderAmount = $this->getClassHeaderAmount($classHeaderAmount);
|
||||
$this->classHeaderPaidAt = $this->getclassHeaderPaidAt($classHeaderPaidAt);
|
||||
|
||||
// From account Hide
|
||||
$this->hideFromAccount = $hideFromAccount;
|
||||
$this->hideFromAccountTitle = $hideFromAccountTitle;
|
||||
$this->hideFromAccountName = $hideFromAccountName;
|
||||
$this->hideFromAccountNumber = $hideFromAccountNumber;
|
||||
$this->hideFromAccountBankName = $hideFromAccountBankName;
|
||||
$this->hideFromAccountBankPhone = $hideFromAccountBankPhone;
|
||||
$this->hideFromAccountBankAddress = $hideFromAccountBankAddress;
|
||||
|
||||
// From account text
|
||||
$this->textFromAccountTitle = $this->getTextFromAccountTitle($textFromAccountTitle);
|
||||
$this->textFromAccountNumber = $this->getTextFromAccountNumber($textFromAccountNumber);
|
||||
|
||||
// To account Hide
|
||||
$this->hideToAccount = $hideToAccount;
|
||||
$this->hideToAccountTitle = $hideToAccountTitle;
|
||||
$this->hideToAccountName = $hideToAccountName;
|
||||
$this->hideToAccountNumber = $hideToAccountNumber;
|
||||
$this->hideToAccountBankName = $hideToAccountBankName;
|
||||
$this->hideToAccountBankPhone = $hideToAccountBankPhone;
|
||||
$this->hideToAccountBankAddress = $hideToAccountBankAddress;
|
||||
|
||||
// To account text
|
||||
$this->textToAccountTitle = $this->getTextToAccountTitle($textToAccountTitle);
|
||||
$this->textToAccountNumber = $this->getTextToAccountNumber($textToAccountNumber);
|
||||
|
||||
// Detail Information Hide checker
|
||||
$this->hideDetails = $hideDetails;
|
||||
$this->hideDetailTitle = $hideDetailTitle;
|
||||
$this->hideDetailDate = $hideDetailDate;
|
||||
$this->hideDetailPaymentMethod = $hideDetailPaymentMethod;
|
||||
$this->hideDetailReference = $hideDetailReference;
|
||||
$this->hideDetailDescription = $hideDetailDescription;
|
||||
$this->hideDetailAmount = $hideDetailAmount;
|
||||
|
||||
// Related Information Text
|
||||
$this->textDetailTitle = $this->getTextDetailTitle($textDetailTitle);
|
||||
$this->textDetailDate = $this->getTextDetailDate($textDetailDate);
|
||||
$this->textDetailPaymentMethod = $this->getTextDetailPaymentMethod($textDetailPaymentMethod);
|
||||
$this->textDetailReference = $this->getTextDetailReference($textDetailReference);
|
||||
$this->textDetailDescription = $this->getTextDetailDescription($textDetailDescription);
|
||||
$this->textDetailAmount = $this->getTextDetailAmount($textDetailAmount);
|
||||
|
||||
// Hide Attachment
|
||||
$this->hideAttachment = $hideAttachment;
|
||||
|
||||
// Attachment data..
|
||||
$this->attachment = '';
|
||||
|
||||
if (!empty($attachment)) {
|
||||
$this->attachment = $attachment;
|
||||
} else if (!empty($transfer)) {
|
||||
$this->attachment = $transfer->attachment;
|
||||
}
|
||||
|
||||
// Histories Hide
|
||||
$this->hideFooter = $hideFooter;
|
||||
$this->hideFooterHistories = $hideFooterHistories;
|
||||
|
||||
// Histories
|
||||
$this->histories = $this->getHistories($histories);
|
||||
$this->textHistories = $this->getTextHistories($textHistories);
|
||||
$this->classFooterHistories = $this->getClassFooterHistories($classFooterHistories);
|
||||
}
|
||||
|
||||
protected function getTransferTemplate($transferTemplate)
|
||||
{
|
||||
if (!empty($transferTemplate)) {
|
||||
return $transferTemplate;
|
||||
}
|
||||
|
||||
return setting('transfer.template');
|
||||
}
|
||||
|
||||
protected function getRouteButtonAddNew($routeButtonAddNew)
|
||||
{
|
||||
if (!empty($routeButtonAddNew)) {
|
||||
return $routeButtonAddNew;
|
||||
}
|
||||
|
||||
return 'transfers.create';
|
||||
}
|
||||
|
||||
protected function getRouteButtonEdit($routeButtonEdit)
|
||||
{
|
||||
if (!empty($routeButtonEdit)) {
|
||||
return $routeButtonEdit;
|
||||
}
|
||||
|
||||
return 'transfers.edit';
|
||||
}
|
||||
|
||||
protected function getRouteButtonDuplicate($routeButtonDuplicate)
|
||||
{
|
||||
if (!empty($routeButtonDuplicate)) {
|
||||
return $routeButtonDuplicate;
|
||||
}
|
||||
|
||||
return 'transfers.duplicate';
|
||||
}
|
||||
|
||||
protected function getRouteButtonPrint($routeButtonPrint)
|
||||
{
|
||||
if (!empty($routeButtonPrint)) {
|
||||
return $routeButtonPrint;
|
||||
}
|
||||
|
||||
return 'transfers.print';
|
||||
}
|
||||
|
||||
protected function getSignedUrl($signedUrl)
|
||||
{
|
||||
if (!empty($signedUrl)) {
|
||||
return $signedUrl;
|
||||
}
|
||||
|
||||
try {
|
||||
$signedUrl = URL::signedRoute('signed.transfer.show', [$this->transfer->id]);
|
||||
} catch (\Exception $e) {
|
||||
$signedUrl = false;
|
||||
}
|
||||
|
||||
return $signedUrl;
|
||||
}
|
||||
|
||||
protected function getRouteButtonEmail($routeButtonEmail)
|
||||
{
|
||||
if (!empty($routeButtonEmail)) {
|
||||
return $routeButtonEmail;
|
||||
}
|
||||
|
||||
return 'transfers.email';
|
||||
}
|
||||
|
||||
protected function getRouteButtonPdf($routeButtonPdf)
|
||||
{
|
||||
if (!empty($routeButtonPdf)) {
|
||||
return $routeButtonPdf;
|
||||
}
|
||||
|
||||
return 'transfers.pdf';
|
||||
}
|
||||
|
||||
protected function getRouteButtonDelete($routeButtonDelete)
|
||||
{
|
||||
if (!empty($routeButtonDelete)) {
|
||||
return $routeButtonDelete;
|
||||
}
|
||||
|
||||
return 'transfers.destroy';
|
||||
}
|
||||
|
||||
protected function getRouteFromAccountShow($routeFromAccountShow)
|
||||
{
|
||||
if (!empty($routeFromAccountShow)) {
|
||||
return $routeFromAccountShow;
|
||||
}
|
||||
|
||||
return 'accounts.show';
|
||||
}
|
||||
|
||||
protected function getRouteToAccountShow($routeToAccountShow)
|
||||
{
|
||||
if (!empty($routeToAccountShow)) {
|
||||
return $routeToAccountShow;
|
||||
}
|
||||
|
||||
return 'accounts.show';
|
||||
}
|
||||
|
||||
protected function getPermissionCreate($permissionCreate)
|
||||
{
|
||||
if (!empty($permissionCreate)) {
|
||||
return $permissionCreate;
|
||||
}
|
||||
|
||||
return 'create-banking-transfers';
|
||||
}
|
||||
|
||||
protected function getPermissionUpdate($permissionUpdate)
|
||||
{
|
||||
if (!empty($permissionUpdate)) {
|
||||
return $permissionUpdate;
|
||||
}
|
||||
|
||||
return 'update-banking-transfers';
|
||||
}
|
||||
|
||||
protected function getPermissionDelete($permissionDelete)
|
||||
{
|
||||
if (!empty($permissionDelete)) {
|
||||
return $permissionDelete;
|
||||
}
|
||||
|
||||
return 'delete-banking-transfers';
|
||||
}
|
||||
|
||||
protected function getTextHeaderFromAccount($textHeaderFromAccount)
|
||||
{
|
||||
if (!empty($textHeaderFromAccount)) {
|
||||
return $textHeaderFromAccount;
|
||||
}
|
||||
|
||||
return 'transfers.from_account';
|
||||
}
|
||||
|
||||
protected function getTextHeaderToAccount($textHeaderToAccount)
|
||||
{
|
||||
if (!empty($textHeaderToAccount)) {
|
||||
return $textHeaderToAccount;
|
||||
}
|
||||
|
||||
return 'transfers.to_account';
|
||||
}
|
||||
|
||||
protected function getTextHeaderAmount($textHeaderAmount)
|
||||
{
|
||||
if (!empty($textHeaderAmount)) {
|
||||
return $textHeaderAmount;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
|
||||
protected function getTextHeaderPaidAt($textHeaderPaidAt)
|
||||
{
|
||||
if (!empty($textHeaderPaidAt)) {
|
||||
return $textHeaderPaidAt;
|
||||
}
|
||||
|
||||
return 'general.date';
|
||||
}
|
||||
|
||||
protected function getClassHeaderFromAccount($classHeaderFromAccount)
|
||||
{
|
||||
if (!empty($classHeaderFromAccount)) {
|
||||
return $classHeaderFromAccount;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-2';
|
||||
}
|
||||
|
||||
protected function getClassHeaderToAccount($classHeaderToAccount)
|
||||
{
|
||||
if (!empty($classHeaderToAccount)) {
|
||||
return $classHeaderToAccount;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-6';
|
||||
}
|
||||
|
||||
protected function getClassHeaderAmount($classHeaderAmount)
|
||||
{
|
||||
if (!empty($classHeaderAmount)) {
|
||||
return $classHeaderAmount;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-2 float-right';
|
||||
}
|
||||
|
||||
protected function getClassHeaderPaidAt($classHeaderPaidAt)
|
||||
{
|
||||
if (!empty($classHeaderPaidAt)) {
|
||||
return $classHeaderPaidAt;
|
||||
}
|
||||
|
||||
return 'col-4 col-lg-2';
|
||||
}
|
||||
|
||||
protected function getTextFromAccountTitle($textToAccountTitle)
|
||||
{
|
||||
if (!empty($textToAccountTitle)) {
|
||||
return $textToAccountTitle;
|
||||
}
|
||||
|
||||
return 'transfers.from_account';
|
||||
}
|
||||
|
||||
protected function getTextFromAccountNumber($textFromAccountNumber)
|
||||
{
|
||||
if (!empty($textFromAccountNumber)) {
|
||||
return $textFromAccountNumber;
|
||||
}
|
||||
|
||||
return 'accounts.number';
|
||||
}
|
||||
|
||||
protected function getTextToAccountTitle($textFromAccountTitle)
|
||||
{
|
||||
if (!empty($textFromAccountTitle)) {
|
||||
return $textFromAccountTitle;
|
||||
}
|
||||
|
||||
return 'transfers.to_account';
|
||||
}
|
||||
|
||||
protected function getTextToAccountNumber($textToAccountNumber)
|
||||
{
|
||||
if (!empty($textToAccountNumber)) {
|
||||
return $textToAccountNumber;
|
||||
}
|
||||
|
||||
return 'accounts.number';
|
||||
}
|
||||
|
||||
protected function getTextDetailTitle($textDetailTitle)
|
||||
{
|
||||
if (!empty($textDetailTitle)) {
|
||||
return $textDetailTitle;
|
||||
}
|
||||
|
||||
return 'transfers.details';
|
||||
}
|
||||
|
||||
protected function getTextDetailDate($textDetailDate)
|
||||
{
|
||||
if (!empty($textDetailDate)) {
|
||||
return $textDetailDate;
|
||||
}
|
||||
|
||||
return 'general.date';
|
||||
}
|
||||
|
||||
protected function getTextDetailPaymentMethod($textDetailPaymentMethod)
|
||||
{
|
||||
if (!empty($textDetailPaymentMethod)) {
|
||||
return $textDetailPaymentMethod;
|
||||
}
|
||||
|
||||
return 'general.payment_methods';
|
||||
}
|
||||
|
||||
protected function getTextDetailReference($textDetailReference)
|
||||
{
|
||||
if (!empty($textDetailReference)) {
|
||||
return $textDetailReference;
|
||||
}
|
||||
|
||||
return 'general.reference';
|
||||
}
|
||||
|
||||
protected function getTextDetailDescription($textDetailDescription)
|
||||
{
|
||||
if (!empty($textDetailDescription)) {
|
||||
return $textDetailDescription;
|
||||
}
|
||||
|
||||
return 'general.description';
|
||||
}
|
||||
|
||||
protected function getTextDetailAmount($textDetailAmount)
|
||||
{
|
||||
if (!empty($textDetailAmount)) {
|
||||
return $textDetailAmount;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
|
||||
protected function getHistories($histories)
|
||||
{
|
||||
if (!empty($histories)) {
|
||||
return $histories;
|
||||
}
|
||||
|
||||
$histories[] = $this->transfer;
|
||||
|
||||
return $histories;
|
||||
}
|
||||
|
||||
protected function getTextHistories($textHistories)
|
||||
{
|
||||
if (!empty($textHistories)) {
|
||||
return $textHistories;
|
||||
}
|
||||
|
||||
return 'invoices.histories';
|
||||
}
|
||||
|
||||
protected function getClassFooterHistories($classFooterHistories)
|
||||
{
|
||||
if (!empty($classFooterHistories)) {
|
||||
return $classFooterHistories;
|
||||
}
|
||||
|
||||
return 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
|
||||
}
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use App\Abstracts\View\Components\Transfer as Base;
|
||||
use App\Models\Common\Media;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Transactions;
|
||||
use App\Utilities\Modules;
|
||||
use File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Image;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
abstract class TransferTemplate extends Component
|
||||
{
|
||||
use DateTime;
|
||||
use Transactions;
|
||||
|
||||
public $transfer;
|
||||
|
||||
/** @var array */
|
||||
public $payment_methods;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountBankName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountBankPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFromAccountBankAddress;
|
||||
|
||||
/** @var string */
|
||||
public $textFromAccountTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textFromAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountBankName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountBankPhone;
|
||||
|
||||
/** @var bool */
|
||||
public $hideToAccountBankAddress;
|
||||
|
||||
/** @var string */
|
||||
public $textToAccountTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textToAccountNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetails;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailDate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailPaymentMethod;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailReference;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailDescription;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDetailAmount;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailTitle;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailDate;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailPaymentMethod;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailReference;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailDescription;
|
||||
|
||||
/** @var string */
|
||||
public $textDetailAmount;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$transfer, array $payment_methods = [],
|
||||
bool $hideFromAccount = false, bool $hideFromAccountTitle = false, bool $hideFromAccountName = false, bool $hideFromAccountNumber = false,
|
||||
bool $hideFromAccountBankName = false, bool $hideFromAccountBankPhone = false, bool $hideFromAccountBankAddress = false,
|
||||
string $textFromAccountTitle = '', string $textFromAccountNumber = '',
|
||||
|
||||
bool $hideToAccount = false, bool $hideToAccountTitle = false, bool $hideToAccountName = false, bool $hideToAccountNumber = false,
|
||||
bool $hideToAccountBankName = false, bool $hideToAccountBankPhone = false, bool $hideToAccountBankAddress = false,
|
||||
string $textToAccountTitle = '', string $textToAccountNumber = '',
|
||||
|
||||
bool $hideDetails = false, bool $hideDetailTitle = false, bool $hideDetailDate = false, bool $hideDetailPaymentMethod = false,
|
||||
bool $hideDetailReference = false, bool $hideDetailDescription = false, bool $hideDetailAmount = false,
|
||||
string $textDetailTitle = '', string $textDetailDate = '', string $textDetailPaymentMethod = '', string $textDetailReference = '',
|
||||
string $textDetailDescription = '', string $textDetailAmount = ''
|
||||
) {
|
||||
$this->transfer = $transfer;
|
||||
|
||||
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
|
||||
|
||||
// From account Hide
|
||||
$this->hideFromAccount = $hideFromAccount;
|
||||
$this->hideFromAccountTitle = $hideFromAccountTitle;
|
||||
$this->hideFromAccountName = $hideFromAccountName;
|
||||
$this->hideFromAccountNumber = $hideFromAccountNumber;
|
||||
$this->hideFromAccountBankName = $hideFromAccountBankName;
|
||||
$this->hideFromAccountBankPhone = $hideFromAccountBankPhone;
|
||||
$this->hideFromAccountBankAddress = $hideFromAccountBankAddress;
|
||||
|
||||
// From account text
|
||||
$this->textFromAccountTitle = $this->getTextFromAccountTitle($textFromAccountTitle);
|
||||
$this->textFromAccountNumber = $this->getTextFromAccountNumber($textFromAccountNumber);
|
||||
|
||||
// To account Hide
|
||||
$this->hideToAccount = $hideToAccount;
|
||||
$this->hideToAccountTitle = $hideToAccountTitle;
|
||||
$this->hideToAccountName = $hideToAccountName;
|
||||
$this->hideToAccountNumber = $hideToAccountNumber;
|
||||
$this->hideToAccountBankName = $hideToAccountBankName;
|
||||
$this->hideToAccountBankPhone = $hideToAccountBankPhone;
|
||||
$this->hideToAccountBankAddress = $hideToAccountBankAddress;
|
||||
|
||||
// To account text
|
||||
$this->textToAccountTitle = $this->getTextToAccountTitle($textToAccountTitle);
|
||||
$this->textToAccountNumber = $this->getTextToAccountNumber($textToAccountNumber);
|
||||
|
||||
// Detail Information Hide checker
|
||||
$this->hideDetails = $hideDetails;
|
||||
$this->hideDetailTitle = $hideDetailTitle;
|
||||
$this->hideDetailDate = $hideDetailDate;
|
||||
$this->hideDetailPaymentMethod = $hideDetailPaymentMethod;
|
||||
$this->hideDetailReference = $hideDetailReference;
|
||||
$this->hideDetailDescription = $hideDetailDescription;
|
||||
$this->hideDetailAmount = $hideDetailAmount;
|
||||
|
||||
// Related Information Text
|
||||
$this->textDetailTitle = $this->getTextDetailTitle($textDetailTitle);
|
||||
$this->textDetailDate = $this->getTextDetailDate($textDetailDate);
|
||||
$this->textDetailPaymentMethod = $this->getTextDetailPaymentMethod($textDetailPaymentMethod);
|
||||
$this->textDetailReference = $this->getTextDetailReference($textDetailReference);
|
||||
$this->textDetailDescription = $this->getTextDetailDescription($textDetailDescription);
|
||||
$this->textDetailAmount = $this->getTextDetailAmount($textDetailAmount);
|
||||
}
|
||||
|
||||
protected function getTextFromAccountTitle($textToAccountTitle)
|
||||
{
|
||||
if (!empty($textToAccountTitle)) {
|
||||
return $textToAccountTitle;
|
||||
}
|
||||
|
||||
return 'transfers.from_account';
|
||||
}
|
||||
|
||||
protected function getTextFromAccountNumber($textFromAccountNumber)
|
||||
{
|
||||
if (!empty($textFromAccountNumber)) {
|
||||
return $textFromAccountNumber;
|
||||
}
|
||||
|
||||
return 'accounts.number';
|
||||
}
|
||||
|
||||
protected function getTextToAccountTitle($textFromAccountTitle)
|
||||
{
|
||||
if (!empty($textFromAccountTitle)) {
|
||||
return $textFromAccountTitle;
|
||||
}
|
||||
|
||||
return 'transfers.to_account';
|
||||
}
|
||||
|
||||
protected function getTextToAccountNumber($textToAccountNumber)
|
||||
{
|
||||
if (!empty($textToAccountNumber)) {
|
||||
return $textToAccountNumber;
|
||||
}
|
||||
|
||||
return 'accounts.number';
|
||||
}
|
||||
|
||||
protected function getTextDetailTitle($textDetailTitle)
|
||||
{
|
||||
if (!empty($textDetailTitle)) {
|
||||
return $textDetailTitle;
|
||||
}
|
||||
|
||||
return 'transfers.details';
|
||||
}
|
||||
|
||||
protected function getTextDetailDate($textDetailDate)
|
||||
{
|
||||
if (!empty($textDetailDate)) {
|
||||
return $textDetailDate;
|
||||
}
|
||||
|
||||
return 'general.date';
|
||||
}
|
||||
|
||||
protected function getTextDetailPaymentMethod($textDetailPaymentMethod)
|
||||
{
|
||||
if (!empty($textDetailPaymentMethod)) {
|
||||
return $textDetailPaymentMethod;
|
||||
}
|
||||
|
||||
return 'general.payment_methods';
|
||||
}
|
||||
|
||||
protected function getTextDetailReference($textDetailReference)
|
||||
{
|
||||
if (!empty($textDetailReference)) {
|
||||
return $textDetailReference;
|
||||
}
|
||||
|
||||
return 'general.reference';
|
||||
}
|
||||
|
||||
protected function getTextDetailDescription($textDetailDescription)
|
||||
{
|
||||
if (!empty($textDetailDescription)) {
|
||||
return $textDetailDescription;
|
||||
}
|
||||
|
||||
return 'general.description';
|
||||
}
|
||||
|
||||
protected function getTextDetailAmount($textDetailAmount)
|
||||
{
|
||||
if (!empty($textDetailAmount)) {
|
||||
return $textDetailAmount;
|
||||
}
|
||||
|
||||
return 'general.amount';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components\Transfers;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
abstract class Show extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public $model;
|
||||
|
||||
public $transfer;
|
||||
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$model = false, $transfer = false, string $template = ''
|
||||
) {
|
||||
$this->model = $model;
|
||||
$this->transfer = $this->getTransfer($model, $transfer);
|
||||
$this->template = ! empty($template) ? $template : setting('transfer.template');
|
||||
|
||||
// Set Parent data
|
||||
$this->setParentData();
|
||||
}
|
||||
|
||||
protected function getTransfer($model, $transfer)
|
||||
{
|
||||
if (! empty($model)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
if (! empty($transfer)) {
|
||||
return $transfer;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Abstracts\View\Components\Transfers;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
abstract class Template extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public $model;
|
||||
|
||||
public $transfer;
|
||||
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$model = false, $transfer = false, string $template = ''
|
||||
) {
|
||||
$this->model = $model;
|
||||
$this->transfer = $this->getTransfer($model, $transfer);
|
||||
$this->template = ! empty($template) ? $template : setting('transfer.template');
|
||||
|
||||
// Set Parent data
|
||||
$this->setParentData();
|
||||
}
|
||||
|
||||
protected function getTransfer($model, $transfer)
|
||||
{
|
||||
if (! empty($model)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
if (! empty($transfer)) {
|
||||
return $transfer;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Abstracts;
|
||||
|
||||
use App\Models\Common\Report;
|
||||
use App\Traits\Charts;
|
||||
use App\Utilities\Date;
|
||||
use App\Utilities\Reports;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class Widget
|
||||
{
|
||||
@@ -14,11 +17,15 @@ abstract class Widget
|
||||
public $default_name = '';
|
||||
|
||||
public $default_settings = [
|
||||
'width' => 'col-md-4',
|
||||
'width' => 'w-full lg:w-2/4 px-12 my-8',
|
||||
];
|
||||
|
||||
public $description = '';
|
||||
|
||||
public $report_class = '';
|
||||
|
||||
public $views = [
|
||||
'header' => 'partials.widgets.standard_header',
|
||||
'header' => 'components.widgets.header',
|
||||
];
|
||||
|
||||
public function __construct($model = null)
|
||||
@@ -36,6 +43,47 @@ abstract class Widget
|
||||
return $this->default_settings;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return trans($this->description);
|
||||
}
|
||||
|
||||
public function getReportUrl(): string
|
||||
{
|
||||
$empty_url = '';
|
||||
|
||||
if (empty($this->report_class)) {
|
||||
return $empty_url;
|
||||
}
|
||||
|
||||
if (Reports::isModule($this->report_class) && Reports::isModuleDisabled($this->report_class)) {
|
||||
$alias = Reports::getModuleAlias($this->report_class);
|
||||
|
||||
return route('apps.app.show', [
|
||||
'alias' => $alias,
|
||||
'utm_source' => 'widget',
|
||||
'utm_medium' => 'app',
|
||||
'utm_campaign' => Str::snake(Str::camel($alias)),
|
||||
]);
|
||||
}
|
||||
|
||||
if (! class_exists($this->report_class)) {
|
||||
return $empty_url;
|
||||
}
|
||||
|
||||
if (Reports::cannotRead($this->report_class)) {
|
||||
return $empty_url;
|
||||
}
|
||||
|
||||
$model = Report::where('class', $this->report_class)->first();
|
||||
|
||||
if (! $model instanceof Report) {
|
||||
return route('reports.create');
|
||||
}
|
||||
|
||||
return route('reports.show', $model->id);
|
||||
}
|
||||
|
||||
public function getViews()
|
||||
{
|
||||
return $this->views;
|
||||
|
||||
Reference in New Issue
Block a user