Browse Source

Add project features export in html format

pull/1/head
Nafies Luthfi 9 years ago
parent
commit
5098956670
  1. 2
      app/Entities/Projects/FeaturesRepository.php
  2. 20
      app/Http/Controllers/Projects/ProjectsController.php
  3. 2
      app/Http/Requests/Features/CreateRequest.php
  4. 2
      app/Http/routes/projects.php
  5. 3
      resources/lang/id/project.php
  6. 8
      resources/views/features/partials/feature-tasks.blade.php
  7. 2
      resources/views/projects/features-export-excel.blade.php
  8. 69
      resources/views/projects/features-export-html.blade.php
  9. 13
      resources/views/projects/features.blade.php
  10. 5
      resources/views/projects/partials/nav-tabs.blade.php

2
app/Entities/Projects/FeaturesRepository.php

@ -26,7 +26,7 @@ class FeaturesRepository extends BaseRepository
->whereHas('project', function($query) {
return $query->whereIn('status_id', [2,3]);
})
->with(['tasks','project','worker'])
->with(['tasks','project'])
->get();
}

20
app/Http/Controllers/Projects/ProjectsController.php

@ -91,20 +91,20 @@ class ProjectsController extends Controller {
return view('projects.features', compact('project','features'));
}
public function featuresExport($projectId)
public function featuresExport($projectId, $type = 'excel')
{
$project = $this->repo->requireById($projectId);
$features = $this->repo->getProjectFeatures($projectId);
// return view('projects.features-export', compact('project','features'));
\Excel::create(str_slug(trans('project.features') . '-' . $project->name), function($excel) use ($project, $features) {
$excel->sheet('testng', function($sheet) use ($project, $features) {
$sheet->loadView('projects.features-export',compact('project','features'));
});
})->download('xlsx');
if ($type == 'excel') {
\Excel::create(str_slug(trans('project.features') . '-' . $project->name), function($excel) use ($project, $features) {
$excel->sheet('testng', function($sheet) use ($project, $features) {
$sheet->loadView('projects.features-export-excel',compact('project','features'));
});
})->download('xlsx');
} else {
return view('projects.features-export-html', compact('project','features'));
}
}
public function payments($projectId)

2
app/Http/Requests/Features/CreateRequest.php

@ -27,7 +27,7 @@ class CreateRequest extends Request {
{
return [
'name' => 'required|max:60',
'price' => 'required',
'price' => 'string',
'worker_id' => 'required|numeric',
'type_id' => 'required|numeric',
'description' => 'max:255',

2
app/Http/routes/projects.php

@ -6,7 +6,7 @@ Route::group(['middleware' => ['web','role:admin'], 'namespace' => 'Projects'],
*/
Route::get('projects/{id}/delete', ['as'=>'projects.delete', 'uses'=>'ProjectsController@delete']);
Route::get('projects/{id}/features', ['as'=>'projects.features', 'uses'=>'ProjectsController@features']);
Route::get('projects/{id}/features-export', ['as'=>'projects.features-export', 'uses'=>'ProjectsController@featuresExport']);
Route::get('projects/{id}/features-export/{type?}', ['as'=>'projects.features-export', 'uses'=>'ProjectsController@featuresExport']);
Route::get('projects/{id}/payments', ['as'=>'projects.payments', 'uses'=>'ProjectsController@payments']);
Route::post('projects/{id}/features-reorder', ['as'=>'projects.features-reorder', 'uses'=>'ProjectsController@featuresReorder']);
Route::patch('projects/{id}/status-update', ['as'=>'projects.status-update', 'uses'=>'ProjectsController@statusUpdate']);

3
resources/lang/id/project.php

@ -24,7 +24,8 @@ return [
'cash_out_total' => 'Total Pengeluaran',
'customer' => 'Customer',
'features' => 'Daftar Fitur',
'features_export' => 'Export Fitur ke Excel',
'features_export_html' => 'Export Fitur ke HTML',
'features_export_excel' => 'Export Fitur ke Excel',
'worker' => 'Pekerja',
'status' => 'Status Project',
'payments' => 'Pembayaran',

8
resources/views/features/partials/feature-tasks.blade.php

@ -3,10 +3,10 @@
<table class="table table-condensed">
<thead>
<th>{{ trans('app.table_no') }}</th>
<th>{{ trans('task.name') }}</th>
<th>{{ trans('task.route_name') }}</th>
<th class="text-center">{{ trans('task.progress') }}</th>
<th>{{ trans('app.action') }}</th>
<th class="col-md-7">{{ trans('task.name') }}</th>
<th class="col-md-2">{{ trans('task.route_name') }}</th>
<th class="text-center col-md-1">{{ trans('task.progress') }}</th>
<th class="col-md-2">{{ trans('app.action') }}</th>
</thead>
<tbody id="sort-tasks">
@forelse($feature->tasks as $key => $task)

2
resources/views/projects/features-export.blade.php → resources/views/projects/features-export-excel.blade.php

@ -29,7 +29,7 @@
<th>{{ trans('feature.name') }}</th>
{{-- <th class="text-center">{{ trans('feature.progress') }}</th> --}}
<th class="text-right">{{ trans('feature.price') }}</th>
<th>{{ trans('app.notes') }}</th>
<th>{{ trans('app.description') }}</th>
</tr>
</thead>
<tbody id="sort-features">

69
resources/views/projects/features-export-html.blade.php

@ -0,0 +1,69 @@
<?php
// $filename = str_slug(trans('project.features') . '-' . $project->name) . '.xls';
// header("Content-Disposition: attachment; filename=\"$filename\"");
// header("Content-Type: application/vnd.ms-excel");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
{{-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> --}}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{ $project->name }}</title>
{!! Html::style('assets/css/app.css') !!}
</head>
<body>
<div class="container">
<h1 class="page-header text-center">{{ trans('project.features') }} {{ $project->name }}</h1>
@foreach($features as $key => $feature)
<h2 class="feature-title">{{ $feature->name }}</h2>
<table class="table table-condensed table-bordered">
<tbody>
<tr style="background-color: #FFCC00"><th colspan="2">{{ trans('app.description') }}</th></tr>
<tr><td colspan="2">{!! nl2br($feature->description) !!}</td></tr>
@if ($feature->tasks->count())
<tr><td colspan="2">&nbsp;</td></tr>
<tr style="background-color: #FFCC00">
<th class="col-md-3">Sub Fitur</th>
<th class="col-md-6">{{ trans('app.description') }}</th>
</tr>
@foreach($feature->tasks as $task)
<tr>
<td>{{ $task->name }}</td>
<td>{!! nl2br($task->description) !!}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
@endforeach
<h1 class="page-header text-center">Biaya Pembuatan</h1>
<table class="table table-condensed table-bordered">
<tbody>
<tr>
<th class="text-center">{{ trans('app.table_no') }}</th>
<th>{{ trans('feature.name') }}</th>
<th class="text-center">{{ trans('feature.price') }}</th>
</tr>
@foreach($features as $key => $feature)
<tr>
<td class="text-center">{{ 1 + $key }}</td>
<td>{{ $feature->name }}</td>
<td class="text-right">{{ formatRp($feature->price) }}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th class="text-right" colspan="2">Total</th>
<th class="text-right">{{ formatRp($features->sum('price')) }}</th>
</tr>
</tfoot>
</table>
</div>
</body>
</html>

13
resources/views/projects/features.blade.php

@ -23,8 +23,8 @@
<th class="text-center">{{ trans('feature.tasks_count') }}</th>
<th class="text-center">{{ trans('feature.progress') }}</th>
<th class="text-right">{{ trans('feature.price') }}</th>
<th>{{ trans('feature.worker') }}</th>
<th>{{ trans('app.action') }}</th>
{{-- <th>{{ trans('feature.worker') }}</th> --}}
<th class="text-center">{{ trans('app.action') }}</th>
</thead>
<tbody id="sort-features">
@forelse($features as $key => $feature)
@ -36,10 +36,7 @@
@if ($feature->tasks->isEmpty() == false)
<ul>
@foreach($feature->tasks as $task)
<li title="{{ $task->progress }} %">
{{-- <i class="fa fa-battery-{{ ceil(4 * $task->progress/100) }}"></i> --}}
{{ $task->name }}
</li>
<li>{{ $task->name }}</li>
@endforeach
</ul>
@endif
@ -47,8 +44,8 @@
<td class="text-center">{{ $feature->tasks_count = $feature->tasks->count() }}</td>
<td class="text-center">{{ formatDecimal($feature->progress = $feature->tasks->avg('progress')) }} %</td>
<td class="text-right">{{ formatRp($feature->price) }}</td>
<td>{{ $feature->worker->name }}</td>
<td>
{{-- <td>{{ $feature->worker->name }}</td> --}}
<td class="text-center">
{!! link_to_route('features.show', trans('task.create'),[$feature->id],['class' => 'btn btn-default btn-xs']) !!}
{!! link_to_route('features.show', trans('app.show'),[$feature->id],['class' => 'btn btn-info btn-xs']) !!}
{!! link_to_route('features.edit', trans('app.edit'),[$feature->id],['class' => 'btn btn-warning btn-xs']) !!}

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

@ -1,5 +1,8 @@
@if (Request::segment(3) == 'features')
{!! link_to_route('projects.features-export', trans('project.features_export'), [$project->id], ['class' => 'btn btn-success pull-right']) !!}
<div class="pull-right">
{!! link_to_route('projects.features-export', trans('project.features_export_html'), [$project->id, 'html'], ['class' => 'btn btn-link','target' => '_blank']) !!}
{!! link_to_route('projects.features-export', trans('project.features_export_excel'), [$project->id], ['class' => 'btn btn-link']) !!}
</div>
@endif
<!-- Nav tabs -->
<ul class="nav nav-tabs">

Loading…
Cancel
Save