<?php
include("scripts/Master.php");
//_________________________________________________________________________________
//Récupération des données de l'application
$reqAllApplications2 = getQueries("nx_applications");
$allApplications2 = $reqAllApplications2['result'];
$reqOwnApplication = getQueries("nx_applications LEFT JOIN nx_users ON nx_applications.user_id = nx_users.idUser",
array("nx_applications.idApplication" => $idApplication));
$ownApplication = $reqOwnApplication['result'][0];
//_________________________________________________________________________________
//_________________________________________________________________________________
//Récupération d'au moins un token API valide
$token = "";
$reqTokens = getQueries("api_tokens", array("application_id" => $idApplication, "token_status" => 1));
if($reqTokens['count']) {
$token = $reqTokens['result'][0];
}
//_________________________________________________________________________________
//_________________________________________________________________________________
//Fichier d'installation
$installFilePath = master_get_installFile_path();
$installFileExist = file_exists($installFilePath);
$installFileURL = 'applications/'. $_SESSION['current_application_folder_system'] .'/install.json';
//_________________________________________________________________________________
//_________________________________________________________________________________
//Générer un fichier functions.php
if(isset($_POST['generate_function'])) {
$filename = "functions.php";
$pathFolder = "applications/" . $ownApplication['application_folder_system'] . "/";
$content = "";
//Suppression du fichier fonction actuelle (si existant)
$pathFile = $pathFolder . $filename;
$flag = unlink($pathFile);
//Création d'un fichier vierge
$file = fopen($pathFolder . $filename, 'x');
fwrite($file, $content);
fclose($file);
//Mise à jour du nom du fichier fonction
$form = array('application_file_php' => $filename,
'user_id' => $user -> getUserId());
$selector = array('idApplication' => $ownApplication['idApplication']);
$flag = dbRowUpdate2("nx_applications", $form, $selector);
//Refresh
redirect($_SERVER['REQUEST_URI']);
}
//_________________________________________________________________________________
//_________________________________________________________________________________
//Demande de publication
if(isset($_POST['request_post'])) {
$comment = htmlspecialchars($_POST['request_comment']);
//Test de publication sur le master
$response = master_create_app(array('idApplication' => $idApplication,
'note' => $comment));
var_dump($response);
//Refresh
//redirect($_SERVER['REQUEST_URI']);
}
//_________________________________________________________________________________
//_________________________________________________________________________________
//Demande de mise à jour
if(isset($_POST['request_update'])) {
$comment = htmlspecialchars($_POST['request_comment']);
//Test de publication sur le master
$response = master_create_app(array('idApplication' => $idApplication,
'note' => $comment,
'update' => true));
var_dump($response);
//Refresh
//redirect($_SERVER['REQUEST_URI']);
}
//_________________________________________________________________________________
//_________________________________________________________________________________
//Mise à jour de la version
if(isset($_POST['update-version'])) {
//Données du formulaire
$form = array('application_version' => htmlspecialchars($_POST['application_version']),
'application_date_edited' => date('Y-m-d H:i:s'),
'user_id' => $user -> getUserId());
$selector = array('idApplication' => $ownApplication['idApplication']);
$flag = dbRowUpdate2("nx_applications", $form, $selector);
if($flag) {
itsLog(array('log_table' => "nx_applications",
'log_operation' => "Mise à jour de l'application",
'log_request' => json_encode($form),
'log_response' => json_encode($flag),
'log_selector' => json_encode($selector),
'log_color' => "success",
'log_display' => 1,
'log_timeout' => 5000,
'id_log' => $ownApplication['idApplication'],
'user_id' => $user -> getUserId()
));
} else {
itsLog(array('log_table' => "nx_applications",
'log_operation' => "Erreur durant la mise à jour de l'application",
'log_request' => json_encode($form),
'log_response' => json_encode($flag),
'log_selector' => json_encode($selector),
'log_color' => "danger",
'log_display' => 1,
'log_timeout' => 5000,
'id_log' => $ownApplication['idApplication'],
'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">
<h4>Gestion de l'application</h4>
</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">Application</div>
</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_function">Générer un fichier de fonction</a>
</div>
<!--end::Menu item-->
<!--begin::Menu item-->
<div class="menu-item px-5">
<a href="#" class="menu-link text-danger px-5" data-action="delete" data-id="<?= encrypt_decrypt("encrypt", $ownApplication['idApplication'], $key_user, $iv_user)?>" data-method="custom" data-element="<?= encrypt_decrypt("encrypt", "application", $key_user, $iv_user)?>">Supprimer l'application</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=application-single">Général</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=application-marketplace">Marketplace</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=application-functions">Fonctions</a>
</li>
<!--end::Nav item-->
<!--begin::Nav item-->
<li class="nav-item mt-2 ms-auto">
<a class="nav-link text-active-primary ms-0 me-10 py-5" href="index.php?page_slug=resources">Ressources<i class="bi bi-box-arrow-up-right mx-3"></i></a>
</li>
<!--end::Nav item-->
</ul>
<!--begin::Navs-->
</div>
</div>
<!--end::Navbar-->
<div class="row">
<div class="col-6">
<!--begin::Card-->
<div class="card mb-6 mb-xl-9">
<form method="post" action="">
<!--begin::Card header-->
<div class="card-header mt-6">
<!--begin::Card title-->
<div class="card-title flex-column">
<h2 class="mb-1">Version</h2>
<div class="fs-6 fw-bold text-muted">Gestion de version</div>
</div>
<!--end::Card title-->
</div>
<!--end::Card header-->
<!--begin::Card body-->
<div class="card-body d-flex flex-column">
<!--begin::Input group-->
<div class="row mb-8">
<!--begin::Label-->
<label class="col-lg-2 col-form-label required fw-bold fs-6">Version</label>
<!--end::Label-->
<!--begin::Col-->
<div class="col-lg-7 fv-row">
<input type="text" class="form-control form-control-lg form-control-solid" value="<?= $ownApplication['application_version']?>" name="application_version"/>
<!--begin::Hint-->
<div class="form-text">Pour publier une mise à jour sur le marketplace, la version doit être différente de la version actuelle.</div>
<!--end::Hint-->
</div>
<!--end::Col-->
<!--begin::Col-->
<button class="col-lg-3" style="background-color:transparent;border: none;cursor: pointer;overflow: hidden;outline: none;" name="update-version" type="submit">
<!--begin::Svg Icon | path: assets/media/icons/duotune/arrows/arr029.svg-->
<span class="svg-icon svg-icon-muted svg-icon-2qx"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M14.5 20.7259C14.6 21.2259 14.2 21.826 13.7 21.926C13.2 22.026 12.6 22.0259 12.1 22.0259C9.5 22.0259 6.9 21.0259 5 19.1259C1.4 15.5259 1.09998 9.72592 4.29998 5.82592L5.70001 7.22595C3.30001 10.3259 3.59999 14.8259 6.39999 17.7259C8.19999 19.5259 10.8 20.426 13.4 19.926C13.9 19.826 14.4 20.2259 14.5 20.7259ZM18.4 16.8259L19.8 18.2259C22.9 14.3259 22.7 8.52593 19 4.92593C16.7 2.62593 13.5 1.62594 10.3 2.12594C9.79998 2.22594 9.4 2.72595 9.5 3.22595C9.6 3.72595 10.1 4.12594 10.6 4.02594C13.1 3.62594 15.7 4.42595 17.6 6.22595C20.5 9.22595 20.7 13.7259 18.4 16.8259Z" fill="currentColor"/>
<path opacity="0.3" d="M2 3.62592H7C7.6 3.62592 8 4.02592 8 4.62592V9.62589L2 3.62592ZM16 14.4259V19.4259C16 20.0259 16.4 20.4259 17 20.4259H22L16 14.4259Z" fill="currentColor"/>
</svg></span>
<!--end::Svg Icon-->
</button>
<!--end::Col-->
</div>
<!--end::Input group-->
</div>
<!--end::Card body-->
</form>
</div>
<!--end::Card-->
</div>
<div class="col-6">
<!--begin::Card-->
<div class="card mb-6 mb-xl-9">
<form method="post" action="">
<!--begin::Card header-->
<div class="card-header mt-6">
<!--begin::Card title-->
<div class="card-title flex-column">
<h2 class="mb-1">Marketplace</h2>
<div class="fs-6 fw-bold text-muted">Gérez la diffusion de l'application</div>
</div>
<!--end::Card title-->
<!--begin::Card toolbar-->
<div class="card-toolbar">
<a href="#" class="btn btn-sm btn-flex btn-light-primary" data-bs-toggle="modal" data-bs-target="#request_post">
<!--begin::Svg Icon | path: icons/duotune/art/art005.svg-->
<span class="svg-icon svg-icon-3">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path opacity="0.3" d="M21.4 8.35303L19.241 10.511L13.485 4.755L15.643 2.59595C16.0248 2.21423 16.5426 1.99988 17.0825 1.99988C17.6224 1.99988 18.1402 2.21423 18.522 2.59595L21.4 5.474C21.7817 5.85581 21.9962 6.37355 21.9962 6.91345C21.9962 7.45335 21.7817 7.97122 21.4 8.35303ZM3.68699 21.932L9.88699 19.865L4.13099 14.109L2.06399 20.309C1.98815 20.5354 1.97703 20.7787 2.03189 21.0111C2.08674 21.2436 2.2054 21.4561 2.37449 21.6248C2.54359 21.7934 2.75641 21.9115 2.989 21.9658C3.22158 22.0201 3.4647 22.0084 3.69099 21.932H3.68699Z" fill="black" />
<path d="M5.574 21.3L3.692 21.928C3.46591 22.0032 3.22334 22.0141 2.99144 21.9594C2.75954 21.9046 2.54744 21.7864 2.3789 21.6179C2.21036 21.4495 2.09202 21.2375 2.03711 21.0056C1.9822 20.7737 1.99289 20.5312 2.06799 20.3051L2.696 18.422L5.574 21.3ZM4.13499 14.105L9.891 19.861L19.245 10.507L13.489 4.75098L4.13499 14.105Z" fill="black" />
</svg>
</span>
<!--end::Svg Icon-->Demande de publication</a>
<a href="#" class="btn btn-sm btn-flex btn-light-primary" data-bs-toggle="modal" data-bs-target="#request_update">
<!--begin::Svg Icon | path: icons/duotune/art/art005.svg-->
<span class="svg-icon svg-icon-3">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
<path opacity="0.3" d="M21.4 8.35303L19.241 10.511L13.485 4.755L15.643 2.59595C16.0248 2.21423 16.5426 1.99988 17.0825 1.99988C17.6224 1.99988 18.1402 2.21423 18.522 2.59595L21.4 5.474C21.7817 5.85581 21.9962 6.37355 21.9962 6.91345C21.9962 7.45335 21.7817 7.97122 21.4 8.35303ZM3.68699 21.932L9.88699 19.865L4.13099 14.109L2.06399 20.309C1.98815 20.5354 1.97703 20.7787 2.03189 21.0111C2.08674 21.2436 2.2054 21.4561 2.37449 21.6248C2.54359 21.7934 2.75641 21.9115 2.989 21.9658C3.22158 22.0201 3.4647 22.0084 3.69099 21.932H3.68699Z" fill="black" />
<path d="M5.574 21.3L3.692 21.928C3.46591 22.0032 3.22334 22.0141 2.99144 21.9594C2.75954 21.9046 2.54744 21.7864 2.3789 21.6179C2.21036 21.4495 2.09202 21.2375 2.03711 21.0056C1.9822 20.7737 1.99289 20.5312 2.06799 20.3051L2.696 18.422L5.574 21.3ZM4.13499 14.105L9.891 19.861L19.245 10.507L13.489 4.75098L4.13499 14.105Z" fill="black" />
</svg>
</span>
<!--end::Svg Icon-->Publier une mise à jour</a>
</div>
<!--end::Card toolbar-->
</div>
<!--end::Card header-->
<!--begin::Card body-->
<div class="card-body d-flex flex-column">
<div class="fw-bolder fs-2">Non-publié
<span class="text-muted fs-4 fw-bold">Version <?= $ownApplication['application_version']?></span>
<div class="fs-7 fw-normal text-muted">Votre application est éligible à la publication sur le Marketplace de Nuasix.</div>
</div>
</div>
<!--end::Card body-->
</form>
</div>
<!--end::Card-->
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header mt-6">
<!--begin::Card title-->
<div class="card-title flex-column">
<h2 class="mb-1">Fichier d'installation</h2>
<div class="fs-6 fw-bold text-muted">Générer fichier d'installation</div>
</div>
<!--end::Card title-->
<!--begin::Card toolbar-->
<div class="card-toolbar">
<?php
if($installFileExist) {?>
<a href="<?= $installFileURL?>" class="btn btn-small" target="_blank" download>
<!--begin::Svg Icon | path: icons/duotune/art/art005.svg-->
<span class="svg-icon svg-icon-3">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-filetype-json" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M14 4.5V11h-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM4.151 15.29a1.176 1.176 0 0 1-.111-.449h.764a.578.578 0 0 0 .255.384c.07.049.154.087.25.114.095.028.201.041.319.041.164 0 .301-.023.413-.07a.559.559 0 0 0 .255-.193.507.507 0 0 0 .084-.29.387.387 0 0 0-.152-.326c-.101-.08-.256-.144-.463-.193l-.618-.143a1.72 1.72 0 0 1-.539-.214 1.001 1.001 0 0 1-.352-.367 1.068 1.068 0 0 1-.123-.524c0-.244.064-.457.19-.639.128-.181.304-.322.528-.422.225-.1.484-.149.777-.149.304 0 .564.05.779.152.217.102.384.239.5.41.12.17.186.359.2.566h-.75a.56.56 0 0 0-.12-.258.624.624 0 0 0-.246-.181.923.923 0 0 0-.37-.068c-.216 0-.387.05-.512.152a.472.472 0 0 0-.185.384c0 .121.048.22.144.3a.97.97 0 0 0 .404.175l.621.143c.217.05.406.12.566.211a1 1 0 0 1 .375.358c.09.148.135.335.135.56 0 .247-.063.466-.188.656a1.216 1.216 0 0 1-.539.439c-.234.105-.52.158-.858.158-.254 0-.476-.03-.665-.09a1.404 1.404 0 0 1-.478-.252 1.13 1.13 0 0 1-.29-.375Zm-3.104-.033a1.32 1.32 0 0 1-.082-.466h.764a.576.576 0 0 0 .074.27.499.499 0 0 0 .454.246c.19 0 .33-.055.422-.164.091-.11.137-.265.137-.466v-2.745h.791v2.725c0 .44-.119.774-.357 1.005-.237.23-.565.345-.985.345a1.59 1.59 0 0 1-.568-.094 1.145 1.145 0 0 1-.407-.266 1.14 1.14 0 0 1-.243-.39Zm9.091-1.585v.522c0 .256-.039.47-.117.641a.862.862 0 0 1-.322.387.877.877 0 0 1-.47.126.883.883 0 0 1-.47-.126.87.87 0 0 1-.32-.387 1.55 1.55 0 0 1-.117-.641v-.522c0-.258.039-.471.117-.641a.87.87 0 0 1 .32-.387.868.868 0 0 1 .47-.129c.177 0 .333.043.47.129a.862.862 0 0 1 .322.387c.078.17.117.383.117.641Zm.803.519v-.513c0-.377-.069-.701-.205-.973a1.46 1.46 0 0 0-.59-.63c-.253-.146-.559-.22-.916-.22-.356 0-.662.074-.92.22a1.441 1.441 0 0 0-.589.628c-.137.271-.205.596-.205.975v.513c0 .375.068.699.205.973.137.271.333.48.589.626.258.145.564.217.92.217.357 0 .663-.072.917-.217.256-.146.452-.355.589-.626.136-.274.205-.598.205-.973Zm1.29-.935v2.675h-.746v-3.999h.662l1.752 2.66h.032v-2.66h.75v4h-.656l-1.761-2.676h-.032Z"/>
</svg>
</span>
<!--end::Svg Icon-->install.json
</a>
<button class="btn btn-sm btn-flex btn-light-primary mr-5" data-api="import_install_file">Importer données</button>
<?php
}
?>
<button class="btn btn-sm btn-flex btn-light-primary" data-api="create_install_file">Générer</button>
</div>
<!--end::Card toolbar-->
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped gy-7 gs-7" id="master_auto_install_responses">
<thead>
<tr class="fw-bold fs-6 text-gray-800 border-bottom-2 border-gray-200">
<th class="min-w-100px">Etape</th>
<th class="min-w-200px">Opération</th>
<th class="min-w-150px">Note</th>
<th class="min-w-75px">Quantité</th>
<th class="min-w-100px">Résultat</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!--end::Container-->
<!--begin::Modals-->
<!--begin::Modal - Création fichier function -->
<div class="modal fade" id="generate_function" 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">
<!--begin::Modal title-->
<h2 class="fw-bolder">Générer un fichier de fonction PHP</h2>
<!--end::Modal title-->
<!--begin::Close-->
<div data-bs-dismiss="modal" class="btn btn-icon btn-sm btn-active-icon-primary">
<!--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::Balance preview-->
<div class="d-flex text-center mb-9">
<div class="w-50 border border-dashed border-gray-300 rounded mx-2 p-4">
<div class="fs-6 fw-bold mb-2 text-muted">Répertoire</div>
<div class="fs-2 fw-bolder"><?= "applications/" . $ownApplication['application_folder_system']?></div>
</div>
<div class="w-50 border border-dashed border-gray-300 rounded mx-2 p-4">
<div class="fs-6 fw-bold mb-2 text-muted">Nom du fichier
<i class="fas fa-exclamation-circle ms-1 fs-7" data-bs-toggle="tooltip" title="Le nom du fichier ne peut pas être modifié."></i></div>
<div class="fs-2 fw-bolder">functions.php</div>
</div>
</div>
<!--end::Balance preview-->
<!--begin::Form-->
<form class="form" action="" method="post">
<!--begin::Disclaimer-->
<div class="fs-7 text-muted mb-15">Si un fichier de fonction existe déjà, il sera écrasé par un nouveau fichier vierge.</div>
<!--end::Disclaimer-->
<!--begin::Actions-->
<div class="text-center">
<button type="reset" data-bs-dismiss="modal" class="btn btn-light me-3">Annuler</button>
<button type="submit" class="btn btn-primary" name="generate_function">
<span class="indicator-label">Générer</span>
<span class="indicator-progress">Patientez...
<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 - Demande publication-->
<!--end::Modals-->
</div>