implementovane ulozenie do backend presuvanie reportov v dashboad

This commit is contained in:
2025-05-04 16:32:33 +02:00
parent c82df663df
commit eab71c2c4d
4 changed files with 120 additions and 17 deletions

View File

@ -91,6 +91,11 @@ function dbCheck() {
option('version', '2');
$db_version = '2';
}
if ($db_version === '2') {
$db->query("ALTER TABLE reports ADD COLUMN ordnum INTEGER DEFAULT 0");
option('version', '3');
$db_version = '3';
}
}
function option($key, $value = null)
@ -148,7 +153,7 @@ function reportAdd($title, $description, $status = 0, $group = null, $priority =
function reportUpdate($report_id, $title, $description, $status = 0, $group = null, $priority = 0) {
global $db;
return $db->update('reports', [
$stm = $db->update('reports', [
'report_title' => $title,
'report_description' => $description,
'report_status' => $status,
@ -157,13 +162,40 @@ function reportUpdate($report_id, $title, $description, $status = 0, $group = nu
], [
'report_id' => $report_id
]);
return ($stm->rowCount() > 0);
}
function reportUpdateStatus($report_id, $status) {
global $db;
$stm = $db->update('reports', [
'report_status' => $status
], [
'report_id' => $report_id
]);
return ($stm->rowCount() > 0);
}
function reportUpdateOrdnum($ordnums) {
global $db;
$ordnums = json_decode($ordnums, true);
$suc = true;
foreach ($ordnums as $report_id => $ordnum) {
$stm = $db->update('reports', [
'ordnum' => $ordnum
], [
'report_id' => $report_id
]);
$suc &= ($stm->rowCount() > 0);
}
return $suc;
}
function reportDelete($report_id) {
global $db;
return $db->delete('reports', [
$stm = $db->delete('reports', [
'report_id' => $report_id
]);
return ($stm->rowCount() > 0);
}
function reportGet($report_id) {
@ -175,14 +207,14 @@ function reportGet($report_id) {
function reportGetAll($status = null) {
global $db;
if ($status === null) $status = array(0, 1, 2, 3);
return $db->select('reports', '*', [
'ORDER' => 'report_priority',
'ORDER' => ['report_priority', 'ordnum'],
'report_status' => $status
]);
}
function reportGetAllGrouped($status = null) {
if ($status === null) $status = array(0, 1, 2, 3);
$all = reportGetAll($status);
$groups = [];
foreach ($all as $report) {