Merge remote-tracking branch 'origin/staging' into origin/production

This commit is contained in:
Server D3 Linksehat
2025-01-23 15:41:30 +07:00
11 changed files with 1336 additions and 0 deletions

View File

@@ -0,0 +1,239 @@
<?php
namespace Modules\Internal\Http\Controllers\Api;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\DB;
use App\Helpers\Helper;
use App\Models\OLDLMS\DoctorRating;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
use Box\Spout\Common\Entity\Style\CellAlignment;
class DoctorOnlineController extends Controller
{
/**
* Display a listing of the resource.
* @param int|null $id
* @return \Illuminate\Http\JsonResponse
*/
public function index($id = null)
{
$query = DoctorRating::query();
if ($id !== null) {
$query->where('nID', $id);
}
$doctorRatings = $query->with([
'user' => function ($query) {
$query->select('nID', 'sFirstName'); // Select only necessary columns
}
])
->select('nIDUser', 'sDate', 'sStatus')
->get();
// $prescriptions->toArray();
// dd($prescriptions);
return response()->json($doctorRatings);
// return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
}
public function getData(Request $request)
{
$limit = $request->has('per_page') ? $request->input('per_page') : 50;
$results = DB::connection('oldlms')->table('tx_users_online')
->leftJoin('tm_users', 'tx_users_online.nIDUser', '=', 'tm_users.nID')
->leftJoin('tm_dokter', 'tx_users_online.nIDUser', '=', 'tm_dokter.nIDUser')
->when($request->input('search'), function ($query, $search) {
$query->where(function ($query) use ($search) {
$query->orWhere('tm_users.sFirstname', 'like', "%" . $search . "%");
$query->orWhere('tx_users_online.sStatus', 'like', "%" . $search . "%");
});
})
->when($request->has('orderBy'), function ($query) use ($request) {
$orderBy = $request->orderBy;
$direction = $request->order ?? 'asc';
$query->orderBy($orderBy, $direction);
})
->when($request->input('start_date') , function ($query, $start_date) {
$query->where(function ($query) use ($start_date) {
$query->where('tx_users_online.sDate', '>=', $start_date. ' 00:00:00');
});
})
->when($request->input('end_date') , function ($query, $end_date) {
$query->where(function ($query) use ($end_date) {
$query->where('tx_users_online.sDate', '<=', $end_date. ' 23:59:59');
});
})
->select(
DB::connection('oldlms')->raw("CONCAT('dr. ', tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) as nama_dokter"),
'tx_users_online.sStatus',
'tx_users_online.sDate'
)
->paginate($limit);
return response()->json(Helper::paginateResources($results));
}
public function export(Request $request)
{
// Menyimpan tanggal mulai dan tanggal selesai dari request
$start_date = $request->input('start_date') ? $request->input('start_date') : 'all';
$end_date = $request->input('end_date') ? $request->input('end_date') : 'all';
// Membuat writer untuk file XLSX
$writer = WriterEntityFactory::createXLSXWriter();
// Pastikan folder 'files' ada dan bisa ditulis
$filePath = public_path('files');
if (!is_dir($filePath)) {
mkdir($filePath, 0755, true); // Membuat folder jika belum ada
}
// Menyimpan file Excel ke folder yang sesuai
$fileName = 'Report-Data-Rating-Dokter-' . $start_date . '-' . $end_date . '.xlsx';
$writer->openToFile(public_path('files/' . $fileName));
// Header Excel
$header = [
'No',
'Nama Dokter',
'Date',
'Status',
];
// Styling untuk header (bold)
$headerStyle = (new StyleBuilder())
->setFontBold() // Menambahkan font bold hanya pada header
->setCellAlignment(CellAlignment::LEFT)
->build();
// Menambahkan header ke dalam file
$headerRow = WriterEntityFactory::createRowFromArray($header, $headerStyle);
$writer->addRow($headerRow);
// Query untuk mengambil data dari database
$results = DB::connection('oldlms')->table('tx_users_online')
->leftJoin('tm_users', 'tx_users_online.nIDUser', '=', 'tm_users.nID')
->when($request->input('search'), function ($query, $search) {
$query->where(function ($query) use ($search) {
$query->orWhere('tm_users.sFirstname', 'like', "%" . $search . "%");
$query->orWhere('tm_users.sLastname', 'like', "%" . $search . "%");
});
})
->when($request->has('orderBy'), function ($query) use ($request) {
$orderBy = $request->orderBy;
$direction = $request->order ?? 'asc';
$query->orderBy($orderBy, $direction);
})
->when($request->input('start_date'), function ($query, $start_date) {
$query->where('tx_users_online.sDate', '>=', $start_date . ' 00:00:00');
})
->when($request->input('end_date'), function ($query, $end_date) {
$query->where('tx_users_online.sDate', '<=', $end_date . ' 23:59:59');
})
->select(
DB::connection('oldlms')->raw("CONCAT('dr. ', tm_users.sFirstName, ' ', IFNULL(tm_users.sMiddleName, ''), ' ', IFNULL(tm_users.sLastName, '')) as nama_dokter"),
'tx_users_online.sStatus',
'tx_users_online.sDate'
)
->get();
// Styling untuk baris data (tidak ada bold)
$dataStyle = (new StyleBuilder())
->setCellAlignment(CellAlignment::LEFT)
->build();
// Menambahkan data baris ke dalam file
$no = 0;
foreach ($results as $item) {
$no++;
$rowData = [
$no,
$item->nama_dokter,
$item->sDate,
$item->sStatus
];
$row = WriterEntityFactory::createRowFromArray($rowData, $dataStyle);
$writer->addRow($row);
}
// Menutup writer setelah selesai menulis file
$writer->close();
// Mengirimkan response JSON
return Helper::responseJson([
'file_name' => $fileName,
'file_url' => url('files/' . $fileName),
]);
}
/**
* Show the form for creating a new resource.
* @return Renderable
*/
public function create()
{
return view('internal::create');
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Renderable
*/
public function store(Request $request)
{
}
/**
* Show the specified resource.
* @param int $id
* @return Renderable
*/
public function show($id)
{
}
/**
* Show the form for editing the specified resource.
* @param int $id
* @return Renderable
*/
public function edit($id)
{
return view('internal::edit');
}
/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Renderable
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
* @param int $id
* @return Renderable
*/
public function destroy($id)
{
//
}
}

View File

@@ -26,6 +26,7 @@ use Modules\Internal\Http\Controllers\Api\DivisionController;
use Modules\Internal\Http\Controllers\Api\HospitalController;
use Modules\Internal\Http\Controllers\Api\DoctorController;
use Modules\Internal\Http\Controllers\Api\DoctorRatingController;
use Modules\Internal\Http\Controllers\Api\DoctorOnlineController;
use Modules\Internal\Http\Controllers\Api\DrugController;
use Modules\Internal\Http\Controllers\Api\FormulariumController;
use Modules\Internal\Http\Controllers\Api\FormulariumTemplateController;
@@ -350,6 +351,9 @@ Route::prefix('internal')->group(function () {
Route::get('get-doctorrating', [DoctorRatingController::class, 'getData']);
Route::get('export-doctorrating', [DoctorRatingController::class, 'export']);
Route::get('get-doctoronline', [DoctorOnlineController::class, 'getData']);
Route::get('export-doctoronline', [DoctorOnlineController::class, 'export']);
Route::get('get-dokter-katalog', [KatalogDokterController::class, 'getData']);
Route::get('export-dokter-katalog', [KatalogDokterController::class, 'export']);

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class DoctorOnline extends Model
{
use HasFactory;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tx_user_online';
// Define a belongsTo relationship with the User model
public function user()
{
return $this->belongsTo(User::class, 'nIDUser');
}
// Include additional fields in the model's JSON form
protected $appends = [
'user_first_name', // Include the attribute for user's first name
];
// Define an accessor to get the first name of the related user
public function getUserFirstNameAttribute()
{
return $this->user ? $this->user->sFirstName : null;
}
}

View File

@@ -187,6 +187,11 @@ class NavigationSeeder extends Seeder
'path' => '/report/doctor-rating',
'permission' => 'report-doctor-rating'
],
[
'title' => 'Doctor Online',
'path' => '/report/doctor-online',
'permission' => 'report-doctor-online'
],
[
'title' => 'Katalog Dokter',
'path' => '/report/katalog-dokter',

View File

@@ -69,6 +69,7 @@ class PermissionTableSeeder extends Seeder
'report-livechat-list',
'report-livechat-payment',
'report-doctor-rating',
'report-doctor-online',
'user-role-list',
'user-access-list',
'report-katalog-dokter'

View File

@@ -0,0 +1,35 @@
import { Card, Grid, Container } from '@mui/material';
import { useParams } from 'react-router-dom';
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
import Page from '../../../components/Page';
import useSettings from '../../../hooks/useSettings';
import List from './List';
export default function Index() {
const { themeStretch } = useSettings();
const { id } = useParams();
const pageTitle = 'Doctor Online';
return (
<Page title={pageTitle}>
<Container maxWidth={themeStretch ? false : 'xl'}>
<HeaderBreadcrumbs
heading={pageTitle}
links={[
{
name: 'Report',
href: '#',
},
{
name: 'Doctor Online',
href: '/report/doctor-online',
},
]}
/>
<List />
</Container>
</Page>
);
}

File diff suppressed because it is too large Load Diff

0
frontend/dashboard/src/pages/Report/Rujukan/Index.tsx Normal file → Executable file
View File

0
frontend/dashboard/src/pages/Report/Rujukan/List.tsx Normal file → Executable file
View File

View File

@@ -13,6 +13,7 @@ import { AuthProvider } from '../contexts/LaravelAuthContext';
import AuthGuard from '../guards/AuthGuard';
import { Link, useParams, useSearchParams } from 'react-router-dom';
import DoctorRating from '@/pages/Report/DoctorRating_v2/Index';
import DoctorOnline from '@/pages/Report/DoctorOnline/Index';
import KatalogDokter from '@/pages/Report/KatalogDokter/Index';
// ----------------------------------------------------------------------
@@ -446,6 +447,10 @@ export default function Router() {
path: 'report/doctor-rating',
element: <DoctorRating/>,
},
{
path: 'report/doctor-online',
element: <DoctorOnline/>,
},
{
path: 'report/katalog-dokter',
element: <KatalogDokter/>,

Binary file not shown.