mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on projects
This commit is contained in:
parent
9e4afb9b99
commit
1e552778f9
@ -82,9 +82,9 @@ class TaskController extends BaseController
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getDatatable($clientPublicId = null)
|
||||
public function getDatatable($clientPublicId = null, $projectPublicId = null)
|
||||
{
|
||||
return $this->taskService->getDatatable($clientPublicId, Input::get('sSearch'));
|
||||
return $this->taskService->getDatatable($clientPublicId, $projectPublicId, Input::get('sSearch'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,13 +48,13 @@ class ProjectDatatable extends EntityDatatable
|
||||
[
|
||||
'budgeted_hours',
|
||||
function ($model) {
|
||||
return $model->budgeted_hours;
|
||||
return $model->budgeted_hours ?: '';
|
||||
},
|
||||
],
|
||||
[
|
||||
'task_rate',
|
||||
function ($model) {
|
||||
return floatval($model->task_rate) ? Utils::roundSignificant($model->task_rate) : '';
|
||||
return floatval($model->task_rate) ? Utils::formatMoney($model->task_rate) : '';
|
||||
}
|
||||
],
|
||||
];
|
||||
|
15
app/Ninja/Datatables/ProjectTaskDatatable.php
Normal file
15
app/Ninja/Datatables/ProjectTaskDatatable.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
class ProjectTaskDatatable extends TaskDatatable
|
||||
{
|
||||
public function columns()
|
||||
{
|
||||
$columns = parent::columns();
|
||||
|
||||
unset($columns[1]);
|
||||
|
||||
return $columns;
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ class TaskDatatable extends EntityDatatable
|
||||
return $model->project;
|
||||
}
|
||||
|
||||
return $model->project_public_id ? link_to("projects/{$model->project_public_id}/edit", $model->project)->toHtml() : '';
|
||||
return $model->project_public_id ? link_to("projects/{$model->project_public_id}", $model->project)->toHtml() : '';
|
||||
},
|
||||
],
|
||||
[
|
||||
|
@ -18,7 +18,7 @@ class TaskRepository extends BaseRepository
|
||||
return 'App\Models\Task';
|
||||
}
|
||||
|
||||
public function find($clientPublicId = null, $filter = null)
|
||||
public function find($clientPublicId = null, $projectPublicId = null, $filter = null)
|
||||
{
|
||||
$query = DB::table('tasks')
|
||||
->leftJoin('clients', 'tasks.client_id', '=', 'clients.id')
|
||||
@ -61,7 +61,9 @@ class TaskRepository extends BaseRepository
|
||||
'task_statuses.name as task_status'
|
||||
);
|
||||
|
||||
if ($clientPublicId) {
|
||||
if ($projectPublicId) {
|
||||
$query->where('projects.public_id', '=', $projectPublicId);
|
||||
} elseif ($clientPublicId) {
|
||||
$query->where('clients.public_id', '=', $clientPublicId);
|
||||
} else {
|
||||
$query->whereNull('clients.deleted_at');
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Ninja\Datatables\ProjectTaskDatatable;
|
||||
use App\Ninja\Datatables\TaskDatatable;
|
||||
use App\Ninja\Repositories\TaskRepository;
|
||||
use Auth;
|
||||
@ -41,10 +42,15 @@ class TaskService extends BaseService
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getDatatable($clientPublicId, $search)
|
||||
public function getDatatable($clientPublicId, $projectPublicId, $search)
|
||||
{
|
||||
$datatable = new TaskDatatable(true, $clientPublicId);
|
||||
$query = $this->taskRepo->find($clientPublicId, $search);
|
||||
if ($projectPublicId) {
|
||||
$datatable = new ProjectTaskDatatable(true, true);
|
||||
} else {
|
||||
$datatable = new TaskDatatable(true, $clientPublicId);
|
||||
}
|
||||
|
||||
$query = $this->taskRepo->find($clientPublicId, $projectPublicId, $search);
|
||||
|
||||
if (! Utils::hasPermission('view_all')) {
|
||||
$query->where('tasks.user_id', '=', Auth::user()->id);
|
||||
|
@ -97,9 +97,9 @@
|
||||
|
||||
{!! Datatable::table()
|
||||
->addColumn(Utils::trans($datatable->columnFields(), $datatable->entityType))
|
||||
->setUrl(url('api/' . Utils::pluralizeEntityType($entityType) . '/' . (isset($clientId) ? $clientId : (isset($vendorId) ? $vendorId : ''))))
|
||||
->setUrl(url('api/' . Utils::pluralizeEntityType($entityType) . '/' . (isset($clientId) ? (isset($projectId) ? ($clientId . '/' . $projectId) : $clientId) : (isset($vendorId) ? $vendorId : ''))))
|
||||
->setCustomValues('entityType', Utils::pluralizeEntityType($entityType))
|
||||
->setCustomValues('clientId', isset($clientId) && $clientId)
|
||||
->setCustomValues('clientId', isset($clientId) && $clientId && empty($projectId))
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('aaSorting', [[isset($clientId) ? ($datatable->sortCol-1) : $datatable->sortCol, 'desc']])
|
||||
->render('datatable') !!}
|
||||
|
@ -20,7 +20,7 @@
|
||||
<div class="col-md-5">
|
||||
<div class="pull-right">
|
||||
|
||||
{!! Former::open('vendors/bulk')->addClass('mainForm') !!}
|
||||
{!! Former::open('projects/bulk')->addClass('mainForm') !!}
|
||||
<div style="display:none">
|
||||
{!! Former::text('action') !!}
|
||||
{!! Former::text('public_id')->value($project->public_id) !!}
|
||||
@ -65,14 +65,24 @@
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.details') }}</h3>
|
||||
|
||||
|
||||
@if ($project->due_date)
|
||||
{{ trans('texts.due_date') . ': ' . Utils::fromSqlDate($project->due_date) }}<br/>
|
||||
@endif
|
||||
@if ($project->budgeted_hours)
|
||||
{{ trans('texts.budgeted_hours') . ': ' . $project->budgeted_hours }}<br/>
|
||||
@endif
|
||||
@if (floatval($project->task_rate))
|
||||
{{ trans('texts.task_rate') . ': ' . Utils::formatMoney($project->task_rate) }}<br/>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.notes') }}</h3>
|
||||
|
||||
{{ $project->private_notes }}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<h3>{{ trans('texts.progress') }}</h3>
|
||||
|
||||
@ -82,5 +92,53 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="nav nav-tabs nav-justified">
|
||||
{!! Form::tab_link('#tasks', trans('texts.tasks')) !!}
|
||||
</ul><br/>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane" id="tasks">
|
||||
@include('list', [
|
||||
'entityType' => ENTITY_TASK,
|
||||
'datatable' => new \App\Ninja\Datatables\ProjectTaskDatatable(true, true),
|
||||
'projectId' => $project->public_id,
|
||||
'clientId' => $project->client->public_id,
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var loadedTabs = {};
|
||||
|
||||
$(function() {
|
||||
$('.normalDropDown:not(.dropdown-toggle)').click(function(event) {
|
||||
openUrlOnClick('{{ URL::to('projects/' . $project->public_id . '/edit') }}', event)
|
||||
});
|
||||
$('.primaryDropDown:not(.dropdown-toggle)').click(function(event) {
|
||||
openUrlOnClick('{{ URL::to('tasks/create/' . $project->client->public_id . '/' . $project->public_id ) }}', event);
|
||||
});
|
||||
|
||||
$('.nav-tabs a[href="#tasks"]').tab('show');
|
||||
});
|
||||
|
||||
function onArchiveClick() {
|
||||
$('#action').val('archive');
|
||||
$('.mainForm').submit();
|
||||
}
|
||||
|
||||
function onRestoreClick() {
|
||||
$('#action').val('restore');
|
||||
$('.mainForm').submit();
|
||||
}
|
||||
|
||||
function onDeleteClick() {
|
||||
if (confirm("{!! trans('texts.are_you_sure') !!}")) {
|
||||
$('#action').val('delete');
|
||||
$('.mainForm').submit();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@stop
|
||||
|
@ -149,7 +149,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
||||
Route::delete('task_statuses/{task_status_id}', 'TaskKanbanController@deleteStatus');
|
||||
Route::put('task_status_order/{task_id}', 'TaskKanbanController@updateTask');
|
||||
Route::resource('tasks', 'TaskController');
|
||||
Route::get('api/tasks/{client_id?}', 'TaskController@getDatatable');
|
||||
Route::get('api/tasks/{client_id?}/{project_id?}', 'TaskController@getDatatable');
|
||||
Route::get('tasks/create/{client_id?}/{project_id?}', 'TaskController@create');
|
||||
Route::post('tasks/bulk', 'TaskController@bulk');
|
||||
Route::get('projects', 'ProjectController@index');
|
||||
|
Loading…
x
Reference in New Issue
Block a user