Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azrul #142

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Azrul #142

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a66fb01
removed tables
MAsraf Mar 19, 2024
dfdd1ae
+feat. announcement banner
MAsraf Mar 20, 2024
a36bae9
fix: notice banner create & edit
MAsraf Mar 25, 2024
d043c7e
fix: Ticket Log Activity
MAsraf Mar 26, 2024
1e084c5
fix: update ticket details
MAsraf Apr 2, 2024
2aaa2d4
.ft category
MAsraf Apr 29, 2024
773c53b
Merge pull request #1 from MAsraf/myip
MAsraf Apr 29, 2024
8bcb78a
v1.2
MAsraf May 24, 2024
40c815b
Update .env.example
MAsraf Jun 7, 2024
8043cf5
fix: modal edit disappearing
MAsraf Jun 10, 2024
fb17f2d
feat: better routing & dynamic options
MAsraf Jun 12, 2024
87c166a
feat: Auto-set "In Progress" status on Responsible selection.
MAsraf Jun 12, 2024
83bb9ae
Fix: category & subcategory function
MAsraf Jun 13, 2024
687cc62
Modify some layout and analytic
MAsraf Jun 14, 2024
1577afe
Update LogsActivity.php
MAsraf Jun 14, 2024
5653865
feat: digest notifications
MAsraf Jun 24, 2024
d27c36d
notifications type arranged
MAsraf Jun 24, 2024
99389df
preparation for ticket date picker analysis
MAsraf Jun 25, 2024
fbb4697
feat: Ticket analysis trend
MAsraf Jun 28, 2024
cd6c6d3
feat: added 2 new ticket analytics
MAsraf Jul 4, 2024
6c56a68
Merge pull request #2 from MAsraf/Ticket-Analytics
MAsraf Jul 4, 2024
a06d8fc
feat: added issues to categories
MAsraf Jul 9, 2024
943beb0
feat: improve analysis & add issues & add button to announcement
MAsraf Jul 11, 2024
9d5fc66
Announcement, analytics & ticket details
MAsraf Jul 15, 2024
e05943a
v1.3
MAsraf Jul 19, 2024
5c268ac
Merge pull request #3 from MAsraf/Ticket-Analytics
MAsraf Jul 19, 2024
5b93b71
v1.4
MAsraf Jul 23, 2024
0f5aaae
Update category.blade.php
azrulshah Jul 26, 2024
d0d31e1
Update category.blade.php
azrulshah Jul 26, 2024
5de3b67
Merge branch 'master' into azrul
azrulshah Jul 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ APP_NAME="Help Desk"
APP_ENV=local
APP_KEY=base64:l6QSYbX2+PeHu73W376Ijo2QbyeMIIOa6/vg60A7uGY=
APP_DEBUG=true
APP_URL=http://localhost
APP_URL=172.0.0.1

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=help_desk
DB_USERNAME=sail
DB_PASSWORD=password
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
Expand All @@ -29,13 +29,13 @@ REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
MAIL_HOST=mail.myipo.gov.my
MAIL_PORT=587
MAIL_USERNAME=[email protected]
MAIL_PASSWORD=MyIPO@@2024
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="Helpdesk MyIPO"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
Expand Down
56 changes: 56 additions & 0 deletions app/Class/SendDigestNotifications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Class;

use App\Models\User;
use Filament\Notifications\Notification;
use App\Notifications\SummaryNotification;

class SendDigestNotifications
{
public function __invoke()
{

$users = User::all(); // Or a more specific query to target users with pending notifications

foreach ($users as $user) {
$notifications = $user->unreadNotifications; // Get unread notifications
$temp = $notifications;
// Aggregate notifications based on your criteria
$groupedNotifications = $notifications->groupBy(function ($notification) {
return $notification->type;
});

foreach ($groupedNotifications as $type => $temp) {
if($temp->first()->type == "App\\Notifications\\SummaryNotification"){
continue;
}
// // Create a summary notification for each group
$summary = $this->createSummary($temp);

// // // Send the summary notification
$user->notify(new SummaryNotification($summary));

// // // Mark the individual notifications as read
}
foreach ($user->unreadNotifications as $notification) {
if($notification->type != "App\\Notifications\\SummaryNotification"){
$notification->delete();
}
}
}

}

protected function createSummary($notifications)
{
// Logic to create a summary from a group of notifications
$summary = [
'count' => $notifications->count(),
'type' => $notifications->first()->type,
'messages' => $notifications->pluck('data')->toArray(), // Assuming 'message' is an attribute in notification data
];

return $summary;
}
}
13 changes: 12 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Class\SendDigestNotifications;

class Kernel extends ConsoleKernel
{
Expand All @@ -15,7 +16,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->call(new SendDigestNotifications)->everyFiveMinute();
}

/**
Expand All @@ -29,4 +30,14 @@ protected function commands()

require base_path('routes/console.php');
}

/**
* Get the timezone that should be used by default for scheduled events.
*
* @return \DateTimeZone|string|null
*/
protected function scheduleTimezone()
{
return 'Asia/Kuala_Lumpur';
}
}
46 changes: 44 additions & 2 deletions app/Core/LogsActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Support\HtmlString;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity as BaseLogsActivity;
use App\Models\User;

trait LogsActivity
{
Expand All @@ -20,7 +21,45 @@ public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logOnly($this->getFillable())
->setDescriptionForEvent(fn(string $eventName) => new HtmlString(
->setDescriptionForEvent(function(string $eventName) {


// Define attributes to exclude from the change log
$excludedAttributes = ['updated_at', 'created_at', 'deleted_at'];


// Get changes and original values
$changes = array_diff_key($this->getDirty(), array_flip($excludedAttributes));
$originals = array_diff_key($this->getOriginal(), array_flip($excludedAttributes));


// Generate changes description
$changesDescription = '';
foreach ($changes as $key => $value) {
$originalValue = $originals[$key] ?? 'null';
if($key=="responsible_id")
{
// Fetch the responsible user based on the current responsible_id
$responsibleUserOld = User::withTrashed()->find($originalValue);

// Get the responsible user's name if available
$responsibleUserNameOld = $responsibleUserOld ? $responsibleUserOld->name : 'None';

// Fetch the responsible user based on the current responsible_id
$responsibleUserNew = User::withTrashed()->find($value);

// Get the responsible user's name if available
$responsibleUserNameNew = $responsibleUserNew ? $responsibleUserNew->name : 'Unknown User';
$changesDescription .= "Responsible: {$responsibleUserNameOld} to {$responsibleUserNameNew} ";
continue;
}
$changesDescription .= "{$key}: '{$originalValue}' => '{$value}' ";
}
if($eventName == "created"){
$changesDescription = "" ;
}
// Generate the description
return new HtmlString(
'<div class="flex flex-col gap-1">'
. (auth()->user()->name ?? '')
. " "
Expand All @@ -29,13 +68,16 @@ public function getActivitylogOptions(): LogOptions
. $this->fromCamelCase((new \ReflectionClass($this))->getShortName())
. " "
. $this
. "<br>"
. $changesDescription
. ' <a class="text-primary-500 hover:underline hover:cursor-pointer"
target="_blank"
href="' . $this->activityLogLink() . '">
' . __('See details')
. '</a>'
. '</div>'
));
);
});
}

/**
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/TicketNumberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function __invoke(string $number)
$ticketPrefix = substr($number, 0, 4);
$ticketNumber = str_replace($ticketPrefix, "", $number);
$ticket = Ticket::where('number', $ticketNumber)
->whereHas('project', fn($query) => $query->where('ticket_prefix', $ticketPrefix))
->first();
if ($ticket) {
return redirect()->route('tickets.details', [
Expand Down
Loading