Commit f379f2c9 by Azhan Hannan

verification & approval notification

parent 8846eb50
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Approval extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'approval:cron';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$year = date('Y');
$month = date('n');
$day = date('j');
if($day<16)
{
$phase = 2;
if ($month == 1)
{
$month = 12;
$year -= 1;
}
else
{
$month -=1;
}
}
else
{
$phase = 1;
}
$checktm = Ts_master::where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->where('tm_timesheet_master_sts', 3)
->get();
$checktpproject = VwTpStatus::select('staffid', 'tp_project_type', 'fk_tm_id', 'tp_year', 'tp_month', 'tp_phase', 'tp_timesheet_sts', 'tp_pd')
->where('tp_year', $year)
->where('tp_month', $month)
->where('tp_phase', $phase)
->where('tp_timesheet_sts', 3)
->where('tp_project_type', 1)
->with('pelulus')
->with('staffdetails')
->distinct()
->get();
$pelulus = VwPelulus::with('details')->get();
foreach ($pelulus as $key => $value)
{
$projectstafflist = [];
if (count($checktpproject) > 0)
{
$projectstafflist = $checktpproject->where('tp_pd', data_get($value,'pelulus'));
}
if(env('EMAIL_ENV') == 'local')
{
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Approval',
'sender_name' => '3fetimesheet@gmail.com',
'cc' => '143hannan@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'DEVELOPMENT')
{
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Approval',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'PRODUCTION')
{
$mailTo = data_get($value,'details.email');
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Approval',
'sender_name' => '3fetimesheet@gmail.com',
'cc' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
if ( count($projectstafflist) > 0 )
{
Mail::to($mailTo)->send(new ApprovalNotification($data_email, $projectstafflist));
// return new ApprovalNotification($data_email, $projectstafflist);
}
}
}
}
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Verification extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'verification:cron';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$year = date('Y');
$month = date('n');
$day = date('j');
if($day<16){
$phase = 2;
if ($month == 1)
{
$month = 12;
$year -= 1;
} else
{
$month -=1;
}
}
else
{
$phase = 1;
}
$checktm = Ts_master::where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->where('tm_timesheet_master_sts', 2)
->get();
$checktpproject = VwTpStatus::select('staffid', 'tp_project_type', 'fk_tm_id', 'tp_year', 'tp_month', 'tp_phase', 'tp_timesheet_sts', 'tp_pm')
->where('tp_year', $year)
->where('tp_month', $month)
->where('tp_phase', $phase)
->where('tp_timesheet_sts', 2)
->where('tp_project_type', 1)
->with('penyokongproject')
->with('staffdetails')
->distinct()
->get();
// dd($checktpproject);
$checktpoverhead = VwTpStatus::where('tp_year', $year)
->where('tp_month', $month)
->where('tp_phase', $phase)
->where('tp_timesheet_sts', 2)
->where('tp_project_type', 3)
->with('staffdetails')
->with('penyokongoverhead')
->get();
$penyokong = VwPenyokong::with('details')->get();
foreach ($penyokong as $key => $value) {
$projectstafflist = [];
if (count($checktpproject->where('tp_pm', data_get($value,'details.u_staffID'))) > 0) {
$projectstafflist = $checktpproject->where('tp_pm', data_get($value,'details.u_staffID'));
}
$overheadstafflist = [];
if (count($checktpoverhead) > 0) {
$overheadstafflist = $checktpoverhead->where('tp_pm', data_get($value, 'penyokong'));
}
if (env('EMAIL_ENV') == 'local') {
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Verification',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'cc' => '143hannan@gmail.com',
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'DEVELOPMENT')
{
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Verification',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'PRODUCTION')
{
$mailTo = data_get($value,'details.email');
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Verification',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'cc' => '3fetimesheet@gmail.com',
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
if ( count($projectstafflist) > 0 || count($overheadstafflist) > 0) {
Mail::to($mailTo)->send(new VerificationNotification($data_email, $projectstafflist, $overheadstafflist));
// return new VerificationNotification($data_email, $projectstafflist, $overheadstafflist);
}
}
}
}
...@@ -33,6 +33,14 @@ class Kernel extends ConsoleKernel ...@@ -33,6 +33,14 @@ class Kernel extends ConsoleKernel
$schedule->command('demo:cron')->monthlyOn(20, '09:00'); $schedule->command('demo:cron')->monthlyOn(20, '09:00');
$schedule->command('demo:cron')->monthlyOn(22, '09:00'); $schedule->command('demo:cron')->monthlyOn(22, '09:00');
$schedule->command('demo:cron')->monthlyOn(25, '09:00'); $schedule->command('demo:cron')->monthlyOn(25, '09:00');
$schedule->command('verification:cron')->weeklyOn(1, '9:00');
$schedule->command('verification:cron')->weeklyOn(2, '9:00');
$schedule->command('verification:cron')->weeklyOn(3, '9:00');
$schedule->command('verification:cron')->weeklyOn(4, '9:00');
$schedule->command('verification:cron')->weeklyOn(5, '9:00');
$schedule->command('approval:cron')->weeklyOn(1, '9:00');
$schedule->command('approval:cron')->weeklyOn(3, '9:00');
$schedule->command('approval:cron')->weeklyOn(5, '9:00');
} }
......
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class ApprovalNotification extends Mailable
{
use Queueable, SerializesModels;
public $data_email;
public $projectstafflist;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data_email, $projectstafflist)
{
$this->data_email = $data_email;
$this->projectstafflist = $projectstafflist;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject($this->data_email['subject'])
->from($this->data_email['sender_name'])
->markdown('mail.content.ApprovalNotification');
}
}
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class VerificationNotification extends Mailable
{
use Queueable, SerializesModels;
public $data_email;
public $projectstafflist;
public $overheadstafflist;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data_email, $projectstafflist, $overheadstafflist)
{
$this->data_email = $data_email;
$this->projectstafflist = $projectstafflist;
$this->overheadstafflist = $overheadstafflist;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject($this->data_email['subject'])
->from($this->data_email['sender_name'])
->markdown('mail.content.VerificationNotification');
}
}
...@@ -66,6 +66,8 @@ Route::group( ...@@ -66,6 +66,8 @@ Route::group(
Route::post('generateOvertimeReport', ['uses' => 'ReportController@generateOvertimeReport', 'as' => 'report.generateOvertimeReport']); Route::post('generateOvertimeReport', ['uses' => 'ReportController@generateOvertimeReport', 'as' => 'report.generateOvertimeReport']);
Route::get('filterNotSubmit', ['uses' => 'ReportController@filterNotSubmit', 'as' => 'report.filterNotSubmit']); Route::get('filterNotSubmit', ['uses' => 'ReportController@filterNotSubmit', 'as' => 'report.filterNotSubmit']);
Route::post('generateNotSubmitReport', ['uses' => 'ReportController@generateNotSubmitReport', 'as' => 'report.generateNotSubmitReport']); Route::post('generateNotSubmitReport', ['uses' => 'ReportController@generateNotSubmitReport', 'as' => 'report.generateNotSubmitReport']);
// Route::get('filterTimesheetStatus', ['uses' => 'ReportController@filterTimesheetStatus', 'as' => 'report.filterTimesheetStatus']);
// Route::post('generateTimesheetStatus', ['uses' => 'ReportController@generateTimesheetStatus', 'as' => 'report.generateTimesheetStatus']);
//maintenance //maintenance
Route::get('senaraiProject',['uses' => 'MaintenanceController@senaraiProject', 'as' => 'maintenance.senaraiProject']); Route::get('senaraiProject',['uses' => 'MaintenanceController@senaraiProject', 'as' => 'maintenance.senaraiProject']);
...@@ -107,6 +109,8 @@ Route::group( ...@@ -107,6 +109,8 @@ Route::group(
Route::get('mail/editProject', ['uses' => 'MaintenanceController@mailEditProject', 'as' => 'maintenance.mailEditProject']); Route::get('mail/editProject', ['uses' => 'MaintenanceController@mailEditProject', 'as' => 'maintenance.mailEditProject']);
Route::get('mail/addProjectTeam', ['uses' => 'MaintenanceController@mailAddProjectTeam', 'as' => 'maintenance.mailAddProjectTeam']); Route::get('mail/addProjectTeam', ['uses' => 'MaintenanceController@mailAddProjectTeam', 'as' => 'maintenance.mailAddProjectTeam']);
Route::get('reminder', ['uses' => 'MaintenanceController@reminder', 'as' => 'maintenance.reminder']); Route::get('reminder', ['uses' => 'MaintenanceController@reminder', 'as' => 'maintenance.reminder']);
Route::get('verificationNotification', ['uses' => 'MaintenanceController@verificationNotification', 'as' => 'maintenance.verificationNotification']);
Route::get('approvalNotification', ['uses' => 'MaintenanceController@approvalNotification', 'as' => 'maintenance.approvalNotification']);
// route to form // route to form
Route::get('chargeableForm',['uses' => 'FormController@chargeableForm', 'as' => 'form.chargeableForm']); Route::get('chargeableForm',['uses' => 'FormController@chargeableForm', 'as' => 'form.chargeableForm']);
......
...@@ -19,7 +19,10 @@ use Portal\Timesheet\Model\Overhead; ...@@ -19,7 +19,10 @@ use Portal\Timesheet\Model\Overhead;
use Portal\Timesheet\Model\Role; use Portal\Timesheet\Model\Role;
use Portal\Timesheet\Model\Pmandays; use Portal\Timesheet\Model\Pmandays;
use Portal\Timesheet\Model\VwMandays; use Portal\Timesheet\Model\VwMandays;
use Portal\Timesheet\Model\VwTpStatus;
use Portal\Timesheet\Model\VwStaff; use Portal\Timesheet\Model\VwStaff;
use Portal\Timesheet\Model\VwPenyokong;
use Portal\Timesheet\Model\VwPelulus;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Input;
// use Illuminate\Support\Facades\Mail; // use Illuminate\Support\Facades\Mail;
...@@ -32,6 +35,8 @@ use App\Mail\AddProjectTeam; ...@@ -32,6 +35,8 @@ use App\Mail\AddProjectTeam;
use App\Mail\EditProjectTeam; use App\Mail\EditProjectTeam;
use App\Mail\EditMandays; use App\Mail\EditMandays;
use App\Mail\Reminder; use App\Mail\Reminder;
use App\Mail\VerificationNotification;
use App\Mail\ApprovalNotification;
use Mail; use Mail;
use Curl; use Curl;
use Auth; use Auth;
...@@ -1273,4 +1278,200 @@ class MaintenanceController extends Controller ...@@ -1273,4 +1278,200 @@ class MaintenanceController extends Controller
// } // }
} }
public function verificationNotification()
{
$year = date('Y');
$month = date('n');
$day = date('j');
if($day<16){
$phase = 2;
if ($month == 1) {
$month = 12;
$year -= 1;
} else {
$month -=1;
}
}else{
$phase = 1;
}
$checktm = Ts_master::where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->where('tm_timesheet_master_sts', 2)
->get();
$checktpproject = VwTpStatus::select('staffid', 'tp_project_type', 'fk_tm_id', 'tp_year', 'tp_month', 'tp_phase', 'tp_timesheet_sts', 'tp_pm')
->where('tp_year', $year)
->where('tp_month', $month)
->where('tp_phase', $phase)
->where('tp_timesheet_sts', 2)
->where('tp_project_type', 1)
->with('penyokongproject')
->with('staffdetails')
->distinct()
->get();
// dd($checktpproject);
$checktpoverhead = VwTpStatus::where('tp_year', $year)
->where('tp_month', $month)
->where('tp_phase', $phase)
->where('tp_timesheet_sts', 2)
->where('tp_project_type', 3)
->with('staffdetails')
->with('penyokongoverhead')
->get();
$penyokong = VwPenyokong::with('details')->get();
foreach ($penyokong as $key => $value) {
$projectstafflist = [];
if (count($checktpproject->where('tp_pm', data_get($value,'details.u_staffID'))) > 0) {
$projectstafflist = $checktpproject->where('tp_pm', data_get($value,'details.u_staffID'));
}
$overheadstafflist = [];
if (count($checktpoverhead) > 0) {
$overheadstafflist = $checktpoverhead->where('tp_pm', data_get($value, 'penyokong'));
}
if (env('EMAIL_ENV') == 'local') {
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Verification',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'cc' => '143hannan@gmail.com',
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'DEVELOPMENT')
{
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Verification',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'PRODUCTION')
{
$mailTo = data_get($value,'details.email');
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Verification',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'cc' => '3fetimesheet@gmail.com',
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
if ( count($projectstafflist) > 0 || count($overheadstafflist) > 0) {
Mail::to($mailTo)->send(new VerificationNotification($data_email, $projectstafflist, $overheadstafflist));
// return new VerificationNotification($data_email, $projectstafflist, $overheadstafflist);
}
}
}
public function approvalNotification()
{
$year = date('Y');
$month = date('n');
$day = date('j');
if($day<16){
$phase = 2;
if ($month == 1) {
$month = 12;
$year -= 1;
} else {
$month -=1;
}
}else{
$phase = 1;
}
$checktm = Ts_master::where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->where('tm_timesheet_master_sts', 3)
->get();
$checktpproject = VwTpStatus::select('staffid', 'tp_project_type', 'fk_tm_id', 'tp_year', 'tp_month', 'tp_phase', 'tp_timesheet_sts', 'tp_pd')
->where('tp_year', $year)
->where('tp_month', $month)
->where('tp_phase', $phase)
->where('tp_timesheet_sts', 3)
->where('tp_project_type', 1)
->with('pelulus')
->with('staffdetails')
->distinct()
->get();
$pelulus = VwPelulus::with('details')->get();
foreach ($pelulus as $key => $value)
{
$projectstafflist = [];
if (count($checktpproject) > 0) {
$projectstafflist = $checktpproject->where('tp_pd', data_get($value,'pelulus'));
}
if(env('EMAIL_ENV') == 'local'){
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Approval',
'sender_name' => '3fetimesheet@gmail.com',
'cc' => '143hannan@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'DEVELOPMENT')
{
$mailTo = '3fetimesheet@gmail.com';
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Approval',
'sender_name' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
elseif (env('EMAIL_ENV') == 'PRODUCTION')
{
$mailTo = data_get($value,'details.email');
$data_email = [
'subject' => 'Timesheet: Notification for Timesheet Approval',
'sender_name' => '3fetimesheet@gmail.com',
'cc' => '3fetimesheet@gmail.com',
'name' => data_get($value,'name'),
'phase' => $phase,
'month' => $month,
'year' => $year,
];
}
if ( count($projectstafflist) > 0 ) {
// dd(count($projectstafflist));
// Mail::to($mailTo)->send(new ApprovalNotification($data_email, $projectstafflist));
return new ApprovalNotification($data_email, $projectstafflist);
}
}
}
} }
\ No newline at end of file
<?php
namespace Portal\Timesheet\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class VwPelulus extends Model
{
use Notifiable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'vw_pelulus';
public function details()
{
return $this->hasOne('Portal\Timesheet\Model\Users','id','pelulus');
}
// public function penyokong()
// {
// return $this->hasOne('Portal\Timesheet\Model\Staff_info','id','penyokong');
// }
/**
* undocumented function
*
* @return void
* @author
**/
public function info()
{
}
}
<?php
namespace Portal\Timesheet\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class VwPenyokong extends Model
{
use Notifiable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'vw_penyokong';
public function details()
{
return $this->hasOne('Portal\Timesheet\Model\Users','id','penyokong');
}
/**
* undocumented function
*
* @return void
* @author
**/
public function info()
{
}
}
<?php
namespace Portal\Timesheet\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class VwTpStatus extends Model
{
use Notifiable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'vw_tp_status';
public function staffdetails()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','staffid');
}
public function penyokongproject()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','tp_pm');
}
public function penyokongoverhead()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','fk_users','tp_pm');
}
public function pelulus()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','fk_users','tp_pd');
}
/**
* undocumented function
*
* @return void
* @author
**/
public function info()
{
}
}
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