1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/app/controllers/PaymentController.php

60 lines
1.6 KiB
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
<?php
class PaymentController extends \BaseController
{
public function index()
{
return View::make('payments.index');
}
2013-11-29 13:09:21 +01:00
public function getDatatable($clientId = null)
2013-11-26 13:45:07 +01:00
{
2013-11-29 13:09:21 +01:00
$collection = Payment::with('invoice.client')->where('account_id', '=', Auth::user()->account_id);
if ($clientId) {
$collection->where('client_id','=',$clientId);
}
$table = Datatable::collection($collection->get());
if (!$clientId) {
$table->addColumn('client', function($model)
2013-11-26 13:45:07 +01:00
{
return link_to('clients/' . $model->invoice->client->id, $model->invoice->client->name);
2013-11-29 13:09:21 +01:00
});
}
return $table->addColumn('invoice', function($model)
2013-11-26 13:45:07 +01:00
{
return link_to('invoices/' . $model->invoice->id . '/edit', $model->invoice->number);
})
->addColumn('amount', function($model)
{
return '$' . $model->amount;
})
->addColumn('date', function($model)
{
return $model->created_at->format('m/d/y h:i a');
})
->orderColumns('client')
->make();
}
2013-12-01 21:58:25 +01:00
public function archive($id)
{
$payment = Payment::find($id);
$payment->delete();
Session::flash('message', 'Successfully archived payment');
return Redirect::to('payments');
}
public function delete($id)
{
$payment = Payment::find($id);
$payment->forceDelete();
Session::flash('message', 'Successfully deleted payment');
return Redirect::to('payments');
}
2013-11-26 13:45:07 +01:00
}