<!-- 
---- Logs
--->

<?php if(service('session')->get('usuario')->id_categoria == 1 AND (isset($logs) AND !empty($logs))) { ?>
	<div class="row">
		<div class="col-lg-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title  border-danger">
					<h5>
						Registro de ações
					</h5>
				</div>

				<div class="ibox-content border-danger">
					<div class="scroll_log_content">
						<div class="row">
							<div class="col-sm-12">
								<div class="accordion accordion" id="accordion">
									<?php foreach ($logs as $key => $log) { ?>
										<div class="accordion-item">
											<h2 class="accordion-header" id="headingOne-<?php echo $key; ?>">
												<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne-<?php echo $key; ?>" aria-expanded="false" aria-controls="collapseOne-<?php echo $key; ?>">
													<a data-toggle="collapse" data-parent="#accordion" href="#<?php echo $key; ?>">
														<?php echo $log['name']; ?>
													</a>
												</button>
											</h2>
											<div id="collapseOne-<?php echo $key; ?>" class="accordion-collapse collapse" aria-labelledby="headingOne-<?php echo $key; ?>" data-bs-parent="#accordion">
												<div class="accordion-body">
													<?php  
													$content = file_get_contents($log['path']);
													echo "<pre>"; print_r(unserialize(service('encrypter')->decrypt(hex2bin($content), ['key' => getenv('ENCRYPTKEY')]))); echo "</pre>";
													?>
												</div>
											</div>
										</div>
									<?php } ?>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<?php $diff = array_slice($logs, -2, 2); ?>

	<?php if(isset($diff[0]) AND isset($diff[1])) { ?>
		<div class="row">
			<div class="col-lg-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title  border-danger">
						<h5>
							Comparativo das últimas duas alterações
						</h5>
					</div>

					<div class="ibox-content ibox-content-diff border-danger">
						<div class="row">
							<div class="col-sm-6">
								<div class="diff-original">
									<?php 
									$content = file_get_contents($diff[0]['path']);
									echo "<pre>"; print_r(unserialize(service('encrypter')->decrypt(hex2bin($content), ['key' => getenv('ENCRYPTKEY')]))); echo "</pre>";
									?>
								</div>
							</div>

							<div class="col-sm-6">
								<div class="diff-changed">
									<?php 
									$content = file_get_contents($diff[1]['path']);
									echo "<pre>"; print_r(unserialize(service('encrypter')->decrypt(hex2bin($content), ['key' => getenv('ENCRYPTKEY')]))); echo "</pre>";
									?>
								</div>
							</div>

							<div class="col-sm-12">
								<pre class="diff-result">
								</pre>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	<?php } ?>

<?php } ?>
