Browse Source

Update feature export view and fixed failed ManageProjectsTest

pull/1/head
Nafies Luthfi 9 years ago
parent
commit
b802e2e4b7
  1. 5
      app/Entities/BaseRepository.php
  2. 2
      app/Http/Controllers/PaymentsController.php
  3. 34
      app/Http/Controllers/Projects/ProjectsController.php
  4. 2
      resources/views/options/index.blade.php
  5. 13
      resources/views/projects/features-export-progress-excel.blade.php
  6. 6
      resources/views/projects/features.blade.php
  7. 2
      tests/functional/ManageProjectsTest.php

5
app/Entities/BaseRepository.php

@ -16,6 +16,11 @@ abstract class BaseRepository extends EloquentRepository {
return User::orderBy('name')->hasRoles(['customer'])->pluck('name','id'); return User::orderBy('name')->hasRoles(['customer'])->pluck('name','id');
} }
public function getCustomersAndVendorsList()
{
return User::orderBy('name')->hasRoles(['customer','vendor'])->pluck('name','id');
}
public function getWorkersList() public function getWorkersList()
{ {
return User::orderBy('name')->hasRoles(['worker'])->pluck('name','id'); return User::orderBy('name')->hasRoles(['worker'])->pluck('name','id');

2
app/Http/Controllers/PaymentsController.php

@ -28,7 +28,7 @@ class PaymentsController extends Controller {
public function create() public function create()
{ {
$projects = $this->repo->getProjectsList(); $projects = $this->repo->getProjectsList();
$customers = $this->repo->getCustomersList();
$customers = $this->repo->getCustomersAndVendorsList();
return view('payments.create',compact('projects','customers')); return view('payments.create',compact('projects','customers'));
} }

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

@ -19,15 +19,15 @@ class ProjectsController extends Controller {
$this->repo = $repo; $this->repo = $repo;
} }
public function index(Request $req)
public function index(Request $request)
{ {
$status = null; $status = null;
$statusId = $req->get('status');
$statusId = $request->get('status');
if ($statusId) { if ($statusId) {
$status = $this->repo->getStatusName($statusId); $status = $this->repo->getStatusName($statusId);
} }
$projects = $this->repo->getProjects($req->get('q'), $statusId);
$projects = $this->repo->getProjects($request->get('q'), $statusId);
return view('projects.index',compact('projects','status')); return view('projects.index',compact('projects','status'));
} }
@ -37,9 +37,9 @@ class ProjectsController extends Controller {
return view('projects.create', compact('customers')); return view('projects.create', compact('customers'));
} }
public function store(CreateRequest $req)
public function store(CreateRequest $request)
{ {
$project = $this->repo->create($req->except('_token'));
$project = $this->repo->create($request->except('_token'));
flash()->success(trans('project.created')); flash()->success(trans('project.created'));
return redirect()->route('projects.show', $project->id); return redirect()->route('projects.show', $project->id);
} }
@ -58,9 +58,9 @@ class ProjectsController extends Controller {
return view('projects.edit',compact('project','statuses','customers')); return view('projects.edit',compact('project','statuses','customers'));
} }
public function update(UpdateRequest $req, $projectId)
public function update(UpdateRequest $request, $projectId)
{ {
$project = $this->repo->update($req->except(['_method','_token']), $projectId);
$project = $this->repo->update($request->except(['_method','_token']), $projectId);
flash()->success(trans('project.updated')); flash()->success(trans('project.updated'));
return redirect()->route('projects.edit', $projectId); return redirect()->route('projects.edit', $projectId);
} }
@ -71,9 +71,9 @@ class ProjectsController extends Controller {
return view('projects.delete', compact('project')); return view('projects.delete', compact('project'));
} }
public function destroy(DeleteRequest $req, $projectId)
public function destroy(DeleteRequest $request, $projectId)
{ {
if ($projectId == $req->get('project_id'))
if ($projectId == $request->get('project_id'))
{ {
$this->repo->delete($projectId); $this->repo->delete($projectId);
flash()->success(trans('project.deleted')); flash()->success(trans('project.deleted'));
@ -97,9 +97,9 @@ class ProjectsController extends Controller {
return view('projects.subscriptions', compact('project')); return view('projects.subscriptions', compact('project'));
} }
public function featuresExport(Request $req, $projectId, $exportType = 'excel')
public function featuresExport(Request $request, $projectId, $exportType = 'excel')
{ {
$featureType = $req->get('feature_type', 1);
$featureType = $request->get('feature_type', 1);
$project = $this->repo->requireById($projectId); $project = $this->repo->requireById($projectId);
$features = $this->repo->getProjectFeatures($projectId, $featureType); $features = $this->repo->getProjectFeatures($projectId, $featureType);
@ -111,7 +111,7 @@ class ProjectsController extends Controller {
}); });
})->download('xls'); })->download('xls');
} elseif ($exportType == 'excel-progress') { } elseif ($exportType == 'excel-progress') {
// return view('projects.features-export-progress-excel', compact('project','features'));
return view('projects.features-export-progress-excel', compact('project','features'));
\Excel::create(str_slug(trans('project.features') . '-' . $project->name), function($excel) use ($project, $features) { \Excel::create(str_slug(trans('project.features') . '-' . $project->name), function($excel) use ($project, $features) {
$excel->sheet('export-progress', function($sheet) use ($project, $features) { $excel->sheet('export-progress', function($sheet) use ($project, $features) {
$sheet->loadView('projects.features-export-progress-excel',compact('project','features')); $sheet->loadView('projects.features-export-progress-excel',compact('project','features'));
@ -129,17 +129,17 @@ class ProjectsController extends Controller {
return view('projects.payments', compact('project')); return view('projects.payments', compact('project'));
} }
public function statusUpdate(Request $req, $projectId)
public function statusUpdate(Request $request, $projectId)
{ {
$project = $this->repo->updateStatus($req->get('status_id'), $projectId);
$project = $this->repo->updateStatus($request->get('status_id'), $projectId);
flash()->success(trans('project.updated')); flash()->success(trans('project.updated'));
return redirect()->route('projects.show', $projectId); return redirect()->route('projects.show', $projectId);
} }
public function featuresReorder(Request $req, $projectId)
public function featuresReorder(Request $request, $projectId)
{ {
if ($req->ajax()) {
$data = $this->repo->featuresReorder($req->get('postData'));
if ($request->ajax()) {
$data = $this->repo->featuresReorder($request->get('postData'));
return 'oke'; return 'oke';
} }

2
resources/views/options/index.blade.php

@ -4,7 +4,7 @@
<h1 class="page-header"> <h1 class="page-header">
{{ trans('option.options') }} {{ trans('option.options') }}
</h1> </h1>
{{ FormField::price('price') }}
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
{!! Form::open(['route'=>'options.save', 'method'=>'patch']) !!} {!! Form::open(['route'=>'options.save', 'method'=>'patch']) !!}

13
resources/views/projects/features-export-progress-excel.blade.php

@ -28,7 +28,7 @@
<th>{{ trans('app.table_no') }}</th> <th>{{ trans('app.table_no') }}</th>
<th>{{ trans('feature.name') }}</th> <th>{{ trans('feature.name') }}</th>
<th class="text-center">{{ trans('feature.progress') }}</th> <th class="text-center">{{ trans('feature.progress') }}</th>
{{-- <th class="text-right">{{ trans('feature.price') }}</th> --}}
<th class="text-right">{{ trans('feature.price') }}</th>
{{-- <th>{{ trans('app.description') }}</th> --}} {{-- <th>{{ trans('app.description') }}</th> --}}
</tr> </tr>
</thead> </thead>
@ -40,21 +40,22 @@
{{ $feature->name }} {{ $feature->name }}
</td> </td>
<td class="text-center">{{ formatDecimal($feature->progress = $feature->tasks->avg('progress')) }}</td> <td class="text-center">{{ formatDecimal($feature->progress = $feature->tasks->avg('progress')) }}</td>
{{-- <td class="text-right">{{ $feature->price }}</td> --}}
<td class="text-right">{{ $feature->price }}</td>
{{-- <td style="wrap-text: true;">{!! nl2br($feature->description) !!}</td> --}} {{-- <td style="wrap-text: true;">{!! nl2br($feature->description) !!}</td> --}}
</tr> </tr>
<?php /*
@if ($feature->tasks->count()) @if ($feature->tasks->count())
@foreach($feature->tasks as $task) @foreach($feature->tasks as $task)
<tr> <tr>
<td></td> <td></td>
<td>{{ $task->name }}</td> <td>{{ $task->name }}</td>
<td>{{ $task->progress }}</td>
<td></td> <td></td>
{{-- <td style="wrap-text: true;">{!! nl2br($task->description) !!}</td> --}} {{-- <td style="wrap-text: true;">{!! nl2br($task->description) !!}</td> --}}
</tr> </tr>
@endforeach @endforeach
@endif @endif
<?php /*
*/ ?> */ ?>
@empty @empty
<tr><td colspan="7">{{ trans('feature.empty') }}</td></tr> <tr><td colspan="7">{{ trans('feature.empty') }}</td></tr>
@ -63,9 +64,9 @@
<tfoot> <tfoot>
<tr> <tr>
<th class="text-right" colspan="2">Total</th> <th class="text-right" colspan="2">Total</th>
<th class="text-center">{{ formatDecimal($features->sum('progress') / count($features)) }}</th>
{{-- <th class="text-center">{{ $project->getFeatureOveralProgress() }} %</th> --}}
{{-- <th class="text-right">{{ $features->sum('price') }}</th> --}}
{{-- <th class="text-center">{{ formatDecimal($features->sum('progress') / count($features)) }}</th> --}}
<th class="text-center">{{ formatDecimal($project->getFeatureOveralProgress()) }} %</th>
<th class="text-right">{{ $features->sum('price') }}</th>
{{-- <th></th> --}} {{-- <th></th> --}}
</tr> </tr>
</tfoot> </tfoot>

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

@ -34,7 +34,7 @@
<th>{{ trans('feature.name') }}</th> <th>{{ trans('feature.name') }}</th>
<th class="text-center">{{ trans('feature.tasks_count') }}</th> <th class="text-center">{{ trans('feature.tasks_count') }}</th>
<th class="text-center">{{ trans('feature.progress') }}</th> <th class="text-center">{{ trans('feature.progress') }}</th>
{{-- <th class="text-right">{{ trans('feature.price') }}</th> --}}
<th class="text-right">{{ trans('feature.price') }}</th>
{{-- <th>{{ trans('feature.worker') }}</th> --}} {{-- <th>{{ trans('feature.worker') }}</th> --}}
<th class="text-center">{{ trans('app.action') }}</th> <th class="text-center">{{ trans('app.action') }}</th>
</thead> </thead>
@ -58,7 +58,7 @@
</td> </td>
<td class="text-center">{{ $feature->tasks_count = $feature->tasks->count() }}</td> <td class="text-center">{{ $feature->tasks_count = $feature->tasks->count() }}</td>
<td class="text-center">{{ formatDecimal($feature->progress) }} %</td> <td class="text-center">{{ formatDecimal($feature->progress) }} %</td>
{{-- <td class="text-right">{{ formatRp($feature->price) }}</td> --}}
<td class="text-right">{{ formatRp($feature->price) }}</td>
{{-- <td>{{ $feature->worker->name }}</td> --}} {{-- <td>{{ $feature->worker->name }}</td> --}}
<td class="text-center"> <td class="text-center">
{!! html_link_to_route('features.show', '',[$feature->id],['icon' => 'search', 'title' => 'Lihat ' . trans('feature.show'), 'class' => 'btn btn-info btn-xs','id' => 'show-feature-' . $feature->id]) !!} {!! html_link_to_route('features.show', '',[$feature->id],['icon' => 'search', 'title' => 'Lihat ' . trans('feature.show'), 'class' => 'btn btn-info btn-xs','id' => 'show-feature-' . $feature->id]) !!}
@ -77,7 +77,7 @@
<span title="Total Progress">{{ formatDecimal($groupedFeatures->sum('progress') / $groupedFeatures->count()) }} %</span> <span title="Total Progress">{{ formatDecimal($groupedFeatures->sum('progress') / $groupedFeatures->count()) }} %</span>
<span title="Overal Progress" style="font-weight:300">({{ formatDecimal($project->getFeatureOveralProgress()) }} %)</span> <span title="Overal Progress" style="font-weight:300">({{ formatDecimal($project->getFeatureOveralProgress()) }} %)</span>
</th> </th>
{{-- <th class="text-right">{{ formatRp($groupedFeatures->sum('price')) }}</th> --}}
<th class="text-right">{{ formatRp($groupedFeatures->sum('price')) }}</th>
<th colspan="2"></th> <th colspan="2"></th>
</tr> </tr>
</tfoot> </tfoot>

2
tests/functional/ManageProjectsTest.php

@ -78,7 +78,7 @@ class ManageProjectsTest extends TestCase
$task = factory(Task::class)->create(['feature_id' => $feature->id]); $task = factory(Task::class)->create(['feature_id' => $feature->id]);
$payment = factory(Payment::class)->create(['project_id' => $project->id]); $payment = factory(Payment::class)->create(['project_id' => $project->id]);
$this->visit('/projects?status=' . $project->status_id);
$this->visit('projects/' . $project->id);
$this->click(trans('app.edit')); $this->click(trans('app.edit'));
$this->click(trans('app.delete')); $this->click(trans('app.delete'));
$this->press(trans('app.delete_confirm_button')); $this->press(trans('app.delete_confirm_button'));

Loading…
Cancel
Save