mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 14:04:40 -04:00
Working on projects
This commit is contained in:
parent
ebd6a78711
commit
d7fbccba3e
@ -10,6 +10,9 @@ use App\Models\Project;
|
||||
use App\Ninja\Datatables\ProjectDatatable;
|
||||
use App\Ninja\Repositories\ProjectRepository;
|
||||
use App\Services\ProjectService;
|
||||
use DateInterval;
|
||||
use DatePeriod;
|
||||
use stdClass;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Session;
|
||||
@ -51,13 +54,67 @@ class ProjectController extends BaseController
|
||||
|
||||
public function show(ProjectRequest $request)
|
||||
{
|
||||
$account = auth()->user()->account;
|
||||
$project = $request->entity();
|
||||
$taskMap = [];
|
||||
|
||||
foreach ($project->tasks as $task) {
|
||||
$parts = json_decode($task->time_log) ?: [];
|
||||
|
||||
if (! count($parts)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($parts as $part) {
|
||||
$start = $part[0];
|
||||
$end = count($part) > 1 ? $part[1] : time();
|
||||
|
||||
$date = $account->getDateTime();
|
||||
$date->setTimestamp($part[0]);
|
||||
$sqlDate = $date->format('Y-m-d');
|
||||
|
||||
if (! isset($taskMap[$sqlDate])) {
|
||||
$taskMap[$sqlDate] = 0;
|
||||
}
|
||||
|
||||
$taskMap[$sqlDate] += $end - $start;
|
||||
}
|
||||
}
|
||||
|
||||
$labels = [];
|
||||
$records = [];
|
||||
$startDate = date_create('2017-11-01');
|
||||
$endDate = date_create('2017-12-01');
|
||||
|
||||
$interval = new DateInterval('P1D');
|
||||
$period = new DatePeriod($startDate, $interval, $endDate);
|
||||
$data = [];
|
||||
$amount = 0;
|
||||
$color = '51,122,183';
|
||||
|
||||
foreach ($period as $date) {
|
||||
$labels[] = $date->format('m/d/Y');
|
||||
$records[] = $amount+=10;
|
||||
}
|
||||
|
||||
$dataset = new stdClass();
|
||||
$dataset->data = $records;
|
||||
$dataset->label = trans("texts.tasks");
|
||||
$dataset->lineTension = 0;
|
||||
$dataset->borderWidth = 4;
|
||||
$dataset->borderColor = "rgba({$color}, 1)";
|
||||
$dataset->backgroundColor = "rgba({$color}, 0.1)";
|
||||
|
||||
$data = new stdClass();
|
||||
$data->labels = $labels;
|
||||
$data->datasets = [$dataset];
|
||||
|
||||
$data = [
|
||||
'account' => auth()->user()->account,
|
||||
'project' => $project,
|
||||
'title' => trans('texts.view_project'),
|
||||
'showBreadcrumbs' => false,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
return View::make('projects.show', $data);
|
||||
|
@ -92,7 +92,7 @@ class DashboardRepository
|
||||
$record->lineTension = 0;
|
||||
$record->borderWidth = 4;
|
||||
$record->borderColor = "rgba({$color}, 1)";
|
||||
$record->backgroundColor = "rgba({$color}, 0.05)";
|
||||
$record->backgroundColor = "rgba({$color}, 0.1)";
|
||||
$datasets[] = $record;
|
||||
|
||||
if ($entityType == ENTITY_INVOICE) {
|
||||
|
@ -2626,6 +2626,7 @@ $LANG = array(
|
||||
'budgeted_hours' => 'Budgeted Hours',
|
||||
'progress' => 'Progress',
|
||||
'view_project' => 'View Project',
|
||||
'summary' => 'Summary',
|
||||
|
||||
);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
<script src="{{ asset('js/select2.min.js') }}" type="text/javascript"></script>
|
||||
<link href="{{ asset('css/select2.css') }}" rel="stylesheet" type="text/css"/>
|
||||
<script src="{!! asset('js/Chart.min.js') !!}" type="text/javascript"></script>
|
||||
@stop
|
||||
|
||||
|
||||
@ -72,20 +73,23 @@
|
||||
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.notes') }}</h3>
|
||||
|
||||
{{ $project->private_notes }}
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<h3>{{ trans('texts.progress') }}</h3>
|
||||
|
||||
|
||||
<div class="col-md-3">
|
||||
<h3>{{ trans('texts.summary') }}</h3>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<canvas id="chart-canvas" height="50px" style="background-color:white;padding:20px;display:none"></canvas><br/>
|
||||
|
||||
|
||||
|
||||
<ul class="nav nav-tabs nav-justified">
|
||||
{!! Form::tab_link('#tasks', trans('texts.tasks')) !!}
|
||||
</ul><br/>
|
||||
@ -114,6 +118,10 @@
|
||||
});
|
||||
|
||||
$('.nav-tabs a[href="#tasks"]').tab('show');
|
||||
|
||||
var chartData = {!! json_encode($data) !!};
|
||||
console.log(chartData);
|
||||
loadChart(chartData);
|
||||
});
|
||||
|
||||
function onArchiveClick() {
|
||||
@ -133,6 +141,75 @@
|
||||
}
|
||||
}
|
||||
|
||||
function loadChart(data) {
|
||||
var ctx = document.getElementById('chart-canvas').getContext('2d');
|
||||
if (window.myChart) {
|
||||
window.myChart.config.data = data;
|
||||
//window.myChart.config.options.scales.xAxes[0].time.unit = chartGroupBy.toLowerCase();
|
||||
//window.myChart.config.options.scales.xAxes[0].time.round = chartGroupBy.toLowerCase();
|
||||
window.myChart.update();
|
||||
} else {
|
||||
$('#chart-canvas').fadeIn();
|
||||
window.myChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: data,
|
||||
options: {
|
||||
tooltips: {
|
||||
mode: 'x-axis',
|
||||
titleFontSize: 15,
|
||||
titleMarginBottom: 12,
|
||||
bodyFontSize: 15,
|
||||
bodySpacing: 10,
|
||||
callbacks: {
|
||||
title: function(item) {
|
||||
//return moment(item[0].xLabel).format("{{ $account->getMomentDateFormat() }}");
|
||||
},
|
||||
label: function(item, data) {
|
||||
/*
|
||||
if (item.datasetIndex == 0) {
|
||||
var label = " {!! trans('texts.invoices') !!}: ";
|
||||
} else if (item.datasetIndex == 1) {
|
||||
var label = " {!! trans('texts.payments') !!}: ";
|
||||
} else if (item.datasetIndex == 2) {
|
||||
var label = " {!! trans('texts.expenses') !!}: ";
|
||||
}
|
||||
|
||||
return label + formatMoney(item.yLabel, chartCurrencyId, account.country_id);
|
||||
*/
|
||||
}
|
||||
}
|
||||
},
|
||||
title: {
|
||||
display: false,
|
||||
fontSize: 18,
|
||||
text: '{{ trans('texts.total_revenue') }}'
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
time: {
|
||||
//unit: chartGroupBy,
|
||||
//round: chartGroupBy,
|
||||
},
|
||||
gridLines: {
|
||||
display: false,
|
||||
},
|
||||
}],
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
callback: function(label, index, labels) {
|
||||
//return formatMoney(label, chartCurrencyId, account.country_id);
|
||||
}
|
||||
},
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@stop
|
||||
|
Loading…
x
Reference in New Issue
Block a user