1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-23 18:01:35 +02:00
invoiceninja/app/controllers/PaymentController.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
<?php
class PaymentController extends \BaseController
{
public function index()
{
2013-12-03 23:00:01 +01:00
return View::make('list', array(
'entityType'=>ENTITY_PAYMENT,
'title' => '- Payments',
'columns'=>['checkbox', 'Transaction Reference', 'Client', 'Amount', 'Payment Date']
));
2013-11-26 13:45:07 +01:00
}
2013-11-29 13:09:21 +01:00
public function getDatatable($clientId = null)
2013-11-26 13:45:07 +01:00
{
2013-12-03 18:32:33 +01:00
$collection = Payment::scope()->with('invoice.client');
2013-11-29 13:09:21 +01:00
if ($clientId) {
$collection->where('client_id','=',$clientId);
}
$table = Datatable::collection($collection->get());
if (!$clientId) {
2013-12-03 23:00:01 +01:00
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->id . '">'; });
2013-11-29 13:09:21 +01:00
}
2013-12-03 23:00:01 +01:00
$table->addColumn('transaction_reference', function($model) { return $model->transaction_reference; });
if (!$clientId) {
$table->addColumn('client', function($model) { return link_to('clients/' . $model->client->id, $model->client->name); });
}
return $table->addColumn('amount', function($model) { return '$' . $model->amount; })
->addColumn('date', function($model) { return timestampToDateTimeString($model->created_at); })
2013-11-26 13:45:07 +01:00
->orderColumns('client')
->make();
}
2013-12-01 21:58:25 +01:00
public function archive($id)
{
2013-12-03 18:32:33 +01:00
$payment = Payment::scope()->findOrFail($id);
2013-12-01 21:58:25 +01:00
$payment->delete();
Session::flash('message', 'Successfully archived payment');
return Redirect::to('payments');
}
public function delete($id)
{
2013-12-03 18:32:33 +01:00
$payment = Payment::scope()->findOrFail($id);
2013-12-01 21:58:25 +01:00
$payment->forceDelete();
Session::flash('message', 'Successfully deleted payment');
return Redirect::to('payments');
}
2013-11-26 13:45:07 +01:00
}