invoiceninja/app/Ninja/Presenters/ProductPresenter.php

54 lines
1.6 KiB
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Ninja\Presenters;
2016-08-10 17:04:17 +03:00
2017-11-03 11:25:14 +02:00
use DropdownButton;
2016-08-10 17:04:17 +03:00
use App\Libraries\Skype\HeroCard;
class ProductPresenter extends EntityPresenter
{
2016-12-15 15:28:24 +02:00
public function user()
{
return $this->entity->user->getDisplayName();
}
2016-08-10 17:04:17 +03:00
public function skypeBot($account)
{
$product = $this->entity;
$card = new HeroCard();
$card->setTitle($product->product_key);
$card->setSubitle($account->formatMoney($product->cost));
$card->setText($product->notes);
return $card;
}
2017-11-03 11:25:14 +02:00
public function moreActions()
{
$product = $this->entity;
2018-03-18 11:09:24 +02:00
$actions = [];
2017-11-03 11:25:14 +02:00
if (! $product->trashed()) {
2018-03-18 11:09:24 +02:00
if (auth()->user()->can('create', ENTITY_PRODUCT)) {
$actions[] = ['url' => 'javascript:submitAction("clone")', 'label' => trans('texts.clone_product')];
}
2017-11-03 11:25:14 +02:00
if (auth()->user()->can('create', ENTITY_INVOICE)) {
$actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans('texts.invoice_product')];
2018-03-18 11:09:24 +02:00
}
if (count($actions)) {
2017-11-03 11:25:14 +02:00
$actions[] = DropdownButton::DIVIDER;
}
$actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans("texts.archive_product")];
} else {
$actions[] = ['url' => 'javascript:submitAction("restore")', 'label' => trans("texts.restore_product")];
}
if (! $product->is_deleted) {
$actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans("texts.delete_product")];
}
return $actions;
}
2016-08-10 17:04:17 +03:00
}