2025-03-31 15:51:06 +00:00
< ? php
use yii\helpers\Url ;
use yii\helpers\Html ;
use yii\jui\AutoComplete ;
use yii\web\JsExpression ;
use kartik\select2\Select2 ;
2025-04-01 09:27:47 +00:00
use common\models\ConstRace ;
2025-04-20 11:36:44 +00:00
use common\models\ConstWard ;
2025-03-31 15:51:06 +00:00
use yii\helpers\ArrayHelper ;
use yii\widgets\MaskedInput ;
2025-04-20 15:44:51 +00:00
use common\models\ConstDoctor ;
2025-04-20 11:36:44 +00:00
use common\models\ConstRights ;
2025-03-31 15:51:06 +00:00
use yii\bootstrap5\ActiveForm ;
use common\models\PatientTitle ;
use common\models\ConstHospital ;
2025-04-01 09:27:47 +00:00
use common\models\ConstNationality ;
2025-04-20 15:44:51 +00:00
use common\models\ConstServiceCharge ;
use unclead\multipleinput\MultipleInput ;
use unclead\multipleinput\MultipleInputColumn ;
2025-03-31 15:51:06 +00:00
?>
< div class = " card " >
< div class = " card-header " >
< h4 class = " card-title " >< i class = " fa fa-file-text " ></ i > < ? = $this -> title ?> </h4>
</ div >
< div class = " card-body " >
< ? php $form = ActiveForm :: begin ([
'enableAjaxValidation' => true ,
'enableClientValidation' => false ,
'validateOnChange' => true ,
'validateOnSubmit' => true ,
'validateOnBlur' => false ,
]) ?>
2025-04-20 15:44:51 +00:00
< ? = $form -> errorSummary ([ $model , /*$patient*/ ]) ?>
2025-03-31 15:51:06 +00:00
2025-04-20 15:44:51 +00:00
< div class = " row mb-4 " >
2025-03-31 15:51:06 +00:00
< div class = " col-md-6 " >
< div class = " row " >
< div class = " col-md-4 " >< ? = $form -> field ( $model , 'id_case' ) -> widget ( MaskedInput :: class , [
'mask' => 'A99-99999' ,
'options' => [
'class' => 'form-control input-lg' ,
'style' => 'font-weight: bold' ,
'readonly' => $model -> isNewRecord ? false : true ,
]
]) ?>
</ div >
< div class = " col-md-6 " >
< ? = $form -> field ( $model , 'hospital_id' ) -> widget ( Select2 :: classname (), [
'data' => ArrayHelper :: map ( ConstHospital :: find () -> orderBy ([ 'name' => SORT_ASC ]) -> all (), 'id' , 'name' ), //->where('id > 1')
'options' => [
'placeholder' => 'เลือกหน่วยงาน ....' ,
],
'theme' => Select2 :: THEME_BOOTSTRAP ,
//'initValueText' => (!$model->isNewRecord ? ConstHospital::findOne($model->hospital_id)->name : ''),
'pluginOptions' => [
'allowClear' => true ,
//'minimumInputLength' => 3,
/* 'ajax' => [
'url' => Url :: to ([ '/site/hospital-list' ]),
'dataType' => 'json' , 1
'data' => new JsExpression ( 'function(params) { return {q:params.term}; }' )
], */
],
]) ?>
</ div >
</ div >
</ div >
< div class = " col-md-6 " >
< ? php if ( ! $model -> isNewRecord ) { ?>
< embed src = " <?= Url::to(['sticker/print', 'id_case' => $model->id_case ], true) ?>#view=fit "
type = " application/pdf " width = " 100% " height = " 252 " >
< ? php } ?>
</ div >
</ div >
< div class = " row " >
< div class = " col-md-2 " >< ? = $form -> field ( $model , 'block_amount' ) ?> </div>
< div class = " col-md-2 " >< ? = $form -> field ( $model , 'slide_amount' ) ?> </div>
2025-04-21 08:29:29 +00:00
<!--< div class = " col-md-4 " >< ? php /* $form->field($model, 'block_ex') */ ?> </div>-->
2025-03-31 15:51:06 +00:00
</ div >
< div class = " row " >
2025-04-21 03:30:12 +00:00
< div class = " col-md-3 " >< ? = $form -> field ( $model , 'is_histo_staining' ) -> checkbox () ?> </div>
< div class = " col-md-3 " >< ? = $form -> field ( $model , 'is_immuno_staining' ) -> checkbox () ?> </div>
2025-03-31 15:51:06 +00:00
</ div >
< div class = " row " >
< div class = " col-md-12 " >< ? = $form -> field ( $model , 'note' ) -> textarea () ?> </div>
</ div >
2025-04-21 03:30:12 +00:00
< ? php if ( ! $model -> isNewRecord ) { ?>
2025-04-21 08:29:29 +00:00
< div class = " mt-4 mb-4 " >
2025-04-21 03:30:12 +00:00
< h5 >< i class = " fa fa-dollar-sign " ></ i > รายการตรวจ </ h5 >
</ div >
2025-04-21 08:29:29 +00:00
< ? php $form = ActiveForm :: begin () ?>
2025-04-21 03:30:12 +00:00
2025-04-21 08:29:29 +00:00
< ? php
if ( substr ( $model -> id_case , 0 , 2 ) == 'AU' ) {
$hospital_id = $model -> body -> hospital_id ;
} else {
$hospital_id = $model -> hospital_id ;
}
?>
< ? = Html :: hiddenInput ( 'hospital_id' , $hospital_id , [ 'id' => 'hospital_id' ]) ?>
< h5 >< i class = " ri-file-add-fill " ></ i > Special Staining </ h5 >
< div class = " row " >
< div class = " col-sm-12 " >
< div class = " mt-3 " >
< ? php $this -> registerJs ( '
$ ( " #histostaining-items " ) . on ( " afterAddRow " , function ( e ){
//console.log("test");
//var sid = cid.split("--");
});
$ . fn . init_histo_charge = function (){
var cid = $ ( this ) . attr ( " id " );
var charge_id = $ ( this ) . val ();
var hospital_id = $ ( " #hospital_id " ) . val ();
var sid = cid . split ( " - " );
//alert(cid);
$ . get (
" ' . Url::toRoute('/site/hospital-service-charge') . ' " ,
{
charge_id : charge_id ,
hospital_id : hospital_id
},
function ( data )
{
var result = data . split ( " -- " );
//alert(sid);
$ ( " #histostaining-items- " + sid [ 2 ] + " -charge_id " ) . val ( result [ 0 ]);
$ ( " .field-histostaining-items- " + sid [ 2 ] + " -code " ) . text ( result [ 1 ]);
$ ( " .field-histostaining-items- " + sid [ 2 ] + " -testing " ) . text ( result [ 2 ]);
$ ( " .field-histostaining-items- " + sid [ 2 ] + " -price " ) . text ( result [ 3 ]);
}
);
};
' ) ?>
< div class = " table-responsive " >
< ? = $form -> field ( $tmp_histo_staining , 'items' ) -> label ( false ) -> widget ( MultipleInput :: class , [
'max' => 50 ,
'id' => 'histostaining-items' ,
'allowEmptyList' => true ,
2025-04-21 03:30:12 +00:00
'options' => [
2025-04-21 08:29:29 +00:00
'id' => 'block-input-wrapper' ,
2025-04-21 03:30:12 +00:00
],
2025-04-21 08:29:29 +00:00
//'min' => 1,
'addButtonPosition' => MultipleInput :: POS_FOOTER ,
'addButtonOptions' => [ 'class' => 'btn btn-primary' ],
'attributeOptions' => [],
'columns' => [
[
'name' => 'id_case' ,
'title' => 'ID Case' ,
'value' => function ( $data ) {
return isset ( $data [ 'id_case' ]) ? $data [ 'id_case' ] : '' ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'id' ,
'title' => 'ID' ,
'value' => function ( $data ) {
return isset ( $data [ 'id' ]) ? $data [ 'id' ] : '' ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'finance_id' ,
'title' => 'ID' ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ]) ? $data [ 'id' ] : '' ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'from_id' ,
'title' => 'ID' ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ]) ? $data [ 'finance' ][ 'from_id' ] : '' ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'block_no' ,
'title' => 'Block No.' ,
'enableError' => true ,
'options' => [
'class' => 'form-control block-no-input' ,
'data-name' => 'block_no' ,
],
],
/* [
'name' => 'block_no' ,
'title' => 'Block No.' ,
'options' => [ 'class' => 'uppercase-input' ],
//'enableError' => true,
'value' => function ( $data ) {
return strtoupper ( isset ( $data [ 'block_no' ])) ? $data [ 'block_no' ] : '' ;
},
/* 'options' => [
'class' => 'form-control' ,
'required' => true ,
2025-04-21 03:30:12 +00:00
2025-04-21 08:29:29 +00:00
],
], */
[
'name' => 'request_type' ,
'title' => 'ID' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'charge_id' ,
'title' => 'ID' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'charge_id' ]) ? $data [ 'finance' ][ 'charge_id' ] : null ;
},
],
[
'name' => 'finance_code' ,
'title' => 'สั่งย้อม' ,
'type' => AutoComplete :: class ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'charge' ][ 'code' ]) ? $data [ 'finance' ][ 'charge' ][ 'code' ] : null ;
},
'enableError' => true ,
'options' => [
'options' => [
'class' => 'form-control' ,
'required' => true ,
],
'clientOptions' => [
'source' => ConstServiceCharge :: find () -> select ([ 'id as id' , 'code as value' , 'CONCAT(code, \' \', name) as label' ]) -> where ([ 'lab' => 'special' ]) -> orderBy ([ 'code' => SORT_ASC ]) -> asArray () -> all (),
'change' => 'function(){$(this).init_histo_charge();}' ,
'select' => new JsExpression ( " function( event, ui ) {
$ ( this ) . val ( ui . item . id );
$ ( this ) . init_histo_charge ();
} " )
],
'class' => 'charge_class' ,
]
],
[
'name' => 'testing' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'ชื่อรายการย้อม' ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'charge' ]) ? $data [ 'finance' ][ 'charge' ][ 'name' ] : null ;
},
'enableError' => true ,
],
[
'name' => 'note' ,
'title' => 'Note' ,
'enableError' => true ,
],
[
'name' => 'is_express_dye' ,
'type' => MultipleInputColumn :: TYPE_CHECKBOX ,
'title' => 'ย้อมด่วน' ,
'enableError' => true ,
'options' => [
'class' => 'select-all-checkbox-special' ,
],
],
[
'name' => 'price' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Price' ,
'value' => function ( $data ) use ( $model ) {
return isset ( $data -> finance ) ? number_format ( Yii :: $app -> pathology -> getHosPrice ( isset ( $model -> hospital_id ) ? $model -> hospital_id : null , $data -> finance -> charge_id ), 2 ) : null ;
},
'enableError' => true ,
],
[
'name' => 'is_able' ,
'title' => 'Dis.' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'value' => function ( $data ) {
return isset ( $data [ 'is_able' ]) ? ( $data [ 'is_able' ] == 1 ? 'Dis.' : '' ) : null ;
}
],
[
'name' => 'disable_comment' ,
'title' => 'Comment' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
],
[
'name' => 'in_at' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Order Date' ,
'enableError' => true ,
],
[
'name' => 'receive_at' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Receive Date' ,
'enableError' => true ,
],
[
'name' => 'out_at' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Success Date' ,
'enableError' => true ,
]
]
]) ?>
</ div >
</ div >
</ div >
2025-04-21 03:30:12 +00:00
</ div >
< ? php
2025-04-21 08:29:29 +00:00
$js = <<< JS
// เมื่อแถวใหม่ถูกเพิ่มเข้ามา
$ ( '#histostaining-items' ) . on ( 'afterAddRow' , function ( e , row , currentIndex ) {
// หาค่าของ .block-no-input ในแถวสุดท้ายก่อนแถวใหม่ (แถวก่อนหน้า)
let lastRowBeforeNew = $ ( '#histostaining-items tbody tr' ) . not ( row ) . last ();
let lastValue = lastRowBeforeNew . find ( '.block-no-input' ) . val ();
// ใส่ค่าเข้าไปในแถวใหม่
$ ( row ) . find ( '.block-no-input' ) . val ( lastValue );
});
// เมื่อมีการเปลี่ยนแปลงค่าในช่อง .block-no-input
$ ( document ) . on ( 'change' , '.block-no-input' , function () {
// ค่าใหม่ที่ถูกแก้ไข
let changedValue = $ ( this ) . val ();
// อัปเดตค่า block-no-input เฉพาะแถวสุดท้าย (หากต้องการ)
// หรืออัปเดตค่าทั้งหมด ถ้านโยบายต้องให้ sync ทุกช่องเหมือนเดิม
$ ( '#histostaining-items tbody tr' ) . each ( function ( index , row ) {
$ ( row ) . find ( '.block-no-input' ) . val ( changedValue );
});
});
JS ;
$this -> registerJs ( $js );
?>
2025-04-21 03:30:12 +00:00
2025-04-21 08:29:29 +00:00
< ? php
$this -> registerJs ( "
$ ( document ) . on ( 'change' , '.select-all-checkbox-special' , function () {
var allCheckboxes = $ ( '.select-all-checkbox-special' );
if ( $ ( this ) . is ( ':checked' )) {
allCheckboxes . prop ( 'checked' , true );
} else {
allCheckboxes . prop ( 'checked' , false );
}
});
" );
?>
2025-04-21 03:30:12 +00:00
2025-04-21 08:29:29 +00:00
< ? php
$this -> registerJs ( "
$ ( '.uppercase-input' ) . on ( 'keyup' , function () {
var input = $ ( this );
var value = input . val () . toUpperCase ();
input . val ( value );
});
" );
?>
< ? php $this -> registerJs ( "
$ ( '#histostaining-items' ) . on ( 'afterInit' , function (){
2025-04-21 03:30:12 +00:00
//console.log('calls on after initialization event');
}) . on ( 'beforeAddRow' , function ( e ) {
//console.log('calls on before add row event');
}) . on ( 'afterAddRow' , function ( e ) {
//console.log('calls on after add row event');
}) . on ( 'beforeDeleteRow' , function ( e , item ){
//console.log(item);
return confirm ( 'คุณแน่ใจนะว่าต้องการลบ?' );
}) . on ( 'afterDeleteRow' , function ( e , item ){
2025-04-21 08:29:29 +00:00
//console.log(item);#immunostaining-items-0-from_id
var id_case = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"histostaining-items-\"][id$=\"-id_case\"]' ) . val ();
var from_id = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"histostaining-items-\"][id$=\"-from_id\"]' ) . val ();
var hs_id = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"histostaining-items-\"][id$=\"-id\"]' ) . val ();
2025-04-21 03:30:12 +00:00
//alert(id_case + from_id);
2025-04-21 08:29:29 +00:00
$ . post ( \ " " . Url :: to ([ 'finance-service-charge-histo-delete' ]) . " \" ,
2025-04-21 03:30:12 +00:00
{
id_case : id_case ,
2025-04-21 08:29:29 +00:00
from_id : from_id ,
hs_id : hs_id
2025-04-21 03:30:12 +00:00
},
function ( data , status ){
2025-04-21 08:29:29 +00:00
//alert(\"Data: \" + data); // + \"Status: \" + status
2025-04-21 03:30:12 +00:00
}
);
});
" ) ?>
2025-04-21 08:29:29 +00:00
< h5 >< i class = " ri-file-add-fill " ></ i > Immuno Staining </ h5 >
< div class = " mt-3 " >
< ? php $this -> registerJs ( '
$ ( " #immunostaining-items " ) . on ( " afterAddRow " , function ( e ){
//console.log("test");
//var sid = cid.split("--");
});
$ . fn . init_immuno_charge = function (){
var cid = $ ( this ) . attr ( " id " );
var charge_id = $ ( this ) . val ();
var hospital_id = $ ( " #hospital_id " ) . val ();
var sid = cid . split ( " - " );
//alert(cid);
$ . get (
" ' . Url::toRoute('/site/hospital-service-charge') . ' " ,
{
charge_id : charge_id ,
hospital_id : hospital_id
},
function ( data )
{
var result = data . split ( " -- " );
//alert(sid);
$ ( " #immunostaining-items- " + sid [ 2 ] + " -charge_id " ) . val ( result [ 0 ]);
$ ( " .field-immunostaining-items- " + sid [ 2 ] + " -code " ) . text ( result [ 1 ]);
$ ( " .field-immunostaining-items- " + sid [ 2 ] + " -testing " ) . text ( result [ 2 ]);
$ ( " .field-immunostaining-items- " + sid [ 2 ] + " -price " ) . text ( result [ 3 ]);
}
);
};
' ) ?>
< div class = " table-responsive " >
< ? = $form -> field ( $tmp_immono_staining , 'items' ) -> label ( false ) -> widget ( MultipleInput :: class , [
'addButtonPosition' => MultipleInput :: POS_HEADER ,
'max' => 50 ,
'id' => 'immunostaining-items' ,
'allowEmptyList' => true ,
'options' => [
'id' => 'block-input-wrapper' ,
],
//'min' => 1,
'addButtonPosition' => MultipleInput :: POS_FOOTER ,
'addButtonOptions' => [ 'class' => 'btn btn-primary' ],
'attributeOptions' => [],
'columns' => [
[
'name' => 'id_case' ,
'title' => 'ID Case' ,
'value' => function ( $data ) {
return isset ( $data [ 'id_case' ]) ? $data [ 'id_case' ] : null ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'id' ,
'title' => 'ID' ,
'value' => function ( $data ) {
return isset ( $data [ 'id' ]) ? $data [ 'id' ] : null ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'finance_id' ,
'title' => 'ID' ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'id' ]) ? $data [ 'finance' ][ 'id' ] : null ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'from_id' ,
'title' => 'ID' ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'from_id' ]) ? $data [ 'finance' ][ 'from_id' ] : null ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'block_no' ,
'title' => 'Block No.' ,
'enableError' => true ,
'options' => [
'class' => 'form-control block-no-input' ,
'data-name' => 'block_no' ,
],
],
[
'name' => 'request_type' ,
'title' => 'ID' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'charge_id' ,
'title' => 'ID' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'charge_id' ]) ? $data [ 'finance' ][ 'charge_id' ] : null ;
},
],
[
'name' => 'finance_code' ,
'title' => 'สั่งย้อม' ,
'type' => AutoComplete :: class ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'charge' ][ 'code' ]) ? $data [ 'finance' ][ 'charge' ][ 'code' ] : null ;
},
'enableError' => true ,
'options' => [
'options' => [
'class' => 'form-control' ,
'required' => true ,
],
'clientOptions' => [
'source' => ConstServiceCharge :: find () -> select ([ 'id as id' , 'code as value' , 'CONCAT(code, \' \', name) as label' ]) -> where ([ 'lab' => 'immuno' ]) /*->orderBy(['code' => SORT_ASC])*/ -> asArray () -> all (),
'change' => 'function(){$(this).init_immuno_charge();}' ,
'select' => new JsExpression ( " function( event, ui ) {
$ ( this ) . val ( ui . item . id );
$ ( this ) . init_immuno_charge ();
} " )
],
'class' => 'charge_class' ,
]
],
[
'name' => 'testing' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'ชื่อรายการย้อม' ,
'value' => function ( $data ) {
return isset ( $data [ 'finance' ][ 'charge' ][ 'name' ]) ? $data [ 'finance' ][ 'charge' ][ 'name' ] : null ;
},
'enableError' => true ,
],
[
'name' => 'note' ,
'title' => 'Note' ,
'enableError' => true ,
],
[
'name' => 'is_express_dye' ,
'type' => MultipleInputColumn :: TYPE_CHECKBOX ,
'title' => 'ย้อมด่วน' ,
'enableError' => true ,
'options' => [
'class' => 'select-all-checkbox-ihc' ,
],
],
[
'name' => 'price' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Price' ,
'value' => function ( $data ) use ( $model ) {
//return isset($data->finance) ? number_format(Yii::$app->pathology->getHosPrice(isset($hospital_id) ? $hospital_id : null, $data->finance->charge_id), 2) : null;
return isset ( $data -> finance ) ? number_format ( Yii :: $app -> pathology -> getHosPrice ( isset ( $model -> hospital_id ) ? $model -> hospital_id : null , $data -> finance -> charge_id ), 2 ) : null ;
},
'enableError' => true ,
],
[
'name' => 'is_able' ,
'title' => 'Dis.' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'value' => function ( $data ) {
return isset ( $data [ 'is_able' ]) ? ( $data [ 'is_able' ] == 1 ? 'Dis.' : '' ) : null ;
}
],
[
'name' => 'disable_comment' ,
'title' => 'Comment' ,
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
],
[
'name' => 'in_at' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Order Date' ,
'enableError' => true ,
],
[
'name' => 'receive_at' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Receive Date' ,
'enableError' => true ,
],
[
'name' => 'send_at' ,
'type' => MultipleInputColumn :: TYPE_STATIC ,
'title' => 'Success Date' ,
'enableError' => true ,
]
]
]) ?>
</ div >
</ div >
< ? php
$js = <<< JS
// เมื่อแถวใหม่ถูกเพิ่มเข้ามา
$ ( '#immunostaining-items' ) . on ( 'afterAddRow' , function ( e , row , currentIndex ) {
// หาค่าของ .block-no-input ในแถวสุดท้ายก่อนแถวใหม่ (แถวก่อนหน้า)
let lastRowBeforeNew = $ ( '#immunostaining-items tbody tr' ) . not ( row ) . last ();
let lastValue = lastRowBeforeNew . find ( '.block-no-input' ) . val ();
// ใส่ค่าเข้าไปในแถวใหม่
$ ( row ) . find ( '.block-no-input' ) . val ( lastValue );
});
// เมื่อมีการเปลี่ยนแปลงค่าในช่อง .block-no-input
$ ( document ) . on ( 'change' , '.block-no-input' , function () {
// ค่าใหม่ที่ถูกแก้ไข
let changedValue = $ ( this ) . val ();
// อัปเดตค่า block-no-input เฉพาะแถวสุดท้าย (หากต้องการ)
// หรืออัปเดตค่าทั้งหมด ถ้านโยบายต้องให้ sync ทุกช่องเหมือนเดิม
$ ( '#immunostaining-items tbody tr' ) . each ( function ( index , row ) {
$ ( row ) . find ( '.block-no-input' ) . val ( changedValue );
});
});
JS ;
$this -> registerJs ( $js );
?>
< ? php
$this -> registerJs ( "
$ ( document ) . on ( 'change' , '.select-all-checkbox-ihc' , function () {
var allCheckboxes = $ ( '.select-all-checkbox-ihc' );
if ( $ ( this ) . is ( ':checked' )) {
allCheckboxes . prop ( 'checked' , true );
} else {
allCheckboxes . prop ( 'checked' , false );
}
});
" ); ?>
< ? php $this -> registerJs ( "
$ ( '#immunostaining-items' ) . on ( 'afterInit' , function (){
//console.log('calls on after initialization event');
}) . on ( 'beforeAddRow' , function ( e ) {
//console.log('calls on before add row event');
}) . on ( 'afterAddRow' , function ( e ) {
//console.log('calls on after add row event');
}) . on ( 'beforeDeleteRow' , function ( e , item ){
//console.log(item);
return confirm ( 'คุณแน่ใจนะว่าต้องการลบ?' );
}) . on ( 'afterDeleteRow' , function ( e , item ){
//console.log(item);#immunostaining-items-0-from_id
var id_case = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"immunostaining-items-\"][id$=\"-id_case\"]' ) . val ();
var from_id = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"immunostaining-items-\"][id$=\"-from_id\"]' ) . val ();
var im_id = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"immunostaining-items-\"][id$=\"-id\"]' ) . val ();
//alert(id_case + from_id + im_id);
$ . post ( \ " " . Url :: to ([ 'finance-service-charge-immuno-delete' ]) . " \" ,
{
id_case : id_case ,
from_id : from_id ,
im_id : im_id
},
function ( data , status ){
//alert(\"Data: \" + data + \"Status: \" + status);
}
);
});
" ) ?>
2025-04-21 03:30:12 +00:00
< ? php } ?>
2025-04-20 15:44:51 +00:00
2025-04-20 11:36:44 +00:00
< div class = " mt-4 " >
< h5 >< i class = " ri-file-user-line " ></ i > ข้อมูลผู้ป่วย ( Patient ) </ h5 >
</ div >
< ? php if ( $model -> isNewRecord ) { ?>
< ? = $form -> field ( $model , 'patient_id' ) -> label ( false ) -> hiddenInput () ?>
< ? php } ?>
2025-03-31 15:51:06 +00:00
< div class = " row " >
< div class = " col-md-2 " >
2025-04-20 15:44:51 +00:00
< ? = $form -> field ( $model , 'title_id' ) -> dropDownList ( ArrayHelper :: map ( PatientTitle :: find () -> all (), 'id' , 'name' ), [ 'prompt' => 'เลือกคำนำหน้า' ]) ?>
2025-03-31 15:51:06 +00:00
</ div >
< div class = " col-md-3 " >
2025-04-20 15:44:51 +00:00
< ? = $form -> field ( $model , 'given_name' ) ?>
2025-04-01 09:27:47 +00:00
</ div >
< div class = " col-md-3 " >
2025-04-20 15:44:51 +00:00
< ? = $form -> field ( $model , 'surname' ) ?>
2025-04-01 09:27:47 +00:00
</ div >
2025-04-20 11:36:44 +00:00
< div class = " col-md-3 " >
2025-04-20 15:44:51 +00:00
< ? = $form -> field ( $model , 'id_card' ) -> widget ( MaskedInput :: class , [
2025-04-20 11:36:44 +00:00
'mask' => '9-9999-99999-99-9'
]) ?>
</ div >
2025-04-20 15:44:51 +00:00
< div class = " col-md-2 " >< ? = $form -> field ( $model , 'birthdate' ) -> widget ( MaskedInput :: class , [
2025-04-20 11:36:44 +00:00
'mask' => '99/99/9999' ,
'options' => [
'id' => 'patient-birthdate' ,
],
])
?>
</ div >
2025-04-01 09:27:47 +00:00
< div class = " col-md-3 " >
2025-04-20 15:44:51 +00:00
< ? = $form -> field ( $model , 'gender' ) -> dropDownList ([ 'U' => '' , 'ช' => 'ชาย' , 'ญ' => 'หญิง' ]) ?>
</ div >
< div class = " col-md-2 " >
< ? = $form -> field ( $model , 'nation' ) -> dropDownList ( ArrayHelper :: map ( ConstNationality :: find () -> all (), 'id' , 'name' ), [ 'prompt' => 'Select Nationalily...' ]) ?>
</ div >
< div class = " col-md-2 " >
< ? = $form -> field ( $model , 'race' ) -> dropDownList ( ArrayHelper :: map ( ConstRace :: find () -> all (), 'id' , 'name' ), [ 'prompt' => 'Select Race...' ]) ?>
</ div >
< div class = " col-md-2 " >
< ? = $form -> field ( $model , 'age' ) -> textInput ([ 'id' => 'patient-age' ]) ?>
</ div >
< div class = " col-md-2 " >
< ? = $form -> field ( $model , 'age_unit' ) -> dropDownList ([ 'ปี' => 'ปี' , 'เดือน' => 'เดือน' , 'วัน' => 'วัน' ], [ 'id' => 'patient-age_unit' ]) ?>
</ div >
< div class = " col-md-2 " >
< ? = $form -> field ( $model , 'h_n' ) -> textInput () ?>
2025-04-01 09:27:47 +00:00
</ div >
< div class = " col-md-3 " >
2025-04-20 15:44:51 +00:00
< ? = $form -> field ( $model , 'a_n' ); ?>
2025-04-01 09:27:47 +00:00
</ div >
< div class = " col-md-3 " >
2025-04-20 15:44:51 +00:00
< ? = $form -> field ( $model , 'v_n' ); ?>
2025-03-31 15:51:06 +00:00
</ div >
2025-04-20 15:44:51 +00:00
< div class = " col-md-3 " >
< ? = $form -> field ( $model , 'ward_id' ) -> widget ( Select2 :: class , [
'data' => ArrayHelper :: map ( ConstWard :: find () -> where ([ 'status' => 1 ]) -> orderBy ([ 'name' => SORT_ASC ]) -> all (), 'id' , 'name' ), //->where('id > 1')
/* 'options' => [
'placeholder' => 'เลือกสิทธิ์การรักษา ....' ,
], */
'theme' => Select2 :: THEME_BOOTSTRAP ,
'pluginOptions' => [
'allowClear' => true ,
'placeholder' => 'เลือกแผนก....'
],
]) ?>
2025-03-31 15:51:06 +00:00
</ div >
2025-04-20 15:44:51 +00:00
< div class = " col-md-3 " >
< ? = $form -> field ( $model , 'doctor_id' ) -> widget ( Select2 :: class , [
'data' => ArrayHelper :: map (
ConstDoctor :: find () -> where ([ 'status' => 1 ]) -> orderBy ([ 'surname' => SORT_ASC ]) -> all (),
'id' ,
function ( $model ) {
//return $model->prefix . ' ' . $model->surname . ' ' . $model->lastname;
return empty ( $model -> surname ) ? $model -> fullname : ( ! empty ( $model -> fullname ) ? $model -> fullname : " { $model -> prefix } { $model -> surname } { $model -> lastname } " );
}
), //->where('id > 1')
'theme' => Select2 :: THEME_BOOTSTRAP ,
'pluginOptions' => [
'allowClear' => true ,
//'minimumInputLength' => 3,
'placeholder' => 'เลือกแพทย์เจ้าของคนไข้....'
],
]) ?>
2025-03-31 15:51:06 +00:00
</ div >
</ div >
< ? = Html :: submitButton ( '<span class="fa fa-save"></span> บันทึกข้อมูล' , [ 'class' => 'btn btn-success' ]) ?>
< ? php ActiveForm :: end () ?>
</ div >
</ div >
< ? php $this -> render ( '_js' ) ?>