@extends('training.inc.master')

@section('title','Dashboard')

@section('content')

<main class="content">
				<div class="container-fluid p-0">

				<h1 class="h3 mb-3"><strong>Send SMS to Clients</strong></h1>
				@include('training.alerts.alert')


					<div class="row">
						<div class="col-4">
							<div class="card">
								<div class="card-header">
									<h5 class="card-title mb-0">SMS Form</h5>
								</div>
								<div class="card-body">
									<form action="{{ route('completetextsms') }}" method="post" autocomplete="off">
										@csrf
										<input type="hidden" name="userid" value="{{ Auth::user()->id }}">
										<div class="mb-3">
											<label for="mobileno" class="form-label">Mobile Number</label>
											<input type="text" class="form-control" id="mobileno" name="mobileno" placeholder="Enter mobile client number" required>
										</div>
									
										<div class="mb-3">
											<label for="message" class="form-label">Message To Client</label>
											 <textarea class="form-control" id="message" name="message" placeholder="Enter the message" required></textarea>
										</div>

										<div class="mb-3">
											<label for="username" class="form-label">Sender Name </label>
											<input type="text" class="form-control" id="username" name="username" value="{{ Auth::user()->name }}" readonly>
										</div>					
										
									
										<button type="submit" class="btn btn-primary">Send SMS</button>
									</form>
									
								</div>
							</div>
						</div>
					
						<div class="col-8">
						<div class="card">
								<div class="card-header">
									<h5 class="card-title">Registered Updates</h5>
									
								</div>
								<div class="card-body">
									<table id="datatables-reponsive" class="table table-striped" style="width:100%">
										<thead>
											<tr>
												 	<th>#</th>
													<th>Sender Name</th>
													<th>Phone Number</th>
													<th>Message</th>
													<th>Created At</th>
											</tr>
										</thead>
										<tbody>
												@foreach($messages as $message)
													<tr>
														<td>{{ $loop->iteration }}</td>
														<td>{{ $message->name }}</td>
														<td>{{ $message->phone }}</td>
														<td>{{ $message->message }}</td>
														<td>{{ \Carbon\Carbon::parse($message->created_at)->format('d-m-Y H:i:s') }}</td>														
													</tr>
												@endforeach
											</tbody>
									</table>
								</div>
							</div>

				</div>
				
			</main>
@endsection