move prio upon delete
This commit is contained in:
parent
3581d8ec80
commit
daabc3d8a0
|
@ -144,6 +144,25 @@ if (isset($_SESSION['username'])){
|
||||||
$sql="SELECT id,prio FROM vms WHERE vmname='$vmname' AND id='$vmid'";
|
$sql="SELECT id,prio FROM vms WHERE vmname='$vmname' AND id='$vmid'";
|
||||||
$res = $db_handle->query($sql);
|
$res = $db_handle->query($sql);
|
||||||
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
|
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
|
||||||
|
$prio = $row['prio'];
|
||||||
|
$nextprio = $prio + 1;
|
||||||
|
$lastprio = "no";
|
||||||
|
while ($lastprio == "no"){
|
||||||
|
$sqln="SELECT id FROM vms WHERE prio='$nextprio'";
|
||||||
|
$nid = $db_handle->query($sqln)->fetchArray(SQLITE3_ASSOC)['id'];
|
||||||
|
if($nid == ""){
|
||||||
|
$lastprio = "yes";
|
||||||
|
} else {
|
||||||
|
$sqlu="UPDATE vms SET prio='$prio' WHERE id='$nid'";
|
||||||
|
if (!$db_handle->query($sqlu)){
|
||||||
|
echo "SQL $sqlu failed!";
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$nextprio = $nextprio + 1;
|
||||||
|
$prio = $prio + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$sqld="DELETE FROM vms WHERE id='$vmid'";
|
$sqld="DELETE FROM vms WHERE id='$vmid'";
|
||||||
if ($db_handle->query($sqld)){
|
if ($db_handle->query($sqld)){
|
||||||
echo "VM $vmname deleted!";
|
echo "VM $vmname deleted!";
|
||||||
|
@ -313,12 +332,9 @@ if (isset($_SESSION['username'])){
|
||||||
$sqlv .= "'$rvalue',";
|
$sqlv .= "'$rvalue',";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// $sqlc = rtrim($sqlc, ',');
|
|
||||||
$sqlc.=" 'prio')";
|
$sqlc.=" 'prio')";
|
||||||
// $sqlv = rtrim($sqlv, ',');
|
|
||||||
$sqlv.=" '$prio')";
|
$sqlv.=" '$prio')";
|
||||||
$sql = "$sqls$sqlc$sqlv";
|
$sql = "$sqls$sqlc$sqlv";
|
||||||
//echo $sql;
|
|
||||||
$res = $db_handle->exec($sql);
|
$res = $db_handle->exec($sql);
|
||||||
echo "success";
|
echo "success";
|
||||||
exit;
|
exit;
|
||||||
|
@ -417,7 +433,6 @@ if (isset($_SESSION['username'])){
|
||||||
$sql="SELECT * FROM users";
|
$sql="SELECT * FROM users";
|
||||||
$res = $db_handle->query($sql);
|
$res = $db_handle->query($sql);
|
||||||
echo "</br>";
|
echo "</br>";
|
||||||
//echo "<div class=row><div class=col>Username</div><div class=col>Is Admin</div><div class=col>New Password</div></div>";
|
|
||||||
if ($_SESSION['username']!="inituser"){
|
if ($_SESSION['username']!="inituser"){
|
||||||
echo "<h2>Existing users</h2>";
|
echo "<h2>Existing users</h2>";
|
||||||
}
|
}
|
||||||
|
@ -452,7 +467,6 @@ if (isset($_SESSION['username'])){
|
||||||
$sql="SELECT * FROM servers";
|
$sql="SELECT * FROM servers";
|
||||||
$res = $db_handle->query($sql);
|
$res = $db_handle->query($sql);
|
||||||
echo "</br>";
|
echo "</br>";
|
||||||
//echo "<div class=row><div class=col>Username</div><div class=col>Is Admin</div><div class=col>New Password</div></div>";
|
|
||||||
echo "<h2>Existing servers</h2>";
|
echo "<h2>Existing servers</h2>";
|
||||||
echo "<div class=row><div class=col>hostname</div><div class=col>connectstring</div><div class=col>VM directory</div><div class=col>ISO directory</div><div class=col></div></div>";
|
echo "<div class=row><div class=col>hostname</div><div class=col>connectstring</div><div class=col>VM directory</div><div class=col>ISO directory</div><div class=col></div></div>";
|
||||||
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
|
while ($row = $res->fetchArray(SQLITE3_ASSOC)){
|
||||||
|
@ -550,7 +564,7 @@ if (isset($_SESSION['username'])){
|
||||||
}
|
}
|
||||||
$server = $e['server'];
|
$server = $e['server'];
|
||||||
for ($col=0; $col <count($arrColnames); $col++){
|
for ($col=0; $col <count($arrColnames); $col++){
|
||||||
if ($arrColnames[$col]!="id"){
|
if (($arrColnames[$col]!="id")&&($arrColnames[$col]!="prio")){
|
||||||
if (isset($e[$arrColnames[$col]])){
|
if (isset($e[$arrColnames[$col]])){
|
||||||
$val = $e[$arrColnames[$col]];
|
$val = $e[$arrColnames[$col]];
|
||||||
} else {
|
} else {
|
||||||
|
@ -583,7 +597,6 @@ if (isset($_SESSION['username'])){
|
||||||
echo "<div class=dropdown-menu aria-labelledby=archbutton>";
|
echo "<div class=dropdown-menu aria-labelledby=archbutton>";
|
||||||
echo "<a class=dropdown-item href=\"javascript:dropdown('archbutton','x86_64')\">x86_64</a>";
|
echo "<a class=dropdown-item href=\"javascript:dropdown('archbutton','x86_64')\">x86_64</a>";
|
||||||
echo "</div></div></div></div><input type=hidden id=archbuttonh name=arch value=x86_64>";
|
echo "</div></div></div></div><input type=hidden id=archbuttonh name=arch value=x86_64>";
|
||||||
// echo "$arrColnames[$col] <select name=arch><option value=qemu-system-x86_64>x86_64</option></select></br>";
|
|
||||||
} elseif (preg_match('/format/', $arrColnames[$col])){
|
} elseif (preg_match('/format/', $arrColnames[$col])){
|
||||||
formatbuttons($arrColnames[$col], $val);
|
formatbuttons($arrColnames[$col], $val);
|
||||||
} elseif ($arrColnames[$col] == "autostart"){
|
} elseif ($arrColnames[$col] == "autostart"){
|
||||||
|
@ -593,7 +606,6 @@ if (isset($_SESSION['username'])){
|
||||||
}
|
}
|
||||||
echo "<div class=row><div class=col-md-1 style=text-align:right>autostart</div><div class=col-md-2><input data-onstyle=\"success\" data-offstyle=danger name=autostart id=\"autostart\" type=\"checkbox\" data-toggle=\"toggle\" data-on=\"boot with host\" data-off=\"no autostart\" $checked></div></div>";
|
echo "<div class=row><div class=col-md-1 style=text-align:right>autostart</div><div class=col-md-2><input data-onstyle=\"success\" data-offstyle=danger name=autostart id=\"autostart\" type=\"checkbox\" data-toggle=\"toggle\" data-on=\"boot with host\" data-off=\"no autostart\" $checked></div></div>";
|
||||||
} elseif ($arrColnames[$col] == "cdrom"){
|
} elseif ($arrColnames[$col] == "cdrom"){
|
||||||
//echo "<div id=cdromdiv>";
|
|
||||||
serverdepropdown($server, $val, "cdrom");
|
serverdepropdown($server, $val, "cdrom");
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
} elseif (preg_match('/tapdev/', $arrColnames[$col])) {
|
} elseif (preg_match('/tapdev/', $arrColnames[$col])) {
|
||||||
|
@ -651,9 +663,7 @@ if (isset($_SESSION['username'])){
|
||||||
$buttonc = "btn-warning";
|
$buttonc = "btn-warning";
|
||||||
}
|
}
|
||||||
$vncport = sprintf("%02d", $row['vncport']);
|
$vncport = sprintf("%02d", $row['vncport']);
|
||||||
echo "<div >";
|
echo "<div><button type=button onclick=\"arrow('up', '$row[id]');\" class=\"btn btn-default\" aria-label=\"Left Align\"><span><img src=arrowup.png width=6px ></span></button><br/>";
|
||||||
//style=\"margin:5px;padding:5px;border:solid 1px;max-width:295px;\">
|
|
||||||
echo "<button type=button onclick=\"arrow('up', '$row[id]');\" class=\"btn btn-default\" aria-label=\"Left Align\"><span><img src=arrowup.png width=6px ></span></button><br/>";
|
|
||||||
echo "<button type=button onclick=\"arrow('down', '$row[id]');\" class=\"btn btn-default\" aria-label=\"Left Align\"><span><img src=arrowdown.png width=6px></span></button></div>";
|
echo "<button type=button onclick=\"arrow('down', '$row[id]');\" class=\"btn btn-default\" aria-label=\"Left Align\"><span><img src=arrowdown.png width=6px></span></button></div>";
|
||||||
echo "<div class=col-sm><b>$row[vmname]</b></div><div class=col-sm>$row[server]</div><div class=col-sm>$row[cpus] CPUs, $row[memory] MB RAM</div><div class=col-sm>$row[drive1]</div>";
|
echo "<div class=col-sm><b>$row[vmname]</b></div><div class=col-sm>$row[server]</div><div class=col-sm>$row[cpus] CPUs, $row[memory] MB RAM</div><div class=col-sm>$row[drive1]</div>";
|
||||||
echo "<div class=col-sm>VNC port: 59$vncport</div><div class-col-sm><a class=\"btn btn-primary\" href=# onclick=\"post('?', {edit: '$row[id]'});\">edit</a> ";
|
echo "<div class=col-sm>VNC port: 59$vncport</div><div class-col-sm><a class=\"btn btn-primary\" href=# onclick=\"post('?', {edit: '$row[id]'});\">edit</a> ";
|
||||||
|
|
Loading…
Reference in New Issue