mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Added resume option to tasks
This commit is contained in:
parent
88865d44fc
commit
97adc27ba1
@ -163,7 +163,8 @@ class TaskController extends BaseController
|
||||
'clientPublicId' => $task->client ? $task->client->public_id : 0,
|
||||
'method' => 'PUT',
|
||||
'url' => 'tasks/'.$publicId,
|
||||
'title' => trans('texts.edit_task')
|
||||
'title' => trans('texts.edit_task'),
|
||||
'duration' => $task->resume_time ? ($task->duration + strtotime('now') - strtotime($task->resume_time)) : (strtotime('now') - strtotime($task->start_time))
|
||||
];
|
||||
|
||||
$data = array_merge($data, self::getViewModel());
|
||||
|
@ -60,13 +60,17 @@ class TaskRepository
|
||||
$task->description = trim($data['description']);
|
||||
}
|
||||
|
||||
$timeLog = $task->time_log ? json_decode($task->time_log) : [];
|
||||
|
||||
if ($data['action'] == 'start') {
|
||||
$task->start_time = Carbon::now()->toDateTimeString();
|
||||
$task->is_running = true;
|
||||
$timeLog[] = [strtotime('now'), false];
|
||||
} else if ($data['action'] == 'resume') {
|
||||
$task->break_duration = strtotime('now') - strtotime($task->start_time) + $task->duration;
|
||||
$task->resume_time = Carbon::now()->toDateTimeString();
|
||||
$task->is_running = true;
|
||||
$timeLog[] = [strtotime('now'), false];
|
||||
} else if ($data['action'] == 'stop' && $task->is_running) {
|
||||
if ($task->resume_time) {
|
||||
$task->duration = $task->duration + strtotime('now') - strtotime($task->resume_time);
|
||||
@ -74,6 +78,7 @@ class TaskRepository
|
||||
} else {
|
||||
$task->duration = strtotime('now') - strtotime($task->start_time);
|
||||
}
|
||||
$timeLog[count($timeLog)-1][1] = strtotime('now');
|
||||
$task->is_running = false;
|
||||
} else if ($data['action'] == 'save' && !$task->is_running) {
|
||||
$task->start_time = $data['start_time'];
|
||||
@ -83,6 +88,7 @@ class TaskRepository
|
||||
|
||||
$task->duration = max($task->duration, 0);
|
||||
$task->break_duration = max($task->break_duration, 0);
|
||||
$task->time_log = json_encode($timeLog);
|
||||
|
||||
$task->save();
|
||||
|
||||
|
@ -13,10 +13,11 @@ class EnableResumingTasks extends Migration {
|
||||
public function up()
|
||||
{
|
||||
Schema::table('tasks', function($table)
|
||||
{
|
||||
{
|
||||
$table->boolean('is_running')->default(false);
|
||||
$table->integer('break_duration')->nullable();
|
||||
$table->timestamp('resume_time')->nullable();
|
||||
$table->text('time_log')->nullable();
|
||||
});
|
||||
|
||||
$tasks = DB::table('tasks')
|
||||
@ -49,6 +50,7 @@ class EnableResumingTasks extends Migration {
|
||||
$table->dropColumn('is_running');
|
||||
$table->dropColumn('resume_time');
|
||||
$table->dropColumn('break_duration');
|
||||
$table->dropColumn('time_log');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -690,5 +690,6 @@ return array(
|
||||
'resume' => 'Resume',
|
||||
'break_duration' => 'Break',
|
||||
'edit_details' => 'Edit Details',
|
||||
'work' => 'Work',
|
||||
|
||||
);
|
||||
|
@ -55,9 +55,6 @@
|
||||
@if ($task->duration)
|
||||
{{ trans('texts.duration') }}: <span id="durationText"></span><br/>
|
||||
@endif
|
||||
@if ($task->break_duration)
|
||||
{{ trans('texts.break_duration') }}: <span id="breakDurationText"></span><br/>
|
||||
@endif
|
||||
<p>{!! Button::primary(trans('texts.edit_details'))->withAttributes(['onclick'=>'showTimeDetails()'])->small() !!}</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -94,7 +91,7 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-4 col-sm-4">
|
||||
{{ trans('texts.duration') }}
|
||||
{{ trans('texts.work') }}
|
||||
</label>
|
||||
<div class="col-lg-8 col-sm-8 time-input">
|
||||
<input class="form-control" id="duration_hours" placeholder="{{ uctrans('texts.hours') }}"
|
||||
@ -285,7 +282,7 @@
|
||||
@if ($task)
|
||||
NINJA.startTime = {{ strtotime($task->start_time) }};
|
||||
@if ($task->is_running)
|
||||
tock({{ $task->duration ?: strtotime('now') - strtotime($task->start_time) }});
|
||||
tock({{ $duration }});
|
||||
@else
|
||||
var date = new Date(NINJA.startTime * 1000);
|
||||
var hours = date.getHours();
|
||||
|
Loading…
Reference in New Issue
Block a user