Browse Source

Update 2016-09-07.20.28

pull/1/head
Nafies Luthfi 9 years ago
parent
commit
51395a17ae
  1. 18
      app/Entities/Projects/Project.php
  2. 13
      app/Entities/Projects/ProjectsRepository.php
  3. 8
      app/Http/Controllers/Projects/ProjectsController.php
  4. 2
      config/app.php
  5. 3
      public/assets/css/app.css
  6. 2
      public/assets/css/app.css.map
  7. 1
      resources/assets/sass/app.scss
  8. 4
      resources/lang/id/project.php
  9. 2
      resources/views/features/add-from-other-project.blade.php
  10. 2
      resources/views/features/partials/feature-tasks-operation.blade.php
  11. 20
      resources/views/features/partials/feature-tasks.blade.php
  12. 14
      resources/views/projects/features-export-excel.blade.php
  13. 48
      resources/views/projects/features.blade.php
  14. 13
      resources/views/projects/partials/nav-tabs.blade.php
  15. 20
      tests/ExampleTest.php
  16. 0
      tests/auth/ManageUsersTest.php
  17. 0
      tests/auth/MemberChangePasswordTest.php
  18. 0
      tests/auth/MemberRegistrationAndLoginTest.php
  19. 0
      tests/auth/MemberResetPasswordTest.php
  20. 16
      tests/functional/ManageFeaturesTest.php
  21. 0
      tests/functional/ManagePaymentsTest.php
  22. 0
      tests/functional/ManageProjectsTest.php
  23. 0
      tests/functional/ManageSubscriptionsTest.php
  24. 0
      tests/functional/ManageTasksTest.php

18
app/Entities/Projects/Project.php

@ -17,12 +17,12 @@ class Project extends Model {
protected $guarded = ['id','created_at','updated_at'];
// protected $dates = ['start_date','end_date'];
public function allFeatures()
public function features()
{
return $this->hasMany(Feature::class)->orderBy('position');
}
public function features()
public function mainFeatures()
{
return $this->hasMany(Feature::class)->orderBy('position')->whereTypeId(1);
}
@ -61,4 +61,18 @@ class Project extends Model {
});
}
public function getFeatureOveralProgress()
{
$overalProgress = 0;
$totalPrice = $this->features->sum('price');
foreach ($this->features as $feature) {
$progress = $feature->tasks->avg('progress');
$index = $feature->price / $totalPrice;
$overalProgress += $progress * $index;
}
return $overalProgress;
}
}

13
app/Entities/Projects/ProjectsRepository.php

@ -81,11 +81,11 @@ class ProjectsRepository extends BaseRepository
$project->payments()->delete();
// Delete features tasks
$featureIds = $project->allFeatures->lists('id')->all();
$featureIds = $project->features->lists('id')->all();
DB::table('tasks')->whereIn('feature_id', $featureIds)->delete();
// Delete features
$project->allFeatures()->delete();
$project->features()->delete();
// Delete project
$project->delete();
@ -94,9 +94,14 @@ class ProjectsRepository extends BaseRepository
return 'deleted';
}
public function getProjectFeatures($projectId, $type = 1)
public function getProjectFeatures($projectId, $type = null)
{
return Feature::whereProjectId($projectId)->whereTypeId($type)->orderBy('position')->with('worker','tasks')->get();
return Feature::where(function($query) use ($projectId, $type) {
$query->whereProjectId($projectId);
if ($type)
$query->whereTypeId($type);
})->orderBy('position')->with('worker','tasks')->get();
}
public function updateStatus($statusId, $projectId)

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

@ -84,11 +84,10 @@ class ProjectsController extends Controller {
return redirect()->route('projects.index');
}
public function features(Request $req, $projectId)
public function features($projectId)
{
$featureType = $req->get('feature_type', 1);
$project = $this->repo->requireById($projectId);
$features = $this->repo->getProjectFeatures($projectId, $featureType);
$features = $this->repo->getProjectFeatures($projectId);
return view('projects.features', compact('project','features'));
}
@ -103,8 +102,9 @@ class ProjectsController extends Controller {
$featureType = $req->get('feature_type', 1);
$project = $this->repo->requireById($projectId);
$features = $this->repo->getProjectFeatures($projectId, $featureType);
// return view('projects.features-export', compact('project','features'));
if ($exportType == 'excel') {
// return view('projects.features-export-excel', 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-excel',compact('project','features'));

2
config/app.php

@ -159,7 +159,7 @@ return [
App\Providers\RouteServiceProvider::class,
BackupManager\Laravel\Laravel5ServiceProvider::class,
// Barryvdh\Debugbar\ServiceProvider::class,
Barryvdh\Debugbar\ServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
Laracasts\Flash\FlashServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,

3
public/assets/css/app.css

@ -7156,7 +7156,8 @@ h1.page-header {
margin: auto; }
.nav > li > a {
padding: 6px 10px; }
padding: 6px 10px;
border-color: #eee #eee #ddd; }
.navbar-right > li > a {
padding: 15px; }

2
public/assets/css/app.css.map
File diff suppressed because it is too large
View File

1
resources/assets/sass/app.scss

@ -50,6 +50,7 @@ h1.page-header {
.nav > li > a {
padding: 6px 10px;
border-color: #eee #eee #ddd;
}
.navbar-right > li > a {

4
resources/lang/id/project.php

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

2
resources/views/features/add-from-other-project.blade.php

@ -26,7 +26,7 @@
@if ($selectedProject)
{!! Form::open(['route'=>['features.store-from-other-project', $project->id]]) !!}
<ul class="list-unstyled">
@forelse($selectedProject->allFeatures as $key => $feature)
@forelse($selectedProject->features as $key => $feature)
<li>
<label for="feature_id_{{ $feature->id }}">
{!! Form::checkbox('feature_ids[' . $feature->id . ']', $feature->id, null, ['id' => 'feature_id_' . $feature->id]) !!}

2
resources/views/features/partials/feature-tasks-operation.blade.php

@ -29,7 +29,7 @@
{!! FormField::text('progress', ['addon' => ['after' => '%']]) !!}
</div>
<div class="col-md-6">
{!! FormField::select('feature_id', $feature->project->allFeatures->lists('name','id'), ['label' => 'Pindahkan ke Fitur lain']) !!}
{!! FormField::select('feature_id', $feature->project->features->lists('name','id'), ['label' => 'Pindahkan ke Fitur lain']) !!}
</div>
</div>
{!! Form::submit(trans('task.update'), ['class' => 'btn btn-warning']) !!}

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

@ -6,7 +6,7 @@
<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>
<th class="col-md-2 text-center">{{ trans('app.action') }}</th>
</thead>
<tbody id="sort-tasks">
@forelse($feature->tasks as $key => $task)
@ -18,17 +18,25 @@
</td>
<td>{{ $task->route_name }}</td>
<td class="text-center">{{ $task->progress }} %</td>
<td>
{{ link_to_route('features.show', trans('task.edit'), [
<td class="text-center">
{!! html_link_to_route('features.show', '', [
$feature->id,
'action' => 'task_edit',
'task_id' => $task->id
],['class' => 'btn btn-warning btn-xs']) }}
{{ link_to_route('features.show', trans('task.delete'), [
],[
'class' => 'btn btn-warning btn-xs',
'title' => trans('task.edit'),
'icon' => 'edit'
]) !!}
{!! html_link_to_route('features.show', '', [
$feature->id,
'action' => 'task_delete',
'task_id' => $task->id
],['class' => 'btn btn-danger btn-xs']) }}
],[
'class' => 'btn btn-danger btn-xs',
'title' => trans('task.delete'),
'icon' => 'close'
]) !!}
</td>
</tr>
@empty

14
resources/views/projects/features-export-excel.blade.php

@ -27,20 +27,20 @@
<tr>
<th>{{ trans('app.table_no') }}</th>
<th>{{ trans('feature.name') }}</th>
{{-- <th class="text-center">{{ trans('feature.progress') }}</th> --}}
<th class="text-right">{{ trans('feature.price') }}</th>
<th class="text-center">{{ trans('feature.progress') }}</th>
{{-- <th class="text-right">{{ trans('feature.price') }}</th> --}}
<th>{{ trans('app.description') }}</th>
</tr>
</thead>
<tbody id="sort-features">
@forelse($features as $key => $feature)
<tr>
<td rowspan="{{ $feature->tasks->count() + 1 }}">{{ 1 + $key }}</td>
<td>{{ 1 + $key }}</td>
<td>
{{ $feature->name }}
</td>
{{-- <td class="text-center">{{ formatDecimal($feature->progress = $feature->tasks->avg('progress')) }} %</td> --}}
<td rowspan="{{ $feature->tasks->count() + 1 }}" class="text-right">{{ $feature->price }}</td>
<td class="text-center">{{ $feature->progress = $feature->tasks->avg('progress')/100 }}</td>
{{-- <td class="text-right">{{ $feature->price }}</td> --}}
<td style="wrap-text: true;">{!! nl2br($feature->description) !!}</td>
</tr>
@ -61,8 +61,8 @@
<tfoot>
<tr>
<th class="text-right" colspan="2">Total</th>
{{-- <th class="text-center">{{ formatDecimal($features->avg('progress')) }} %</th> --}}
<th class="text-right">{{ $features->sum('price') }}</th>
<th class="text-center">{{ $features->avg('progress')/100 }}</th>
{{-- <th class="text-right">{{ $features->sum('price') }}</th> --}}
<th></th>
</tr>
</tfoot>

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

@ -15,8 +15,19 @@
@include('projects.partials.nav-tabs')
<div class="panel panel-default">
<table id="features-table" class="table table-condensed table-striped">
@foreach($features->groupBy('type_id') as $key => $groupedFeatures)
<div class="panel panel-default table-responsive">
<div class="panel-heading">
<div class="pull-right">
{!! link_to_route('projects.features-export', trans('project.features_export_html'), [$project->id, 'html', 'feature_type' => $key], ['class' => '','target' => '_blank']) !!} |
{!! link_to_route('projects.features-export', trans('project.features_export_excel'), [$project->id, 'excel', 'feature_type' => $key], ['class' => '']) !!}
</div>
<h3 class="panel-title">
{{ $key == 1 ? 'Daftar Fitur' : 'Fitur Tambahan' }}
</h3>
</div>
<table class="table table-condensed table-striped">
<thead>
<th>{{ trans('app.table_no') }}</th>
<th>{{ trans('feature.name') }}</th>
@ -26,8 +37,8 @@
{{-- <th>{{ trans('feature.worker') }}</th> --}}
<th class="text-center">{{ trans('app.action') }}</th>
</thead>
<tbody id="sort-features">
@forelse($features as $key => $feature)
<tbody class="sort-features">
@forelse($groupedFeatures as $key => $feature)
@php($no = 1 + $key)
<tr id="{{ $feature->id }}">
<td>{{ $no }}</td>
@ -46,9 +57,8 @@
<td class="text-right">{{ formatRp($feature->price) }}</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','id' => 'show-feature-' . $feature->id]) !!}
{!! link_to_route('features.edit', trans('app.edit'),[$feature->id],['class' => 'btn btn-warning btn-xs']) !!}
{!! 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.edit', '',[$feature->id],['icon' => 'edit', 'title' => trans('feature.edit'), 'class' => 'btn btn-warning btn-xs']) !!}
</td>
</tr>
@empty
@ -58,35 +68,27 @@
<tfoot>
<tr>
<th class="text-right" colspan="2">Total</th>
<th class="text-center">{{ $features->sum('tasks_count') }}</th>
<th class="text-center">{{ formatDecimal($features->avg('progress')) }} %</th>
<th class="text-right">{{ formatRp($features->sum('price')) }}</th>
<th class="text-center">{{ $groupedFeatures->sum('tasks_count') }}</th>
<th class="text-center">{{ formatDecimal($project->getFeatureOveralProgress()) }} %</th>
<th class="text-right">{{ formatRp($groupedFeatures->sum('price')) }}</th>
<th colspan="2"></th>
</tr>
</tfoot>
</table>
</div>
@endforeach
@endsection
{{--
@section('ext_css')
{!! Html::style(url('assets/css/plugins/dataTables.bootstrap.css')) !!}
@endsection
--}}
@section('ext_js')
{{-- {!! Html::script(url('assets/js/plugins/dataTables/jquery.dataTables.js')) !!}
{!! Html::script(url('assets/js/plugins/dataTables/dataTables.bootstrap.js')) !!}
--}} {!! Html::script(url('assets/js/plugins/jquery-ui.min.js')) !!}
{!! Html::script(url('assets/js/plugins/jquery-ui.min.js')) !!}
@endsection
@section('script')
<script>
(function() {
// $('#features-table').dataTable({
// "paging": false,
// "info": false
// });
$('#sort-features').sortable({
$('.sort-features').sortable({
update: function (event, ui) {
var data = $(this).sortable('toArray').toString();
$.post("{{ route('projects.features-reorder', $project->id) }}", {postData: data});

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

@ -1,22 +1,11 @@
@if (Request::segment(3) == 'features')
<div class="pull-right">
{!! link_to_route('projects.features-export', trans('project.features_export_html'), [$project->id, 'html', 'feature_type' => Request::get('feature_type', 1)], ['class' => 'btn btn-link','target' => '_blank']) !!}
{!! link_to_route('projects.features-export', trans('project.features_export_excel'), [$project->id, 'excel', 'feature_type' => Request::get('feature_type', 1)], ['class' => 'btn btn-link']) !!}
</div>
@endif
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="{{ Request::segment(3) == null ? 'active' : '' }}">
{!! link_to_route('projects.show', trans('project.show'), [$project->id]) !!}
</li>
<li class="{{ Request::segment(3) == 'features' && Request::has('feature_type') == false ? 'active' : '' }}">
<li class="{{ Request::segment(3) == 'features' ? 'active' : '' }}">
{!! link_to_route('projects.features', trans('project.features') . ' (' . $project->features->count() . ')', [$project->id]) !!}
</li>
@if ($project->additionalFeatures->count())
<li class="{{ Request::segment(3) == 'features' && Request::has('feature_type') ? 'active' : '' }}">
{!! link_to_route('projects.features', trans('project.features') . ' Tambahan (' . $project->additionalFeatures->count() . ')', [$project->id, 'feature_type' => 2]) !!}
</li>
@endif
<li class="{{ Request::segment(3) == 'payments' ? 'active' : '' }}">
{!! link_to_route('projects.payments', trans('project.payments') . ' (' . $project->payments->count() . ')', [$project->id]) !!}
</li>

20
tests/ExampleTest.php

@ -1,20 +0,0 @@
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
/**
* A basic functional test example.
*
* @return void
*/
public function testBasicExample()
{
$this->visit('/auth/login')
->see('Login');
$this->assertTrue(true);
}
}

0
tests/ManageUsersTest.php → tests/auth/ManageUsersTest.php

0
tests/MemberChangePasswordTest.php → tests/auth/MemberChangePasswordTest.php

0
tests/MemberRegistrationAndLoginTest.php → tests/auth/MemberRegistrationAndLoginTest.php

0
tests/MemberResetPasswordTest.php → tests/auth/MemberResetPasswordTest.php

16
tests/ManageFeaturesTest.php → tests/functional/ManageFeaturesTest.php

@ -143,22 +143,6 @@ class ManageFeaturesTest extends TestCase
}
/** @test */
public function admin_can_see_all_features()
{
$user = factory(User::class)->create();
$user->assignRole('admin');
$this->actingAs($user);
$project = factory(Project::class)->create(['owner_id' => $user->id]);
$features = factory(Feature::class, 5)->create(['project_id' => $project->id, 'type_id' => 1]);
$this->assertEquals(5, $features->count());
$this->visit('projects/' . $project->id . '/features');
$this->see($features[1]->name);
$this->see(formatRp($features[1]->price));
}
/** @test */
public function admin_may_clone_many_features_from_other_projects()
{
$user = factory(User::class)->create();

0
tests/ManagePaymentsTest.php → tests/functional/ManagePaymentsTest.php

0
tests/ManageProjectsTest.php → tests/functional/ManageProjectsTest.php

0
tests/ManageSubscriptionsTest.php → tests/functional/ManageSubscriptionsTest.php

0
tests/ManageTasksTest.php → tests/functional/ManageTasksTest.php

Loading…
Cancel
Save