fixing some bugs in uploader
This commit is contained in:
@@ -6,5 +6,9 @@
|
|||||||
}
|
}
|
||||||
$username=$_SESSION["username"];
|
$username=$_SESSION["username"];
|
||||||
$path = "/var/www/html/user_files/$username/";
|
$path = "/var/www/html/user_files/$username/";
|
||||||
|
$public_path = "/var/www/html/user_files/public/";
|
||||||
|
if($_GET["pc"]=="1")
|
||||||
|
$_SESSION["current_file"]=$public_path.$_GET["file"];
|
||||||
|
else
|
||||||
$_SESSION["current_file"]=$path.$_GET["file"];
|
$_SESSION["current_file"]=$path.$_GET["file"];
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ session_start();
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$username=$_SESSION["username"];
|
$username=$_SESSION["username"];
|
||||||
|
if($_GET["pc"]=="1")
|
||||||
|
echo(get_base64_preview("/var/www/html/user_files/public/".$_GET["file"]));
|
||||||
|
else
|
||||||
echo(get_base64_preview("/var/www/html/user_files/$username/".$_GET["file"]));
|
echo(get_base64_preview("/var/www/html/user_files/$username/".$_GET["file"]));
|
||||||
|
|
||||||
function get_base64_preview($filename){
|
function get_base64_preview($filename){
|
||||||
$base64="";
|
$base64="";
|
||||||
$file=fopen($filename,"r");
|
$file=fopen($filename,"r");
|
||||||
|
|||||||
@@ -469,43 +469,68 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
<center><h3>Warteschlange</h3></center>
|
<center><h3>Warteschlange</h3></center>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$userid = $_SESSION["id"];
|
$userid = $_SESSION["id"];
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
$filepath="";
|
$sql = "SELECT COUNT(*) FROM queue";
|
||||||
$sql="select count(*) from queue";
|
|
||||||
$stmt = mysqli_prepare($link, $sql);
|
$stmt = mysqli_prepare($link, $sql);
|
||||||
mysqli_stmt_execute($stmt);
|
mysqli_stmt_execute($stmt);
|
||||||
mysqli_stmt_store_result($stmt);
|
|
||||||
mysqli_stmt_bind_result($stmt, $cnt);
|
mysqli_stmt_bind_result($stmt, $cnt);
|
||||||
mysqli_stmt_fetch($stmt);
|
mysqli_stmt_fetch($stmt);
|
||||||
//echo($cnt);
|
mysqli_stmt_close($stmt);
|
||||||
echo("<div class='container'><div class='row'><div class='col'><div class='overflow-auto'><table class='table'><thead><tr><th>Datei</th><th>Drucken auf Drucker</th><th>aus der Warteschlange entfernen</th></tr></thead><tbody>");
|
|
||||||
$last_id = 0;
|
$last_id = 0;
|
||||||
$form_userid=0;
|
|
||||||
$print_on=0;
|
echo "<div class='container'><div class='row'><div class='col'><div class='overflow-auto'>
|
||||||
while($cnt!=0)
|
<table class='table'>
|
||||||
{
|
<thead>
|
||||||
$sql="select id,filepath,from_userid,print_on from queue where id>$last_id order by id";
|
<tr>
|
||||||
$cancel=0;
|
<th>Datei</th>
|
||||||
|
<th>Drucken auf Drucker</th>
|
||||||
|
<th>Auftrag von</th>
|
||||||
|
<th>Aus der Warteschlange entfernen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>";
|
||||||
|
|
||||||
|
while ($cnt > 0) {
|
||||||
|
$sql = "SELECT q.id, q.filepath, q.from_userid, q.print_on, u.username
|
||||||
|
FROM queue q
|
||||||
|
JOIN users u ON q.from_userid = u.id
|
||||||
|
WHERE q.id > ?
|
||||||
|
ORDER BY q.id LIMIT 1";
|
||||||
|
|
||||||
$stmt = mysqli_prepare($link, $sql);
|
$stmt = mysqli_prepare($link, $sql);
|
||||||
echo mysqli_error($link);
|
mysqli_stmt_bind_param($stmt, "i", $last_id);
|
||||||
mysqli_stmt_execute($stmt);
|
mysqli_stmt_execute($stmt);
|
||||||
mysqli_stmt_store_result($stmt);
|
mysqli_stmt_bind_result($stmt, $queue_id, $filepath, $from_userid, $print_on, $from_user);
|
||||||
mysqli_stmt_bind_result($stmt, $queue_id,$filepath,$from_userid,$print_on);
|
|
||||||
mysqli_stmt_fetch($stmt);
|
mysqli_stmt_fetch($stmt);
|
||||||
|
mysqli_stmt_close($stmt);
|
||||||
|
|
||||||
|
if (!$queue_id) break; // Exit if no more entries
|
||||||
|
|
||||||
$filepath = basename($filepath);
|
$filepath = basename($filepath);
|
||||||
$last_id = $queue_id;
|
$last_id = $queue_id;
|
||||||
echo("<tr><td>$filepath</td>");
|
|
||||||
if($print_on==-1)
|
echo "<tr>
|
||||||
echo("<td>Erster verfügbarer Drucker</td>");
|
<td>{$filepath}</td>
|
||||||
else
|
<td>" . ($print_on == -1 ? "Erster verfügbarer Drucker" : htmlspecialchars($print_on)) . "</td>
|
||||||
echo("<td>$print_on</td>");
|
<td>{$from_user}</td>";
|
||||||
if($_SESSION["role"][3]==="1" or $_SESSION["id"]==$from_userid)
|
|
||||||
echo("<td><form method='POST' action='?remove_queue=$queue_id&rid=".$_SESSION["rid"]."'><button type='submit' value='remove' name='remove' class='btn btn-danger'>Löschen</button></form></td></tr>");
|
if ($_SESSION["role"][3] === "1" || $_SESSION["id"] == $from_userid) {
|
||||||
|
echo "<td>
|
||||||
|
<form method='POST' action='?remove_queue={$queue_id}&rid={$_SESSION["rid"]}'>
|
||||||
|
<button type='submit' name='remove' class='btn btn-danger'>Löschen</button>
|
||||||
|
</form>
|
||||||
|
</td>";
|
||||||
|
}
|
||||||
|
echo "</tr>";
|
||||||
|
|
||||||
$cnt--;
|
$cnt--;
|
||||||
}
|
}
|
||||||
echo("</tbody></table></div></div></div></div>");
|
|
||||||
|
echo "</tbody></table></div></div></div></div>";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<?php
|
<?php
|
||||||
if(isset($_GET["cloudprint"])){
|
if(isset($_GET["cloudprint"])){
|
||||||
echo("<script>let cloudprint=1;</script>");
|
echo("<script>let cloudprint=1;</script>");
|
||||||
echo '<script>fetch("/api/uploader/image_preview.php?file='.$_GET["cloudprint"].'").then(res => res.text()).then(data => document.getElementById("preview").src = "data:image/png;base64," + data).catch(err => console.error("Error:", err));</script>';
|
echo '<script>fetch("/api/uploader/image_preview.php?file='.$_GET["cloudprint"].'&pc='.isset($_GET["pc"]).'").then(res => res.text()).then(data => document.getElementById("preview").src = "data:image/png;base64," + data).catch(err => console.error("Error:", err));</script>';
|
||||||
}else{
|
}else{
|
||||||
echo("<script>let cloudprint=0;</script>");
|
echo("<script>let cloudprint=0;</script>");
|
||||||
}
|
}
|
||||||
@@ -96,6 +96,9 @@
|
|||||||
if(item.error_status==0){
|
if(item.error_status==0){
|
||||||
if(item.free==1){
|
if(item.free==1){
|
||||||
option.textContent = `Drucker ${item.id} - ${item.color}`;
|
option.textContent = `Drucker ${item.id} - ${item.color}`;
|
||||||
|
if(preselectId==null){
|
||||||
|
option.selected="true";
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
option.textContent = `Drucker ${item.id} - ${item.color} - Warteschlange`;
|
option.textContent = `Drucker ${item.id} - ${item.color} - Warteschlange`;
|
||||||
}
|
}
|
||||||
@@ -108,6 +111,44 @@
|
|||||||
})
|
})
|
||||||
.catch(error => console.error("Error fetching data:", error));
|
.catch(error => console.error("Error fetching data:", error));
|
||||||
});
|
});
|
||||||
|
async function reload_printer_selection(){
|
||||||
|
document.getElementById("selectOption").innerHTML = "";
|
||||||
|
const selectElement = document.getElementById("selectOption");
|
||||||
|
const apiUrl = "/api/uploader/fetch_printers.php"; // Replace with your actual API URL
|
||||||
|
function getUrlParam(name) {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
return urlParams.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const preselectId = getUrlParam("preselect"); // Get "preselect" value from URL
|
||||||
|
const option_1 = document.createElement("option");
|
||||||
|
option_1.value = "not_set";
|
||||||
|
option_1.textContent = "Bitte wähle einen Drucker";
|
||||||
|
selectElement.appendChild(option_1);
|
||||||
|
fetch(apiUrl)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
data.forEach(item => {
|
||||||
|
const option = document.createElement("option");
|
||||||
|
option.value = item.id;
|
||||||
|
if(item.error_status==0){
|
||||||
|
if(item.free==1){
|
||||||
|
option.textContent = `Drucker ${item.id} - ${item.color}`;
|
||||||
|
if(preselectId==null){
|
||||||
|
option.selected="true";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
option.textContent = `Drucker ${item.id} - ${item.color} - Warteschlange`;
|
||||||
|
}
|
||||||
|
if (item.id == preselectId) {
|
||||||
|
option.selected = true;
|
||||||
|
}
|
||||||
|
selectElement.appendChild(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => console.error("Error fetching data:", error));
|
||||||
|
}
|
||||||
async function start_upload(use_checks){
|
async function start_upload(use_checks){
|
||||||
document.getElementById("close_progress_modal2").click();
|
document.getElementById("close_progress_modal2").click();
|
||||||
//main function handles the steps from user pressing upload button via checking params to starting job via api
|
//main function handles the steps from user pressing upload button via checking params to starting job via api
|
||||||
@@ -142,7 +183,7 @@
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//just tell the server what the file is.
|
//just tell the server what the file is.
|
||||||
await fetch("/api/uploader/cloudprint.php?file=<?php echo($_GET['cloudprint']); ?>");
|
await fetch("/api/uploader/cloudprint.php?file=<?php echo($_GET['cloudprint']); ?>&pc=<?php echo(isset($_GET['pc'])); ?>");
|
||||||
}
|
}
|
||||||
global_error="";
|
global_error="";
|
||||||
//check if there is a reservation ongoing during this print
|
//check if there is a reservation ongoing during this print
|
||||||
@@ -208,6 +249,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
show_close_button();
|
show_close_button();
|
||||||
|
reload_printer_selection();
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_circumvent_link(progressContent) {
|
function add_circumvent_link(progressContent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user