<?php
foreach($product_arr as $k => $product)
{
	$image_url = null;
	if(!empty($product['image']))
	{
		$image_url = PJ_INSTALL_URL . $product['image'];
	}
	if($k % 2 == 0)
	{
		?>
		<div class="row pjMbProductsBody">
		<?php 
	}
	?>
	<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 pjMbProduct">
		<div class="thumbnail">
			<header class="pjMbProductHead">
				<h3 class="pjMbProductTitle"><?php echo pjSanitize::html($product['name']);?></h3><!-- /.pjMbProductTitle -->
			</header><!-- /.pjMbProductHead -->
	
			<div class="pjMbProductBody">
				<?php
				if($image_url != null)
				{ 
					?>
					<div class="row">
						<div class="col-md-5 col-xs-12">
							<div class="pjMbProductImage">
								<img src="<?php echo $image_url;?>" alt="" />
							</div><!-- /.pjMbProductImage -->
						</div>
				
						<div class="col-md-7 col-xs-12">
							<div class="pjMbProductBody pjCsProductForm">
								<form id="pjCsProductForm_<?php echo $product['id'];?>" action="#" method="post">
									<input type="hidden" name="id" value="<?php echo $product['id'];?>"/>
									<input type="hidden" name="type" value="products"/>
									<?php
									if($product['set_different_sizes'] == 'T')
									{ 
										if(is_array($product['prices']))
										{
											?>
											<?php
											foreach($product['prices'] as $price)
											{
												list($pid, $p, $p_name) = explode("~|~", $price);
												?>
												<div class="pjCsProductQty">
													<div class="pjCsSpinner">
														<input type="text" name="qty[<?php echo $product['id'];?>][<?php echo $pid;?>]" data-id="<?php echo $product['id'];?>" class="form-control pjCsQty" autocomplete="off" value="<?php echo isset($product_in_cart[$product['id']][$pid]) ? $product_in_cart[$product['id']][$pid] : 0; ?>" data-min="0" />
														
														<span class="pjCsSpinnerBtn pjCsSpinnerBtnUp">
															<span class="caret"></span>
														</span>
																				
														<span class="pjCsSpinnerBtn pjCsSpinnerBtnDown">
															<span class="caret"></span>
														</span>
													</div><!-- /.pjCsSpinner -->
													<p class="pjMbMultipleSign">x</p>
													<p class="pjMbProductPrice"><?php echo pjUtil::formatCurrencySign($p, $tpl['option_arr']['o_currency'])?></p><!-- /.pjMbProductPrice -->
													<p class="pjMbPriceName"><?php echo $p_name;?></p>
												</div>
												<?php
											}
											?>
											<?php
										}
									}else{
										?>
										<div class="pjCsProductQty">
											<div class="pjCsSpinner">
												<input type="text" name="qty[<?php echo $product['id'];?>]" data-id="<?php echo $product['id'];?>" class="form-control pjCsQty" autocomplete="off" value="<?php echo isset($product_in_cart[$product['id']]) ? $product_in_cart[$product['id']] : 0; ?>" data-min="0" />
												
												<span class="pjCsSpinnerBtn pjCsSpinnerBtnUp">
													<span class="caret"></span>
												</span>
																	
												<span class="pjCsSpinnerBtn pjCsSpinnerBtnDown">
													<span class="caret"></span>
												</span>
											</div><!-- /.pjCsSpinner -->
											<p class="pjMbMultipleSign">x</p>
											<p class="pjMbProductPrice"><?php echo pjUtil::formatCurrencySign($product['price'], $tpl['option_arr']['o_currency'])?></p><!-- /.pjMbProductPrice -->
										</div>
										<?php
									} 
									$is_added_text = '';
									if(isset($product_in_cart) && array_key_exists($product['id'], $product_in_cart))
									{
										$is_added_text = __('front_added_to_cart', true);
									}
									?>
									
									<button type="button" class="btn btn-primary pull-right pjCsBtnOrder" data-id="<?php echo $product['id'];?>"><?php __('front_btn_order');?></button>
									<label id="pjCsOrderMsg_<?php echo $product['id'];?>" class="text-muted pull-right" data-type="<?php echo $is_added_text != '' ? 'added' : ''; ?>" data-enter="<?php __('front_enter_quantity');?>" data-added="<?php __('front_added_to_cart');?>"></label>
								</form>
							</div>
						</div>
					</div><!-- /.row -->
				
					<div class="pjMbProductContent">
						<p><?php echo nl2br(pjSanitize::html($product['description']));?></p>
					</div><!-- /.pjMbProductContent -->
					<?php
				}else{
					?>
					<div class="row">	
						<div class="col-md-7 col-xs-12">
							<div class="pjMbProductContent">
								<p><?php echo nl2br(pjSanitize::html($product['description']));?></p>
							</div><!-- /.pjMbProductContent -->
						</div>
						<div class="col-md-5 col-xs-12">
							<div class="pjMbProductBody pjCsProductForm">
								<form id="pjCsProductForm_<?php echo $product['id'];?>" action="#" method="post">
									<input type="hidden" name="id" value="<?php echo $product['id'];?>"/>
									<input type="hidden" name="type" value="products"/>
									<?php
									if($product['set_different_sizes'] == 'T')
									{ 
										if(is_array($product['prices']))
										{
											?>
											<?php
											foreach($product['prices'] as $price)
											{
												list($pid, $p, $p_name) = explode("~|~", $price);
												?>
												<div class="pjCsProductQty">
													<div class="pjCsSpinner">
														<input type="text" name="qty[<?php echo $product['id'];?>][<?php echo $pid;?>]" data-id="<?php echo $product['id'];?>" class="form-control pjCsQty" autocomplete="off" value="<?php echo isset($product_in_cart[$product['id']][$pid]) ? $product_in_cart[$product['id']][$pid] : 0; ?>" data-min="0" />
														
														<span class="pjCsSpinnerBtn pjCsSpinnerBtnUp">
															<span class="caret"></span>
														</span>
																				
														<span class="pjCsSpinnerBtn pjCsSpinnerBtnDown">
															<span class="caret"></span>
														</span>
													</div><!-- /.pjCsSpinner -->
													<p class="pjMbMultipleSign">x</p>
													<p class="pjMbProductPrice"><?php echo pjUtil::formatCurrencySign($p, $tpl['option_arr']['o_currency'])?></p><!-- /.pjMbProductPrice -->
													<p class="pjMbPriceName"><?php echo $p_name;?></p>
												</div>
												<?php
											}
											?>
											<?php
										}
									}else{
										?>
										<div class="pjCsProductQty">
											<div class="pjCsSpinner">
												<input type="text" name="qty[<?php echo $product['id'];?>]" data-id="<?php echo $product['id'];?>" class="form-control pjCsQty" autocomplete="off" value="<?php echo isset($product_in_cart[$product['id']]) ? $product_in_cart[$product['id']] : 0; ?>" data-min="0" />
												
												<span class="pjCsSpinnerBtn pjCsSpinnerBtnUp">
													<span class="caret"></span>
												</span>
																	
												<span class="pjCsSpinnerBtn pjCsSpinnerBtnDown">
													<span class="caret"></span>
												</span>
											</div><!-- /.pjCsSpinner -->
											<p class="pjMbMultipleSign">x</p>
											<p class="pjMbProductPrice"><?php echo pjUtil::formatCurrencySign($product['price'], $tpl['option_arr']['o_currency'])?></p><!-- /.pjMbProductPrice -->
										</div>
										<?php
									} 
									$is_added_text = '';
									if(isset($product_in_cart) && array_key_exists($product['id'], $product_in_cart))
									{
										$is_added_text = __('front_added_to_cart', true);
									}
									?>
									
									<button type="button" class="btn btn-primary pull-right pjCsBtnOrder" data-id="<?php echo $product['id'];?>"><?php __('front_btn_order');?></button>
									<label id="pjCsOrderMsg_<?php echo $product['id'];?>" class="text-muted pull-right" data-type="<?php echo $is_added_text != '' ? 'added' : ''; ?>" data-enter="<?php __('front_enter_quantity');?>" data-added="<?php __('front_added_to_cart');?>"></label>
								</form>
							</div>
						</div>
					</div><!-- /.row -->
					
					<?php 
				} 
				?>
			</div><!-- /.pjMbProductBody -->

			
		</div><!-- /.thumbnail -->
	</div><!-- /.col-lg-6 col-md-6 col-sm-6 col-xs-12 pjMbProduct -->
	<?php
	if($k % 2 != 0)
	{
		?>
		</div><!-- /.pjMbProductsBody -->
		<?php 
	}
} 
?>