Commit 27511bf4 by hannan

export to excel, page report summary

parent 86b99787
<?php
namespace App\Exports;
use App\User;
use Portal\Timesheet\Model\Overhead;
use Portal\Timesheet\Model\VwStaff;
use Portal\Timesheet\Model\VwChargeable;
use Portal\Timesheet\Model\VwRingkasanLaporan;
use Portal\Timesheet\Model\VwNonchargeSummary;
use Portal\Timesheet\Model\VwOverheadSummary;
// use Illuminate\Contracts\Support\Responsable;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
// class UsersExport implements FromCollection, Responsable
class RingkasanExport implements FromView, ShouldAutoSize
{
use Exportable;
// private $fileName = "Ringkasan Laporan.xlsx";
protected $request;
function __construct($request) {
$this->request = $request;
}
/**
* @return \Illuminate\Support\Collection
*/
public function view(): View
{
// dd(VwStaff::all());
$month = $this->request['month'];
$year = $this->request['year'];
return view('timesheet::exports.exportRingkasan', [
'staffs' => VwStaff::orderby('deptID')
->where('deptID','!=', 8)
->get(),
'chargeproject' => VwChargeable::all(),
'overhead' => Overhead::where('o_overhead_sts', 1)->get(),
'ringkasan' => VwRingkasanLaporan::where('month', $month)
->where('year', $year)
->get(),
'projectnc' => VwNonchargeSummary::where('month', $month)
->where('year', $year)
->get(),
'ovhours' => VwOverheadSummary::where('month', $month)
->where('year', $year)
->get()
]);
}
}
<?php
namespace App\Exports;
use App\User;
// use Illuminate\Contracts\Support\Responsable;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
// class UsersExport implements FromCollection, Responsable
class UsersExport implements FromView, ShouldAutoSize
{
use Exportable;
// private $fileName = "Ringkasan Laporan.xlsx";
/**
* @return \Illuminate\Support\Collection
*/
public function view(): View
{
// dd(User::all());
return view('timesheet::exports.users', [
'users' => User::all()
]);
}
}
<table class="ui unstackable celled table" style="width: 100%">
<thead>
<tr>
<th colspan="5"></th>
<th colspan="{{count($chargeproject)+2}}" class="center aligned">Chargeable</th>
<th colspan="{{count($overhead)+3}}" class="center aligned">Non-Chargeable</th>
<th rowspan="2" class="center aligned">Total (Working Days)</th>
</tr>
<tr>
<th>No</th>
<th>Department</th>
<th>Staff Id</th>
<th>Staff Name</th>
<th>Position</th>
@foreach($chargeproject as $key => $chargeable)
<th>
{{data_get($chargeable, 'p_project_code')}}
</th>
@endforeach
<th>Total Hours</th>
<th>Total Days</th>
<th class="center aligned">Project</th>
@foreach($overhead as $key => $value)
<th>{{data_get($value,'o_overhead_desc')}}</th>
@endforeach
<th>Total Hours</th>
<th>Total Days</th>
</tr>
</thead>
<?php $totaldays = $totalalldays = 0; ?>
@foreach($staffs as $key => $staff)
<tbody>
<tr>
<td>{{$key+1}}</td>
<td>{{data_get($staff,'deptCode')}}</td>
<td>{{data_get($staff,'staffid')}}</td>
<td class="single line">{{data_get($staff,'name')}}</td>
<td></td>
<?php $totalc = 0; ?>
@foreach($chargeproject as $key => $chargeable)
<td>
@foreach($ringkasan as $key => $value)
@if(data_get($value,'staffid') == data_get($staff,'staffid') && data_get($chargeable,'id') == data_get($value,'c_pid'))
{{data_get($value,'total_c_hours')}}
<?php $totalc += data_get($value,'total_c_hours'); ?>
@endif
@endforeach
</td>
@endforeach
<td class="center aligned">{{$totalc}}</td>
<td class="center aligned">{{number_format($totalc/8, 1, '.', '')}}</td>
<td class="center aligned">
<?php $totalnc = 0; ?>
@foreach($projectnc as $key => $project)
@if(data_get($project,'staffid') == data_get($staff,'staffid'))
{{data_get($project,'nonchargehours')}}
<?php $totalnc += data_get($project,'nonchargehours'); ?>
@endif
@endforeach
</td>
@foreach($overhead as $key => $value)
<td>
@foreach($ovhours as $key => $hours)
@if(data_get($staff,'staffid') == data_get($hours,'staffid') && data_get($value,'id') == data_get($hours,'oid'))
{{data_get($hours,'hours')}}
<?php $totalnc += data_get($hours,'hours'); ?>
@endif
@endforeach
</td>
@endforeach
<td class="center aligned">{{$totalnc}}</td>
<td class="center aligned">{{number_format($totalnc/8, 1, '.', '')}}</td>
<?php $totaldays = number_format($totalc/8, 1, '.', '') + number_format($totalnc/8, 1, '.', ''); ?>
<td>{{$totaldays}}</td>
</tr>
</tbody>
<?php $totalalldays += $totaldays; ?>
@endforeach
<tfoot>
<tr>
<th colspan="5" class="center aligned">
<strong>Total</strong>
</th>
<th colspan="{{count($chargeproject)+2+count($overhead)+3}}"></th>
<th><strong>{{$totalalldays}}</strong></th>
</tr>
</tfoot>
</table>
\ No newline at end of file
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@foreach($users as $key => $user)
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
</tr>
@endforeach
</tbody>
</table>
\ No newline at end of file
......@@ -2,7 +2,7 @@
@section('content')
<div class="ui orange modal uploadmodal">
<div class="ui tiny orange modal uploadmodal">
<div class="header">
Upload Attachment
</div>
......
......@@ -7,7 +7,7 @@
Report Summary
</div>
<button class="right floated center aligned ui violet compact labeled icon button">
<button class="right floated center aligned ui violet compact labeled icon button" onclick="window.location.href='{{ route('timesheet::export.exportsummary', ['month'=> $intmonth, 'year'=> $year]) }}';">
<i class="file excel outline icon"></i>
Export to Excel
</button>
......
......@@ -9,6 +9,10 @@ Route::group(
],
function () {
//export
Route::get('ringkasan/export/', ['uses' => 'ExportController@export', 'as' => 'export.exportsummary']);
Route::get('users/export/', ['uses' => 'ReportController@export', 'as' => 'report.exportsummary']);
//dashboard
Route::get('home',['uses' => 'DashboardController@index', 'as' => 'dashboard.index']);
......
......@@ -407,9 +407,9 @@ class DashboardController extends Controller
$dept = Department::where('id', $user->fk_lkp_department)
->first();
// dd(Staff_info::all());
$hod = Staff_info::find($user->penyokong)
->fullname;
$penyokong = Staff_info::where('penyokong', 0)
->get();
......
<?php
namespace Portal\Timesheet\Http\Controllers;
use Illuminate\Routing\Controller;
use Carbon\Carbon;
use DB;
use Portal\Timesheet\Model\Users;
use Portal\Timesheet\Model\Ts_master;
use Portal\Timesheet\Model\Ts_detail;
use Portal\Timesheet\Model\Project;
use Portal\Timesheet\Model\Tproject;
use Portal\Timesheet\Model\Department;
use Portal\Timesheet\Model\Pteam;
use Portal\Timesheet\Model\Staff_info;
use Portal\Timesheet\Model\Overhead;
use Portal\Timesheet\Model\Role;
use Portal\Timesheet\Model\VwViewer;
use Portal\Timesheet\Model\VwReviewProfile;
use Portal\Timesheet\Model\VwReviewDetails;
use Portal\Timesheet\Model\VwRingkasanLaporan;
use Portal\Timesheet\Model\VwChargeable;
use Portal\Timesheet\Model\VwNonChargeable;
use Portal\Timesheet\Model\VwStaff;
use Portal\Timesheet\Model\VwOverhead;
use Portal\Timesheet\Model\VwProject;
use Portal\Timesheet\Model\VwNonchargeSummary;
use Portal\Timesheet\Model\VwOverheadSummary;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use File;
use Redirect;
use App\Mail\StatusAccept;
use App\Mail\StatusReject;
use Mail;
use Curl;
use Auth;
use App\Exports\RingkasanExport;
use Maatwebsite\Excel\Facades\Excel;
class ExportController extends Controller
{
public function export(Request $request)
{
// dd($request);
$month = date('F', mktime(0,0,0,$request->month, 1, date('Y')));
$year = strval($request->year);
return (new RingkasanExport(
[
'month' => $request->month,
'year' => $request->year
]))->download('Ringkasan Laporan '.$month.' '.$year.'.xlsx');
}
}
\ No newline at end of file
......@@ -35,9 +35,23 @@ use App\Mail\StatusReject;
use Mail;
use Curl;
use Auth;
use App\Exports\UsersExport;
use Maatwebsite\Excel\Facades\Excel;
class ReportController extends Controller
{
public function export(Request $request)
{
// dd($request);
$month = date('F', mktime(0,0,0,$request->month, 1, date('Y')));
$year = strval($request->year);
return (new UsersExport)->download('Ringkasan Laporan '.$month.' '.$year.'.xlsx');
// return new UsersExport;
}
public function ringkasanLaporan()
{
$dept = Department::all()
......@@ -76,21 +90,20 @@ class ReportController extends Controller
// dd($ovhours);
$chargeproject = VwChargeable::all();
$nonchargeproject = VwNonChargeable::all();
// $nonchargeproject = VwNonChargeable::all();
$staffs = VwStaff::orderby('deptID')
->where('deptID','!=', 8)
->get();
$year = date('Y');
if ($request->year) {
$year = $request->year;
}
$intmonth = $request->month;
$month = date('F', mktime(0,0,0,$request->month, 1, date('Y')));
return view('timesheet::report.ringkasan', compact('month', 'year','ringkasan', 'chargeproject', 'nonchargeproject', 'staffs', 'projectnc', 'overhead', 'ovhours'));
return view('timesheet::report.ringkasan', compact('intmonth','month', 'year','ringkasan', 'chargeproject', 'staffs', 'projectnc', 'overhead', 'ovhours'));
}
public function projectreport()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment