Add work deletion functionality and enhance task popup interactions

This commit is contained in:
2025-02-14 16:03:57 +01:00
parent 65b78d49fd
commit 1a05d881d1
8 changed files with 198 additions and 80 deletions

View File

@@ -83,9 +83,9 @@
},
"class.Finances.php": {
"type": "-",
"size": 6626,
"size": 6614,
"lmtime": 1738397958562,
"modified": false
"modified": true
},
"class.Projects.php": {
"type": "-",
@@ -101,8 +101,8 @@
},
"class.Tasks.php": {
"type": "-",
"size": 12995,
"lmtime": 1734256610087,
"size": 13263,
"lmtime": 1739371100017,
"modified": false
},
"class.Users.php": {
@@ -145,8 +145,8 @@
},
"class.Tasks.php": {
"type": "-",
"size": 15730,
"lmtime": 1734274673524,
"size": 16197,
"lmtime": 1739371127349,
"modified": false
},
"class.Users.php": {
@@ -197,20 +197,20 @@
"layout": {
"style.css": {
"type": "-",
"size": 18616,
"lmtime": 1738914090080,
"size": 20440,
"lmtime": 1739372998318,
"modified": false
},
"style.css.map": {
"type": "-",
"size": 33482,
"lmtime": 1738914090080,
"size": 35516,
"lmtime": 1739372998318,
"modified": false
},
"style.scss": {
"type": "-",
"size": 23242,
"lmtime": 1738914089934,
"size": 24734,
"lmtime": 1739372998055,
"modified": false
}
},
@@ -470,8 +470,8 @@
},
"main_view.php": {
"type": "-",
"size": 22535,
"lmtime": 1738913967676,
"size": 23301,
"lmtime": 1739371502121,
"modified": false
},
"task_edit.php": {
@@ -482,8 +482,8 @@
},
"task_popup.php": {
"type": "-",
"size": 5285,
"lmtime": 1738913959844,
"size": 6028,
"lmtime": 1739372828862,
"modified": false
},
"task_single.php": {

View File

@@ -411,4 +411,13 @@ class Tasks
$result = \factory\Tasks::change_task_work_date_start( \S::get( 'task_work_id' ), \S::get( 'date_start' ) );
exit;
}
static public function work_delete() {
if ( \factory\Tasks::work_delete( \S::get( 'work_id' ) ) )
echo json_encode( [ 'status' => 'success' ] );
else
echo json_encode( [ 'status' => 'error' ] );
exit;
}
}

View File

@@ -5,6 +5,11 @@ class Tasks
{
public static $statuses = [ 0 => 'nowe', 3 => 'do rozliczenia', 5 => 'do zrobienia', 4 => 'zawieszone', 1 => 'do sprawdzenia', 6 => 'faktury', 2 => 'zamknięte' ];
static public function work_delete( $work_id ) {
global $mdb;
return $mdb -> update( 'tasks_work', [ 'deleted' => 1 ], [ 'id' => $work_id ] );
}
static public function change_task_work_date_start( $task_work_id, $date_start )
{
global $mdb;
@@ -14,7 +19,7 @@ class Tasks
static public function task_works( $task_id )
{
global $mdb;
return $mdb -> select( 'tasks_work', '*', [ 'task_id' => $task_id, 'ORDER' => [ 'date_end' => 'DESC' ] ] );
return $mdb -> select( 'tasks_work', '*', [ 'AND' => [ 'task_id' => $task_id, 'deleted' => 0 ], 'ORDER' => [ 'date_end' => 'DESC' ] ] );
}
static public function get_statuses()
@@ -231,10 +236,10 @@ class Tasks
if ( $month )
{
$results = $mdb -> select( 'tasks_work', [ 'date_start', 'date_end' ], [ 'AND' => [ 'task_id' => $task_id, 'date_end[>=]' => $month . '-01 00:00:00', 'date_end[<=]' => $month . '-' . date( 't', strtotime( $month ) ) . ' 23:59:59' ], 'ORDER' => [ 'id' => 'ASC' ] ] );
$results = $mdb -> select( 'tasks_work', [ 'date_start', 'date_end' ], [ 'AND' => [ 'deleted' => 0, 'task_id' => $task_id, 'date_end[>=]' => $month . '-01 00:00:00', 'date_end[<=]' => $month . '-' . date( 't', strtotime( $month ) ) . ' 23:59:59' ], 'ORDER' => [ 'id' => 'ASC' ] ] );
}
else
$results = $mdb -> select( 'tasks_work', [ 'date_start', 'date_end' ], [ 'AND' => [ 'task_id' => $task_id ], 'ORDER' => [ 'id' => 'ASC' ] ] );
$results = $mdb -> select( 'tasks_work', [ 'date_start', 'date_end' ], [ 'AND' => [ 'deleted' => 0, 'task_id' => $task_id ], 'ORDER' => [ 'id' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) ) foreach ( $results as $row )
{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
$cBlue: #6690F4;
$cRed: #aa0505;
$cGreen: #43833f;
$cRed: #cc563d;
$cGreen: #099885;
$cBlack: #4e5e6a;
.default-btn {
@@ -101,7 +101,7 @@ body {
transition: all 0.3s ease;
color: #FFF;
border: 0;
border-radius: 6px;
border-radius: .25rem;
cursor: pointer;
display: inline-flex;
text-decoration: none;
@@ -120,7 +120,7 @@ body {
}
&.btn-success {
background: #57b951;
background: $cGreen;
&:hover {
background: #4a9c3b;
@@ -136,7 +136,7 @@ body {
}
&.btn-danger {
background: #cc563d;
background: $cRed;
&:hover {
background: #b30000;
@@ -149,7 +149,7 @@ body {
}
.form-error {
color: #cc563d;
color: $cRed;
font-size: 13px;
}
@@ -158,11 +158,11 @@ body {
}
input[type="checkbox"] {
border: 1px solid #eee;
border: 1px solid #ced4da;
}
.form-control {
border: 1px solid #eee;
border: 1px solid #ced4da;
border-radius: 3px;
height: 35px;
width: 100%;
@@ -189,13 +189,13 @@ input[type="checkbox"] {
.box-login {
background: #FFF;
padding: 25px;
border-radius: 6px;
border-radius: .25rem;
width: 400px;
.title {
text-align: center;
padding: 10px 10px 25px;
border-bottom: 1px solid #eee;
border-bottom: 1px solid #ced4da;
font-size: 20px;
margin-bottom: 25px;
}
@@ -204,7 +204,7 @@ input[type="checkbox"] {
body>.top {
background: #FFF;
border-bottom: 1px solid #eee;
border-bottom: 1px solid #ced4da;
display: flex;
justify-content: space-between;
align-items: center;
@@ -244,7 +244,7 @@ body>.top {
padding: 0;
width: 100%;
list-style-type: none;
border: 1px solid #eee;
border: 1px solid #ced4da;
display: none;
li {
@@ -338,7 +338,7 @@ body>.top {
&.tasks_suspended {
h2 {
border-bottom: 5px solid #cc563d;
border-bottom: 5px solid $cRed;
}
}
@@ -392,7 +392,7 @@ body>.top {
position: relative;
&.notopened {
border: 2px solid #cc563d;
border: 2px solid $cRed;
}
.left {
@@ -441,7 +441,7 @@ body>.top {
}
.task_start {
background: #57b951;
background: $cGreen;
color: #FFF;
border-radius: 3px;
cursor: pointer;
@@ -460,7 +460,7 @@ body>.top {
}
.task_end {
background: #cc563d;
background: $cRed;
color: #FFF;
border-radius: 3px;
cursor: pointer;
@@ -522,7 +522,7 @@ body>.top {
select {
width: 250px;
padding: 10px;
border: 1px solid #eee;
border: 1px solid #ced4da;
border-radius: 3px;
option {
@@ -540,7 +540,7 @@ body>.top {
font-size: 12px;
.danger {
color: #cc563d;
color: $cRed;
font-weight: 600;
}
@@ -575,7 +575,7 @@ body>.top {
gap: 5px;
&.btn_add {
background: #57b951;
background: $cGreen;
&:hover {
background: #4a9c3b;
@@ -583,7 +583,7 @@ body>.top {
}
&.btn_cancel {
background: #cc563d;
background: $cRed;
&:hover {
background: #b30000;
@@ -639,7 +639,7 @@ body>.top {
transform: translate(-50%, -50%);
background: #FFF;
padding: 25px;
border-radius: 6px;
border-radius: .25rem;
max-width: 1140px;
width: 100%;
transition: all 0.3s ease;
@@ -649,7 +649,7 @@ body>.top {
max-width: 1540px;
.content {
grid-template-columns: 1fr 300px 300px;
grid-template-columns: 1fr 300px 350px;
.task_work_details {
display: block;
@@ -660,14 +660,37 @@ body>.top {
.title {
font-size: 20px;
margin-bottom: 25px;
display: flex;
align-items: center;
gap: 10px;
a {
color: #333;
text-decoration: none;
margin-right: 10px;
border: 1px solid $cGreen;
display: inline-flex;
height: 30px;
width: 30px;
border-radius: .25rem;
align-items: center;
justify-content: center;
&:hover {
text-decoration: none;
}
i {
color: $cGreen;
}
&.task-delete {
color: #cc563d;
border: 1px solid $cRed;
i {
color: $cRed;
}
}
i {
font-size: 14px;
}
}
}
@@ -712,34 +735,35 @@ body>.top {
.avatar {
height: 30px;
width: 30px;
border-radius: 50%;
border-radius: .25rem;
background: #ccc;
display: flex;
justify-content: center;
align-items: center;
color: #FFF;
font-size: 12px;
}
}
}
.comments {
border-radius: 3px;
padding: 0 15px 15px 0;
margin-bottom: 15px;
border-bottom: 1px solid #eee;
margin-bottom: 10px;
.new_comment {
margin-bottom: 15px;
margin-bottom: 10px;
textarea {
height: 75px;
margin-bottom: 10px;
border-radius: .25rem;
}
.add_comment {
background: #57b951;
background: $cGreen;
color: #FFF;
padding: 10px;
border-radius: 6px;
border-radius: .25rem;
cursor: pointer;
display: inline-flex;
align-items: center;
@@ -759,10 +783,10 @@ body>.top {
list-style-type: none;
li {
background: #eee;
background: #ced4da;
margin-bottom: 5px;
padding: 15px;
border-radius: 6px;
border-radius: .25rem;
position: relative;
.delete_comment {
@@ -770,7 +794,7 @@ body>.top {
top: 10px;
right: 10px;
cursor: pointer;
color: #cc563d;
color: $cRed;
}
.author {
@@ -796,23 +820,21 @@ body>.top {
.checklist {
border-radius: 3px;
padding: 0 15px 15px 0;
margin-bottom: 15px;
border-bottom: 1px solid #eee;
margin-bottom: 10px;
.new_element {
display: flex;
margin-bottom: 15px;
margin-bottom: 10px;
a {
display: flex;
align-items: center;
justify-content: center;
padding: 10px;
border-radius: 0 6px 6px 0;
border-radius: 0 .25rem .25rem 0;
text-decoration: none;
width: 35px;
background: #57b951;
background: $cGreen;
color: #FFF;
}
}
@@ -829,7 +851,7 @@ body>.top {
background: #FFF;
border-radius: 3px;
padding: 10px;
border: 1px solid #eee;
border: 1px solid #ced4da;
font-size: 13px;
align-items: flex-start;
@@ -837,7 +859,7 @@ body>.top {
margin-left: auto;
margin-right: 0;
cursor: pointer;
background: #cc563d;
background: $cRed;
display: flex;
height: 25px;
width: 25px;
@@ -908,7 +930,7 @@ body>.top {
}
&.task_end {
background: #cc563d;
background: $cRed;
color: #FFF;
}
@@ -924,7 +946,7 @@ body>.top {
flex-wrap: wrap;
.danger {
color: #cc563d;
color: $cRed;
font-weight: 600;
}
@@ -945,6 +967,7 @@ body>.top {
max-height: 508px;
width: 100%;
padding-right: 10px;
padding-top: 4px;
._line {
display: flex;
@@ -959,8 +982,36 @@ body>.top {
}
input {
width: calc(50% - 10px);
width: calc(50% - 25px);
text-align: center;
margin-left: 2px;
margin-right: 2px;
}
}
._work_delete {
display: inline-flex;
height: 35px;
width: 35px;
border-radius: .25rem;
align-items: center;
justify-content: center;
cursor: pointer;
border: 1px solid $cRed;
margin-left: 2px;
transition: all 0.3s ease;
&:hover {
background: $cRed;
i {
color: #FFF;
}
}
i {
transition: all 0.3s ease;
color: $cRed;
}
}
}
@@ -973,7 +1024,7 @@ body>.top {
th,
td {
border: 1px solid #eee;
border: 1px solid #ced4da;
padding: 5px;
}
@@ -989,7 +1040,7 @@ body>.top {
.projects_container {
background: #FFF;
padding: 15px;
border-radius: 6px;
border-radius: .25rem;
display: flex;
gap: 20px;
@@ -1007,7 +1058,7 @@ body>.top {
align-items: flex-start;
justify-content: center;
gap: 20px;
border-left: 1px solid #eee;
border-left: 1px solid #ced4da;
padding-left: 15px;
select {
@@ -1032,7 +1083,7 @@ body>.top {
transform: translate(-50%, -50%);
background: #FFF;
padding: 25px;
border-radius: 6px;
border-radius: .25rem;
max-width: 1140px;
width: 100%;
@@ -1049,7 +1100,7 @@ body>.top {
margin: 10px 0;
.countdown {
background: #57b951;
background: $cGreen;
color: #FFF;
padding: 10px;
}
@@ -1070,7 +1121,7 @@ body>.top {
.card {
background: #FFF;
padding: 25px;
border-radius: 6px;
border-radius: .25rem;
color: #000;
font-size: 15px;
max-width: 1280px;
@@ -1110,7 +1161,7 @@ body>.top {
color: $cBlue;
&:hover {
color: #cc563d;
color: $cRed;
}
}
}
@@ -1125,7 +1176,7 @@ body>.top {
.panel {
background: #FFF;
border-radius: 6px;
border-radius: .25rem;
padding: 15px;
h1 {

View File

@@ -165,7 +165,8 @@
});
}
function task_popup( task_id ) {
function task_popup( task_id, open_works_time = false ) {
$.ajax({
url: '/tasks/task_popup/',
type: 'POST',
@@ -175,9 +176,11 @@
success: function( response )
{
$( '.task[task_id="' + task_id + '"]' ).removeClass( 'notopened' );
$( '.task_popup' ).empty().append( response ).show();
$( '.task_popup .checklist ul li input.g-checkbox' ).on( 'change', function(e) {
var action_id = $( this ).parents( 'li' ).attr( 'action_id' );
var status = $( this ).is( ':checked' ) ? 1 : 0;
@@ -195,6 +198,9 @@
}
});
});
if ( open_works_time )
$( '.task_popup .task_details' ).addClass( 'open_works_time' );
}
});
}
@@ -762,6 +768,50 @@
checkedVals.join( "," );
reload_tasks( checkedVals );
});
})
$( 'body' ).on( 'click', '.task_work_details ._work_delete', function(e)
{
var work_id = $( this ).attr( 'work_id' );
var task_id = $( this ).attr( 'task_id' );
$.confirm({
title: 'Potwierdź',
content: 'Na pewno chcesz usunąć wybrane zadanie?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
boxWidth: '500px',
useBootstrap: false,
theme: 'material',
buttons: {
confirm: {
text: 'Usuń',
btnClass: 'btn-red',
action: function(){
$.ajax({
type: 'POST',
cache: false,
url: '/tasks/work_delete/',
data: {
work_id: work_id
},
beforeSend: function() { },
success: function( response ) {
task_popup( task_id, true );
}
});
}
},
cancel: {
text: 'Anuluj',
btnClass: 'btn-default',
action: function(){
}
}
}
});
});
})
</script>

View File

@@ -1,8 +1,8 @@
<div class="task_details" task_id="<?= $this -> task['id'];?>">
<a href="#" class="close"><i class="fa fa-times"></i></a>
<div class="title">
<a href="/tasks/task_edit/task_id=<?= $this -> task['id'];?>">
<i class="fa fa-edit"></i>
<a href="/tasks/task_edit/task_id=<?= $this -> task['id'];?>" class="_edit">
<i class="fa fa-pencil"></i>
</a>
<? if ( $this -> user['id'] == 1 ):?>
<a href="#" class="task-delete" task_id="<?= $this -> task['id'];?>">
@@ -110,6 +110,9 @@
<div class="_line">
<div class="_user"><?= \factory\Users::user_details( $task_work['user_id'] )['name'] . ' ' . \factory\Users::user_details( $task_work['user_id'] )['surname'];?></div>
<input type="text" class="form-control task_work_date_start" task_work_id="<?= $task_work['id'];?>" value="<?= $task_work['date_start'];?>"><span>-</span><input type="text" class="form-control task_work_end" task_work_id="<?= $task_work['id'];?>" value="<?= $task_work['date_end'];?>">
<a href="#" class="_work_delete" work_id="<?= $task_work['id'];?>" task_id="<?= $this -> task['id'];?>">
<i class="fa fa-trash"></i>
</a>
</div>
<? endforeach;?>
</div>