@using PantheonRA.WebApi.Contracts.Enums
@using PAW.Contracts.Enums;

@model List<PantheonRA.WebApi.Contracts.PaWoExItemWork>

@{
    ViewBag.Title = Loc.AddWork;

    var workDate = ViewBag.Date;
    var Tn = (double)ViewBag.Qty1;
    var Tpz = (double)ViewBag.Qty2;

    var itemResourceNum = (int)ViewBag.Enumerator;
    var resourceQId = (int)ViewBag.ResourceQid;
    var itemResourceName = "WoExItemResources[" + itemResourceNum + "].WoExItemWork[{0}].{1}";
}

@Html.Hidden("ResourceWorkersPrefix-" + itemResourceNum, string.Format(itemResourceName, "OrdinalNumberNo", "Property"))

<table id="ResourceWorkersTable-@itemResourceNum" class="table table-bordered input-no-bottom-border to-panel-table allows-expenses-table">
    <thead>
        <tr>
            <th style="width: 20%">@Loc.Worker</th>
            <th style="width: 20%">@Loc.StartDate</th>
            <th style="width: 10%">@Loc.Duration</th>
            <th style="width: 10%">@Loc.WOOperationGoodPcs</th>
            <th style="width: 10%">@Loc.WOOperationRepairPcs</th>
            <th style="width: 10%">@Loc.WOOperationScrapPcs</th>
            <th style="width: 7%">@Loc.WOOperationTsu</th>
            <th style="width: 7%">@Loc.WOOperationTpr</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr id="ResourceWorkersCreate-@itemResourceNum" class="to-dailyallow-create">

            <td class="hidden" data-column-id="HiddenFields" data-sortable="false">
                <input type="hidden"
                       id="@string.Format("{0}-{1}","AcKey", itemResourceNum)"
                       name="AcKey"
                       value=@ViewBag.AcKey />
                <input type="hidden"
                       id="@string.Format("{0}-{1}","AnNo", itemResourceNum)"
                       name="AnNo"
                       value=@ViewBag.AnNo />
                <input type="hidden"
                       id="@string.Format("{0}-{1}","ResourceQId", itemResourceNum)"
                       name="ResourceQid"
                       value=@ViewBag.ResourceQid />
            </td>


            <td label="@Loc.Worker">
                <select id="@string.Format("{0}-{1}","Worker",itemResourceNum)"
                        name="Worker"
                        required
                        class="form-control"
                        allow-clear="true"
                        data-placeholder="@Loc.Worker"
                        data-dropdown-height="300">
                    @foreach (var item in ViewBag.Workers)
                    {
                        <option value="@item.Id" data-name="@item.Name">
                            @item.Name
                        </option>
                    }

                </select>
            </td>

            <td label="@Loc.DateAndTime">
                <input type="text"
                       id="@string.Format("{0}-{1}", "BeginTime", itemResourceNum)"
                       name="BeginTime"
                       required
                       class="form-control custom-datetimepicker expense-dt-picker"
                       placeholder="@Loc.DateAndTime"
                       value="@DateTime.Now.ToString("dd.MM.yyyy HH:mm")"
                       autocomplete="off" />
            </td>
            <td label="@Loc.Duration">
                <input type="time"
                       id="@string.Format("{0}-{1}", "Duration", itemResourceNum)"
                       name="Duration"
                       required
                       value="@DateTime.Today.ToString("HH:mm")"
                       class="form-control"
                       autocomplete="off" />
            </td>

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

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

            <td label="@Loc.WOOperationScrapPcs">
                <input type="text"
                       id="@string.Format("{0}-{1}","ScrapPcs",itemResourceNum)"
                       name="ScrapPcs"
                       required
                       class="form-control numberInput"
                       placeholder="@Loc.WOOperationScrapPcs"
                       value= "0" />
            </td>
            <td label="@Loc.WOOperationTpr">
                <input type="text"
                       id="@string.Format("{0}-{1}","Tn",itemResourceNum)"
                       name="Tn"
                       required
                       class="form-control numberInput"
                       placeholder="@Loc.WOOperationTpr"
                       value=@Tn.ToString("N2") />
            </td>
            <td label="@Loc.WOOperationTsu">
                <input type="text"
                       id="@string.Format("{0}-{1}","Tpf",itemResourceNum)"
                       name="Tpf"
                       required
                       class="form-control numberInput"
                       placeholder="@Loc.WOOperationTsu"
                       value=@Tpz.ToString("N2") />
            </td>

            <td>
                <button id="addDailyAllow"
                        type="button"
                        onclick="AddRow('#ResourceWorkersCreate-@itemResourceNum', '#ResourceWorkersPrefix-@itemResourceNum', '#ResourceWorkersTable-@itemResourceNum')"
                        class="btn btn-success add-del-allow-expense">
                    <i class="fa fa-plus"></i>
                </button>
            </td>

        </tr>

    </tbody>
</table>

