<?php
//_________________________________________________________________________________
//Récupération du post
$reqPost = getQueries("api_posts LEFT JOIN nx_users ON api_posts.user_id = nx_users.idUser LEFT JOIN api_commands ON api_posts.command_id = api_commands.idCommand LEFT JOIN nx_entites ON api_posts.entite_id = nx_entites.idEntite",
array("idPost" => encrypt_decrypt("decrypt", rawurldecode($_GET['element']), $key_user, $iv_user)));
if(!$reqPost['count'])
redirect("index.php?page_slug=api_posts");
$post = $reqPost['result'][0];
//Récupération du flux de validation
$reqValidation = getQueries("api_validations", array('post_id' => $post['idPost']));
if($reqValidation['count']) {
//Il y a un flux de validation
$validation = $reqValidation['result'][0];
$buttonValidate = false;
//Est-il d'actualité ?
if(!$validation['validation_status']) {
//Oui, chargement de l'utilisateur qui doit valider selon l'ordre de validation
$reqUserInfo = getQueries("api_validations_as_users", array("validation_id" => $validation['idValidation'],
"validation_user_status" => 0,
"ORDER BY" => "validation_user_order LIMIT 1"));
$userInfo = $reqUserInfo['result'][0];
//Est-ce que l'utilisateur connecté doit valider ?
if($user -> getUserId() == $userInfo['user_id']) {
$buttonValidate = true;
}
}
}
//_________________________________________________________________________________
//_________________________________________________________________________________
//Validation du post
if(isset($_POST['validate-post'])) {
validatePost(array('idPost' => $post['idPost'],
"idCommand" => $post['command_id']));
//Refresh
redirect($_SERVER['REQUEST_URI']);
}
//_________________________________________________________________________________
?>
<div class="docs-content d-flex flex-column flex-column-fluid" id="kt_docs_content">
<!--begin::Container-->
<div class="container" id="kt_docs_content_container">
<!--begin::Card-->
<div class="card card-docs mb-2">
<!--begin::Card Body-->
<div class="card-body fs-6 py-15 px-10 py-lg-15 px-lg-15 text-gray-700">
<!--begin::Section-->
<div class="px-md-10 pt-md-10 pb-md-5">
<!--begin::Block-->
<div class="text-center mb-20">
<h1 class="fs-2tx fw-bolder mb-8">
<span class="d-inline-block position-relative ms-2">
<span class="d-inline-block mb-2"><?= ( ($reqValidation['count']) ? $reqValidation['result'][0]['validation_status_label'] : "Sauvegarde de la requête")?></span>
<span class="d-inline-block position-absolute h-8px bottom-0 end-0 start-0 bg-<?= ( ($reqValidation['count']) ? ( $reqValidation['result'][0]['validation_status'] == 1 ? "success" : "warning" ) : "info")?> translate rounded"></span>
</span></h1>
<div class="fw-bold fs-2 text-gray-500 mb-10"><?= $post['command_name']?></div>
</div>
<!--end::Block-->
<div class="py-5">
<div class="rounded border p-10">
<table class="table">
<thead>
<tr class="fw-bolder fs-6 text-gray-800">
<th>API</th>
<th>ID</th>
<th>Validation</th>
<th>Date</th>
<th>Utilisateur</th>
<th>Entité</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= $post['command_api_name']?></td>
<td><?= $post['idPost']?></td>
<td><?= ( ($reqValidation['count']) ? $reqValidation['result'][0]['validation_status_label'] : "Aucun flux")?></td>
<td><?= dateToFrench($post['post_date_created'], "d-m-Y H:i")?></td>
<td><?= encrypt_decrypt("decrypt", $post['user_firstname'], $key_user, $iv_user)." ". encrypt_decrypt("decrypt", $post['user_lastname'], $key_user, $iv_user)?></td>
<td><?= ( (!empty($post['entite_name']) ? $post['entite_name'] : "Non spécifié") )?></td>
</tr>
</tbody>
</table>
</div>
</div>
<!--begin::Block-->
<div class="py-5">
<div class="rounded border p-10">
<!--begin::Accordion-->
<div class="accordion accordion-icon-toggle" id="kt_accordion_2">
<!--begin::Item-->
<div class="mb-5">
<!--begin::Header-->
<div class="accordion-header py-3 d-flex" data-bs-toggle="collapse" data-bs-target="#kt_accordion_2_item_1">
<span class="accordion-icon">
<!--begin::Svg Icon | path: icons/duotune/arrows/arr064.svg-->
<span class="svg-icon svg-icon-4">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<rect opacity="0.5" x="18" y="13" width="13" height="2" rx="1" transform="rotate(-180 18 13)" fill="black" />
<path d="M15.4343 12.5657L11.25 16.75C10.8358 17.1642 10.8358 17.8358 11.25 18.25C11.6642 18.6642 12.3358 18.6642 12.75 18.25L18.2929 12.7071C18.6834 12.3166 18.6834 11.6834 18.2929 11.2929L12.75 5.75C12.3358 5.33579 11.6642 5.33579 11.25 5.75C10.8358 6.16421 10.8358 6.83579 11.25 7.25L15.4343 11.4343C15.7467 11.7467 15.7467 12.2533 15.4343 12.5657Z" fill="black" />
</svg>
</span>
<!--end::Svg Icon-->
</span>
<h3 class="fs-4 fw-bold mb-0 ms-4">Requête</h3>
</div>
<!--end::Header-->
<!--begin::Body-->
<div id="kt_accordion_2_item_1" class="fs-6 collapse show ps-10" data-bs-parent="#kt_accordion_2">
<!--begin::Highlight-->
<div class="highlight">
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">Copier</button>
<div class="highlight-code">
<?= $post['post_data']?>
</div>
</div>
<!--end::Highlight-->
</div>
<!--end::Body-->
</div>
<!--end::Item-->
<!--begin::Item-->
<div class="mb-5">
<!--begin::Header-->
<div class="accordion-header py-3 d-flex collapsed" data-bs-toggle="collapse" data-bs-target="#kt_accordion_2_item_2">
<span class="accordion-icon">
<!--begin::Svg Icon | path: icons/duotune/arrows/arr064.svg-->
<span class="svg-icon svg-icon-4">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<rect opacity="0.5" x="18" y="13" width="13" height="2" rx="1" transform="rotate(-180 18 13)" fill="black" />
<path d="M15.4343 12.5657L11.25 16.75C10.8358 17.1642 10.8358 17.8358 11.25 18.25C11.6642 18.6642 12.3358 18.6642 12.75 18.25L18.2929 12.7071C18.6834 12.3166 18.6834 11.6834 18.2929 11.2929L12.75 5.75C12.3358 5.33579 11.6642 5.33579 11.25 5.75C10.8358 6.16421 10.8358 6.83579 11.25 7.25L15.4343 11.4343C15.7467 11.7467 15.7467 12.2533 15.4343 12.5657Z" fill="black" />
</svg>
</span>
<!--end::Svg Icon-->
</span>
<h3 class="fs-4 fw-bold mb-0 ms-4">Paramètres</h3>
</div>
<!--end::Header-->
<!--begin::Body-->
<div id="kt_accordion_2_item_2" class="collapse fs-6 ps-10" data-bs-parent="#kt_accordion_2"><!--begin::Highlight-->
<div class="highlight">
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">Copier</button>
<div class="highlight-code">
<?= $post['post_parameters']?>
</div>
</div>
<!--end::Highlight-->
</div>
<!--end::Body-->
</div>
<!--end::Item-->
</div>
<!--end::Accordion-->
</div>
</div>
<!--end::Block-->
</div>
<!--end::Section-->
</div>
<!--end::Card Body-->
<?php
if($buttonValidate) {?>
<!--begin::Card footer-->
<div class="card-footer d-flex justify-content-end py-6 px-9">
<form method="post" action=""><button class="btn btn-primary px-6" type="submit" name="validate-post">Valider</button></form>
</div>
<!--end::Card footer-->
<?php
}
?>
</div>
<!--end::Card-->
</div>
<!--end::Container-->
</div>