Browse Source

Add project invoices list and relation

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
da2204f8ff
  1. 6
      app/Entities/Projects/Project.php
  2. 15
      app/Http/Controllers/Projects/InvoicesController.php
  3. 1
      resources/lang/id/project.php
  4. 58
      resources/views/projects/invoices.blade.php
  5. 3
      resources/views/projects/partials/nav-tabs.blade.php
  6. 2
      resources/views/projects/payments.blade.php
  7. 4
      resources/views/projects/subscriptions.blade.php
  8. 5
      routes/web/projects.php

6
app/Entities/Projects/Project.php

@ -2,6 +2,7 @@
namespace App\Entities\Projects;
use App\Entities\Invoices\Invoice;
use App\Entities\Payments\Payment;
use App\Entities\Projects\ProjectPresenter;
use App\Entities\Projects\Task;
@ -43,6 +44,11 @@ class Project extends Model {
return $this->hasMany(Subscription::class);
}
public function invoices()
{
return $this->hasMany(Invoice::class);
}
public function payments()
{
return $this->hasMany(Payment::class)->orderBy('date','desc');

15
app/Http/Controllers/Projects/InvoicesController.php

@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers\Projects;
use App\Entities\Projects\Project;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class InvoicesController extends Controller
{
public function index(Project $project)
{
return view('projects.invoices', compact('project'));
}
}

1
resources/lang/id/project.php

@ -37,6 +37,7 @@ return [
'files' => 'List Dokumen',
'features' => 'Daftar Item Pekerjaan',
'cost_proposal' => 'Pengajuan Biaya',
'invoices' => 'List Invoice',
// Actions
'features_export_html' => 'Export HTML',

58
resources/views/projects/invoices.blade.php

@ -0,0 +1,58 @@
@extends('layouts.app')
@section('title', trans('project.invoices') . ' | ' . $project->name)
@section('content')
@include('projects.partials.breadcrumb', ['title' => trans('project.invoices')])
<h1 class="page-header">
<div class="pull-right">
{!! html_link_to_route('invoices.create', trans('invoice.create'), ['project_id' => $project->id], ['class' => 'btn btn-success','icon' => 'plus']) !!}
</div>
{{ $project->name }} <small>{{ trans('project.invoices') }}</small>
</h1>
@include('projects.partials.nav-tabs')
<div class="row">
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ trans('project.invoices') }}</h3></div>
<table class="table table-condensed">
<thead>
<th>{{ trans('app.table_no') }}</th>
<th class="col-md-2 text-center">{{ trans('invoice.number') }}</th>
<th class="col-md-2 text-center">{{ trans('app.date') }}</th>
<th class="col-md-2">{{ trans('invoice.customer') }}</th>
<th class="col-md-2 text-right">{{ trans('invoice.amount') }}</th>
<th>{{ trans('app.action') }}</th>
</thead>
<tbody>
@forelse($project->invoices as $key => $invoice)
<tr>
<td>{{ 1 + $key }}</td>
<td class="text-center">{{ $invoice->number }}</td>
<td class="text-center">{{ $invoice->created_at->format('Y-m-d') }}</td>
<td>{{ $project->customer->name }}</td>
<td class="text-right">{{ formatRp($invoice->amount) }}</td>
<td>
{!! html_link_to_route('invoices.show', '', [$invoice->number], ['class' => 'btn btn-info btn-xs','icon' => 'search','title' => 'Lihat ' . trans('invoice.show')]) !!}
{!! html_link_to_route('invoices.pdf', '', [$invoice->number], ['class' => 'btn btn-default btn-xs','icon' => 'print','title' => trans('invoice.print'), 'target' => '_blank']) !!}
</td>
</tr>
@empty
<tr><td colspan="6">{{ trans('invoice.empty') }}</td></tr>
@endforelse
</tbody>
<tfoot>
<tr>
<th colspan="4" class="text-right">{{ trans('app.total') }}</th>
<th class="text-right">{{ formatRp($project->invoices->sum('amount')) }}</th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
@endsection

3
resources/views/projects/partials/nav-tabs.blade.php

@ -12,6 +12,9 @@
<li class="{{ Request::segment(3) == 'subscriptions' ? 'active' : '' }}">
{!! link_to_route('projects.subscriptions', trans('project.subscriptions'), [$project->id]) !!}
</li>
<li class="{{ Request::segment(3) == 'invoices' ? 'active' : '' }}">
{!! link_to_route('projects.invoices', trans('project.invoices') . ' (' . $project->invoices->count() . ')', [$project->id]) !!}
</li>
<li class="{{ Request::segment(3) == 'files' ? 'active' : '' }}">
{!! link_to_route('projects.files', trans('project.files') . ' (' . $project->files->count() . ')', [$project->id]) !!}
</li>

2
resources/views/projects/payments.blade.php

@ -7,7 +7,7 @@
<h1 class="page-header">
<div class="pull-right">
{!! html_link_to_route('payments.create', trans('payment.create'), ['project_id' => $project->id,'customer_id' => $project->customer_id], ['class' => 'btn btn-primary','icon' => 'plus']) !!}
{!! html_link_to_route('payments.create', trans('payment.create'), ['project_id' => $project->id,'customer_id' => $project->customer_id], ['class' => 'btn btn-success','icon' => 'plus']) !!}
</div>
{{ $project->name }} <small>{{ trans('project.payments') }}</small>
</h1>

4
resources/views/projects/subscriptions.blade.php

@ -7,7 +7,9 @@
@include('projects.partials.breadcrumb',['title' => trans('project.subscriptions')])
<h1 class="page-header">
{!! link_to_route('subscriptions.create', trans('subscription.create'), ['project_id' => $project->id, 'customer_id' => $project->customer_id], ['class'=>'btn btn-success pull-right']) !!}
<div class="pull-right">
{!! link_to_route('subscriptions.create', trans('subscription.create'), ['project_id' => $project->id, 'customer_id' => $project->customer_id], ['class'=>'btn btn-success']) !!}
</div>
{{ $project->name }} <small>{{ trans('project.subscriptions') }}</small>
</h1>

5
routes/web/projects.php

@ -14,6 +14,11 @@ Route::group(['middleware' => ['web','role:admin'], 'namespace' => 'Projects'],
Route::resource('projects','ProjectsController');
/**
* Project Invoices Routes
*/
Route::get('projects/{project}/invoices', ['as'=>'projects.invoices', 'uses'=>'InvoicesController@index']);
/**
* Features Routes
*/
Route::get('projects/{id}/features/create', ['as'=>'features.create', 'uses'=>'FeaturesController@create']);

Loading…
Cancel
Save