akaunting 3.0 (the last dance)
This commit is contained in:
@ -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'));
|
||||
}
|
||||
|
230
app/View/Components/Documents/Form/Contact.php
Normal file
230
app/View/Components/Documents/Form/Contact.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Contact as Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Contact extends Component
|
||||
{
|
||||
public $type;
|
||||
|
||||
public $contact;
|
||||
|
||||
public $placeholder;
|
||||
|
||||
public $contacts;
|
||||
|
||||
public $searchRoute;
|
||||
|
||||
public $createRoute;
|
||||
|
||||
/** @var string */
|
||||
public $textAddContact;
|
||||
|
||||
/** @var string */
|
||||
public $textCreateNewContact;
|
||||
|
||||
/** @var string */
|
||||
public $textEditContact;
|
||||
|
||||
/** @var string */
|
||||
public $textContactInfo;
|
||||
|
||||
/** @var string */
|
||||
public $textChooseDifferentContact;
|
||||
|
||||
/** @var $error */
|
||||
public $error;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
$this->searchRoute = $searchRoute;
|
||||
$this->createRoute = $createRoute;
|
||||
$this->error = ($error) ?: "form.errors.get('contact_id')" ;
|
||||
|
||||
$this->textAddContact = $this->getTextAddContact($type, $textAddContact);
|
||||
$this->textCreateNewContact = $this->getTextCreateNewContact($type, $textCreateNewContact);
|
||||
$this->textEditContact = $this->getTextEditContact($type, $textEditContact);
|
||||
$this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo);
|
||||
$this->textChooseDifferentContact = $this->getTextChooseDifferentContact($type, $textChooseDifferentContact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->contacts)) {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->searchRoute)) {
|
||||
switch ($this->type) {
|
||||
case 'customer':
|
||||
$this->searchRoute = route('customers.index');
|
||||
break;
|
||||
case 'vendor':
|
||||
$this->searchRoute = route('vendors.index');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->createRoute)) {
|
||||
switch ($this->type) {
|
||||
case 'customer':
|
||||
$this->createRoute = route('modals.customers.create');
|
||||
break;
|
||||
case 'vendor':
|
||||
$this->createRoute = route('modals.vendors.create');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#todo 3rd part apps
|
||||
$this->placeholder = trans('general.placeholder.contact_search', ['type' => trans_choice('general.' . Str::plural($this->type, 2), 1)]);
|
||||
|
||||
return view('components.documents.form.contact');
|
||||
}
|
||||
|
||||
protected function getTextAddContact($type, $textAddContact)
|
||||
{
|
||||
if (!empty($textAddContact)) {
|
||||
return $textAddContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textAddContact = [
|
||||
'general.form.add',
|
||||
'general.vendors'
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$textAddContact = [
|
||||
'general.form.add',
|
||||
'general.customers'
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $textAddContact;
|
||||
}
|
||||
|
||||
protected function getTextCreateNewContact($type, $textCreateNewContact)
|
||||
{
|
||||
if (!empty($textCreateNewContact)) {
|
||||
return $textCreateNewContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textCreateNewContact = [
|
||||
'general.form.add_new',
|
||||
'general.vendors'
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$textCreateNewContact = [
|
||||
'general.form.add_new',
|
||||
'general.customers'
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $textCreateNewContact;
|
||||
}
|
||||
|
||||
protected function getTextEditContact($type, $textEditContact)
|
||||
{
|
||||
if (!empty($textEditContact)) {
|
||||
return $textEditContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textEditContact = [
|
||||
'general.form.contact_edit',
|
||||
'general.vendors'
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$textEditContact = [
|
||||
'general.form.contact_edit',
|
||||
'general.customers'
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $textEditContact;
|
||||
}
|
||||
|
||||
protected function getTextContactInfo($type, $textContactInfo)
|
||||
{
|
||||
if (!empty($textContactInfo)) {
|
||||
return $textContactInfo;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textContactInfo = 'bills.bill_from';
|
||||
break;
|
||||
default:
|
||||
$textContactInfo = 'invoices.bill_to';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textContactInfo;
|
||||
}
|
||||
|
||||
protected function getTextChooseDifferentContact($type, $textChooseDifferentContact)
|
||||
{
|
||||
if (!empty($textChooseDifferentContact)) {
|
||||
return $textChooseDifferentContact;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textChooseDifferentContact = [
|
||||
'general.form.choose_different',
|
||||
'general.vendors'
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$textChooseDifferentContact = [
|
||||
'general.form.choose_different',
|
||||
'general.customers'
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $textChooseDifferentContact;
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
81
app/View/Components/Documents/Form/ItemButton.php
Normal file
81
app/View/Components/Documents/Form/ItemButton.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Common\Item;
|
||||
|
||||
class ItemButton extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var bool */
|
||||
public $isSale;
|
||||
|
||||
/** @var bool */
|
||||
public $isPurchase;
|
||||
|
||||
/** @var int */
|
||||
public $searchCharLimit;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = 'sale', bool $isSale = false, bool $isPurchase = false, int $searchCharLimit = 3)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->isSale = $isSale;
|
||||
$this->isPurchase = $isPurchase;
|
||||
$this->searchCharLimit = $searchCharLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$items = Item::enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
|
||||
$price_type = $this->getPriceType($this->type, $this->isSale, $this->isPurchase);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$price = $item->{$price_type . '_price'};
|
||||
|
||||
$item->price = $price;
|
||||
}
|
||||
|
||||
$price = $price_type . '_price';
|
||||
|
||||
return view('components.documents.form.item-button', compact('items', 'price'));
|
||||
}
|
||||
|
||||
protected function getPriceType($type, $is_sale, $is_purchase)
|
||||
{
|
||||
if (!empty($is_sale)) {
|
||||
return 'sale';
|
||||
}
|
||||
|
||||
if (!empty($is_purchase)) {
|
||||
return 'purchase';
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$type = 'purchase';
|
||||
break;
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
default:
|
||||
$type = 'sale';
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
}
|
31
app/View/Components/Documents/Form/ItemColumns.php
Normal file
31
app/View/Components/Documents/Form/ItemColumns.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class ItemColumns extends Component
|
||||
{
|
||||
/* string */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = 'invoice')
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
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
|
||||
{
|
||||
|
Reference in New Issue
Block a user