Commit af814f6f authored by jlopez's avatar jlopez
Browse files

Fix manage section

parent 18e21607
......@@ -21,6 +21,7 @@ $id = NULL;
$version = NULL;
$manager = NULL;
$active = 0;
$vname = "";
if(isset($_POST['action'])) {
......@@ -64,19 +65,16 @@ if(isset($_POST['active'])) {
}
}
if(isset($_POST['vname'])) {
$vname = $_POST['vname'];
}
$distrib = new Distribution($id, $name, $version, $manager, $active);
$distrib = new Distribution($id, $name, $version, $manager, $active, $vname);
if($action == "create") {
$distrib->active = 1;
$distrib->escape($db);
if($db->checkTableExist($distrib->getFullName())) {
$db->create($distrib);
} else {
//TODO alert user.
}
$db->create($distrib);
} else if ($action == "update") {
$distrib->escape($db);
$db->update($distrib);
......
......@@ -72,16 +72,12 @@ if(isset($_POST['active'])) {
}
}
$section = new Section($id, $name, $visual, $active, $color, $arrangement);
$section = new Section($id, $name, $visual, $active, $color, $arrangement, "");
if($action == "create") {
$section->active = 1;
$section->escape($db);
if($db->checkTableExist($name)) {
$db->create($section);
} else {
//TODO alert user.
}
$db->create($section);
} else if ($action == "update") {
$section->escape($db);
$db->update($section);
......
......@@ -68,7 +68,6 @@ require_once "./inc/php/buildHeader.php";
<th>Arrangement</th>
<th>SubArrangement</th>
<th>Parent</th>
<th>Packages</th>
<th>Save</th>
</tr>
</thead>
......@@ -94,7 +93,6 @@ require_once "./inc/php/buildHeader.php";
echo '<td>' . '<input id="number" name="arrangement" class="form-control" type="number" value="'.$section->arrangement.'">' . '</td>';
echo '<td>' . "" . '</td>';
echo '<td>' . $section->parent . '</td>';
echo '<td>' . $db->getNumberPackage($section->name). '</td>';
echo '<td>' . '<button type="submit" class="btn btn-info btn-sm">save</button>' . '</td>';
echo '</tr></form>';
......@@ -114,7 +112,6 @@ require_once "./inc/php/buildHeader.php";
echo '<td>' . "" . '</td>';
echo '<td>' . '<input id="number" name="arrangement" class="form-control" type="number" value="'.$subsection->arrangement.'">' . '</td>';
echo '<td>' . $subsection->parent . '</td>';
echo '<td>' . $db->getNumberPackage($subsection->name). '</td>';
echo '<td>' . '<button type="submit" class="btn btn-info btn-sm">save</button>' . '</td>';
echo '</tr></form>';
}
......@@ -142,7 +139,7 @@ require_once "./inc/php/buildHeader.php";
<input type="text" class="form-control" id="nameSection" name="name" >
</div>
<div class="col-2">
<label for="visualSection">Panel ame :</label>
<label for="visualSection">Panel name :</label>
<input type="text" class="form-control" id="visualSection" name="visual" >
</div>
<div class="col-2">
......@@ -191,9 +188,9 @@ require_once "./inc/php/buildHeader.php";
<th>Name</th>
<th>Version</th>
<th>Manager</th>
<th>Packages</th>
<th>Vname</th>
<th>Save</th>
<th>Update</th>
<th>Delete</th>
</tr>
</thead>
<tbody id="TableSection">
......@@ -214,8 +211,8 @@ require_once "./inc/php/buildHeader.php";
echo '</td>';
echo '<td > <input class="form-control" type="text" name="name" value="' . $dist->name . '" readonly ></td>';
echo '<td > <input class="form-control" type="text" name="version" value="' . $dist->version . '" readonly ></td>';
echo '<td > <input class="form-control" type="text" name="name" value="' . $dist->name . '" ></td>';
echo '<td > <input class="form-control" type="text" name="version" value="' . $dist->version . '" ></td>';
echo '<td><select name="manager" class="form-control">';
foreach ($managers as $manager) {
......@@ -228,9 +225,9 @@ require_once "./inc/php/buildHeader.php";
}
echo '</select></td>';
echo '<td>' . $db->getNumberPackage($dist->getFullName()) . '</td>';
echo '<td > <input class="form-control" type="text" name="vname" value="' . $dist->vname . '" ></td>';
echo '<td>' . '<button type="submit" class="btn btn-info btn-sm">save</button>' . '</td>';
echo '<td>' . '<a href="#" class="btn btn-warning btn-sm">update</button>' . '</td>';
echo '<td>' . '<a class="btn btn-danger btn-sm" href="./action/action_distribution.php?action=delete&distribid='.$dist->ID.'" >x</a>' . '</td>';
echo '</tr> </form>';
}
......@@ -243,8 +240,6 @@ require_once "./inc/php/buildHeader.php";
<br/>
<br/>
<br/>
<br/>
<form action="./action/action_distribution.php" method="post">
<input type="text" class="form-control" style="display: none;" placeholder="action" name="action" value="create">
......@@ -257,6 +252,10 @@ require_once "./inc/php/buildHeader.php";
<label for="versionManager">Version :</label>
<input type="text" class="form-control" id="versionManager" name="version" >
</div>
<div class="col-2">
<label for="vnameManager">Version name :</label>
<input type="text" class="form-control" id="vnameManager" name="vname" >
</div>
<div class="col-2">
<label for="managerManager">Manager :</label>
<select class="form-control" id="managerManager" name="manager">
......@@ -272,17 +271,8 @@ require_once "./inc/php/buildHeader.php";
<button type="submit" class="btn btn-success">Create</button>
</div>
</div>
</form>
<br/>
<p> If you want create a distribution you must first create table in database. </p>
</div>
</div>
</div>
</div>
......
......@@ -6,7 +6,6 @@
* Time: 13:46
*/
require_once(__DIR__.'/../dao/DBquery.php');
require_once(__DIR__.'/../model/Model.php');
/**
......@@ -41,6 +40,7 @@ class Distribution extends Model
$this->manager = $manager;
$this->active = $active;
$this->vname = $vname;
$this->state = 0;
}
/**
......@@ -57,8 +57,8 @@ class Distribution extends Model
* @return string
*/
public function getInsert() {
return "INSERT INTO Distrib (name, version, manager, active, vname)
VALUES ('$this->name', '$this->version', '$this->manager', '$this->active', '$this->vname');";
return "INSERT INTO Distrib (name, version, manager, active, vname, state)
VALUES ('$this->name', '$this->version', '$this->manager', '$this->active', '$this->vname', '$this->state');";
}
/**
......@@ -68,8 +68,8 @@ class Distribution extends Model
*/
public function getUpdate() {
return "UPDATE Distrib
SET name='$this->name', version='$this->version', manager='$this->manager', active=$this->active, vname=$this->vname
WHERE ID = '$this->ID';";
SET name='$this->name', version='$this->version', manager='$this->manager', active=$this->active, vname='$this->vname', state='$this->state'
WHERE ID = $this->ID;";
}
......@@ -79,7 +79,7 @@ class Distribution extends Model
* @return string
*/
public function getDelete() {
return "DELETE FROM Distrib WHERE ID = '$this->ID';";
return "DELETE FROM Distrib WHERE ID = $this->ID;";
}
/**
......
......@@ -6,7 +6,6 @@
* Time: 14:28
*/
require_once(__DIR__.'/../dao/DBquery.php');
require_once(__DIR__.'/../model/Model.php');
/**
......@@ -50,8 +49,8 @@ class Section extends Model
* @return string
*/
public function getInsert() {
return "INSERT INTO Section (name, visual, active, color, arrangement)
VALUES ('$this->name', '$this->visual', '$this->active', '$this->color', '$this->arrangement' );";
return "INSERT INTO Section (name, visual, active, color, arrangement, state)
VALUES ('$this->name', '$this->visual', '$this->active', '$this->color', '$this->arrangement' , '$this->state');";
}
/**
......@@ -61,7 +60,7 @@ class Section extends Model
*/
public function getUpdate() {
return "UPDATE Section
SET name='$this->name', visual='$this->visual', active='$this->active', color='$this->color', arrangement='$this->arrangement'
SET name='$this->name', visual='$this->visual', active='$this->active', color='$this->color', arrangement='$this->arrangement', state='$this->state'
WHERE ID = '$this->ID';";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment