@using System.Linq @using Resto.Front.PrintTemplates.Cheques.Razor @using Resto.Front.PrintTemplates.Cheques.Razor.TemplateModels @using Resto.Front.PrintTemplates.RmsEntityWrappers @inherits TemplateBase @{ var order = Model.Order; IKitchenOrderProductItem productItem; IKitchenOrderProductItem compoundItemSecondaryComponent = null; IKitchenOrderModifierItem modifierItem; if (Model.Item is IKitchenOrderProductItem) { productItem = (IKitchenOrderProductItem)Model.Item; if (Model.CompoundItemSecondaryComponent != null) { compoundItemSecondaryComponent = Model.CompoundItemSecondaryComponent; } modifierItem = null; } else { modifierItem = (IKitchenOrderModifierItem)Model.Item; productItem = order.Items.Single(item => item.Modifiers.Contains(modifierItem)); } var course = productItem.Course; } @if(Model.Order.Type != null && Model.Order.Type.Name == "DINE-IN"){
@Model.Order.Type.Name №@order.Number
@string.Format(Resources.KitchenHeaderPattern, FormatFullDateTime(Model.CommonInfo.CurrentTime), order.Number, 1, order.Waiter.GetNameOrEmpty()) @if (course != 1) { @GetCourseTitle(course) } @if (modifierItem == null) { @ProductTable(productItem) if (HasModifiersToPrint(productItem)) { @ModifiersTable(productItem) } if (compoundItemSecondaryComponent != null) { @ProductTable(compoundItemSecondaryComponent) if (HasModifiersToPrint(productItem)) { @ModifiersTable(compoundItemSecondaryComponent) } } if (Model.CookingPlace.PrintKitchenBarcodeType != PrintKitchenBarcodeType.Never) {
@productItem.ServiceChequeBarcode
} } else { @ModifierProductTable(modifierItem) }
} else { } @helper ProductTable(IKitchenOrderProductItem product) { if (product.CompoundsInfo != null && product.CompoundsInfo.IsPrimaryComponent) { @TableColumns() @FormatAmount(product.Amount * 2) @string.Format("{0} {1}", product.CompoundsInfo.ModifierSchemaName, product.ProductSize == null ? string.Empty : product.ProductSize.Name)
@ModifiersTable(product, true) } var componentString = string.Empty; if (product.CompoundsInfo != null) { componentString = " 1/2 "; } @TableColumns() @if (product.CompoundsInfo == null) { @FormatAmount(product.Amount) } else { } @(Model.CookingPlace == product.Kitchen ? componentString + GetProductKitchenNameWithSize(product) : componentString + string.Format(Resources.CookingPlaceTemplate, product.Kitchen.Name, GetProductKitchenNameWithSize(product)))
} @helper ModifierProductTable(IKitchenOrderModifierItem modifier) { @TableColumns() @FormatAmount(modifier.Amount) @(Model.CookingPlace == modifier.Kitchen ? modifier.Product.GetKitchenOrDefaultName() : string.Format(Resources.CookingPlaceTemplate, modifier.Kitchen.Name, modifier.Product.GetKitchenOrDefaultName()))
} @helper ModifiersTable(IKitchenOrderProductItem productItem, bool onlyCommonModifiers = false) { var commentText = productItem.Comment != null && !productItem.Comment.Deleted ? productItem.Comment.Text : null; var modifiers = productItem.Modifiers.Where(m => CommonModifiersFilter(m.IsCommonModifier, productItem, onlyCommonModifiers) && !m.Deleted && !m.IsHidden).ToList(); var productsOfZeroAmountModifiers = productItem.CompoundsInfo == null ? productItem.ProductsOfZeroAmountCommonModifiers.Concat(productItem.ProductsOfZeroAmountModifiers) : productItem.CompoundsInfo.IsPrimaryComponent && onlyCommonModifiers ? productItem.ProductsOfZeroAmountCommonModifiers : productItem.ProductsOfZeroAmountModifiers; @TableColumns() @if (commentText != null) { @commentText } @{ var parentAmount = GetParentAmount(productItem, onlyCommonModifiers); foreach (var modifier in modifiers) { @(modifier.AmountIndependentOfParentAmount ? string.Format(Resources.KitchenModifierAbsoluteAmountPattern, modifier.Amount) : string.Format(Resources.KitchenModifierAmountPattern, (int)(modifier.Amount / parentAmount))) @(Model.CookingPlace == modifier.Kitchen ? modifier.Product.GetKitchenOrDefaultName() : string.Format(Resources.CookingPlaceTemplate, modifier.Kitchen.Name, modifier.Product.GetKitchenOrDefaultName())) } } @foreach (var product in productsOfZeroAmountModifiers) { @string.Format(Resources.KitchenModifierAmountPattern, 0m) @(Model.CookingPlace == productItem.Kitchen ? product.GetKitchenOrDefaultName() : string.Format(Resources.CookingPlaceTemplate, productItem.Kitchen.Name, product.GetKitchenOrDefaultName())) }
} @helper TableColumns() { } @functions { private static string GetCourseTitle(int course) { switch (course) { case 0: return Resources.KitchenCourseVipTitle; case 1: return Resources.KitchenCourse1Title; case 2: return Resources.KitchenCourse2Title; case 3: return Resources.KitchenCourse3Title; case 4: return Resources.KitchenCourse4Title; default: return string.Format(Resources.KitchenCourseTitleFormat, course); } } private static bool HasModifiersToPrint(IKitchenOrderProductItem productItem) { if (productItem.Comment != null && !productItem.Comment.Deleted) return true; if (productItem.Modifiers.Any(modifier => !modifier.Deleted && !modifier.IsHidden)) return true; return productItem.ProductsOfZeroAmountModifiers.Any(); } private static bool CommonModifiersFilter(bool isCommonModifier, IKitchenOrderProductItem parent, bool onlyCommonModifiers) { if (parent.CompoundsInfo != null && parent.CompoundsInfo.IsPrimaryComponent) { if (onlyCommonModifiers && !isCommonModifier) return false; if (!onlyCommonModifiers && isCommonModifier) return false; return true; } return true; } private static string GetProductKitchenNameWithSize(IKitchenOrderProductItem productItem) { return productItem.ProductSize == null || productItem.CompoundsInfo != null ? productItem.Product.GetKitchenOrDefaultName() : string.Format(Resources.ProductNameWithSizeFormat, productItem.Product.GetKitchenOrDefaultName(), productItem.ProductSize.Name); } private static decimal GetParentAmount(IKitchenOrderItem parent, bool onlyCommonModifiers) { return onlyCommonModifiers ? parent.Amount * 2 : parent.Amount; } }