<?php use yii\helpers\Html;use yii\bootstrap\ActiveForm;use kartik\select2\Select2;$payments=$model->getPaymentData();$accounts=$model->getAccountData();$paymentAccounts=$model->getPaymentAccountData();?><div class="sync-account-to-jurnal-form"><?php $form=ActiveForm::begin(['layout'=>'horizontal']);?><div class="form-group"><label class="control-label col-sm-3">Akun</label><div class="col-sm-6"><?php echo Select2::widget([ 'name'=>'akun','data'=>$accounts,'options'=>[ 'placeholder'=>'Pilih Akun ...',],'pluginEvents'=>[ "select2:select"=>"function(e) {
				    	var data = e.params.data;
    					$('.akunPayment').addClass('hidden');
    					$('.akunPayment[data-id=\"'+data.id+'\"]').removeClass('hidden');
				    }",] ]);?></div></div><?php foreach($accounts as $keyAccount=>$account){?><div class="akunPayment hidden" data-id="<?=$keyAccount?>"><?php foreach($payments as $keyPayment=>$payment){if($paymentAccounts[$keyPayment]==$keyAccount){$checked=true;$disabled=false;}elseif(!empty($paymentAccounts[$keyPayment])){$checked=false;$disabled=true;}else{$checked=false;$disabled=false;}echo $form->field($model,'accountPayments["'.$keyAccount.'"][]',['options'=>[ 'class'=>'clearfix',]])->checkbox([ 'uncheck'=>null,'label'=>$payment,'value'=>$keyPayment,'checked'=>$checked,'disabled'=>$disabled,'labelOptions'=>[ 'for'=>str_replace(' ','',$keyAccount).$keyPayment,],'id'=>str_replace(' ','',$keyAccount).$keyPayment,'class'=>'sync-config-checkbox','data-payment'=>$keyPayment,'data-account'=>$keyAccount,]);}?></div><?php }?><div class="form-group"><?=Html::submitButton('Save',['class'=>'btn btn-success'])?></div><?php ActiveForm::end();?></div><script type="text/javascript">$(".sync-config-checkbox").change(function(){var b=$(this).attr("data-payment");var a=$(this).attr("data-account");if(this.checked){$('input[type="checkbox"][data-payment="'+b+'"]').prop("disabled",true);$(this).prop("disabled",false)}else{$('input[type="checkbox"][data-payment="'+b+'"]').prop("disabled",false)}});</script>