|
|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
/**
|
|
|
* Classe `core`
|
|
|
*
|
|
|
@@ -23,7 +24,7 @@ class core
|
|
|
*/
|
|
|
public static function ifGet(?string $_string = NULL)
|
|
|
{
|
|
|
- if($_string == NULL){
|
|
|
+ if ($_string == NULL) {
|
|
|
return (empty($_GET)) ? FALSE : TRUE;
|
|
|
} else {
|
|
|
if (isset($_GET[$_string])) {
|
|
|
@@ -42,7 +43,7 @@ class core
|
|
|
*/
|
|
|
public static function ifPost(?string $_string = NULL)
|
|
|
{
|
|
|
- if($_string == NULL){
|
|
|
+ if ($_string == NULL) {
|
|
|
return (empty($_POST)) ? FALSE : TRUE;
|
|
|
} else {
|
|
|
if (isset($_POST[$_string])) {
|
|
|
@@ -64,7 +65,7 @@ class core
|
|
|
if ($_string == NULL) {
|
|
|
return (empty($_FILES)) ? FALSE : TRUE;
|
|
|
} else {
|
|
|
- if (isset($_FILES[$_string]) AND $_FILES[$_string]["size"] > 0) {
|
|
|
+ if (isset($_FILES[$_string]) and $_FILES[$_string]["size"] > 0) {
|
|
|
return TRUE;
|
|
|
} else {
|
|
|
return FALSE;
|
|
|
@@ -159,7 +160,7 @@ class core
|
|
|
public static function checkboxSelecter(bool $_val, $_echo = 1)
|
|
|
{
|
|
|
$tmp = ($_val == TRUE) ? "checked" : "";
|
|
|
- if($_echo == 1){
|
|
|
+ if ($_echo == 1) {
|
|
|
echo $tmp;
|
|
|
} else {
|
|
|
return $tmp;
|
|
|
@@ -315,12 +316,13 @@ class core
|
|
|
* @param float $_amount Le montant à formater.
|
|
|
* @return string Le montant formaté en euros.
|
|
|
*/
|
|
|
- public static function formatEuro($_amount) {
|
|
|
+ public static function formatEuro($_amount)
|
|
|
+ {
|
|
|
$amount = (float)$_amount;
|
|
|
$formattedAmount = number_format($amount, 2, ',', ' ');
|
|
|
return $formattedAmount . ' €';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Vérifie si une chaîne ne contient que des caractères alphabétiques.
|
|
|
@@ -411,17 +413,16 @@ class core
|
|
|
foreach ($_arbo["arbo"] as $label => $lien) {
|
|
|
if ($_arbo["current"] == $label) {
|
|
|
$return .= '<li class="breadcrumb-item active" aria-current="page"';
|
|
|
- if(isset($_arbo["refresh-json"])){
|
|
|
- $return .= 'title="Cliquez ici pour rafraichir les données Json" onclick="return confirm(\'Voulez-vous rafraichir les données Json?\')" id="json-refresh"><a href="#" style="text-decoration:none;">' .icon::getFont(["icon" => "bi bi-arrow-clockwise"]) . ' ';
|
|
|
+ if (isset($_arbo["refresh-json"])) {
|
|
|
+ $return .= 'title="Cliquez ici pour rafraichir les données Json" onclick="return confirm(\'Voulez-vous rafraichir les données Json?\')" id="json-refresh"><a href="#" style="text-decoration:none;">' . icon::getFont(["icon" => "bi bi-arrow-clockwise"]) . ' ';
|
|
|
} else {
|
|
|
$return .= '>';
|
|
|
}
|
|
|
$return .= $label;
|
|
|
- if(isset($_arbo["refresh-json"])){
|
|
|
+ if (isset($_arbo["refresh-json"])) {
|
|
|
$return .= '</a>';
|
|
|
}
|
|
|
$return .= '</li>';
|
|
|
-
|
|
|
} elseif ($lien == NULL) {
|
|
|
$return .= '<li class="breadcrumb-item">' . $label . '</li>';
|
|
|
} else {
|
|
|
@@ -432,7 +433,7 @@ class core
|
|
|
$return .= '</ol>';
|
|
|
$return .= '</nav>';
|
|
|
|
|
|
- if(isset($_arbo["refresh-json"])){
|
|
|
+ if (isset($_arbo["refresh-json"])) {
|
|
|
$return .= "<script>
|
|
|
$('#json-refresh').on('click', function() {
|
|
|
$.ajax({
|
|
|
@@ -597,11 +598,11 @@ class core
|
|
|
/**
|
|
|
* Imprime une option sélectionnée dans un formulaire.
|
|
|
*
|
|
|
- * @param string|null $_string La valeur de l'option.
|
|
|
* @param mixed $_value La valeur à comparer.
|
|
|
+ * @param string|null $_string La valeur de l'option.
|
|
|
* @return void
|
|
|
*/
|
|
|
- public static function printFormSelectOption(?string $_string = NULL, $_value)
|
|
|
+ public static function printFormSelectOption($_value, ?string $_string = NULL)
|
|
|
{
|
|
|
if ($_string != NULL and $_string == $_value) {
|
|
|
echo " selected";
|
|
|
@@ -665,12 +666,13 @@ class core
|
|
|
*
|
|
|
* @return array Les informations sur la taille de la base de données.
|
|
|
*/
|
|
|
- public static function getSizeDataBase(){
|
|
|
+ public static function getSizeDataBase()
|
|
|
+ {
|
|
|
db::query("SELECT
|
|
|
table_schema AS nameDB,
|
|
|
ROUND(SUM( data_length + index_length ) / 1024 / 1024, 2) AS moDB
|
|
|
FROM information_schema.TABLES
|
|
|
- WHERE TABLE_SCHEMA = '".DB_NAME."'");
|
|
|
+ WHERE TABLE_SCHEMA = '" . DB_NAME . "'");
|
|
|
return db::single();
|
|
|
}
|
|
|
|
|
|
@@ -683,24 +685,25 @@ class core
|
|
|
* @param string $_icon L'icône à afficher.
|
|
|
* @return void
|
|
|
*/
|
|
|
- public static function progressBarWarning(float $_num, float $_max, string $_label, string $_icon){
|
|
|
+ public static function progressBarWarning(float $_num, float $_max, string $_label, string $_icon)
|
|
|
+ {
|
|
|
$changeUnit = 1073741824;
|
|
|
$valueUnitNum = $_num >= $changeUnit ? "Go" : "Mo";
|
|
|
$valueUnitMax = $_max >= $changeUnit ? "Go" : "Mo";
|
|
|
|
|
|
$pourcentage = number_format(($_num / $_max) * 100, 2);
|
|
|
- if($pourcentage < 50){
|
|
|
+ if ($pourcentage < 50) {
|
|
|
$infos = ["color" => "bg-success"];
|
|
|
- } elseif($pourcentage < 75){
|
|
|
+ } elseif ($pourcentage < 75) {
|
|
|
$infos = ["color" => "bg-warning"];
|
|
|
} else {
|
|
|
$infos = ["color" => "bg-danger"];
|
|
|
}
|
|
|
|
|
|
echo ' <div class="mb-3" style="margin:10px 0;">
|
|
|
- <label class="form-label" style=""><i class="'.$_icon.'" style="font-size:18px; margin:4px;"></i> <span style="font-weight: bold;">'.$_label.'</span> [' . core::convertBytes($_num, "o", $valueUnitNum) . ' / ' . core::convertBytes($_max, "o", $valueUnitMax) . ']</label>
|
|
|
- <div class="progress" role="progressbar" aria-label="Success example" aria-valuenow="'.$pourcentage.'" aria-valuemin="0" aria-valuemax="100">
|
|
|
- <div class="progress-bar '.$infos["color"].'" style="width: '.$pourcentage.'%">'.$pourcentage.'%</div>
|
|
|
+ <label class="form-label" style=""><i class="' . $_icon . '" style="font-size:18px; margin:4px;"></i> <span style="font-weight: bold;">' . $_label . '</span> [' . core::convertBytes($_num, "o", $valueUnitNum) . ' / ' . core::convertBytes($_max, "o", $valueUnitMax) . ']</label>
|
|
|
+ <div class="progress" role="progressbar" aria-label="Success example" aria-valuenow="' . $pourcentage . '" aria-valuemin="0" aria-valuemax="100">
|
|
|
+ <div class="progress-bar ' . $infos["color"] . '" style="width: ' . $pourcentage . '%">' . $pourcentage . '%</div>
|
|
|
</div>
|
|
|
</div>';
|
|
|
}
|
|
|
@@ -711,7 +714,8 @@ class core
|
|
|
* @param bool $_alerte Indique si l'alerte doit être affichée.
|
|
|
* @return string|null Le code HTML du badge ou NULL.
|
|
|
*/
|
|
|
- static public function printBadgeGeneral(bool $_alerte){
|
|
|
+ static public function printBadgeGeneral(bool $_alerte)
|
|
|
+ {
|
|
|
return $_alerte == TRUE ? '<span class="position-absolute start-100 translate-middle p-1 bg-danger border border-light rounded-circle"></span>' : NULL;
|
|
|
}
|
|
|
|
|
|
@@ -724,7 +728,7 @@ class core
|
|
|
{
|
|
|
$return = [];
|
|
|
$return["DOC"] = document::badgeAlert();
|
|
|
-
|
|
|
+
|
|
|
if ($return["DOC"] != NULL) {
|
|
|
$return["ALERTE"] = TRUE;
|
|
|
} else {
|
|
|
@@ -739,16 +743,17 @@ class core
|
|
|
* @param array $_navInfos Les informations de navigation.
|
|
|
* @return void
|
|
|
*/
|
|
|
- static public function menu(array $_navInfos){
|
|
|
+ static public function menu(array $_navInfos)
|
|
|
+ {
|
|
|
$badge = self::ifbadge();
|
|
|
- echo '<a href="/" style="box-shadow: none; background-color:'. $_navInfos["color"] .';" class="navbar-brand">' . $_navInfos["title"] . '</a>' . debug::getBadges();
|
|
|
+ echo '<a href="/" style="box-shadow: none; background-color:' . $_navInfos["color"] . ';" class="navbar-brand">' . $_navInfos["title"] . '</a>' . debug::getBadges();
|
|
|
echo '<div id="navbarCollapse" class="collapse navbar-collapse p-0">';
|
|
|
echo '<ul class="nav navbar-nav ms-auto">';
|
|
|
echo '<li class="nav-item dropdown">';
|
|
|
echo '<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown">' . session::getName() . self::printBadgeGeneral($badge["ALERTE"]) . '</a>';
|
|
|
echo '<div class="dropdown-menu dropdown-menu-end">';
|
|
|
echo '<a href="/user.html" class="dropdown-item">Mon profil</a>';
|
|
|
- if((access::ifAccesss("documents") AND session::getType() == 5) OR session::getType() == 1){ // Membre du bureau ou Admin
|
|
|
+ if ((access::ifAccesss("documents") and session::getType() == 5) or session::getType() == 1) { // Membre du bureau ou Admin
|
|
|
$nb = $badge["DOC"] > 0 ? '<span class="position-absolute badge rounded-pill bg-danger" style="right:-10px; margin-top:-10px;">' . $badge["DOC"] . '</span>' : NULL;
|
|
|
echo '<a href="/documents-my-assign.html" class="dropdown-item">Vos assignations' . $nb . '</a>';
|
|
|
echo '<a href="/alertes-emails.html" class="dropdown-item">Vos règles d\'alertes</a>';
|
|
|
@@ -766,9 +771,10 @@ class core
|
|
|
*
|
|
|
* @return string L'adresse IP de l'utilisateur.
|
|
|
*/
|
|
|
- static public function getUserIP() {
|
|
|
+ static public function getUserIP()
|
|
|
+ {
|
|
|
$ip = 'Inconnue';
|
|
|
-
|
|
|
+
|
|
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
|
|
// IP partagée par un proxy
|
|
|
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
|
|
@@ -779,12 +785,12 @@ class core
|
|
|
// IP du client directement connectée au serveur
|
|
|
$ip = $_SERVER['REMOTE_ADDR'];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Nettoyage des IPs multiples dans le cas de 'HTTP_X_FORWARDED_FOR'
|
|
|
if (strpos($ip, ',') !== false) {
|
|
|
$ip = explode(',', $ip)[0];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return $ip;
|
|
|
}
|
|
|
|
|
|
@@ -794,8 +800,9 @@ class core
|
|
|
* @param array|null $_array Le tableau à aplatir (optionnel).
|
|
|
* @return array|null Le tableau aplati ou NULL.
|
|
|
*/
|
|
|
- static public function extractArrayInArray(?array $_array = NULL){
|
|
|
- if($_array != NULL){
|
|
|
+ static public function extractArrayInArray(?array $_array = NULL)
|
|
|
+ {
|
|
|
+ if ($_array != NULL) {
|
|
|
foreach ($_array as $item) {
|
|
|
foreach ($item as $key => $value) {
|
|
|
$flattened[$key] = $value;
|
|
|
@@ -804,7 +811,7 @@ class core
|
|
|
} else {
|
|
|
$flattened = NULL;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return $flattened;
|
|
|
}
|
|
|
}
|