<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" encoding="Windows-1251"/>

<!-- Шаблон для корзины -->
<xsl:variable name="recount" select="recount"/>

<xsl:template match="/cart">

<xsl:choose>
	<xsl:when test="(count_item=0) and (count_postpone_item=0)">
		<!-- В корзине нет ни одного элемента -->
		<p class="title">В корзине нет ни одного товара.</p>
		
		<p>
		<xsl:choose>
		<xsl:when test="user_id != 0">
			Для оформления заказа добавьте товар в корзину.
		</xsl:when>
		<xsl:otherwise>
			<xsl:choose>
				<xsl:when test="site_users_class_exists = 1">			
				Вы не авторизированы. Если Вы зарегистрированный пользователь, данные Вашей корзины станут видны после авторизации.
				</xsl:when>
				<xsl:otherwise></xsl:otherwise>
			</xsl:choose>			
		</xsl:otherwise>
		</xsl:choose>
		</p>
		
		
	</xsl:when>
	<xsl:otherwise>
		<!-- Вывод корзины -->
		<h1>Моя корзина</h1>
		
		<p>Для оформления заказа, нажмите "Оформить заказ".</p>
		
		<form action="/shop/cart/" name="address" method="POST">
			<table cellspacing="0" cellpadding="0" border="0">
				<!-- Если есть товары -->
				<xsl:if test="count(itemincart[flag_postpone=0]) > 0">
					<tr class="shop_cart_table_title">
						<td>Название</td>
						<td width="70">Вес</td>
						<td width="70">Количество</td>
						<td width="70">Цена</td>
						<td>Сумма</td>
						<td>Отложить</td>
						<td>Действия</td>
					</tr>
					<xsl:apply-templates select="itemincart[flag_postpone=0]"/>
					<tr class="shop_cart_table">
						<td><b>Итого:</b></td>
						<td>
							<xsl:if test="totalweight > 0">
							<b><xsl:value-of disable-output-escaping="yes" select="totalweight"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_mesures_name"/></b>
							</xsl:if>
						</td>
						<td><b><xsl:value-of disable-output-escaping="yes" select="totalquantity"/></b></td>
						<td>&#xA0;</td>
						<td><b><xsl:value-of disable-output-escaping="yes" select="total_sum_without_discount"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/currency"/></b></td>
						<td>&#xA0;</td>
						<td>&#xA0;</td>
					</tr>
					<xsl:if test="total_sum_without_discount > totalsum">
					<tr class="shop_cart_table">
						<td style="border-bottom: thin dashed #DADADA"><b>Скидка:</b></td>
						<td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
						<td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
						<td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
						<td style="border-bottom: thin dashed #DADADA"><b><xsl:value-of disable-output-escaping="yes" select="format-number(total_sum_without_discount - totalsum, '#.00')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/currency"/></b></td>
						<td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
						<td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
					</tr>
					<tr class="shop_cart_table">
						<td style="border-bottom: none"><b>Всего:</b></td>
						<td style="border-bottom: none">&#xA0;</td>
						<td style="border-bottom: none">&#xA0;</td>
						<td style="border-bottom: none">&#xA0;</td>
						<td style="border-bottom: none"><b><xsl:value-of disable-output-escaping="yes" select="totalsum"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/currency"/></b></td>
						<td style="border-bottom: none">&#xA0;</td>
						<td style="border-bottom: none">&#xA0;</td>
					</tr>
					</xsl:if>
				</xsl:if>
				
				<!-- Если есть отложенные товары -->
				<xsl:if test="count(itemincart[flag_postpone=1]) > 0">
					<tr class="shop_cart_table">
						<td colspan="7" style="padding-top:10px"><strong><big>Отложенные товары</big></strong></td>
					</tr>
					<tr class="shop_cart_table_title">
						<td>Название</td>
						<td width="70">Вес</td>
						<td width="70">Количество</td>
						<td width="70">Цена</td>
						<td>Сумма</td>
						<td>Отложить</td>
						<td>Действия</td>
					</tr>
					<xsl:apply-templates select="itemincart[flag_postpone=1]"/>
					<tr class="shop_cart_table">
						<td><b>Итого:</b></td>
						<td>
						<xsl:if test="totalweight > 0">
						<b><xsl:value-of disable-output-escaping="yes" select="totalweight"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_mesures_name"/></b>
						</xsl:if>
						</td>
						<td><b><xsl:value-of disable-output-escaping="yes" select="totalquantity_postpone_item"/></b></td>
						<td>&#xA0;</td>
						<td><b><xsl:value-of disable-output-escaping="yes" select="totalsum_postpone_item"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/currency"/></b></td>
						<td>&#xA0;</td>
						<td>&#xA0;</td>
					</tr>
					
				</xsl:if>
			</table>
			<!-- Купон -->
			<div style="padding: 5px;">
				Купон&#xA0;
				<input name="shop_coupon_text" type="text" value="{coupon_text}" /><br />
			</div>
			<!-- Кнопки -->
			<xsl:choose>
			<xsl:when test="site_users_class_exists = 1">
				<input name="recount" value="Сохранить изменения" type="submit" style="margin-right: 10px" />
			</xsl:when>
			<xsl:otherwise>
				<!-- В случае если отключен модуль пользователей сайта, запрашиваем информацию
				о пользователе сайта здесь -->
				<table border="0" cellspacing="0" cellpadding="2">
		       	<tr class="shop_cart_table_title">
		       		<td colspan="2" align="center">Данные о заказчике</td>
				</tr>
		       	<tr>
		       		<td>Имя</td>
					<td><input name="site_users_name" type="text" value="" size="40"/></td>
				</tr>
		       	<tr>
		       		<td>Фамилия</td>
					<td><input name="site_users_surname" type="text" value="" size="40"/></td>
				</tr>
		       	<tr>
		       		<td>Отчество</td>
					<td><input name="site_users_patronymic" type="text" value="" size="40"/></td>
				</tr>
		       	<tr>
		       		<td>E-mail</td>
					<td><input name="site_users_email" type="text" value="" size="40"/></td>
				</tr>
				<tr>
		       		<td>Телефон</td>
					<td><input name="site_users_phone" type="text" value="" size="40"/></td>
				</tr>
		       	<tr>
		       		<td>Факс</td>
					<td><input name="site_users_fax" type="text" value="" size="40"/></td>
				</tr>
		       	<tr>
		       		<td>Адрес</td>
					<td><input name="site_users_address" type="text" value="" size="40"/></td>
				</tr>
				</table>
				<!-- Добавляем скрытое поле с указанием подшага -->
				<input name="step_1_1a" type="hidden" value="1"/>
			</xsl:otherwise>
			</xsl:choose>			
			<xsl:if test="user_id != 0 or site_users_class_exists = 0">
				<input name="step_1" value="Оформить заказ" type="submit" style="font-weight: bold" />
			</xsl:if>
		</form>
	</xsl:otherwise>
</xsl:choose>

</xsl:template>

<!-- Шаблон для товара в корзине -->
<xsl:template match="itemincart">
<tr class="shop_cart_table">
	<td>
		<a href="/shop/{item/fullpath}{item/path}/"><xsl:value-of disable-output-escaping="yes" select="item/name"/></a>
	</td>
	<td style="white-space: nowrap">
		<xsl:if test="item/weight > 0">
			<xsl:value-of disable-output-escaping="yes" select="item/weight"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="../shop/shop_mesures_name"/>
		</xsl:if>
	</td>
	<td style="white-space: nowrap">
		<input type="text" size="3" name="{item/@id}" value="{quantity}"/>&#xA0;<xsl:value-of select="item/mesure"/>
	</td>
	<td style="white-space: nowrap">
	<!-- Цена -->
	<xsl:value-of select="item/price"/>&#xA0;<xsl:value-of select="item/currency"/>
	</td>
	<td style="white-space: nowrap">
		<!-- Сумма -->
		<xsl:value-of disable-output-escaping="yes" select="item/price * quantity"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="item/currency"/>
	</td>
	<td align="center">
	<!-- Отложенные товары -->
	<xsl:choose>
		<xsl:when test="flag_postpone=1">
			<input type="checkbox" name="flag_postpone{item/@id}" checked=""/>
		</xsl:when>
		<xsl:otherwise>
			<input type="checkbox" name="flag_postpone{item/@id}"/>
		</xsl:otherwise>
	</xsl:choose>
	</td>
	
	<td align="center"><a href="?action=delete_item&amp;item_id={item/@id}" title="Удалить товар из корзины" alt="Удалить товар из корзины"><img src="/hostcmsfiles/images/delete.gif"/></a></td>
</tr>
</xsl:template>

</xsl:stylesheet>