diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 31685ab6dee0..a1b12dad293c 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -1,5 +1,6 @@ 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"); diff --git a/app/Models/Task.php b/app/Models/Task.php index a6be8204e7e7..68cfaffe2e75 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -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(); diff --git a/resources/lang/da/texts.php b/resources/lang/da/texts.php index 3a2583c31fb8..96b073155e8b 100644 --- a/resources/lang/da/texts.php +++ b/resources/lang/da/texts.php @@ -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', + diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php index ccea344c8f33..617e306b773d 100644 --- a/resources/lang/de/texts.php +++ b/resources/lang/de/texts.php @@ -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', + ); \ No newline at end of file diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 25204764aea9..b7ac26271b32 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -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', + ); diff --git a/resources/lang/es/texts.php b/resources/lang/es/texts.php index af39747b07ff..45b3492e16f0 100644 --- a/resources/lang/es/texts.php +++ b/resources/lang/es/texts.php @@ -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', + ); \ No newline at end of file diff --git a/resources/lang/es_ES/texts.php b/resources/lang/es_ES/texts.php index 76961896f100..1fe6041634f1 100644 --- a/resources/lang/es_ES/texts.php +++ b/resources/lang/es_ES/texts.php @@ -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', + ); \ No newline at end of file diff --git a/resources/lang/fr/texts.php b/resources/lang/fr/texts.php index ea26f2e0d354..f06c0f2e748b 100644 --- a/resources/lang/fr/texts.php +++ b/resources/lang/fr/texts.php @@ -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', + ); \ No newline at end of file diff --git a/resources/lang/fr_CA/texts.php b/resources/lang/fr_CA/texts.php index efc2dcda3e69..8ab007fd034b 100644 --- a/resources/lang/fr_CA/texts.php +++ b/resources/lang/fr_CA/texts.php @@ -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', + ); diff --git a/resources/lang/it/texts.php b/resources/lang/it/texts.php index c9ecfb94526c..27a68990a798 100644 --- a/resources/lang/it/texts.php +++ b/resources/lang/it/texts.php @@ -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', + ); diff --git a/resources/lang/lt/texts.php b/resources/lang/lt/texts.php index fe886c1c9d53..3be68c86ad19 100644 --- a/resources/lang/lt/texts.php +++ b/resources/lang/lt/texts.php @@ -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', + ); diff --git a/resources/lang/nb_NO/texts.php b/resources/lang/nb_NO/texts.php index bcbc262c2109..39321b953cdc 100644 --- a/resources/lang/nb_NO/texts.php +++ b/resources/lang/nb_NO/texts.php @@ -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', + ); \ No newline at end of file diff --git a/resources/lang/nl/texts.php b/resources/lang/nl/texts.php index 9a2b8f5b00a1..7dc7ae608cb7 100644 --- a/resources/lang/nl/texts.php +++ b/resources/lang/nl/texts.php @@ -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', + ); diff --git a/resources/lang/pt_BR/texts.php b/resources/lang/pt_BR/texts.php index 13aeaf76fd02..efb84c6e7fce 100644 --- a/resources/lang/pt_BR/texts.php +++ b/resources/lang/pt_BR/texts.php @@ -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', + ); diff --git a/resources/lang/sv/texts.php b/resources/lang/sv/texts.php index df4d92c3355c..5b3cad8ce34d 100644 --- a/resources/lang/sv/texts.php +++ b/resources/lang/sv/texts.php @@ -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', + ); diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index f9ca8ea3da8f..004296f63468 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -418,7 +418,7 @@