mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
Merge branch 'main' of bitbucket.org:studiotem/jandl-taskmanager-app
This commit is contained in:
commit
39466d7bb4
20 files changed
+459
-14
No files matched your search
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\SubTask;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class SubTaskDeleted
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $subtask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(SubTask $subtask)
|
||||||
|
{
|
||||||
|
$this->subtask = $subtask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\SubTask;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class SubTaskEdited
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $subtask;
|
||||||
|
public $originalSubtask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(SubTask $subtask, array $originalSubtask)
|
||||||
|
{
|
||||||
|
$this->subtask = $subtask;
|
||||||
|
$this->originalSubtask = $originalSubtask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@ class SubTaskController extends Controller
|
|||||||
$subtasks = SubTask::whereHas('mastertask', function ($query) use ($parameters) {
|
$subtasks = SubTask::whereHas('mastertask', function ($query) use ($parameters) {
|
||||||
$query->where('team_id', $parameters['team_id']);
|
$query->where('team_id', $parameters['team_id']);
|
||||||
})->whereHas('timeblocks', function ($query) use ($parameters) {
|
})->whereHas('timeblocks', function ($query) use ($parameters) {
|
||||||
$query->where('start', '>=', $parameters['start']);
|
$query->where('start', '>', $parameters['start']);
|
||||||
$query->where('end', '<=', $parameters['end']);
|
$query->where('end', '<=', $parameters['end']);
|
||||||
})->get();
|
})->get();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ class SubTaskController extends Controller
|
|||||||
|
|
||||||
} else if (isset($parameters['user_id'])) {
|
} else if (isset($parameters['user_id'])) {
|
||||||
$subtasks = SubTask::where('user_id', $parameters['user_id'])->whereHas('timeblocks', function ($query) use ($parameters) {
|
$subtasks = SubTask::where('user_id', $parameters['user_id'])->whereHas('timeblocks', function ($query) use ($parameters) {
|
||||||
$query->where('start', '>=', $parameters['start']);
|
$query->where('start', '>', $parameters['start']);
|
||||||
$query->where('end', '<=', $parameters['end']);
|
$query->where('end', '<=', $parameters['end']);
|
||||||
})->get();
|
})->get();
|
||||||
|
|
||||||
@@ -222,6 +222,7 @@ class SubTaskController extends Controller
|
|||||||
$data['data'] = $request->all()['data'];
|
$data['data'] = $request->all()['data'];
|
||||||
$data['data']['user_id'] = $request->all()['data']['employee_id'];
|
$data['data']['user_id'] = $request->all()['data']['employee_id'];
|
||||||
$data['data']['estimated_time'] = $request->all()['data']['duration'];
|
$data['data']['estimated_time'] = $request->all()['data']['duration'];
|
||||||
|
$data['data']['updated_by'] = User::getUserIdFromBearerToken($request->bearerToken());
|
||||||
|
|
||||||
$request->merge($data);
|
$request->merge($data);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\SubTaskDeleted;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
// naschval nedavam implement ShouldQueue, pretoze bol problem s tym, ze subtask uz neexistoval
|
||||||
|
class SendDeletedSubTaskNotification
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(SubTaskDeleted $event)
|
||||||
|
{
|
||||||
|
$receiversArray[] = $event->subtask->user->email;
|
||||||
|
$receiversArray[] = \App\Models\User::find($event->subtask->created_by)->email;
|
||||||
|
|
||||||
|
Mail::to( $receiversArray )->send( new \App\Mail\SubTaskDeleted( $event->subtask ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,9 @@ namespace App\Listeners;
|
|||||||
|
|
||||||
use App\Events\MasterTaskEdited;
|
use App\Events\MasterTaskEdited;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
class SendEditedMasterTaskNotification
|
class SendEditedMasterTaskNotification implements ShouldQueue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
@@ -29,11 +28,22 @@ class SendEditedMasterTaskNotification
|
|||||||
{
|
{
|
||||||
$difference = [];
|
$difference = [];
|
||||||
|
|
||||||
|
$editedMasterTaskArray = $event->mastertask->toArray();
|
||||||
|
$originalMasterTaskArray = $event->originalMastertask;
|
||||||
|
|
||||||
|
// unset key from array
|
||||||
|
unset($editedMasterTaskArray['created_at']);
|
||||||
|
unset($editedMasterTaskArray['updated_at']);
|
||||||
|
unset($editedMasterTaskArray['subtasks']);
|
||||||
|
|
||||||
|
unset($originalMasterTaskArray['created_at']);
|
||||||
|
unset($originalMasterTaskArray['updated_at']);
|
||||||
|
|
||||||
// get the difference between $mastertask and $originalMastertask
|
// get the difference between $mastertask and $originalMastertask
|
||||||
$modelDiff = array_diff($event->mastertask->toArray(), $event->originalMastertask);
|
$modelDiff = array_diff_assoc($editedMasterTaskArray, $originalMasterTaskArray);
|
||||||
|
|
||||||
foreach ( $modelDiff as $key => $diff ) {
|
foreach ( $modelDiff as $key => $diff ) {
|
||||||
if (in_array($key, ['created_at', 'updated_at', 'status'])) {
|
if (in_array($key, ['status'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +51,9 @@ class SendEditedMasterTaskNotification
|
|||||||
if ($key == 'is_finished' && $diff == 0) {
|
if ($key == 'is_finished' && $diff == 0) {
|
||||||
foreach ( $event->mastertask->subtasks as $subtask ) {
|
foreach ( $event->mastertask->subtasks as $subtask ) {
|
||||||
// Mail::to( $subtask->user->email )->send( new \App\Mail\MasterTaskEdited( $event->mastertask, $difference ) );
|
// Mail::to( $subtask->user->email )->send( new \App\Mail\MasterTaskEdited( $event->mastertask, $difference ) );
|
||||||
Mail::to( 'feher@studiotem.com' )->send( new \App\Mail\MasterTaskEdited( $event->mastertask, $difference ) );
|
Mail::to( 'feher@studiotem.com' )->send( new \App\Mail\MasterTaskReopened( $event->mastertask ) );
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\SubTaskEdited;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
class SendEditedSubTaskNotification
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(SubTaskEdited $event)
|
||||||
|
{
|
||||||
|
// emailova notifikacia sa posiela len ak subtask bol upraveny inym uzivatelom
|
||||||
|
if ($event->subtask->updated_by == $event->subtask->user_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$difference = [];
|
||||||
|
|
||||||
|
$editedSubTaskArray = $event->subtask->toArray();
|
||||||
|
$originalSubTaskArray = $event->originalSubtask;
|
||||||
|
|
||||||
|
// unset key from array
|
||||||
|
unset($editedSubTaskArray['created_at']);
|
||||||
|
unset($editedSubTaskArray['updated_at']);
|
||||||
|
unset($editedSubTaskArray['timesheets']);
|
||||||
|
unset($editedSubTaskArray['timeblocks']);
|
||||||
|
|
||||||
|
unset($originalSubTaskArray['created_at']);
|
||||||
|
unset($originalSubTaskArray['updated_at']);
|
||||||
|
unset($originalSubTaskArray['timesheets']);
|
||||||
|
unset($originalSubTaskArray['timeblocks']);
|
||||||
|
|
||||||
|
// get the difference between $subtask and $originalSubtask
|
||||||
|
$modelDiff = array_diff_assoc($editedSubTaskArray, $originalSubTaskArray);
|
||||||
|
|
||||||
|
foreach ( $modelDiff as $key => $diff ) {
|
||||||
|
if (in_array($key, ['status', 'tracked_time'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$difference[$key] = $diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($difference)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mail::to( $subtask->user->email )->send( new \App\Mail\SubTaskEdited( $event->subtask, $difference ) );
|
||||||
|
Mail::to( 'feher@studiotem.com' )->send( new \App\Mail\SubTaskEdited( $event->subtask, $difference ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -9,7 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
class SendNewTaskEmailNotification implements ShouldQueue
|
class SendNewSubTaskEmailNotification implements ShouldQueue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Models\MasterTask;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class MasterTaskReopened extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $mastertask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(MasterTask $mastertask)
|
||||||
|
{
|
||||||
|
$this->mastertask = $mastertask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Envelope
|
||||||
|
*/
|
||||||
|
public function envelope()
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Master Task ' . $this->mastertask->title . ' was reopened',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Content
|
||||||
|
*/
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: 'emails.task.master_task_reopened',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attachments()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,7 +46,7 @@ class NewTask extends Mailable
|
|||||||
public function content()
|
public function content()
|
||||||
{
|
{
|
||||||
return new Content(
|
return new Content(
|
||||||
view: 'emails.task.new_task_created',
|
view: 'emails.task.sub_task_created',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Models\SubTask;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class SubTaskDeleted extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $subtask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(SubTask $subtask)
|
||||||
|
{
|
||||||
|
$this->subtask = $subtask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Envelope
|
||||||
|
*/
|
||||||
|
public function envelope()
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Sub Task ' . $this->subtask->mastertask->title . ' was deleted',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Content
|
||||||
|
*/
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: 'emails.task.sub_task_deleted',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attachments()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Models\SubTask;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class SubTaskEdited extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $subtask;
|
||||||
|
public $difference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(SubTask $subtask, array $difference)
|
||||||
|
{
|
||||||
|
$this->subtask = $subtask;
|
||||||
|
$this->difference = $difference;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Envelope
|
||||||
|
*/
|
||||||
|
public function envelope()
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Sub Task Edited',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Mail\Mailables\Content
|
||||||
|
*/
|
||||||
|
public function content()
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: 'emails.task.sub_task_edited',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attachments()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Observers;
|
namespace App\Observers;
|
||||||
|
|
||||||
use App\Events\SubTaskCreated;
|
use App\Events\SubTaskCreated;
|
||||||
|
use App\Events\SubTaskDeleted;
|
||||||
|
use App\Events\SubTaskEdited;
|
||||||
use App\Models\SubTask;
|
use App\Models\SubTask;
|
||||||
|
|
||||||
class SubTaskObserver
|
class SubTaskObserver
|
||||||
@@ -24,6 +26,8 @@ class SubTaskObserver
|
|||||||
$subTask->created_by = $subTask->getOriginal('created_by');
|
$subTask->created_by = $subTask->getOriginal('created_by');
|
||||||
|
|
||||||
$subTask->tracked_time = $subTask->timesheets->sum('time');
|
$subTask->tracked_time = $subTask->timesheets->sum('time');
|
||||||
|
|
||||||
|
SubTaskEdited::dispatch($subTask, $subTask->getOriginal());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +50,7 @@ class SubTaskObserver
|
|||||||
*/
|
*/
|
||||||
public function deleted(SubTask $subTask)
|
public function deleted(SubTask $subTask)
|
||||||
{
|
{
|
||||||
//
|
SubTaskDeleted::dispatch($subTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ namespace App\Providers;
|
|||||||
|
|
||||||
use App\Events\MasterTaskEdited;
|
use App\Events\MasterTaskEdited;
|
||||||
use App\Events\SubTaskCreated;
|
use App\Events\SubTaskCreated;
|
||||||
|
use App\Events\SubTaskDeleted;
|
||||||
|
use App\Events\SubTaskEdited;
|
||||||
|
use App\Listeners\SendDeletedSubTaskNotification;
|
||||||
use App\Listeners\SendEditedMasterTaskNotification;
|
use App\Listeners\SendEditedMasterTaskNotification;
|
||||||
use App\Listeners\SendNewTaskEmailNotification;
|
use App\Listeners\SendEditedSubTaskNotification;
|
||||||
|
use App\Listeners\SendNewSubTaskEmailNotification;
|
||||||
use App\Models\MasterTask;
|
use App\Models\MasterTask;
|
||||||
use App\Models\SubTask;
|
use App\Models\SubTask;
|
||||||
use App\Observers\MasterTaskObserver;
|
use App\Observers\MasterTaskObserver;
|
||||||
@@ -27,9 +31,15 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
SendEmailVerificationNotification::class,
|
SendEmailVerificationNotification::class,
|
||||||
],
|
],
|
||||||
SubTaskCreated::class => [
|
SubTaskCreated::class => [
|
||||||
SendNewTaskEmailNotification::class,
|
SendNewSubTaskEmailNotification::class,
|
||||||
//LogEvent::class,
|
//LogEvent::class,
|
||||||
],
|
],
|
||||||
|
SubTaskDeleted::class => [
|
||||||
|
SendDeletedSubTaskNotification::class
|
||||||
|
],
|
||||||
|
SubTaskEdited::class => [
|
||||||
|
SendEditedSubTaskNotification::class
|
||||||
|
],
|
||||||
MasterTaskEdited::class => [
|
MasterTaskEdited::class => [
|
||||||
SendEditedMasterTaskNotification::class
|
SendEditedMasterTaskNotification::class
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -68,9 +68,11 @@ class Api
|
|||||||
|
|
||||||
public static function setTimesheet($timesheet)
|
public static function setTimesheet($timesheet)
|
||||||
{
|
{
|
||||||
|
echo 'Setting timesheet for project ' . $timesheet->subtask->mastertask->project->code . PHP_EOL;
|
||||||
|
|
||||||
$body = [
|
$body = [
|
||||||
'command' => 'TM_SET_vykaz',
|
'command' => 'TM_SET_vykaz',
|
||||||
'zakazka' => $timesheet->subtask->project->code,
|
'zakazka' => $timesheet->subtask->mastertask->project->code,
|
||||||
'zdroj' => $timesheet->user->code,
|
'zdroj' => $timesheet->user->code,
|
||||||
'hodin' => $timesheet->time,
|
'hodin' => $timesheet->time,
|
||||||
'datum' => $timesheet->created_at->format('Y-m-d'),
|
'datum' => $timesheet->created_at->format('Y-m-d'),
|
||||||
|
|||||||
@@ -134,6 +134,9 @@ class KaratService
|
|||||||
$notSyncedTimesheets = Timesheet::whereNull('synced_to_karat')->get();
|
$notSyncedTimesheets = Timesheet::whereNull('synced_to_karat')->get();
|
||||||
|
|
||||||
$notSyncedTimesheets->each(function ($timesheet) {
|
$notSyncedTimesheets->each(function ($timesheet) {
|
||||||
|
if (!$timesheet->subtask || !$timesheet->subtask->mastertask->project)
|
||||||
|
return false;
|
||||||
|
|
||||||
$this->syncTimesheet($timesheet);
|
$this->syncTimesheet($timesheet);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -141,7 +144,7 @@ class KaratService
|
|||||||
private function syncTimesheet(Timesheet $timesheet) {
|
private function syncTimesheet(Timesheet $timesheet) {
|
||||||
$this->api->setTimesheet($timesheet);
|
$this->api->setTimesheet($timesheet);
|
||||||
|
|
||||||
$timesheet->synced_to_karat = true;
|
$timesheet->synced_to_karat = Carbon::now();
|
||||||
$timesheet->save();
|
$timesheet->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('sub_tasks', function (Blueprint $table) {
|
||||||
|
$table->foreignIdFor( \App\Models\User::class, 'updated_by')->after('updated_at')->nullable()->default(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('subtask', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Master Task {{$mastertask->title}} was reopened. <br><br>
|
||||||
File renamed without changes.
@@ -0,0 +1 @@
|
|||||||
|
Sub Task {{$subtask->mastertask->title}} was deleted. <br><br>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Sub Task edited. <br><br>
|
||||||
|
|
||||||
|
Edited fields: <br> <br>
|
||||||
|
@foreach($difference as $key => $diff)
|
||||||
|
{{ $key }}: {{ $diff }} <br>
|
||||||
|
@endforeach
|
||||||
Reference in new issue
Block a user