diff --git a/app/DAL/Studies/IUserStudyLister.php b/app/DAL/Studies/IUserStudyLister.php index 3d6e249..0ee8a68 100644 --- a/app/DAL/Studies/IUserStudyLister.php +++ b/app/DAL/Studies/IUserStudyLister.php @@ -29,4 +29,6 @@ public function get(?int $user_id = null): LengthAwarePaginator; public function setStudyDate(string $from, ?string $to = null): self; public function setReceiveDate(string $from, ?string $to = null): self; + + public function setReportDate(string $from, ?string $to = null): self; } diff --git a/app/DAL/Studies/WorklistBase.php b/app/DAL/Studies/WorklistBase.php index 92cb085..0075868 100644 --- a/app/DAL/Studies/WorklistBase.php +++ b/app/DAL/Studies/WorklistBase.php @@ -35,6 +35,10 @@ abstract class WorklistBase implements IUserStudyLister private ?string $receiveDateTo = null; + private ?string $reportDateFrom = null; + + private ?string $reportDateTo = null; + public function setRadiologist(int $radiologist_id): self { $this->radiologist_id = $radiologist_id; @@ -211,12 +215,14 @@ private function applyLocked(Builder $query): Builder private function applyDateFilter(Builder $query, string $column, string $from, ?string $to): Builder { - $start = Carbon::parse($from); - if (filled($to)) { - $end = Carbon::parse($to); - $query = $query->whereBetween($column, [$start->toDateString(), $end->toDateString()]); - } else { - $query = $query->where($column, '>=', $start->toDateString()); + if (filled($from)) { + $start = Carbon::parse($from); + + if (filled($to)) { + $query = $query->whereBetween($column, [$start->toDateString(), Carbon::parse($to)->toDateString()]); + } else { + $query = $query->where($column, '=', $start->toDateString()); + } } return $query; @@ -230,7 +236,11 @@ private function applyDateFilters(Builder $query): Builder } if (filled($this->receiveDateFrom)) { - $query = $this->applyDateFilter($query, 'receive_date', $this->receiveDateFrom, $this->receiveDateTo); + $query = $this->applyDateFilter($query, 'received_at', $this->receiveDateFrom, $this->receiveDateTo); + } + + if (filled($this->reportDateFrom)) { + $query = $this->applyDateFilter($query, 'reported_at', $this->reportDateFrom, $this->reportDateTo); } return $query; @@ -251,4 +261,12 @@ public function setReceiveDate(string $from, ?string $to = null): self return $this; } + + public function setReportDate(string $from, ?string $to = null): self + { + $this->reportDateFrom = $from; + $this->reportDateTo = $to; + + return $this; + } } diff --git a/app/DataTables/WorklistDataTable.php b/app/DataTables/WorklistDataTable.php new file mode 100644 index 0000000..dca2407 --- /dev/null +++ b/app/DataTables/WorklistDataTable.php @@ -0,0 +1,82 @@ +addColumn('action', 'worklist.action') + ->setRowId('id'); + } + + /** + * Get the query source of dataTable. + */ + public function query(Worklist $model): QueryBuilder + { + return $model->newQuery(); + } + + /** + * Optional method if you want to use the html builder. + */ + public function html(): HtmlBuilder + { + return $this->builder() + ->setTableId('worklist-table') + ->columns($this->getColumns()) + ->minifiedAjax() + // ->dom('Bfrtip') + ->orderBy(1) + ->selectStyleSingle() + ->buttons([ + Button::make('excel'), + Button::make('csv'), + Button::make('pdf'), + Button::make('print'), + Button::make('reset'), + Button::make('reload'), + ]); + } + + /** + * Get the dataTable columns definition. + */ + public function getColumns(): array + { + return [ + Column::computed('action') + ->exportable(false) + ->printable(false) + ->width(60) + ->addClass('text-center'), + Column::make('id'), + Column::make('add your columns'), + Column::make('created_at'), + Column::make('updated_at'), + ]; + } + + /** + * Get the filename for export. + */ + protected function filename(): string + { + return 'Worklist_'.date('YmdHis'); + } +} diff --git a/composer.json b/composer.json index 3becce2..1756279 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "sentry/sentry-laravel": "^4.10", "spatie/laravel-permission": "^6.10", "vinkla/hashids": "^12.0", + "yajra/laravel-datatables": "^11.0", "yajra/laravel-datatables-oracle": "^11.1" }, "require-dev": { diff --git a/resources/js/worklist.js b/resources/js/worklist.js new file mode 100644 index 0000000..232cd4e --- /dev/null +++ b/resources/js/worklist.js @@ -0,0 +1,2 @@ +import './bootstrap'; +import 'laravel-datatables-vite'; diff --git a/vite.config.js b/vite.config.js index 12102d7..0c27602 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,7 @@ -import { defineConfig } from 'vite'; +import {defineConfig} from 'vite'; import laravel from 'laravel-vite-plugin'; import html from '@rollup/plugin-html'; -import { glob } from 'glob'; +import {glob} from 'glob'; /** * Get Files from a directory @@ -9,11 +9,16 @@ import { glob } from 'glob'; * @returns array */ function GetFilesArray(query) { - return glob.sync(query); + return glob.sync(query); } + /** * Js Files */ +// Ppp JS Files +const appJsFiles = GetFilesArray('resources/js/*.js'); + + // Page JS Files const pageJsFiles = GetFilesArray('resources/assets/js/*.js'); @@ -38,38 +43,39 @@ const FontsScssFiles = GetFilesArray('resources/assets/vendor/fonts/**/!(_)*.scs // Processing Window Assignment for Libs like jKanban, pdfMake function libsWindowAssignment() { - return { - name: 'libsWindowAssignment', + return { + name: 'libsWindowAssignment', - transform(src, id) { - if (id.includes('jkanban.js')) { - return src.replace('this.jKanban', 'window.jKanban'); - } else if (id.includes('vfs_fonts')) { - return src.replaceAll('this.pdfMake', 'window.pdfMake'); - } - } - }; + transform(src, id) { + if (id.includes('jkanban.js')) { + return src.replace('this.jKanban', 'window.jKanban'); + } else if (id.includes('vfs_fonts')) { + return src.replaceAll('this.pdfMake', 'window.pdfMake'); + } + } + }; } export default defineConfig({ - plugins: [ - laravel({ - input: [ - 'resources/css/app.css', - 'resources/assets/css/demo.css', - 'resources/js/app.js', - ...pageJsFiles, - ...vendorJsFiles, - ...LibsJsFiles, - 'resources/js/laravel-user-management.js', // Processing Laravel User Management CRUD JS File - ...CoreScssFiles, - ...LibsScssFiles, - ...LibsCssFiles, - ...FontsScssFiles - ], - refresh: true - }), - html(), - libsWindowAssignment() - ] + plugins: [ + laravel({ + input: [ + 'resources/css/app.css', + 'resources/assets/css/demo.css', + //'resources/js/app.js', + ...appJsFiles, + ...pageJsFiles, + ...vendorJsFiles, + ...LibsJsFiles, + 'resources/js/laravel-user-management.js', // Processing Laravel User Management CRUD JS File + ...CoreScssFiles, + ...LibsScssFiles, + ...LibsCssFiles, + ...FontsScssFiles + ], + refresh: true + }), + html(), + libsWindowAssignment() + ] });