@using PantheonRA.WebApi.Contracts.Enums;

@if (!PantheonRA.BackOffice.CurrentUser.HasGranules() && PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.MATERIAL_BUSINESS))
{
    <li data-list-item-id="MaterialBusiness"
        class="dropdown @Html.IsSelected("Index", "ReceivedBills") @Html.IsSelected("Create", "ReceivedBills") @Html.IsSelected("Edit", "ReceivedBills")
                    @Html.IsSelected("ReceivedBillsBilling", "ReceivedBills") @Html.IsSelected("IssuedAdvancePayments", "ReceivedBills")
                    @Html.IsSelected("CreateIssuedAdvancePayment", "AdvancePayment") @Html.IsSelected("EditIssuedAdvancePayment", "AdvancePayment")">
        <a href="@Url.Action("Create", "ReceivedBills")">
            <i class="fas fa-dolly"></i> <span class="nav-label">@Loc.PurchasesNavMenu</span>
        </a>
        <ul class="dropdown-menu dropdown-menu-right">
            @if (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.MATERIAL_BUSINESS_INVOICES))
            {
                <li><a href="@Url.Action("Create", "ReceivedBills")">@Loc.NewReceivedBills.SetMenuNameLength()</a></li>
            }
            @if (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.MATERIAL_BUSINESS_INVOICES))
            {
                <li><a href="@Url.Action("Index", "ReceivedBills")">@Loc.PurchaseReceivedBillsBilling.SetMenuNameLength()</a></li>
            }
            @if (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.ISSUED_ADVANCE_PAYMENTS))
            {
                <li><a href="@Url.Action("CreateIssuedAdvancePayment", "AdvancePayment")">@Loc.NewIssuedAdvancePayment.SetMenuNameLength()</a></li>
            }
            @if (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.ISSUED_ADVANCE_PAYMENTS))
            {
                <li><a href="@Url.Action("IssuedAdvancePayments", "ReceivedBills")">@Loc.AdvancePaymentsList.SetMenuNameLength()</a></li>
            }
        </ul>
    </li>
}

@if ((!PantheonRA.BackOffice.CurrentUser.HasGranules() || PantheonRA.BackOffice.CurrentUser.HasGranule(Granules.B2BGranule)) &&
    (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PAW_ORDERS_BUYER) ||
    PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PAW_ORDERS_SUPPLIER)))
{
    <li data-list-item-id="Orders"
        class="dropdown @Html.IsSelected("Index", "Order") @Html.IsSelected("EditBuyerOrder", "Order")
        @Html.IsSelected("CreateBuyerOrder", "Order") @Html.IsSelected("EditSupplierOrder", "Order")
        @Html.IsSelected("CreateSupplierOrder", "Order") @Html.IsSelected("BuyerOrdersReport", "Order")
        @Html.IsSelected("SupplierOrdersReport", "Order")">
        <a href="@Url.Action("CreateBuyerOrder", "Order")">
            <i class="fas fa-file-import"></i> <span class="nav-label">@(PantheonRA.BackOffice.CurrentUser.HasGranule(Granules.B2BGranule) ? Loc.OrdersBuyer : Loc.OrdersNavMenu)</span>
        </a>
        <ul class="dropdown-menu dropdown-menu-right">
            @if (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PAW_ORDERS_BUYER))
            {
                <li><a href="@Url.Action("CreateBuyerOrder", "Order")">@Loc.NewOrdersBuyer.SetMenuNameLength()</a></li>
            }
            @if (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PAW_ORDERS_BUYER) && !PantheonRA.BackOffice.CurrentUser.HasGranule(Granules.B2BGranule))
            {
                <li id="menu-order-calendar-item" class="hidden">
                    <a href="@Url.Action("CreateBuyerOrder", "Order", new { calendarTab = true })">@Loc.Calendar.SetMenuNameLength()</a>
                </li>
            }
            @if (PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PAW_ORDERS_BUYER))
            {
                <li><a href="@Url.Action("BuyerOrdersReport", "Order")">@Loc.OrdersBuyersList.SetMenuNameLength()</a></li>
            }
            @if (!PantheonRA.BackOffice.CurrentUser.HasGranules() && PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PAW_ORDERS_SUPPLIER))
            {
                <li><a href="@Url.Action("CreateSupplierOrder", "Order")">@Loc.NewOrdersSupplier.SetMenuNameLength()</a></li>
            }
            @if (!PantheonRA.BackOffice.CurrentUser.HasGranules() && PantheonRA.BackOffice.CurrentUser.CanAccess(PantheonRA.WebApi.Contracts.Enums.Permissions.PAW_ORDERS_SUPPLIER))
            {
                <li><a href="@Url.Action("SupplierOrdersReport", "Order")">@Loc.OrdersSuppliersList.SetMenuNameLength()</a></li>
            }
        </ul>
    </li>
}