Commit a1af4395 by Muhammad Iz'aan bin suhaimi
parents 4985f864 64bb93be
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Portal\\Mileage\\":"packages/portal/mileage/src", "Portal\\Mileage\\":"packages/portal/mileage/src",
"Portal\\Overtime\\":"packages/portal/overtime/src",
"App\\": "app/", "App\\": "app/",
"Database\\Factories\\": "database/factories/", "Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/", "Database\\Seeders\\": "database/seeders/",
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Portal\\Mileage\\":"packages/portal/mileage/src", "Portal\\Mileage\\":"packages/portal/mileage/src",
"Portal\\Overtime\\":"packages/portal/overtime/src",
"Tests\\": "tests/", "Tests\\": "tests/",
"Portal\\Overide\\": "packages/portal/overide/src" "Portal\\Overide\\": "packages/portal/overide/src"
} }
......
...@@ -195,6 +195,7 @@ ...@@ -195,6 +195,7 @@
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
Portal\Mileage\ServiceProvider::class, Portal\Mileage\ServiceProvider::class,
Portal\Overtime\ServiceProvider::class,
Portal\Overide\ServiceProvider::class, Portal\Overide\ServiceProvider::class,
......
<?php
/*
* Set specific configuration variables here
*/
return [
];
@extends('ui::layouts.app')
@section('content')
<style>
.table-uppercase td
{
text-transform: uppercase;
}
</style>
<div class="ui segment">
<a class="ui violet left ribbon label">Senarai Permohonan Tuntutan Lebih Masa</a><br/>
<div class="ui segment">
<a href="overtime/add" class="ui right floated primary button">Tambah</a><br/>
<div class="column sixteen wide table-uppercase">
<h1 class="ui header">Senarai Pengguna</h1>
{!!
Suitable::source($list)
->title(__('Senarai Pengguna'))
->columns([
\Laravolt\Suitable\Columns\Numbering::make('No'),
['header' => __('Nama'), 'field' => 'name', 'sortable' => true],
['header' => __('Tarikh Hari ini'), 'raw' => function($list){return date("d-m-Y");}, 'sortable' => true],
['header' => __('Terperinci'), 'raw' => function($list){
return "<div class='ui small basic icon buttons'><a href='/applications/".$list->id."' class='ui button'><i class='file icon'></i></a></div>";
}]
])
->render()
!!}
</div>
<br/><br/>
</div>
</div>
@endsection
<?php
use Illuminate\Support\Facades\Route;
use Portal\overtime\Http\Controllers\OvertimeController;
// Group claim Ot
Route::group(
[
'namespace' => '\Portal\Overtime\Http\Controllers',
'prefix' => 'overtime',
'as' => 'overtime::',
'middleware' => ['web', 'auth'],
],
function () {
Route::get('index', ['uses' => 'OvertimeController@index', 'as' => 'overtime.index']);
}
);
\ No newline at end of file
<?php
namespace Portal\Overtime\Data\Repo;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Input;
use Carbon\Carbon;
use App\Events\AuditLog;
use Auth;
use DB;
use Event;
use File;
use Mail;
use PDF;
use Redirect;
use Curl;
use Portal\Overtime\Model\MainOvertime;
use Portal\Mileage\Model\Users;
/**
* undocumented function
*
* @return testing please hide this function and continue below
* @author afif@3fresources.com
**/
class OvertimeRepo
{
public function index($request)
{
$users = Users::where('status', 'ACTIVE')
->paginate(10);
return $users;
}
}
\ No newline at end of file
<?php
namespace Portal\Overtime\Events;
use Portal\Overtime\Model\AuditTrail;
class AuditTrailMileage
{
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($id=NULL,$staffid=NULL,$mainapp=NULL,$content)
{
$this->id = $id;
$this->staffid = $staffid;
$this->mainapp = $mainapp;
$this->content = $this->AuditTrailMileage($id,$staffid,$mainapp,$content);
}
/**
* undocumented function
*
* @return void
* @author
**/
public function AuditTrailMileage($id,$staffid,$mainapp,$content)
{
$save = new AuditTrail;
$save->user_id = $id;
$save->staff_id = $staffid;
$save->main_app = $mainapp;
$save->description = $content;
$save->save();
}
}
\ No newline at end of file
<?php
namespace Portal\Overtime\Events;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
// use Portal\Mileage\Model\MainApp;
// use Portal\Mileage\Model\ContentEmail;
class NotifyEmailAction extends Mailable
{
use Queueable, SerializesModels;
public $data;
public $id;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data,$id)
{
$this->data = MainApp::whereIn('id',$data)
->with('leavetype','user','lkpstatus','appleave.leavedate','appleave.leavecode')
->with('cancelleave.canceldate','user','lkpstatus','user.info','verifier','approver','cancelleave.canceldt')
->get();
$this->id = $id;
// echo $this->data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
// $content = ContentEmail::where('id',$this->id)->first();
if($this->id == 12){
return $this
->subject('Senarai Permohonan Cuti Pegawai Untuk Tindakan Sokongan')
->cc('pss3frsb@gmail.com')
->markdown('ecuti::admin.sentmail.verifylist');
}
if($this->id == 13){
return $this
->subject('Senarai Permohonan Cuti Pegawai Untuk Tindakan Kelulusan')
->cc('pss3frsb@gmail.com')
->markdown('ecuti::admin.sentmail.approvallist');
}
}
}
\ No newline at end of file
<?php
namespace Portal\Overtime\Exports;
use Portal\Overtime\Model\Claim;
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class ClaimsExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithStyles
{
private const DATA_START_ROW = 7;
protected $user;
protected $claims;
public function __construct($user = null, $claims = null)
{
$this->user = $user;
$this->claims = $claims;
}
public function collection(): Collection
{
// Only Disemak claims should be exported
return $this->claims->where('status', 'Disemak') ?? collect();
}
public function headings(): array
{
$roleName = $this->user?->roles?->first()?->name ?? '-';
return [
['BORANG TUNTUTAN PERJALANAN'],
[''],
[
'Nama Staf:', $this->user->name ?? '-',
'Peranan:', $roleName,
],
[
'Syarikat:', '3F RESOURCES SDN BHD',
'Tarikh:', Carbon::now()->format('d/m/Y'),
],
[''],
[
'Tarikh',
'Butiran Tuntutan',
'Dari',
'Ke',
'Jumlah KM (Hari)',
'Tol (RM)',
'Lain-lain (RM)',
],
];
}
public function map($claim): array
{
return [
Carbon::parse($claim->claim_date)->format('d/m/Y'),
$claim->description ?? '-',
$claim->distance_from ?? '-',
$claim->distance_to ?? '-',
number_format($claim->total_mileage ?? 0, 2),
number_format($claim->toll_amount ?? 0, 2),
number_format($claim->others_amount ?? 0, 2),
];
}
public function styles(Worksheet $sheet): array
{
$lastDataRow = $sheet->getHighestRow();
$totalRow = $lastDataRow + 2;
$signRow = $totalRow + 3;
// Header Formatting
$sheet->mergeCells('A1:G1');
$sheet->getStyle('A1')->applyFromArray([
'font' => ['bold' => true, 'size' => 14],
'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER],
]);
// Table Header Formatting
$sheet->getStyle('A6:G6')->applyFromArray([
'font' => ['bold' => true],
'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER],
'fill' => [
'fillType' => Fill::FILL_SOLID,
'startColor' => ['argb' => 'FFEFEFEF'],
],
]);
// Align numeric columns to the right
$dataRange = 'E' . self::DATA_START_ROW . ':G' . $lastDataRow;
$sheet->getStyle($dataRange)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
// Total Row Formatting
$sheet->setCellValue("A{$totalRow}", 'Jumlah Keseluruhan:');
$sheet->mergeCells("A{$totalRow}:D{$totalRow}");
$sheet->setCellValue("E{$totalRow}", "=SUM(E" . self::DATA_START_ROW . ":E{$lastDataRow})");
$sheet->setCellValue("F{$totalRow}", "=SUM(F" . self::DATA_START_ROW . ":F{$lastDataRow})");
$sheet->setCellValue("G{$totalRow}", "=SUM(G" . self::DATA_START_ROW . ":G{$lastDataRow})");
$sheet->getStyle("A{$totalRow}:G{$totalRow}")->getFont()->setBold(true);
// Notes Section Formatting
$sheet->setCellValue("A{$signRow}", 'Seksyen Pengiraan:');
$sheet->setCellValue("A" . ($signRow + 1), '• Tuntutan bermula selepas 40KM pertama setiap hari.');
$sheet->setCellValue("A" . ($signRow + 2), '• Kadar (Kereta): RM0.55/km (<500km), RM0.50/km (>500km).');
$sheet->setCellValue("A" . ($signRow + 3), '• Kadar (Motosikal): RM0.30/km.');
$sheet->getStyle("A{$signRow}")->getFont()->setBold(true);
// Signature Section Formatting
$signStart = $signRow + 6;
// Disahkan oleh (Project Manager / HOD) with Project name or description
$approvedList = $this->claims
->whereNotNull('approved_by')
->map(function ($claim) {
$user = $claim->approvedBy?->name ?? '-';
$role = $claim->approvedBy?->roles?->first()?->name ?? 'Penyemak';
// If project exists, use project name, else fallback to description
$project = $claim->project ? $claim->project->p_project_description : "(Butiran Projek: " . ($claim->description ?? '-') . ")";
return "{$user} - {$role} ({$project})"; // Project name in parentheses
})
->unique()
->implode("\n\n");
// Diluluskan oleh (Project Director / BOD)
$reviewedList = $this->claims
->whereNotNull('reviewed_by')
->map(function ($claim) {
$user = $claim->reviewedBy?->name ?? '-';
$role = $claim->reviewedBy?->roles?->first()?->name ?? 'Pelulus';
$project = $claim->project ? $claim->project->name : "(Butiran Projek: " . ($claim->description ?? '-') . ")";
return "{$user} - {$role} {$project}";
})
->unique()
->implode("\n\n");
// Disediakan oleh (Staff) with Role
$preparedBy = $this->user->name ?? '-';
$preparedRole = $this->user->roles->first()->name ?? 'Staf';
// Write to Excel Cells
$sheet->setCellValue("A{$signStart}", 'Disediakan oleh:');
$sheet->setCellValue("A" . ($signStart + 1), "{$preparedBy}\n({$preparedRole})");
$sheet->getStyle("A" . ($signStart + 1))->getAlignment()->setWrapText(true);
$sheet->setCellValue("C{$signStart}", 'Disahkan oleh:');
$sheet->setCellValue("C" . ($signStart + 1), $approvedList ?: '-');
$sheet->getStyle("C" . ($signStart + 1))->getAlignment()->setWrapText(true);
$sheet->setCellValue("E{$signStart}", 'Diluluskan oleh:');
$sheet->setCellValue("E" . ($signStart + 1), $reviewedList ?: '-');
$sheet->getStyle("E" . ($signStart + 1))->getAlignment()->setWrapText(true);
$sheet->getStyle("A{$signStart}:E{$signStart}")->getFont()->setBold(true);
return [];
}
}
<?php
namespace Portal\Overtime\Handlers\Events;
use Portal\Overtime\Events\NotifyEmail;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
// use Threef\Entree\Database\Model\User;
// use Elesen\Model\Data\Model\Application\Applicant;
use Portal\Overtime\Http\Notifications\PpjMailer;
class SentEmail
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param PaymentMade $event
* @return void
*/
public function handle(NotifyEmail $event)
{
$application = $event->application;
$message = $event->messageContent;
// dd($message);
$user = User::find(id);
// $applicant = Applicant::find($application->fk_applicant);
// if(filter_var($user->email, FILTER_VALIDATE_EMAIL)) :
// $user->notify(new PpjMailer($message));
// endif;
// if(filter_var($applicant->emel, FILTER_VALIDATE_EMAIL)) :
// if($user->email != $applicant->emel):
// $applicant->notify(new PpjMailer($message));
// endif;
// endif;
}
}
<?php
namespace Portal\Overtime\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Carbon\Carbon;
use Portal\Overtime\Data\Repo\OvertimeRepo;
use Auth;
use DB;
use Event;
use File;
use Mail;
use PDF;
use Redirect;
use Curl;
class OvertimeController extends Controller
{
public function __construct(OvertimeRepo $repos)
{
$this->repos = $repos;
}
/**
* undocumented function
*
* @return testing please hide this function and continue below
* @author afif@3fresources.com
**/
public function index(Request $request)
{
// dd('sini controller');exit;
$list = $this->repos->index($request);
return view('overtime::list', compact('list'));
}
}
\ No newline at end of file
<?php
namespace Portal\Overtime\Http\Notifications\Mailable;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Portal\Overtime\Http\Notifications\PpjMailer;
use Illuminate\Notifications\Notification;
// use Orchestra\Contracts\Memory\Provider;
class TestEmail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
// $this->memory = app(Provider::class);
$mailMessage = new MailMessage;
$mailMessage->subject(" : Kemaskini Maklumat Akaun Email");
// $mailMessage->title(" : Kemaskini Maklumat Akaun Email");
$mailMessage->level('warning');
$mailMessage->greeting('Hi' . ', Tuan / Puan');
$mailMessage->line('Maklumat Akaun Email Bagi Berikut Perlu Dikemaskini');
$mailMessage->line('<b>ID Pengguna</b> : ');
$mailMessage->line('<b>Kata Laluan</b> : ');
$mailMessage->line('Sila Tukar Katalaluan Anda Kemudian Log Masuk Melalui Pautan Dibawah');
// $mailMessage->actionText(handles('Mileage::/auth/login'));
$this->content = $mailMessage->toArray();
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('portaladmin@ppj.gov.my')
->subject(data_get($this->content,'subject'))
->view('ecuti::emails.layouts.simple')
->with($this->content);
}
}
<?php
namespace Portal\Overtime\Http\Notifications\Mailable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Bus\Queueable;
class Welcome extends Notification implements ShouldQueue
{
use Queueable, SerializesModels;
public $user;
public function __construct($user)
{
// The $notifiable is already a User instance so not really necessary to pass it here
$this->user = $user;
}
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->greeting('Bonjour '.$this->user->name)
->line('Nous vous remercions de votre inscription.')
->line('Pour rappel voici vos informations :')
->line('Mail: '.$this->user->email)
->line('Password: '.$this->user->password);
}
}
\ No newline at end of file
<?php
namespace Portal\Overtime\Http\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class PpjMailer extends Notification implements ShouldQueue
{
use Queueable;
protected $view = 'ecuti::emails.layouts.simple';
public $message;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($message , $view = FALSE)
{
$this->message = $message;
$this->view = ($view) ? $view : $this->view;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$mailMessage = new MailMessage;
if($this->view) $mailMessage->view = $this->view;
$mailMessage->subject($this->message->get('title', 'Email From ' ));
// $mailMessage->title($this->message->get('title', 'Email From ' ));
$mailMessage->level($this->message->get('level'));
// $mailMessage->greeting('Hi,' . ' ' .$notifiable->name. ', ');
$content = $this->message->get('content',[]);
// dd($content);
foreach($content as $cont){
$mailMessage->line($cont);
}
$action = $this->message->get('action', FALSE);
if($action):
foreach($action as $title => $uri){
$mailMessage->action($title,$uri);
}
endif;
$footer = $this->message->get('footer',[]);
foreach($footer as $foot){
$mailMessage->line($foot);
}
// dd($mailMessage);
// $mailMessage->cc('portalppjadmin@ppj.gov.my');
// $mailMessage->bcc('pss3frsb@gmail.com'); // bcc email ke pss3frsb
return $mailMessage;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
}
}
<?php
namespace Portal\Overtime\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Connection;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
*
* @package
* @author afif@3fresources.com
**/
class MainOvertime extends Model
{
/**
* The database table used by the model.
*
* @var string
*/
// use SoftDeletes;
protected $table = 'overtime_main';
protected $guarded = ['id'];
protected $primaryKey = 'id';
protected $dates = ['deleted_at'];
/**
* undocumented function
*
* @return void
* @author
**/
// public function attach()
// {
// return $this->belongsTo('Workbench\Site\Model\Pemindahan\LesenPindahAttachment', 'fk_lesen_pindah');
// }
} // END class
<?php
namespace Portal\Overtime;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use App\Enums\Permission;
use DB;
use Carbon\Carbon;
/**
* Class PackageServiceProvider
*
* @package Portal\Ecuti
* @see http://laravel.com/docs/master/packages#service-providers
* @see http://laravel.com/docs/master/providers
*/
class ServiceProvider extends BaseServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @see http://laravel.com/docs/master/providers#deferred-providers
* @var bool
*/
protected $defer = false;
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
\Portal\Overtime\Events\NotifyEmail::class => [
\Portal\Overtime\Handlers\Events\SentEmail::class
],
];
/**
* Register the service provider.
*
* @see http://laravel.com/docs/master/providers#the-register-method
* @return void
*/
public function register()
{
// $this->app->bind('staff', \Portal\Ecuti\Data\Repo\StaffRepo::class);
}
/**
* Application is booting
*
* @see http://laravel.com/docs/master/providers#the-boot-method
* @return void
*/
public function boot()
{
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
$this->loadViewsFrom(__DIR__.'/../resources/views', 'overtime');
$this->menu();
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
//add old laravolt view directive
$this->loadViewsFrom(realpath(__DIR__ . '/../resources/views'), 'ui');
// allow views to be published to the storage directory
$this->publishes(
[realpath(__DIR__ . '/../resources/views') => base_path('resources/views/vendor/ui')],
'views'
);
}
protected function menu()
{
app('laravolt.menu.sidebar')->register(function (\Lavary\Menu\Builder $menus)
{
$menu = $menus->add(__('Tuntutan Lebih Masa'))->data('icon', 'align justify');
$menu->add(__('Senarai Permohonan '), url('/overtime/index'))
->data('icon', 'home')
->active('overtime/*');
// ->data('permission', Permission::PROJECT_MANAGER);
});
}
}
\ No newline at end of file
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