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": { "class.Finances.php": {
"type": "-", "type": "-",
"size": 6626, "size": 6614,
"lmtime": 1738397958562, "lmtime": 1738397958562,
"modified": false "modified": true
}, },
"class.Projects.php": { "class.Projects.php": {
"type": "-", "type": "-",
@@ -101,8 +101,8 @@
}, },
"class.Tasks.php": { "class.Tasks.php": {
"type": "-", "type": "-",
"size": 12995, "size": 13263,
"lmtime": 1734256610087, "lmtime": 1739371100017,
"modified": false "modified": false
}, },
"class.Users.php": { "class.Users.php": {
@@ -145,8 +145,8 @@
}, },
"class.Tasks.php": { "class.Tasks.php": {
"type": "-", "type": "-",
"size": 15730, "size": 16197,
"lmtime": 1734274673524, "lmtime": 1739371127349,
"modified": false "modified": false
}, },
"class.Users.php": { "class.Users.php": {
@@ -197,20 +197,20 @@
"layout": { "layout": {
"style.css": { "style.css": {
"type": "-", "type": "-",
"size": 18616, "size": 20440,
"lmtime": 1738914090080, "lmtime": 1739372998318,
"modified": false "modified": false
}, },
"style.css.map": { "style.css.map": {
"type": "-", "type": "-",
"size": 33482, "size": 35516,
"lmtime": 1738914090080, "lmtime": 1739372998318,
"modified": false "modified": false
}, },
"style.scss": { "style.scss": {
"type": "-", "type": "-",
"size": 23242, "size": 24734,
"lmtime": 1738914089934, "lmtime": 1739372998055,
"modified": false "modified": false
} }
}, },
@@ -470,8 +470,8 @@
}, },
"main_view.php": { "main_view.php": {
"type": "-", "type": "-",
"size": 22535, "size": 23301,
"lmtime": 1738913967676, "lmtime": 1739371502121,
"modified": false "modified": false
}, },
"task_edit.php": { "task_edit.php": {
@@ -482,8 +482,8 @@
}, },
"task_popup.php": { "task_popup.php": {
"type": "-", "type": "-",
"size": 5285, "size": 6028,
"lmtime": 1738913959844, "lmtime": 1739372828862,
"modified": false "modified": false
}, },
"task_single.php": { "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' ) ); $result = \factory\Tasks::change_task_work_date_start( \S::get( 'task_work_id' ), \S::get( 'date_start' ) );
exit; 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' ]; 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 ) static public function change_task_work_date_start( $task_work_id, $date_start )
{ {
global $mdb; global $mdb;
@@ -14,7 +19,7 @@ class Tasks
static public function task_works( $task_id ) static public function task_works( $task_id )
{ {
global $mdb; 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() static public function get_statuses()
@@ -231,10 +236,10 @@ class Tasks
if ( $month ) 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 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 ) 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; $cBlue: #6690F4;
$cRed: #aa0505; $cRed: #cc563d;
$cGreen: #43833f; $cGreen: #099885;
$cBlack: #4e5e6a; $cBlack: #4e5e6a;
.default-btn { .default-btn {
@@ -101,7 +101,7 @@ body {
transition: all 0.3s ease; transition: all 0.3s ease;
color: #FFF; color: #FFF;
border: 0; border: 0;
border-radius: 6px; border-radius: .25rem;
cursor: pointer; cursor: pointer;
display: inline-flex; display: inline-flex;
text-decoration: none; text-decoration: none;
@@ -120,7 +120,7 @@ body {
} }
&.btn-success { &.btn-success {
background: #57b951; background: $cGreen;
&:hover { &:hover {
background: #4a9c3b; background: #4a9c3b;
@@ -136,7 +136,7 @@ body {
} }
&.btn-danger { &.btn-danger {
background: #cc563d; background: $cRed;
&:hover { &:hover {
background: #b30000; background: #b30000;
@@ -149,7 +149,7 @@ body {
} }
.form-error { .form-error {
color: #cc563d; color: $cRed;
font-size: 13px; font-size: 13px;
} }
@@ -158,11 +158,11 @@ body {
} }
input[type="checkbox"] { input[type="checkbox"] {
border: 1px solid #eee; border: 1px solid #ced4da;
} }
.form-control { .form-control {
border: 1px solid #eee; border: 1px solid #ced4da;
border-radius: 3px; border-radius: 3px;
height: 35px; height: 35px;
width: 100%; width: 100%;
@@ -189,13 +189,13 @@ input[type="checkbox"] {
.box-login { .box-login {
background: #FFF; background: #FFF;
padding: 25px; padding: 25px;
border-radius: 6px; border-radius: .25rem;
width: 400px; width: 400px;
.title { .title {
text-align: center; text-align: center;
padding: 10px 10px 25px; padding: 10px 10px 25px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #ced4da;
font-size: 20px; font-size: 20px;
margin-bottom: 25px; margin-bottom: 25px;
} }
@@ -204,7 +204,7 @@ input[type="checkbox"] {
body>.top { body>.top {
background: #FFF; background: #FFF;
border-bottom: 1px solid #eee; border-bottom: 1px solid #ced4da;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -244,7 +244,7 @@ body>.top {
padding: 0; padding: 0;
width: 100%; width: 100%;
list-style-type: none; list-style-type: none;
border: 1px solid #eee; border: 1px solid #ced4da;
display: none; display: none;
li { li {
@@ -338,7 +338,7 @@ body>.top {
&.tasks_suspended { &.tasks_suspended {
h2 { h2 {
border-bottom: 5px solid #cc563d; border-bottom: 5px solid $cRed;
} }
} }
@@ -392,7 +392,7 @@ body>.top {
position: relative; position: relative;
&.notopened { &.notopened {
border: 2px solid #cc563d; border: 2px solid $cRed;
} }
.left { .left {
@@ -441,7 +441,7 @@ body>.top {
} }
.task_start { .task_start {
background: #57b951; background: $cGreen;
color: #FFF; color: #FFF;
border-radius: 3px; border-radius: 3px;
cursor: pointer; cursor: pointer;
@@ -460,7 +460,7 @@ body>.top {
} }
.task_end { .task_end {
background: #cc563d; background: $cRed;
color: #FFF; color: #FFF;
border-radius: 3px; border-radius: 3px;
cursor: pointer; cursor: pointer;
@@ -522,7 +522,7 @@ body>.top {
select { select {
width: 250px; width: 250px;
padding: 10px; padding: 10px;
border: 1px solid #eee; border: 1px solid #ced4da;
border-radius: 3px; border-radius: 3px;
option { option {
@@ -540,7 +540,7 @@ body>.top {
font-size: 12px; font-size: 12px;
.danger { .danger {
color: #cc563d; color: $cRed;
font-weight: 600; font-weight: 600;
} }
@@ -575,7 +575,7 @@ body>.top {
gap: 5px; gap: 5px;
&.btn_add { &.btn_add {
background: #57b951; background: $cGreen;
&:hover { &:hover {
background: #4a9c3b; background: #4a9c3b;
@@ -583,7 +583,7 @@ body>.top {
} }
&.btn_cancel { &.btn_cancel {
background: #cc563d; background: $cRed;
&:hover { &:hover {
background: #b30000; background: #b30000;
@@ -639,7 +639,7 @@ body>.top {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
background: #FFF; background: #FFF;
padding: 25px; padding: 25px;
border-radius: 6px; border-radius: .25rem;
max-width: 1140px; max-width: 1140px;
width: 100%; width: 100%;
transition: all 0.3s ease; transition: all 0.3s ease;
@@ -649,7 +649,7 @@ body>.top {
max-width: 1540px; max-width: 1540px;
.content { .content {
grid-template-columns: 1fr 300px 300px; grid-template-columns: 1fr 300px 350px;
.task_work_details { .task_work_details {
display: block; display: block;
@@ -660,14 +660,37 @@ body>.top {
.title { .title {
font-size: 20px; font-size: 20px;
margin-bottom: 25px; margin-bottom: 25px;
display: flex;
align-items: center;
gap: 10px;
a { a {
color: #333; border: 1px solid $cGreen;
text-decoration: none; display: inline-flex;
margin-right: 10px; height: 30px;
width: 30px;
border-radius: .25rem;
align-items: center;
justify-content: center;
&:hover {
text-decoration: none;
}
i {
color: $cGreen;
}
&.task-delete { &.task-delete {
color: #cc563d; border: 1px solid $cRed;
i {
color: $cRed;
}
}
i {
font-size: 14px;
} }
} }
} }
@@ -712,34 +735,35 @@ body>.top {
.avatar { .avatar {
height: 30px; height: 30px;
width: 30px; width: 30px;
border-radius: 50%; border-radius: .25rem;
background: #ccc; background: #ccc;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
color: #FFF; color: #FFF;
font-size: 12px;
} }
} }
} }
.comments { .comments {
border-radius: 3px; border-radius: 3px;
padding: 0 15px 15px 0; margin-bottom: 10px;
margin-bottom: 15px;
border-bottom: 1px solid #eee;
.new_comment { .new_comment {
margin-bottom: 15px; margin-bottom: 10px;
textarea { textarea {
height: 75px; height: 75px;
margin-bottom: 10px;
border-radius: .25rem;
} }
.add_comment { .add_comment {
background: #57b951; background: $cGreen;
color: #FFF; color: #FFF;
padding: 10px; padding: 10px;
border-radius: 6px; border-radius: .25rem;
cursor: pointer; cursor: pointer;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -759,10 +783,10 @@ body>.top {
list-style-type: none; list-style-type: none;
li { li {
background: #eee; background: #ced4da;
margin-bottom: 5px; margin-bottom: 5px;
padding: 15px; padding: 15px;
border-radius: 6px; border-radius: .25rem;
position: relative; position: relative;
.delete_comment { .delete_comment {
@@ -770,7 +794,7 @@ body>.top {
top: 10px; top: 10px;
right: 10px; right: 10px;
cursor: pointer; cursor: pointer;
color: #cc563d; color: $cRed;
} }
.author { .author {
@@ -796,23 +820,21 @@ body>.top {
.checklist { .checklist {
border-radius: 3px; border-radius: 3px;
padding: 0 15px 15px 0; margin-bottom: 10px;
margin-bottom: 15px;
border-bottom: 1px solid #eee;
.new_element { .new_element {
display: flex; display: flex;
margin-bottom: 15px; margin-bottom: 10px;
a { a {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 10px; padding: 10px;
border-radius: 0 6px 6px 0; border-radius: 0 .25rem .25rem 0;
text-decoration: none; text-decoration: none;
width: 35px; width: 35px;
background: #57b951; background: $cGreen;
color: #FFF; color: #FFF;
} }
} }
@@ -829,7 +851,7 @@ body>.top {
background: #FFF; background: #FFF;
border-radius: 3px; border-radius: 3px;
padding: 10px; padding: 10px;
border: 1px solid #eee; border: 1px solid #ced4da;
font-size: 13px; font-size: 13px;
align-items: flex-start; align-items: flex-start;
@@ -837,7 +859,7 @@ body>.top {
margin-left: auto; margin-left: auto;
margin-right: 0; margin-right: 0;
cursor: pointer; cursor: pointer;
background: #cc563d; background: $cRed;
display: flex; display: flex;
height: 25px; height: 25px;
width: 25px; width: 25px;
@@ -908,7 +930,7 @@ body>.top {
} }
&.task_end { &.task_end {
background: #cc563d; background: $cRed;
color: #FFF; color: #FFF;
} }
@@ -924,7 +946,7 @@ body>.top {
flex-wrap: wrap; flex-wrap: wrap;
.danger { .danger {
color: #cc563d; color: $cRed;
font-weight: 600; font-weight: 600;
} }
@@ -945,6 +967,7 @@ body>.top {
max-height: 508px; max-height: 508px;
width: 100%; width: 100%;
padding-right: 10px; padding-right: 10px;
padding-top: 4px;
._line { ._line {
display: flex; display: flex;
@@ -959,8 +982,36 @@ body>.top {
} }
input { input {
width: calc(50% - 10px); width: calc(50% - 25px);
text-align: center; 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, th,
td { td {
border: 1px solid #eee; border: 1px solid #ced4da;
padding: 5px; padding: 5px;
} }
@@ -989,7 +1040,7 @@ body>.top {
.projects_container { .projects_container {
background: #FFF; background: #FFF;
padding: 15px; padding: 15px;
border-radius: 6px; border-radius: .25rem;
display: flex; display: flex;
gap: 20px; gap: 20px;
@@ -1007,7 +1058,7 @@ body>.top {
align-items: flex-start; align-items: flex-start;
justify-content: center; justify-content: center;
gap: 20px; gap: 20px;
border-left: 1px solid #eee; border-left: 1px solid #ced4da;
padding-left: 15px; padding-left: 15px;
select { select {
@@ -1032,7 +1083,7 @@ body>.top {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
background: #FFF; background: #FFF;
padding: 25px; padding: 25px;
border-radius: 6px; border-radius: .25rem;
max-width: 1140px; max-width: 1140px;
width: 100%; width: 100%;
@@ -1049,7 +1100,7 @@ body>.top {
margin: 10px 0; margin: 10px 0;
.countdown { .countdown {
background: #57b951; background: $cGreen;
color: #FFF; color: #FFF;
padding: 10px; padding: 10px;
} }
@@ -1070,7 +1121,7 @@ body>.top {
.card { .card {
background: #FFF; background: #FFF;
padding: 25px; padding: 25px;
border-radius: 6px; border-radius: .25rem;
color: #000; color: #000;
font-size: 15px; font-size: 15px;
max-width: 1280px; max-width: 1280px;
@@ -1110,7 +1161,7 @@ body>.top {
color: $cBlue; color: $cBlue;
&:hover { &:hover {
color: #cc563d; color: $cRed;
} }
} }
} }
@@ -1125,7 +1176,7 @@ body>.top {
.panel { .panel {
background: #FFF; background: #FFF;
border-radius: 6px; border-radius: .25rem;
padding: 15px; padding: 15px;
h1 { h1 {

View File

@@ -165,7 +165,8 @@
}); });
} }
function task_popup( task_id ) { function task_popup( task_id, open_works_time = false ) {
$.ajax({ $.ajax({
url: '/tasks/task_popup/', url: '/tasks/task_popup/',
type: 'POST', type: 'POST',
@@ -175,9 +176,11 @@
success: function( response ) success: function( response )
{ {
$( '.task[task_id="' + task_id + '"]' ).removeClass( 'notopened' ); $( '.task[task_id="' + task_id + '"]' ).removeClass( 'notopened' );
$( '.task_popup' ).empty().append( response ).show(); $( '.task_popup' ).empty().append( response ).show();
$( '.task_popup .checklist ul li input.g-checkbox' ).on( 'change', function(e) { $( '.task_popup .checklist ul li input.g-checkbox' ).on( 'change', function(e) {
var action_id = $( this ).parents( 'li' ).attr( 'action_id' ); var action_id = $( this ).parents( 'li' ).attr( 'action_id' );
var status = $( this ).is( ':checked' ) ? 1 : 0; 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( "," ); checkedVals.join( "," );
reload_tasks( checkedVals ); 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> </script>

View File

@@ -1,8 +1,8 @@
<div class="task_details" task_id="<?= $this -> task['id'];?>"> <div class="task_details" task_id="<?= $this -> task['id'];?>">
<a href="#" class="close"><i class="fa fa-times"></i></a> <a href="#" class="close"><i class="fa fa-times"></i></a>
<div class="title"> <div class="title">
<a href="/tasks/task_edit/task_id=<?= $this -> task['id'];?>"> <a href="/tasks/task_edit/task_id=<?= $this -> task['id'];?>" class="_edit">
<i class="fa fa-edit"></i> <i class="fa fa-pencil"></i>
</a> </a>
<? if ( $this -> user['id'] == 1 ):?> <? if ( $this -> user['id'] == 1 ):?>
<a href="#" class="task-delete" task_id="<?= $this -> task['id'];?>"> <a href="#" class="task-delete" task_id="<?= $this -> task['id'];?>">
@@ -110,6 +110,9 @@
<div class="_line"> <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> <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'];?>"> <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> </div>
<? endforeach;?> <? endforeach;?>
</div> </div>