Merge branch 'master' into truong-sprint-1
This commit is contained in:
commit
26b8c724fe
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Admin\app\Http\Controllers;
|
||||
|
||||
use App\Helper\Cache\CurrentMonthTimekeeping;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Notes;
|
||||
use App\Traits\AnalyzeData;
|
||||
use App\Traits\HasFilterRequest;
|
||||
use App\Traits\HasOrderByRequest;
|
||||
use App\Traits\HasSearchRequest;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TicketController extends Controller
|
||||
{
|
||||
use HasOrderByRequest;
|
||||
use HasFilterRequest;
|
||||
use HasSearchRequest;
|
||||
use AnalyzeData;
|
||||
|
||||
public function get(Request $request)
|
||||
{
|
||||
// Get data tickets and user -> pagination, orderby 'desc', filter: fromDate, toDate, status, type, name
|
||||
}
|
||||
|
||||
public function createTicket(Request $request){
|
||||
//Get data from request
|
||||
$startDate = $request->input('start_date'); //Start day
|
||||
$startPeriod = $request->input('start_period'); //The session begins
|
||||
$endDate = $request->input('end_date'); //End date
|
||||
$endPeriod = $request->input('end_period'); //Session ends
|
||||
$user_id = $request->input('user_id'); // ID user create ticket
|
||||
$results = $this->getAllPeriod($startDate, $startPeriod, $endDate, $endPeriod);
|
||||
}
|
||||
|
||||
public function deleteTicket(Request $request){
|
||||
$user = auth('admins')->user();
|
||||
$ticket_id = $request->input('ticket_id');
|
||||
|
||||
// $user->id == user_id of ticket ---> delete
|
||||
|
||||
// else false
|
||||
}
|
||||
|
||||
public function handleTicket(Request $request){
|
||||
|
||||
$ticket_id = $request->input('ticket_id');
|
||||
$admin_note = $request->input('admin_note');
|
||||
$action = $request->input('action'); // 'confirm' or 'refuse'
|
||||
$admin = auth('admins')->user();
|
||||
|
||||
// $admin->id != user_id of ticket ---> continue
|
||||
// Confirm
|
||||
// Add records to the notes table like function Timekeeping.addNoteForUser() based on the $results array
|
||||
|
||||
// Update updated_by and admin_note in tickets table
|
||||
|
||||
// Send notification email to admin (list) and users
|
||||
|
||||
// Refuse
|
||||
// Update updated_by and admin_note in tickets table
|
||||
|
||||
// Send notification email to admin (list) and users
|
||||
|
||||
// false
|
||||
}
|
||||
|
||||
private function getAllPeriod($startDate, $startPeriod, $endDate, $endPeriod)
|
||||
{
|
||||
//Create an array to contain the results
|
||||
$results = [];
|
||||
|
||||
//Use CarbonPeriod to create a period from the start date to the end date
|
||||
$period = CarbonPeriod::create($startDate, $endDate);
|
||||
|
||||
foreach ($period as $date) {
|
||||
//If it is the start date
|
||||
if ($date->isSameDay($startDate)) {
|
||||
//Add start session
|
||||
$results[] = ['date' => $date->toDateString(), 'period' => $startPeriod];
|
||||
//If the start date is morning, add afternoon
|
||||
if ($startPeriod == 'morning') {
|
||||
$results[] = ['date' => $date->toDateString(), 'period' => 'afternoon'];
|
||||
}
|
||||
} elseif ($date->isSameDay($endDate)) {
|
||||
//If it is the end date
|
||||
//If the end session is afternoon, add morning first
|
||||
if ($endPeriod == 'afternoon') {
|
||||
$results[] = ['date' => $date->toDateString(), 'period' => 'morning'];
|
||||
}
|
||||
$results[] = ['date' => $date->toDateString(), 'period' => $endPeriod];
|
||||
} else {
|
||||
//Add both sessions for days between intervals
|
||||
$results[] = ['date' => $date->toDateString(), 'period' => 'morning'];
|
||||
$results[] = ['date' => $date->toDateString(), 'period' => 'afternoon'];
|
||||
}
|
||||
}
|
||||
|
||||
//Returns results
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,8 +16,6 @@ use Modules\Admin\app\Models\Admin;
|
|||
use Modules\Admin\app\Models\MonthlyTimekeeping;
|
||||
use Modules\Admin\app\Models\Tracking;
|
||||
|
||||
use function PHPSTORM_META\type;
|
||||
|
||||
class TimekeepingController extends Controller
|
||||
{
|
||||
use HasOrderByRequest;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\Admin\app\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use App\Traits\HasCacheModel;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasCacheModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'tickets';
|
||||
$this->guarded = [];
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ use Modules\Admin\app\Http\Controllers\DashboardController;
|
|||
use Modules\Admin\app\Http\Controllers\JiraController;
|
||||
use Modules\Admin\app\Http\Controllers\LeaveManagementController;
|
||||
use Modules\Admin\app\Http\Controllers\SettingController;
|
||||
use Modules\Admin\app\Http\Controllers\TicketController;
|
||||
use Modules\Admin\app\Http\Controllers\TimekeepingController;
|
||||
use Modules\Admin\app\Http\Controllers\TrackingController;
|
||||
use Modules\Admin\app\Http\Middleware\AdminMiddleware;
|
||||
|
|
@ -125,7 +126,6 @@ Route::middleware('api')
|
|||
'prefix' => 'category',
|
||||
], function () {
|
||||
Route::get('/get-list-master', [CategoryController::class, 'getListMaster']);
|
||||
|
||||
});
|
||||
|
||||
Route::group([
|
||||
|
|
@ -133,7 +133,15 @@ Route::middleware('api')
|
|||
], function () {
|
||||
Route::get('/', [LeaveManagementController::class, 'get'])->middleware('check.permission:admin.hr.staff');
|
||||
Route::post('/saveNoteLeave', [LeaveManagementController::class, 'saveNoteLeave'])->middleware('check.permission:admin.hr');
|
||||
});
|
||||
|
||||
Route::group([
|
||||
'prefix' => 'ticket',
|
||||
], function () {
|
||||
Route::get('/', [TicketController::class, 'get']);
|
||||
Route::post('/create', [TrackingController::class, 'createTicket'])->middleware('check.permission:admin.hr.staff');
|
||||
Route::get('/delete', [TrackingController::class, 'deleteTicket'])->middleware('check.permission:admin.hr.staff');
|
||||
Route::post('/handle-ticket', [TrackingController::class, 'handleTicket'])->middleware('check.permission:admin');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tickets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('user_id');
|
||||
$table->timestamps('start_date');
|
||||
$table->string('start_period');
|
||||
$table->timestamps('end_date');
|
||||
$table->string('end_period');
|
||||
$table->string('type');
|
||||
$table->string('reason');
|
||||
$table->string('admin_note')->nullable();
|
||||
$table->string('updated_by');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tickets');
|
||||
}
|
||||
};
|
||||
|
|
@ -23,11 +23,14 @@ import {
|
|||
} from '@mantine/core'
|
||||
import { useDisclosure } from '@mantine/hooks'
|
||||
import { notifications } from '@mantine/notifications'
|
||||
import { IconCheck, IconExclamationMark, IconX } from '@tabler/icons-react'
|
||||
import {
|
||||
IconCheck,
|
||||
IconExclamationMark,
|
||||
IconPointFilled,
|
||||
IconX
|
||||
} from '@tabler/icons-react'
|
||||
import moment from 'moment'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Popover, PopoverBody } from 'reactstrap'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import classes from './Timekeeping.module.css'
|
||||
|
||||
|
|
@ -762,8 +765,10 @@ const Timekeeping = () => {
|
|||
{daysInMonth.map((d) => {
|
||||
var total =
|
||||
user.history.find((h) => h.day === d)?.total ?? 0
|
||||
var notes = user.history.find((h) => h.day === d)?.notes
|
||||
return (
|
||||
<Table.Td
|
||||
pos={'relative'}
|
||||
key={d}
|
||||
ta={'center'}
|
||||
bg={
|
||||
|
|
@ -774,6 +779,14 @@ const Timekeeping = () => {
|
|||
: ''
|
||||
}
|
||||
>
|
||||
<Box
|
||||
pos={'absolute'}
|
||||
top={-3}
|
||||
right={-3}
|
||||
display={notes && notes.length > 0 ? 'block' : 'none'}
|
||||
>
|
||||
<IconPointFilled width={15} height={15} style={{color:"#2767e1"}} />
|
||||
</Box>
|
||||
{total / 60 / 60 < 7 &&
|
||||
user.history.find(
|
||||
(h) => h.day === d && h.values && h.values.length > 0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue