mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-09 15:24:35 -04:00
Support bulk mark paid
This commit is contained in:
parent
9201004f33
commit
16dba695b1
@ -142,6 +142,7 @@ class InvoiceController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$invoice->is_recurring && $invoice->balance > 0 && $invoice->is_public) {
|
if (!$invoice->is_recurring && $invoice->balance > 0 && $invoice->is_public) {
|
||||||
|
$actions[] = ['url' => 'javascript:submitBulkAction("markPaid")', 'label' => trans('texts.mark_paid')];
|
||||||
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
|
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +512,13 @@ class InvoiceController extends BaseController
|
|||||||
$count = $this->invoiceService->bulk($ids, $action);
|
$count = $this->invoiceService->bulk($ids, $action);
|
||||||
|
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
$key = $action == 'markSent' ? "updated_{$entityType}" : "{$action}d_{$entityType}";
|
if ($action == 'markSent') {
|
||||||
|
$key = 'marked_sent_invoice';
|
||||||
|
} elseif ($action == 'markPaid') {
|
||||||
|
$key = 'created_payment';
|
||||||
|
} else {
|
||||||
|
$key = "{$action}d_{$entityType}";
|
||||||
|
}
|
||||||
$message = Utils::pluralize($key, $count);
|
$message = Utils::pluralize($key, $count);
|
||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,20 @@ class EntityDatatable
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bulkActions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'label' => mtrans($this->entityType, 'archive_'.$this->entityType),
|
||||||
|
'url' => 'javascript:submitForm_'.$this->entityType.'("archive")',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => mtrans($this->entityType, 'delete_'.$this->entityType),
|
||||||
|
'url' => 'javascript:submitForm_'.$this->entityType.'("delete")',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function columnFields()
|
public function columnFields()
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
@ -117,6 +117,15 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
return $model->invoice_status_id < INVOICE_STATUS_SENT && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
return $model->invoice_status_id < INVOICE_STATUS_SENT && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
trans('texts.mark_paid'),
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return "javascript:submitForm_{$entityType}('markPaid', {$model->public_id})";
|
||||||
|
},
|
||||||
|
function ($model) {
|
||||||
|
return $model->balance > 0 && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
|
}
|
||||||
|
],
|
||||||
[
|
[
|
||||||
trans('texts.enter_payment'),
|
trans('texts.enter_payment'),
|
||||||
function ($model) {
|
function ($model) {
|
||||||
@ -190,4 +199,25 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bulkActions()
|
||||||
|
{
|
||||||
|
$actions = parent::bulkActions();
|
||||||
|
|
||||||
|
if ($this->entityType == ENTITY_INVOICE || $this->entityType == ENTITY_QUOTE) {
|
||||||
|
$actions[] = [
|
||||||
|
'label' => mtrans($this->entityType, 'mark_sent'),
|
||||||
|
'url' => 'javascript:submitForm_'.$this->entityType.'("markSent")',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->entityType == ENTITY_INVOICE) {
|
||||||
|
$actions[] = [
|
||||||
|
'label' => mtrans($this->entityType, 'mark_paid'),
|
||||||
|
'url' => 'javascript:submitForm_'.$this->entityType.'("markPaid")',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $actions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,11 @@ class InvoiceRepository extends BaseRepository
|
|||||||
return 'App\Models\Invoice';
|
return 'App\Models\Invoice';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(PaymentService $paymentService, DocumentRepository $documentRepo)
|
public function __construct(PaymentService $paymentService, DocumentRepository $documentRepo, PaymentRepository $paymentRepo)
|
||||||
{
|
{
|
||||||
$this->documentRepo = $documentRepo;
|
$this->documentRepo = $documentRepo;
|
||||||
$this->paymentService = $paymentService;
|
$this->paymentService = $paymentService;
|
||||||
|
$this->paymentRepo = $paymentRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function all()
|
public function all()
|
||||||
@ -753,6 +754,26 @@ class InvoiceRepository extends BaseRepository
|
|||||||
|
|
||||||
$invoice->is_public = true;
|
$invoice->is_public = true;
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
|
$invoice->markInvitationsSent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Invoice $invoice
|
||||||
|
*/
|
||||||
|
public function markPaid(Invoice $invoice)
|
||||||
|
{
|
||||||
|
if (floatval($invoice->balance) <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'client_id' => $invoice->client_id,
|
||||||
|
'invoice_id' => $invoice->id,
|
||||||
|
'amount' => $invoice->balance,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->paymentRepo->save($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2269,7 +2269,9 @@ $LANG = array(
|
|||||||
'user_guide' => 'User Guide',
|
'user_guide' => 'User Guide',
|
||||||
'promo_message' => 'Upgrade before :expires and get :amount% OFF your first year of our Pro or Enterprise packages.',
|
'promo_message' => 'Upgrade before :expires and get :amount% OFF your first year of our Pro or Enterprise packages.',
|
||||||
'discount_message' => ':amount% off expires :expires',
|
'discount_message' => ':amount% off expires :expires',
|
||||||
|
'mark_paid' => 'Mark Paid',
|
||||||
|
'marked_sent_invoice' => 'Successfully marked invoice sent',
|
||||||
|
'marked_sent_invoices' => 'Successfully marked invoices sent',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
@endif
|
@endif
|
||||||
@endcan
|
@endcan
|
||||||
|
|
||||||
{!! DropdownButton::normal(trans('texts.archive'))->withContents([
|
{!! DropdownButton::normal(trans('texts.archive'))
|
||||||
['label' => mtrans($entityType, 'archive_'.$entityType), 'url' => 'javascript:submitForm_'.$entityType.'("archive")'],
|
->withContents($datatable->bulkActions())
|
||||||
['label' => mtrans($entityType, 'delete_'.$entityType), 'url' => 'javascript:submitForm_'.$entityType.'("delete")'],
|
->withAttributes(['class'=>'archive'])
|
||||||
])->withAttributes(['class'=>'archive'])->split() !!}
|
->split() !!}
|
||||||
|
|
||||||
|
|
||||||
<span id="statusWrapper_{{ $entityType }}" style="display:none">
|
<span id="statusWrapper_{{ $entityType }}" style="display:none">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user