<?php
$category = !empty($category[0]) ? $category[0] : array();
$menus = !empty($category) ? $menus[$category->id] : array();
?>
<div class="order-menu-list">
    <div class="menupage-category-info">
        <?php if (!empty($category)): ?>
            <ol class="breadcrumb breadcrumb-arrow">
                <li><a href="javascript:void(0)" onclick="listMenus('<?php echo $breadcrumb_category ?>', '<?php echo $breadcrumb_index ?>', '<?php echo $breadcrumb_offset ?>', '<?php echo $breadcrumb_is_special ?>')"><?php echo!empty($category) ? $category->title : '' ?></a></li>
                <li id="menuBreadcurmb"></li>
                <li id="selectrionBreadcurmb"></li>
            </ol>
        <?php endif; ?>
    </div>
    <div id="menuListArea">
        <?php if (!empty($category)): ?>
            <?php if (!empty($menus)): ?>
                <input type="hidden" id="ListCategoryId" value="<?php echo $category->id ?>">
                <input type="hidden" id="ListCategoryIsSpecial" value="<?php echo $category->is_special ?>">
                <input type="hidden" id="ListCategoryIndex" value="<?php echo $index ?>">
                <input type="hidden" id="menuPrevPage" value="<?php echo $menuPrevPage ?>">
                <input type="hidden" id="menuNextPage" value="<?php echo $menuNextPage ?>">
                <?php foreach ($menus as $amenu): ?>
                    <?php if (!empty($selections[$category->id][$amenu->id])): ?>
                        <div class="menu-block">
                            <a class="inline item-btn item-btn-<?php echo $index ?> col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center" onclick="openSelectionBox('#inline_content<?php echo $amenu->id ?>', '<?php echo ucwords(strtolower($amenu->title)) ?>')"><?php echo ucwords(strtolower($amenu->title)) ?></a>
                        </div>
                        <div  id='inline_content<?php echo $amenu->id ?>' style='padding:3px; display: none;'>
                            <?php foreach ($selections[$category->id][$amenu->id] as $asel): ?>
                                <?php if ($asel->is_special == 'yes' && $asel->deal != null && $asel->deal > 0): ?>
                                    <?php $adeal = get_single_record('meal_deal', array('id' => $asel->deal)) ?>
                                    <?php if (!empty($adeal)): ?>
                                        <?php
                                        $deal_sets = get_record_list('meal_deal_set', array('deal' => $adeal->id, 'status' => 1));
                                        $deal_toppings = get_record_list('item_toppings', array('meal_deal' => $adeal->id, 'status' => 1));
                                        $deal_toppings_deafault = get_record_list('item_toppings', array('meal_deal' => $adeal->id, 'status' => 1, 'is_default' => 'yes'));
                                        $dealToppingsDefaultString = '';
                                        if (!empty($deal_toppings_deafault)) {
                                            foreach ($deal_toppings_deafault as $defaultTopping) {
                                                $dealToppingsDefaultString .= ',' . $defaultTopping->title;
                                            }
                                        }
                                        ?>
                                        <form id="dealForm_<?php echo $adeal->id ?>">
                                            <input type="hidden" name="order_id" value="<?php echo $order_id ?>">
                                            <input type="hidden" name="quantity" value="1">
                                            <input type="hidden" name="content" value="<?php echo $adeal->content ?>">
                                            <input type="hidden" name='category' value='<?php echo $category->id ?>'>
                                            <input type="hidden" name='category_title' value='<?php echo ucwords(strtolower($category->title)) ?>'>
                                            <input type='hidden' name='print_option' value='<?php echo $category->print_option ?>'>
                                            <input type='hidden' name='type' value='<?php echo $category->type ?>'>
                                            <input type="hidden" name='is_special' value='<?php echo $category->is_special ?>'>
                                            <input type="hidden" name='menu' value='<?php echo $adeal->id ?>'>
                                            <input type="hidden" name='menu_title' value='<?php echo ucwords(strtolower($adeal->title)) ?>'>
                                            <input type="hidden" name='selection' value=''>
                                            <input type="hidden" name='selection_title' value=''>
                                            <input type="hidden" name='set_items' value='' id='dealSetItems_<?php echo $adeal->id ?>'>
                                            <input type="hidden" name='price' value='<?php echo to_currency_no_money($adeal->price) ?>' id="dealHiddenPriceFor_<?php echo $adeal->id ?>">
                                            <input type="hidden" name="toppings" value="<?php echo $dealToppingsDefaultString ?>" id="dealToppingsString_<?php echo $adeal->id ?>">
                                            <input type="hidden" name='toppings_counter' id='toppingsCounter_<?php echo $adeal->id ?>' value="0">
                                            <input type="hidden" name='bogo' value='<?php echo $adeal->bogo ?>'>
                                            <input type="hidden" name='bogo_discount_on' value='deal'>
                                            <input type="hidden" name='deal' value='<?php echo $adeal->id ?>'>
                                            <?php if (!empty($deal_sets) || !empty($deal_toppings)): ?>
                                                <div class="item-btn item-btn-<?php echo $index ?> col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center" onclick="openPopupBox('<?php echo "dealSetBox_" . $adeal->id ?>', 'dealForm_<?php echo $adeal->id ?>')"><?php echo ucwords(strtolower($adeal->title)) ?></div>
                                                <div id="<?php echo "dealSetBox_" . $adeal->id ?>" class="modal modal-message modal-danger fade" style="display: none;" aria-hidden="true">
                                                    <div class="modal-dialog">
                                                        <div class="modal-content">
                                                            <div class="modal-header">
                                                                <div class="modal-title">
                                                                    <div class="col-lg-11 col-md-11 col-sm-11"><?php echo ucwords(strtolower('Prepare ' . $adeal->title . ' using the following sets')) ?></div>
                                                                    <div class="col-lg-1 col-md-1 col-sm-1" data-dismiss="modal" aria-hidden="true"  aria-label="Close" style="cursor: default"><i class="fa fa-close"></i></div>
                                                                </div>
                                                            </div>
                                                            <div class="modal-body">
                                                                <ul class="list-group">
                                                                    <?php if (!empty($deal_sets)): ?>
                                                                        <?php $setindex = 0; ?>
                                                                        <?php $set_ids = ''; ?>
                                                                        <?php foreach ($deal_sets as $aset): ?>
                                                                            <?php $set_ids .= $aset->id . '_'; ?>
                                                                            <?php $deal_set_menus = get_record_list('meal_deal_menu', array('deal' => $adeal->id, 'set' => $aset->id)) ?>
                                                                            <?php if (!empty($deal_set_menus)): ?>
                                                                                <li class="list-group-item">
                                                                                    <div class="item-btn deal-set-btn menu-item item-btn-<?php echo $index ?> text-center" onclick="showExtra('<?php echo 'dealSet_' . $aset->id ?>', 'noForm')">
                                                                                        <h5 class="text-center text-uppercase" id="setTitleFor_<?php echo $aset->id ?>">  <?php echo ucwords(strtolower($aset->title)) ?></h5>
                                                                                        <p class="text-center"><span style="font-size: 12px; font-weight: bold; text-transform: capitalize">[Any <?php echo $aset->allowed ?> items can be chosen from this set]</span></p>
                                                                                    </div>
                                                                                    <ul class="list-group show-extra" style="width: 100%;display: none;" id="dealSet_<?php echo $aset->id ?>">
                                                                                        <li class="list-group-item checkbox">
                                                                                            <?php
                                                                                            foreach ($deal_set_menus as $set_item) {
                                                                                                $menuId = $set_item->menu;
                                                                                                $menuInfo = get_menu_info_by_id($set_item->menu);
                                                                                                if (!empty($menuInfo)) {
                                                                                                    $menuSelObj = get_record_list('meal_deal_selection', array('deal' => $set_item->deal, 'set' => $set_item->set, 'cat' => $set_item->cat, 'menu' => $set_item->menu));
                                                                                                    if (!empty($menuSelObj)) {
                                                                                                        foreach ($menuSelObj as $menSel) {
                                                                                                            $menuId = $set_item->menu . '_' . $menSel->selection;
                                                                                                            $selInfo = get_selection_info_by_id($menSel->selection);
                                                                                                            if (!empty($selInfo)) {
                                                                                                                ?>
                                                                                                                <label style="font-size: 2em; width: 100%;" class="text-left btn-primary btn-block sharp btn-sm">
                                                                                                                    <input type="checkbox" name="set_menus[]" value="<?php echo html_escape(ucwords(strtolower($selInfo->title)) . '-' . ucwords(strtolower($menuInfo->title))) ?>" id='dealSetItemsCheckbox_<?php echo $adeal->id . '_' . $aset->id . '_' . $menuId ?>' onclick="calculateDealSetInfo('<?php echo $adeal->id ?>', '<?php echo $aset->id ?>', '<?php echo $menuId ?>', 'dealForm_<?php echo $adeal->id ?>', '<?php echo $aset->allowed ?>')"><span class="cr"><i class="cr-icon fa fa-check"></i></span><span class="pull-left" style="font-size: 20px;padding-top: 5px;"><?php echo ucwords(strtolower($selInfo->title)) . '-' . ucwords(strtolower($menuInfo->title)) ?></span>
                                                                                                                </label>
                                                                                                            <?php } ?>
                                                                                                        <?php } ?>
                                                                                                        <?php
                                                                                                    } else {
                                                                                                        ?>
                                                                                                        <label style="font-size: 2em; width: 100%;" class="text-left btn-primary btn-block sharp btn-sm">
                                                                                                            <input type="checkbox" name="set_menus[]" id='dealSetItemsCheckbox_<?php echo $adeal->id . '_' . $aset->id . '_' . $menuId ?>' onclick="calculateDealSetInfo('<?php echo $adeal->id ?>', '<?php echo $aset->id ?>', '<?php echo $menuId ?>', 'dealForm_<?php echo $adeal->id ?>', '<?php echo $aset->allowed ?>')" value="<?php echo html_escape(ucwords(strtolower($menuInfo->title))) ?>"><span class="cr"><i class="cr-icon fa fa-check"></i></span><span class="pull-left" style="font-size: 20px;padding-top: 5px;"><?php echo ucwords(strtolower($menuInfo->title)) ?></span>
                                                                                                        </label>
                                                                                                    <?php } ?>
                                                                                                <?php } ?>    
                                                                                            <?php }; ?>
                                                                                        </li>
                                                                                        <input type='hidden' id='setItemCounter_<?php echo $adeal->id . '_' . $aset->id ?>' value='0'> 
                                                                                    </ul>
                                                                                </li>
                                                                                <?php $setindex++; ?>    
                                                                            <?php endif; ?>
                                                                        <?php endforeach; ?>
                                                                    <?php endif; ?>
                                                                    <?php if (!empty($deal_toppings)): ?>
                                                                        <?php
                                                                        $unorganizedToppings = $deal_toppings;
                                                                        $organizedToppings = array();
                                                                        foreach ($unorganizedToppings as $key => $item) {
                                                                            $organizedToppings[$item->top_cat][] = $item;
                                                                        }
                                                                        ?>    
                                                                        <li class="list-group-item">
                                                                            <div class="item-btn deal-set-btn menu-item item-btn item-btn-toppings text-center deal-toppings" onclick="showExtra('<?php echo 'dealToppings_' . $adeal->id ?>', 'noForm')">
                                                                                <?php
                                                                                $toopingsInformation = '';
                                                                                if ($adeal->free_toppings > 0) {
                                                                                    $toopingsInformation .= ' Free Toppings: ' . $adeal->free_toppings;
                                                                                }
                                                                                if ($adeal->max_toppings > 0) {
                                                                                    $toopingsInformation .= ' Maximum Toppings: ' . $adeal->max_toppings;
                                                                                }
                                                                                ?>
                                                                                <p class="text-center text-uppercase" style="line-height: 1">Choose Toppings of this deal if want <?php trim($toopingsInformation) != null ? print '<br/><span style="text-transform:capitalize;">' . $toopingsInformation . '</span>' : '' ?></p>

                                                                            </div>
                                                                            <ul class="list-group show-extra" style="width: 100%;display: none;" id="dealToppings_<?php echo $adeal->id ?>">
                                                                                <li class="list-group-item checkbox">
                                                                                    <div class="list-group">
                                                                                        <?php foreach ($organizedToppings as $ToppingCategoryId => $toppingsCategory): ?>
                                                                                            <?php $toppingCategoryInfo = get_topping_category_name($ToppingCategoryId) ?>
                                                                                            <div class="list-group-item text-left">
                                                                                                <div class="text-left checkbox">
                                                                                                    <label style="width: 100%;color: #000;" data-toggle="collapse" data-target="#toppingCategory_<?php echo $ToppingCategoryId . '_' . $adeal->id ?>" id="collapseToppingCategory_<?php echo $ToppingCategoryId . '_' . $adeal->id ?>">
                                                                                                        <input type="checkbox" style="color: #000000;"> <?php echo $toppingCategoryInfo->title ?>&nbsp;[Maximum <?php echo $toppingCategoryInfo->max_select ?>]
                                                                                                        <input type="hidden" id="maximumCategoryTopping_<?php echo $toppingCategoryInfo->id . '_' . $adeal->id ?>" value="<?php echo $toppingCategoryInfo->max_select ?>">
                                                                                                        <input type="hidden" id="maxmumCategoryToppingCounter_<?php echo $toppingCategoryInfo->id . '_' . $adeal->id ?>" value="0" class="empty-counter">
                                                                                                    </label>
                                                                                                </div>
                                                                                                <div class="row collapse" id="toppingCategory_<?php echo $ToppingCategoryId . '_' . $adeal->id ?>">
                                                                                                    <?php foreach ($toppingsCategory as $deal_topping): ?>
                                                                                                        <label style="font-size: 2em; width: 100%; padding-left: 50px;" class="text-left btn-warning btn-block sharp btn-sm">
                                                                                                            <input <?php $deal_topping->is_default == 'yes' ? print'checked="checked" disabled="true"' : '' ?> type="checkbox" id='dealTopping_<?php echo $adeal->id . '_' . $deal_topping->id ?>'  value="<?php echo ucwords(strtolower($deal_topping->title)) ?>" onclick="calculateDealToppingsInfo('<?php echo $adeal->id ?>', '<?php echo $deal_topping->id ?>', 'dealForm_<?php echo $adeal->id ?>', '<?php echo $adeal->max_toppings ?>', '<?php $adeal->free_toppings > 0 ? print $adeal->free_toppings : print 0 ?>', '<?php echo $adeal->price ?>', '<?php echo $deal_topping->top_cat ?>')"><span class="cr">
                                                                                                                <i class="cr-icon fa fa-check"></i></span>
                                                                                                            <span class="pull-left" style="font-size: 20px;padding-top: 5px;">
                                                                                                                <?php echo ucwords(strtolower($deal_topping->title)) . '&nbsp;[&nbsp;+&nbsp;' . to_currency($deal_topping->price) . '&nbsp;]' ?>
                                                                                                            </span>
                                                                                                            <input type="hidden" id='dealToppingPrice_<?php echo $adeal->id . '_' . $deal_topping->id ?>' value="<?php echo $deal_topping->price ?>">
                                                                                                        </label>
                                                                                                    <?php endforeach; ?>
                                                                                                </div>
                                                                                            </div>
                                                                                        <?php endforeach; ?>
                                                                                    </div>
                                                                                </li>
                                                                            </ul>
                                                                        </li> 
                                                                    <?php endif; ?>
                                                                    <ul class="list-group" id="dealStringDisplay_<?php echo $adeal->id ?>" style="display: none;">
                                                                        <li class="list-group-item">
                                                                            <ul class="list-group">
                                                                                <li class="list-group-item" id="dealItemsDisplayLi_<?php echo $adeal->id ?>">Items:&nbsp;<span id="dealItemsDisplay_<?php echo $adeal->id ?>"></span></li>
                                                                                <li class="list-group-item" id="dealToppingsDisplayLi_<?php echo $adeal->id ?>">Toppings:&nbsp;<span id="dealToppingsDisplay_<?php echo $adeal->id ?>"></span><span style="display: none;" id="dealToppingsPriceDisplay_<?php echo $adeal->id ?>"><span>+ <?php echo $this->config->item('currency_symbol') ?></span><span class="price"></span></span></li>
                                                                            </ul>
                                                                        </li>
                                                                    </ul>    
                                                                    <li class="list-group-item">
                                                                        <input type="hidden" id="DealSetQuantity_<?php echo $adeal->id ?>" value="<?php echo $setindex ?>">
                                                                        <input type="hidden" id="DealSetIds_<?php echo $adeal->id ?>" value="<?php echo $set_ids ?>">
                                                                        <input type="hidden" id="DealToppingsPriceTotal_<?php echo $adeal->id ?>" value="0">
                                                                        <button type="button" class="btn btn-danger" style="width: 100%; height: 75px;" onclick="submitDeal('<?php echo $adeal->id ?>', 'dealForm_<?php echo $adeal->id ?>')">Add Now</button>
                                                                    </li>    
                                                                </ul>
                                                            </div>
                                                        </div> 
                                                    </div>
                                                </div>
                                            <?php else: ?>
                                                <div class="item-btn item-btn-<?php echo $index ?> col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center" onclick="submit('dealForm_<?php echo $adeal->id ?>')"><?php echo ucwords(strtolower($adeal->title)) ?></div>
                                            <?php endif; ?>
                                        </form>
                                    <?php endif; ?>
                                <?php else: ?>
                                    <form id="selectionForm_<?php echo $asel->id ?>">
                                        <?php
                                        $existingSelToppings = get_record_list('item_toppings', array('selection' => $asel->id, 'status' => 1));
                                        $existingSelToppingsDefault = get_record_list('item_toppings', array('selection' => $asel->id, 'status' => 1, 'is_default' => 'yes'));
                                        $selToppingsDefaultString = '';
                                        if (!empty($existingSelToppingsDefault)) {
                                            foreach ($existingSelToppingsDefault as $defaultTopping) {
                                                $selToppingsDefaultString .= ',' . $defaultTopping->title;
                                            }
                                        }
                                        ?>
                                        <?php
                                        $price = to_currency_no_money(0);
                                        if ($currentOrderType == 'table') {
                                            $price = $asel->in_price > 0 ? to_currency_no_money($asel->in_price) : to_currency_no_money($asel->base_price);
                                        } else {
                                            $price = $asel->out_price > 0 ? to_currency_no_money($asel->out_price) : to_currency_no_money($asel->base_price);
                                        }
                                        ?>
                                        <input type="hidden" name="order_id" value="<?php echo $order_id ?>">
                                        <input type="hidden" name="quantity" value="1">
                                        <input type="hidden" name="content" value="<?php echo $asel->content ?>">
                                        <input type="hidden" name='category' value='<?php echo $category->id ?>'>
                                        <input type="hidden" name='category_title' value='<?php echo ucwords(strtolower($category->title)) ?>'>
                                        <input type='hidden' name='print_option' value='<?php echo $category->print_option ?>'>
                                        <input type='hidden' name='type' value='<?php echo $category->type ?>'>
                                        <input type="hidden" name='is_special' value='<?php echo $category->is_special ?>'>
                                        <input type="hidden" name='menu' value='<?php echo $amenu->id ?>'>
                                        <input type="hidden" name='menu_title' value='<?php echo ucwords(strtolower($amenu->title)) ?>'>
                                        <input type="hidden" name='selection' value='<?php echo $asel->id ?>'>
                                        <input type="hidden" name='selection_title' value='<?php echo ucwords(strtolower($asel->title)) ?>'>
                                        <input type="hidden" name='set_items' value='' class="empty-string">
                                        <input type="hidden" value='<?php echo to_currency_no_money($price) ?>' class="orginal-price">
                                        <input type="hidden" name='price' value='<?php echo $price ?>' id="hiddenPriceFor_<?php echo $amenu->id . '_' . $asel->id ?>">
                                        <input type="hidden" name="toppings" value="<?php echo $selToppingsDefaultString ?>"  id="toppingsString_<?php echo $amenu->id . '_' . $asel->id ?>" class="empty-string">
                                        <input type="hidden" id='selectionToppingsCounter_<?php echo $amenu->id . '_' . $asel->id ?>' value="0" class="empty-counter">
                                        <input  type="hidden"id="selectionToppingsPriceTotal_<?php echo $amenu->id . '_' . $asel->id ?>" value="0" class="empty-counter"/> 
                                        <input type="hidden" name='bogo' value='<?php echo $asel->bogo ?>'>
                                        <input type="hidden" name='bogo_discount_on' value='selection'>
                                        <input type="hidden" name='deal' value=''>
                                        <?php if (!empty($existingSelToppings)): ?>
                                            <div class="selection-block">
                                                <div class="item-btn item-btn-<?php echo $index ?> col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center"  onclick="openSlectionBoxTopping('SelectionToppingBox_<?php echo $asel->id ?>', '<?php echo'selectionForm_' . $asel->id ?>', ' <?php echo ucwords(strtolower($asel->title)) ?>')"> <?php echo ucwords(strtolower($asel->title)) ?></div>
                                            </div>
                                            <?php
                                            $organizedSelectionToppings = array();
                                            foreach ($existingSelToppings as $key => $item) {
                                                $organizedSelectionToppings[$item->top_cat][] = $item;
                                            }
                                            ?>
                                            <div id="SelectionToppingBox_<?php echo $asel->id ?>" class="toppings-block-box" style="display: none;">
                                                <div class="list-group">
                                                    <?php foreach ($organizedSelectionToppings as $ToppingCategoryId => $toppingsCategory): ?>
                                                        <?php $toppingCategoryInfo = get_topping_category_name($ToppingCategoryId) ?>
                                                        <div class="list-group-item text-left">
                                                            <div class="text-left checkbox">
                                                                <label style="width: 100%;" data-toggle="collapse" data-target="#toppingCategory_<?php echo $ToppingCategoryId . '_' . $category->id . '_' . $amenu->id . '_' . $asel->id ?>" id="collapseToppingCategory_<?php echo $ToppingCategoryId . '_' . $amenu->id . '_' . $asel->id ?>">
                                                                    <input type="checkbox" style="color: #000000;"> <?php echo $toppingCategoryInfo->title ?>&nbsp;[Maximum <?php echo $toppingCategoryInfo->max_select ?>]
                                                                    <input type="hidden" id="maximumCategoryTopping_<?php echo $toppingCategoryInfo->id . '_' . $amenu->id . '_' . $asel->id ?>" value="<?php echo $toppingCategoryInfo->max_select ?>">
                                                                    <input type="hidden" id="maxmumCategoryToppingCounter_<?php echo $toppingCategoryInfo->id . '_' . $amenu->id . '_' . $asel->id ?>" value="0" class="empty-counter">
                                                                </label>
                                                            </div>
                                                            <div class="row collapse" id="toppingCategory_<?php echo $ToppingCategoryId . '_' . $category->id . '_' . $amenu->id . '_' . $asel->id ?>">
                                                                <?php foreach ($toppingsCategory as $atopping): ?>
                                                                    <div class="col-sm-4">
                                                                        <label style="min-height: 50px; width: 100%" class=" menu-item text-center item-btn item-btn-<?php echo $index ?>">
                                                                            <span style="font-size: 12px;padding-top: 5px;"><?php echo ucwords(strtolower($atopping->title)) ?>&nbsp;&nbsp;[<?php $atopping->price > 0 ? print to_currency($atopping->price) : print to_currency(0) ?>]</span><br/>
                                                                            <input <?php $atopping->is_default == 'yes' ? print 'checked="checked" disabled="true"' : '' ?> type="checkbox" value="<?php echo ucwords(strtolower($atopping->title)) ?>" id='topping_<?php echo $amenu->id . '_' . $asel->id . '_' . $atopping->id ?>' onclick="calculateSelectionToppingsInfo('<?php echo $amenu->id ?>', '<?php echo $asel->id ?>', '<?php echo $atopping->id ?>', 'selectionForm_<?php echo $asel->id ?>', '<?php $asel->max_toppings > 0 ? print $asel->max_toppings : print 0 ?>', '<?php $asel->free_toppings > 0 ? print $asel->free_toppings : print 0 ?>', '<?php echo to_currency_no_money($asel->in_price > 0 ? $asel->in_price : $asel->base_price) ?>', '<?php echo $atopping->top_cat ?>')">
                                                                            <input type="hidden" id='toppingPrice_<?php echo $amenu->id . '_' . $asel->id . '_' . $atopping->id ?>'  value="<?php echo $atopping->price ?>">
                                                                        </label>
                                                                    </div>
                                                                <?php endforeach; ?>
                                                            </div>
                                                        </div>
                                                    <?php endforeach; ?>
                                                    <div class="list-group-item">
                                                        <label id="additionaSelectionPriceLabel_<?php echo $asel->id ?>" style="font-size: 1em; width: 100%; height: 40px; display: none" class="text-center  additional-label"><span>+&nbsp;<?php echo $this->config->item('currency_symbol') ?></span><span class="price"></span></label>
                                                        <label style="font-size: 1em; width: 100%; height: 40px;color: #FFF;" class="text-center btn btn-danger btn-block toppings-after-submit" onclick="submit('selectionForm_<?php echo $asel->id ?>')">Add</label>
                                                    </div>
                                                </div>
                                            </div>
                                        <?php else: ?>
                                            <div class="selection-block">
                                                <div class="item-btn item-btn-<?php echo $index ?> col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center" onclick="submit('selectionForm_<?php echo $asel->id ?>')"><?php echo ucwords(strtolower($asel->title)) ?></div>
                                            </div>
                                        <?php endif ?>
                                    </form>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        </div>
                    <?php else: ?>
                        <?php if ($amenu->is_special == 'yes' && $amenu->deal != null && $amenu->deal > 0): ?>
                            <?php $adeal = get_single_record('meal_deal', array('id' => $amenu->deal)) ?>
                            <?php if (!empty($adeal)): ?>
                                <?php
                                $deal_sets = get_record_list('meal_deal_set', array('deal' => $adeal->id, 'status' => 1));
                                $deal_toppings = get_record_list('item_toppings', array('meal_deal' => $adeal->id, 'status' => 1));
                                $deal_toppings_deafault = get_record_list('item_toppings', array('meal_deal' => $adeal->id, 'status' => 1, 'is_default' => 'yes'));
                                $dealToppingsDefaultString = '';
                                if (!empty($deal_toppings_deafault)) {
                                    foreach ($deal_toppings_deafault as $defaultTopping) {
                                        $dealToppingsDefaultString .= ',' . $defaultTopping->title;
                                    }
                                }
                                ?>
                                <form id="dealForm_<?php echo $adeal->id ?>">
                                    <input type="hidden" name="order_id" value="<?php echo $order_id ?>">
                                    <input type="hidden" name="quantity" value="1">
                                    <input type="hidden" name="content" value="<?php echo $adeal->content ?>">
                                    <input type="hidden" name='category' value='<?php echo $category->id ?>'>
                                    <input type="hidden" name='category_title' value='<?php echo ucwords(strtolower($category->title)) ?>'>
                                    <input type='hidden' name='print_option' value='<?php echo $category->print_option ?>'>
                                    <input type='hidden' name='type' value='<?php echo $category->type ?>'>
                                    <input type="hidden" name='is_special' value='<?php echo $category->is_special ?>'>
                                    <input type="hidden" name='menu' value='<?php echo $adeal->id ?>'>
                                    <input type="hidden" name='menu_title' value='<?php echo ucwords(strtolower($adeal->title)) ?>'>
                                    <input type="hidden" name='selection' value=''>
                                    <input type="hidden" name='selection_title' value=''>
                                    <input type="hidden" name='set_items' value='' id='dealSetItems_<?php echo $adeal->id ?>'>
                                    <input type="hidden" name='price' value='<?php echo to_currency_no_money($adeal->price) ?>' id="dealHiddenPriceFor_<?php echo $adeal->id ?>">
                                    <input type="hidden" name="toppings" value="<?php echo $dealToppingsDefaultString ?>" id="dealToppingsString_<?php echo $adeal->id ?>">
                                    <input type="hidden" name='toppings_counter' id='toppingsCounter_<?php echo $adeal->id ?>' value="0">
                                    <input type="hidden" name='bogo' value='<?php echo $adeal->bogo ?>'>
                                    <input type="hidden" name='bogo_discount_on' value='deal'>
                                    <input type="hidden" name='deal' value='<?php echo $adeal->id ?>'>
                                    <?php if (!empty($deal_sets) || !empty($deal_toppings)): ?>
                                        <div class="item-btn item-btn-<?php echo $index ?> col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center" onclick="openPopupBox('<?php echo "dealSetBox_" . $adeal->id ?>', 'dealForm_<?php echo $adeal->id ?>')"><?php echo ucwords(strtolower($adeal->title)) ?></div>
                                        <div id="<?php echo "dealSetBox_" . $adeal->id ?>" class="modal modal-message modal-danger fade" style="display: none;" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <div class="modal-title">
                                                            <div class="col-lg-11 col-md-11 col-sm-11"><?php echo ucwords(strtolower('Prepare ' . $adeal->title . ' using the following sets')) ?></div>
                                                            <div class="col-lg-1 col-md-1 col-sm-1" data-dismiss="modal" aria-hidden="true"  aria-label="Close" style="cursor: default"><i class="fa fa-close"></i></div>
                                                        </div>
                                                    </div>
                                                    <div class="modal-body">
                                                        <ul class="list-group">
                                                            <?php if (!empty($deal_sets)): ?>
                                                                <?php $setindex = 0; ?>
                                                                <?php $set_ids = ''; ?>
                                                                <?php foreach ($deal_sets as $aset): ?>
                                                                    <?php $set_ids .= $aset->id . '_'; ?>
                                                                    <?php $deal_set_menus = get_record_list('meal_deal_menu', array('deal' => $adeal->id, 'set' => $aset->id)) ?>
                                                                    <?php if (!empty($deal_set_menus)): ?>
                                                                        <li class="list-group-item">
                                                                            <div class="item-btn deal-set-btn menu-item item-btn-<?php echo $index ?> text-center" onclick="showExtra('<?php echo 'dealSet_' . $aset->id ?>', 'noForm')">
                                                                                <h5 class="text-center text-uppercase" id="setTitleFor_<?php echo $aset->id ?>">  <?php echo ucwords(strtolower($aset->title)) ?></h5>
                                                                                <p class="text-center"><span style="font-size: 12px; font-weight: bold; text-transform: capitalize">[Any <?php echo $aset->allowed ?> items can be chosen from this set]</span></p>
                                                                            </div>
                                                                            <ul class="list-group show-extra" style="width: 100%;display: none;" id="dealSet_<?php echo $aset->id ?>">
                                                                                <li class="list-group-item checkbox">
                                                                                    <?php
                                                                                    foreach ($deal_set_menus as $set_item) {
                                                                                        $menuId = $set_item->menu;
                                                                                        $menuInfo = get_menu_info_by_id($set_item->menu);
                                                                                        if (!empty($menuInfo)) {
                                                                                            $menuSelObj = get_record_list('meal_deal_selection', array('deal' => $set_item->deal, 'set' => $set_item->set, 'cat' => $set_item->cat, 'menu' => $set_item->menu));
                                                                                            if (!empty($menuSelObj)) {
                                                                                                foreach ($menuSelObj as $menSel) {
                                                                                                    $menuId = $set_item->menu . '_' . $menSel->selection;
                                                                                                    $selInfo = get_selection_info_by_id($menSel->selection);
                                                                                                    if (!empty($selInfo)) {
                                                                                                        ?>
                                                                                                        <label style="font-size: 2em; width: 100%;" class="text-left btn-primary btn-block sharp btn-sm">
                                                                                                            <input type="checkbox" name="set_menus[]" value="<?php echo html_escape(ucwords(strtolower($selInfo->title)) . '-' . ucwords(strtolower($menuInfo->title))) ?>" id='dealSetItemsCheckbox_<?php echo $adeal->id . '_' . $aset->id . '_' . $menuId ?>' onclick="calculateDealSetInfo('<?php echo $adeal->id ?>', '<?php echo $aset->id ?>', '<?php echo $menuId ?>', 'dealForm_<?php echo $adeal->id ?>', '<?php echo $aset->allowed ?>')"><span class="cr"><i class="cr-icon fa fa-check"></i></span><span class="pull-left" style="font-size: 20px;padding-top: 5px;"><?php echo ucwords(strtolower($selInfo->title)) . '-' . ucwords(strtolower($menuInfo->title)) ?></span>
                                                                                                        </label>
                                                                                                    <?php } ?>
                                                                                                <?php } ?>
                                                                                                <?php
                                                                                            } else {
                                                                                                ?>
                                                                                                <label style="font-size: 2em; width: 100%;" class="text-left btn-primary btn-block sharp btn-sm">
                                                                                                    <input type="checkbox" name="set_menus[]" id='dealSetItemsCheckbox_<?php echo $adeal->id . '_' . $aset->id . '_' . $menuId ?>' onclick="calculateDealSetInfo('<?php echo $adeal->id ?>', '<?php echo $aset->id ?>', '<?php echo $menuId ?>', 'dealForm_<?php echo $adeal->id ?>', '<?php echo $aset->allowed ?>')" value="<?php echo html_escape(ucwords(strtolower($menuInfo->title))) ?>"><span class="cr"><i class="cr-icon fa fa-check"></i></span><span class="pull-left" style="font-size: 20px;padding-top: 5px;"><?php echo ucwords(strtolower($menuInfo->title)) ?></span>
                                                                                                </label>
                                                                                            <?php } ?>
                                                                                        <?php } ?>    
                                                                                    <?php }; ?>
                                                                                </li>
                                                                                <input type='hidden' id='setItemCounter_<?php echo $adeal->id . '_' . $aset->id ?>' value='0'> 
                                                                            </ul>
                                                                        </li>
                                                                        <?php $setindex++; ?>    
                                                                    <?php endif; ?>
                                                                <?php endforeach; ?>
                                                            <?php endif; ?>
                                                            <?php if (!empty($deal_toppings)): ?>
                                                                <?php
                                                                $unorganizedToppings = $deal_toppings;
                                                                $organizedToppings = array();
                                                                foreach ($unorganizedToppings as $key => $item) {
                                                                    $organizedToppings[$item->top_cat][] = $item;
                                                                }
                                                                ?>    
                                                                <li class="list-group-item">
                                                                    <div class="item-btn deal-set-btn menu-item item-btn item-btn-toppings text-center deal-toppings" onclick="showExtra('<?php echo 'dealToppings_' . $adeal->id ?>', 'noForm')">
                                                                        <?php
                                                                        $toopingsInformation = '';
                                                                        if ($adeal->free_toppings > 0) {
                                                                            $toopingsInformation .= ' Free Toppings: ' . $adeal->free_toppings;
                                                                        }
                                                                        if ($adeal->max_toppings > 0) {
                                                                            $toopingsInformation .= ' Maximum Toppings: ' . $adeal->max_toppings;
                                                                        }
                                                                        ?>
                                                                        <p class="text-center text-uppercase" style="line-height: 1">Choose Toppings of this deal if want <?php trim($toopingsInformation) != null ? print '<br/><span style="text-transform:capitalize;">' . $toopingsInformation . '</span>' : '' ?></p>

                                                                    </div>
                                                                    <ul class="list-group show-extra" style="width: 100%;display: none;" id="dealToppings_<?php echo $adeal->id ?>">
                                                                        <li class="list-group-item checkbox">
                                                                            <div class="list-group">
                                                                                <?php foreach ($organizedToppings as $ToppingCategoryId => $toppingsCategory): ?>
                                                                                    <?php $toppingCategoryInfo = get_topping_category_name($ToppingCategoryId) ?>
                                                                                    <div class="list-group-item text-left">
                                                                                        <div class="text-left checkbox">
                                                                                            <label style="width: 100%;color: #000;" data-toggle="collapse" data-target="#toppingCategory_<?php echo $ToppingCategoryId . '_' . $adeal->id ?>" id="collapseToppingCategory_<?php echo $ToppingCategoryId . '_' . $adeal->id ?>">
                                                                                                <input type="checkbox" style="color: #000000;"> <?php echo $toppingCategoryInfo->title ?>&nbsp;[Maximum <?php echo $toppingCategoryInfo->max_select ?>]
                                                                                                <input type="hidden" id="maximumCategoryTopping_<?php echo $toppingCategoryInfo->id . '_' . $adeal->id ?>" value="<?php echo $toppingCategoryInfo->max_select ?>">
                                                                                                <input type="hidden" id="maxmumCategoryToppingCounter_<?php echo $toppingCategoryInfo->id . '_' . $adeal->id ?>" value="0" class="empty-counter">
                                                                                            </label>
                                                                                        </div>
                                                                                        <div class="row collapse" id="toppingCategory_<?php echo $ToppingCategoryId . '_' . $adeal->id ?>">
                                                                                            <?php foreach ($toppingsCategory as $deal_topping): ?>
                                                                                                <label style="font-size: 2em; width: 100%; padding-left: 50px;" class="text-left btn-warning btn-block sharp btn-sm">
                                                                                                    <input <?php $deal_topping->is_default == 'yes' ? print'checked="checked" disabled="true"' : '' ?> type="checkbox" id='dealTopping_<?php echo $adeal->id . '_' . $deal_topping->id ?>'  value="<?php echo ucwords(strtolower($deal_topping->title)) ?>" onclick="calculateDealToppingsInfo('<?php echo $adeal->id ?>', '<?php echo $deal_topping->id ?>', 'dealForm_<?php echo $adeal->id ?>', '<?php echo $adeal->max_toppings ?>', '<?php $adeal->free_toppings > 0 ? print $adeal->free_toppings : print 0 ?>', '<?php echo $adeal->price ?>', '<?php echo $deal_topping->top_cat ?>')"><span class="cr">
                                                                                                        <i class="cr-icon fa fa-check"></i></span>
                                                                                                    <span class="pull-left" style="font-size: 20px;padding-top: 5px;">
                                                                                                        <?php echo ucwords(strtolower($deal_topping->title)) . '&nbsp;[&nbsp;+&nbsp;' . to_currency($deal_topping->price) . '&nbsp;]' ?>
                                                                                                    </span>
                                                                                                    <input type="hidden" id='dealToppingPrice_<?php echo $adeal->id . '_' . $deal_topping->id ?>' value="<?php echo $deal_topping->price ?>">
                                                                                                </label>
                                                                                            <?php endforeach; ?>
                                                                                        </div>
                                                                                    </div>
                                                                                <?php endforeach; ?>
                                                                            </div>
                                                                        </li>
                                                                    </ul>
                                                                </li> 
                                                            <?php endif; ?>
                                                            <ul class="list-group" id="dealStringDisplay_<?php echo $adeal->id ?>" style="display: none;">
                                                                <li class="list-group-item">
                                                                    <ul class="list-group">
                                                                        <li class="list-group-item" id="dealItemsDisplayLi_<?php echo $adeal->id ?>">Items:&nbsp;<span id="dealItemsDisplay_<?php echo $adeal->id ?>"></span></li>
                                                                        <li class="list-group-item" id="dealToppingsDisplayLi_<?php echo $adeal->id ?>">Toppings:&nbsp;<span id="dealToppingsDisplay_<?php echo $adeal->id ?>"></span><span style="display: none;" id="dealToppingsPriceDisplay_<?php echo $adeal->id ?>"><span>+ <?php echo $this->config->item('currency_symbol') ?></span><span class="price"></span></span></li>
                                                                    </ul>
                                                                </li>
                                                            </ul>    
                                                            <li class="list-group-item">
                                                                <input type="hidden" id="DealSetQuantity_<?php echo $adeal->id ?>" value="<?php echo $setindex ?>">
                                                                <input type="hidden" id="DealSetIds_<?php echo $adeal->id ?>" value="<?php echo $set_ids ?>">
                                                                <input type="hidden" id="DealToppingsPriceTotal_<?php echo $adeal->id ?>" value="0">
                                                                <button type="button" class="btn btn-danger" style="width: 100%; height: 75px;" onclick="submitDeal('<?php echo $adeal->id ?>', 'dealForm_<?php echo $adeal->id ?>')">Add Now</button>
                                                            </li>    
                                                        </ul>
                                                    </div>
                                                </div> 
                                            </div>
                                        </div>
                                    <?php else: ?>
                                        <div class="item-btn item-btn-<?php echo $index ?> col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center" onclick="submit('dealForm_<?php echo $adeal->id ?>')"><?php echo ucwords(strtolower($adeal->title)) ?></div>
                                    <?php endif; ?>
                                </form>
                            <?php endif; ?>
                        <?php else: ?>
                            <form id="menuForm_<?php echo $amenu->id ?>">
                                <?php
                                $price = to_currency_no_money(0);
                                if ($currentOrderType == 'table') {
                                    $price = $amenu->in_price > 0 ? to_currency_no_money($amenu->in_price) : to_currency_no_money($amenu->base_price);
                                } else {
                                    $price = $amenu->out_price > 0 ? to_currency_no_money($amenu->out_price) : to_currency_no_money($amenu->base_price);
                                }
                              
                                $menuToppings = get_record_list('item_toppings', array('menu' => $amenu->id, 'status' => 1));
                                $menuToppingsDefault = get_record_list('item_toppings', array('menu' => $amenu->id, 'status' => 1, 'is_default' => 'yes'));
                                $menuToppingsDefaultString = '';
                                if (!empty($menuToppingsDefault)) {
                                    foreach ($menuToppingsDefault as $defaultTopping) {
                                        $menuToppingsDefaultString .= ',' . $defaultTopping->title;
                                    }
                                }
                                ?>
                                <input type="hidden" name="order_id" value="<?php echo $order_id ?>">
                                <input type="hidden" name="quantity" value="1">
                                <input type="hidden" name="content" value="<?php echo $amenu->content ?>">
                                <input type="hidden" name='category' value='<?php echo $category->id ?>'>
                                <input type="hidden" name='category_title' value='<?php echo ucwords(strtolower($category->title)) ?>'>
                                <input type='hidden' name='print_option' value='<?php echo $category->print_option ?>'>
                                <input type='hidden' name='type' value='<?php echo $category->type ?>'>
                                <input type="hidden" name='is_special' value='<?php echo $category->is_special ?>'>
                                <input type="hidden" name='menu' value='<?php echo $amenu->id ?>'>
                                <input type="hidden" name='menu_title' value='<?php echo ucwords(strtolower($amenu->title)) ?>'>
                                <input type="hidden" name='selection' value=''>
                                <input type="hidden" name='selection_title' value=''>
                                <input type="hidden" name='set_items' value=''>
                                <input type="hidden" value='<?php echo to_currency_no_money($price) ?>' class="orginal-price">
                                <input type="hidden" name='price' value='<?php echo $price ?>' id="hiddenPriceFor_<?php echo $price ?>" class="hidden-price">
                                <input type="hidden" name="toppings" value="<?php echo $menuToppingsDefaultString?>" id="toppingsString_<?php echo $amenu->id ?>" class="empty-string">
                                <input type="hidden" id='menuToppingsCounter_<?php echo $amenu->id ?>' value="0" class="empty-counter">
                                <input type="hidden" id="menuToppingsPriceTotal_<?php echo $amenu->id ?>" value="0" class="empty-counter"/> 
                                <input type="hidden" name='bogo' value='<?php echo $amenu->bogo ?>'>
                                <input type="hidden" name='bogo_discount_on' value='menu'>
                                <input type="hidden" name='deal' value=''>
                                <div class="menu-block">
                                    <?php if (!empty($menuToppings)): ?>
                                        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center item-btn item-btn-<?php echo $index ?>" onclick="openMenuBoxTopping('<?php echo "menuToppingBox_" . $amenu->id ?>', '<?php echo "menuForm_" . $amenu->id ?>', '<?php echo ucwords(strtolower($amenu->title)) ?>')"><?php echo ucwords(strtolower($amenu->title)) ?></div>
                                    <?php else: ?>
                                        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 menu-item text-center item-btn item-btn-<?php echo $index ?>" onclick="submit('menuForm_<?php echo $amenu->id ?>')"><?php echo ucwords(strtolower($amenu->title)) ?></div>
                                    <?php endif; ?>
                                </div>         
                                <?php if (!empty($menuToppings)): ?>
                                    <div id="<?php echo "menuToppingBox_" . $amenu->id ?>" style="display: none;" class="toppings-block-box">
                                        <?php
                                        $unorganizedToppings = $menuToppings;
                                        $organizedToppings = array();
                                        foreach ($unorganizedToppings as $key => $item) {
                                            $organizedToppings[$item->top_cat][] = $item;
                                        }
                                        ?>
                                        <div class="list-group">
                                            <?php foreach ($organizedToppings as $ToppingCategoryId => $toppingsCategory): ?>
                                                <?php $toppingCategoryInfo = get_topping_category_name($ToppingCategoryId) ?>
                                                <div class="list-group-item text-left">
                                                    <div class="text-left checkbox">
                                                        <label style="width: 100%" data-toggle="collapse" data-target="#toppingCategory_<?php echo $ToppingCategoryId . '_' . $category->id . '_' . $amenu->id ?>" id="collapseToppingCategory_<?php echo $ToppingCategoryId . '_' . $amenu->id ?>">
                                                            <input type="checkbox" style="color: #000000;"> <?php echo $toppingCategoryInfo->title ?>&nbsp;[Maximum <?php echo $toppingCategoryInfo->max_select ?>]
                                                            <input type="hidden" id="maximumCategoryTopping_<?php echo $toppingCategoryInfo->id . '_' . $amenu->id ?>" value="<?php echo $toppingCategoryInfo->max_select ?>">
                                                            <input type="hidden" id="maxmumCategoryToppingCounter_<?php echo $toppingCategoryInfo->id . '_' . $amenu->id ?>" value="0" class="empty-counter">
                                                        </label>
                                                    </div>
                                                    <div class="row collapse" id="toppingCategory_<?php echo $ToppingCategoryId . '_' . $category->id . '_' . $amenu->id ?>">
                                                        <?php foreach ($toppingsCategory as $atopping): ?>
                                                            <div class="col-sm-4">
                                                                <label style="min-height: 50px; width: 100%" class=" menu-item text-center item-btn item-btn-<?php echo $index ?>">
                                                                    <span style="font-size: 12px;padding-top: 5px;"><?php echo ucwords(strtolower($atopping->title)) ?>&nbsp;&nbsp;[<?php $atopping->price > 0 ? print to_currency($atopping->price) : print to_currency(0) ?>]</span><br/>
                                                                    <input type="checkbox" <?php $atopping->is_default=='yes'?print'checked="checked" disabled="true"':''?> onclick="calculateMenuToppingsInfo('<?php echo $amenu->id ?>', '<?php echo $atopping->id ?>', 'menuForm_<?php echo $amenu->id ?>', '<?php $amenu->max_toppings > 0 ? print $amenu->max_toppings : print 0 ?>', '<?php $amenu->free_toppings > 0 ? print $amenu->free_toppings : print 0 ?>', '<?php $amenu->in_price > 0 ? print $amenu->in_price : print $amenu->base_price ?>', '<?php echo $atopping->top_cat ?>')" value="<?php echo ucwords(strtolower($atopping->title)) ?>" id='topping_<?php echo $amenu->id . '_' . $atopping->id ?>' >
                                                                    <input type="hidden" id='toppingPrice_<?php echo $amenu->id . '_' . $atopping->id ?>' value="<?php echo $atopping->price ?>">
                                                                </label>
                                                            </div>
                                                        <?php endforeach; ?>
                                                    </div>
                                                </div>
                                            <?php endforeach; ?>
                                            <div class="list-group-item">
                                                <label id="additionaMenuPriceLabel_<?php echo $amenu->id ?>" style="font-size: 1em; width: 100%; height: 40px; display: none" class="text-center additional-label"><span>+&nbsp;<?php echo $this->config->item('currency_symbol') ?></span><span class="price empty-string"></span></label>
                                                <label style="font-size: 1em; width: 100%; height: 40px; color: #FFF;" class="text-center btn btn-danger btn-block toppings-after-submit" onclick="submit('menuForm_<?php echo $amenu->id ?>')">Add</label>
                                            </div>
                                        </div>
                                    </div>
                                <?php endif; ?>
                            </form>
                        <?php endif; ?>
                    <?php endif; ?>
                <?php endforeach; ?>
            <?php else: ?>
                <div class="item-btn item-btn-<?php echo $index ?> col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center"><?php echo ucwords(strtolower('No Menus Under This category')) ?></div>
            <?php endif; ?>
        <?php else: ?>
            <?php echo $this->load->view('order_info', array('order_info' => $currentOrderObj, 'first_taken' => !empty($firstTaken) ? $firstTaken[0]->first_taken : '', 'first_taken_by' => !empty($firstTaken) ? $firstTaken[0]->created_by : '', 'last_taken' => !empty($lastTaken) ? $lastTaken[0]->last_taken : '', 'last_taken_by' => !empty($lastTaken) ? $lastTaken[0]->created_by : '')) ?>
        <?php endif; ?>
    </div>
    <div class="clearfix"></div>
    <div id="operationStatus" class="alert alert-success alert-dismissable" style="display: none;">
        <button type="button" class="close" data-dismiss="alert">x</button>
        <?php echo $this->lang->line('gkpos_operation_sucess') ?>
    </div>
</div>
<script>
<?php if (!empty($category)) { ?>
        var MenuSegment = '<?php isset($menuSegment) ? print $menuSegment + 1 : print 1 ?>';
        var MenuPages = '<?php isset($menuAjaxpages) ? print $menuAjaxpages : print 1 ?>';
        var MenuSegmentPlusPages = MenuSegment + ' OF ' + MenuPages;
        $('#MenuSegmentPlusPages').text(MenuSegmentPlusPages);
<?php } ?>
    $(document).ready(function () {
        manageWindowHeight();
        manageMenuAreaHeight();
    });

    function openSelectionBox(target, menu) {
        var element = '<a href="javascript:void(0)" onclick="openSelectionBox(\'' + target + '\',\'' + menu + '\')">' + menu + '</a>';
        $('#menuBreadcurmb').html(element);
        $('#selectrionBreadcurmb').html('');
        $('.menu-block').removeAttr('style').css({'display': 'none'});
        $('.selection-block').removeAttr('style').css({'display': 'none'});
        $('.toppings-block-box').removeAttr('style').css({'display': 'none'});
        $(target).removeAttr('style').css({'display': 'block'});
        $(target + ' .selection-block').removeAttr('style').css({'display': 'block'});
    }
    function openMenuBoxTopping(boxId, itemForm, menuTitle) {
        
        var showDescription = $('#showItemDescription').val();
        if (showDescription == 'yes' && itemForm != 'noForm') {
            var myform = document.getElementById(itemForm);
            var formdata = new FormData(myform);
            var menu = formdata.get('menu_title');
            var sel = formdata.get('selection_title');
            var title = null;
            if ($.trim(sel)) {
                title = sel + '-' + menu;
            } else {
                title = menu;
            }
            var description = formdata.get('content');
            var price = formdata.get('price');
            var priceString = '<br/><STRONG>PRICE:' + '<?php echo $this->config->item('currency_symbol') ?>' + Number(price).toFixed(2) + '</STRONG>';
            $.confirm({
                'title': title ? title : 'No Title To Show',
                'message': description ? description + priceString : 'No Description available to show' + priceString,
                'buttons': {
                    'OK': {
                        'class': 'btn btn-success',
                        'action': function () {
                        }
                    }
                }
            });
            $('#confirmBox').css({'left': '46%'});
        } else {
            var element = '<a href="javascript:void(0)" onclick="openMenuBoxTopping(\'' + boxId + '\',\'' + itemForm + '\',\'' + menuTitle + '\')">' + menuTitle + '</a>';
            $('#menuBreadcurmb').html(element);
            $('.menu-block').removeAttr('style').css({'display': 'none'});
            $('.selection-block').removeAttr('style').css({'display': 'none'});
            $('.toppings-block-box').removeAttr('style').css({'display': 'none'});
            $('#' + boxId).removeAttr('style').css({'display': 'block'});
            $('.toppings-after-submit').show();
        }
    }
    function openSlectionBoxTopping(boxId, itemForm, SelectionTitle) {
        
        var showDescription = $('#showItemDescription').val();
        if (showDescription == 'yes' && itemForm != 'noForm') {
            var myform = document.getElementById(itemForm);
            var formdata = new FormData(myform);
            var menu = formdata.get('menu_title');
            var sel = formdata.get('selection_title');
            var title = null;
            if ($.trim(sel)) {
                title = sel + '-' + menu;
            } else {
                title = menu;
            }
            var description = formdata.get('content');
            var price = formdata.get('price');
            var priceString = '<br/><STRONG>PRICE:' + '<?php echo $this->config->item('currency_symbol') ?>' + Number(price).toFixed(2) + '</STRONG>';
            $.confirm({
                'title': title ? title : 'No Title To Show',
                'message': description ? description + priceString : 'No Description available to show' + priceString,
                'buttons': {
                    'OK': {
                        'class': 'btn btn-success',
                        'action': function () {
                        }
                    }
                }
            });
            $('#confirmBox').css({'left': '46%'});
        } else {
            var element = '<a href="javascript:void(0)" onclick="openSlectionBoxTopping(\'' + boxId + '\',\'' + itemForm + '\',\'' + SelectionTitle + '\')">' + SelectionTitle + '</a>';
            $('#selectrionBreadcurmb').html(element);
            $('.menu-block').removeAttr('style').css({'display': 'none'});
            $('.selection-block').removeAttr('style').css({'display': 'none'});
            $('.toppings-block-box').removeAttr('style').css({'display': 'none'});
            $('#' + boxId).removeAttr('style').css({'display': 'block'});
            $('.toppings-after-submit').show();
        }
    }
    function calculateMenuToppingsInfo(menu, topping, menuForm, maxToppings, freeToppings, price, top_cat) {
        
        var title = '';
        var toppingPrice = 0;
        var toppingsString = '';
        var maximumCategoryTopping = '#' + menuForm + ' #maximumCategoryTopping_' + top_cat + '_' + menu;
        var maximumCategoryToppingVal = Number($(maximumCategoryTopping).val());
        var maxmumCategoryToppingCounter = '#' + menuForm + ' #maxmumCategoryToppingCounter_' + top_cat + '_' + menu;
        var maxmumCategoryToppingCounterVal = Number($(maxmumCategoryToppingCounter).val());
        var checkbox = '#' + menuForm + ' #topping_' + menu + '_' + topping;
        var toppingsStringLoc = '#' + menuForm + ' #toppingsString_' + menu;
        var toppingPriceLoc = '#' + menuForm + ' #toppingPrice_' + menu + '_' + topping;
        var visiblePriceLoc = '#' + menuForm + ' #visiblePriceFor_' + menu;
        var hiddenPriceLoc = '#' + menuForm + ' .hidden-price';
        var menuToppingsCounterLoc = '#' + menuForm + ' #menuToppingsCounter_' + menu;
        var menuToppingsCounter = Number($(menuToppingsCounterLoc).val());
        var menuToppingsPriceTotalLoc = '#' + menuForm + ' #menuToppingsPriceTotal_' + menu;
        title = $(checkbox).val();
        toppingPrice = $(toppingPriceLoc).val();
        toppingsString = $(toppingsStringLoc).val();
        if ($(checkbox).is(':checked')) {
            if (Number(maxToppings) > 0 && menuToppingsCounter >= Number(maxToppings)) {
                $(checkbox).attr('checked', false);
                alert('Please select any ' + maxToppings + ' toppings');
            } else {
                if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                    $(checkbox).attr('checked', false);
                    alert('you can not exceed ' + Number(maximumCategoryToppingVal) + ' toppings from this category');
                    if ($('#collapseToppingCategory_' + top_cat + '_' + menu).length > 0) {
                        $('#collapseToppingCategory_' + top_cat + '_' + menu).click();
                    }
                } else {
                    maxmumCategoryToppingCounterVal += 1;
                    $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
                    if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                        if ($('#collapseToppingCategory_' + top_cat + '_' + menu).length > 0) {
                            $('#collapseToppingCategory_' + top_cat + '_' + menu).click();
                        }
                    }
                    menuToppingsCounter += 1;
                    var toppingsPriceTotal;
                    if (freeToppings < menuToppingsCounter) {
                        toppingsPriceTotal = $(menuToppingsPriceTotalLoc).val();
                        toppingsPriceTotal = parseFloat(toppingsPriceTotal) + parseFloat(toppingPrice);
                        $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    } else {
                        toppingsPriceTotal = 0;
                        $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    }
                    toppingsString += ',' + title;
                }
            }
        } else {
            maxmumCategoryToppingCounterVal -= 1;
            $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
            menuToppingsCounter -= 1;
            var toppingsPriceTotal;
            if (freeToppings < menuToppingsCounter) {
                toppingsPriceTotal = $(menuToppingsPriceTotalLoc).val();
                toppingsPriceTotal = parseFloat(toppingsPriceTotal) - parseFloat(toppingPrice);
                $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
            } else {
                toppingsPriceTotal = 0;
                $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
            }
            toppingsString = toppingsString.replace(',' + title, '');
        }
        var EndToppingsPriceTotal = Number($(menuToppingsPriceTotalLoc).val());
        var menu_price = parseFloat(0);
        if (EndToppingsPriceTotal > 0) {
            menu_price = parseFloat(price) + parseFloat(EndToppingsPriceTotal);
        } else {
            menu_price = parseFloat(price);
        }
        if (EndToppingsPriceTotal > 0) {
            $('#additionaMenuPriceLabel_' + menu).show();
            $('#additionaMenuPriceLabel_' + menu + ' .price').text(EndToppingsPriceTotal.toFixed(2));
        } else {
            $('#additionaMenuPriceLabel_' + menu).hide();
        }
        $(menuToppingsCounterLoc).val(menuToppingsCounter);
        $(visiblePriceLoc).text(menu_price.toFixed(2));
        $(hiddenPriceLoc).val(menu_price.toFixed(2));
        $(toppingsStringLoc).val(toppingsString);
        if (menuToppingsCounter == Number(maxToppings)) {
            if ($('#additionaMenuPriceLabel_' + menu).length > 0) {
                $('#additionaMenuPriceLabel_' + menu).hide();
                $('#additionaMenuPriceLabel_' + menu + ' .price').text('');
            }
            if ($('#collapseToppingCategory_' + top_cat + '_' + menu).length > 0) {
                $('#collapseToppingCategory_' + top_cat + '_' + menu).click();
            }
            $('.toppings-after-submit').hide();
            submit(menuForm);
        }
    }
    function calculateSelectionToppingsInfo(menu, sel, topping, selForm, maxToppings, freeToppings, price, top_cat) {
        
        var title = '';
        var toppingPrice = 0;
        var toppingsString = '';
        var checkbox = '#' + selForm + ' #topping_' + menu + '_' + sel + '_' + topping;
        var toppingsStringLoc = '#' + selForm + ' #toppingsString_' + menu + '_' + sel;
        var toppingPriceLoc = '#' + selForm + ' #toppingPrice_' + menu + '_' + sel + '_' + topping;
        var visiblePriceLoc = '#' + selForm + ' #visiblePriceFor_' + menu + '_' + sel;
        var hiddenPriceLoc = '#' + selForm + ' #hiddenPriceFor_' + menu + '_' + sel;
        var selectionToppingsPriceTotalLoc = '#' + selForm + ' #selectionToppingsPriceTotal_' + menu + '_' + sel;
        var selectionToppingsCounterLoc = '#' + selForm + ' #selectionToppingsCounter_' + menu + '_' + sel;
        var selectionToppingsCounter = Number($(selectionToppingsCounterLoc).val());
        var maximumCategoryTopping = '#' + selForm + ' #maximumCategoryTopping_' + top_cat + '_' + menu + '_' + sel;
        var maximumCategoryToppingVal = Number($(maximumCategoryTopping).val());
        var maxmumCategoryToppingCounter = '#' + selForm + ' #maxmumCategoryToppingCounter_' + top_cat + '_' + menu + '_' + sel;
        var maxmumCategoryToppingCounterVal = Number($(maxmumCategoryToppingCounter).val());


        title = $(checkbox).val();
        toppingPrice = $(toppingPriceLoc).val();
        toppingsString = $(toppingsStringLoc).val();
        if ($(checkbox).is(':checked')) {
            if (Number(maxToppings) > 0 && selectionToppingsCounter >= Number(maxToppings)) {
                $(checkbox).attr('checked', false);
                alert('Please select any ' + maxToppings + ' toppings');
            } else {
                if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                    $(checkbox).attr('checked', false);
                    alert('you can not exceed ' + Number(maximumCategoryToppingVal) + ' toppings from this category');
                    if ($('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).length > 0) {
                        $('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).click();
                    }
                } else {
                    maxmumCategoryToppingCounterVal += 1;
                    $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
                    if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                        if ($('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).length > 0) {
                            $('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).click();
                        }
                    }
                    selectionToppingsCounter += 1;
                    var toppingsPriceTotal;
                    if (freeToppings < selectionToppingsCounter) {
                        toppingsPriceTotal = $(selectionToppingsPriceTotalLoc).val();
                        toppingsPriceTotal = parseFloat(toppingsPriceTotal) + parseFloat(toppingPrice);
                        $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    } else {
                        toppingsPriceTotal = 0;
                        $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    }
                    toppingsString += ',' + title;
                }
            }
        } else {
            maxmumCategoryToppingCounterVal -= 1;
            $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
            selectionToppingsCounter -= 1;
            var toppingsPriceTotal;
            if (freeToppings < selectionToppingsCounter) {
                toppingsPriceTotal = $(selectionToppingsPriceTotalLoc).val();
                toppingsPriceTotal = parseFloat(toppingsPriceTotal) - parseFloat(toppingPrice);
                $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
            } else {
                toppingsPriceTotal = 0;
                $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
            }
            toppingsString = toppingsString.replace(',' + title, '');
        }
        var EndToppingsPriceTotal = Number($(selectionToppingsPriceTotalLoc).val());
        var selection_price = parseFloat(0);
        if (EndToppingsPriceTotal > 0) {
            selection_price = parseFloat(price) + parseFloat(EndToppingsPriceTotal);
        } else {
            selection_price = parseFloat(price);
        }
        if (EndToppingsPriceTotal > 0) {
            $('#additionaSelectionPriceLabel_' + sel).show();
            $('#additionaSelectionPriceLabel_' + sel + ' .price').text(EndToppingsPriceTotal.toFixed(2));
        } else {
            $('#additionaSelectionPriceLabel_' + sel).hide();
        }
        $(selectionToppingsCounterLoc).val(selectionToppingsCounter);
        $(visiblePriceLoc).text(selection_price.toFixed(2));
        $(hiddenPriceLoc).val(selection_price.toFixed(2));
        $(toppingsStringLoc).val(toppingsString);
        if (selectionToppingsCounter == Number(maxToppings)) {
            if ($('#additionaSelectionPriceLabel_' + sel).length > 0) {
                $('#additionaSelectionPriceLabel_' + sel).hide();
                $('#additionaSelectionPriceLabel_' + sel + ' .price').text('');
            }
            if ($('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).length > 0) {
                $('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).click();
            }
            $('.toppings-after-submit').hide();
            submit(selForm);
        }
    }
    function submit(itemForm) {
        
        var quantity = Number($('#popUpQuantity').val()) > 0 ? Number($('#popUpQuantity').val()) : 1;
        if (quantity > 1) {
            $('#' + itemForm).find('input[name="quantity"]').val(quantity);
        }
        var myform = document.getElementById(itemForm);
        var formdata = new FormData(myform);
        var showDescription = $('#showItemDescription').val();
        if (showDescription == 'yes') {
            var menu = formdata.get('menu_title');
            var sel = formdata.get('selection_title');
            var title = null;
            if ($.trim(sel)) {
                title = sel + '-' + menu;
            } else {
                title = menu;
            }
            var description = formdata.get('content');
            var price = formdata.get('price');
            var priceString = '<br/><STRONG>PRICE:' + '<?php echo $this->config->item('currency_symbol') ?>' + Number(price).toFixed(2) + '</STRONG>';
            $.confirm({
                'title': title ? title : 'No title to show',
                'message': description ? description + priceString : 'No description available to show' + priceString,
                'buttons': {
                    'OK': {'class': 'btn btn-success',
                        'action': function () {
                            showItemDescription();
                        }
                    }
                }
            });
            $('#confirmBox').css({'left': '46%'});
        } else {
            if ($('.modal').hasClass('in')) {
                $(".modal").hide();
            }
            $.ajax({
                url: '<?php echo site_url('gkpos/orders/addtocart') ?>',
                data: formdata,
                cache: false,
                processData: false,
                contentType: false,
                type: 'POST',
                dataType: 'json',
                success: function (output) {
                    if (typeof output.line !== 'undefined') {
                        loadCart(output.order_id, output.line);
                        $('input[type=checkbox]').each(function ()
                        {
                            if (!this.disabled === 'true') {
                                this.checked = false;
                            }
                        });
                        var orginalPrice = $('#' + itemForm + ' .orginal-price').val();
                        $('#' + itemForm + ' .hidden-price').val(orginalPrice);
                        $('#' + itemForm + ' .empty-string').val('');
                        $('#' + itemForm + ' .empty-counter').val(0);
                        if ($('.additional-label').length > 0) {
                            $('.additional-label .price').text('');
                            $('.additional-label').hide();
                        }
                        if (itemForm.indexOf("dealForm_") != -1) {
                            <?php if (!empty($category)) { ?>
                                listMenusPage('<?php echo $category->id ?>', '<?php echo $index ?>', '<?php echo $menuSegment ?>', '<?php echo $category->is_special ?>');
                             <?php } ?>
                        }
                    } else {
                        loadCart(output.order_id, false);
                    }
                }
            });
        }

    }
    function submitDeal(deal, dealForm) {
        var setQuantity = $('#DealSetQuantity_' + deal).val();
        setQuantity = setQuantity >= 1 ? setQuantity : 0;
        if (setQuantity > 0) {
            var setIds = $('#DealSetIds_' + deal).val();
            var setIdsArr = setIds.split('_');
            var setItemCounterVal = 0;
            var setTitleForLoc = '#' + dealForm + ' #setTitleFor_';
            var setItemEmtyId = 'no';
            for (var i = 0; i < setQuantity; i++) {
                setItemCounterVal = $('#' + dealForm + ' #setItemCounter_' + deal + '_' + setIdsArr[i]).val();
                if (setItemCounterVal == 0) {
                    setItemEmtyId = setIdsArr[i];
                    break;
                }
            }
            if (setItemEmtyId != 'no') {
                var setTitle = $(setTitleForLoc + setItemEmtyId).text();
                alert('please select items from ' + setTitle);
                return false;
            } else {
                submit(dealForm);
            }
        } else {
            submit(dealForm);
        }
    }
    function calculateDealSetInfo(deal, set, menu, form, maxAllowed) {
        
        var setItemCounterLoc = '#' + form + ' #setItemCounter_' + deal + '_' + set;
        var checkbox = '#' + form + ' #dealSetItemsCheckbox_' + deal + '_' + set + '_' + menu;
        var dealSetItemsLoc = '#' + form + ' #dealSetItems_' + deal;
        var dealSetItems = $(dealSetItemsLoc).val();
        var setItemCounter = Number($(setItemCounterLoc).val());
        var title = $(checkbox).val();
        if ($(checkbox).is(':checked')) {
            if (Number(setItemCounter) >= Number(maxAllowed)) {
                $(checkbox).attr('checked', false);
                alert('Please select any ' + maxAllowed + ' items from this set');
            } else {
                setItemCounter += 1;
                dealSetItems += ',' + title;
            }
        } else {
            setItemCounter -= 1;
            dealSetItems = dealSetItems.replace(',' + title, '');
        }
        $(dealSetItemsLoc).val(dealSetItems);
        $(setItemCounterLoc).val(setItemCounter);
        showDealString(deal);
        setItemCounter = Number($(setItemCounterLoc).val());
        if (setItemCounter === Number(maxAllowed)) {
            showExtra('dealSet_' + set, 'noForm');
        }

    }
    function showDealString(deal) {
        var dealItems = $('#dealSetItems_' + deal).val();
        var dealToppings = $('#dealToppingsString_' + deal).val();
        if ($.trim(dealItems) || $.trim(dealToppings)) {
            $('#dealStringDisplay_' + deal).show();
            if ($.trim(dealToppings)) {
                $('#dealToppingsDisplayLi_' + deal).show();
                $('#dealToppingsDisplay_' + deal).text(dealToppings.substr(1));
            } else {
                $('#dealToppingsDisplayLi_' + deal).hide();
            }
            if ($.trim(dealItems)) {
                $('#dealItemsDisplayLi_' + deal).show();
                $('#dealItemsDisplay_' + deal).text(dealItems.substr(1));
            } else {
                $('#dealItemsDisplayLi_' + deal).hide();
            }
        } else {
            $('#dealStringDisplay_' + deal).hide();
            $('#dealItemsDisplay_' + deal).text('');
            $('#dealToppingsDisplay_' + deal).text('');
        }
    }
    function calculateDealToppingsInfo(deal, topping, form, maxToppings, freeToppings, dealPrice, top_cat) {
        
        var title = '';
        var toppingPrice = 0;
        var toppingsString = '';
        var toppingsCounterLoc = '#' + form + ' #toppingsCounter_' + deal;
        var toppingsCounter = Number($(toppingsCounterLoc).val());
        var checkbox = '#' + form + ' #dealTopping_' + deal + '_' + topping;
        var toppingsStringLoc = '#' + form + ' #dealToppingsString_' + deal;
        var toppingPriceLoc = '#' + form + ' #dealToppingPrice_' + deal + '_' + topping;
        var hiddenPriceLoc = '#' + form + ' #dealHiddenPriceFor_' + deal;
        var maximumCategoryTopping = '#' + form + ' #maximumCategoryTopping_' + top_cat + '_' + deal;
        var maximumCategoryToppingVal = Number($(maximumCategoryTopping).val());
        var maxmumCategoryToppingCounter = '#' + form + ' #maxmumCategoryToppingCounter_' + top_cat + '_' + deal;
        var maxmumCategoryToppingCounterVal = Number($(maxmumCategoryToppingCounter).val());
        title = $(checkbox).val();
        toppingPrice = $(toppingPriceLoc).val();
        toppingsString = $(toppingsStringLoc).val();
        if ($(checkbox).is(':checked')) {
            if (Number(toppingsCounter) >= Number(maxToppings)) {
                $(checkbox).attr('checked', false);
                alert('Please select any ' + maxToppings + ' toppings');
            } else {
                if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                    $(checkbox).attr('checked', false);
                    if ($('#collapseToppingCategory_' + top_cat + '_' + deal).length > 0) {
                        $('#collapseToppingCategory_' + top_cat + '_' + deal).click();
                    }
                } else {
                    maxmumCategoryToppingCounterVal += 1;
                    $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
                    if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                        if ($('#collapseToppingCategory_' + top_cat + '_' + deal).length > 0) {
                            $('#collapseToppingCategory_' + top_cat + '_' + deal).click();
                        }
                    }
                    toppingsCounter += 1;
                    var toppingsPriceTotal;
                    if (freeToppings < toppingsCounter) {
                        toppingsPriceTotal = $('#' + form + ' #DealToppingsPriceTotal_' + deal).val();
                        toppingsPriceTotal = parseFloat(toppingsPriceTotal) + parseFloat(toppingPrice);
                        $('#' + form + ' #DealToppingsPriceTotal_' + deal).val(toppingsPriceTotal);
                    } else {
                        toppingsPriceTotal = 0;
                        $('#' + form + ' ' + '#DealToppingsPriceTotal_' + deal).val(toppingsPriceTotal);
                    }
                    toppingsString += ',' + title;
                }
            }
        } else {
            maxmumCategoryToppingCounterVal -= 1;
            $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
            toppingsCounter -= 1;
            var toppingsPriceTotal;
            if (freeToppings < toppingsCounter) {
                toppingsPriceTotal = $('#' + form + ' #DealToppingsPriceTotal_' + deal).val();
                toppingsPriceTotal = parseFloat(toppingsPriceTotal) - parseFloat(toppingPrice);
                $('#' + form + ' #DealToppingsPriceTotal_' + deal).val(toppingsPriceTotal);
            } else {
                toppingsPriceTotal = 0;
                $('#' + form + ' #DealToppingsPriceTotal_' + deal).val(toppingsPriceTotal);
            }
            toppingsString = toppingsString.replace(',' + title, '');
        }
        toppingsPriceTotal = Number($('#' + form + ' #DealToppingsPriceTotal_' + deal).val());
        var itemPrice;
        if (toppingsPriceTotal > 0) {
            itemPrice = parseFloat(dealPrice) + parseFloat(toppingsPriceTotal);
        } else {
            itemPrice = parseFloat(dealPrice);
        }
        $(toppingsCounterLoc).val(toppingsCounter);
        $(hiddenPriceLoc).val(itemPrice.toFixed(2));
        $(toppingsStringLoc).val(toppingsString);
        toppingsCounter = Number($(toppingsCounterLoc).val());
        if (toppingsCounter === Number(maxToppings)) {
            showExtra('dealToppings_' + deal, 'noForm');
        }
        showDealString(deal);
        if (toppingsPriceTotal > 0) {
            $('#dealToppingsPriceDisplay_' + deal).show();
            $('#dealToppingsPriceDisplay_' + deal + ' .price').text(toppingsPriceTotal.toFixed(2));
        } else {
            $('#dealToppingsPriceDisplay_' + deal).hide();
        }
    }



</script>
<style>
    .toppings-block-box .list-group-item{
        padding: 0px;
        text-align: center;
    }
    .toppings-block-box .list-group-item label{
        color: #000000;
    }
    #menuListArea  .toppings-block-box  .item-btn {
        border-radius: 25px;
        font-size: 12px;
        font-weight: bold;
        height: 57px;
        padding: 3% 1%;
    }
</style>