mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 19:54:30 -04:00
Added resume option to tasks
This commit is contained in:
parent
97adc27ba1
commit
9c577371bb
@ -1,5 +1,6 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
use View;
|
use View;
|
||||||
use URL;
|
use URL;
|
||||||
use Utils;
|
use Utils;
|
||||||
@ -8,6 +9,7 @@ use Datatable;
|
|||||||
use Validator;
|
use Validator;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Session;
|
use Session;
|
||||||
|
use DropdownButton;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
|
|
||||||
@ -44,7 +46,12 @@ class TaskController extends BaseController
|
|||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
if (!Auth::user()->account->timezone) {
|
||||||
|
$link = link_to('/company/details', trans('texts.click_here'), ['target' => '_blank']);
|
||||||
|
Session::flash('warning', trans('texts.timezone_unset', ['link' => $link]));
|
||||||
|
}
|
||||||
|
|
||||||
return View::make('list', array(
|
return View::make('list', array(
|
||||||
'entityType' => ENTITY_TASK,
|
'entityType' => ENTITY_TASK,
|
||||||
'title' => trans('texts.tasks'),
|
'title' => trans('texts.tasks'),
|
||||||
@ -156,7 +163,21 @@ class TaskController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function edit($publicId)
|
public function edit($publicId)
|
||||||
{
|
{
|
||||||
$task = Task::scope($publicId)->with('client')->firstOrFail();
|
$task = Task::scope($publicId)->with('client', 'invoice')->firstOrFail();
|
||||||
|
|
||||||
|
$actions = [];
|
||||||
|
if ($task->invoice) {
|
||||||
|
$actions[] = ['url' => URL::to("inovices/{$task->invoice->public_id}/edit"), 'label' => trans("texts.view_invoice")];
|
||||||
|
} else {
|
||||||
|
$actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans("texts.invoice_task")];
|
||||||
|
}
|
||||||
|
$actions[] = DropdownButton::DIVIDER;
|
||||||
|
if (!$task->trashed()) {
|
||||||
|
$actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_task')];
|
||||||
|
$actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans('texts.delete_task')];
|
||||||
|
} else {
|
||||||
|
$actions[] = ['url' => 'javascript:submitAction("restore")', 'label' => trans('texts.restore_task')];
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
@ -164,7 +185,8 @@ class TaskController extends BaseController
|
|||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'tasks/'.$publicId,
|
'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))
|
'duration' => $task->resume_time ? ($task->duration + strtotime('now') - strtotime($task->resume_time)) : (strtotime('now') - strtotime($task->start_time)),
|
||||||
|
'actions' => $actions
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = array_merge($data, self::getViewModel());
|
$data = array_merge($data, self::getViewModel());
|
||||||
@ -192,8 +214,13 @@ class TaskController extends BaseController
|
|||||||
|
|
||||||
private function save($publicId = null)
|
private function save($publicId = null)
|
||||||
{
|
{
|
||||||
$task = $this->taskRepo->save($publicId, Input::all());
|
$action = Input::get('action');
|
||||||
|
|
||||||
|
if (in_array($action, ['archive', 'delete', 'invoice', 'restore'])) {
|
||||||
|
return self::bulk();
|
||||||
|
}
|
||||||
|
|
||||||
|
$task = $this->taskRepo->save($publicId, Input::all());
|
||||||
Session::flash('message', trans($publicId ? 'texts.updated_task' : 'texts.created_task'));
|
Session::flash('message', trans($publicId ? 'texts.updated_task' : 'texts.created_task'));
|
||||||
|
|
||||||
return Redirect::to("tasks/{$task->public_id}/edit");
|
return Redirect::to("tasks/{$task->public_id}/edit");
|
||||||
|
@ -13,6 +13,11 @@ class Task extends EntityModel
|
|||||||
return $this->belongsTo('App\Models\Account');
|
return $this->belongsTo('App\Models\Account');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function invoice()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('App\Models\Invoice');
|
||||||
|
}
|
||||||
|
|
||||||
public function client()
|
public function client()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Client')->withTrashed();
|
return $this->belongsTo('App\Models\Client')->withTrashed();
|
||||||
|
@ -692,6 +692,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -683,6 +683,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
@ -691,5 +691,8 @@ return array(
|
|||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
'work' => 'Work',
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -662,6 +662,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
@ -691,6 +691,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
@ -683,6 +683,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
@ -684,5 +684,9 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -686,6 +686,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -693,6 +693,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -691,6 +691,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
@ -686,6 +686,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -686,6 +686,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -689,6 +689,10 @@ return array(
|
|||||||
'resume' => 'Resume',
|
'resume' => 'Resume',
|
||||||
'break_duration' => 'Break',
|
'break_duration' => 'Break',
|
||||||
'edit_details' => 'Edit Details',
|
'edit_details' => 'Edit Details',
|
||||||
|
'work' => 'Work',
|
||||||
|
'timezone_unset' => 'Please :link to set your timezone',
|
||||||
|
'click_here' => 'click here',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -418,7 +418,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@if (Session::has('warning'))
|
@if (Session::has('warning'))
|
||||||
<div class="alert alert-warning">{{ Session::get('warning') }}</div>
|
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (Session::has('message'))
|
@if (Session::has('message'))
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div style="display:none">
|
<div style="display:none">
|
||||||
|
@if ($task)
|
||||||
|
{!! Former::text('id') !!}
|
||||||
|
{!! Former::populateField('id', $task->public_id) !!}
|
||||||
|
@endif
|
||||||
{!! Former::text('action') !!}
|
{!! Former::text('action') !!}
|
||||||
{!! Former::text('start_time') !!}
|
{!! Former::text('start_time') !!}
|
||||||
{!! Former::text('duration') !!}
|
{!! Former::text('duration') !!}
|
||||||
@ -144,6 +148,10 @@
|
|||||||
@if ($task)
|
@if ($task)
|
||||||
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button']) !!}
|
||||||
{!! Button::primary(trans('texts.resume'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'resume-button']) !!}
|
{!! Button::primary(trans('texts.resume'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'resume-button']) !!}
|
||||||
|
{!! DropdownButton::normal(trans('texts.more_actions'))
|
||||||
|
->withContents($actions)
|
||||||
|
->large()
|
||||||
|
->dropup() !!}
|
||||||
@else
|
@else
|
||||||
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button', 'style' => 'display:none']) !!}
|
{!! Button::success(trans('texts.save'))->large()->appendIcon(Icon::create('floppy-disk'))->withAttributes(['id' => 'save-button', 'style' => 'display:none']) !!}
|
||||||
{!! Button::success(trans('texts.start'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'start-button']) !!}
|
{!! Button::success(trans('texts.start'))->large()->appendIcon(Icon::create('play'))->withAttributes(['id' => 'start-button']) !!}
|
||||||
@ -181,7 +189,7 @@
|
|||||||
var period = periods[i];
|
var period = periods[i];
|
||||||
var letter = period.charAt(0);
|
var letter = period.charAt(0);
|
||||||
var value = parts[letter];
|
var value = parts[letter];
|
||||||
if (!value || data.length) {
|
if (!value) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
period = value == 1 ? timeLabels[period] : timeLabels[period + 's'];
|
period = value == 1 ? timeLabels[period] : timeLabels[period + 's'];
|
||||||
@ -216,6 +224,12 @@
|
|||||||
$('.task-form').submit();
|
$('.task-form').submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDeleteClick() {
|
||||||
|
if (confirm('{!! trans("texts.are_you_sure") !!}')) {
|
||||||
|
submitAction('delete');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function showTimeDetails() {
|
function showTimeDetails() {
|
||||||
$('#datetime-details').fadeIn();
|
$('#datetime-details').fadeIn();
|
||||||
$('#editDetailsLink').hide();
|
$('#editDetailsLink').hide();
|
||||||
@ -317,7 +331,7 @@
|
|||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
determineEndTime();
|
determineEndTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user