mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 21:52:35 +01:00
b233aa0744
Conflicts: .travis.yml CONTRIBUTING.md README.md app/Http/Controllers/AccountController.php app/Http/Controllers/AppController.php app/Http/Controllers/BaseAPIController.php app/Http/Controllers/CreditController.php app/Http/Controllers/DashboardController.php app/Http/Controllers/DocumentController.php app/Http/Controllers/PaymentController.php app/Http/Controllers/QuoteApiController.php app/Http/Requests/EntityRequest.php app/Http/routes.php app/Listeners/AnalyticsListener.php app/Models/Account.php app/Models/Credit.php app/Models/Document.php app/Models/EntityModel.php app/Models/Expense.php app/Models/Invoice.php app/Models/Task.php app/Models/VendorContact.php app/Ninja/Notifications/PushFactory.php app/Ninja/Repositories/DocumentRepository.php app/Ninja/Repositories/ExpenseRepository.php app/Ninja/Repositories/InvoiceRepository.php app/Services/PushService.php composer.json composer.lock database/migrations/2014_05_17_175626_add_quotes.php database/seeds/UserTableSeeder.php resources/lang/en/texts.php resources/views/accounts/customize_design.blade.php resources/views/accounts/invoice_design.blade.php resources/views/accounts/management.blade.php resources/views/expenses/edit.blade.php resources/views/header.blade.php resources/views/invoices/edit.blade.php resources/views/master.blade.php resources/views/payments/payment.blade.php resources/views/users/edit.blade.php
115 lines
3.0 KiB
PHP
115 lines
3.0 KiB
PHP
<?php namespace App\Http\Controllers;
|
|
|
|
use Input;
|
|
use Redirect;
|
|
use Session;
|
|
use URL;
|
|
use Utils;
|
|
use View;
|
|
use App\Models\Client;
|
|
use App\Services\CreditService;
|
|
use App\Ninja\Repositories\CreditRepository;
|
|
use App\Http\Requests\CreateCreditRequest;
|
|
use App\Http\Requests\CreditRequest;
|
|
|
|
class CreditController extends BaseController
|
|
{
|
|
protected $creditRepo;
|
|
protected $creditService;
|
|
protected $entityType = ENTITY_CREDIT;
|
|
|
|
public function __construct(CreditRepository $creditRepo, CreditService $creditService)
|
|
{
|
|
// parent::__construct();
|
|
|
|
$this->creditRepo = $creditRepo;
|
|
$this->creditService = $creditService;
|
|
}
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function index()
|
|
{
|
|
return View::make('list', [
|
|
'entityType' => ENTITY_CREDIT,
|
|
'title' => trans('texts.credits'),
|
|
'sortCol' => '4',
|
|
'columns' => Utils::trans([
|
|
'checkbox',
|
|
'client',
|
|
'credit_amount',
|
|
'credit_balance',
|
|
'credit_date',
|
|
'private_notes',
|
|
''
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public function getDatatable($clientPublicId = null)
|
|
{
|
|
return $this->creditService->getDatatable($clientPublicId, Input::get('sSearch'));
|
|
}
|
|
|
|
public function create(CreditRequest $request)
|
|
{
|
|
$data = [
|
|
'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
|
|
'credit' => null,
|
|
'method' => 'POST',
|
|
'url' => 'credits',
|
|
'title' => trans('texts.new_credit'),
|
|
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
|
|
];
|
|
|
|
return View::make('credits.edit', $data);
|
|
}
|
|
|
|
/*
|
|
public function edit($publicId)
|
|
{
|
|
$credit = Credit::scope($publicId)->firstOrFail();
|
|
|
|
$this->authorize('edit', $credit);
|
|
|
|
$credit->credit_date = Utils::fromSqlDate($credit->credit_date);
|
|
|
|
$data = array(
|
|
'client' => null,
|
|
'credit' => $credit,
|
|
'method' => 'PUT',
|
|
'url' => 'credits/'.$publicId,
|
|
'title' => 'Edit Credit',
|
|
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
|
|
|
return View::make('credit.edit', $data);
|
|
}
|
|
*/
|
|
|
|
public function store(CreateCreditRequest $request)
|
|
{
|
|
$credit = $this->creditRepo->save($request->input());
|
|
|
|
Session::flash('message', trans('texts.created_credit'));
|
|
|
|
return redirect()->to($credit->client->getRoute());
|
|
}
|
|
|
|
public function bulk()
|
|
{
|
|
$action = Input::get('action');
|
|
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
|
|
$count = $this->creditService->bulk($ids, $action);
|
|
|
|
if ($count > 0) {
|
|
$message = Utils::pluralize($action.'d_credit', $count);
|
|
Session::flash('message', $message);
|
|
}
|
|
|
|
return Redirect::to('credits');
|
|
}
|
|
}
|