@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;">
		### This is an automated email, please DO NOT reply to it! ###
		<p style="margin-top: 5px;">Ticket number: <span style="color: #3a87ad; font-weight: bold;">#{!! $task->id !!}</span></p>
	</div>

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

	<div style="font-size: 24px; margin-bottom: 30px; margin-top: 20px; font-weight: bold;">A task you have subscribed to has been updated</div>

	<!-- Render conversations -->
	<table style="width: 100%; boder: none;">
		<tbody>

			<tr style="margin: 5px 0;">
				<td style="width: 65px; padding-top: 15px; padding-bottom: 30px;">
					<img src="{!! strpos($task->modifier->profile_photo_url, 'data:image') !== FALSE ? $task->modifier->profile_photo_url : 'data:image/png;base64,'. base64_encode(file_get_contents($task->modifier->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 made the change -->
						{!! $task->modifier->name !!}
					</div>

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

					<!-- Render the message -->
					<div style="font-size: 14px; margin-top: 10px;">
						@if (isset($status_change))
							<p>{!! $status_change->user()->count() ? trim($status_change->user()->first()->name) : 'No one' !!} changed the status from <strong>{!! $status_change->old_status()->count() ? $status_change->old_status()->first()->name : 'No status' !!}</strong> to <strong>{!! $status_change->new_status()->count() ? $status_change->new_status()->first()->name : 'No status' !!}</strong></p>
						@endif

						@if (isset($assigned_change))
							<p><strong>{!! $assigned_change->user()->count() ? trim($assigned_change->user()->first()->name) : 'No one' !!}</strong> re-assigned this task from <strong>{!! $assigned_change->old_user()->count() ? trim($assigned_change->old_user()->first()->name) : 'No one' !!}</strong> to <strong>{!! $assigned_change->new_user()->count() ? trim($assigned_change->new_user()->first()->name) : 'No one' !!}</strong></p>
						@endif
					</div>
				</td>
			</tr>

		</tbody>
	</table>

	<!-- Bordered delimiter -->
	<div style="height: 1px; border-top: 1px solid #F1F1F1; margin: 5px 0; margin-bottom: 35px;"></div>

	<div style="font-size: 24px; margin-bottom: 30px; font-weight: bold;">Task Information</div>

	<table style="boder: none; margin-left: 5px;">
		<tbody>
			<tr>
				<td><strong>Task ID</strong></td>
				<td style="padding: 0 10px 10px 25px;">{!! $task->id !!}</td>
			</tr>
			@if($task->client_type == 'customer')
				<tr>
					<td><strong>Customer</strong></td>
					<td style="padding: 0 10px 10px 25px;">{!! $task->client->name !!}</td>
				</tr>
			@endif
			@if($task->client_type == 'client')
				<tr>
					<td><strong>Client</strong></td>
					<td style="padding: 0 10px 10px 25px;">{!! $task->client->name !!}</td>
				</tr>
				@if( $task->site_user )
					<tr>
						<td><strong>Site User:</strong></td>
						<td style="padding: 0 10px 10px 25px;">{!! $task->site_user->name !!}</td>
					</tr>
				@endif
			@endif
			<tr>
				<td><strong>Title</strong></td>
				<td style="padding: 0 10px 10px 25px;">{!! $task->title !!}</td>
			</tr>
			<tr>
				<td><strong>Status</strong></td>
				<td style="padding: 0 10px 10px 25px;">{!! $task->status->name !!}</td>
			</tr>
			<tr>
				<td><strong>Assigned to</strong></td>
				<td style="padding: 0 10px 10px 25px;"> {!! $task->user ?  trim($task->user->name) : 'No one' !!}</td>
			</tr>
			<tr>
				<td><strong>Description</strong></td>
				<td style="padding: 0 10px 10px 25px;">{!! $task->problem !!}</td>
			</tr>
			<tr>
				<td><strong>Booked in by</strong></td>
				<td style="padding: 0 10px 10px 25px;">{!! trim($task->creator->name) !!}</td>
			</tr>
			<tr>
				<td><strong>Booked at</strong></td>
				<td style="padding: 0 10px 10px 25px;">{!! Carbon\Carbon::parse($task->created_at)->format('d/m/Y \a\t H:i') !!}</td>
			</tr>
		</tbody>
	</table>
@stop

@section('automessage')

	<!-- Bordered delimiter -->
	<div style="height: 1px; border-top: 1px dotted #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