surat/frontend/modules/register/views/hospital-import/his-request.php

190 lines
8.3 KiB
PHP
Raw Normal View History

2025-03-20 09:59:10 +00:00
<?php
2025-03-25 18:43:44 +00:00
use yii\bootstrap5\ActiveForm;
2025-03-21 01:15:45 +00:00
use yii\helpers\Url;
2025-03-20 09:59:10 +00:00
use yii\helpers\Html;
use yii\grid\GridView;
2025-03-25 18:43:44 +00:00
2025-03-20 09:59:10 +00:00
/* @var $this yii\web\View */
/* @var $model app\models\PatientApi */
/* @var $dataProvider yii\data\ArrayDataProvider */
$this->title = 'ค้นหาผู้ป่วย';
$this->params['breadcrumbs'][] = $this->title;
?>
2025-03-21 01:15:45 +00:00
<div class="card shadow">
2025-03-21 07:14:20 +00:00
<div class="card-header">
<h5 class="card-title"><?= $this->title ?></h5>
</div>
<div class="card-body">
2025-03-20 09:59:10 +00:00
2025-03-21 07:14:20 +00:00
<?php $form = ActiveForm::begin(); ?>
2025-03-20 09:59:10 +00:00
2025-03-29 05:01:38 +00:00
<div class="row">
<div class="col-md-3"><?= $form->field($model, 'hn')->textInput(['maxlength' => true]) ?></div>
<div class="col-md-3"><?= $form->field($model, 'reqNo')->textInput(['maxlength' => true]) ?></div>
<div class="col-md-3"><?= $form->field($model, 'reqDate')->textInput() ?></div>
</div>
2025-03-20 09:59:10 +00:00
2025-03-21 07:14:20 +00:00
<div class="form-group mt-4">
<?= Html::submitButton('ค้นหา', ['class' => 'btn btn-primary']) ?>
</div>
2025-03-20 09:59:10 +00:00
2025-03-21 07:14:20 +00:00
<?php ActiveForm::end(); ?>
</div>
2025-03-20 09:59:10 +00:00
</div>
2025-03-21 01:15:45 +00:00
<br>
2025-03-25 18:43:44 +00:00
2025-03-29 05:01:38 +00:00
<?php if ($model->load(Yii::$app->request->post()) && $model->validate()) { ?>
<div class="card shadow">
<div class="card-header">
<h5 class="card-title"> รายการผู้ป่วย</h5>
</div>
<div class="card-body">
2025-03-21 07:14:20 +00:00
2025-03-29 05:01:38 +00:00
<div class="table-responsive">
<?php if ($dataProvider) { ?>
2025-03-21 07:14:20 +00:00
2025-03-29 05:01:38 +00:00
<?php $form = ActiveForm::begin() ?>
<div class="card shadow">
<div class="card-body">
2025-03-21 07:14:20 +00:00
2025-03-29 05:01:38 +00:00
<?= Html::submitButton('นำเข้าข้อมูล', ['class' => 'btn btn-info', 'id' => 'btn-import-1']) ?>
2025-03-21 07:14:20 +00:00
2025-03-29 05:01:38 +00:00
<div class="table-responsive">
<?php $this->registerJsFile(Yii::getAlias('@web') . '/datatable/jquery.dataTables.min.js', ['depends' => [\yii\web\JqueryAsset::class]]) ?>
<?php $this->registerCssFile(Yii::getAlias('@web') . '/datatable/jquery.dataTables.min.css') ?>
<?php $this->registerJs('
2025-03-21 07:14:20 +00:00
$(document).ready(function() {
$(\'#apidatatable\').dataTable({
"paging": false,
"info": false,
"order": [[2, \'asc\']]
});
});
') ?>
2025-03-29 05:01:38 +00:00
<?php $this->registerCss("
2025-03-21 07:14:20 +00:00
.dataTables_filter {
float: left !important;
}
") ?>
2025-03-29 05:01:38 +00:00
<div class="mt-4" id="selectedCount">Selected: 0</div>
<?php $this->registerJs('
2025-03-21 07:14:20 +00:00
$(\'input[name="selection[]"]\').on(\'change\', function() {
var count = $(\'input[name="selection[]"]:checked\').length;
$(\'#selectedCount\').text(\'Selected: \' + count);
});
') ?>
2025-03-29 05:01:38 +00:00
<?= GridView::widget([
'dataProvider' => $dataProvider,
'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>",
'tableOptions' => [
'class' => 'table table-striped truncate m-0',
'id' => 'apidatatable'
2025-03-21 07:14:20 +00:00
],
2025-03-29 05:01:38 +00:00
'columns' => [
[
'class' => 'yii\grid\CheckboxColumn',
'checkboxOptions' => function ($model, $key, $index, $column) {
return [
'value' => serialize($model),
];
},
],
'req_no',
'hn',
'reg_flag',
2025-03-30 02:30:26 +00:00
'lab_type',
'lab_code',
'lab_name',
2025-03-29 05:01:38 +00:00
'title',
'firstName',
'lastName',
'CardID',
'docCode',
'docName',
'order_by_name',
[
'label' => 'แพทย์เจ้าของเคส',
'attribute' => 'docName',
],
[
'label' => 'เจ้าหน้าที่ผู้รับผิดชอบ',
'attribute' => 'staff',
],
'hospital_name',
'NATION',
'RACE',
'sex',
'birthDay',
'age',
'age_unit',
'payTypeCode',
'payTypeDes',
'deptCode',
'deptDesc',
'ward_id',
'ward_name',
'req_date',
'import_at',
2025-03-30 02:30:26 +00:00
//'import_by',
[
'attribute' => 'import_by',
'label' => 'ผู้นำเข้า',
'value' => function ($model) {
return isset($model->importBy) ? $model->importBy->realname : '';
}
],
2025-03-29 05:01:38 +00:00
]
]) ?>
<?php
//var_dump($data);
?>
</div>
<?= Html::submitButton('นำเข้าข้อมูล', ['class' => 'btn btn-info', 'id' => 'btn-import-2']) ?>
</div>
<!--card body-->
2025-03-25 17:48:16 +00:00
</div>
2025-03-29 05:01:38 +00:00
<?php ActiveForm::end() ?>
<?php
$assets = Yii::$app->assetManager->getPublishedUrl('@frontend/themes/mali/assets');
?>
<?php } ?>
2025-03-21 07:14:20 +00:00
2025-03-25 17:48:16 +00:00
</div>
2025-03-21 07:14:20 +00:00
</div>
</div>
2025-03-29 05:01:38 +00:00
<?php } ?>
2025-03-21 07:14:20 +00:00
<?php
$importUrl = Url::to(['his-import']); // กำหนด URL เป็นตัวแปร PHP
$this->registerJs("
$(document).ready(function() {
2025-03-25 08:32:09 +00:00
$('#btn-import-1, #btn-import-2').click(function(){
2025-03-21 07:14:20 +00:00
var keys = $('#apidatatable').find('input[name=\"selection[]\"]:checked').map(function(){
return $(this).val();
}).get();
2025-03-21 01:15:45 +00:00
if(keys.length > 0){
2025-03-21 07:14:20 +00:00
console.log('Keys ที่ถูกส่งไป:', keys); // Debug แสดงค่า keys ใน console
$.post('$importUrl', {
keys: JSON.stringify(keys) // ใช้ JSON.stringify เพื่อส่งเป็น array
}, function(data){
2025-03-21 01:15:45 +00:00
alert(data);
2025-03-21 07:14:20 +00:00
$.pjax.reload({container: '#pjax-import', async: false});
2025-03-21 01:15:45 +00:00
});
2025-03-21 07:14:20 +00:00
} else {
alert('No rows selected');
2025-03-21 01:15:45 +00:00
}
});
2025-03-21 07:14:20 +00:00
});
");
?>