<!-- Modal -->
<div id="modalRefund" class='modal fade' data-backdrop="static"  data-keyboard="false" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
    <div class="modal-content">
        <?php $refundForm = new RefundForm();
              echo $refundForm->openForm();
              echo $refundForm->showElement('charge');?>
        <div class="modal-header">
            <h3 id="myModalLabel"><?php echo $_translator->_getTranslation('Reembolsar pago');?></h3>
        </div> 
        <div id="flashmessenger-refund"></div>
        <div class="modal-body">   
            <div class='col-lg-12 col-md-12 col-sm-12'>
                    <?php echo $refundForm->showElement('amount');?>
                    <?php echo $refundForm->showElement('reason');?>
                    <?php echo $refundForm->showElement('comments');?>
            </div>   
            <div class='clear'></div>
            <p><i class="fa fa-exclamation-triangle"></i> <?php echo $_translator->_getTranslation('Los rembolsos tardan de 5 a 10 días en aparecer en el extracto del cliente.');?></p>
        </div>
        <div class="modal-footer">    
            <div class='col-lg-12 col-md-12 col-sm-12 pull-right'>
                <?php $element = $refundForm->getElement('sendRefund');echo $refundForm->createOnlyElement($element);?>
                <input type="button" id="btn-refund-close" class='btn btn-default' value="<?php echo $_translator->_getTranslation('Cerrar');?>" />
            </div>            
        </div>
        <?php echo $refundForm->closeForm()?>
    </div>           
    </div>
    <script>
       
        $(document).ready(function() {
            $('form[name=refund] input').keydown(function(event){
                if(event.keyCode === 13) {
                  event.preventDefault();
                  return false;
                }
            });
        });

        $('#reason').select2();
        $('#sendRefund').on('click',function(){crateRefund();});
        $('#btn-refund-close').on('click',function(){clearModalRefund();});
        $('#modalRefund').on('shown.bs.modal', function (e) {
            $('#amount').focus();
        });
        
        $(document).on('keyup','#amount',function(e){if(e.keyCode===13){$('#reason').select2('open');}});   
        $('#reason').on('select2:close', function (e) {$('#comments').focus();});
        $(document).on('keyup','#sendRefund',function(e){if(e.keyCode===13){crateRefund();}});
        $(document).on('keyup','#btn-refund-close',function(e){if(e.keyCode===13){clearModalRefund();}});
    </script>
</div>