2025-12-26 03:03:19 +00:00
< ? php
use common\models\CenterApprove ;
use common\models\ConstStatus ;
use common\models\CytoPapDiagnosis ;
use yii\grid\GridView ;
use yii\helpers\ArrayHelper ;
use yii\helpers\Html ;
use yii\widgets\MaskedInput ;
?>
< ? = GridView :: widget ([
'dataProvider' => $dataProvider ,
'pager' => [ 'class' => 'yii\bootstrap5\LinkPager' ],
'filterModel' => $searchModel ,
2026-01-09 10:35:33 +00:00
'tableOptions' => [ 'class' => 'table align-middle table-hover m-0 truncate' ],
'layout' => " { summary}<div class='table-outer'><div class='table-responsive'> \n { items} \n </div></div><div class='d-flex justify-content-between align-items-center mt-4'> { pager}</div> " ,
2025-12-26 03:03:19 +00:00
'columns' => [
[ 'class' => 'yii\grid\SerialColumn' ],
[
'class' => 'yii\grid\ActionColumn' ,
'template' => '{transfer} {do-task}' ,
'visibleButtons' => [
'transfer' => function ( $model ) {
return false ;
},
],
'buttons' => [
'do-task' => function ( $url , $model ) {
2026-01-09 10:35:33 +00:00
return Html :: a ( '<i class="ri-file-list-line"></i> Diagnosis' , [ 'do' , 'id_case' => $model [ 'id_case' ]], [ 'class' => 'btn btn-primary btn-block' ]) . ' ' ;
2025-12-26 03:03:19 +00:00
},
'transfer' => function ( $url , $model ) {
2026-01-09 10:35:33 +00:00
return Html :: a ( '<i class="ri-repeat-line"></i> Transfer' , [ 'transfer' , 'id_case' => $model [ 'id_case' ]], [ 'class' => 'btn btn-warning btn-block' , 'data' => [ 'confirm' => 'ต้องการ Transfer Case นี้?' ]]);
2025-12-26 03:03:19 +00:00
}
]
],
[
'attribute' => 'register_at' ,
'filter' => MaskedInput :: widget ([
'model' => $searchModel ,
'attribute' => 'register_at' ,
'mask' => '99/99/9999'
]),
'value' => function ( $model ) {
return $model -> register_at ;
}
],
[
'attribute' => 'receive_at' ,
'filter' => MaskedInput :: widget ([
'model' => $searchModel ,
'attribute' => 'receive_at' ,
'mask' => '99/99/9999'
]),
'value' => function ( $model ) {
return $model -> receive_at ;
}
],
//'register_at',
[
'attribute' => 'id_case' ,
'format' => 'raw' ,
'value' => function ( $model ) {
$case = Yii :: $app -> pathology -> getCase ( $model -> id_case );
$c = '' ;
2026-01-09 10:35:33 +00:00
if ( isset ( $case ) && ! empty ( $case -> previous_report )) {
$c .= '<br /><small>(' . $case -> previous_report . ')</small>' ;
2025-12-26 03:03:19 +00:00
}
2026-01-09 10:35:33 +00:00
return Html :: a ( Html :: encode ( $model -> id_case ), [ 'do' , 'id_case' => $model -> id_case ]) . $c ;
2025-12-26 03:03:19 +00:00
}
],
//'title',
[
'attribute' => 'patient_name' ,
'value' => function ( $model ) {
return Html :: encode ( $model -> name );
}
],
[
'attribute' => 'age' ,
'value' => function ( $model ) {
return intval ( $model -> age );
}
],
'age_unit' ,
[
'attribute' => 'hospital_id' ,
'value' => function ( $model ) {
return Html :: encode ( $model -> hospital -> name );
}
],
[
'attribute' => 'status_id' ,
'filter' => ArrayHelper :: map ( ConstStatus :: find () -> all (), 'status' , 'status' ),
'format' => 'raw' ,
'value' => function ( $model ) {
return Yii :: $app -> pathology -> getStatus ( $model -> status_id );
}
],
[
'label' => 'Report Status' ,
'format' => 'raw' ,
'value' => function ( $model ) {
$case_type = Yii :: $app -> pathology -> getCaseType ( $model -> id_case );
$rt = '' ;
if ( $case_type == 'pap' ) {
$surgical_count = CytoPapDiagnosis :: find ()
-> where ([
'id_case' => $model -> id_case
]) -> count ();
if ( $surgical_count > 0 ) {
$rt .= '<table style="font-size: 11px;" class="table table-bordered table-hover table-striped">' ;
$rt .= '<thead>' ;
$rt .= '<tr><td>Report Type</td><td>Status</td><td>Authorised At</td><td>Approved At</td><td>Release At</td></tr>' ;
$rt .= '</thead>' ;
$rt .= '<tbody>' ;
2026-01-09 10:35:33 +00:00
foreach (
CytoPapDiagnosis :: find ()
-> where ([
'id_case' => $model -> id_case
])
-> all () as $case
) {
2025-12-26 03:03:19 +00:00
$center_approve = CenterApprove :: findOne ([
'id_case' => $case -> id_case ,
'report_type' => $case -> report_type ,
'ref_id' => $case -> id ,
]);
if ( ! $center_approve ) {
$check = '<span class="badge badge-info">รอแพทย์ Authorized</span>' ;
} else {
$arr = [ 1 => '<span class="badge badge-danger">ยังไม่ตรวจสอบ</span>' , 2 => '<span class="badge badge-secondary">รอแก้ไข</span>' , 3 => '<span class="badge badge-warning">แพทย์แก้ไขผลแล้ว</span>' , 4 => '<span class="badge badge-success">ตรวจสอบแล้ว</span>' ];
$check = $arr [ $center_approve -> approve_status ];
}
$rt .= '<tr>' ;
$rt .= '<td>' . Html :: encode ( ucfirst ( $case -> report_type )) . '</td>' ;
$rt .= '<td>' . Html :: encode ( $case -> status -> name ) . '</td>' ;
$rt .= '<td>' . Html :: encode ( $case -> pathologist_at ) . '</td>' ;
$rt .= '<td>' . $check . '</td>' ;
$rt .= '<td>' . ( isset ( $center_approve -> release_at ) ? $center_approve -> release_at : '' ) . '</td>' ;
$rt .= '</tr>' ;
}
$rt .= '</tbody>' ;
$rt .= '</table>' ;
2026-01-09 10:35:33 +00:00
} //surgical count
2025-12-26 03:03:19 +00:00
}
return $rt ;
}
],
]
]) ?>