adjust UI, add send mail when delete note/update refuse ticket
This commit is contained in:
parent
27b59ae939
commit
705e8f9216
|
|
@ -397,6 +397,31 @@ class TicketController extends Controller
|
||||||
// Delete related note, if status change to Refuse
|
// Delete related note, if status change to Refuse
|
||||||
if ($request->status == "REFUSED") {
|
if ($request->status == "REFUSED") {
|
||||||
$ticket->status = "REFUSED";
|
$ticket->status = "REFUSED";
|
||||||
|
|
||||||
|
// Handle send mail
|
||||||
|
$dataMasterStartPeriod = CategoryController::getListMasterByCodeAndType("TIME_TYPE", $ticket->start_period);
|
||||||
|
$dataMasterEndPeriod = CategoryController::getListMasterByCodeAndType("TIME_TYPE", $ticket->end_period);
|
||||||
|
$dataMasterType = CategoryController::getListMasterByCodeAndType("REASON", $ticket->type);
|
||||||
|
$formattedStartDate = Carbon::createFromFormat('Y-m-d', $ticket->start_date)->format('d/m/Y');
|
||||||
|
$formattedEndDate = Carbon::createFromFormat('Y-m-d', $ticket->end_date)->format('d/m/Y');
|
||||||
|
|
||||||
|
$user = Admin::find($ticket->user_id);
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
"email_template" => "email.notification_tickets_user",
|
||||||
|
"user_name" => $user->name,
|
||||||
|
"email" => $user->email,
|
||||||
|
"name" => $admin->name, //name admin duyệt
|
||||||
|
"date" => $dataMasterStartPeriod->c_name . " (" . $formattedStartDate . ") - " . $dataMasterEndPeriod->c_name . " (" . $formattedEndDate . ")",
|
||||||
|
"type" => $dataMasterType->c_name,
|
||||||
|
"note" => $ticket->reason,
|
||||||
|
"admin_note" => $ticket->admin_note,
|
||||||
|
"link" => "/tickets", //link đến page admin
|
||||||
|
"status" => "refused",
|
||||||
|
"subject" => "[Ticket response] Ticket From " . $admin->name
|
||||||
|
);
|
||||||
|
Mail::to($user->email)->send(new TicketMail($data));
|
||||||
|
|
||||||
Notes::where('ticket_id', $ticket->id)->delete();
|
Notes::where('ticket_id', $ticket->id)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,9 +429,10 @@ class TicketController extends Controller
|
||||||
$ticket->admin_note = $request->admin_note;
|
$ticket->admin_note = $request->admin_note;
|
||||||
|
|
||||||
// Clear Timekeeping cache
|
// Clear Timekeeping cache
|
||||||
|
$ticket->save();
|
||||||
|
|
||||||
$this->createOrUpdateRecordForCurrentMonth(Carbon::parse($ticket->start_date)->month, Carbon::parse($ticket->start_date)->year);
|
$this->createOrUpdateRecordForCurrentMonth(Carbon::parse($ticket->start_date)->month, Carbon::parse($ticket->start_date)->year);
|
||||||
$this->createOrUpdateRecordForCurrentMonth(Carbon::parse($ticket->end_date)->month, Carbon::parse($ticket->end_date)->year);
|
$this->createOrUpdateRecordForCurrentMonth(Carbon::parse($ticket->end_date)->month, Carbon::parse($ticket->end_date)->year);
|
||||||
$ticket->save();
|
|
||||||
|
|
||||||
return AbstractController::ResultSuccess($ticket, "Ticket updated successfully!");
|
return AbstractController::ResultSuccess($ticket, "Ticket updated successfully!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ use App\Traits\HasOrderByRequest;
|
||||||
use App\Traits\HasSearchRequest;
|
use App\Traits\HasSearchRequest;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use App\Mail\TicketMail;
|
||||||
use Modules\Admin\app\Models\Admin;
|
use Modules\Admin\app\Models\Admin;
|
||||||
use Modules\Admin\app\Models\MonthlyTimekeeping;
|
use Modules\Admin\app\Models\MonthlyTimekeeping;
|
||||||
use Modules\Admin\app\Models\Tracking;
|
use Modules\Admin\app\Models\Tracking;
|
||||||
|
|
@ -184,10 +185,35 @@ class TimekeepingController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin = auth('admins')->user();
|
$admin = auth('admins')->user();
|
||||||
|
|
||||||
|
// Handle send mail
|
||||||
|
$dataMasterStartPeriod = CategoryController::getListMasterByCodeAndType("TIME_TYPE", $ticket->start_period);
|
||||||
|
$dataMasterEndPeriod = CategoryController::getListMasterByCodeAndType("TIME_TYPE", $ticket->end_period);
|
||||||
|
$dataMasterType = CategoryController::getListMasterByCodeAndType("REASON", $ticket->type);
|
||||||
|
$formattedStartDate = Carbon::createFromFormat('Y-m-d', $ticket->start_date)->format('d/m/Y');
|
||||||
|
$formattedEndDate = Carbon::createFromFormat('Y-m-d', $ticket->end_date)->format('d/m/Y');
|
||||||
|
|
||||||
|
$user = Admin::find($ticket->user_id);
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
"email_template" => "email.notification_tickets_user",
|
||||||
|
"user_name" => $user->name,
|
||||||
|
"email" => $user->email,
|
||||||
|
"name" => $admin->name, //name admin duyệt
|
||||||
|
"date" => $dataMasterStartPeriod->c_name . " (" . $formattedStartDate . ") - " . $dataMasterEndPeriod->c_name . " (" . $formattedEndDate . ")",
|
||||||
|
"type" => $dataMasterType->c_name,
|
||||||
|
"note" => $ticket->reason,
|
||||||
|
"admin_note" => $ticket->admin_note,
|
||||||
|
"link" => "/tickets", //link đến page admin
|
||||||
|
"status" => "refused",
|
||||||
|
"subject" => "[Ticket response] Ticket From " . $admin->name
|
||||||
|
);
|
||||||
|
Mail::to($user->email)->send(new TicketMail($data));
|
||||||
|
|
||||||
|
// Update
|
||||||
$ticket->updated_by = $admin->name;
|
$ticket->updated_by = $admin->name;
|
||||||
$ticket->status = "REFUSED";
|
$ticket->status = "REFUSED";
|
||||||
$ticket->save();
|
$ticket->save();
|
||||||
|
|
||||||
Notes::where('ticket_id', $ticket->id)->delete();
|
Notes::where('ticket_id', $ticket->id)->delete();
|
||||||
|
|
||||||
// Clear Timekeeping cache
|
// Clear Timekeeping cache
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ class UserController extends Controller
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
$this->createOrUpdateRecordForCurrentMonth(Carbon::now()->month, Carbon::now()->year);
|
||||||
|
|
||||||
$user_res = [
|
$user_res = [
|
||||||
'name' => $user->name,
|
'name' => $user->name,
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
DB::table('categories')->insert([
|
|
||||||
[
|
|
||||||
'c_code' => 'PERMANENT',
|
|
||||||
'c_name' => 'Phép cộng nhân viên chính thức',
|
|
||||||
'c_type' => 'PERMANENT_ONLEAVE',
|
|
||||||
'c_value' => 3,
|
|
||||||
'c_active' => 1,
|
|
||||||
'created_at' => now(),
|
|
||||||
'updated_at' => now(),
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
DB::table('categories')->where('c_code', 'PERMANENT')->delete();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -13,6 +13,15 @@ return new class extends Migration
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
DB::table('categories')->insert([
|
DB::table('categories')->insert([
|
||||||
|
[
|
||||||
|
'c_code' => 'PERMANENT',
|
||||||
|
'c_name' => 'Phép cộng nhân viên chính thức',
|
||||||
|
'c_type' => 'PERMANENT_ONLEAVE',
|
||||||
|
'c_value' => 1,
|
||||||
|
'c_active' => 1,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now(),
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'c_code' => 'TEMPORARY_ONLEAVE',
|
'c_code' => 'TEMPORARY_ONLEAVE',
|
||||||
'c_name' => 'Nghỉ dự kiến',
|
'c_name' => 'Nghỉ dự kiến',
|
||||||
|
|
@ -30,6 +39,7 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
DB::table('categories')->where('c_code', 'TEMPORARY_ONLEAVE')->delete();
|
DB::table('categories')->where('c_code', 'PERMANENT')->where('c_type', 'PERMANENT_ONLEAVE')->delete();
|
||||||
|
DB::table('categories')->where('c_code', 'TEMPORARY_ONLEAVE')->where('c_type', 'REASON_NOTES')->delete();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -711,7 +711,7 @@ const LeaveManagement = () => {
|
||||||
return (
|
return (
|
||||||
<Table.Td
|
<Table.Td
|
||||||
bg={total > 0 ? '#ffb5b5' : ''}
|
bg={total > 0 ? '#ffb5b5' : ''}
|
||||||
opacity={d.value > currentMonth ? 0.6 : 1}
|
opacity={d.value > currentMonth ? 0.4 : 1}
|
||||||
key={i}
|
key={i}
|
||||||
ta={'center'}
|
ta={'center'}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ const Timekeeping = () => {
|
||||||
const [exportOption, setExportOption] = useState('default')
|
const [exportOption, setExportOption] = useState('default')
|
||||||
|
|
||||||
const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = useState(false)
|
const [isDeleteConfirmOpen, setIsDeleteConfirmOpen] = useState(false)
|
||||||
|
const [isDisableDeleteBtn, setIsDisableDeleteBtn] = useState(false)
|
||||||
const [noteToDelete, setNoteToDelete] = useState<any>(null)
|
const [noteToDelete, setNoteToDelete] = useState<any>(null)
|
||||||
|
|
||||||
const getListMasterByType = async (type: string) => {
|
const getListMasterByType = async (type: string) => {
|
||||||
|
|
@ -467,7 +468,9 @@ const Timekeeping = () => {
|
||||||
|
|
||||||
const handleConfirmDelete = async () => {
|
const handleConfirmDelete = async () => {
|
||||||
if (noteToDelete) {
|
if (noteToDelete) {
|
||||||
|
setIsDisableDeleteBtn(true)
|
||||||
await handleDelete(noteToDelete.id)
|
await handleDelete(noteToDelete.id)
|
||||||
|
setIsDisableDeleteBtn(false)
|
||||||
setIsDeleteConfirmOpen(false)
|
setIsDeleteConfirmOpen(false)
|
||||||
setNoteToDelete(null)
|
setNoteToDelete(null)
|
||||||
}
|
}
|
||||||
|
|
@ -506,10 +509,15 @@ const Timekeeping = () => {
|
||||||
setIsDeleteConfirmOpen(false)
|
setIsDeleteConfirmOpen(false)
|
||||||
setNoteToDelete(null)
|
setNoteToDelete(null)
|
||||||
}}
|
}}
|
||||||
|
disabled={isDisableDeleteBtn}
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={classes.deleteButton} onClick={handleConfirmDelete}>
|
<Button
|
||||||
|
className={classes.deleteButton}
|
||||||
|
onClick={handleConfirmDelete}
|
||||||
|
disabled={isDisableDeleteBtn}
|
||||||
|
>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue