Code in my view file:
$this->registerJs("$('#dailywardentry-doctor_visit_name').on('change',function(){
$.ajax({
url: '".yii\helpers\Url::toRoute("daily-ward-entry/charges-cash")."',
dataType: 'json',
method: 'GET',
data: {id:$('#dailywardentry-doctor_visit_name').val(),
room_category:$('#dailywardentry-room_name').val()// Want to use this additional params
},
success: function (data, textStatus, jqXHR) {
$('#dailywardentry-visit_charges').val(data.visit_charges);
$('#dailywardentry-doctor_id').val(data.doctor_id);
},
});
});");
And code in my controller is like:
public function actionChargesCash($id){
$model = \app\models\IpdCharges::findOne(['id'=>$id]);
return \yii\helpers\Json::encode([
'visit_charges'=>$model->charges_cash,
'doctor_id'=>$model->doctor_id
]);
}
I want to fill the data on the basis of additional parameter room_category:$(’#dailywardentry-room_name’).val() which is not working.
While checking in firefox I am getting the status 200 OK like:
GET http://localhost/hospitalerp/web/index.php?r=daily-ward-entry%2Fcharges-cash&id=1&room_category=6
Still I am getting the values as if the parameter room_category is not supplied.
I think the problem is in the code which needs to be modified -
$model = \app\models\IpdCharges::findOne(['id'=>$id]);
Here only id is used in find and I don’t know how to add parameter for room_category
Any solution will be greatly appreciated. Thanks.