akaunting 3.0 (the last dance)
This commit is contained in:
69
app/View/Components/Button.php
Normal file
69
app/View/Components/Button.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Button extends Component
|
||||
{
|
||||
public $type;
|
||||
|
||||
public $class;
|
||||
|
||||
public $override;
|
||||
|
||||
public $kind;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type = '', string $class = '', string $override = '', string $kind = ''
|
||||
) {
|
||||
$this->type = !empty($type) ? $type : 'button';
|
||||
$this->override = $this->getOverride($override);
|
||||
|
||||
$this->kind = $kind;
|
||||
$this->class = $this->getClass($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.button');
|
||||
}
|
||||
|
||||
protected function getOverride($override)
|
||||
{
|
||||
return explode(',', $override);
|
||||
}
|
||||
|
||||
protected function getClass($class)
|
||||
{
|
||||
$default = 'px-3 py-1.5 mb-3 sm:mb-0 rounded-xl text-sm font-medium leading-6';
|
||||
|
||||
switch ($this->kind) {
|
||||
case 'primary':
|
||||
$default .= ' bg-green hover:bg-green-700 text-white disabled:bg-green-100';
|
||||
break;
|
||||
case 'secondary':
|
||||
$default .= ' bg-purple hover:bg-purple-700 text-white disabled:bg-purple-100';
|
||||
break;
|
||||
default:
|
||||
$default .= ' bg-gray-100 hover:bg-gray-200 disabled:bg-gray-50';
|
||||
}
|
||||
|
||||
if (in_array('class', $this->override)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Form/Address.php
Normal file
18
app/View/Components/Contacts/Form/Address.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Form;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Form as Component;
|
||||
|
||||
class Address extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.form.address');
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Form/Billing.php
Normal file
18
app/View/Components/Contacts/Form/Billing.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Form;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Form as Component;
|
||||
|
||||
class Billing extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.form.billing');
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Form/Buttons.php
Normal file
18
app/View/Components/Contacts/Form/Buttons.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Form;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Form as Component;
|
||||
|
||||
class Buttons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.form.buttons');
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Form/Content.php
Normal file
18
app/View/Components/Contacts/Form/Content.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Form;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Form as Component;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.form.content');
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Form/General.php
Normal file
18
app/View/Components/Contacts/Form/General.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Form;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Form as Component;
|
||||
|
||||
class General extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.form.general');
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Index/Buttons.php
Normal file
18
app/View/Components/Contacts/Index/Buttons.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Index;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Index as Component;
|
||||
|
||||
class Buttons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.index.buttons');
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Index/Content.php
Normal file
18
app/View/Components/Contacts/Index/Content.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Index;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Index as Component;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.index.content');
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Index/MoreButtons.php
Normal file
18
app/View/Components/Contacts/Index/MoreButtons.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Index;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Index as Component;
|
||||
|
||||
class MoreButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.index.more-buttons');
|
||||
}
|
||||
}
|
72
app/View/Components/Contacts/Script.php
Normal file
72
app/View/Components/Contacts/Script.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
class Script extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'contact';
|
||||
public const DEFAULT_TYPE = 'customer';
|
||||
public const DEFAULT_PLURAL_TYPE = 'customers';
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
public $contact;
|
||||
|
||||
public $currencies;
|
||||
|
||||
public $currency_code;
|
||||
|
||||
/** @var string */
|
||||
public $alias;
|
||||
|
||||
/** @var string */
|
||||
public $folder;
|
||||
|
||||
/** @var string */
|
||||
public $file;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type = '', $contact = false, $currencies = [],
|
||||
string $alias = '', string $folder = '', string $file = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->contact = $contact;
|
||||
$this->currencies = $this->getCurrencies($currencies);
|
||||
$this->currency_code = ($contact) ? $contact->currency_code : setting('default.currency');
|
||||
|
||||
$this->alias = $this->getAlias($type, $alias);
|
||||
$this->folder = $this->getScriptFolder($type, $folder);
|
||||
$this->file = $this->getScriptFile($type, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.script');
|
||||
}
|
||||
|
||||
protected function getCurrencies($currencies)
|
||||
{
|
||||
if (!empty($currencies)) {
|
||||
return $currencies;
|
||||
}
|
||||
|
||||
return Currency::enabled()->orderBy('name')->get()->makeHidden(['id', 'company_id', 'created_at', 'updated_at', 'deleted_at']);
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Show/Buttons.php
Normal file
18
app/View/Components/Contacts/Show/Buttons.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Show as Component;
|
||||
|
||||
class Buttons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.show.buttons');
|
||||
}
|
||||
}
|
102
app/View/Components/Contacts/Show/Content.php
Normal file
102
app/View/Components/Contacts/Show/Content.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Show;
|
||||
|
||||
use App\Utilities\Date;
|
||||
use App\Abstracts\View\Components\Contacts\Show as Component;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
public $counts;
|
||||
|
||||
public $totals;
|
||||
|
||||
public $transactions;
|
||||
|
||||
public $documents;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$totals = [
|
||||
'paid' => 0,
|
||||
'open' => 0,
|
||||
'overdue' => 0,
|
||||
];
|
||||
|
||||
$this->counts = [];
|
||||
|
||||
// Handle documents
|
||||
$this->documents = $this->contact->documents()->with('transactions')->isNotRecurring()->get();
|
||||
|
||||
$this->counts['documents'] = $this->documents->count();
|
||||
|
||||
$today = Date::today()->toDateString();
|
||||
|
||||
foreach ($this->documents as $item) {
|
||||
// Already in transactions
|
||||
if ($item->status == 'paid' || $item->status == 'cancelled') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$transactions = 0;
|
||||
|
||||
foreach ($item->transactions as $transaction) {
|
||||
$transactions += $transaction->getAmountConvertedToDefault();
|
||||
}
|
||||
|
||||
// Check if it's open or overdue invoice
|
||||
if ($item->due_at > $today) {
|
||||
$totals['open'] += $item->getAmountConvertedToDefault() - $transactions;
|
||||
} else {
|
||||
$totals['overdue'] += $item->getAmountConvertedToDefault() - $transactions;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle payments
|
||||
$this->transactions = $this->contact->transactions()->with('account', 'category')->isNotRecurring()->get();
|
||||
|
||||
$this->counts['transactions'] = $this->transactions->count();
|
||||
|
||||
// Prepare data
|
||||
$this->transactions->each(function ($item) use (&$totals) {
|
||||
$totals['paid'] += $item->getAmountConvertedToDefault();
|
||||
});
|
||||
|
||||
$this->totals = $totals;
|
||||
|
||||
$limit = (int) request('limit', setting('default.list_limit', '25'));
|
||||
$this->transactions = $this->paginate($this->transactions->sortByDesc('paid_at'), $limit);
|
||||
$this->documents = $this->paginate($this->documents->sortByDesc('issued_at'), $limit);
|
||||
|
||||
return view('components.contacts.show.content');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a pagination collection.
|
||||
*
|
||||
* @param array|Collection $items
|
||||
* @param int $perPage
|
||||
* @param int $page
|
||||
* @param array $options
|
||||
*
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function paginate($items, $perPage = 15, $page = null, $options = [])
|
||||
{
|
||||
$perPage = $perPage ?: (int) request('limit', setting('default.list_limit', '25'));
|
||||
|
||||
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
|
||||
|
||||
$items = $items instanceof Collection ? $items : Collection::make($items);
|
||||
|
||||
return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
|
||||
}
|
||||
}
|
18
app/View/Components/Contacts/Show/MoreButtons.php
Normal file
18
app/View/Components/Contacts/Show/MoreButtons.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Contacts\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Contacts\Show as Component;
|
||||
|
||||
class MoreButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.contacts.show.more-buttons');
|
||||
}
|
||||
}
|
68
app/View/Components/Date.php
Normal file
68
app/View/Components/Date.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\DateTime;
|
||||
use App\Utilities\Date as UDate;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Date extends Component
|
||||
{
|
||||
public $rawDate;
|
||||
|
||||
public $date;
|
||||
|
||||
public $format;
|
||||
|
||||
public $function;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$date, string $format = '', string $function = ''
|
||||
) {
|
||||
$this->rawDate = $date;
|
||||
$this->format = $this->getFormat($format);
|
||||
$this->function = $function;
|
||||
|
||||
$this->date = $this->getFormatDate($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.date');
|
||||
}
|
||||
|
||||
protected function getFormat($format)
|
||||
{
|
||||
if (! empty($format)) {
|
||||
return $format;
|
||||
}
|
||||
|
||||
$date_time = new class() {
|
||||
use DateTime;
|
||||
};
|
||||
|
||||
return $date_time->getCompanyDateFormat();
|
||||
}
|
||||
|
||||
protected function getFormatDate($date)
|
||||
{
|
||||
if (! empty($this->function)) {
|
||||
$date = UDate::parse($date)->{$this->function}();
|
||||
|
||||
return Str::ucfirst($date);
|
||||
}
|
||||
|
||||
return UDate::parse($date)->format($this->format);
|
||||
}
|
||||
}
|
269
app/View/Components/DeleteButton.php
Normal file
269
app/View/Components/DeleteButton.php
Normal file
@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DeleteButton extends Component
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $label;
|
||||
|
||||
public $model;
|
||||
|
||||
public $modelId;
|
||||
|
||||
public $modelName;
|
||||
|
||||
public $modelTable;
|
||||
|
||||
/** @var string */
|
||||
public $text;
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $title;
|
||||
|
||||
/** @var string */
|
||||
public $message;
|
||||
|
||||
public $action;
|
||||
|
||||
public $route;
|
||||
|
||||
public $url;
|
||||
|
||||
public $cancelText;
|
||||
|
||||
public $deleteText;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$label = '',
|
||||
$model = false, $modelId = 'id', $modelName = 'name', string $modelTable = '',
|
||||
$text = '', $type = '',
|
||||
$title = '', $message = '',
|
||||
$action = '', $route = '', $url = '',
|
||||
$cancelText = '', $deleteText = ''
|
||||
) {
|
||||
$this->label = $this->getLabel($label);
|
||||
|
||||
$this->model = $model;
|
||||
$this->modelId = $modelId;
|
||||
$this->modelName = $modelName;
|
||||
$this->modelTable = $model->getTable();
|
||||
|
||||
$this->text = $text;
|
||||
$this->type = $type;
|
||||
|
||||
$this->action = $this->getAction($action, $route, $url);
|
||||
$this->route = $route;
|
||||
$this->url = $url;
|
||||
|
||||
$this->title = $this->getTitle($title);
|
||||
$this->message = $this->getMessage($message);
|
||||
|
||||
$this->cancelText = $this->getCancelText($cancelText);
|
||||
$this->deleteText = $this->getDeleteText($deleteText);
|
||||
|
||||
$this->id = $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.delete-button');
|
||||
}
|
||||
|
||||
protected function getId()
|
||||
{
|
||||
if (! empty($this->model)) {
|
||||
return $this->model->{$this->modelId};
|
||||
}
|
||||
|
||||
if (! empty($this->route) && is_array($this->route)) {
|
||||
return $this->route[1];
|
||||
}
|
||||
|
||||
return mt_rand();
|
||||
}
|
||||
|
||||
protected function getLabel($label)
|
||||
{
|
||||
if (! empty($label)) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
return trans('general.delete');
|
||||
}
|
||||
|
||||
protected function getAction($action, $route, $url)
|
||||
{
|
||||
if (! empty($action)) {
|
||||
return $action;
|
||||
}
|
||||
|
||||
if (! empty($route)) {
|
||||
return $this->getRouteAction($route);
|
||||
}
|
||||
|
||||
if (! empty($url)) {
|
||||
return $this->getUrlAction($url);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "url" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrlAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
return url($options[0], array_slice($options, 1));
|
||||
}
|
||||
|
||||
if (! empty($this->model)) {
|
||||
return url($options, $this->model->{$this->modelId});
|
||||
}
|
||||
|
||||
return url($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "route" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRouteAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$parameters = array_slice($options, 1);
|
||||
|
||||
if (array_keys($options) === [0, 1]) {
|
||||
$parameters = head($parameters);
|
||||
}
|
||||
|
||||
return route($options[0], $parameters);
|
||||
}
|
||||
|
||||
if (! empty($this->model)) {
|
||||
return route($options, $this->model->{$this->modelId});
|
||||
}
|
||||
|
||||
return route($options);
|
||||
}
|
||||
|
||||
protected function getTitle($title)
|
||||
{
|
||||
if (! empty($title)) {
|
||||
return $title;
|
||||
}
|
||||
|
||||
$type = '';
|
||||
|
||||
if (! empty($this->model)) {
|
||||
$type = $this->getModelTitle();
|
||||
}
|
||||
|
||||
return ! empty($type) ? trans('general.title.delete', ['type' => $type]) : trans('general.delete');
|
||||
}
|
||||
|
||||
protected function getMessage($cancelText)
|
||||
{
|
||||
if (!empty($cancelText)) {
|
||||
return $cancelText;
|
||||
}
|
||||
|
||||
$name = '';
|
||||
$type = '';
|
||||
|
||||
if (! empty($this->model)) {
|
||||
$page = '';
|
||||
|
||||
if (! empty($this->route)) {
|
||||
$page = explode('.', $this->route)[0];
|
||||
} elseif (! empty($this->url)) {
|
||||
$page = explode('/', $this->url)[1];
|
||||
}
|
||||
|
||||
$text = $this->text ? $this->text : $page;
|
||||
$name = addslashes($this->model->{$this->modelName});
|
||||
|
||||
$type = mb_strtolower($this->getModelTitle());
|
||||
|
||||
$message = trans('general.delete_confirm', ['name' => '<strong>' . $name . '</strong>', 'type' => $type]);
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
return trans('general.delete_confirm', ['name' => '<strong>' . $name . '</strong>', 'type' => $type]);
|
||||
}
|
||||
|
||||
protected function getModelTitle()
|
||||
{
|
||||
if (! empty($this->text)) {
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
$group = 'core';
|
||||
$page = '';
|
||||
|
||||
if (! empty($this->route)) {
|
||||
$paths = explode('.', $this->route);
|
||||
|
||||
$page = $paths[0];
|
||||
} elseif (! empty($this->url)) {
|
||||
$paths = explode('/', $this->url);
|
||||
|
||||
$page = $paths[1];
|
||||
}
|
||||
|
||||
$title = trans_choice('general.' . $page, 1);
|
||||
|
||||
if (module($page) != null) {
|
||||
$group = $page;
|
||||
$page = (! empty($this->route)) ? $paths[1] : $paths[2];
|
||||
|
||||
$title = trans_choice($group . '::general.' . $page, 1);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
protected function getCancelText($cancelText)
|
||||
{
|
||||
if (!empty($cancelText)) {
|
||||
return $cancelText;
|
||||
}
|
||||
|
||||
return trans('general.cancel');
|
||||
}
|
||||
|
||||
protected function getDeleteText($deleteText)
|
||||
{
|
||||
if (!empty($deleteText)) {
|
||||
return $deleteText;
|
||||
}
|
||||
|
||||
return trans('general.delete');
|
||||
}
|
||||
}
|
296
app/View/Components/DeleteLink.php
Normal file
296
app/View/Components/DeleteLink.php
Normal file
@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DeleteLink extends Component
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $label;
|
||||
|
||||
public $model;
|
||||
|
||||
public $modelId;
|
||||
|
||||
public $modelName;
|
||||
|
||||
public $modelTable;
|
||||
|
||||
/** @var string */
|
||||
public $text;
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $title;
|
||||
|
||||
/** @var string */
|
||||
public $message;
|
||||
|
||||
public $action;
|
||||
|
||||
public $route;
|
||||
|
||||
public $url;
|
||||
|
||||
public $cancelText;
|
||||
|
||||
public $deleteText;
|
||||
|
||||
public $override;
|
||||
|
||||
public $class;
|
||||
|
||||
public $textClass;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$label = '',
|
||||
$model = false, $modelId = 'id', $modelName = 'name', string $modelTable = '',
|
||||
$text = '', $type = '',
|
||||
$title = '', $message = '',
|
||||
$action = '', $route = '', $url = '',
|
||||
$cancelText = '', $deleteText = '',
|
||||
$override = '', $class = '', $textClass = ''
|
||||
) {
|
||||
$this->label = $this->getLabel($label);
|
||||
|
||||
$this->model = $model;
|
||||
$this->modelId = $modelId;
|
||||
$this->modelName = $modelName;
|
||||
$this->modelTable = $model->getTable();
|
||||
|
||||
$this->text = $text;
|
||||
$this->type = $type;
|
||||
|
||||
$this->action = $this->getAction($action, $route, $url);
|
||||
$this->route = $route;
|
||||
$this->url = $url;
|
||||
|
||||
$this->title = $this->getTitle($title);
|
||||
$this->message = $this->getMessage($message);
|
||||
|
||||
$this->cancelText = $this->getCancelText($cancelText);
|
||||
$this->deleteText = $this->getDeleteText($deleteText);
|
||||
|
||||
$this->id = $this->getId();
|
||||
|
||||
$this->override = $override;
|
||||
|
||||
$this->class = $this->getClass($class);
|
||||
$this->textClass = ! empty($textClass) ? $textClass : 'w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.delete-link');
|
||||
}
|
||||
|
||||
protected function getId()
|
||||
{
|
||||
if (! empty($this->model)) {
|
||||
return $this->model->{$this->modelId};
|
||||
}
|
||||
|
||||
if (! empty($this->route) && is_array($this->route)) {
|
||||
return $this->route[1];
|
||||
}
|
||||
|
||||
return mt_rand();
|
||||
}
|
||||
|
||||
protected function getLabel($label)
|
||||
{
|
||||
if (! empty($label)) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
return trans('general.delete');
|
||||
}
|
||||
|
||||
protected function getAction($action, $route, $url)
|
||||
{
|
||||
if (! empty($action)) {
|
||||
return $action;
|
||||
}
|
||||
|
||||
if (! empty($route)) {
|
||||
return $this->getRouteAction($route);
|
||||
}
|
||||
|
||||
if (! empty($url)) {
|
||||
return $this->getUrlAction($url);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "url" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrlAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
return url($options[0], array_slice($options, 1));
|
||||
}
|
||||
|
||||
if (! empty($this->model)) {
|
||||
return url($options, $this->model->{$this->modelId});
|
||||
}
|
||||
|
||||
return url($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "route" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRouteAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$parameters = array_slice($options, 1);
|
||||
|
||||
if (array_keys($options) === [0, 1]) {
|
||||
$parameters = head($parameters);
|
||||
}
|
||||
|
||||
return route($options[0], $parameters);
|
||||
}
|
||||
|
||||
if (! empty($this->model)) {
|
||||
return route($options, $this->model->{$this->modelId});
|
||||
}
|
||||
|
||||
return route($options);
|
||||
}
|
||||
|
||||
protected function getTitle($title)
|
||||
{
|
||||
if (! empty($title)) {
|
||||
return $title;
|
||||
}
|
||||
|
||||
$type = '';
|
||||
|
||||
if (! empty($this->model)) {
|
||||
$type = $this->getModelTitle();
|
||||
}
|
||||
|
||||
return ! empty($type) ? trans('general.title.delete', ['type' => $type]) : trans('general.delete');
|
||||
}
|
||||
|
||||
protected function getMessage($cancelText)
|
||||
{
|
||||
if (!empty($cancelText)) {
|
||||
return $cancelText;
|
||||
}
|
||||
|
||||
$name = '';
|
||||
$type = '';
|
||||
|
||||
if (! empty($this->model)) {
|
||||
$page = '';
|
||||
|
||||
if (! empty($this->route)) {
|
||||
$page = explode('.', $this->route)[0];
|
||||
} elseif (! empty($this->url)) {
|
||||
$page = explode('/', $this->url)[1];
|
||||
}
|
||||
|
||||
$text = $this->text ? $this->text : $page;
|
||||
$name = addslashes($this->model->{$this->modelName});
|
||||
|
||||
$type = mb_strtolower($this->getModelTitle());
|
||||
|
||||
$message = trans('general.delete_confirm', ['name' => '<strong>' . $name . '</strong>', 'type' => $type]);
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
return trans('general.delete_confirm', ['name' => '<strong>' . $name . '</strong>', 'type' => $type]);
|
||||
}
|
||||
|
||||
protected function getModelTitle()
|
||||
{
|
||||
if (! empty($this->text)) {
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
$group = 'core';
|
||||
$page = '';
|
||||
|
||||
if (! empty($this->route)) {
|
||||
$paths = explode('.', $this->route);
|
||||
|
||||
$page = $paths[0];
|
||||
} elseif (! empty($this->url)) {
|
||||
$paths = explode('/', $this->url);
|
||||
|
||||
$page = $paths[1];
|
||||
}
|
||||
|
||||
$title = trans_choice('general.' . $page, 1);
|
||||
|
||||
if (module($page) != null) {
|
||||
$group = $page;
|
||||
$page = (! empty($this->route)) ? $paths[1] : $paths[2];
|
||||
|
||||
$title = trans_choice($group . '::general.' . $page, 1);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
protected function getCancelText($cancelText)
|
||||
{
|
||||
if (!empty($cancelText)) {
|
||||
return $cancelText;
|
||||
}
|
||||
|
||||
return trans('general.cancel');
|
||||
}
|
||||
|
||||
protected function getDeleteText($deleteText)
|
||||
{
|
||||
if (!empty($deleteText)) {
|
||||
return $deleteText;
|
||||
}
|
||||
|
||||
return trans('general.delete');
|
||||
}
|
||||
|
||||
protected function getClass($class)
|
||||
{
|
||||
$default_class = 'w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap';
|
||||
|
||||
$explode = explode(',', $this->override);
|
||||
|
||||
if (count($explode) && in_array('class', $explode)) {
|
||||
$default_class = $class;
|
||||
} else {
|
||||
$default_class .= ' ' . $class;
|
||||
}
|
||||
|
||||
return $default_class;
|
||||
}
|
||||
}
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Advanced extends Component
|
||||
{
|
||||
@ -14,39 +13,6 @@ class Advanced extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$category_type = $this->categoryType;
|
||||
|
||||
if ($category_type) {
|
||||
$categories = Category::$category_type()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
|
||||
} else {
|
||||
$categories = Category::enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
|
||||
}
|
||||
|
||||
if (!empty($this->document) && ($this->document->category && !$categories->has($this->document->category_id))) {
|
||||
$categories->put($this->document->category->id, $this->document->category->name);
|
||||
}
|
||||
|
||||
$recurring_class = 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
|
||||
$more_class = 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
|
||||
$more_form_class = 'col-md-12';
|
||||
|
||||
if ($this->hideRecurring && (!$this->hideCategory || !$this->hideAttachment)) {
|
||||
$more_class = 'col-sm-12 col-md-12 col-lg-12 col-xl-12';
|
||||
$more_form_class = 'col-md-6';
|
||||
} else if ($this->hideRecurring && ($this->hideCategory && $this->hideAttachment)) {
|
||||
$recurring_class = 'col-sm-12 col-md-12 col-lg-12 col-xl-12';
|
||||
}
|
||||
|
||||
$file_type_mimes = explode(',', config('filesystems.mimes'));
|
||||
|
||||
$file_types = [];
|
||||
|
||||
foreach ($file_type_mimes as $mime) {
|
||||
$file_types[] = '.' . $mime;
|
||||
}
|
||||
|
||||
$file_types = implode(',', $file_types);
|
||||
|
||||
return view('components.documents.form.advanced', compact('categories', 'category_type', 'recurring_class', 'more_class', 'more_form_class', 'file_types'));
|
||||
return view('components.documents.form.advanced');
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Buttons extends Component
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
use App\Models\Common\Company as Model;
|
||||
|
||||
class Company extends Component
|
||||
@ -16,7 +16,7 @@ class Company extends Component
|
||||
{
|
||||
$company = Model::find(company_id());
|
||||
|
||||
$inputNameType = config('type.' . $this->type . '.route.parameter');
|
||||
$inputNameType = config('type.document.' . $this->type . '.route.parameter');
|
||||
|
||||
return view('components.documents.form.company', compact('company', 'inputNameType'));
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Contact as Model;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Common\Contact;
|
||||
|
||||
class SelectContactCard extends Component
|
||||
class Contact extends Component
|
||||
{
|
||||
public $type;
|
||||
|
||||
@ -46,8 +46,7 @@ class SelectContactCard extends Component
|
||||
public function __construct(
|
||||
$type, $contact = false, $contacts = [], $searchRoute = '', $createRoute = '', string $error = '',
|
||||
$textAddContact = '', $textCreateNewContact = '', $textEditContact = '', $textContactInfo = '', $textChooseDifferentContact = ''
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->contact = $contact;
|
||||
$this->contacts = $contacts;
|
||||
@ -70,7 +69,7 @@ class SelectContactCard extends Component
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->contacts)) {
|
||||
$this->contacts = Contact::{$this->type}()->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
|
||||
$this->contacts = Model::{$this->type}()->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
|
||||
|
||||
if (!empty($this->contact) && (!$this->contacts->contains('id', $contact->id))) {
|
||||
$this->contacts->push($this->contact);
|
||||
@ -102,7 +101,7 @@ class SelectContactCard extends Component
|
||||
#todo 3rd part apps
|
||||
$this->placeholder = trans('general.placeholder.contact_search', ['type' => trans_choice('general.' . Str::plural($this->type, 2), 1)]);
|
||||
|
||||
return view('components.select-contact-card');
|
||||
return view('components.documents.form.contact');
|
||||
}
|
||||
|
||||
protected function getTextAddContact($type, $textAddContact)
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
@ -15,7 +15,7 @@ class Content extends Component
|
||||
{
|
||||
$status = 'draft';
|
||||
|
||||
if (!empty($this->document)) {
|
||||
if (! empty($this->document)) {
|
||||
$status = $this->document->status;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Footer extends Component
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Item;
|
||||
|
||||
class SelectItemButton extends Component
|
||||
class ItemButton extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
@ -50,9 +50,9 @@ class SelectItemButton extends Component
|
||||
|
||||
$price = $price_type . '_price';
|
||||
|
||||
return view('components.select-item-button', compact('items', 'price'));
|
||||
return view('components.documents.form.item-button', compact('items', 'price'));
|
||||
}
|
||||
|
||||
|
||||
protected function getPriceType($type, $is_sale, $is_purchase)
|
||||
{
|
||||
if (!empty($is_sale)) {
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class EditItemColumns extends Component
|
||||
class ItemColumns extends Component
|
||||
{
|
||||
/* string */
|
||||
public $type;
|
||||
@ -26,6 +26,6 @@ class EditItemColumns extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.edit-item-columns');
|
||||
return view('components.documents.form.item-columns');
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
class Items extends Component
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class LineItem extends Component
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Main extends Component
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Metadata extends Component
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Note extends Component
|
||||
{
|
||||
|
18
app/View/Components/Documents/Form/Recurring.php
Normal file
18
app/View/Components/Documents/Form/Recurring.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Recurring extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.form.recurring');
|
||||
}
|
||||
}
|
27
app/View/Components/Documents/Form/RecurringMetadata.php
Normal file
27
app/View/Components/Documents/Form/RecurringMetadata.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class RecurringMetadata extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$payment_terms = [
|
||||
'0' => trans('settings.invoice.due_receipt'),
|
||||
'15' => trans('settings.invoice.due_days', ['days' => 15]),
|
||||
'30' => trans('settings.invoice.due_days', ['days' => 30]),
|
||||
'45' => trans('settings.invoice.due_days', ['days' => 45]),
|
||||
'60' => trans('settings.invoice.due_days', ['days' => 60]),
|
||||
'90' => trans('settings.invoice.due_days', ['days' => 90]),
|
||||
];
|
||||
|
||||
return view('components.documents.form.recurring_metadata', compact('payment_terms'));
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Abstracts\View\Components\Documents\Form as Component;
|
||||
|
||||
class Totals extends Component
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\View\Components\Documents\Index;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentIndex as Component;
|
||||
use App\Abstracts\View\Components\Documents\Index as Component;
|
||||
|
||||
class CardBody extends Component
|
||||
class Buttons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -13,6 +13,6 @@ class CardBody extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.index.card-body');
|
||||
return view('components.documents.index.buttons');
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Index;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentIndex as Component;
|
||||
use App\Abstracts\View\Components\Documents\Index as Component;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\View\Components\Documents\Index;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentIndex as Component;
|
||||
use App\Abstracts\View\Components\Documents\Index as Component;
|
||||
|
||||
class EmptyPage extends Component
|
||||
class Document extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -13,6 +13,6 @@ class EmptyPage extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.index.empty-page');
|
||||
return view('components.documents.index.document');
|
||||
}
|
||||
}
|
47
app/View/Components/Documents/Index/Information.php
Normal file
47
app/View/Components/Documents/Index/Information.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
class Information extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'contact';
|
||||
public const DEFAULT_TYPE = 'customer';
|
||||
public const DEFAULT_PLURAL_TYPE = 'customers';
|
||||
|
||||
public $document;
|
||||
|
||||
public $hideShow;
|
||||
|
||||
public $showRoute;
|
||||
|
||||
public $placement;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$document, bool $hideShow = false, string $showRoute = '', string $placement = ''
|
||||
) {
|
||||
$this->document = $document;
|
||||
$this->hideShow = $hideShow;
|
||||
$this->showRoute = $this->getShowRoute($document->contact->type, $showRoute);
|
||||
$this->placement = (! empty($placement)) ? $placement : 'left';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.index.information');
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\View\Components\Documents\Index;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentIndex as Component;
|
||||
use App\Abstracts\View\Components\Documents\Index as Component;
|
||||
|
||||
class CardFooter extends Component
|
||||
class MoreButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -13,6 +13,6 @@ class CardFooter extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.index.card-footer');
|
||||
return view('components.documents.index.more-buttons');
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\View\Components\Documents\Index;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentIndex as Component;
|
||||
use App\Abstracts\View\Components\Documents\Index as Component;
|
||||
|
||||
class CardHeader extends Component
|
||||
class RecurringTemplates extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -13,6 +13,6 @@ class CardHeader extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.index.card-header');
|
||||
return view('components.documents.index.recurring_templates');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Index;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentIndex as Component;
|
||||
|
||||
class TopButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.index.top-buttons');
|
||||
}
|
||||
}
|
@ -2,22 +2,22 @@
|
||||
|
||||
namespace App\View\Components\Documents;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
class Script extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'document';
|
||||
public const DEFAULT_TYPE = 'invoice';
|
||||
public const DEFAULT_PLURAL_TYPE = 'invoices';
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $scriptFile;
|
||||
|
||||
/** @var string */
|
||||
public $version;
|
||||
|
||||
public $document;
|
||||
|
||||
public $items;
|
||||
@ -28,21 +28,34 @@ class Script extends Component
|
||||
|
||||
public $taxes;
|
||||
|
||||
/** @var string */
|
||||
public $alias;
|
||||
|
||||
/** @var string */
|
||||
public $folder;
|
||||
|
||||
/** @var string */
|
||||
public $file;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = '', string $scriptFile = '', string $version = '', $document = false, $items = [], $currencies = [], $taxes = [])
|
||||
{
|
||||
public function __construct(
|
||||
string $type = '', $document = false, $items = [], $currencies = [], $taxes = [],
|
||||
string $alias = '', string $folder = '', string $file = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->scriptFile = ($scriptFile) ? $scriptFile : 'public/js/common/documents.js';
|
||||
$this->version = $this->getVersion($version);
|
||||
$this->document = $document;
|
||||
$this->items = $items;
|
||||
$this->currencies = $this->getCurrencies($currencies);
|
||||
$this->currency_code = ($document) ? $document->currency_code : setting('default.currency');
|
||||
$this->taxes = $this->getTaxes($taxes);
|
||||
|
||||
$this->alias = $this->getAlias($type, $alias);
|
||||
$this->folder = $this->getScriptFolder($type, $folder);
|
||||
$this->file = $this->getScriptFile($type, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,19 +68,6 @@ class Script extends Component
|
||||
return view('components.documents.script');
|
||||
}
|
||||
|
||||
protected function getVersion($version)
|
||||
{
|
||||
if (!empty($version)) {
|
||||
return $version;
|
||||
}
|
||||
|
||||
if ($alias = config('type.' . $this->type . '.alias')) {
|
||||
return module_version($alias);
|
||||
}
|
||||
|
||||
return version('short');
|
||||
}
|
||||
|
||||
protected function getCurrencies($currencies)
|
||||
{
|
||||
if (!empty($currencies)) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Attachment extends Component
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Timeline extends Component
|
||||
class Buttons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -13,6 +13,6 @@ class Timeline extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.timeline');
|
||||
return view('components.documents.show.buttons');
|
||||
}
|
||||
}
|
24
app/View/Components/Documents/Show/Children.php
Normal file
24
app/View/Components/Documents/Show/Children.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
use App\Models\Common\Recurring;
|
||||
|
||||
|
||||
class Children extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$recurring = Recurring::where('recurable_type', 'App\\Models\\Document\\Document')
|
||||
->where('recurable_id', $this->document->id)
|
||||
->first();
|
||||
|
||||
return view('components.documents.show.children', compact('recurring'));
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
|
25
app/View/Components/Documents/Show/Create.php
Normal file
25
app/View/Components/Documents/Show/Create.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Create extends Component
|
||||
{
|
||||
public $description;
|
||||
|
||||
public $created_date;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->description = ($this->document->isRecurringDocument()) ? 'invoices.slider.create_recurring' : 'invoices.slider.create';
|
||||
$this->created_date = '<span class="font-medium">' . company_date($this->document->created_at) . '</span>';
|
||||
|
||||
return view('components.documents.show.create');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
|
||||
class Footer extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.footer');
|
||||
}
|
||||
}
|
22
app/View/Components/Documents/Show/GetPaid.php
Normal file
22
app/View/Components/Documents/Show/GetPaid.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class GetPaid extends Component
|
||||
{
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->description = trans('general.amount_due') . ': ' . '<span class="font-medium">' . money($this->document->amount, $this->document->currency_code, true) . '</span>';
|
||||
|
||||
return view('components.documents.show.get-paid');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
|
||||
class Header extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.header');
|
||||
}
|
||||
}
|
22
app/View/Components/Documents/Show/MakePayment.php
Normal file
22
app/View/Components/Documents/Show/MakePayment.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class MakePayment extends Component
|
||||
{
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->description = trans('general.amount_due') . ': ' . '<span class="font-medium">' . money($this->document->amount, $this->document->currency_code, true) . '</span>';
|
||||
|
||||
return view('components.documents.show.make-payment');
|
||||
}
|
||||
}
|
44
app/View/Components/Documents/Show/Message.php
Normal file
44
app/View/Components/Documents/Show/Message.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Message extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $backgroundColor;
|
||||
|
||||
/** @var string */
|
||||
public $textColor;
|
||||
|
||||
/** @var string */
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type = '', string $backgroundColor = '', string $textColor = '', string $message = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->backgroundColor = $backgroundColor;
|
||||
$this->textColor = $textColor;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.message');
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Document extends Component
|
||||
class MoreButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -13,6 +13,6 @@ class Document extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.document');
|
||||
return view('components.documents.show.more-buttons');
|
||||
}
|
||||
}
|
31
app/View/Components/Documents/Show/Receive.php
Normal file
31
app/View/Components/Documents/Show/Receive.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Models\Document\DocumentHistory;
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Receive extends Component
|
||||
{
|
||||
public $description;
|
||||
|
||||
public $sent_date;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->description = ($this->document->isRecurringDocument()) ? 'invoices.slider.create_recurring' : 'general.last_sent';
|
||||
|
||||
$last_sent = DocumentHistory::where('document_id', $this->document->id)->whereIn('status', ['sent', 'received'])->latest()->first();
|
||||
|
||||
$date = ($last_sent) ? company_date($last_sent->created_at) : trans('general.na');
|
||||
|
||||
$this->sent_date = '<span class="font-medium">' . $date . '</span>';
|
||||
|
||||
return view('components.documents.show.receive');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
|
||||
class RecurringMessage extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.recurring-message');
|
||||
}
|
||||
}
|
25
app/View/Components/Documents/Show/Restore.php
Normal file
25
app/View/Components/Documents/Show/Restore.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Restore extends Component
|
||||
{
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$last_history = $this->document->histories()->orderBy('id', 'desc')->first();
|
||||
|
||||
$this->description = trans('invoices.cancel_date') . ': ';
|
||||
$this->description .= '<span class="font-medium">' . company_date($last_history->created_at) . '</span>';
|
||||
|
||||
return view('components.documents.show.restore');
|
||||
}
|
||||
}
|
32
app/View/Components/Documents/Show/Schedule.php
Normal file
32
app/View/Components/Documents/Show/Schedule.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
use App\Models\Common\Recurring;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Schedule extends Component
|
||||
{
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$recurring = Recurring::where('recurable_type', 'App\\Models\\Document\\Document')
|
||||
->where('recurable_id', $this->document->id)
|
||||
->first();
|
||||
|
||||
$started_date = '<span class="font-medium">' . company_date($recurring->started_at) . '</span>';
|
||||
$frequency = Str::lower(trans('recurring.' . str_replace('ly', 's', $recurring->frequency)));
|
||||
$invertal = $recurring->interval;
|
||||
|
||||
$this->description = trans('transactions.slider.schedule', ['frequency' => $frequency, 'interval' => $invertal, 'date' => $started_date]);
|
||||
|
||||
return view('components.documents.show.schedule', compact('recurring'));
|
||||
}
|
||||
}
|
31
app/View/Components/Documents/Show/Send.php
Normal file
31
app/View/Components/Documents/Show/Send.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Models\Document\DocumentHistory;
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Send extends Component
|
||||
{
|
||||
public $description;
|
||||
|
||||
public $sent_date;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->description = ($this->document->isRecurringDocument()) ? 'invoices.slider.create_recurring' : 'general.last_sent';
|
||||
|
||||
$last_sent = DocumentHistory::where('document_id', $this->document->id)->whereIn('status', ['sent', 'received'])->latest()->first();
|
||||
|
||||
$date = ($last_sent) ? company_date($last_sent->created_at) : trans('general.na');
|
||||
|
||||
$this->sent_date = '<span class="font-medium">' . $date . '</span>';
|
||||
|
||||
return view('components.documents.show.send');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
|
||||
class StatusMessage extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.status-message');
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
use App\Abstracts\View\Components\Documents\Show as Component;
|
||||
|
||||
class Histories extends Component
|
||||
class Template extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
@ -13,6 +13,6 @@ class Histories extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.histories');
|
||||
return view('components.documents.show.template');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
|
||||
class TopButtons extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.top-buttons');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Show;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentShow as Component;
|
||||
|
||||
class Transactions extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.documents.show.transactions');
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Template;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentTemplate as Component;
|
||||
use App\Abstracts\View\Components\Documents\Template as Component;
|
||||
|
||||
class Classic extends Component
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Template;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentTemplate as Component;
|
||||
use App\Abstracts\View\Components\Documents\Template as Component;
|
||||
|
||||
class Ddefault extends Component
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Template;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentTemplate as Component;
|
||||
use App\Abstracts\View\Components\Documents\Template as Component;
|
||||
|
||||
class LineItem extends Component
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\View\Components\Documents\Template;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentTemplate as Component;
|
||||
use App\Abstracts\View\Components\Documents\Template as Component;
|
||||
|
||||
class Modern extends Component
|
||||
{
|
||||
|
34
app/View/Components/Dropdown.php
Normal file
34
app/View/Components/Dropdown.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Dropdown extends Component
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $override;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$id = '', $override = ''
|
||||
) {
|
||||
$this->id = $id;
|
||||
$this->override = explode(',', $override);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.dropdown.index');
|
||||
}
|
||||
}
|
18
app/View/Components/Dropdown/Button.php
Normal file
18
app/View/Components/Dropdown/Button.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Dropdown;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Button extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.dropdown.button');
|
||||
}
|
||||
}
|
31
app/View/Components/Dropdown/Link.php
Normal file
31
app/View/Components/Dropdown/Link.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Dropdown;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Link extends Component
|
||||
{
|
||||
public $href;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$href = '',
|
||||
) {
|
||||
$this->href = $href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.dropdown.link');
|
||||
}
|
||||
}
|
@ -2,38 +2,68 @@
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Traits\Modules;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
|
||||
class EmptyPage extends Component
|
||||
{
|
||||
use Modules;
|
||||
|
||||
/** @var string */
|
||||
public $page;
|
||||
public $alias;
|
||||
|
||||
/** @var string */
|
||||
public $group;
|
||||
|
||||
/** @var string */
|
||||
public $page;
|
||||
|
||||
/** @var string */
|
||||
public $title;
|
||||
|
||||
/** @var string */
|
||||
public $description;
|
||||
|
||||
/** @var string */
|
||||
public $docsCategory;
|
||||
|
||||
/** @var string */
|
||||
public $image;
|
||||
|
||||
/** @var string */
|
||||
public $imageEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $textEmptyPage;
|
||||
|
||||
/** @var string */
|
||||
public $textPage;
|
||||
|
||||
/** @var string */
|
||||
public $urlDocsPath;
|
||||
|
||||
/** @var bool */
|
||||
public $checkPermissionCreate;
|
||||
|
||||
/** @var string */
|
||||
public $permissionCreate;
|
||||
|
||||
/** @var array */
|
||||
public $buttons;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonCreate;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtonImport;
|
||||
|
||||
/** @var string */
|
||||
public $routeCreate;
|
||||
public $importRoute;
|
||||
|
||||
/** @var array */
|
||||
public $importRouteParameters;
|
||||
|
||||
/** @var array */
|
||||
public $suggestion;
|
||||
|
||||
/** @var array */
|
||||
public $suggestions;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
@ -41,18 +71,38 @@ class EmptyPage extends Component
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $page, string $group = '', string $imageEmptyPage = '', string $textEmptyPage = '', string $textPage = '',
|
||||
string $urlDocsPath = '', bool $checkPermissionCreate = true, string $permissionCreate = '', string $routeCreate = ''
|
||||
string $alias = '', string $group = '', string $page = '',
|
||||
string $title = '', string $description = '', string $docsCategory = 'accounting',
|
||||
string $image = '', string $imageEmptyPage = '',
|
||||
bool $checkPermissionCreate = true, string $permissionCreate = '',
|
||||
array $buttons = [], bool $hideButtonCreate = false, bool $hideButtonImport = false,
|
||||
string $importRoute = '', array $importRouteParameters = []
|
||||
) {
|
||||
$this->page = $page;
|
||||
if (empty($alias) && ! empty($group)) {
|
||||
$alias = $group;
|
||||
}
|
||||
|
||||
$this->alias = (module($alias) === null) ? 'core': $alias;
|
||||
$this->group = $group;
|
||||
$this->imageEmptyPage = $this->getImageEmptyPage($page, $imageEmptyPage);
|
||||
$this->textEmptyPage = $this->getTextEmptyPage($page, $textEmptyPage);
|
||||
$this->textPage = $this->getTextPage($page, $textPage);
|
||||
$this->urlDocsPath = $this->getUrlDocsPath($page, $group, $urlDocsPath);
|
||||
$this->page = $page;
|
||||
$this->docsCategory = $docsCategory;
|
||||
|
||||
$this->title = $this->getTitle($title);
|
||||
$this->description = $this->getDescription($description);
|
||||
|
||||
$this->imageEmptyPage = $imageEmptyPage;
|
||||
$this->image = $this->getImage($page, $image);
|
||||
|
||||
$this->checkPermissionCreate = $checkPermissionCreate;
|
||||
$this->permissionCreate = $this->getPermissionCreate($page, $group, $permissionCreate);
|
||||
$this->routeCreate = $this->getRouteCreate($page, $routeCreate);
|
||||
|
||||
$this->hideButtonCreate = $hideButtonCreate;
|
||||
$this->hideButtonImport = $hideButtonImport;
|
||||
|
||||
$this->buttons = $this->getButtons($page, $group, $buttons);
|
||||
|
||||
$this->suggestions = $this->getSuggestionModules();
|
||||
$this->suggestion = $this->getSuggestionModule();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,61 +115,111 @@ class EmptyPage extends Component
|
||||
return view('components.empty-page');
|
||||
}
|
||||
|
||||
protected function getImageEmptyPage($page, $imageEmptyPage)
|
||||
protected function getTitle($title = null, $number = 2)
|
||||
{
|
||||
if ($imageEmptyPage) {
|
||||
return $imageEmptyPage;
|
||||
if (! empty($title)) {
|
||||
return $title;
|
||||
}
|
||||
|
||||
return 'public/img/empty_pages/' . $page . '.png';
|
||||
switch ($this->alias) {
|
||||
case 'core':
|
||||
$text = 'general.' . $this->page;
|
||||
break;
|
||||
default:
|
||||
$text = $this->alias . '::general.' . $this->page;
|
||||
}
|
||||
|
||||
$title = trans_choice($text, $number);
|
||||
|
||||
if ($title == $text) {
|
||||
$title = trans_choice(Str::replace('-', '_', $text), $number);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
protected function getTextEmptyPage($page, $textEmptyPage)
|
||||
protected function getDescription($description)
|
||||
{
|
||||
if ($textEmptyPage) {
|
||||
return $textEmptyPage;
|
||||
if (! empty($description)) {
|
||||
return $description;
|
||||
}
|
||||
|
||||
return 'general.empty.' . $page;
|
||||
switch ($this->alias) {
|
||||
case 'core':
|
||||
$text = 'general.empty.' . $this->page;
|
||||
break;
|
||||
default:
|
||||
$text = $this->alias . '::general.empty.' . $this->page;
|
||||
}
|
||||
|
||||
$description = trans($text);
|
||||
|
||||
if ($description == $text) {
|
||||
$description = trans(Str::replace('-', '_', $text));
|
||||
}
|
||||
|
||||
$docs_url = $this->getDocsUrl();
|
||||
|
||||
if (! empty($docs_url)) {
|
||||
$description .= ' ' . trans('general.empty.documentation', ['url' => $docs_url]);
|
||||
}
|
||||
|
||||
return $description;
|
||||
}
|
||||
|
||||
protected function getTextPage($page, $textPage)
|
||||
protected function getDocsUrl()
|
||||
{
|
||||
if ($textPage) {
|
||||
return $textPage;
|
||||
switch ($this->alias) {
|
||||
case 'core':
|
||||
$docs_path = 'user-manual/';
|
||||
|
||||
if (! empty($this->group)) {
|
||||
$docs_path .= $this->group . '/';
|
||||
}
|
||||
|
||||
$docs_path .= $this->page;
|
||||
break;
|
||||
default:
|
||||
$docs_path = 'app-manual/' . $this->docsCategory . '/' . $this->alias;
|
||||
}
|
||||
|
||||
return 'general.' . $page;
|
||||
return 'https://akaunting.com/docs/' . $docs_path;
|
||||
}
|
||||
|
||||
protected function getUrlDocsPath($page, $group, $urlDocsPath)
|
||||
protected function getImage($page, $image)
|
||||
{
|
||||
if ($urlDocsPath) {
|
||||
return $urlDocsPath;
|
||||
if (! empty($image)) {
|
||||
return $image;
|
||||
}
|
||||
|
||||
$docs_path = $page;
|
||||
|
||||
if (!empty($group)) {
|
||||
$docs_path = $group . '/' . $page;
|
||||
if (! empty($this->imageEmptyPage)) {
|
||||
return asset($this->imageEmptyPage);
|
||||
}
|
||||
|
||||
return 'https://akaunting.com/docs/user-manual/' . $docs_path;
|
||||
$path = 'public/img/empty_pages/' . $page . '.png';
|
||||
|
||||
if ($this->alias != 'core') {
|
||||
$path = 'modules/' . Str::studly($this->alias) . '/Resources/assets/img/empty-' . $page . '.png';
|
||||
|
||||
if (! file_exists($path)) {
|
||||
$path = 'public/img/empty_pages/default.png';
|
||||
}
|
||||
}
|
||||
|
||||
return asset($path);
|
||||
}
|
||||
|
||||
protected function getPermissionCreate($page, $group, $permissionCreate)
|
||||
{
|
||||
if ($permissionCreate) {
|
||||
if (! empty($permissionCreate)) {
|
||||
return $permissionCreate;
|
||||
}
|
||||
|
||||
$pages = [
|
||||
'reconciliations' => 'create-banking-reconciliations',
|
||||
'transfers' => 'create-banking-transfers',
|
||||
'payments' => 'create-purchases-payments',
|
||||
'vendors' => 'create-purchases-vendors',
|
||||
'customers' => 'create-sales-customers',
|
||||
'revenues' => 'create-sales-revenues',
|
||||
'taxes' => 'create-settings-taxes',
|
||||
'items' => 'create-common-items',
|
||||
];
|
||||
@ -135,12 +235,121 @@ class EmptyPage extends Component
|
||||
return $permissionCreate;
|
||||
}
|
||||
|
||||
protected function getRouteCreate($page, $routeCreate)
|
||||
protected function getButtons($page, $group, $buttons)
|
||||
{
|
||||
if ($routeCreate) {
|
||||
return $routeCreate;
|
||||
if (! empty($buttons)) {
|
||||
$suggestion = $this->getSuggestionModule();
|
||||
|
||||
if (! empty($suggestion)) {
|
||||
return array_slice($buttons, 0, 2);
|
||||
} else {
|
||||
return array_slice($buttons, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
return $page . '.create';
|
||||
if (! $this->hideButtonCreate) {
|
||||
$buttons[] = $this->getCreateButton($page, $group);
|
||||
}
|
||||
|
||||
if (! $this->hideButtonImport) {
|
||||
$buttons[] = $this->getImportButton();
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
protected function getCreateButton($page, $group)
|
||||
{
|
||||
try {
|
||||
$route = route($group . '.' . $page . '.create');
|
||||
} catch (\Exception $e) {
|
||||
$route = route($page . '.create');
|
||||
}
|
||||
|
||||
$title = $this->getTitle(null, 1);
|
||||
|
||||
return [
|
||||
'url' => $route,
|
||||
'permission' => $this->permissionCreate,
|
||||
'text' => trans('general.title.new', ['type' => $title]),
|
||||
'description' => trans('general.empty.actions.new', ['type' => strtolower($title)]),
|
||||
'active_badge' => true,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getImportButton()
|
||||
{
|
||||
$importRoute = $this->getImportRoute($this->importRoute);
|
||||
$importRouteParameters = $this->getImportRouteParameters($this->importRouteParameters);
|
||||
|
||||
$title = $this->getTitle();
|
||||
|
||||
return [
|
||||
'url' => route($importRoute, $importRouteParameters),
|
||||
'permission' => $this->permissionCreate,
|
||||
'text' => trans('import.title', ['type' => $title]),
|
||||
'description' => trans('general.empty.actions.import', ['type' => strtolower($title)]),
|
||||
'active_badge' => false,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getImportRoute($importRoute)
|
||||
{
|
||||
if (! empty($importRoute)) {
|
||||
return $importRoute;
|
||||
}
|
||||
|
||||
$route = 'import.create';
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
protected function getImportRouteParameters($importRouteParameters)
|
||||
{
|
||||
if (! empty($importRouteParameters)) {
|
||||
return $importRouteParameters;
|
||||
}
|
||||
|
||||
return array_slice(request()->segments(), -2, 2, true) ;
|
||||
}
|
||||
|
||||
public function getSuggestionModule()
|
||||
{
|
||||
return ! empty($this->suggestions) ? Arr::random($this->suggestions) : false;
|
||||
}
|
||||
|
||||
public function getSuggestionModules()
|
||||
{
|
||||
if ((! $user = user()) || $user->cannot('read-modules-home')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! $path = Route::current()->uri()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$path = str_replace('{company_id}/', '', $path);
|
||||
|
||||
if (! $suggestions = $this->getSuggestions($path)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$modules = [];
|
||||
|
||||
foreach ($suggestions->modules as $s_module) {
|
||||
if ($this->moduleIsEnabled($s_module->alias)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$s_module->action_url = company_id() . '/' . $s_module->action_url;
|
||||
|
||||
$modules[] = $s_module;
|
||||
}
|
||||
|
||||
if (empty($modules)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
}
|
||||
|
132
app/View/Components/Form.php
Normal file
132
app/View/Components/Form.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use App\Abstracts\View\Components\Form as BaseForm;
|
||||
|
||||
class Form extends BaseForm
|
||||
{
|
||||
/** @var string */
|
||||
public $method;
|
||||
|
||||
/** @var string */
|
||||
public $action;
|
||||
|
||||
public $model;
|
||||
|
||||
/** @var string */
|
||||
public $class;
|
||||
|
||||
/** @var string */
|
||||
public $role;
|
||||
|
||||
/** @var string */
|
||||
public $novalidate;
|
||||
|
||||
/** @var string */
|
||||
public $enctype;
|
||||
|
||||
/** @var string */
|
||||
public $acceptCharset;
|
||||
|
||||
public $route;
|
||||
|
||||
public $url;
|
||||
|
||||
public $submit;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $method = 'POST',
|
||||
string $action = '',
|
||||
$model = false,
|
||||
string $class = 'mb-0',
|
||||
string $role = 'form',
|
||||
string $novalidate = 'true',
|
||||
string $enctype = 'multipart/form-data',
|
||||
string $acceptCharset = 'UTF-8',
|
||||
$route = '',
|
||||
$url = '',
|
||||
$submit = 'onSubmit'
|
||||
) {
|
||||
$this->method = Str::upper($method);
|
||||
$this->action = $this->getAction($action, $route, $url);
|
||||
$this->model = $model;
|
||||
$this->class = $class;
|
||||
$this->role = $role;
|
||||
$this->novalidate = $novalidate;
|
||||
$this->enctype = $enctype;
|
||||
$this->acceptCharset = $acceptCharset;
|
||||
$this->submit = $submit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.index');
|
||||
}
|
||||
|
||||
protected function getAction($action, $route, $url)
|
||||
{
|
||||
if (!empty($action)) {
|
||||
return $action;
|
||||
}
|
||||
|
||||
if (!empty($route)) {
|
||||
return $this->getRouteAction($route);
|
||||
}
|
||||
|
||||
if (!empty($url)) {
|
||||
return $this->getUrlAction($url);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "url" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrlAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
return url($options[0], array_slice($options, 1));
|
||||
}
|
||||
|
||||
return url($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "route" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRouteAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$parameters = array_slice($options, 1);
|
||||
|
||||
if (array_keys($options) === [0, 1]) {
|
||||
$parameters = head($parameters);
|
||||
}
|
||||
|
||||
return route($options[0], $parameters);
|
||||
}
|
||||
|
||||
return route($options);
|
||||
}
|
||||
}
|
46
app/View/Components/Form/Accordion.php
Normal file
46
app/View/Components/Form/Accordion.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Accordion extends Component
|
||||
{
|
||||
public $type;
|
||||
|
||||
public $icon;
|
||||
|
||||
public $open;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, string $icon = '', bool $open = false
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->icon = $this->getIcon($icon);
|
||||
$this->open = $open;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.accordion.index');
|
||||
}
|
||||
|
||||
protected function getIcon($icon)
|
||||
{
|
||||
if (! empty($icon)) {
|
||||
return $icon;
|
||||
}
|
||||
|
||||
return 'expand_more';
|
||||
}
|
||||
}
|
131
app/View/Components/Form/Buttons.php
Normal file
131
app/View/Components/Form/Buttons.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Buttons extends Component
|
||||
{
|
||||
public $groupClass = 'sm:col-span-6';
|
||||
|
||||
public $withoutCancel;
|
||||
|
||||
public $cancel;
|
||||
|
||||
public $cancelRoute;
|
||||
|
||||
public $cancelUrl;
|
||||
|
||||
public $cancelClass = 'px-6 py-1.5 hover:bg-gray-200 rounded-lg ltr:mr-2 rtl:ml-2';
|
||||
|
||||
public $cancelText;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$groupClass = '',
|
||||
$cancel = '', $cancelRoute = '', $cancelUrl = '', $cancelClass = '', $cancelText = '', $withoutCancel = false
|
||||
) {
|
||||
$this->groupClass = $this->getGroupClass($groupClass);
|
||||
|
||||
$this->cancel = $this->getCancel($cancel, $cancelRoute, $cancelUrl);
|
||||
$this->cancelClass = $this->getCancelClass($cancelClass);
|
||||
$this->cancelText = $this->getCancelText($cancelText);
|
||||
$this->withoutCancel = $withoutCancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.buttons');
|
||||
}
|
||||
|
||||
protected function getGroupClass($groupClass)
|
||||
{
|
||||
if (! empty($groupClass)) {
|
||||
return $groupClass;
|
||||
}
|
||||
|
||||
return $this->groupClass;
|
||||
}
|
||||
|
||||
protected function getCancel($cancel, $route, $url)
|
||||
{
|
||||
if (! empty($cancel)) {
|
||||
return $cancel;
|
||||
}
|
||||
|
||||
if (!empty($route)) {
|
||||
return $this->getRouteAction($route);
|
||||
}
|
||||
|
||||
if (!empty($url)) {
|
||||
return $this->getUrlAction($url);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "url" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrlAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
return url($options[0], array_slice($options, 1));
|
||||
}
|
||||
|
||||
return url($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "route" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRouteAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$parameters = array_slice($options, 1);
|
||||
|
||||
if (array_keys($options) === [0, 1]) {
|
||||
$parameters = head($parameters);
|
||||
}
|
||||
|
||||
return route($options[0], $parameters);
|
||||
}
|
||||
|
||||
return route($options);
|
||||
}
|
||||
|
||||
protected function getCancelClass($cancelClass)
|
||||
{
|
||||
if (! empty($cancelClass)) {
|
||||
return $cancelClass;
|
||||
}
|
||||
|
||||
return $this->cancelClass;
|
||||
}
|
||||
|
||||
protected function getCancelText($cancelText)
|
||||
{
|
||||
if (! empty($cancelText)) {
|
||||
return $cancelText;
|
||||
}
|
||||
|
||||
return trans('general.cancel');
|
||||
}
|
||||
}
|
37
app/View/Components/Form/Group/Account.php
Normal file
37
app/View/Components/Form/Group/Account.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
use App\Models\Banking\Account as Model;
|
||||
|
||||
class Account extends Form
|
||||
{
|
||||
public $type = 'account';
|
||||
|
||||
public $path;
|
||||
|
||||
public $accounts;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
$this->name = 'account_id';
|
||||
}
|
||||
|
||||
$this->path = route('modals.accounts.create');
|
||||
|
||||
$this->accounts = Model::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
if (empty($this->selected) && empty($this->getParentData('model'))) {
|
||||
$this->selected = setting('default.account');
|
||||
}
|
||||
|
||||
return view('components.form.group.account');
|
||||
}
|
||||
}
|
80
app/View/Components/Form/Group/Attachment.php
Normal file
80
app/View/Components/Form/Group/Attachment.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Attachment extends Form
|
||||
{
|
||||
public $name = 'attachment';
|
||||
|
||||
public $type = 'file';
|
||||
|
||||
public $formGroupClass = 'sm:col-span-3';
|
||||
|
||||
public $custom_attributes = [
|
||||
'dropzone-class' => 'form-file dropzone-column w-1/2 h-32.5',
|
||||
];
|
||||
|
||||
public $file_types;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->setFileTypes();
|
||||
|
||||
$this->custom_attributes = $this->setCustomAttributes();
|
||||
|
||||
return view('components.form.group.attachment');
|
||||
}
|
||||
|
||||
protected function setFileTypes()
|
||||
{
|
||||
$this->file_types = [];
|
||||
|
||||
$file_type_mimes = explode(',', config('filesystems.mimes'));
|
||||
|
||||
$file_types = [];
|
||||
|
||||
foreach ($file_type_mimes as $mime) {
|
||||
$file_types[] = '.' . $mime;
|
||||
}
|
||||
|
||||
$this->file_types = implode(',', $file_types);
|
||||
}
|
||||
|
||||
protected function setCustomAttributes()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
if (! empty($this->options)) {
|
||||
$attributes['options'] = $this->options;
|
||||
}
|
||||
|
||||
if (! empty($this->multiple)) {
|
||||
$attributes['multiple'] = $this->multiple;
|
||||
}
|
||||
|
||||
foreach ($this->custom_attributes as $key => $value) {
|
||||
$attributes[$key] = $value;
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
}
|
46
app/View/Components/Form/Group/Category.php
Normal file
46
app/View/Components/Form/Group/Category.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
use App\Models\Setting\Category as Model;
|
||||
|
||||
class Category extends Form
|
||||
{
|
||||
public $type = 'income';
|
||||
|
||||
public $path;
|
||||
|
||||
public $remoteAction;
|
||||
|
||||
public $categories;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$type = $this->type;
|
||||
|
||||
if (empty($this->name)) {
|
||||
$this->name = 'category_id';
|
||||
}
|
||||
|
||||
$this->path = route('modals.categories.create', ['type' => $this->type]);
|
||||
$this->remoteAction = route('categories.index', ['search' => 'type:' . $this->type . ' enabled:1']);
|
||||
|
||||
$this->categories = Model::type($type)->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
|
||||
|
||||
if (!empty($model) && $model->category && ! $this->categories->has($model->category_id)) {
|
||||
$this->categories->put($model->category->id, $model->category->name);
|
||||
}
|
||||
|
||||
if (empty($this->selected) && (in_array($type, ['income', 'expense']))) {
|
||||
$this->selected = setting('default.' . $type . '_category');
|
||||
}
|
||||
|
||||
return view('components.form.group.category');
|
||||
}
|
||||
}
|
27
app/View/Components/Form/Group/Checkbox.php
Normal file
27
app/View/Components/Form/Group/Checkbox.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Checkbox extends Form
|
||||
{
|
||||
public $type = 'checkbox';
|
||||
|
||||
/** @var string */
|
||||
public $formGroupClass = 'sm:col-span-6';
|
||||
|
||||
public $except = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.checkbox');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Color.php
Normal file
20
app/View/Components/Form/Group/Color.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Color extends Form
|
||||
{
|
||||
public $type = 'color';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.color');
|
||||
}
|
||||
}
|
76
app/View/Components/Form/Group/Contact.php
Normal file
76
app/View/Components/Form/Group/Contact.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
use App\Models\Common\Contact as Model;
|
||||
|
||||
class Contact extends Form
|
||||
{
|
||||
public $type = 'contact';
|
||||
|
||||
public $label;
|
||||
|
||||
public $view = 'components.form.group.contact';
|
||||
|
||||
public $path;
|
||||
|
||||
public $remoteAction;
|
||||
|
||||
public $contacts;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$type = $this->type;
|
||||
|
||||
switch ($type) {
|
||||
case 'customer':
|
||||
$this->prepareCustomer();
|
||||
break;
|
||||
case 'vendor':
|
||||
$this->prepareVendor();
|
||||
break;
|
||||
}
|
||||
|
||||
return view($this->view);
|
||||
}
|
||||
|
||||
protected function prepareCustomer()
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
$this->name = 'contact_id';
|
||||
}
|
||||
|
||||
$this->path = route('modals.customers.create');
|
||||
$this->remoteAction = route('customers.index');
|
||||
$this->label = trans_choice('general.customers', 1);
|
||||
|
||||
$this->contacts = Model::customer()->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
|
||||
|
||||
if (!empty($model) && $model->customer && ! $this->contacts->has($model->contact_id)) {
|
||||
$this->contacts->put($model->customer->id, $model->customer->name);
|
||||
}
|
||||
}
|
||||
|
||||
protected function prepareVendor()
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
$this->name = 'contact_id';
|
||||
}
|
||||
|
||||
$this->path = route('modals.vendors.create');
|
||||
$this->remoteAction = route('vendors.index');
|
||||
$this->label = trans_choice('general.vendors', 1);
|
||||
|
||||
$this->contacts = Model::vendor()->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
|
||||
|
||||
if (!empty($model) && $model->vendor && ! $this->contacts->has($model->contact_id)) {
|
||||
$this->contacts->put($model->vendor->id, $model->vendor->name);
|
||||
}
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Country.php
Normal file
20
app/View/Components/Form/Group/Country.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Country extends Form
|
||||
{
|
||||
public $type = 'country';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.country');
|
||||
}
|
||||
}
|
44
app/View/Components/Form/Group/Currency.php
Normal file
44
app/View/Components/Form/Group/Currency.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
use App\Models\Setting\Currency as Model;
|
||||
|
||||
class Currency extends Form
|
||||
{
|
||||
public $type = 'currency';
|
||||
|
||||
public $path;
|
||||
|
||||
public $field;
|
||||
|
||||
public $currencies;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
$this->name = 'currency_code';
|
||||
}
|
||||
|
||||
$this->path = route('modals.currencies.create');
|
||||
|
||||
$this->field = [
|
||||
'key' => 'code',
|
||||
'value' => 'name'
|
||||
];
|
||||
|
||||
$this->currencies = Model::enabled()->orderBy('name')->pluck('name', 'code');
|
||||
|
||||
if (empty($this->selected) && empty($this->getParentData('model'))) {
|
||||
$this->selected = setting('default.currency');
|
||||
}
|
||||
|
||||
return view('components.form.group.currency');
|
||||
}
|
||||
}
|
10
app/View/Components/Form/Group/Customer.php
Normal file
10
app/View/Components/Form/Group/Customer.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form\Group\Contact;
|
||||
|
||||
class Customer extends Contact
|
||||
{
|
||||
public $type = 'customer';
|
||||
}
|
20
app/View/Components/Form/Group/Date.php
Normal file
20
app/View/Components/Form/Group/Date.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Date extends Form
|
||||
{
|
||||
public $type = 'date';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.date');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/DateTime.php
Normal file
20
app/View/Components/Form/Group/DateTime.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class DateTime extends Form
|
||||
{
|
||||
public $type = 'date_time';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.date_time');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Editor.php
Normal file
20
app/View/Components/Form/Group/Editor.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Editor extends Form
|
||||
{
|
||||
public $type = 'editor';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.editor');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Email.php
Normal file
20
app/View/Components/Form/Group/Email.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Email extends Form
|
||||
{
|
||||
public $type = 'email';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.email');
|
||||
}
|
||||
}
|
26
app/View/Components/Form/Group/File.php
Normal file
26
app/View/Components/Form/Group/File.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class File extends Form
|
||||
{
|
||||
public $type = 'file';
|
||||
|
||||
public $formGroupClass = 'sm:col-span-3';
|
||||
|
||||
public $custom_attributes = [
|
||||
'dropzone-class' => 'form-file dropzone-column w-1/2 h-32.5',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.file');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/InvoiceText.php
Normal file
20
app/View/Components/Form/Group/InvoiceText.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class InvoiceText extends Form
|
||||
{
|
||||
public $type = 'invoice-text';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.invoice_text');
|
||||
}
|
||||
}
|
26
app/View/Components/Form/Group/Locale.php
Normal file
26
app/View/Components/Form/Group/Locale.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Locale extends Form
|
||||
{
|
||||
public $type = 'locale';
|
||||
|
||||
public $name = 'locale';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->selected)) {
|
||||
$this->selected = setting('default.locale', config('app.locale', 'en-GB'));
|
||||
}
|
||||
|
||||
return view('components.form.group.locale');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Money.php
Normal file
20
app/View/Components/Form/Group/Money.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Money extends Form
|
||||
{
|
||||
public $type = 'money';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.money');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Number.php
Normal file
20
app/View/Components/Form/Group/Number.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Number extends Form
|
||||
{
|
||||
public $type = 'number';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.number');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Password.php
Normal file
20
app/View/Components/Form/Group/Password.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Password extends Form
|
||||
{
|
||||
public $type = 'password';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.password');
|
||||
}
|
||||
}
|
29
app/View/Components/Form/Group/PaymentMethod.php
Normal file
29
app/View/Components/Form/Group/PaymentMethod.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
use App\Utilities\Modules;
|
||||
|
||||
class PaymentMethod extends Form
|
||||
{
|
||||
public $type = 'payment_method';
|
||||
|
||||
public $payment_methods;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
if (empty($this->selected) && empty($this->getParentData('model'))) {
|
||||
$this->selected = setting('default.payment_method');
|
||||
}
|
||||
|
||||
return view('components.form.group.payment_method');
|
||||
}
|
||||
}
|
27
app/View/Components/Form/Group/Radio.php
Normal file
27
app/View/Components/Form/Group/Radio.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Radio extends Form
|
||||
{
|
||||
public $type = 'radio';
|
||||
|
||||
/** @var string */
|
||||
public $formGroupClass = 'sm:col-span-6';
|
||||
|
||||
public $except = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.radio');
|
||||
}
|
||||
}
|
174
app/View/Components/Form/Group/Recurring.php
Normal file
174
app/View/Components/Form/Group/Recurring.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Utilities\Date;
|
||||
|
||||
class Recurring extends Component
|
||||
{
|
||||
public $type;
|
||||
|
||||
public $frequency;
|
||||
public $frequencies = [];
|
||||
|
||||
public $customFrequency = '';
|
||||
public $customFrequencies = [];
|
||||
|
||||
public $limit = '';
|
||||
public $limits = [];
|
||||
|
||||
public $startedValue = '';
|
||||
public $limitCount = '';
|
||||
public $limitDateValue = '';
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$type = '',
|
||||
$frequency = '',
|
||||
$frequencies = [],
|
||||
|
||||
$customFrequency = '',
|
||||
$customFrequencies = [],
|
||||
|
||||
$limit = '',
|
||||
$limits = [],
|
||||
|
||||
$startedValue = '',
|
||||
$limitCount = '',
|
||||
$limitDateValue = '',
|
||||
) {
|
||||
$this->type = $this->getType($type);
|
||||
$this->frequency = $this->getFrequency($frequency);
|
||||
$this->frequencies = $this->getFrequencies($frequencies);
|
||||
|
||||
$this->customFrequency = $this->getCustomFrequency($customFrequency);
|
||||
$this->customFrequencies = $this->getCustomFrequencies($customFrequencies);
|
||||
|
||||
$this->limit = $this->getLimit($limit);
|
||||
$this->limits = $this->getLimits($limits);
|
||||
|
||||
$this->startedValue = $this->getStartedValue($startedValue);
|
||||
$this->limitCount = $this->getLimitCount($limitCount);
|
||||
$this->limitDateValue = $this->getLimitDateValue($limitDateValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.recurring');
|
||||
}
|
||||
|
||||
protected function getType($type)
|
||||
{
|
||||
if (! empty($type)) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
return 'invoice';
|
||||
}
|
||||
|
||||
protected function getFrequency($frequency)
|
||||
{
|
||||
if (! empty($frequency)) {
|
||||
return $frequency;
|
||||
}
|
||||
|
||||
return 'monthly';
|
||||
}
|
||||
|
||||
protected function getFrequencies($frequencies)
|
||||
{
|
||||
if (! empty($frequencies)) {
|
||||
return $frequencies;
|
||||
}
|
||||
|
||||
return [
|
||||
'daily' => trans('recurring.daily'),
|
||||
'weekly' => trans('recurring.weekly'),
|
||||
'monthly' => trans('recurring.monthly'),
|
||||
'yearly' => trans('recurring.yearly'),
|
||||
'custom' => trans('recurring.custom'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getCustomFrequency($customFrequency)
|
||||
{
|
||||
if (! empty($customFrequency)) {
|
||||
return $customFrequency;
|
||||
}
|
||||
|
||||
return 'monthly';
|
||||
}
|
||||
|
||||
protected function getCustomFrequencies($customFrequencies)
|
||||
{
|
||||
if (! empty($customFrequencies)) {
|
||||
return $customFrequencies;
|
||||
}
|
||||
|
||||
return [
|
||||
'daily' => trans('recurring.days'),
|
||||
'weekly' => trans('recurring.weeks'),
|
||||
'monthly' => trans('recurring.months'),
|
||||
'yearly' => trans('recurring.years'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getLimit($limit)
|
||||
{
|
||||
if (! empty($limit)) {
|
||||
return $limit;
|
||||
}
|
||||
|
||||
return 'never';
|
||||
}
|
||||
|
||||
protected function getLimits($limits)
|
||||
{
|
||||
if (! empty($limits)) {
|
||||
return $limits;
|
||||
}
|
||||
|
||||
return [
|
||||
'after' => trans('recurring.after'),
|
||||
'on' => trans('recurring.on'),
|
||||
'never' => trans('recurring.never'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getStartedValue($startedValue)
|
||||
{
|
||||
if (! empty($startedValue)) {
|
||||
return $startedValue;
|
||||
}
|
||||
|
||||
return Date::now()->toDateString();
|
||||
}
|
||||
|
||||
protected function getLimitCount($limitCount)
|
||||
{
|
||||
if (! empty($limitCount)) {
|
||||
return $limitCount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function getLimitDateValue($limitDateValue)
|
||||
{
|
||||
if (! empty($limitDateValue)) {
|
||||
return $limitDateValue;
|
||||
}
|
||||
|
||||
return Date::now()->toDateString();
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Select.php
Normal file
20
app/View/Components/Form/Group/Select.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Select extends Form
|
||||
{
|
||||
public $type = 'select';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.select');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Sswitch.php
Normal file
20
app/View/Components/Form/Group/Sswitch.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Sswitch extends Form
|
||||
{
|
||||
public $type = 'switch';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.switch');
|
||||
}
|
||||
}
|
44
app/View/Components/Form/Group/Tax.php
Normal file
44
app/View/Components/Form/Group/Tax.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
use App\Models\Setting\Currency as Model;
|
||||
|
||||
class Tax extends Form
|
||||
{
|
||||
public $type = 'tax';
|
||||
|
||||
public $path;
|
||||
|
||||
public $field;
|
||||
|
||||
public $currencies;
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
$this->name = 'currency_code';
|
||||
}
|
||||
|
||||
$this->path = route('modals.currencies.create');
|
||||
|
||||
$this->field = [
|
||||
'key' => 'code',
|
||||
'value' => 'name'
|
||||
];
|
||||
|
||||
$this->currencies = Model::enabled()->orderBy('name')->pluck('name', 'code');
|
||||
|
||||
if (empty($this->selected)) {
|
||||
$this->selected = setting('default.currency');
|
||||
}
|
||||
|
||||
return view('components.form.group.tax');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Text.php
Normal file
20
app/View/Components/Form/Group/Text.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Text extends Form
|
||||
{
|
||||
public $type = 'text';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.text');
|
||||
}
|
||||
}
|
22
app/View/Components/Form/Group/Textarea.php
Normal file
22
app/View/Components/Form/Group/Textarea.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Textarea extends Form
|
||||
{
|
||||
public $type = 'textarea';
|
||||
|
||||
public $formGroupClass = 'sm:col-span-6';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.textarea');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Time.php
Normal file
20
app/View/Components/Form/Group/Time.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Time extends Form
|
||||
{
|
||||
public $type = 'time';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.time');
|
||||
}
|
||||
}
|
20
app/View/Components/Form/Group/Toggle.php
Normal file
20
app/View/Components/Form/Group/Toggle.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Form\Group;
|
||||
|
||||
use App\Abstracts\View\Components\Form;
|
||||
|
||||
class Toggle extends Form
|
||||
{
|
||||
public $type = 'radio';
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.form.group.toggle');
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user