@extends('emails.layouts.master')

@section('content')
	<div style="font-style: italic; color: #555;">
		<!-- ******** Please do not reply to this email ******** -->
	</div>
	<div style="font-size: 14px; margin-top: 10px; color: #999;">
		### Please do not reply to this email! ###
	</div>

	<!-- Bordered delimiter -->
	<div style="height: 1px; border-top: 1px dashed #cacaca; margin: 5px 0;"></div>

	<!-- Render the person's details -->
	<table style="width: 100%; border: none;">
		<tbody>
			<tr>
				<td style="width: 60px; vertical-align: middle;">
					<img src="{!! strpos($task->user->profile_photo_url, 'data:image') !== FALSE ? $task->user->profile_photo_url : 'data:image/png;base64,'. base64_encode(file_get_contents($task->user->profile_photo_url)) !!}" alt="Profile Photo" style="width: 50px; height: 50px; font-size: 15px; border-radius: 7px; border: 1px solid #EAEAEA;">
				</td>
				<td>
					<div style="font-size: 27px; padding-top: 15px; padding-bottom: 5px;">
						<span style="font-weight: bold; color: #3a87ad; font-style: italic;">{!! $task->user->name !!}</span> <span style="">completed a repair.</span> <span style="font-style: italic;">[{!! $task->id !!}]</span>
					</div>
					<div style="font-size: 15px; color: #999;">
						{!! Carbon\Carbon::parse($task->completed_at)->diffForHumans() !!} &middot; Duration: {!! Carbon\Carbon::parse($task->completed_at)->diffInDays(Carbon\Carbon::parse($task->created_at), true) !!} days &middot; {!! $task->client->name !!}
					</div>
				</td>
			</tr>
		</tbody>
	</table>

	<div style="clear: both;"></div>

	<table style="width: 100%; boder: none; margin-top: 20px;">
		<tbody>
			<tr>
				<td style="width: 70%;">

					<!-- Render details about the job -->
					<p style="font-size: 17px; font-weight: bold;">{!! $task->title !!}</p>

					<p style="font-size: 13px; color: #555;">
						{!! $task->problem !!}
					</p>

					<!-- Render comments -->
					<p style="font-size: 17px; font-weight: normal; margin-top: 50px;">Comments</p>

					<table style="width: 100%; boder: none;">
						<tbody>

							@foreach ($task->comments as $comment)
								<tr style="border-bottom: 1px dotted #cacaca; margin: 5px 0;">
									<td style="width: 65px; padding-top: 15px; padding-bottom: 30px;">
										<img src="{!! strpos($comment->creator->profile_photo_url, 'data:image') !== FALSE ? $comment->creator->profile_photo_url : 'data:image/png;base64,'. base64_encode(file_get_contents($comment->creator->profile_photo_url)) !!}" alt="Profile Photo" style="width: 50px; border-radius: 10px;">
									</td>
									<td style="padding-top: 15px; padding-bottom: 30px;">
										<!-- Render the author's name -->
										<div style="font-size: 16px; font-weight: bold;">

											<!-- Render the name of the person who created the comment -->
											@if ( $comment->customer_reply)
												<!-- this was emailed by a customer -->
												{!! $comment->from_name ? : trim($comment->client->name) !!}
											@else
												<!-- this is from a member of staff -->
												{!! trim($comment->creator->name) !!}
											@endif
										</div>

										<!-- Render the time -->
										<div style="color: #999; margin-top: 5px; font-size: 14px;">{!! Carbon\Carbon::parse($comment->created_at)->format('d F Y \a\t H:i') !!}</div>

										<!-- Render the message -->
										<div style="font-size: 14px; margin-top: 25px;">
											{!! nl2br($comment->message) !!}
										</div>
									</td>
								</tr>
							@endforeach


						</tbody>
					</table>

				</td>
				<td style="width: 30%;">

					<!-- Render the customer details -->
					<div style="font-size: 17px; margin-left: 20px; font-weight: bold; padding-top: 10px; color: #3a87ad;">
						{!! $task->client->name !!}
					</div>

					<!-- Render pricing summary -->
					<div style="margin-left: 20px; margin-top: 15px; border: 1px solid #EAEAEA;">
						<p style="font-size: 15px; font-weight: bold; padding-top: 10px; padding-left: 5px; padding-bottom: 5px; border-bottom: 1px solid #EAEAEA;">Pricing</p>

						<div style="padding-left: 5px;">
							<table style="width: 100%; boder: none; margin-top: 10px;">
								<tbody>
									<tr>
										<td>Labour</td>
										<td>&pound;{!! number_format($task->labour, 2) !!}</td>
									</tr>
									<tr style="border-bottom: 1px solid #EAEAEA;">
										<td style="padding-bottom: 5px; padding-top: 5px;">Parts</td>
										<td style="padding-bottom: 5px; padding-top: 5px;">&pound;{!! number_format($task->parts_total, 2) !!}</td>
									</tr>
									<tr>
										<td style="font-weight: bold; padding-bottom: 5px; padding-top: 5px;">Total</td>
										<td style="font-weight: bold; padding-bottom: 5px; padding-top: 5px;">&pound;{!! number_format($task->labour + $task->parts_total, 2) !!}</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>

				</td>
			</tr>
		</tbody>
	</table>
@stop

@section('automessage')
	<!-- Bordered delimiter -->
	<div style="height: 1px; border-top: 1px dashed #cacaca; margin: 5px 0;"></div>

	<div style="font-size: 14px; margin-top: 10px; color: #999;">
		## This message was generated using the <span style="color: #3a87ad;">Seraph HelpDesk</span> ##
	</div>
@stop