@using PantheonRA.BackOffice.Enums

@{
    var expenseNum = (int)ViewBag.Enumerator;
    var distanceAnNo = (int)ViewBag.DistanceAnNo;
    var defaultFxRate = DailyAllowTypes.DefaultFxRate;
}

<tr id="ExpensesCreate-@expenseNum">
    
    <td class="hidden">
        @Html.Hidden("Deleted", "", new { @name = "Deleted", @id = string.Format("{0}-{1}", expenseNum, "Deleted") })
        @Html.Hidden("AcKey", "", new { @name = "AcKey", @id = string.Format("{0}-{1}", expenseNum, "AcKey") })
        @Html.Hidden("AnCostNo", "", new { @name = "AnCostNo", @id = string.Format("{0}-{1}", expenseNum, "AnCostNo") })
        @Html.Hidden("ExpenseAnNo", distanceAnNo, new { @name = "ExpenseAnNo", @id = string.Format("{0}-{1}", expenseNum, "ExpenseAnNo"), @resetValue = "false" })
        @Html.Hidden("CostNo", "", new { @name = "CostNo", @id = string.Format("{0}-{1}", expenseNum, "CostNo") })
        @Html.Hidden("ExpenseOrdinalNumber", "", new { @name = "ExpenseOrdinalNumber", @id = string.Format("{0}-{1}", expenseNum, "ExpenseOrdinalNumber") })
        @Html.Hidden("Name", "", new { @name = "Name", @id = string.Format("{0}-{1}", expenseNum, "Name") })
        @Html.Hidden("QId", "", new { @name = "QId", @id = string.Format("{0}-{1}", expenseNum, "QId") })
    </td>

    <td label="@Loc.Type">
        <div style="width: 100%" onclick="expandTravelOrderRow('ExpensesTable-@expenseNum', '-1', true);">
            <select id=@string.Format("{0}-{1}", expenseNum, "CostType")
                    name="CostType"
                    class="form-control select2withAPI"
                    allow-clear="true"
                    filter-by="HeaderDocumentType"
                    data-placeholder="@Loc.Type"
                    required
                    onchange="clearAmount('@expenseNum');
                              setNotForPayout('@expenseNum', this.id, '@string.Format("{0}-{1}", expenseNum, "NotForPayment")');"
                    data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/travel-orders/expenses/types-lookupitems" })></select>
        </div>
    </td>

    <td label="@Loc.Amount">
        <input type="text"
               id="@string.Format("{0}-{1}", expenseNum, "PriceCurrencyString")"
               name="PriceCurrencyString"
               class="form-control thousands-with-decimals"
               required
               placeholder="@Loc.Amount"
               onchange="convertCurrency(
                           '@string.Format("{0}-{1}", expenseNum, "DateCost")',
                           '@string.Format("{0}-{1}", expenseNum, "ExpensesCurrency")',
                           '@string.Format("{0}-{1}", expenseNum, "FxRate")',
                           '@string.Format("{0}-{1}", expenseNum, "PriceCurrencyString")',
                           '@string.Format("{0}-{1}", expenseNum, "Value")')" />
    </td>

    <td label="@Loc.Currency">
        <select id="@string.Format("{0}-{1}", expenseNum, "ExpensesCurrency")"
                name="Currency"
                required
                class="form-control select2withAPI default-currency"
                data-placeholder="@Loc.Currency"
                data-url=@Url.Action("GetDropDownValues", "GlobalHelper", new { apiPath = "/v1/travel-orders/expenses/currencies-lookupitems" })
                onchange="convertCurrency(
                           '@string.Format("{0}-{1}", expenseNum, "DateCost")',
                           '@string.Format("{0}-{1}", expenseNum, "ExpensesCurrency")',
                           '@string.Format("{0}-{1}", expenseNum, "FxRate")',
                           '@string.Format("{0}-{1}", expenseNum, "PriceCurrencyString")',
                           '@string.Format("{0}-{1}", expenseNum, "Value")')"></select>
    </td>

    <td label="@Loc.DateAndTime">
        <input type="text"
               id="@string.Format("{0}-{1}", expenseNum, "DateCost")"
               name="DateCost"
               required
               class="form-control custom-datetimepicker expense-dt-picker"
               placeholder="@Loc.DateAndTime"
               onchange="convertCurrency(
                           '@string.Format("{0}-{1}", expenseNum, "DateCost")',
                           '@string.Format("{0}-{1}", expenseNum, "ExpensesCurrency")',
                           '@string.Format("{0}-{1}", expenseNum, "FxRate")',
                           '@string.Format("{0}-{1}", expenseNum, "PriceCurrencyString")',
                           '@string.Format("{0}-{1}", expenseNum, "Value")')"
               autocomplete="off" />
    </td>

    <td label="@Loc.FxRate">
        <input type="text"
               id="@string.Format("{0}-{1}", expenseNum, "FxRate")"
               name="FxRate"
               class="form-control"
               value="@defaultFxRate"
               required
               placeholder="@Loc.FxRate" />
    </td>

    <td label="@Loc.Value">
        <input type="text"
               id="@string.Format("{0}-{1}", expenseNum, "Value")"
               name="Value"
               class="form-control"
               placeholder="@Loc.Value"
               disabled />
    </td>

    <td label="@Loc.NotInCurrency" class="text-center">
        <input type="checkbox"
               class="travelorders-checkbox custom-checkbox"
               id="@string.Format("{0}-{1}", expenseNum, "NotInCurrency")"
               name="NotInCurrency"
               onchange="setCheckedValue(this.id)" />
    </td>

    <td label="@Loc.NotForPayout" class="text-center">
        <input type="checkbox"
               class="travelorders-checkbox custom-checkbox"
               id="@string.Format("{0}-{1}", expenseNum, "NotForPayment")"
               name="NotForPayment"
               onchange="setCheckedValue(this.id)" />
    </td>

    <td label="@Loc.Description">
        <input type="text"
               id="@string.Format("{0}-{1}", expenseNum, "Note")"
               name="Note"
               class="form-control"
               placeholder="@Loc.Description" />
    </td>

    <td>
        <button 
           id="addExpense"
           type="button"
           onclick="AddNewRow('#ExpensesCreate-@expenseNum', '#ExpensesPrefix-@expenseNum', '#ExpensesTable-@expenseNum'); SetExpenseSettings('@expenseNum');
           showExpenseDateTimePicker()"
           class="btn btn-success add-del-allow-expense">
            <i class="fa fa-plus"></i>
        </button>
    </td>

</tr>