Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
3
3f-timesheet
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dockers
3f-timesheet
Commits
13475f90
Commit
13475f90
authored
Jan 11, 2023
by
Azhan Hannan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cron Job -> reminder for unsubmission timesheet for 3 times each for each phase.
parent
d308a692
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
0 deletions
+148
-0
app/Console/Commands/DemoCron.php
+140
-0
app/Console/Kernel.php
+8
-0
No files found.
app/Console/Commands/DemoCron.php
0 → 100644
View file @
13475f90
<?php
namespace
App\Console\Commands
;
use
Illuminate\Console\Command
;
use
Portal\Timesheet\Model\Ts_master
;
use
Portal\Timesheet\Model\VwStaff
;
use
Mail
;
use
App\Mail\Reminder
;
class
DemoCron
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'demo: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
()
{
$today
=
date
(
'd-m-Y'
);
$currday
=
date
(
'j'
);
$currmonth
=
date
(
'n'
);
$curryear
=
date
(
'Y'
);
// $currday = 20;
// $currmonth = 11;
// $curryear = 2022;
if
(
$currday
>
15
)
{
$checkphase
=
1
;
$checkyear
=
$curryear
;
$checkmonth
=
$currmonth
;
}
else
{
$checkphase
=
2
;
if
(
$currmonth
==
1
)
{
$checkmonth
=
12
;
$checkyear
=
$curryear
-
1
;
}
else
{
$checkmonth
=
$currmonth
-
1
;
$checkyear
=
$curryear
;
}
}
$timesheets
=
Ts_master
::
select
(
'tm_staff_id'
)
->
where
(
'tm_year'
,
$checkyear
)
->
where
(
'tm_month'
,
$checkmonth
)
->
where
(
'tm_phase'
,
$checkphase
)
->
whereIn
(
'tm_timesheet_master_sts'
,
[
'2,3,4,5,6'
])
->
get
();
$staffsubmitted
=
[];
foreach
(
$timesheets
as
$key
=>
$value
)
{
$staffsubmitted
[]
=
$value
->
tm_staff_id
;
}
$users
=
VwStaff
::
whereNotIn
(
'staffid'
,
$staffsubmitted
)
->
where
(
'deptID'
,
'<>'
,
8
)
->
with
(
'penyokong'
)
->
get
();
if
(
env
(
'EMAIL_ENV'
)
==
'local'
)
{
foreach
(
$users
as
$key
=>
$value
)
{
$mailTo
=
'3fetimesheet@gmail.com'
;
\Log
::
info
(
$mailTo
);
$data_email
=
[
'subject'
=>
'Timesheet: Reminder for Timesheet Submission'
,
'sender_name'
=>
'3fetimesheet@gmail.com'
,
'name'
=>
data_get
(
$value
,
'name'
),
'cc'
=>
'143hannan@gmail.com'
,
'today'
=>
$today
,
'phase'
=>
$checkphase
,
'month'
=>
$checkmonth
,
'year'
=>
$checkyear
,
];
// Mail::to($mailTo)->cc($data_email['cc'])->send(new Reminder($data_email));
}
}
elseif
(
env
(
'EMAIL_ENV'
)
==
'PRODUCTION'
)
{
foreach
(
$users
as
$key
=>
$value
)
{
$mailTo
=
$value
->
email
;
$data_email
=
[
'subject'
=>
'Timesheet: Reminder for Timesheet Submission'
,
'sender_name'
=>
'3fetimesheet@gmail.com'
,
'name'
=>
data_get
(
$value
,
'name'
),
'cc'
=>
data_get
(
$value
,
'penyokong.email'
),
'today'
=>
$today
,
'phase'
=>
$checkphase
,
'month'
=>
$checkmonth
,
'year'
=>
$checkyear
,
];
Mail
::
to
(
$mailTo
)
->
cc
(
$data_email
[
'cc'
])
->
send
(
new
Reminder
(
$data_email
));
}
}
/*
Write your database logic we bellow:
Item::create(['name'=>'hello new']);
*/
}
}
app/Console/Kernel.php
View file @
13475f90
...
...
@@ -26,6 +26,14 @@ class Kernel extends ConsoleKernel
{
// $schedule->command('inspire')
// ->hourly();
$schedule
->
command
(
'demo:cron'
)
->
monthlyOn
(
5
,
'09:00'
);
$schedule
->
command
(
'demo:cron'
)
->
monthlyOn
(
7
,
'09:00'
);
$schedule
->
command
(
'demo:cron'
)
->
monthlyOn
(
10
,
'09:00'
);
$schedule
->
command
(
'demo:cron'
)
->
monthlyOn
(
20
,
'09:00'
);
$schedule
->
command
(
'demo:cron'
)
->
monthlyOn
(
22
,
'09:00'
);
$schedule
->
command
(
'demo:cron'
)
->
monthlyOn
(
25
,
'09:00'
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment