<?php // BEGIN PHP
session_start(); // start session
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/categories.lib.php';

$tag = GETPOST('tag', 'alpha');
$cat_id = GETPOST('cat', 'alpha');
$search = GETPOST('search_query', 'alpha');
// END PHP 
?>
<div id="page">
	<div class="header-container">
		<?php includeContainer('header'); ?>
	</div>
	<div class="columns-container">
		<div id="columns" class="container">
			<!--  Breadcrumb  -->
			<div class="breadcrumb clearfix">
				<a class="home" href="index.php" title="<?php print $weblangs->trans("backHome"); ?>"><i class="icon-home"></i></a>
				<span class="navigation-pipe">&gt;</span> <?php print $weblangs->trans("yourShoppingCart"); ?>
			</div>
			<!--  Breadcrumb  -->
			<div id="slider_row" class="row">
				<div id="top_column" class="center_column col-xs-12 col-sm-12"></div>
			</div>
			<div class="row">
				<!-- include lefet sidebar container -->
				<?php includeContainer('sidebar'); ?>
				<div id="center_column" class="center_column col-xs-12 col-sm-9">
					<div class="clearfix">
						<h1 class="page-heading"><?php print $weblangs->trans("cartSummary"); ?>
						<span class="heading-counter"><?php print $weblangs->trans("yourCartContains"); ?>:
    						<?php if ($_SESSION['products']): ?>
                                <span class="ajax_cart_no_product"><?php print count($_SESSION['products']); ?></span> <?php if(count($_SESSION['products']) > 1){ print $weblangs->trans("products");}else{ print $weblangs->trans("product");} ?>
                            <?php else: ?>
                                <span id="ajax_cart_no_product">0</span> <?php print $weblangs->trans("product"); ?>
                            <?php endif ?>
						</span>
						</h1>
						<?php if (!$_SESSION['products']): ?>
                            <p class="alert alert-warning"><?php print $weblangs->trans("cartIsEmpty"); ?></p>
                        <?php else: ?>
							<div id="order-detail-content" class="table_block table-responsive">
							    
							    <?php if (getDolGlobalInt("MARKETPLACE_BLOCK_SALES")): ?>
                                    <div class="block-sells-notification">
                                        <?php print $weblangs->trans("marketplacePurchasesDisabled"); ?>
                                    </div>
                                <?php endif ?>
                                
								<table id="cart_summary" class="table table-bordered stock-management-off">
									<thead>
										<tr>
											<th class="cart_product first_item"><?php print $weblangs->trans("product"); ?></th>
											<th class="cart_description item"><?php print $weblangs->trans("description"); ?></th>
											<th class="cart_unit item"><?php print $weblangs->trans("unitPrice"); ?></th>
											<th class="cart_quantity item"><?php print $weblangs->trans("quantity"); ?></th>
											<th class="cart_total item"><?php print $weblangs->trans("total"); ?></th>
											<th class="cart_delete last_item">&nbsp;</th>
										</tr>
									</thead>
									
									<tbody>
                                        <?php $total = 0; ?>
                                        <?php foreach ($_SESSION['products'] as $cart_product): ?>
                                            <tr id="product_<?php print $cart_product['product_id']; ?>" class="cart_item">
    											<td class="cart_product">
    												<a href="product.php?id=<?php print $cart_product['product_id']; ?>"><img src="<?php print $cart_product['product_thumb']; ?>" id="product_img_<?php print $cart_product['product_id']; ?>" alt="<?php print $cart_product['product_name']; ?>" width="98" height="98"></a>
    											</td>
    											<td class="cart_description">
    												<p class="product-name"><a href="product.php?id=<?php print $cart_product['product_id']; ?>"><?php print $cart_product['product_name']; ?></a></p>
    												<small class="cart_ref"><?php print $weblangs->trans("sku"); ?> : <?php print $cart_product['product_ref']; ?></small>
    											</td>
    											<td class="cart_unit" data-title="Unit price">
    												<span class="price" id="product_price"><span class="price" id="product_price_<?php print $cart_product['product_id']; ?>"><?php print price($cart_product['product_price']); ?></span> €</span>
    											</td>
    
    											<td class="cart_quantity text-center">
    
    												<input type="hidden" value="1" name="quantity_<?php print $cart_product['product_id']; ?>_hidden">
    												<input size="2" type="text" autocomplete="off" class="cart_quantity_input form-control grey" value="<?php print $cart_product['product_qty']; ?>" name="quantity_<?php print $cart_product['product_id']; ?>">
    												<div class="cart_quantity_button clearfix">
    													<a rel="nofollow" class="product_quantity_down btn btn-default button-minus button-minus-order" id="cart_quantity_down" data-field-qty="quantity_<?php print $cart_product['product_id']; ?>" data-ref="<?php print $cart_product['product_id']; ?>" href="" title="<?php print $weblangs->trans("subtract"); ?>">
    														<span><i class="icon-minus"></i></span>
    													</a>
    													<a rel="nofollow" class="product_quantity_up btn btn-default button-plus button-plus-order" id="cart_quantity_up" data-field-qty="quantity_<?php print $cart_product['product_id']; ?>" data-ref="<?php print $cart_product['product_id']; ?>" href="" title="<?php print $weblangs->trans("add"); ?>"><span><i class="icon-plus"></i></span></a>
    												</div>
    											</td>
    											<td class="cart_total" data-title="Total">
    												<span class="price"><span class="total_line" id="total_product_price_<?php print $cart_product['product_id']; ?>"><?php print price($cart_product['product_price']*$cart_product['product_qty']); ?></span> €</span>
    											</td>
    											<td class="cart_delete text-center" data-title="Delete">
    												<div>
    													<a rel="nofollow" title="<?php print $weblangs->trans("delete"); ?>" class="cart_quantity_delete ajax_cart_block_remove_link" data-code="<?php print $cart_product['product_id']; ?>" href=""><i class="icon-trash"></i></a>
    												</div>
    											</td>
    										</tr>
										
                                            	
                                            <?php
                                                $subtotal = ($cart_product['product_price'] * $cart_product['product_qty']);
                                                $total = ($total + $subtotal);
                                            ?>
                                        <?php endforeach ?>
										
									</tbody>
									<tfoot>
										<tr class="cart_total_price">
											<td rowspan="5" colspan="2" id="cart_voucher" class="cart_voucher">
											</td>
											<td colspan="2" class="text-right"><?php print $weblangs->trans("totalProductsTaxIncl"); ?></td>
											<td colspan="2" class="price" ><span id="total_product"><?php print price($total); ?></span> €</td>
										</tr>
										<tr class="cart_total_delivery">
											<td colspan="2" class="text-right"><?php print $weblangs->trans("shipping"); ?></td>
											<td colspan="2" class="price" id="total_shipping"><?php print $weblangs->trans("freeShipping"); ?></td>
										</tr>

										<tr class="cart_total_price">
											<td colspan="2" class="total_price_container text-right">
												<span><?php print $weblangs->trans("total"); ?></span>
											</td>
											<td colspan="2" class="price" id="total_price_container">
												<span><span id="total_price"><?php print price($total); ?></span> €</span>
											</td>
										</tr>
									</tfoot>
								</table>
							</div>

							<p class="cart_navigation clearfix">
							    <?php if (!getDolGlobalInt("MARKETPLACE_BLOCK_SALES")): ?>
                                    <a href="payment.php" class="button btn btn-default standard-checkout button-medium" title="<?php print $weblangs->trans("LoginCheckout"); ?>">
    									<span><?php print $retVal = (empty($_SESSION['user']['id_user'])) ? $weblangs->trans("LoginCheckout") : $weblangs->trans("proceedToCheckout") ; ?><i class="icon-chevron-right right"></i></span>
    								</a>
                                <?php endif ?>

								<a href="" onclick="history.go(-1)" class="button-exclusive btn btn-default" title="<?php print $weblangs->trans("continueShopping"); ?>">
									<i class="icon-chevron-left"></i><?php print $weblangs->trans("continueShopping"); ?>
								</a>
							</p>


						<?php endif ?>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- .columns-container -->
	<div class="footer-container">
		<?php includeContainer('footer'); ?>
	</div>
</div>