1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Added resume option to tasks

This commit is contained in:
Hillel Coren 2015-06-14 17:49:13 +03:00
parent 97adc27ba1
commit 9c577371bb
17 changed files with 104 additions and 7 deletions

View File

@ -1,5 +1,6 @@
<?php namespace App\Http\Controllers;
use Auth;
use View;
use URL;
use Utils;
@ -8,6 +9,7 @@ use Datatable;
use Validator;
use Redirect;
use Session;
use DropdownButton;
use App\Models\Client;
use App\Models\Task;
@ -44,7 +46,12 @@ class TaskController extends BaseController
* @return Response
*/
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(
'entityType' => ENTITY_TASK,
'title' => trans('texts.tasks'),
@ -156,7 +163,21 @@ class TaskController extends BaseController
*/
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 = [
'task' => $task,
@ -164,7 +185,8 @@ class TaskController extends BaseController
'method' => 'PUT',
'url' => 'tasks/'.$publicId,
'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());
@ -192,8 +214,13 @@ class TaskController extends BaseController
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'));
return Redirect::to("tasks/{$task->public_id}/edit");

View File

@ -13,6 +13,11 @@ class Task extends EntityModel
return $this->belongsTo('App\Models\Account');
}
public function invoice()
{
return $this->belongsTo('App\Models\Invoice');
}
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();

View File

@ -692,6 +692,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',

View File

@ -683,6 +683,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -691,5 +691,8 @@ return array(
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -662,6 +662,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -691,6 +691,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -683,6 +683,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -684,5 +684,9 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -686,6 +686,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -693,6 +693,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -691,6 +691,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -686,6 +686,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -686,6 +686,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -689,6 +689,10 @@ return array(
'resume' => 'Resume',
'break_duration' => 'Break',
'edit_details' => 'Edit Details',
'work' => 'Work',
'timezone_unset' => 'Please :link to set your timezone',
'click_here' => 'click here',
);

View File

@ -418,7 +418,7 @@
<div class="container">
@if (Session::has('warning'))
<div class="alert alert-warning">{{ Session::get('warning') }}</div>
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
@endif
@if (Session::has('message'))

View File

@ -25,6 +25,10 @@
@endif
<div style="display:none">
@if ($task)
{!! Former::text('id') !!}
{!! Former::populateField('id', $task->public_id) !!}
@endif
{!! Former::text('action') !!}
{!! Former::text('start_time') !!}
{!! Former::text('duration') !!}
@ -144,6 +148,10 @@
@if ($task)
{!! 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']) !!}
{!! DropdownButton::normal(trans('texts.more_actions'))
->withContents($actions)
->large()
->dropup() !!}
@else
{!! 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']) !!}
@ -181,7 +189,7 @@
var period = periods[i];
var letter = period.charAt(0);
var value = parts[letter];
if (!value || data.length) {
if (!value) {
continue;
}
period = value == 1 ? timeLabels[period] : timeLabels[period + 's'];
@ -216,6 +224,12 @@
$('.task-form').submit();
}
function onDeleteClick() {
if (confirm('{!! trans("texts.are_you_sure") !!}')) {
submitAction('delete');
}
}
function showTimeDetails() {
$('#datetime-details').fadeIn();
$('#editDetailsLink').hide();
@ -317,7 +331,7 @@
@endif
@endif
determineEndTime();
determineEndTime();
});
</script>