diff --git a/app/Entities/Projects/Project.php b/app/Entities/Projects/Project.php index 82974aa..050dd2e 100755 --- a/app/Entities/Projects/Project.php +++ b/app/Entities/Projects/Project.php @@ -4,6 +4,7 @@ namespace App\Entities\Projects; use App\Entities\Payments\Payment; use App\Entities\Projects\ProjectPresenter; +use App\Entities\Subscriptions\Subscription; use App\Entities\Users\User; use Illuminate\Database\Eloquent\Model; use Laracasts\Presenter\PresentableTrait; @@ -16,11 +17,26 @@ class Project extends Model { protected $guarded = ['id','created_at','updated_at']; // protected $dates = ['start_date','end_date']; - public function features() + public function allFeatures() { return $this->hasMany(Feature::class)->orderBy('position'); } + public function features() + { + return $this->hasMany(Feature::class)->orderBy('position')->whereTypeId(1); + } + + public function additionalFeatures() + { + return $this->hasMany(Feature::class)->orderBy('position')->whereTypeId(2); + } + + public function subscriptions() + { + return $this->hasMany(Subscription::class); + } + public function payments() { return $this->hasMany(Payment::class)->orderBy('date','desc'); diff --git a/app/Entities/Projects/ProjectsRepository.php b/app/Entities/Projects/ProjectsRepository.php index 669e1ee..fdd8990 100755 --- a/app/Entities/Projects/ProjectsRepository.php +++ b/app/Entities/Projects/ProjectsRepository.php @@ -81,21 +81,22 @@ class ProjectsRepository extends BaseRepository $project->payments()->delete(); // Delete features tasks - $featureIds = $project->features->lists('id')->all(); + $featureIds = $project->allFeatures->lists('id')->all(); DB::table('tasks')->whereIn('feature_id', $featureIds)->delete(); // Delete features - $project->features()->delete(); + $project->allFeatures()->delete(); // Delete project $project->delete(); + DB::commit(); return 'deleted'; } - public function getProjectFeatures($projectId) + public function getProjectFeatures($projectId, $type = 1) { - return Feature::whereProjectId($projectId)->orderBy('position')->with('worker','tasks')->get(); + return Feature::whereProjectId($projectId)->whereTypeId($type)->orderBy('position')->with('worker','tasks')->get(); } public function updateStatus($statusId, $projectId) diff --git a/app/Entities/Subscriptions/Subscription.php b/app/Entities/Subscriptions/Subscription.php index 18213d3..8158418 100755 --- a/app/Entities/Subscriptions/Subscription.php +++ b/app/Entities/Subscriptions/Subscription.php @@ -25,4 +25,9 @@ class Subscription extends Model { return $this->belongsTo(User::class,'customer_id'); } + public function status() + { + return $this->status_id ? 'Aktif' : 'Non Aktif'; + } + } diff --git a/app/Entities/Subscriptions/SubscriptionsRepository.php b/app/Entities/Subscriptions/SubscriptionsRepository.php index ffc64ad..ce7a28d 100755 --- a/app/Entities/Subscriptions/SubscriptionsRepository.php +++ b/app/Entities/Subscriptions/SubscriptionsRepository.php @@ -18,6 +18,8 @@ class SubscriptionsRepository extends BaseRepository public function getAll($q) { - return $this->model->orderBy('due_date')->where('domain_name','like','%' . $q . '%')->paginate($this->_paginate); + return $this->model->orderBy('due_date') + ->where('domain_name','like','%' . $q . '%') + ->paginate($this->_paginate); } } \ No newline at end of file diff --git a/app/Http/Controllers/Projects/ProjectsController.php b/app/Http/Controllers/Projects/ProjectsController.php index ae862dd..736b282 100755 --- a/app/Http/Controllers/Projects/ProjectsController.php +++ b/app/Http/Controllers/Projects/ProjectsController.php @@ -84,19 +84,27 @@ class ProjectsController extends Controller { return redirect()->route('projects.index'); } - public function features($projectId) + public function features(Request $req, $projectId) { + $featureType = $req->get('feature_type', 1); $project = $this->repo->requireById($projectId); - $features = $this->repo->getProjectFeatures($projectId); + $features = $this->repo->getProjectFeatures($projectId, $featureType); return view('projects.features', compact('project','features')); } - public function featuresExport($projectId, $type = 'excel') + public function subscriptions($projectId) { $project = $this->repo->requireById($projectId); - $features = $this->repo->getProjectFeatures($projectId); + return view('projects.subscriptions', compact('project')); + } + + public function featuresExport(Request $req, $projectId, $exportType = 'excel') + { + $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 ($type == 'excel') { + if ($exportType == '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')); diff --git a/app/Http/Controllers/References/OptionsController.php b/app/Http/Controllers/References/OptionsController.php index 0a7afde..4d5d9ff 100755 --- a/app/Http/Controllers/References/OptionsController.php +++ b/app/Http/Controllers/References/OptionsController.php @@ -20,8 +20,13 @@ class OptionsController extends Controller { public function index(Request $req) { + $editableOption = null; $options = $this->repo->getAll(); - return view('options.index',compact('options')); + + if (in_array($req->get('action'), ['del','edit']) && $req->has('id')) + $editableOption = $this->repo->requireById($req->get('id')); + + return view('options.index',compact('options','editableOption')); } public function create() diff --git a/app/Http/routes/projects.php b/app/Http/routes/projects.php index f90e0fd..9744c42 100644 --- a/app/Http/routes/projects.php +++ b/app/Http/routes/projects.php @@ -8,6 +8,7 @@ Route::group(['middleware' => ['web','role:admin'], 'namespace' => 'Projects'], Route::get('projects/{id}/features', ['as'=>'projects.features', 'uses'=>'ProjectsController@features']); 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::get('projects/{id}/subscriptions', ['as'=>'projects.subscriptions', 'uses'=>'ProjectsController@subscriptions']); 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']); Route::resource('projects','ProjectsController'); diff --git a/config/backup-manager.php b/config/backup-manager.php new file mode 100644 index 0000000..f2dd3dc --- /dev/null +++ b/config/backup-manager.php @@ -0,0 +1,61 @@ + [ + 'type' => 'Local', + 'root' => storage_path('app'), + ], + 's3' => [ + 'type' => 'AwsS3', + 'key' => '', + 'secret' => '', + 'region' => 'us-east-1', + 'bucket' => '', + 'root' => '', + ], + 'gcs' => [ + 'type' => 'Gcs', + 'key' => '', + 'secret' => '', + 'bucket' => '', + 'root' => '', + ], + 'rackspace' => [ + 'type' => 'Rackspace', + 'username' => '', + 'key' => '', + 'container' => '', + 'zone' => '', + 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', + 'root' => '', + ], + 'dropbox' => [ + 'type' => 'Dropbox', + 'token' => '', + 'key' => '', + 'secret' => '', + 'app' => '', + 'root' => '', + ], + 'ftp' => [ + 'type' => 'Ftp', + 'host' => '', + 'username' => '', + 'password' => '', + 'port' => 21, + 'passive' => true, + 'ssl' => true, + 'timeout' => 30, + 'root' => '', + ], + 'sftp' => [ + 'type' => 'Sftp', + 'host' => '', + 'username' => '', + 'password' => '', + 'port' => 21, + 'timeout' => 10, + 'privateKey' => '', + 'root' => '', + ], +]; diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index f26be01..a8afcc0 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -75,6 +75,7 @@ $factory->define(Subscription::class, function (Faker\Generator $faker) { return [ 'project_id' => factory(Project::class)->create()->id, + 'status_id' => 1, 'domain_name' => 'www.' . str_random(10) . '.com', 'domain_price' => 125000, 'epp_code' => str_random(10), diff --git a/resources/lang/id/option.php b/resources/lang/id/option.php index f8f7a83..ee2f41f 100644 --- a/resources/lang/id/option.php +++ b/resources/lang/id/option.php @@ -1,9 +1,11 @@ 'Daftar Option', 'create' => 'Buat Option Baru', 'created' => 'Option baru berhasil dibuat', 'updated' => 'Option berhasil disimpan', + 'delete' => 'Hapus Option', 'deleted' => 'Option berhasil dihapus', 'undeleted' => 'Option tidak berhasil dihapus', 'key' => 'Key', diff --git a/resources/lang/id/project.php b/resources/lang/id/project.php index cde5bd1..6689479 100644 --- a/resources/lang/id/project.php +++ b/resources/lang/id/project.php @@ -26,6 +26,7 @@ return [ 'features' => 'Daftar Fitur', 'features_export_html' => 'Export Fitur ke HTML', 'features_export_excel' => 'Export Fitur ke Excel', + 'subscriptions' => 'Langganan', 'worker' => 'Pekerja', 'status' => 'Status Project', 'payments' => 'Pembayaran', diff --git a/resources/views/features/add-from-other-project.blade.php b/resources/views/features/add-from-other-project.blade.php index 10f2a08..5e9be76 100755 --- a/resources/views/features/add-from-other-project.blade.php +++ b/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]]) !!}
\ No newline at end of file diff --git a/resources/views/projects/subscriptions.blade.php b/resources/views/projects/subscriptions.blade.php new file mode 100755 index 0000000..690a7df --- /dev/null +++ b/resources/views/projects/subscriptions.blade.php @@ -0,0 +1,43 @@ +@extends('layouts.app') + +@section('title', trans('project.subscriptions')) + +@section('content') + +@include('projects.partials.breadcrumb',['title' => trans('project.subscriptions')]) + +

+ {!! link_to_route('subscriptions.create', trans('subscription.create'), ['project_id' => $project->id, 'customer_id' => $project->customer_id], ['class'=>'btn btn-success pull-right']) !!} + {{ $project->name }} {{ trans('project.subscriptions') }} +

+ +@include('projects.partials.nav-tabs') + + + + + + + + + + + + + @foreach($project->subscriptions as $key => $subscription) + due_date)->diffInDays(Carbon::now()) < 60 ? 'class=bg-danger' : '' }}> + + + + + + + + + @endforeach + +
{{ trans('app.table_no') }}{{ trans('subscription.domain_name') }}{{ trans('subscription.hosting_capacity') }}{{ trans('subscription.start_date') }}{{ trans('subscription.due_date') }}{{ trans('subscription.extension_price') }}{{ trans('app.action') }}
{{ 1 + $key }}{{ $subscription->domain_name }}{{ $subscription->hosting_capacity }}{{ dateId($subscription->start_date) }}{{ dateId($subscription->due_date) }}{{ formatRp($subscription->domain_price + $subscription->hosting_price) }} + {!! link_to_route('subscriptions.show',trans('app.show'),[$subscription->id],['class'=>'btn btn-info btn-xs']) !!} + {!! link_to_route('subscriptions.edit',trans('app.edit'),[$subscription->id],['class'=>'btn btn-warning btn-xs']) !!} +
+@endsection diff --git a/resources/views/subscriptions/create.blade.php b/resources/views/subscriptions/create.blade.php index 2b49ef5..404fd12 100755 --- a/resources/views/subscriptions/create.blade.php +++ b/resources/views/subscriptions/create.blade.php @@ -39,8 +39,8 @@ {!! FormField::text('due_date',['label'=> trans('subscription.due_date')]) !!} - {!! FormField::select('customer_id', $customers,['label'=> trans('subscription.customer')]) !!} - {!! FormField::select('project_id', $projects,['label'=> trans('subscription.project')]) !!} + {!! FormField::select('customer_id', $customers,['label'=> trans('subscription.customer'),'value' => Request::get('customer_id')]) !!} + {!! FormField::select('project_id', $projects,['label'=> trans('subscription.project'),'value' => Request::get('project_id')]) !!} {!! FormField::textarea('remark',['label'=> trans('subscription.remark')]) !!} diff --git a/resources/views/subscriptions/edit.blade.php b/resources/views/subscriptions/edit.blade.php index 44376d3..1e0ccc0 100755 --- a/resources/views/subscriptions/edit.blade.php +++ b/resources/views/subscriptions/edit.blade.php @@ -36,6 +36,7 @@ {!! FormField::select('customer_id', $customers,['label'=> trans('subscription.customer')]) !!} {!! FormField::select('project_id', $projects,['label'=> trans('subscription.project')]) !!} + {!! FormField::radios('status_id', ['Non Active','Active'],['label'=> trans('app.status')]) !!} {!! FormField::textarea('remark',['label'=> trans('subscription.remark')]) !!} diff --git a/resources/views/subscriptions/index.blade.php b/resources/views/subscriptions/index.blade.php index 5734927..205ee42 100755 --- a/resources/views/subscriptions/index.blade.php +++ b/resources/views/subscriptions/index.blade.php @@ -14,6 +14,7 @@ {!! link_to_route('subscriptions.index','Reset',[],['class' => 'btn btn-default btn-sm']) !!} {!! Form::close() !!} + @@ -22,6 +23,7 @@ + @@ -33,6 +35,7 @@ +
{{ trans('app.table_no') }}{{ trans('subscription.start_date') }} {{ trans('subscription.due_date') }} {{ trans('subscription.extension_price') }}{{ trans('app.status') }} {{ trans('app.action') }}
{{ dateId($subscription->start_date) }} {{ dateId($subscription->due_date) }} {{ formatRp($subscription->domain_price + $subscription->hosting_price) }}{{ $subscription->status() }} {!! link_to_route('subscriptions.show',trans('app.show'),[$subscription->id],['class'=>'btn btn-info btn-xs']) !!} {!! link_to_route('subscriptions.edit',trans('app.edit'),[$subscription->id],['class'=>'btn btn-warning btn-xs']) !!} diff --git a/tests/ManageFeaturesTest.php b/tests/ManageFeaturesTest.php index e7d080e..1704cc9 100644 --- a/tests/ManageFeaturesTest.php +++ b/tests/ManageFeaturesTest.php @@ -99,8 +99,13 @@ class ManageFeaturesTest extends TestCase 'project_id' => $project->id, ]); - $this->visit('projects/' . $feature->project_id . '/features'); - $this->click(trans('app.show')); + // $this->visit('projects/' . $project->id . '/features'); + // $this->seePageIs('projects/' . $project->id . '/features'); + // $this->click('show-feature-' . $feature->id); + // $this->dump(); + $this->visit('features/' . $feature->id); + $this->seePageIs('features/' . $feature->id); + // die('hit'); $this->click(trans('app.edit')); $this->click(trans('feature.delete')); $this->press(trans('app.delete_confirm_button')); @@ -126,10 +131,10 @@ class ManageFeaturesTest extends TestCase $this->actingAs($user); $project = factory(Project::class)->create(['owner_id' => $user->id]); - $feature = factory(Feature::class)->create(['project_id' => $project->id]); + $feature = factory(Feature::class)->create(['project_id' => $project->id,'type_id' => 1]); $this->visit('projects/' . $project->id . '/features'); - $this->click(trans('app.show')); + $this->click('show-feature-' . $feature->id); $this->seePageIs('features/' . $feature->id); $this->see(trans('feature.show')); $this->see($feature->name); @@ -145,12 +150,11 @@ class ManageFeaturesTest extends TestCase $this->actingAs($user); $project = factory(Project::class)->create(['owner_id' => $user->id]); - $features = factory(Feature::class, 5)->create(['project_id' => $project->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($features[1]->worker->name); $this->see(formatRp($features[1]->price)); } diff --git a/tests/ManagePaymentsTest.php b/tests/ManagePaymentsTest.php index 4c21697..c2cc032 100644 --- a/tests/ManagePaymentsTest.php +++ b/tests/ManagePaymentsTest.php @@ -156,7 +156,6 @@ class ManagePaymentsTest extends TestCase $this->see($payments[4]->project->name); $this->see($payments[4]->date); $this->see(formatRp($payments[4]->amount)); - $this->see($payments[4]->description); $this->see($payments[4]->customer->name); } diff --git a/tests/ManageSubscriptionsTest.php b/tests/ManageSubscriptionsTest.php index c160c0d..5120d46 100644 --- a/tests/ManageSubscriptionsTest.php +++ b/tests/ManageSubscriptionsTest.php @@ -44,7 +44,13 @@ class ManageSubscriptionsTest extends TestCase $this->seePageIs('subscriptions'); $this->see(trans('subscription.created')); - $this->seeInDatabase('subscriptions', ['project_id' => $project->id,'domain_price' => 100000,'start_date' => '2015-05-02','due_date' => '2016-05-02']); + $this->seeInDatabase('subscriptions', [ + 'project_id' => $project->id, + 'domain_price' => 100000, + 'status_id' => 1, + 'start_date' => '2015-05-02', + 'due_date' => '2016-05-02' + ]); } /** @test */ @@ -70,6 +76,7 @@ class ManageSubscriptionsTest extends TestCase $this->type(500000,'hosting_price'); $this->type('2015-05-02','start_date'); $this->type('2016-05-02','due_date'); + $this->select(0,'status_id'); $this->press(trans('subscription.update')); $this->seePageIs('subscriptions/' . $subscription->id . '/edit'); @@ -78,6 +85,7 @@ class ManageSubscriptionsTest extends TestCase 'epp_code' => $eppCode, 'customer_id' => $customer->id, 'project_id' => $project->id, + 'status_id' => 0, 'hosting_capacity' => '4GB', 'hosting_price' => '500000', 'start_date' => '2015-05-02', diff --git a/tests/ManageTasksTest.php b/tests/ManageTasksTest.php index 9a88034..2da09b8 100644 --- a/tests/ManageTasksTest.php +++ b/tests/ManageTasksTest.php @@ -62,7 +62,6 @@ class ManageTasksTest extends TestCase // Fill Form $this->type('Nama Task Edit','name'); - $this->type('tasks/{id}/edit','route_name'); $this->type(77,'progress'); $this->press(trans('task.update')); @@ -71,8 +70,7 @@ class ManageTasksTest extends TestCase $this->seeInDatabase('tasks', [ 'name' => 'Nama Task Edit', 'progress' => 77, - 'feature_id' => $feature->id, - 'route_name' => 'tasks/{id}/edit', + 'feature_id' => $feature->id ]); }