<{assign var="profile" value=$product->getProfile()}>
<{assign var="attr" value=$profile->getAttributeList()}>

<{$has_variants = false}>
<{section name="j" loop=$attr}>
	<{if $attr[j]->getIsVariant() && $attr[j]->getDataType() == "valuelist"}>
		<{$has_variants = true}>
	<{/if}>
<{/section}>

<section>
    <{if $product->getIsInStock() || $product->getAllowNegativeStock()}>

		<{$remote_stock_count = 0}>
		<{if $default_stock_location = $webshop->getDefaultStockLocation()}>
			<{$default_stock_count = $product->getLocationStock($default_stock_location->getStockLocationId())}>
		<{/if}>

		<ul class="list-1 color">
			<{if $webshop->getStockLocations() && !$default_stock_count}>
				<li><{t}>På lager (eksternt lager)<{/t}></li>
				<li>Leveringstid: <{$product->getDeliveryTimeNotInStock()|escape}></li>
			<{else}>
				<li>På lager</li>
				<{if $product->getDeliveryTime()}>
					<li>Leveringstid: <{$product->getDeliveryTime()|escape}></li>
				<{/if}>
			<{/if}>

			<{if $product->getPackage()}>
				<li><{$product->getPackage()}> i kolli</li>
			<{/if}>
		</ul>
    <{else}>
		<ul class="list-4">
			<li>Ikke på lager</li>
			<{if $product->getDeliveryTimeNotInStock()}>
				<li>Leveringstid: <{$product->getDeliveryTimeNotInStock()|escape}></li>
			<{/if}>

			<{if $product->getPackage()}>
				<li><{$product->getPackage()}> i kolli</li>
			<{/if}>
		</ul>

		<{if !$has_variants}>
			<{include file="out_of_stock_signup.html" product=$product}>
		<{/if}>
    <{/if}>
</section>

<{assign var="pdf_files" value=$product->getPdfFiles()}>
<{if $pdf_files}>
	<section>
		<strong>Download fil</strong>
		<{section name="j" loop=$pdf_files}>
			<div>
				<a target="_blank" class="button color" href="<{$pdf_files[j]->getUrl()|escape}>">
					<i class="fa fa-cloud-download"></i> <{$pdf_files[j]->getFilename()|escape}> (<{$pdf_files[j]->getMB()|number_format:2:",":"."}> MB)
				</a>
			</div>
		<{/section}>
	</section>
<{/if}>

<{if $product->getIsInStock() || $product->getAllowNegativeStock()}>

	<form action="" method="post" id="basket_form">
		<input type="hidden" name="product_id" value="<{$product->getProductId()}>"/>

		<{if $product->hasBundleProducts()}>
			<{assign var="bundle" value=$product->getBundleProductsCount()}>
			<section class="variables">
				<{if $bundle}>
					<h4 class="mb-4">I denne samlepakke:</h4>

					<{section name="f" loop=$bundle}>
						<div class="row mb-2">

							<{assign var="b_product" value=$bundle[f].product}>
							<{assign var="b_profile" value=$b_product->getProfile()}>
							<{assign var="b_attr" value=$b_profile->getAttributeList()}>

							<{assign var="b_img" value=$b_product->getImage()}>

							<div class="col-2">
								<{if $b_img}>
									<a href="<{$b_product->getRemoteUrl()|escape}>"><img class="rounded img-fluid" src="<{$b_img->getSrc(80, 80, 'box')}>"></a>
								<{/if}>
							</div>

							<div class="col">
								<strong><{$bundle[f].count}> x <a href="<{$b_product->getRemoteUrl()|escape}>"><{$b_product->getName()|escape}></a></strong>
							</div>

							<div class="col">
								<{section name="j" loop=$b_attr}>
									<{if $b_attr[j]->getIsVariant()}>
										<{if $b_attr[j]->getDataType() == "valuelist"}>
											<{assign var="values" value=$b_attr[j]->getValues()}>
											<select class="form-control" name="b_attributes[<{$b_product->getProductId()}>][<{$b_attr[j]->getAttributeId()}>]" required>
												<{section name="k" loop=$values}>
													<option value="<{$values[k]->getAttributeValueId()}>">
														<{$values[k]->getVal()|escape}>
													</option>
												<{/section}>
											</select>
										<{/if}>
									<{/if}>
								<{/section}>
							</div>
						</div>

						<{if !$smarty.section.f.last}><div class="border-top my-3"></div><{/if}>

					<{/section}>

				<{/if}>
			</section>
		<{/if}>

		<{section name="j" loop=$attr}>
			<{if $attr[j]->getIsVariant()}>

				<section class="variables">

					<label for="a<{$attr[j]->getAttributeId()}>"><{$attr[j]->getName()|escape}>:</label>

					<{if $attr[j]->getDataType() == "valuelist"}>

						<{assign var="values" value=$attr[j]->getValues()}>

						<select name="attributes[<{$attr[j]->getAttributeId()}>]" id="a<{$attr[j]->getAttributeId()}>">

							<{section name="k" loop=$values}>

								<{assign var="attribute_price" value=$product->getAttributePrice($values[k]->getAttributeValueId())}>
								<option value="<{$values[k]->getAttributeValueId()}>">
									<{$values[k]->getVal()|escape}>
									<{if $attribute_price}>
										[<{$attribute_price|number_format:2:",":"."}> <{$webshop->getCurrency()}>]
									<{/if}>

									<{if $settings.settings.show_stock}>
										(<{$product->getInStock($attr[j]->getAttributeId(), $values[k]->getAttributeValueId())}> på lager)
									<{/if}>
								</option>

							<{/section}>
						</select>

					<{elseif $attr[j]->getDataType() == "string"}>

						<input required type="text" name="attributes[<{$attr[j]->getAttributeId()}>]" id="a<{$attr[j]->getAttributeId()}>"/>

					<{elseif $attr[j]->getDataType() == "integer"}>

						<input required type="text" name="attributes[<{$attr[j]->getAttributeId()}>]" id="a<{$attr[j]->getAttributeId()}>"/>

					<{elseif $attr[j]->getDataType() == "boolean"}>

						<input required type="checkbox" name="attributes[<{$attr[j]->getAttributeId()}>]" value="1" id="a<{$attr[j]->getAttributeId()}>"/>

					<{/if}>

				</section>

			<{else}>

			<{/if}>

		<{/section}>

		<section class="linking">
			<div class="qtyminus"></div>
			<input type='text' name="amount" <{if $product->getPackage()}>package="<{$product->getPackage()}>" value='<{$product->getPackage()}>'<{else}>value='1'<{/if}> class="qty" style="box-sizing: content-box !important" />
			<div class="qtyplus"></div>
			<input class="button adc color productEntityAddToCart" type="submit" value="Læg i kurv">

			<div class="clearfix"></div>
		</section>

		<div class="clearfix"></div>
	</form>

<{/if}>

<{if $has_variants}>
	<{include file="out_of_stock_signup.html" product=$product for_variants=true}>
<{/if}>

<{include file="add_to_wishlist.html"}>