<div class="b-cart" ng-controller="productsCtrl">
	<div class="container"  ng-controller="cartCtrl">
		<div class="row b-info-restaurant" ng-include="'views/part/info-restaurant.html?ver=4'"></div>

		<div class="row title-cart"  ng-show="CartInfo.ResultCount != '0'">
			<div class="col-md-8 col-md-offset-2 text-center">
				<h1 class="title">
					{{getLocale('Count products in cart')}}: {{ CartInfo.ResultCount }}
				</h1>
			</div>
			<div class="col-md-2 wrapper-btn-link">
				<a ng-href="#/catalog" class="btn pull-right">{{getLocale('Continue shopping')}}</a>
			</div>
		</div>

		<div class="row" ng-show="!loadingCart">
			<div class="col-xs-12">
				<div class="b-load m-load-catalog text-center" >
					<div class="load-circle"></div>
					<p>{{getLocale('Load cart')}}</p>
				</div>
			</div>
		</div>

		<div class="row"  ng-show="loadingCart">
			<div class="col-xs-12 content">
				<div ng-show="cartProduct.length == 0" class="text-center">
					<p>{{getLocale('No products in cart')}}</p><br />
					<a class="btn" ng-href="#/catalog">{{getLocale('Back to catalog')}}</a>
				</div>

				<div class="b-group" ng-hide="cartProduct.length == 0">
					<div class="items js-group-product">
						<div ng-repeat="item in cartProduct track by item.order" data-id-product="{{item.info.id}}"
							 ng-init="isModis[item.info.id] = !(item.info.modischeme == 0 || item.info.modischeme == null)"
							 class="item-group js-product-item" id="product-{{ item.order }}" >

							<div class="row row-main-info">
								<div class="col-sm-3">
									<div class="image-wrapper">
										<!--<div class="ticket action">{{getLocale('Action')}}</div>-->
										<!--<div class="ticket new" style="display: none;">{{getLocale('Novelty')}}</div>-->
										<img ng-src="images-product/img{{item.info.code}}.png" alt="" image-load />
									</div>
								</div>
								<div class="col-lg-4 col-md-4 col-sm-9">
									<div class="title-wrapper">
										<p class="title-product">{{item.info.name}}</p>
										<p class="description">{{item.info.locres[3].value}}</p>
									</div>
								</div>
								<div class="col-lg-2 col-md-2 col-sm-6 col-sm-clear text-center">
									<div class="count-wrapper wrapper-inc no-wrap">
										<a class="button-inc"
										   href="javascript:void(0);"
										   data-index="{{item.order}}"
										   data-id-product="{{item.info.id}}"
										   data-sub-product=""
										   data-id-category="{{item.info.category}}"
										   data-id-parent=""
										   data-type="dec"
										   ng-class="{ 'disabled': countProduct[item.order] <= 1 }"
										   change-count>-</a>

										<input type="text" ng-model="countProduct[item.order]" mask='99' restrict="reject" readonly
											   class="input input-count"  step="1" max="{{maxValueProduct}}" min="1" />
										<a class="button-inc"
										   href="javascript:void(0);"
										   data-index="{{item.order}}"
										   data-id-product="{{item.info.id}}"
										   data-sub-product=""
										   data-id-category="{{item.info.category}}"
										   data-id-parent=""
										   data-type="inc"
										   ng-class="{'disabled': countProduct[item.order] >= maxValueProduct}"
										   change-count>+</a>
									</div>
									<a href="javascript:void(0);" class="delete-product" ng-click="deleteProduct(item.info.id, item.order)">{{getLocale('Delete')}}</a>
								</div>
								<div class="col-lg-3 col-md-3 col-sm-6">
									<div class="price-wrapper text-right">
										<p class="price"  >{{ countProduct[item.order] * resultPriceProduct[item.order] | filterPrice | filterNumeric }} {{ Currency }}</p>
									</div>
								</div>
							</div>
							<div class="row hide-row row-bottom-cart"  ng-if="isModis[item.info.id]"
								 ng-init="disabledDecSubProduct[item.order] = {};
										 errorMinCount[item.order] = {};
										 disabledIncSubProduct[item.id] = {};" >

								<div class="col-sm-12 col-more-info">
									<div class="option-sub-product" ng-if="item.info.modis.selectModis.length >= 1 && item.info.type == 'dish'">
										<div class="row item-sub-product" ng-repeat="itemModis in item.info.modis.selectModis">
											<div class="col-xs-5 title-param-wrapper">
												<p class="title-param">{{itemModis.name}}</p>
											</div>
											<div class="wrapper-select col-xs-7">
												<!--<select class="h-full-width" ng-model="modisSelect[item.order][itemModis.id]"-->
														<!--ng-init="modisSelect[item.id][itemModis.id] = itemModis.modi[0].id.toString()"-->
														<!--ng-change="GetResultPriceSelect(item.info.id, item.order, itemModis.id, modisSelect[item.order][itemModis.id])">-->
													<!--<option value="{{itemModisValue.id}}" ng-repeat="itemModisValue in itemModis.modi" >-->
														<!--{{ itemModisValue.name }}-->
														<!--({{ itemModisValue.price| filterPrice | filterNumeric }} {{ Currency }})-->
													<!--</option>-->
												<!--</select>-->

												<select class="h-full-width h-select js-select-modis"
														ng-init="modisSelect[item.info.id][itemModis.id] = itemModis.modi[0].id.toString()"
														ng-model="modisSelect[item.order][itemModis.id]"
														ng-change="GetResultPriceSelect(item.info.id, item.order, itemModis.id, modisSelect[item.order][itemModis.id])"
														data-id-product="{{item.info.id}}"
														check-error-adding>
													<option value="{{itemModisValue.id}}" ng-repeat="itemModisValue in itemModis.modi" >
														{{ itemModisValue.name }}
														({{ itemModisValue.price| filterPrice | filterNumeric }} {{ Currency }})
													</option>
												</select>
											</div>
										</div>
									</div>

									<div class="option-sub-product"  ng-if="item.info.modis.selectModis.length >= 1 && item.info.type == 'combo'">
										<div class="row item-sub-product" ng-repeat="itemModis in item.info.modis.selectModis" ng-init="tempName='name' + $index">
											<div class="col-xs-5 title-param-wrapper">
												<p class="title-param">{{itemModis.name}}</p>
											</div>
											<div class="wrapper-select col-xs-7">
												<!--ng-init="modisSelect[item.id][itemModis.id] = itemModis.modi[0].id.toString()"-->
												<div class="item-radio" ng-repeat="itemModisValue in itemModis.modi" ng-init="modisSelect[item.id][itemModis.id] = ''" >
													<input type="radio"
														ng-init="modisSelect[item.info.id][itemModis.id] = itemModis.modi[0].id.toString(); "
														ng-model="modisSelect[item.order][itemModis.id]"
														ng-change="GetResultPriceSelect(item.info.id, item.order, itemModis.id, modisSelect[item.order][itemModis.id])"
														data-id-product="{{item.info.id}}"
														check-error-adding
														value="{{itemModisValue.id}}"
														id="{{tempName + '_' + $index + item.info.id}}"
														name="{{tempName + item.order }}"
															/>

													<label for="{{tempName + '_' + $index + item.info.id}}">{{ itemModisValue.name }}
														<span ng-show="itemModisValue.price > 0">({{ itemModisValue.price| filterPrice | filterNumeric }} {{ Currency }})</span>
													</label>
													<!--<span ng-init="helpChange( needRadio, item.id, item.id, itemModis.id, modisSelect[item.id][itemModis.id] )"></span>-->
												</div>
											</div>
										</div>
									</div>





									<div class="row" ng-if="item.info.modis.inputModis.length >= 1 && item.info.type == 'dish'" >

										<div class="col-xs-12">
											<div class="sub-title-wrapper">
												<p class="sub-title">{{getLocale('Additional ingredients')}}</p>
											</div>
										</div>
									</div>
									<div class="sub-products js-sub-products-input"
										 ng-if="item.info.type == 'dish'"
										 data-parent-modi="{{ itemModisInput.id }}"
										 data-min-value="{{ itemModisInput.downLimit }}"
										 ng-repeat="itemModisInput in item.info.modis.inputModis"
										 ng-class="{ 'min-group-val-error': errorMinCount[item.order][itemModisInput.id] }"
										 id="modi-group-{{itemModisInput.id}}">

										<div class="title-param-group">{{itemModisInput.name}}
											<span ng-if="itemModisInput.downLimit || itemModisInput.upLimit">
												({{getLocale('Number of ingredients required')}}:
													<span ng-if="itemModisInput.downLimit && itemModisInput.useDownLimit == 1">{{getLocale('from')}} {{ itemModisInput.downLimit }}</span><span ng-if="itemModisInput.upLimit && itemModisInput.useUpLimit == 1"> {{getLocale('to')}} {{ itemModisInput.upLimit }}</span>)
											</span>
										</div>

										<div class="row row-item" ng-repeat="itemModisInputMini in itemModisInput.modi" ng-class="{ 'row-item-last': $last }">
											<div class="col-xs-5 mini-mobile-col mini-mobile-title"><p class="text">{{itemModisInputMini.name}}</p></div>
											<div class="col-xs-7 mini-mobile-col">
												<div class="row no-right-border">
													<div class="col-xs-3 text-center border-item">
														<p class="text">
															{{ priceSubProduct[item.info.id][itemModisInputMini.id] | filterPrice | filterNumeric }} {{ Currency }}
														</p>
													</div>
													<div class="col-xs-5 border-item wrapper-inc no-wrap"
														 ng-init="maxValueModi[item.order + itemModisInputMini.id] = (itemModisInputMini.maxOneDish == 0 ? 99 : itemModisInputMini.maxOneDish);
														 		maxValueModiGroup[item.id + '_' + itemModisInputMini.id] = ((itemModisInput.useUpLimit == 1) ? itemModisInput.upLimit : 99)">
														<!--{{ itemModisInputMini.id }}-->
														<!--{{ item.info.id }}-->

														<a class="button-inc js-button-inc"
														   href="javascript:void(0);"
														   data-max-group-count="{{ maxValueModiGroup[item.id  + '_' +  itemModisInputMini.id] }}"
														   data-index="{{item.order}}"
														   data-id-product="{{ item.order }}"
														   data-id-product-cart="{{item.info.id}}"
														   data-sub-product="{{itemModisInputMini.id}}"
														   data-id-category="{{item.info.category}}"
														   data-id-parent="{{itemModisInput.id}}"
														   data-type="dec"
														   ng-class="{ 'disabled': disabledDecSubProduct[item.order][itemModisInput.id] || countSubProduct[item.order][itemModisInputMini.id] <= 0 }"
														   change-count>-</a>
														<input type="text"
														   max="{{ maxValueModi[item.order + itemModisInputMini.id] }}"
														   readonly
														   class="input input-count"
														   mask='99'
														   restrict="reject"
														   min="0"
														   ng-model="countSubProduct[item.order][itemModisInputMini.id]" />
														<a class="button-inc"
														   href="javascript:void(0);"
														   data-max-group-count="{{ maxValueModiGroup[item.id  + '_' +  itemModisInputMini.id] }}"
														   data-index="{{ item.order }}"
														   data-id-product-cart="{{item.info.id}}"
														   data-id-product="{{ item.order}}"
														   data-sub-product="{{itemModisInputMini.id}}"
														   data-id-category="{{item.info.category}}"
														   data-id-parent="{{itemModisInput.id}}"
														   data-type="inc"
														   ng-class="{'disabled': disabledIncSubProduct[item.order][itemModisInput.id] ||
														   					countSubProduct[item.order][itemModisInputMini.id] >=  maxValueModi[item.order + itemModisInputMini.id] ||
																		    countSubProduct[item.id][itemModisInputMini.id] >= maxValueModiGroup[item.id + '_' + itemModisInputMini.id]  }"
														   change-count>+</a>
													</div>
													<div class="col-xs-4 text-center border-item last-block">
														<p class="text">{{ countSubProduct[item.order][itemModisInputMini.id] * priceSubProduct[item.info.id][itemModisInputMini.id] | filterPrice | filterNumeric }} {{ Currency }}</p>
													</div>
												</div>
											</div>
										</div>

										<p class="error-adding" ng-show="errorMinCount[item.order][itemModisInput.id]">{{ getLocale('The minimum amount of modifier is not selected') }}: {{ itemModisInput.downLimit }}</p>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="row result-info-cart" ng-show="cartProduct.length != 0" ng-if="UserInfo.typeDelivery == 'delivery'">
			<div class="col-sm-6 result-info-item">
				<div class="info-footer">
					<p>{{getLocale('Delivery address')}}: <span class="address">{{UserInfo.addressDelivery.fullAddress}}</span></p>
				</div>
			</div>
			<div class="col-sm-6 text-right result-info-item">
				<p>{{getLocale('Delivery')}}: <span class="value">{{ UserInfo.restaurantInfo.delivery_price | filterNumeric }} {{ Currency }}</span></p>
				<p>{{getLocale('Sum total')}}: <span class="value">{{ CartInfo.ResultSumm | filterPrice | filterNumeric }} {{ Currency }}</span></p>
				<!--<p>{{getLocale('Tax')}}: <span class="value">0.00 Р</span></p>-->
			</div>
		</div>
		<div class="row result-info-cart"  ng-show="cartProduct.length != 0"  ng-if="UserInfo.typeDelivery == 'restaurant'">
			<div class="col-sm-6 result-info-item">
				<div class="info-footer">
					<p>{{getLocale('Pickup from the restaurant')}}: {{UserInfo.restaurantInfo.name}}</p>
					<p>{{getLocale('Address')}}: {{UserInfo.restaurantInfo.address.formatted_address}}</p>
				</div>
			</div>
			<div class="col-sm-6 text-right result-info-item">
				<p>{{getLocale('Sum total')}}: <span class="value">{{CartInfo.ResultSumm | filterPrice | filterNumeric }} {{ Currency }}</span></p>
			</div>
		</div>
		<div class="row result-info-cart"  ng-show="cartProduct.length != 0">
			<div class="col-xs-12 text-right h-error-color error-final-cart" ng-show="errorCart">
				{{getLocale('Errors in selecting products')}}
			</div>
			<div class="col-xs-12 text-right result-info-item">
				<a ng-href="#/catalog" class="link-catalog btn"> {{getLocale('Continue shopping')}}</a>
				<a class="button-result-form btn" ng-click="checkMinValueCart()">{{getLocale('Go to formalization')}} <i class="fa fa-chevron-right arrow"></i></a>
			</div>
		</div>
	</div>
</div>
