mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add invoice product to datatable
This commit is contained in:
parent
c6dd901203
commit
c39f57fcb5
@ -149,6 +149,10 @@ class ProductController extends BaseController
|
|||||||
$message = $productPublicId ? trans('texts.updated_product') : trans('texts.created_product');
|
$message = $productPublicId ? trans('texts.updated_product') : trans('texts.created_product');
|
||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
|
||||||
|
if (in_array(request('action'), ['archive', 'delete', 'restore', 'invoice'])) {
|
||||||
|
return self::bulk();
|
||||||
|
}
|
||||||
|
|
||||||
return Redirect::to("products/{$product->public_id}/edit");
|
return Redirect::to("products/{$product->public_id}/edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,6 +166,7 @@ class ProductController extends BaseController
|
|||||||
|
|
||||||
if ($action == 'invoice') {
|
if ($action == 'invoice') {
|
||||||
$products = Product::scope($ids)->get();
|
$products = Product::scope($ids)->get();
|
||||||
|
$data = [];
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
$data[] = $product->product_key;
|
$data[] = $product->product_key;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,15 @@ class ProductDatatable extends EntityDatatable
|
|||||||
return URL::to("products/{$model->public_id}/edit");
|
return URL::to("products/{$model->public_id}/edit");
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
trans('texts.invoice_product'),
|
||||||
|
function ($model) {
|
||||||
|
return "javascript:submitForm_product('invoice', {$model->public_id})";
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return (! $model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
|
},
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Ninja\Presenters;
|
namespace App\Ninja\Presenters;
|
||||||
|
|
||||||
|
use DropdownButton;
|
||||||
use App\Libraries\Skype\HeroCard;
|
use App\Libraries\Skype\HeroCard;
|
||||||
|
|
||||||
class ProductPresenter extends EntityPresenter
|
class ProductPresenter extends EntityPresenter
|
||||||
@ -22,4 +23,25 @@ class ProductPresenter extends EntityPresenter
|
|||||||
|
|
||||||
return $card;
|
return $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function moreActions()
|
||||||
|
{
|
||||||
|
$product = $this->entity;
|
||||||
|
|
||||||
|
if (! $product->trashed()) {
|
||||||
|
if (auth()->user()->can('create', ENTITY_INVOICE)) {
|
||||||
|
$actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans('texts.invoice_product')];
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2518,6 +2518,7 @@ $LANG = array(
|
|||||||
'enabled_two_factor' => 'Successfully enabled Two-Factor Authentication',
|
'enabled_two_factor' => 'Successfully enabled Two-Factor Authentication',
|
||||||
'add_product' => 'Add Product',
|
'add_product' => 'Add Product',
|
||||||
'email_will_be_sent_on' => 'Note: the email will be sent on :date.',
|
'email_will_be_sent_on' => 'Note: the email will be sent on :date.',
|
||||||
|
'invoice_product' => 'Invoice Product',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6,7 +6,17 @@
|
|||||||
{!! Former::open($url)
|
{!! Former::open($url)
|
||||||
->method($method)
|
->method($method)
|
||||||
->rules(['product_key' => 'required|max:255'])
|
->rules(['product_key' => 'required|max:255'])
|
||||||
->addClass('col-md-10 col-md-offset-1 warn-on-exit') !!}
|
->addClass('col-md-10 col-md-offset-1 main-form warn-on-exit') !!}
|
||||||
|
|
||||||
|
@if ($product)
|
||||||
|
{{ Former::populate($product) }}
|
||||||
|
{{ Former::populateField('cost', Utils::roundSignificant($product->cost)) }}
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<span style="display:none">
|
||||||
|
{!! Former::text('public_id') !!}
|
||||||
|
{!! Former::text('action') !!}
|
||||||
|
</span>
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
@ -14,11 +24,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body form-padding-right">
|
<div class="panel-body form-padding-right">
|
||||||
|
|
||||||
@if ($product)
|
|
||||||
{{ Former::populate($product) }}
|
|
||||||
{{ Former::populateField('cost', Utils::roundSignificant($product->cost)) }}
|
|
||||||
@endif
|
|
||||||
|
|
||||||
{!! Former::text('product_key')->label('texts.product') !!}
|
{!! Former::text('product_key')->label('texts.product') !!}
|
||||||
{!! Former::textarea('notes')->rows(6) !!}
|
{!! Former::textarea('notes')->rows(6) !!}
|
||||||
|
|
||||||
@ -43,15 +48,32 @@
|
|||||||
<center class="buttons">
|
<center class="buttons">
|
||||||
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(HTMLUtils::previousUrl('/products'))->appendIcon(Icon::create('remove-circle')) !!}
|
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(HTMLUtils::previousUrl('/products'))->appendIcon(Icon::create('remove-circle')) !!}
|
||||||
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
|
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
|
||||||
|
@if ($product)
|
||||||
|
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||||
|
->withContents($product->present()->moreActions())
|
||||||
|
->large()
|
||||||
|
->dropup() !!}
|
||||||
|
@endif
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
{!! Former::close() !!}
|
{!! Former::close() !!}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$('#product_key').focus();
|
$('#product_key').focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function submitAction(action) {
|
||||||
|
$('#action').val(action);
|
||||||
|
$('.main-form').submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDeleteClick() {
|
||||||
|
sweetConfirm(function() {
|
||||||
|
submitAction('delete');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user