Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
Homestead.json
Homestead.yaml
.env
composer.lock
dompdf.php

54 changes: 53 additions & 1 deletion app/Modules/Recruitment/Http/Controllers/ReportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use App\Modules\Recruitment\Repositories\Interfaces\ReportRepositoryInterface as ReportRepository;
use App\Modules\Settings\Repositories\Interfaces\ContractTypeRepositoryInterface as ContractTypeRepository;
use App\Modules\Settings\Repositories\Interfaces\SkillRepositoryInterface as SkillRepository;
use Illuminate\Http\Request;
use App\Modules\Pim\Repositories\Interfaces\CandidateRepositoryInterface as CandidateRepository;
use Datatables;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;

class ReportsController extends Controller
{
Expand Down Expand Up @@ -77,4 +79,54 @@ public function show($id)
$breadcrumb = ['title' => $candidate->first_name.' '.$candidate->last_name, 'id' => $candidate->id];
return view('recruitment::reports.show', compact('candidate', 'breadcrumb'));
}

public function download(CandidateRepository $candidateRepository)
{
$reports = Datatables::collection($this->reportRepository->getCollection([[
'key' => 'role',
'operator' => '=',
'value' => $candidateRepository->model::USER_ROLE_CANDIDATE
]], ['id' ,'first_name', 'last_name', 'email', 'gender', 'birth_date', 'notes', 'how_did_they_hear'])->get())
->addColumn('phone', function($candidate) {
return @$candidate->contact->phone;
})
->addColumn('address', function($candidate) {
return @$candidate->address->street_1 . ' ' . @$candidate->address->city . ' ' . @$candidate->address->country;
})
->addColumn('skills', function($candidate) {
return @implode(', ', $candidate->skills->pluck('name')->toArray());
})
->addColumn('salary', function($candidate) {
return @format_price($candidate->user_preferences->salary);
})
->addColumn('contract_type', function($candidate) {
return @$candidate->user_preferences->contractType->name;
})
->addColumn('location', function($candidate) {
return @get_location_name($candidate->user_preferences->location);
})
->addColumn('social_accounts', function($candidate) {
return @implode(', ', $candidate->social_accounts->pluck('url')->toArray());
})
->addColumn('education_major', function($candidate) {
return @implode(', ', $candidate->education->pluck('major')->toArray());
})
->addColumn('comments', function($candidate) {
return @$candidate->user_preferences->comments;
})
->removeColumn('id')
->make(true);

$reports = $reports->getData(true)['data'];

Excel::create('Recruitment report', function($excel) use($reports) {

$excel->sheet('Report', function($sheet) use($reports) {

$sheet->fromArray($reports);

});

})->export('xls');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<div class="col-sm-12">
<div class="custom-panel">
<div class="custom-panel-heading">{{trans('app.recruitment.reports.main')}}</div>
<form action="{{route('recruitment.reports.download')}}" method="POST">
{{ Form::token() }}
<button type="submit" class="btn btn-sm btn-default">Download report</button>
</form>
<table class="table table-bordered table-hover" id="recruitmentTable">
<thead>
<th>{{trans('app.recruitment.reports.first_name')}}</th>
Expand Down
Empty file modified bootstrap/cache/.gitignore
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"laravel/framework": "5.3.*",
"laravelcollective/html": "^5.3",
"yajra/laravel-datatables-oracle": "~6.0",
"guzzlehttp/guzzle": "~6.0"
"guzzlehttp/guzzle": "~6.0",
"maatwebsite/excel": "~2.1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
Loading