Document form component styling..
This commit is contained in:
parent
f8d0075f79
commit
47917a0cc8
@ -2,19 +2,151 @@
|
||||
|
||||
namespace App\Abstracts\View\Components;
|
||||
|
||||
use App\Models\Common\Contact;
|
||||
use App\Models\Document\Document;
|
||||
use App\Traits\Documents;
|
||||
use Date;
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class DocumentForm extends Component
|
||||
{
|
||||
use Documents;
|
||||
|
||||
public $type;
|
||||
|
||||
public $documents;
|
||||
public $document;
|
||||
|
||||
public $bulkActions;
|
||||
/** Advanced Component Start */
|
||||
/** @var bool */
|
||||
public $hideRecurring;
|
||||
|
||||
/** @var bool */
|
||||
public $hideBulkAction;
|
||||
public $hideCategory;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAttachment;
|
||||
/** Advanced Component End */
|
||||
|
||||
/** Company Component Start */
|
||||
/** @var bool */
|
||||
public $hideLogo;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentSubheading;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyEdit;
|
||||
/** Company Component End */
|
||||
|
||||
/** Content Component Start */
|
||||
/** @var string */
|
||||
public $formRoute;
|
||||
|
||||
/** @var string */
|
||||
public $formId;
|
||||
|
||||
/** @var string */
|
||||
public $formSubmit;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompany;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAdvanced;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFooter;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtons;
|
||||
/** Content Component End */
|
||||
|
||||
/** Metadata Component Start */
|
||||
public $contacts;
|
||||
|
||||
/** @var string */
|
||||
public $contactType;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContact;
|
||||
|
||||
/** @var bool */
|
||||
public $hideIssuedAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDueAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideOrderNumber;
|
||||
|
||||
/** @var string */
|
||||
public $issuedAt;
|
||||
|
||||
/** @var string */
|
||||
public $documentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $dueAt;
|
||||
|
||||
/** @var string */
|
||||
public $orderNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textIssuedAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDueAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDocumentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textOrderNumber;
|
||||
/** Metadata Component End */
|
||||
|
||||
/** Items Component Start */
|
||||
/** @var bool */
|
||||
public $hideEditItemColumns;
|
||||
|
||||
/** @var string */
|
||||
public $textItems;
|
||||
|
||||
/** @var string */
|
||||
public $textQuantity;
|
||||
|
||||
/** @var string */
|
||||
public $textPrice;
|
||||
|
||||
/** @var string */
|
||||
public $textAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideItems;
|
||||
|
||||
/** @var bool */
|
||||
public $hideName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDescription;
|
||||
|
||||
/** @var bool */
|
||||
public $hideQuantity;
|
||||
|
||||
/** @var bool */
|
||||
public $hidePrice;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDiscount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAmount;
|
||||
/** Items Component End */
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
@ -22,13 +154,574 @@ abstract class DocumentForm extends Component
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$type, $documents = [], $bulkActions = [],
|
||||
bool $hideBulkAction = false
|
||||
$type, $document = false,
|
||||
/** Advanced Component Start */
|
||||
bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false,
|
||||
/** Advanced Component End */
|
||||
/** Company Component Start */
|
||||
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false,
|
||||
/** Company Component End */
|
||||
/** Content Component Start */
|
||||
string $formRoute = '', string $formId = 'document', string $formSubmit = 'onSubmit',
|
||||
bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false,
|
||||
/** Content Component End */
|
||||
/** Metadata Component Start */
|
||||
$contacts = [], string $contactType = '',
|
||||
bool $hideContact = false, bool $hideIssuedAt = false, bool $hideDocumentNumber = false, bool $hideDueAt = false, bool $hideOrderNumber = false,
|
||||
string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '',
|
||||
string $issuedAt = '', string $documentNumber = '', string $dueAt = '', string $orderNumber = '',
|
||||
/** Metadata Component End */
|
||||
/** Items Component Start */
|
||||
string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '',
|
||||
bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false,
|
||||
bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false,
|
||||
bool $hideEditItemColumns = false
|
||||
/** Items Component End */
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->documents = $documents;
|
||||
$this->document = $document;
|
||||
|
||||
$this->bulkActions = $bulkActions;
|
||||
$this->hideBulkAction = $hideBulkAction;
|
||||
/** Advanced Component Start */
|
||||
$this->hideRecurring = $hideRecurring;
|
||||
$this->hideCategory = $hideCategory;
|
||||
$this->hideAttachment = $hideAttachment;
|
||||
/** Advanced Component End */
|
||||
|
||||
/** Company Component Start */
|
||||
$this->hideLogo = $hideLogo;
|
||||
$this->hideDocumentTitle = $hideDocumentTitle;
|
||||
$this->hideDocumentSubheading = $hideDocumentSubheading;
|
||||
$this->hideCompanyEdit = $hideCompanyEdit;
|
||||
/** Company Component End */
|
||||
|
||||
/** Content Component Start */
|
||||
$this->formRoute = ($formRoute) ? $formRoute : $this->getRoute($type, $document);
|
||||
$this->formId = $formId;
|
||||
$this->formSubmit = $formSubmit;
|
||||
|
||||
$this->hideCompany = $hideCompany;
|
||||
$this->hideAdvanced = $hideAdvanced;
|
||||
$this->hideFooter = $hideFooter;
|
||||
$this->hideButtons = $hideButtons;
|
||||
/** Content Component End */
|
||||
|
||||
/** Metadata Component Start */
|
||||
$this->contacts = $this->getContacts($type, $contacts);
|
||||
$this->contactType = $this->getContactType($type, $contactType);
|
||||
|
||||
$this->hideContact = $hideContact;
|
||||
$this->hideIssuedAt = $hideIssuedAt;
|
||||
$this->hideDocumentNumber = $hideDocumentNumber;
|
||||
$this->hideDueAt = $hideDueAt;
|
||||
$this->hideOrderNumber = $hideOrderNumber;
|
||||
$this->issuedAt = $this->getIssuedAt($type, $document, $issuedAt);
|
||||
$this->documentNumber = $this->getDocumentNumber($type, $document, $documentNumber);
|
||||
$this->dueAt = $this->getDueAt($type, $document, $dueAt);
|
||||
$this->orderNumber = $this->getOrderNumber($type, $document, $orderNumber);
|
||||
|
||||
$this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt);
|
||||
$this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
|
||||
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
|
||||
$this->textOrderNumber = $this->getTextOrderNumber($type, $textOrderNumber);
|
||||
/** Metadata Component End */
|
||||
|
||||
/** Items Component Start */
|
||||
$this->textItems = $this->getTextItems($type, $textItems);
|
||||
$this->textQuantity = $this->getTextQuantity($type, $textQuantity);
|
||||
$this->textPrice = $this->getTextPrice($type, $textPrice);
|
||||
$this->textAmount = $this->getTextAmount($type, $textAmount);
|
||||
|
||||
$this->hideItems = $this->getHideItems($type, $hideItems, $hideName, $hideDescription);
|
||||
$this->hideName = $this->getHideName($type, $hideName);
|
||||
$this->hideDescription = $this->getHideDescription($type, $hideDescription);
|
||||
$this->hideQuantity = $this->getHideQuantity($type, $hideQuantity);
|
||||
$this->hidePrice = $this->getHidePrice($type, $hidePrice);
|
||||
$this->hideDiscount = $this->getHideDiscount($type, $hideDiscount);
|
||||
$this->hideAmount = $this->getHideAmount($type, $hideAmount);
|
||||
|
||||
$this->hideEditItemColumns = $hideEditItemColumns;
|
||||
/** Items Component End */
|
||||
}
|
||||
|
||||
protected function getRoute($type, $document, $parameters = [])
|
||||
{
|
||||
$page = Str::plural($type, 2);
|
||||
|
||||
$route = $page . '.store';
|
||||
|
||||
if ($document) {
|
||||
$parameters = [
|
||||
Str::replaceFirst('-', '_', $type) => $document->id
|
||||
];
|
||||
|
||||
$route = $page . '.update';
|
||||
}
|
||||
|
||||
try {
|
||||
route($route, $parameters);
|
||||
} catch (\Exception $e) {
|
||||
$route = '';
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
|
||||
protected function getContacts($type, $contacts)
|
||||
{
|
||||
if (!empty($contacts)) {
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
$contact_type = $this->getContactType($type, null);
|
||||
|
||||
if ($contact_type) {
|
||||
$contacts = Contact::$contact_type()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
|
||||
} else {
|
||||
$contacts = Contact::enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
|
||||
}
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
protected function getContactType($type, $contact_type)
|
||||
{
|
||||
if (!empty($contact_type)) {
|
||||
return $contact_type;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$contact_type = 'customer';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$contact_type = 'vendor';
|
||||
break;
|
||||
}
|
||||
|
||||
return $contact_type;
|
||||
}
|
||||
|
||||
protected function getIssuedAt($type, $document, $issued_at)
|
||||
{
|
||||
if (!empty($issued_at)) {
|
||||
return $issued_at;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->issued_at;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$issued_at = request()->get('invoiced_at', Date::now()->toDateString());
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$issued_at = request()->get('billed_at', Date::now()->toDateString());
|
||||
break;
|
||||
}
|
||||
|
||||
return $issued_at;
|
||||
}
|
||||
|
||||
protected function getDocumentNumber($type, $document, $document_number)
|
||||
{
|
||||
if (!empty($document_number)) {
|
||||
return $document_number;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->document_number;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$document_number = $this->getNextDocumentNumber(Document::BILL_TYPE);
|
||||
break;
|
||||
}
|
||||
|
||||
return $document_number;
|
||||
}
|
||||
|
||||
protected function getDueAt($type, $document, $due_at)
|
||||
{
|
||||
if (!empty($due_at)) {
|
||||
return $due_at;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->due_at;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays(setting('invoice.payment_terms', 0))->toDateString();
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$due_at = request()->get('billed_at', Date::now()->toDateString());
|
||||
break;
|
||||
}
|
||||
|
||||
return $due_at;
|
||||
}
|
||||
|
||||
protected function getOrderNumber($type, $document, $order_number)
|
||||
{
|
||||
if (!empty($order_number)) {
|
||||
return $order_number;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->order_number;
|
||||
}
|
||||
|
||||
$order_number = null;
|
||||
}
|
||||
|
||||
protected function getTextDocumentNumber($type, $textDocumentNumber)
|
||||
{
|
||||
if (!empty($textDocumentNumber)) {
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textDocumentNumber = 'invoices.invoice_number';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDocumentNumber = 'bills.bill_number';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
protected function getTextOrderNumber($type, $textOrderNumber)
|
||||
{
|
||||
if (!empty($textOrderNumber)) {
|
||||
return $textOrderNumber;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textOrderNumber = 'invoices.order_number';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textOrderNumber = 'bills.order_number';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textOrderNumber;
|
||||
}
|
||||
|
||||
protected function getTextIssuedAt($type, $textIssuedAt)
|
||||
{
|
||||
if (!empty($textIssuedAt)) {
|
||||
return $textIssuedAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textIssuedAt = 'invoices.invoice_date';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textIssuedAt = 'bills.bill_date';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textIssuedAt;
|
||||
}
|
||||
|
||||
protected function getTextDueAt($type, $textDueAt)
|
||||
{
|
||||
if (!empty($textDueAt)) {
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textDueAt = 'invoices.due_date';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDueAt = 'bills.due_date';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
protected function getTextItems($type, $text_items)
|
||||
{
|
||||
if (!empty($text_items)) {
|
||||
return $text_items;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$text_items = setting('invoice.item_name', 'general.items');
|
||||
|
||||
if ($text_items == 'custom') {
|
||||
$text_items = setting('invoice.item_name_input');
|
||||
}
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_items = 'general.items';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_items;
|
||||
}
|
||||
|
||||
protected function getTextQuantity($type, $text_quantity)
|
||||
{
|
||||
if (!empty($text_quantity)) {
|
||||
return $text_quantity;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$text_quantity = setting('invoice.quantity_name', 'invoices.quantity');
|
||||
|
||||
if ($text_quantity == 'custom') {
|
||||
$text_quantity = setting('invoice.quantity_name_input');
|
||||
}
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_quantity = 'bills.quantity';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_quantity;
|
||||
}
|
||||
|
||||
protected function getTextPrice($type, $text_price)
|
||||
{
|
||||
if (!empty($text_price)) {
|
||||
return $text_price;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$text_price = setting('invoice.price_name', 'invoices.price');
|
||||
|
||||
if ($text_price == 'custom') {
|
||||
$text_price = setting('invoice.price_name_input');
|
||||
}
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_price = 'bills.price';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_price;
|
||||
}
|
||||
|
||||
protected function getTextAmount($type, $text_amount)
|
||||
{
|
||||
if (!empty($text_amount)) {
|
||||
return $text_amount;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_amount = 'general.amount';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_amount;
|
||||
}
|
||||
|
||||
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
|
||||
{
|
||||
if (!empty($hideItems)) {
|
||||
return $hideItems;
|
||||
}
|
||||
|
||||
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
|
||||
|
||||
return $hideItems;
|
||||
}
|
||||
|
||||
protected function getHideName($type, $hideName)
|
||||
{
|
||||
if (!empty($hideName)) {
|
||||
return $hideName;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideName = setting('invoice.hide_item_name', $hideName);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideName = setting('bill.hide_item_name', $hideName);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideName;
|
||||
}
|
||||
|
||||
protected function getHideDescription($type, $hideDescription)
|
||||
{
|
||||
if (!empty($hideDescription)) {
|
||||
return $hideDescription;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideDescription = setting('bill.hide_item_description', $hideDescription);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideDescription;
|
||||
}
|
||||
|
||||
protected function getHideQuantity($type, $hideQuantity)
|
||||
{
|
||||
if (!empty($hideQuantity)) {
|
||||
return $hideQuantity;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideQuantity;
|
||||
}
|
||||
|
||||
protected function getHidePrice($type, $hidePrice)
|
||||
{
|
||||
if (!empty($hidePrice)) {
|
||||
return $hidePrice;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hidePrice = setting('invoice.hide_price', $hidePrice);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hidePrice = setting('bill.hide_price', $hidePrice);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hidePrice;
|
||||
}
|
||||
|
||||
protected function getHideDiscount($type, $hideDiscount)
|
||||
{
|
||||
if (!empty($hideDiscount)) {
|
||||
return $hideDiscount;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideDiscount;
|
||||
}
|
||||
|
||||
protected function getHideAmount($type, $hideAmount)
|
||||
{
|
||||
if (!empty($hideAmount)) {
|
||||
return $hideAmount;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideAmount = setting('invoice.hide_amount', $hideAmount);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideAmount = setting('bill.hide_amount', $hideAmount);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideAmount;
|
||||
}
|
||||
}
|
||||
|
@ -2,37 +2,11 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Models\Setting\Category;
|
||||
|
||||
class Advanced extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var bool */
|
||||
public $hideRecurring;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCategory;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAttachment;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type, bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
$this->hideRecurring = $hideRecurring;
|
||||
$this->hideCategory = $hideCategory;
|
||||
$this->hideAttachment = $hideAttachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
|
@ -2,23 +2,10 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class Buttons extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
|
@ -2,41 +2,10 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class Company extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var bool */
|
||||
public $hideLogo;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentSubheading;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyEdit;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->hideLogo = $hideLogo;
|
||||
$this->hideDocumentTitle = $hideDocumentTitle;
|
||||
$this->hideDocumentSubheading = $hideDocumentSubheading;
|
||||
$this->hideCompanyEdit = $hideCompanyEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
@ -50,29 +19,4 @@ class Company extends Component
|
||||
|
||||
return view('components.documents.form.company', compact('company','inputNameType'));
|
||||
}
|
||||
|
||||
protected function getFilterName($column)
|
||||
{
|
||||
if (strpos($column, '_id') !== false) {
|
||||
$column = str_replace('_id', '', $column);
|
||||
} else if (strpos($column, '_code') !== false) {
|
||||
$column = str_replace('_code', '', $column);
|
||||
}
|
||||
|
||||
$plural = Str::plural($column, 2);
|
||||
|
||||
if (trans_choice('general.' . $plural, 1) !== 'general.' . $plural) {
|
||||
return trans_choice('general.' . $plural, 1);
|
||||
} elseif (trans_choice('search_string.columns.' . $plural, 1) !== 'search_string.columns.' . $plural) {
|
||||
return trans_choice('search_string.columns.' . $plural, 1);
|
||||
}
|
||||
|
||||
$name = trans('general.' . $column);
|
||||
|
||||
if ($name == 'general.' . $column) {
|
||||
$name = trans('search_string.columns.' . $column);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
@ -2,152 +2,10 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class Content extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
public $document;
|
||||
|
||||
/** @var string */
|
||||
public $formRoute;
|
||||
|
||||
/** @var string */
|
||||
public $formId;
|
||||
|
||||
/** @var string */
|
||||
public $formSubmit;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompany;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAdvanced;
|
||||
|
||||
/** @var bool */
|
||||
public $hideFooter;
|
||||
|
||||
/** @var bool */
|
||||
public $hideButtons;
|
||||
|
||||
/* Company Component Field Status */
|
||||
/** @var bool */
|
||||
public $hideLogo;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentTitle;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentSubheading;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCompanyEdit;
|
||||
/* Company Component Field Status */
|
||||
|
||||
/* Main.Header Fields */
|
||||
/** @var string */
|
||||
public $contactType;
|
||||
|
||||
/** @var string */
|
||||
public $documentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textIssuedAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDueAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDocumentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textOrderNumber;
|
||||
/* Main.Header Fields */
|
||||
|
||||
/* Main.Header Component Field Status */
|
||||
/** @var bool */
|
||||
public $hideContact;
|
||||
|
||||
/** @var bool */
|
||||
public $hideIssuedAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDueAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideOrderNumber;
|
||||
/* Main.Header Component Field Status */
|
||||
|
||||
/* Advanced Component Field Status */
|
||||
/** @var bool */
|
||||
public $hideRecurring;
|
||||
|
||||
/** @var bool */
|
||||
public $hideCategory;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAttachment;
|
||||
/* Advanced Component Field Status */
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, $document = false, string $formRoute = '', string $formId = 'document', string $formSubmit = 'onSubmit', bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false,
|
||||
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false, // Company
|
||||
string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', // Main.Header
|
||||
string $contactType = '', string $documentNumber = '',
|
||||
bool $hideContact = false, bool $hideIssuedAt = false, bool $hideDocumentNumber = false, bool $hideDueAt = false, bool $hideOrderNumber = false, // Main.Header
|
||||
bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false // Advanced
|
||||
)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->document = $document;
|
||||
$this->formRoute = ($formRoute) ? $formRoute : $this->getRoute($type, $document);
|
||||
$this->formId = $formId;
|
||||
$this->formSubmit = $formSubmit;
|
||||
|
||||
$this->hideCompany = $hideCompany;
|
||||
$this->hideAdvanced = $hideAdvanced;
|
||||
$this->hideFooter = $hideFooter;
|
||||
$this->hideButtons = $hideButtons;
|
||||
|
||||
// Company component fields status
|
||||
$this->hideLogo = $hideLogo;
|
||||
$this->hideDocumentTitle = $hideDocumentTitle;
|
||||
$this->hideDocumentSubheading = $hideDocumentSubheading;
|
||||
$this->hideCompanyEdit = $hideCompanyEdit;
|
||||
|
||||
// Main.Header fields
|
||||
$this->contactType = $contactType;
|
||||
$this->documentNumber = $documentNumber;
|
||||
|
||||
$this->textIssuedAt = $textIssuedAt;
|
||||
$this->textDocumentNumber = $textDocumentNumber;
|
||||
$this->textDueAt = $textDueAt;
|
||||
$this->textOrderNumber = $textOrderNumber;
|
||||
|
||||
// Main.Header component fields status
|
||||
$this->hideContact = $hideContact;
|
||||
$this->hideIssuedAt = $hideIssuedAt;
|
||||
$this->hideDocumentNumber = $hideDocumentNumber;
|
||||
$this->hideDueAt = $hideDueAt;
|
||||
$this->hideOrderNumber = $hideOrderNumber;
|
||||
|
||||
// Advanced component fields status
|
||||
$this->hideRecurring = $hideRecurring;
|
||||
$this->hideCategory = $hideCategory;
|
||||
$this->hideAttachment = $hideAttachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
@ -157,27 +15,4 @@ class Content extends Component
|
||||
{
|
||||
return view('components.documents.form.content');
|
||||
}
|
||||
|
||||
protected function getRoute($type, $document, $parameters = [])
|
||||
{
|
||||
$page = Str::plural($type, 2);
|
||||
|
||||
$route = $page . '.store';
|
||||
|
||||
if ($document) {
|
||||
$parameters = [
|
||||
Str::replaceFirst('-', '_', $type) => $document->id
|
||||
];
|
||||
|
||||
$route = $page . '.update';
|
||||
}
|
||||
|
||||
try {
|
||||
route($route, $parameters);
|
||||
} catch (\Exception $e) {
|
||||
$route = '';
|
||||
}
|
||||
|
||||
return $route;
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,10 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class Footer extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
|
@ -2,85 +2,13 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
class Items extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
public $document;
|
||||
|
||||
/** @var bool */
|
||||
public $hideEditItemColumns;
|
||||
|
||||
/** @var string */
|
||||
public $textItems;
|
||||
|
||||
/** @var string */
|
||||
public $textQuantity;
|
||||
|
||||
/** @var string */
|
||||
public $textPrice;
|
||||
|
||||
/** @var string */
|
||||
public $textAmount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideItems;
|
||||
|
||||
/** @var bool */
|
||||
public $hideName;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDescription;
|
||||
|
||||
/** @var bool */
|
||||
public $hideQuantity;
|
||||
|
||||
/** @var bool */
|
||||
public $hidePrice;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDiscount;
|
||||
|
||||
/** @var bool */
|
||||
public $hideAmount;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, $document = false,
|
||||
string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '',
|
||||
bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false,
|
||||
bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false,
|
||||
bool $hideEditItemColumns = false
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->document = $document;
|
||||
|
||||
$this->textItems = $this->getTextItems($type, $textItems);
|
||||
$this->textQuantity = $this->getTextQuantity($type, $textQuantity);
|
||||
$this->textPrice = $this->getTextPrice($type, $textPrice);
|
||||
$this->textAmount = $this->getTextAmount($type, $textAmount);
|
||||
|
||||
$this->hideItems = $this->getHideItems($type, $hideItems, $hideName, $hideDescription);
|
||||
$this->hideName = $this->getHideName($type, $hideName);
|
||||
$this->hideDescription = $this->getHideDescription($type, $hideDescription);
|
||||
$this->hideQuantity = $this->getHideQuantity($type, $hideQuantity);
|
||||
$this->hidePrice = $this->getHidePrice($type, $hidePrice);
|
||||
$this->hideDiscount = $this->getHideDiscount($type, $hideDiscount);
|
||||
$this->hideAmount = $this->getHideAmount($type, $hideAmount);
|
||||
|
||||
$this->hideEditItemColumns = $hideEditItemColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
@ -94,245 +22,4 @@ class Items extends Component
|
||||
|
||||
return view('components.documents.form.items', compact('currency', 'taxes'));
|
||||
}
|
||||
|
||||
protected function getTextItems($type, $text_items)
|
||||
{
|
||||
if (!empty($text_items)) {
|
||||
return $text_items;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$text_items = setting('invoice.item_name', 'general.items');
|
||||
|
||||
if ($text_items == 'custom') {
|
||||
$text_items = setting('invoice.item_name_input');
|
||||
}
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_items = 'general.items';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_items;
|
||||
}
|
||||
|
||||
protected function getTextQuantity($type, $text_quantity)
|
||||
{
|
||||
if (!empty($text_quantity)) {
|
||||
return $text_quantity;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$text_quantity = setting('invoice.quantity_name', 'invoices.quantity');
|
||||
|
||||
if ($text_quantity == 'custom') {
|
||||
$text_quantity = setting('invoice.quantity_name_input');
|
||||
}
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_quantity = 'bills.quantity';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_quantity;
|
||||
}
|
||||
|
||||
protected function getTextPrice($type, $text_price)
|
||||
{
|
||||
if (!empty($text_price)) {
|
||||
return $text_price;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$text_price = setting('invoice.price_name', 'invoices.price');
|
||||
|
||||
if ($text_price == 'custom') {
|
||||
$text_price = setting('invoice.price_name_input');
|
||||
}
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_price = 'bills.price';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_price;
|
||||
}
|
||||
|
||||
protected function getTextAmount($type, $text_amount)
|
||||
{
|
||||
if (!empty($text_amount)) {
|
||||
return $text_amount;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$text_amount = 'general.amount';
|
||||
break;
|
||||
}
|
||||
|
||||
return $text_amount;
|
||||
}
|
||||
|
||||
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
|
||||
{
|
||||
if (!empty($hideItems)) {
|
||||
return $hideItems;
|
||||
}
|
||||
|
||||
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
|
||||
|
||||
return $hideItems;
|
||||
}
|
||||
|
||||
protected function getHideName($type, $hideName)
|
||||
{
|
||||
if (!empty($hideName)) {
|
||||
return $hideName;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideName = setting('invoice.hide_item_name', $hideName);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideName = setting('bill.hide_item_name', $hideName);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideName;
|
||||
}
|
||||
|
||||
protected function getHideDescription($type, $hideDescription)
|
||||
{
|
||||
if (!empty($hideDescription)) {
|
||||
return $hideDescription;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideDescription = setting('bill.hide_item_description', $hideDescription);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideDescription;
|
||||
}
|
||||
|
||||
protected function getHideQuantity($type, $hideQuantity)
|
||||
{
|
||||
if (!empty($hideQuantity)) {
|
||||
return $hideQuantity;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideQuantity;
|
||||
}
|
||||
|
||||
protected function getHidePrice($type, $hidePrice)
|
||||
{
|
||||
if (!empty($hidePrice)) {
|
||||
return $hidePrice;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hidePrice = setting('invoice.hide_price', $hidePrice);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hidePrice = setting('bill.hide_price', $hidePrice);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hidePrice;
|
||||
}
|
||||
|
||||
protected function getHideDiscount($type, $hideDiscount)
|
||||
{
|
||||
if (!empty($hideDiscount)) {
|
||||
return $hideDiscount;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideDiscount;
|
||||
}
|
||||
|
||||
protected function getHideAmount($type, $hideAmount)
|
||||
{
|
||||
if (!empty($hideAmount)) {
|
||||
return $hideAmount;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$hideAmount = setting('invoice.hide_amount', $hideAmount);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$hideAmount = setting('bill.hide_amount', $hideAmount);
|
||||
break;
|
||||
}
|
||||
|
||||
return $hideAmount;
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,10 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class LineItem extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
|
@ -2,83 +2,10 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class Main extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
public $document;
|
||||
|
||||
/* Main.Header Fields */
|
||||
/** @var string */
|
||||
public $contactType;
|
||||
|
||||
/** @var string */
|
||||
public $documentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textIssuedAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDueAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDocumentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textOrderNumber;
|
||||
/* Main.Header Fields */
|
||||
|
||||
/* Main.Header Component Field Status */
|
||||
/** @var bool */
|
||||
public $hideContact;
|
||||
|
||||
/** @var bool */
|
||||
public $hideIssuedAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDueAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideOrderNumber;
|
||||
/* Main.Header Component Field Status */
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$type, $document = false,
|
||||
string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', // Main.Header
|
||||
string $contactType = '', string $documentNumber = '',
|
||||
bool $hideContact = false, bool $hideIssuedAt = false, bool $hideDocumentNumber = false, bool $hideDueAt = false, bool $hideOrderNumber = false // Main.Header
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->document = $document;
|
||||
|
||||
// Main.Header fields
|
||||
$this->contactType = $contactType;
|
||||
$this->documentNumber = $documentNumber;
|
||||
|
||||
$this->textIssuedAt = $textIssuedAt;
|
||||
$this->textDocumentNumber = $textDocumentNumber;
|
||||
$this->textDueAt = $textDueAt;
|
||||
$this->textOrderNumber = $textOrderNumber;
|
||||
|
||||
// Main.Header component fields status
|
||||
$this->hideContact = $hideContact;
|
||||
$this->hideIssuedAt = $hideIssuedAt;
|
||||
$this->hideDocumentNumber = $hideDocumentNumber;
|
||||
$this->hideDueAt = $hideDueAt;
|
||||
$this->hideOrderNumber = $hideOrderNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
|
@ -2,98 +2,11 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Models\Common\Contact;
|
||||
use App\Models\Document\Document;
|
||||
use App\Traits\Documents;
|
||||
use Date;
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class Metadata extends Component
|
||||
{
|
||||
use Documents;
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
public $document;
|
||||
|
||||
public $contacts;
|
||||
|
||||
/** @var string */
|
||||
public $contactType;
|
||||
|
||||
/** @var bool */
|
||||
public $hideContact;
|
||||
|
||||
/** @var bool */
|
||||
public $hideIssuedAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDocumentNumber;
|
||||
|
||||
/** @var bool */
|
||||
public $hideDueAt;
|
||||
|
||||
/** @var bool */
|
||||
public $hideOrderNumber;
|
||||
|
||||
/** @var string */
|
||||
public $issuedAt;
|
||||
|
||||
/** @var string */
|
||||
public $documentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $dueAt;
|
||||
|
||||
/** @var string */
|
||||
public $orderNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textIssuedAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDueAt;
|
||||
|
||||
/** @var string */
|
||||
public $textDocumentNumber;
|
||||
|
||||
/** @var string */
|
||||
public $textOrderNumber;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $type, $document = false, $contacts = [], string $contactType = '',
|
||||
bool $hideContact = false, bool $hideIssuedAt = false, bool $hideDocumentNumber = false, bool $hideDueAt = false, bool $hideOrderNumber = false,
|
||||
string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '',
|
||||
string $issuedAt = '', string $documentNumber = '', string $dueAt = '', string $orderNumber = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->document = $document;
|
||||
$this->contacts = $this->getContacts($type, $contacts);
|
||||
$this->contactType = $this->getContactType($type, $contactType);
|
||||
|
||||
$this->hideContact = $hideContact;
|
||||
$this->hideIssuedAt = $hideIssuedAt;
|
||||
$this->hideDocumentNumber = $hideDocumentNumber;
|
||||
$this->hideDueAt = $hideDueAt;
|
||||
$this->hideOrderNumber = $hideOrderNumber;
|
||||
$this->issuedAt = $this->getissuedAt($type, $document, $issuedAt);
|
||||
$this->documentNumber = $this->getDocumentNumber($type, $document, $documentNumber);
|
||||
$this->dueAt = $this->getDueAt($type, $document, $dueAt);
|
||||
$this->orderNumber = $this->getOrderNumber($type, $document, $orderNumber);
|
||||
|
||||
$this->textIssuedAt = $this->gettextIssuedAt($type, $textIssuedAt);
|
||||
$this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
|
||||
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
|
||||
$this->textOrderNumber = $this->getTextOrderNumber($type, $textOrderNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
@ -103,222 +16,4 @@ class Metadata extends Component
|
||||
{
|
||||
return view('components.documents.form.metadata');
|
||||
}
|
||||
|
||||
protected function getContacts($type, $contacts)
|
||||
{
|
||||
if (!empty($contacts)) {
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
$contact_type = $this->getContactType($type, null);
|
||||
|
||||
if ($contact_type) {
|
||||
$contacts = Contact::$contact_type()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
|
||||
} else {
|
||||
$contacts = Contact::enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
|
||||
}
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
protected function getContactType($type, $contact_type)
|
||||
{
|
||||
if (!empty($contact_type)) {
|
||||
return $contact_type;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$contact_type = 'customer';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$contact_type = 'vendor';
|
||||
break;
|
||||
}
|
||||
|
||||
return $contact_type;
|
||||
}
|
||||
|
||||
protected function getissuedAt($type, $document, $issued_at)
|
||||
{
|
||||
if (!empty($issued_at)) {
|
||||
return $issued_at;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->issued_at;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$issued_at = request()->get('invoiced_at', Date::now()->toDateString());
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$issued_at = request()->get('billed_at', Date::now()->toDateString());
|
||||
break;
|
||||
}
|
||||
|
||||
return $issued_at;
|
||||
}
|
||||
|
||||
protected function getDocumentNumber($type, $document, $document_number)
|
||||
{
|
||||
if (!empty($document_number)) {
|
||||
return $document_number;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->document_number;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$document_number = $this->getNextDocumentNumber(Document::BILL_TYPE);
|
||||
break;
|
||||
}
|
||||
|
||||
return $document_number;
|
||||
}
|
||||
|
||||
protected function getDueAt($type, $document, $due_at)
|
||||
{
|
||||
if (!empty($due_at)) {
|
||||
return $due_at;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->due_at;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays(setting('invoice.payment_terms', 0))->toDateString();
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$due_at = request()->get('billed_at', Date::now()->toDateString());
|
||||
break;
|
||||
}
|
||||
|
||||
return $due_at;
|
||||
}
|
||||
|
||||
protected function getOrderNumber($type, $document, $order_number)
|
||||
{
|
||||
if (!empty($order_number)) {
|
||||
return $order_number;
|
||||
}
|
||||
|
||||
if ($document) {
|
||||
return $document->order_number;
|
||||
}
|
||||
|
||||
$order_number = null;
|
||||
}
|
||||
|
||||
protected function getTextDocumentNumber($type, $textDocumentNumber)
|
||||
{
|
||||
if (!empty($textDocumentNumber)) {
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textDocumentNumber = 'invoices.invoice_number';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDocumentNumber = 'bills.bill_number';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textDocumentNumber;
|
||||
}
|
||||
|
||||
protected function getTextOrderNumber($type, $textOrderNumber)
|
||||
{
|
||||
if (!empty($textOrderNumber)) {
|
||||
return $textOrderNumber;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textOrderNumber = 'invoices.order_number';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textOrderNumber = 'bills.order_number';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textOrderNumber;
|
||||
}
|
||||
|
||||
protected function gettextIssuedAt($type, $textIssuedAt)
|
||||
{
|
||||
if (!empty($textIssuedAt)) {
|
||||
return $textIssuedAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textIssuedAt = 'invoices.invoice_date';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textIssuedAt = 'bills.bill_date';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textIssuedAt;
|
||||
}
|
||||
|
||||
protected function getTextDueAt($type, $textDueAt)
|
||||
{
|
||||
if (!empty($textDueAt)) {
|
||||
return $textDueAt;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'sale':
|
||||
case 'income':
|
||||
case 'invoice':
|
||||
$textDueAt = 'invoices.due_date';
|
||||
break;
|
||||
case 'bill':
|
||||
case 'expense':
|
||||
case 'purchase':
|
||||
$textDueAt = 'bills.due_date';
|
||||
break;
|
||||
}
|
||||
|
||||
return $textDueAt;
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,10 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
|
||||
class Note extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
|
@ -2,24 +2,11 @@
|
||||
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Models\Setting\Currency;
|
||||
|
||||
class Totals extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
|
@ -45,6 +45,16 @@
|
||||
text-due-at="{{ $textDueAt }}"
|
||||
hide-order-number="{{ $hideOrderNumber }}"
|
||||
text-order-number="{{ $textOrderNumber }}"
|
||||
hide-edit-item-columns="{{ $hideEditItemColumns }}"
|
||||
hide-items="{{ $hideItems }}"
|
||||
text-items="{{ $textItems }}"
|
||||
hide-quantity="{{ $hideQuantity }}"
|
||||
text-quantity="{{ $textQuantity }}"
|
||||
hide-price="{{ $hidePrice }}"
|
||||
text-price="{{ $textPrice }}"
|
||||
hide-discount="{{ $hideDiscount }}"
|
||||
hide-amount="{{ $hideAmount }}"
|
||||
text-amount="{{ $textAmount }}"
|
||||
/>
|
||||
|
||||
@if (!$hideFooter)
|
||||
|
@ -24,7 +24,9 @@
|
||||
|
||||
@if (!$hideItems)
|
||||
@stack('name_th_start')
|
||||
<th class="text-left border-top-0 border-right-0 border-bottom-0">{{ (trans_choice($textItems, 2) != $textItems) ? trans_choice($textItems, 2) : trans($textItems) }}</th>
|
||||
<th class="text-left border-top-0 border-right-0 border-bottom-0">
|
||||
{{ (trans_choice($textItems, 2) != $textItems) ? trans_choice($textItems, 2) : trans($textItems) }}
|
||||
</th>
|
||||
@stack('name_th_end')
|
||||
|
||||
@stack('move_th_start')
|
||||
@ -34,27 +36,35 @@
|
||||
|
||||
@stack('quantity_th_start')
|
||||
@if (!$hideQuantity)
|
||||
<th class="text-center border-top-0 border-right-0 border-bottom-0" style="padding-right: 5px;">{{ trans($textQuantity) }}</th>
|
||||
<th class="text-center border-top-0 border-right-0 border-bottom-0" style="padding-right: 5px;">
|
||||
{{ trans($textQuantity) }}
|
||||
</th>
|
||||
@endif
|
||||
@stack('quantity_th_end')
|
||||
|
||||
@stack('price_th_start')
|
||||
@if (!$hidePrice)
|
||||
<th class="text-right border-top-0 border-right-0 border-bottom-0" style="padding-left: 5px;">{{ trans($textPrice) }}</th>
|
||||
<th class="text-right border-top-0 border-right-0 border-bottom-0" style="padding-left: 5px;">
|
||||
{{ trans($textPrice) }}
|
||||
</th>
|
||||
@endif
|
||||
@stack('price_th_end')
|
||||
|
||||
@if (!$hideDiscount)
|
||||
@if (in_array(setting('localisation.discount_location', 'total'), ['item', 'both']))
|
||||
@stack('discount_th_start')
|
||||
<th class="text-right border-top-0 border-right-0 border-bottom-0">{{ trans('invoices.discount') }}</th>
|
||||
<th class="text-right border-top-0 border-right-0 border-bottom-0">
|
||||
{{ trans('invoices.discount') }}
|
||||
</th>
|
||||
@stack('discount_th_end')
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@stack('total_th_start')
|
||||
@if (!$hideAmount)
|
||||
<th class="text-right border-top-0 border-bottom-0 item-total">{{ trans($textAmount) }}</th>
|
||||
<th class="text-right border-top-0 border-bottom-0 item-total">
|
||||
{{ trans($textAmount) }}
|
||||
</th>
|
||||
@endif
|
||||
@stack('total_th_end')
|
||||
|
||||
|
@ -18,6 +18,16 @@
|
||||
<x-documents.form.items
|
||||
type="{{ $type }}"
|
||||
:document="$document"
|
||||
hide-edit-item-columns="{{ $hideEditItemColumns }}"
|
||||
hide-items="{{ $hideItems }}"
|
||||
text-items="{{ $textItems }}"
|
||||
hide-quantity="{{ $hideQuantity }}"
|
||||
text-quantity="{{ $textQuantity }}"
|
||||
hide-price="{{ $hidePrice }}"
|
||||
text-price="{{ $textPrice }}"
|
||||
hide-discount="{{ $hideDiscount }}"
|
||||
hide-amount="{{ $hideAmount }}"
|
||||
text-amount="{{ $textAmount }}"
|
||||
/>
|
||||
|
||||
<x-documents.form.totals
|
||||
|
@ -1,6 +1,4 @@
|
||||
<akaunting-edit-item-columns
|
||||
placeholder="{{ (!empty($filters)) ? trans('general.placeholder.search_and_filter') : trans('general.search_placeholder')}}"
|
||||
search-text="{{ trans('general.search_text') }}"
|
||||
:edit-column="{{ json_encode([
|
||||
'status' => true,
|
||||
'text' => trans('general.add_new'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user