Commit a9d7056f authored by jlopez's avatar jlopez
Browse files

clean code

parent 13c2fd8f
......@@ -181,7 +181,7 @@ require_once "./inc/php/buildHeader.php";
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" class="btn btn-success">Submit</button>
<button type="submit" class="btn btn-success">Import</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
......
......@@ -73,6 +73,16 @@ class DBquery
return $results;
}
public function getActiveDistributionsFullName() {
$sql = "SELECT name,version FROM `Distrib` WHERE active = 1 ORDER BY `Distrib`.`name` ASC;";
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
array_push($results, $row['name'].":".$row['version']);
}
return $results;
}
public function getManagers() {
$sql = "SELECT * FROM `Manager`;";
$result = mysqli_query($this->dbh, $sql);
......@@ -263,6 +273,16 @@ class DBquery
return $results;
}
public function getNameSectionWhithParent($parent) {
$sql = "SELECT name FROM `Section` WHERE `Section`.`parent` = '$parent' AND active = 1 ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
$results = array();
while($row = mysqli_fetch_assoc($result)){
array_push($results,$row['name']);
}
return $results;
}
public function getAllSectionWhithParent($parent) {
$sql = "SELECT * FROM `Section` WHERE `Section`.`parent` = '$parent' ORDER BY `Section`.`arrangement` ASC;";
$result = mysqli_query($this->dbh, $sql);
......
<?php
function printPanel($name) {
function printSection($name, $db) {
if($name == "Python") {
echo '
<br/>
<div class="form-group">
<label for="selectedPython" class="font-weight-bold">Python version :</label>
<select class="custom-select" id="selectedPython">
<option value="0" selected="selected">None</option>
<option value="3.7" >3.7</option>
<option value="3.6" >3.6</option>
<option value="3.5" >3.5</option>
<option value="2.7" >2.7</option>
</select>
</div>
';
printPanel($name);
} else if($name == "R") {
$subsection = $db->getNameSectionWhithParent("R");
echo '
<div class="form-group">
<label for="selectedR" class="font-weight-bold">R version :</label>
<select class="custom-select" id="selectedR">
<option value="0" >None</option>
<option value="3.5" selected="selected">3.5</option>
</select>
</div>
<nav>
<div class="nav nav-tabs" id="nav-tab-R" role="tablist">
';
echo '<a class="nav-item nav-link active" id="nav-'.$subsection[0].'-tab-R" data-toggle="tab" href="#nav-'.$subsection[0].'-R" role="tab" aria-controls="nav-'.$subsection[0].'-R" aria-selected="false">'.$subsection[0].'</a>';
for ($i = 1; $i < sizeof($subsection); $i++) {
echo '<a class="nav-item nav-link" id="nav-'.$subsection[$i].'-tab-R" data-toggle="tab" href="#nav-'.$subsection[$i].'-R" role="tab" aria-controls="nav-'.$subsection[$i].'-R" aria-selected="false">'.$subsection[$i].'</a>';
}
echo '
</div>
</nav>
<div class="tab-content" id="nav-tabContent-R">
';
$indexSub = 0;
foreach ($subsection as $sub) {
if ($indexSub == 0) {
echo '<div class="tab-pane fade show active" id="nav-' . $sub . '-R" role="tabpanel" aria-labelledby="nav-' . $s . '-tab-R">';
} else {
echo '<div class="tab-pane fade" id="nav-' . $sub . '-R" role="tabpanel" aria-labelledby="nav-' . $s . '-tab-R">';
}
printPanel($sub);
echo '</div>';
$indexSub++;
}
echo '</div>';
} else {
printPanel($name);
}
}
function printPanel($name) {
echo '
<label for="find'.$name.'Packages">Find packages with pattern :</label>
<input type="email" class="form-control" id="find'.$name.'Packages">
<input type="email" class="form-control" id="find'.$name.'Packages">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="pattern'.$name.'Name" checked>
<label class="form-check-label" for="pattern'.$name.'Name">Pattern on name</label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="pattern'.$name.'Name" checked>
<label class="form-check-label" for="pattern'.$name.'Name">Pattern on name</label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="pattern'.$name.'Description" checked>
<label class="form-check-label" for="pattern'.$name.'Description">Pattern on description</label>
</div>
<br/>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="pattern'.$name.'Description" checked>
<label class="form-check-label" for="pattern'.$name.'Description">Pattern on description</label>
</div>
<br/>
<div class="form-group">
<label for="limit'.$name.'" class="font-check-label">Max found :</label>
<select class="custom-select" id="limit'.$name.'">
<option value="5">5</option>
<option value="10" selected="selected">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="100">200</option>
<option value="1000000000">all</option>
</select>
<label for="limit'.$name.'" class="font-check-label">Max found :</label>
<select class="custom-select" id="limit'.$name.'">
<option value="5">5</option>
<option value="10" selected="selected">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="100">200</option>
<option value="1000000000">all</option>
</select>
</div>
<br/>
<button type="button" class="btn btn-primary" onclick="showPackage(\''.$name.'\')">Search</button>
<br/><br/>
<div id="containPackages'.$name.'">
<div class="form-group">
<button type="button" class="btn btn-primary" onclick="showPackage(\''.$name.'\')">Search</button>
</div>
';
<div id="containPackages'.$name.'">
</div>
';
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: jimmy
* Date: 11/12/18
* Time: 14:30
*/
//$content = file_get_contents("container.json", FILE_USE_INCLUDE_PATH);
//$tools = json_decode($content)->containers;
session_start ();
......@@ -17,31 +7,7 @@ require_once "./inc/php/printPanel.php";
$db = new DBquery();
$distribs = [];
$data_distribs = $db->getActiveDistributions();
foreach($data_distribs as $value){
array_push($distribs,$value->name.":".$value->version);
}
$managers = $db->getManagers();
$data_section = $db->getActiveSection();
$section = array();
$section_visual = array();
$grade = $db->getGradeWithLogin($_SESSION['username']);
$labels = $db->getLabelsWithGrade($grade);
foreach ($db->getAllActiveSectionParent() as $s){
if($s->active == 1) {
array_push($section, $s->name);
array_push($section_visual, $s->visual);
}
}
$section = $db->getAllActiveSectionParent();
require_once "./inc/php/buildHeader.php";
......@@ -78,8 +44,8 @@ require_once "./inc/php/buildHeader.php";
<select class="custom-select" id="selectedOS" onchange="hide_os_rows()">
<?php
foreach ($distribs as $d){
echo ' <option value="'.$d.'">'.$d.'</option>';
foreach ($db->getActiveDistributionsFullName() as $name){
echo ' <option value="'.$name.'">'.$name.'</option>';
}
?>
......@@ -91,7 +57,7 @@ require_once "./inc/php/buildHeader.php";
<select class="custom-select" id="selectedInstaller">
<?php
foreach ($managers as $manager){
foreach ($db->getManagers() as $manager){
echo '<option value="'.$manager->value.'">'.$manager->value.'</option>';
}
?>
......@@ -188,9 +154,9 @@ require_once "./inc/php/buildHeader.php";
$index = 0;
foreach ($section as $s) {
if($index == 0) {
echo '<a class="nav-item nav-link active" id="nav-'.$s.'-tab" data-toggle="tab" href="#nav-'.$s.'" role="tab" aria-controls="nav-'.$s.'" aria-selected="false">'.$section_visual[$index].'</a>';
echo '<a class="nav-item nav-link active" id="nav-'.$s->name.'-tab" data-toggle="tab" href="#nav-'.$s->name.'" role="tab" aria-controls="nav-'.$s->name.'" aria-selected="false">'.$s->visual.'</a>';
} else {
echo '<a class="nav-item nav-link" id="nav-'.$s.'-tab" data-toggle="tab" href="#nav-'.$s.'" role="tab" aria-controls="nav-'.$s.'" aria-selected="false">'.$section_visual[$index].'</a>';
echo '<a class="nav-item nav-link" id="nav-'.$s->name.'-tab" data-toggle="tab" href="#nav-'.$s->name.'" role="tab" aria-controls="nav-'.$s->name.'" aria-selected="false">'.$s->visual.'</a>';
}
$index++;
}
......@@ -202,97 +168,11 @@ require_once "./inc/php/buildHeader.php";
$index = 0;
foreach ($section as $s) {
if($index == 0) {
echo '<div class="tab-pane fade show active" id="nav-'.$s.'" role="tabpanel" aria-labelledby="nav-'.$s.'-tab">';
echo '<div class="tab-pane fade show active" id="nav-'.$s->name.'" role="tabpanel" aria-labelledby="nav-'.$s->name.'-tab">';
}else {
echo '<div class="tab-pane fade" id="nav-'.$s.'" role="tabpanel" aria-labelledby="nav-'.$s.'-tab">';
echo '<div class="tab-pane fade" id="nav-'.$s->name.'" role="tabpanel" aria-labelledby="nav-'.$s->name.'-tab">';
}
if($s == "R") {
$subsection = array();
foreach ($db->getSectionWhithParent("R") as $value){
if($value[1]) {
array_push($subsection, $value[0]);
}
}
echo '
<div class="form-group">
<label for="selectedR" class="font-weight-bold">R version :</label>
<select class="custom-select" id="selectedR">
<option value="0" >None</option>
<option value="3.5" selected="selected">3.5</option>
</select>
</div>
<nav>
<div class="nav nav-tabs" id="nav-tab-R" role="tablist">
';
$indexSub = 0;
foreach ($subsection as $sub) {
if($indexSub == 0) {
echo '<a class="nav-item nav-link active" id="nav-'.$sub.'-tab-R" data-toggle="tab" href="#nav-'.$sub.'-R" role="tab" aria-controls="nav-'.$sub.'-R" aria-selected="false">'.$sub.'</a>';
} else {
echo '<a class="nav-item nav-link" id="nav-'.$sub.'-tab-R" data-toggle="tab" href="#nav-'.$sub.'-R" role="tab" aria-controls="nav-'.$sub.'-R" aria-selected="false">'.$sub.'</a>';
}
$indexSub++;
}
echo '
</div>
</nav>
<div class="tab-content" id="nav-tabContent-R">
';
$indexSub = 0;
foreach ($subsection as $sub) {
if ($indexSub == 0) {
echo '<div class="tab-pane fade show active" id="nav-' . $sub . '-R" role="tabpanel" aria-labelledby="nav-' . $s . '-tab-R">';
} else {
echo '<div class="tab-pane fade" id="nav-' . $sub . '-R" role="tabpanel" aria-labelledby="nav-' . $s . '-tab-R">';
}
printPanel($sub);
echo '</div>';
$indexSub++;
}
echo '</div>';
}
else if($s == "Python") {
echo '
<div class="form-group">
<label for="selectedPython" class="font-weight-bold">Python version :</label>
<select class="custom-select" id="selectedPython">
<option value="0" selected="selected">None</option>
<option value="3.7" >3.7</option>
<option value="3.6" >3.6</option>
<option value="3.5" >3.5</option>
<option value="2.7" >2.7</option>
</select>
</div>
';
printPanel($s);
}
else {
printPanel($s);
}
printSection($s->name, $db);
echo '</div>';
$index++;
}
......@@ -360,7 +240,7 @@ require_once "./inc/php/buildHeader.php";
<label for="labelsContainer">Labels :</label>
<select class="form-control" id="labelsContainer" name="labels[]" multiple>
<?php
foreach ($labels as $label){
foreach ($db->getLabelsWithGrade($db->getGradeWithLogin($_SESSION['username'])) as $label){
echo '<option value="'.$label->ID.'">'.$label->name.'</option>';
}
?>
......@@ -390,41 +270,29 @@ require_once "./inc/php/buildHeader.php";
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>
<!-- local fallbacks -->
<script src="./inc/js/jquery-3.2.1.slim.min.js"></script>
<script src="./inc/js/popper.min.js"></script>
<script src="./inc/js/bootstrap.min.js"></script>
<script src="./inc/js/jquery.dataTables.min.js"></script>
<script src="./inc/js/wicopa.js"></script>
<script>
$(function()
{
SELECTED_PACKAGES["Distribution"] = [];
<?php
foreach ($data_section as $s) {
foreach ($db->getActiveSection() as $s) {
echo 'SELECTED_PACKAGES["'.$s->name.'"] = [];';
echo '';
}
foreach ($data_section as $s) {
echo 'SELECTED_PACKAGES_COLOR["'.$s->name.'"] = "' . $s->color . '";' ;
echo '';
echo '
';
}
?>
hide_os_rows();
});
......@@ -449,7 +317,7 @@ require_once "./inc/php/buildHeader.php";
<?php
foreach($data_distribs as $value){
foreach($db->getActiveDistributions() as $value){
echo "if(selectedOSRelease.includes(\"$value->name\")) {\n";
......@@ -465,11 +333,7 @@ require_once "./inc/php/buildHeader.php";
?>
document.getElementById("selectedInstaller").disabled = true;
SELECTED_PACKAGES["Distribution"] = [];
//document.getElementById("containDistributionPackages").innerHTML = '';
gestionPackageSelected();
}
......
<?php
/**
* Created by PhpStorm.
* User: jimmy
* Date: 20/02/19
* Time: 10:10
*/
require_once "./inc/php/buildHeader.php";
require_once "./inc/php/buildHeader.php";
?>
<<<<<<< HEAD
=======
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" crossorigin="anonymous">
<!-- local fallbacks -->
<!--link rel="stylesheet" href="./inc/css/bootstrap.min.css">
<link rel="stylesheet" href="./inc/css/jquery.dataTables.min.css"-->
<link rel="stylesheet" href="./inc/css/style.css">
<title>wicopa</title>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark navbar-custom p-0">
<a class="navbar-brand" href="#">WICOPA</a>
<div class="collapse navbar-collapse justify-content-between" id="navbar">
<div class="navbar-nav justify-content-center">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo ' <a class="nav-item nav-link" href="./index.php"> Home </a>';
echo ' <a class="nav-item nav-link" href="./gestion.php"> Gestion </a>';
}
?>
</div>
<div class="navbar-nav">
<?php
if(isset($_SESSION['username']) && !empty($_SESSION['username']))
{
echo '<a class="nav-item btn btn-primary " href="./action/action_logout.php"> Logout ('.$_SESSION['username'].') </a>';
}
else
{
echo '<a class="nav-item btn btn-primary" href="./login.php"> Login </a>';
}
?>
</div>
</nav>
>>>>>>> f123b4be009adfbfca34a7889a496e1d4a6ec6ff
<div class="container-fluid">
<?php
echo '<!-- Page Content -->
......@@ -96,13 +31,7 @@ echo '<!-- Page Content -->
</div>
';
//<!-- jQuery Version 1.11.1 -->
echo '<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
';
?>
/*echo '<!-- local fallbacks -->
<script src="inc/js/jquery-latest.min.js" type="text/javascript"></script>
<script src="inc/js/bootstrap.min.js" type="text/javascript"></script>
';*/
\ No newline at end of file
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
......@@ -19,16 +19,10 @@ $db = new DBquery();
$sections_parent = $db->getAllSectionParent();
$distribs = $db->getDistributions();
$managers = $db->getManagers();
$grades = $db->getGrades();
$labels = $db->getLabels();
$users = $db->getUsers();
$max_arrangement = 0;
foreach ($sections_parent as $section) {
......@@ -165,23 +159,6 @@ require_once "./inc/php/buildHeader.php";
<label for="arrangementSection">Arrangement :</label>
<input id="arrangementSection" name="arrangement" class="form-control" type="number" value="<?php echo $max_arrangement + 1; ?>">
</div>
<!--
<div class="col-2">
<label for="subarrangementSection">SubArrangement :</label>
<input id="subarrangementSection" name="subarrangement" class="form-control" type="number" value="">
</div>-->
<!--<div class="col-2">
<label for="parentSection">Parent :</label>
<select class="form-control" id="parentSection" name="parentSection">
<?php
/*echo '<option value=""></option>';
foreach ($sections_parent as $section) {
echo '<option value="'.$section->name.'">'.$section->name.'</option>';
}*/
?>
</select>
</div>-->
<div class="col-12">
<br/>
<button type="submit" class="btn btn-success">Create</button>
......@@ -228,7 +205,7 @@ require_once "./inc/php/buildHeader.php";
<tbody id="TableSection">
<?php
foreach ($distribs as $dist) {
foreach ($db->getDistributions() as $dist) {
echo '<form action="./action/action_distribution.php" method="post"><tr>';
......@@ -434,8 +411,6 @@ require_once "./inc/php/buildHeader.php";
</tbody>
</table>
<!-- <button type="button" class="btn btn-primary" >Save change</button> -->
<br/>
<br/>
<br/>
......@@ -495,7 +470,7 @@ require_once "./inc/php/buildHeader.php";
<tbody id="TableSection">
<?php
foreach ($labels as $label) {
foreach ($db->getLabels() as $label) {
echo '<form action="./action/action_label.php" method="post"><tr>';
echo '<td>' . '
......@@ -522,8 +497,6 @@ require_once "./inc/php/buildHeader.php";
</tbody>
</table>
<!-- <button type="button" class="btn btn-primary" >Save change</button> -->
<br/>
<br/>
<br/>
......@@ -594,7 +567,7 @@ require_once "./inc/php/buildHeader.php";
foreach ($users as $user) {
foreach ($db->getUsers() as $user) {
echo '<form action="./action/action_user.php" method="post"><tr>';
echo '<td>' . '
......@@ -620,8 +593,6 @@ require_once "./inc/php/buildHeader.php";
</tbody>
</table>
<!-- <button type="button" class="btn btn-primary" >Save change</button> -->
<br/>
<br/>
<br/>
......@@ -669,21 +640,9 @@ require_once "./inc/php/buildHeader.php";
</div>
<!-- jQuery Version 1.11.1 -->
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<<<<<<< HEAD
=======
<!-- local fallbaks -->
<!--script src="inc/js/jquery-latest.min.js" type="text/javascript"></script>