<?php
$data = $users[0];
$userid = $data['userid'];
$usernumber = $data['usernumber'];
$firstname = $data['firstname'];
$lastname = $data['lastname'];
$initial = $data['initial'];
$birthdate = $data['birthdate'];
if($birthdate != '') { $birthdate = substr( $birthdate,0,10 ); }
$email_1 = $data['email_1'];
$email_2 = $data['email_2'];
$phone = $data['phone'];
$userposition = $data['userposition'];
$userdepartment = $data['userdepartment'];
$userreportto = $data['userreportto'];
$offname = $data['offname'];
$startdate= $data['startdate'];
if($startdate != '') { $startdate= substr( $startdate,0,10 ); }
$enddate = $data['enddate'];
if($enddate != '') { $enddate = substr( $enddate,0,10 ); }
?>
<div class="modal-header">
	<h4 class="modal-title" id="tooltipmodel">User Detail</h4>
	<button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
</div>
<div class="modal-body">
	<div class='row'> <div class='col-3'>User ID</div>	<div class='col-9'>: <?=$userid;?></div> </div>
	<div class='row'> <div class='col-3'>User#</div> <div class='col-9'>: <?=$usernumber;?></div> </div>
	<div class='row'> <div class='col-3'>Firstname</div> <div class='col-9'>: <?=$firstname;?></div> </div>
	<div class='row'> <div class='col-3'>Lastname</div> <div class='col-9'>: <?=$lastname;?></div> </div>
	<div class='row'> <div class='col-3'>Initial</div> <div class='col-9'>: <?=$initial;?></div> </div>
	<div class='row'> <div class='col-3'>DoB</div> <div class='col-9'>: <?=$birthdate;?></div> </div>
	<div class='row'> <div class='col-3'>Email 1</div> <div class='col-9'>: <?=$email_1;?></div> </div>
	<div class='row'> <div class='col-3'>Email 2</div> <div class='col-9'>: <?=$email_2;?></div> </div>
	<div class='row'> <div class='col-3'>Phone</div> <div class='col-9'>: <?=$phone;?></div> </div>
	<div class='row'> <div class='col-3'>Department</div> <div class='col-9'>: <?=$userdepartment;?></div> </div>
	<div class='row'> <div class='col-3'>Position</div> <div class='col-9'>: <?=$userposition;?></div> </div>
	<div class='row'> <div class='col-3'>Report To</div> <div class='col-9'>: <?=$userreportto;?></div> </div>
	<div class='row'> <div class='col-3'>Office</div> <div class='col-9'>: <?=$offname;?></div> </div>
	<div class='row'> <div class='col-3'>Start Work</div> <div class='col-9'>: <?=$startdate;?></div> </div>
	<div class='row'> <div class='col-3'>End Work</div> <div class='col-9'>: <?=$enddate;?></div> </div>
</div>

<div class="modal-header">
	<h4 class="modal-title" id="tooltipmodel">History</h4>
</div>
<div class="modal-body">
	<div class="table-responsive">
		<table class="table display table-striped border">
			<thead>
				<tr> <th>Department</th> <th>Position</th> <th>Office</th> <th>Report to</th> <th style="width:12%">Start Work</th><th style="width:12%">End Work</th><th>Action</th></tr>
			</thead>
			<tbody>
				<?php foreach($users_log as $data) { 
					$userlogid = $data['userlogid'];
					$userdepartment = $data['userdepartment'];
					$userposition = $data['userposition'];
					$office = $data['office'];
					$reportto = $data['reportto'];
					
					$startdate = $data['startdate'];
					$startdate = substr( $startdate,0,10 );

					$createdate = $data['createdate'];
					$createdate = substr( $createdate,0,10 );

					$enddate = $data['enddate'];
					if($enddate != '') { $enddate = substr( $enddate,0,10 ); }
				?>
					<tr> 
						<td><?=$userdepartment;?></td>
						<td><?=$userposition;?></td>
						<td><?=$office;?></td>
						<td><?=$reportto;?></td>
						<td><?=$startdate;?></td>
						<td><?=$enddate;?></td>
						<td>
							<div class="row ">
							<div class="col-auto mb-1">
								<a class='btn btn-warning btn-sm' href='users/log/edit/<?=$userlogid;?>' 
									onclick="window.open(this.href, 'Site Log Editor','width=900,height=600,toolbar=1,resizable=0'); return false;">
									<i class="fas fa-pencil-alt"></i> Edit
								</a>
							</div>
							<div class="col-auto">
								<a class='btn btn-danger btn-sm' href='users/log/delete/<?=$userlogid;?>' onclick="return confirm('Are you sure?')" > <i class="fas fa-trash-alt"></i> Delete </a>
							</div>
							</div>
						</td> 							
					</tr>
				<?php } ?>

			</tbody>
		</table>
	</div>
</div>

<div class="modal-footer">
	<button type="button" class="btn btn-info waves-effect text-white" data-bs-dismiss="modal">Close</button>
</div>

