<div class="row order-business-row">
	<div class="col-sm-5">
    	<?php
			$order->details=$order_dtls;
			$businessName="";
			$businessUrl="";
			
			if($order->to_user_id){
				$user=\Auth::user()->present()->getUserById($order->to_user_id);
				if($user){
					$businessName=$user->fullname;
					$businessUrl=$user->present()->url();
				}
			}
		?>
		
        @if($order->details)
				<?php 
                    $pr=1;
                    $prCount=count($order->details);
                ?>
                @foreach($order->details as $dtls)
                    @if($dtls->product)
                        <?php 
							$product=$dtls->product;							
                            $productUrl="";                            
                            if($dtls->community_business_id!=0){								
                                $business=\Auth::user()->present()->getStoreById($dtls->community_business_id);
                            }else{
                                $business=\Auth::user()->present()->getStoreById($dtls->community_id);
                            }
                            
                            if($business){
                                $productUrl=URL::route('store', ['slug' => $business->slug])."/product/".$product->id;
								
								$businessName=$business->title;
								$businessUrl=URL::route('store', ['slug' => $business->slug]);
                            }else{
								$productUrl=\URL::route('productbuy',['id'=>$product->id]);
							}
						?>
                        
                        @if($prCount>1){{$pr}}) @endif <a href="{{$productUrl}}">
                        
                        @if($product->product_type!=2)
                            @if($product->image1)
                                <img data-original="{{Image::url($dtls->product->image1)}}" class="purchase-history-product-img lazy"/>
                                <br />
                            @endif
                        @else
                        	@if($product->digital_type==1)
                            	@if($product->digital_video_sample_file)
                                    <div class="order-video-outer-box">
                                         <iframe class="upload-video" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" style="border: none;padding: 0;border-radius: 10px;overflow: hidden" src="{{URL::route('play-video')}}?path={{$product->digital_video_sample_file}}" width="100%" height="330"></iframe>
                                    </div> 
                                @endif 
                            @elseif($product->digital_type==2)
                            	@if($product->digital_image_sample_file)
                                     <img data-original="{{Image::url($product->digital_image_sample_file)}}" data-url="{{Image::url($product->digital_image_sample_file)}}" class="order-show-business-product-image lazy" data-id="{{$product->id}}">
                                @endif 
                            @elseif($product->digital_type==3)
                           		<br />
                            	<?php
									$allowed_files  = ['jpg', 'jpeg', 'png', 'gif','pdf', 'txt','mp4', 'mov', 'mpg', 'flv','mp3', 'wav', 'ogg', 'aif','wma','mid'];
									
									$fullPath=getFullPath($product->digital_file_sample_file);
									$extension=strtolower($product->digital_sample_file_extension);
									
								?>
                                
                                @if(in_array($extension, $allowed_files))
                              		<span class="read-sample-file" data-id="{{$product->id}}" style="font-size: 14px;padding: 5px 6px;">Read Sample</span>
                            	@else
                            		<a class="download-sample-file" href="{{\URL::route('postproduct-downloadfile')}}?path={{$product->digital_file_sample_file}}" style="font-size: 14px;padding: 5px 6px;">Download Sample</a>
                                @endif
                              
                              	<br /><br />
                                
    							{!! Theme::section('user.products.view-sample-file',['product'=>$product]) !!}
                            @endif
                        @endif
                        
                        {{$product->product_name}}
                        
                        <span class="brand-colored-texts">@if($dtls->product_size) ({{$dtls->product_size}}) @endif @if($dtls->product_color) <span class="selected-color">{{$dtls->product_color}}</span> @endif</a> <br />
                        
                        Quantity : <strong>{{$dtls->quantity}} </strong>
                        
                        @if($product->product_type==2)
                        	<br />
                            <br />
                        	@if($product->digital_type==1)
                            	<a href="{{\URL::route('postproduct-orderview')}}?orderid={{$order->id}}" class="view-digital-order-btn">View Full Video</a>
                            @elseif($product->digital_type==2)
                            	<a href="{{\URL::route('postproduct-orderview')}}?orderid={{$order->id}}" class="view-digital-order-btn">View Full Image</a>
                            @elseif($product->digital_type==3)
                           		 <a href="{{\URL::route('postproduct-orderview')}}?orderid={{$order->id}}" class="view-digital-order-btn">View eBook</a>
                            @endif                        
                        @endif
                        
                        @if($order->order_type==1)
                        	<br />
                        	<span class="brand-colored-texts">Subscription Basis</span> <br />
                            
                            Subscription type:
                            		<strong>
                                    @if($order->subscription_type==1)
                                        weekly
                                    @elseif($order->subscription_type==2)
                                        bi-weekly
                                    @elseif($order->subscription_type==3)
                                        monthly
                                    @endif </strong><br />
                                    
                            Subscription Cycle: <strong>{{$order->subscription_cycle}}</strong> <br />                            
                            Completed Cycle: <strong>{{$order->completed_cycles}}</strong> <br />                              
                            Subscribed On: <strong><br />  {{date("F j, Y",strtotime($order->subscription_date))}}</strong><br />
                            Next cycle date: <strong><br />  {{date("F j, Y",strtotime($order->next_payment_date))}}</strong>  
														
							<p style="margin-top:15px;"><strong>Payment transactions:</strong></p>
																		
							<?php
								$transactions=\Auth::user()->present()->getProductRecurringTrans($product->id,$order->id);
							?>
							
							<div>
								@if(!empty($transactions))
									<table class="table table-bordered">
										<tr>
											<th>Amount</td>
											<th>Date</td>
											<th>Transaction Details</td>
										</tr>													
										
										@foreach($transactions as $trans)	
											<tr>
												<td>{!! $currencyIcon !!} {{number_format($trans->amount, 2, '.', ',')}}</td>
												<td>{{date("F j, Y",strtotime($trans->created_at))}} </td>
												<td>
													<strong>Status:</strong> Completed <br>
													<strong>Transaction Id:</strong> {{$trans->transaction_id}}
												</td>
											</tr>															
										@endforeach	
										
										<tr>
											<td>{!! $currencyIcon !!} {{number_format($order->amount, 2, '.', ',')}}</td>
											<td>{{date("M j, Y",strtotime($order->created_at))}} </td>
											<td>
												<strong>Status:</strong> Completed <br>
												<strong>Transaction Id:</strong> {{$order->transaction_id}}
											</td>
										</tr>
									</table>	
								@endif
							</div>
                        @endif
                        
                        <br /><br />
                        <?php $pr++;?>
                    @endif
                @endforeach
           @endif
    </div>
    
    @if($product->product_type==3) 
		<div class="col-sm-7">	
			
			<span class="brand-colored-texts"> Seller : </span>        
			<p>@if($businessName) <a href="{{$businessUrl}}">{{$businessName}}</a> @endif</p> <br>

			@if($product->coursecontents)				
				<div class="box-outsite-course-contents">
					<div class="box-inside-course-contents">
						<p class="heading-course-contents" style="font-size:19px;">Course content</p>				
						<div class="course-contents-list">
							<div class="course-contents-section-ttl" style="font-size: 15px;">
								{{$product->course_total_sections}} Sections  •  {{$product->course_total_lectures}} Lectures  •  {{$product->course_taotal_length}} hrs  {{$product->course_taotal_length_mins}} mins total length
							</div>
							
							<div class="course-contents-listing"> 
								@foreach($product->coursecontents as $content)
									<div class="course-contents-item" data-id="{{$content->id}}">	
										<div class="row">
											<div class="col-sm-8 col-xs-8">
												<div class="course-contents-heading-details" style="font-size: 15px; font-weight:normal;">
													{{$content->section_heading}}	
												</div>	
											</div>

											<div class="col-sm-4 col-xs-4">	
												<div class="course-contents-length-details">
													{{$content->total_lectures}} lectures
													<br>							
													{{$content->hrs}} hrs {{$content->mins}} mins 	
												</div>	
											</div>	
										</div>	
									</div> 
									
									@if($content->coursecontenttopics)
										<div class="course-contents-item-details course-contents-item-details-{{$content->id}}">	
											@foreach($content->coursecontenttopics as $topic)
												<div class="topic-itesm">
													<div class="row">
														<div class="col-sm-9 col-xs-9">
															<i style="margin-right:8px;" class="fa fa-video-camera" aria-hidden="true"></i> {{$topic->topic}}
														</div>

														<div class="col-sm-3 col-xs-3">
															<div class="topic-time-box">
																<a href="{{\URL::route('product-to-sell-course-watch',['id'=>$product->id,'topic_id'=>$topic->id,'order_id'=>$order->id])}}" style="color:#f00;" target="_blank">Watch</a> <br>
																{{$topic->hrs}} hrs {{$topic->mins}} mins 	
															</div>	
														</div>	
													</div>	
												</div>	
											@endforeach	
										</div>
									@endif	
								@endforeach	
							</div>
						</div>
					</div>
				</div>
			 @endif	
		</div>	 
	@else
		<div class="col-sm-7">
			  <span class="brand-colored-texts"> Seller : </span>        
			  <p>@if($businessName) <a href="{{$businessUrl}}">{{$businessName}}</a> @endif</p> <br>
	
			  @if($order->delivery_option==1) 
					<b>Pickup</b><br />
					
					<p class="product_pickup_dt product_pickup_dt_{{$order->id}}"><strong>Date:</strong> {{date("d F Y",strtotime($order->order_date_time))}}<br />
					<strong>Time:</strong> {{date("H:i A",strtotime($order->order_date_time))}}<br /></p>
					
					<strong>Cell:</strong> {{$order->mobile}}
					
					@if(!$order->picked_by and $showChangeDate=='yes' and $order->original_pickup_date_time=='0000-00-00 00:00:00')
						<div class="change_pickup_date_box change_pickup_date_box_{{$order->id}}">
							<input type="text" class="form-control product_picked_date new_pickup_date_{{$order->id}}" />
							
							<button data-id="{{$order->id}}" class="btn btn-sm red-color-button save_new_pickup_date" placeholder="Select new pickup date and time">Save</button>
							
						</div> 
						
					   <button data-id="{{$order->id}}" class="btn btn-sm black-color-button open_save_new_pickup_date open_save_new_pickup_date_{{$order->id}}">Change Pickup Time</button>  
					@endif
				@else 
					<b>Courier</b> 
					<br />
					Address:
					<br />
					<!--<b>Delivery Details</b><br />-->
					{{$order->full_name}}<br />
					{{$order->address_1}}<br />
					{{$order->city}}, {{$order->zip}}<br />
					{{$order->state}}, {{$order->country}}<br />
					<strong>Cell:</strong> {{$order->mobile}}
				@endif        
				<br /><br />
		
			 @if($order->delivery_option==1) 
				<b>Picked by:</b> <br />
				
				@if($order->picked_by)
					{{$order->picked_by}}<br />	
					<strong>Date:</strong> {{date("d F Y",strtotime($order->picked_date))}}<br />
					<strong>Time:</strong> {{date("H:i A",strtotime($order->picked_date))}}<br />
				@endif 
			@else
				<b>Courier information:</b> <br />
				
				@if($order->courier_by)
					{{$order->courier_by}}<br />	
					<strong>Date:</strong> {{date("d F Y",strtotime($order->courier_date))}}<br />
					<strong>Tracking No:</strong> <br />{{$order->tracking_number}}<br />
				@endif 
			@endif
		</div>
	@endif	
</div> 
