<?php
//_________________________________________________________________________________
//Récupération des fonctionnalités
$fileNameResourcesApp = 'resources_app.json';
$fileNameDependenciesApp = 'dependencies_app.json';
$resourcesAppPath = dirname(__FILE__, 2) . '/'. $_SESSION['current_application_folder_system'] .'/'. $fileNameResourcesApp;
$dependenciesAppPath = dirname(__FILE__, 2) . '/'. $_SESSION['current_application_folder_system'] .'/'. $fileNameDependenciesApp;
$resourcesAll = file_exists($resourcesAppPath) ? json_decode( file_get_contents($resourcesAppPath), true ) : array('resources', 'features');
$resources = $resourcesAll['resources'];
$features = $resourcesAll['features'];
//_________________________________________________________________________________
//_________________________________________________________________________________
//Création d'une fonctionnalité
if(isset($_POST['add-feature'])) {
//Données du formulaire
$featureUniqId = uniqid();
$resourcesUniqId = array();
foreach($_POST['resources_id'] as $resourceUniqId) {
//Sauvegarde des ressources
array_push($resourcesUniqId, $resourceUniqId);
}
$form = array('feature_uniqid' => $featureUniqId,
'feature_name' => htmlspecialchars($_POST['feature_name']),
'feature_order_start' => htmlspecialchars($_POST['feature_order_start']),
'resources_uniqid' => $resourcesUniqId);
$features[$featureUniqId] = $form;
$resourcesAll['features'] = $features;
$flag = file_put_contents( $resourcesAppPath, json_encode( $resourcesAll ) );
itsLog(array('log_table' => "nx_features",
'log_operation' => "Ajout d'une fonctionnalité",
'log_request' => json_encode($form),
'log_response' => json_encode($flag),
'log_color' => "success",
'log_display' => 1,
'log_timeout' => 5000,
'id_log' => $featureUniqId,
'user_id' => $user -> getUserId()
));
//Refresh
redirect($_SERVER['REQUEST_URI']);
}
//_________________________________________________________________________________
?>
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
<!--begin::Container-->
<div class="container-xxl" id="kt_content_container">
<!--begin::Navbar-->
<div class="card mb-5 mb-xl-10">
<div class="card-body pt-9 pb-0">
<!--begin::Details-->
<div class="d-flex flex-wrap flex-sm-nowrap mb-3">
<!--begin::Info-->
<div class="flex-grow-1">
<!--begin::Title-->
<div class="d-flex justify-content-between align-items-start flex-wrap mb-2">
<!--begin::User-->
<div class="d-flex flex-column">
<!--begin::Name-->
<div class="d-flex align-items-center mb-2">
<a href="#" class="text-gray-900 text-hover-primary fs-2 fw-bolder me-1">dependencies.json</a>
<span class="btn btn-sm btn-light-success fw-bolder ms-2 fs-8 py-1 px-3"><?= $_SESSION['current_application_prefix']?></span>
</div>
<!--end::Name-->
</div>
<!--end::User-->
<!--begin::Actions-->
<div class="d-flex my-4">
<!--begin::Action menu-->
<a href="#" class="btn btn-primary ps-7" data-kt-menu-trigger="click" data-kt-menu-attach="parent" data-kt-menu-placement="bottom-end">Actions
<!--begin::Svg Icon | path: icons/duotune/arrows/arr072.svg-->
<span class="svg-icon svg-icon-2 me-0">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M11.4343 12.7344L7.25 8.55005C6.83579 8.13583 6.16421 8.13584 5.75 8.55005C5.33579 8.96426 5.33579 9.63583 5.75 10.05L11.2929 15.5929C11.6834 15.9835 12.3166 15.9835 12.7071 15.5929L18.25 10.05C18.6642 9.63584 18.6642 8.96426 18.25 8.55005C17.8358 8.13584 17.1642 8.13584 16.75 8.55005L12.5657 12.7344C12.2533 13.0468 11.7467 13.0468 11.4343 12.7344Z" fill="black" />
</svg>
</span>
<!--end::Svg Icon--></a>
<!--begin::Menu-->
<div class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-800 menu-state-bg-light-primary fw-bold py-4 w-250px fs-6" data-kt-menu="true">
<!--begin::Menu item-->
<div class="menu-item px-5">
<div class="menu-content text-muted pb-2 px-5 fs-7 text-uppercase">Fonctionnalités</div>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5">
<a href="index.php?page_slug=editor&element=<?= rawurlencode(encrypt_decrypt("encrypt", 'resources_app.json', $key_user, $iv_user))?>" class="menu-link text-dark px-5" target="_blank">Editer les ressources</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5">
<a href="index.php?page_slug=editor&element=<?= rawurlencode(encrypt_decrypt("encrypt", 'dependencies_app.json', $key_user, $iv_user))?>" class="menu-link text-dark px-5" target="_blank">Editer les dépendances</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5">
<a href="#" class="menu-link text-dark px-5" data-bs-toggle="modal" data-bs-target="#generate-dependencies">Générer les dépendances (v0 de Nuasix)</a>
</div>
<!--end::Menu item-->
</div>
<!--end::Menu-->
</div>
<!--end::Actions-->
</div>
<!--end::Title-->
</div>
<!--end::Info-->
</div>
<!--end::Details-->
<!--begin::Navs-->
<ul class="nav nav-stretch nav-line-tabs nav-line-tabs-2x border-transparent fs-5 fw-bolder">
<!--begin::Nav item-->
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5" href="index.php?page_slug=plugins">Plugins</a>
</li>
<!--end::Nav item-->
<!--begin::Nav item-->
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5" href="index.php?page_slug=resources">Ressources</a>
</li>
<!--end::Nav item-->
<!--begin::Nav item-->
<li class="nav-item mt-2">
<a class="nav-link text-active-primary ms-0 me-10 py-5 active" href="index.php?page_slug=features">Fonctionnalités</a>
</li>
<!--end::Nav item-->
</ul>
<!--begin::Navs-->
</div>
</div>
<!--end::Navbar-->
<!--begin::Card-->
<div class="card">
<!--begin::Card header-->
<div class="card-header border-0 pt-6">
<!--begin::Card toolbar-->
<div class="card-toolbar">
<!--begin::Toolbar-->
<div class="d-flex justify-content-end" data-kt-user-table-toolbar="base">
<!--begin::Add user-->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-item">
<!--begin::Svg Icon | path: icons/duotune/arrows/arr075.svg-->
<span class="svg-icon svg-icon-2">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<rect opacity="0.5" x="11.364" y="20.364" width="16" height="2" rx="1" transform="rotate(-90 11.364 20.364)" fill="black" />
<rect x="4.36396" y="11.364" width="16" height="2" rx="1" fill="black" />
</svg>
</span>
<!--end::Svg Icon-->Ajouter</button>
<!--end::Add user-->
</div>
<!--end::Toolbar-->
<!--begin::Modal - Add task-->
<div class="modal fade" id="add-item" tabindex="-1" aria-hidden="true">
<!--begin::Modal dialog-->
<div class="modal-dialog modal-dialog-centered mw-650px">
<!--begin::Modal content-->
<div class="modal-content">
<!--begin::Modal header-->
<div class="modal-header" id="kt_modal_add_user_header">
<!--begin::Modal title-->
<h2 class="fw-bolder">Ajouter une fonctionnalité</h2>
<!--end::Modal title-->
<!--begin::Close-->
<div class="btn btn-icon btn-sm btn-active-icon-primary" data-bs-dismiss="modal">
<!--begin::Svg Icon | path: icons/duotune/arrows/arr061.svg-->
<span class="svg-icon svg-icon-1">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<rect opacity="0.5" x="6" y="17.3137" width="16" height="2" rx="1" transform="rotate(-45 6 17.3137)" fill="black" />
<rect x="7.41422" y="6" width="16" height="2" rx="1" transform="rotate(45 7.41422 6)" fill="black" />
</svg>
</span>
<!--end::Svg Icon-->
</div>
<!--end::Close-->
</div>
<!--end::Modal header-->
<!--begin::Modal body-->
<div class="modal-body scroll-y mx-5 mx-xl-15 my-7">
<!--begin::Form-->
<form class="form" action="" method="post">
<!--begin::Scroll-->
<div class="d-flex flex-column scroll-y me-n7 pe-7" id="kt_modal_add_user_scroll" data-kt-scroll="true" data-kt-scroll-activate="{default: false, lg: true}" data-kt-scroll-max-height="auto" data-kt-scroll-dependencies="#kt_modal_add_user_header" data-kt-scroll-wrappers="#kt_modal_add_user_scroll" data-kt-scroll-offset="300px">
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Nom</label>
<!--end::Label-->
<!--begin::Input-->
<input type="text" name="feature_name" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Libellé" />
<!--end::Input-->
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Ressources</label>
<!--end::Label-->
<!--begin::Input-->
<select data-control="select2" data-placeholder="Choisir une ou plusieurs ressources..." class="form-select form-select-solid form-select-lg fw-bold" name="resources_id[]" multiple>
<option value="0">Choisir une ou plusieurs ressources</option>
<?php
foreach($resources as $resource) {
echo '<option value="'.$resource['resource_uniqid'].'">'.$resource['resource_name'].' ('.$resource['resource_location'].')</option>';
}
?>
</select>
<!--end::Input-->
</div>
<!--end::Input group-->
<!--begin::Input group-->
<div class="fv-row mb-7">
<!--begin::Label-->
<label class="required fw-bold fs-6 mb-2">Début du numéro d'ordre</label>
<!--end::Label-->
<!--begin::Input-->
<input type="int" name="feature_order_start" class="form-control form-control-solid mb-3 mb-lg-0" placeholder="Exemple : 100" />
<!--end::Input-->
</div>
<!--end::Input group-->
</div>
<!--end::Scroll-->
<!--begin::Actions-->
<div class="text-center pt-15">
<button type="reset" class="btn btn-light me-3" data-bs-dismiss="modal">Annuler</button>
<button type="submit" class="btn btn-primary" name="add-feature">
<span class="indicator-label">Ajout</span>
<span class="indicator-progress">2 secondes...
<span class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
</button>
</div>
<!--end::Actions-->
</form>
<!--end::Form-->
</div>
<!--end::Modal body-->
</div>
<!--end::Modal content-->
</div>
<!--end::Modal dialog-->
</div>
<!--end::Modal - Add task-->
</div>
<!--end::Card toolbar-->
</div>
<!--end::Card header-->
<!--begin::Card body-->
<div class="card-body pt-0">
<!--begin::Table-->
<table id="datatable_nuasix_default" class="table table-row-bordered gy-5">
<thead>
<tr class="fw-bold fs-6 text-muted">
<th class="min-w-125px">Nom</th>
<th class="min-w-125px">Plage</th>
<th class="text-end min-w-70px">Actions</th>
</tr>
</thead>
<tbody>
<?php
foreach($features as $feature) {
?>
<tr data-id="<?= encrypt_decrypt("encrypt", $feature['feature_uniqid'], $key_user, $iv_user)?>" data-method="custom" data-element="<?= encrypt_decrypt("encrypt", "feature", $key_user, $iv_user)?>">
<!--begin::Nom resource-->
<td>
<?= $feature['feature_name']?>
</td>
<!--end::Nom resource-->
<!--begin::Plage resource-->
<td><?= $feature['feature_order_start']?></td>
<!--end::Plage resource-->
<!--begin::Action-->
<td class="text-end">
<a href="#" class="btn btn-sm btn-icon btn-bg-light btn-active-color-primary" data-action="delete">
<!--begin::Svg Icon | path: assets/media/icons/duotune/general/gen027.svg-->
<span class="svg-icon svg-icon-muted svg-icon-2hx"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M5 9C5 8.44772 5.44772 8 6 8H18C18.5523 8 19 8.44772 19 9V18C19 19.6569 17.6569 21 16 21H8C6.34315 21 5 19.6569 5 18V9Z" fill="black"/>
<path opacity="0.5" d="M5 5C5 4.44772 5.44772 4 6 4H18C18.5523 4 19 4.44772 19 5V5C19 5.55228 18.5523 6 18 6H6C5.44772 6 5 5.55228 5 5V5Z" fill="black"/>
<path opacity="0.5" d="M9 4C9 3.44772 9.44772 3 10 3H14C14.5523 3 15 3.44772 15 4V4H9V4Z" fill="black"/>
</svg></span>
<!--end::Svg Icon-->
</a>
</td>
<!--end::Action-->
</tr>
<?php
}
?>
</tbody>
</table>
<!--end::Table-->
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</div>
<!--end::Container-->
</div>