Commit 23cfda72 by Azhan Hannan

changes in report

parent 9e777547
......@@ -3,7 +3,12 @@
namespace App\Exports;
use App\User;
use Portal\Timesheet\Model\Users;
use Portal\Timesheet\Model\Pmandays;
use Portal\Timesheet\Model\Tproject;
use Portal\Timesheet\Model\Pteam;
use Portal\Timesheet\Model\VwProject;
use Portal\Timesheet\Model\VwProjectStaffRoles;
// use Illuminate\Contracts\Support\Responsable;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
......@@ -14,6 +19,7 @@ use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use Auth;
// class UsersExport implements FromCollection, Responsable
......@@ -40,31 +46,16 @@ class ProjectExport implements FromView, ShouldAutoSize, WithColumnWidths, WithS
$sheet->getStyle('4')->getFont()->setBold(true);
}
// public function styles(Worksheet $sheet)
// {
// return [
// // Style the first row as bold text.
// '1' => ['font' => ['bold' => true]],
// '2' => ['font' => ['bold' => true]],
// '4' => ['font' => ['bold' => true]],
// '10' => ['font' => ['bold' => true]]
// // Styling a specific cell by coordinate.
// // 'B2' => ['font' => ['italic' => true]],
// // Styling an entire column.
// // 'C' => ['font' => ['size' => 16]],
// ];
// }
public function columnWidths(): array
{
return [
'A' => 50,
'B' => 20,
'C' => 15,
'D' => 15
'D' => 15,
'E' => 20,
'F' => 15,
'G' => 15
];
}
......@@ -77,6 +68,9 @@ class ProjectExport implements FromView, ShouldAutoSize, WithColumnWidths, WithS
$year = $this->request['year'];
$project = $this->request['pid'];
$roleid = auth()->user()->roles['0']->id;
$user = Users::find(Auth::id());
return view('timesheet::exports.exportProject', [
'month' => $month,
......@@ -97,8 +91,28 @@ class ProjectExport implements FromView, ShouldAutoSize, WithColumnWidths, WithS
->where('year', $year)
->where('roleid', '<>', '7')
->orderby('roleid')
->get()
->get(),
'roles' => Pmandays::where('fk_project', $project)
->with('role')
->orderby('pm_roles', 'ASC')
->get(),
'pteams' => Pteam::where('fk_project_id', $project)
->orderby('role_id')
// ->where('pt_project_task_sts', 1)
->get(),
'accumulates' => VwProjectStaffRoles::where('td_project', $project)
->where('tp_year', '<=' ,$year)
->where('tp_month', '<=', $month)
->orderby('tp_month', 'ASC')
->get(),
'currentmonthhours' => Tproject::where('td_project', $project)
->where('tp_year', $year)
->where('tp_month', $month)
->get(),
]);
}
}
......@@ -6,6 +6,7 @@ use App\User;
use Portal\Timesheet\Model\Overhead;
use Portal\Timesheet\Model\VwStaff;
use Portal\Timesheet\Model\VwChargeable;
use Portal\Timesheet\Model\Tproject;
use Portal\Timesheet\Model\VwRingkasanLaporan;
use Portal\Timesheet\Model\VwNonchargeSummary;
use Portal\Timesheet\Model\VwOverheadSummary;
......@@ -50,30 +51,130 @@ class RingkasanExport implements ShouldAutoSize, FromView, WithColumnWidths
public function view(): View
{
// dd(VwStaff::all());
$dept = $this->request['dept'];
$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)
->where('status', 4)
->get(),
// 'projectnc' => VwNonchargeSummary::where('month', $month)
// ->where('year', $year)
// ->get(),
'ovhours' => VwOverheadSummary::where('month', $month)
->where('year', $year)
->where('status', 4)
->get()
]);
$liststaffs = [];
$chargeproject = VwChargeable::where('deleted_at', null)->get();
if ($dept == 'all') {
$staffs = VwStaff::orderby('deptID')
->where('deptID','!=', 8)
->get();
foreach ($staffs as $key => $staff)
{
$liststaffs[] = data_get($staff,'staffid');
}
}
else
{
$staffs = VwStaff::orderby('deptID')
->where('deptID','!=', 8)
->where('deptID', $dept)
->get();
foreach ($staffs as $key => $staff)
{
$liststaffs[] = data_get($staff,'staffid');
}
}
// dd($liststaffs);
if ($dept == 'all') {
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)
->where('status', 4)
->get(),
'ovhours' => VwOverheadSummary::where('month', $month)
->where('year', $year)
->where('status', 4)
->get(),
'chargehours' => Tproject::where('tp_year', $year)
->where('tp_month', $month)
->where('tp_hours', '<>', null)
->where('tp_project_type', 1)
->whereIn('staffid', $liststaffs)
->where('tp_timesheet_sts', 4)
->get(),
'chargeprojects' => Tproject::select('td_project', 'tp_year', 'tp_month', 'tp_project_name')
->where('tp_year', $year)
->where('tp_month', $month)
->where('tp_hours', '<>', null)
->where('tp_project_type', 1)
->whereIn('staffid', $liststaffs)
->with('project')
->where('tp_timesheet_sts', 4)
->distinct()
->get(),
'month' => date('F', mktime(0,0,0,$month, 1, date('Y'))),
'year' => $year,
]);
}
else
{
return view('timesheet::exports.exportRingkasan', [
'staffs' => VwStaff::orderby('deptID')
->where('deptID','!=', 8)
->where('deptID', $dept)
->get(),
'chargeproject' => VwChargeable::all(),
'overhead' => Overhead::where('o_overhead_sts', 1)->get(),
'ringkasan' => VwRingkasanLaporan::where('month', $month)
->where('year', $year)
->where('status', 4)
->get(),
'ovhours' => VwOverheadSummary::where('month', $month)
->where('year', $year)
->where('status', 4)
->get(),
'chargehours' => Tproject::where('tp_year', $year)
->where('tp_month', $month)
->where('tp_hours', '<>', null)
->where('tp_project_type', 1)
->whereIn('staffid', $liststaffs)
->where('tp_timesheet_sts', 4)
->get(),
'chargeprojects' => Tproject::select('td_project', 'tp_year', 'tp_month', 'tp_project_name')
->where('tp_year', $year)
->where('tp_month', $month)
->where('tp_hours', '<>', null)
->where('tp_project_type', 1)
->whereIn('staffid', $liststaffs)
->with('project')
->where('tp_timesheet_sts', 4)
->distinct()
->get(),
'month' => date('F', mktime(0,0,0,$month, 1, date('Y'))),
'year' => $year,
]);
}
}
}
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