2025-04-25 03:58:32 +00:00
< ? php
use yii\helpers\Url ;
use yii\helpers\Html ;
use yii\jui\AutoComplete ;
use yii\web\JsExpression ;
2025-04-28 02:16:44 +00:00
use kartik\date\DatePicker ;
2025-04-25 03:58:32 +00:00
use kartik\select2\Select2 ;
use common\models\ConstRace ;
use common\models\ConstWard ;
use yii\helpers\ArrayHelper ;
use yii\widgets\MaskedInput ;
use common\models\ConstDoctor ;
use common\models\ConstRights ;
use yii\bootstrap5\ActiveForm ;
use common\models\PatientTitle ;
use common\models\ConstHospital ;
use common\models\ConstNationality ;
use common\models\ConstServiceCharge ;
use unclead\multipleinput\MultipleInput ;
use unclead\multipleinput\MultipleInputColumn ;
?>
< 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 " >
2025-04-28 02:16:44 +00:00
< ? php $form = ActiveForm :: begin ([]) ?>
2025-04-25 03:58:32 +00:00
2025-04-28 02:16:44 +00:00
< ? = $form -> errorSummary ([ $model , /*$patient*/ ]) ?>
2025-04-25 03:58:32 +00:00
< div class = " row " >
2025-04-28 02:16:44 +00:00
< div class = " row " >
< div class = " col-md-2 " >< ? = $form -> field ( $model , 'document_no' ) ?> </div>
< div class = " col-md-2 " >
< ? = $form -> field ( $model , 'document_at' ) -> widget ( DatePicker :: class , [
'options' => [ 'placeholder' => 'วันที่หนังสือ ...' ],
'pluginOptions' => [
'format' => 'yyyy/mm/dd' ,
'allowClear' => true ,
'autoclose' => true ,
'todayHighlight' => true ,
//'todayBtn' => true,
]
])
?>
</ div >
< div class = " col-md-2 " >< ? = $form -> field ( $model , 'request_by' ) ?> </div>
< div class = " col-md-2 " >< ? = $form -> field ( $model , 'request_tel' ) ?> </div>
2025-04-25 03:58:32 +00:00
</ div >
2025-04-28 02:16:44 +00:00
< div class = " row " >
< div class = " mt-4 " >
2025-04-28 04:22:59 +00:00
< h5 >< i class = " ri-file-edit-line " ></ i > รายการตรวจ </ h5 >
2025-04-28 02:16:44 +00:00
</ div >
2025-04-28 04:22:59 +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 class = " mt-4 " >< 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 ( '
$ ( " #hospitalimportservicecharge-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);
$ ( " #hospitalimportservicecharge-items- " + sid [ 2 ] + " -charge_id " ) . val ( result [ 0 ]);
$ ( " .field-hospitalimportservicecharge-items- " + sid [ 2 ] + " -code " ) . text ( result [ 1 ]);
$ ( " .field-hospitalimportservicecharge-items- " + sid [ 2 ] + " -testing " ) . text ( result [ 2 ]);
$ ( " .field-hospitalimportservicecharge-items- " + sid [ 2 ] + " -price " ) . text ( result [ 3 ]);
}
);
};
' ) ?>
< div class = " table-responsive " >
< ? = $form -> field ( $tmp_hospital_import_service_charge , 'items' ) -> label ( false ) -> widget ( MultipleInput :: class , [
'max' => 50 ,
'id' => 'hospitalimportservicecharge-items' ,
'allowEmptyList' => true ,
'options' => [
'id' => 'block-input-wrapper' ,
],
//'min' => 1,
'addButtonPosition' => MultipleInput :: POS_FOOTER ,
'addButtonOptions' => [ 'class' => 'btn btn-primary' ],
'attributeOptions' => [],
'columns' => [
[
'name' => 'id' ,
'title' => 'ID' ,
'value' => function ( $data ) {
return isset ( $data [ 'id' ]) ? $data [ 'id' ] : '' ;
},
'enableError' => true ,
'type' => MultipleInputColumn :: TYPE_HIDDEN_INPUT ,
],
[
'name' => 'case_no' ,
'title' => 'Case No' ,
'enableError' => true ,
'options' => [
'class' => 'form-control case-no-input' ,
'data-name' => 'case_no' ,
],
],
[
'name' => 'amount_block' ,
'title' => 'จำนวนบล็อก' ,
'enableError' => true ,
'options' => [
'class' => 'form-control amount-block-input' ,
'data-name' => 'amount_block' ,
],
],
[
'name' => 'amount_slide' ,
'title' => 'จำสวนสไลด์' ,
'enableError' => true ,
'options' => [
'class' => 'form-control amount-slide-input' ,
'data-name' => 'amount_slide' ,
],
],
[
'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' ]) -> 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' => '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' => 'title' ,
'title' => 'คำนำหน้า' ,
'enableError' => true ,
'options' => [
'class' => 'form-control title-input' ,
'data-name' => 'title' ,
],
],
[
'name' => 'first_name' ,
'title' => 'ขื่อ' ,
'enableError' => true ,
'options' => [
'class' => 'form-control first-name-input' ,
'data-name' => 'first_name' ,
],
],
[
'name' => 'last_name' ,
'title' => 'นามสกุล' ,
'enableError' => true ,
'options' => [
'class' => 'form-control last-name-input' ,
'data-name' => 'last_name' ,
],
],
]
]) ?>
</ div >
</ div >
</ div >
2025-04-28 02:16:44 +00:00
</ div >
2025-04-28 04:22:59 +00:00
< ? php
$js = <<< JS
// เมื่อแถวใหม่ถูกเพิ่มเข้ามา
$ ( '#hospitalimportservicecharge-items' ) . on ( 'afterAddRow' , function ( e , row , currentIndex ) {
// หาค่าของ .block-no-input ในแถวสุดท้ายก่อนแถวใหม่ (แถวก่อนหน้า)
let lastRowBeforeNew = $ ( '#hospitalimportservicecharge-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 ทุกช่องเหมือนเดิม
$ ( '#hospitalimportservicecharge-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-special' , function () {
var allCheckboxes = $ ( '.select-all-checkbox-special' );
if ( $ ( this ) . is ( ':checked' )) {
allCheckboxes . prop ( 'checked' , true );
} else {
allCheckboxes . prop ( 'checked' , false );
}
});
" );
?>
< ? php
$this -> registerJs ( "
$ ( '.uppercase-input' ) . on ( 'keyup' , function () {
var input = $ ( this );
var value = input . val () . toUpperCase ();
input . val ( value );
});
" );
?>
< ? php $this -> registerJs ( "
$ ( '#hospitalimportservicecharge-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);#hospitalimportservicecharge-items-0-from_id
var id_case = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"hospitalimportservicecharge-items-\"][id$=\"-id_case\"]' ) . val ();
var from_id = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"hospitalimportservicecharge-items-\"][id$=\"-from_id\"]' ) . val ();
var hs_id = item . find ( '.list-cell__block_no' ) . find ( 'input[id*=\"hospitalimportservicecharge-items-\"][id$=\"-id\"]' ) . val ();
//alert(id_case + from_id);
$ . post ( \ " " . Url :: to ([ 'finance-service-charge-histo-delete' ]) . " \" ,
{
id_case : id_case ,
from_id : from_id ,
hs_id : hs_id
},
function ( data , status ){
//alert(\"Data: \" + data); // + \"Status: \" + status
}
);
});
" ) ?>
2025-04-25 03:58:32 +00:00
</ div >
2025-04-28 02:16:44 +00:00
2025-04-25 03:58:32 +00:00
</ div >
2025-04-28 02:16:44 +00:00
< div class = " mt-4 " >
< ? = Html :: submitButton ( '<span class="fa fa-save"></span> บันทึกข้อมูล' , [ 'class' => 'btn btn-success' ]) ?>
</ div >
2025-04-25 03:58:32 +00:00
< ? php ActiveForm :: end () ?>
</ div >
</ div >
< ? php $this -> render ( '_js' ) ?>