<?php
$tr = '';
if($companies)
{
    $company = html::select('refundCompany', $companies, $refund->refundCompany, "class='form-control'");
    $tr = <<<EOF
<tr>
  <th>{$lang->refund->refundCompany}</th>
  <td>{$company}</td>
  <td></td>
</tr>
EOF;
}

$type  = html::select('type', $lang->refund->typeList, $refund->type, "class='form-control'");
$month = html::select('deductionMonth', $monthList, $refund->deductionMonth, "class='form-control deductionMonth'");
$tr   .= <<<EOF
<tr>
  <th>{$lang->refund->type}</th>
  <td>
    <div class='required required-wrapper deductionMonth'></div>
    <div class='input-group'>
      {$type}
      <span class='input-group-addon fix-border deductionMonth'>{$lang->refund->deductionMonth}</span>
      {$month}
    </div>
  </td>
  <td><span class='deductionMonth'>{$lang->refund->deductionTips}</span></td>
</tr>
EOF;
?>
<script>
$('#name').parents('tr').before(<?php echo helper::jsonEncode($tr);?>);
$('#type').change(function()
{
    $('.deductionMonth').toggle($(this).val() == 'deduction');
    $('#deductionMonth').css({'margin-bottom': 0, 'border-color': ''});
    $('#deductionMonthLabel').remove();
});
$('#type').change();
if($('#refundCompany').length == 1) $('#refundCompany').chosen(chosenDefaultOptions);
</script>
