HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/hours.komma.pro/resources/views/projects/show.blade.php
@extends('app')

@section('pageTitle')
    {{$project->name}}
@endsection

@section('content')

    <div class="container projectOverview">
        <div class="row">
            @if (\Session::has('message'))
                @if(!empty(Session::get('message')['url']))
                    <div class="alert alert-info">
                        {{ Session::get('message')['message'] }}
                        <a class="pull-right btn btn-default" href="{{ Session::get('message')['url'] }}"
                           style="margin-top: -7px">Herstel</a>
                    </div>
                @else
                    <div class="alert alert-info">{{ Session::get('message') }}</div>
                @endif
            @endif
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="col-md-12">
                        <div class="col-lg-8">
                            <h1>{{$project->name}}</h1>

                        </div>
                        <div class="col-lg-2">
                            @can('recalculate_project')
                                @if($project->archived == 1 and $project->calculated != 1)
                                    <a href="/projecten/{{$project->id}}/recalculate" class="btn btn-warning pull-right"
                                       style="margin-top: 18px; margin-right: -37px;">Herbereken</a>
                                @endif
                            @endcan
                        </div>
                        <div class="col-lg-2">
                            {{--                            FIXME: CORRECT PERMISSION ? --}}
                            @if($project->archived == '1')
                                @can('recalculate_project')
                                    <a href="/projecten/{{ $project->id }}/activate" class="btn btn-default pull-right"
                                       style="margin-top: 18px">Activeren</a>
                                @endcan
                            @else
                                <a href="/projecten/{{$project->id}}/edit" class="btn btn-primary pull-right"
                                   style="margin-top: 18px;" dusk="editProject">Bewerk project</a>
                            @endif
                        </div>
                    </div>
                    @can('download_excel')
                        <div class="col-lg-12">
                            <br>
                            <div class="col-md-3">
                                <label>Begin datum</label>
                                <input type="text" id="datepicker" name="begin"
                                       value="{{$begin ?? $project->created_at->toDateString()}}"
                                       class="form-control beginDate">
                            </div>
                            <div class="col-md-3">
                                <label>Eind datum</label>
                                <input type="text" id="datepicker2" name="end"
                                       value="{{$end ?? \Carbon\Carbon::today()->toDateString()}}"
                                       class="form-control endDate">
                            </div>
                            <div class="col-md-3" style="margin-top: 27px;">
                                <select name="projectWorker" id="projectWorker" class="form-control selectpicker"
                                        data-live-search="true" title="Kies een projectlid">
                                    @if(!empty($user))
                                        <option value="{{$user}}" selected>{{$user}}</option>
                                        @foreach($allData->workers as $projectWorker => $projectWorkersHours)
                                            @if($user != $projectWorker)
                                                <option value="{{$projectWorker}}">{{$projectWorker}}</option>
                                            @endif
                                        @endforeach
                                    @else
                                        <option selected disabled></option>
                                        @foreach($allData->workers as $projectWorker => $projectWorkersHours)
                                            <option value="{{$projectWorker}}">{{$projectWorker}}</option>
                                        @endforeach
                                    @endif
                                </select>
                            </div>
                            <div class="col-md-1">
                                <a href="/projecten/{{$project->id}}" class="btn btn-primary"
                                   style="margin-top: 27px; margin-left: 10px;">Reset alles</a>
                            </div>
                            <div class="col-md-2">
                                <a href="{{route('excel.project', ['project' => $project->id, 'begin' => $begin ?? $subproject->created_at->toDateString(), 'end' => $end ?? today()->toDateString()])}}"
                                   class="pull-right excelExport" style="margin-top: 32px;">
                                    <img src="/images/excel.png"> Download Excel
                                </a>
                            </div>
                        </div>
                    @endcan
                    <div class="col-lg-12 project-details" id="{{$project->id}}">
                        <div class="col-lg-2">
                            <h4><b>Klant</b></h4>
                            <h4><b>Projectleider</b></h4>
                        </div>
                        <div class="col-lg-2">
                            <h4><a href="/klanten/{{$project->Company->id}}">{{$project->Company->name}}</a></h4>
                            <h4>@foreach($project->ProjectWorkers as $projectWorker){{$projectWorker->User->name}}@endforeach</h4>
                        </div>
                        <div class="col-md-8">
                            <div class="col-md-6">
                                <h4><b>Process:</b> {{$budgets->projectHours['totalHoursInBudget']}}
                                    @if($budgets->projectHours['budget'] > 0)
                                        / {{$budgets->projectHours['budget']}} @endif</h4>
                            </div>
                            <div class="col-md-6" style="text-align: right;">
                                @if($budgets->projectHours['budget'] > 0)
                                    <h4><b>Resterend budget:</b> <span
                                                style="margin-top: 4px; color: {{ $budgets->projectHours['hoursLeftInBudget'] > 0 ? '#2ab27b' : 'red' }}; ">{{ $budgets->projectHours['hoursLeftInBudget']  }}</span>
                                    </h4>
                                @endif
                            </div>
                            <div class="col-md-12">
                                @include('partials.generalElements.progressBar',[
                                        'budget' => $budgets->projectHours['budget'],
                                        'hoursNoBudget' => $budgets->projectHours['totalBillWithoutBudget']+$budgets->projectHours['totalNotBillWithoutBudget'],
                                        'hoursLeftInBudget' => $budgets->projectHours['hoursLeftInBudget'],
                                        'barWidth' => $budgets->projectHours['budget'] > 0 ? ((100 / $budgets->projectHours['budget']) * $budgets->projectHours['totalHoursInBudget']) : 100,
                                        'isProject' => true
                                    ])
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12 stats">
                        <div class="col-md-6 left">
                            <h3>Geschreven uren</h3>

                            <div class="col-md-8"><h5>Facturabel</h5></div>
                            <div class="col-md-4 pull-right">
                                <h5> {{$budgets->projectHours['totalBillWithBudget'] + $budgets->projectHours['totalBillWithoutBudget']}} </h5>
                            </div>
                            <div class="col-md-8">
                                <div class="col-md-8"> Begroot</div>
                                <div class="col-md-4">{{$budgets->projectHours['totalBillWithBudget']}}</div>
                                <div class="col-md-8"> Nacalculatie</div>
                                <div class="col-md-4">{{$budgets->projectHours['totalBillWithoutBudget']}}</div>
                            </div>

                            <div class="col-md-8"><h5>Niet facturabel</h5></div>
                            <div class="col-md-4 pull-right">
                                <h5> {{$budgets->projectHours['totalNotBillWithBudget'] + $budgets->projectHours['totalNotBillWithoutBudget']+$budgets->projectHours['totalExceedsSubproject']}} </h5>
                            </div>
                            <div class="col-md-8">
                                <div class="col-md-8"> Bewust met budget</div>
                                <div class="col-md-4">{{$budgets->projectHours['totalNotBillWithBudget']}}</div>
                                <div class="col-md-8"> Bewust zonder budget</div>
                                <div class="col-md-4">{{$budgets->projectHours['totalNotBillWithoutBudget']}}</div>
                                <div class="col-md-8"> Budgetoverschrijding</div>
                                <div class="col-md-4">{{$budgets->projectHours['totalExceedsSubproject']}}</div>
                            </div>

                        </div>
                        <div class="col-md-6 right">
                            <h3>Facturatie</h3>

                            <div class="col-md-8">Begroot (facturabel)</div>
                            <div class="col-md-3 value">{{$billableBudget}}</div>

                            <div class="col-md-8">Nacalculatie</div>
                            <div class="col-md-3 value">{{$budgets->projectHours['totalBillWithoutBudget']}} </div>
                            <div class="col-md-11"><span class="line"></span></div>
                            <div class="col-md-1 value"><span class="plus">+</span></div>

                            <div class="col-md-8">Totaal</div>
                            <div class="col-md-3 value">{{$billableBudget+$budgets->projectHours['totalBillWithoutBudget']}} </div>

                            <div class="col-md-8">(Gewogen) uurprijs</div>
                            <div class="col-md-3 value">
                                &euro; {{number_format((float) $weightedAverageHourlyRate, 2, '.', '')}}</div>

                            <div class="col-md-8">Omzet uren</div>
                            <div class="col-md-3 value">
                                &euro; {{number_format( $weightedAverageHourlyRate*($billableBudget+$budgets->projectHours['totalBillWithoutBudget']) , 2, '.', '')}} </div>

                            <div class="col-md-7">Onkosten</div>
                            <div class="col-md-4 value">
                                &euro; {{number_format( $sumExpense->total , 2, '.', '')}}
                            </div>

                            <div class="col-md-8">Berekend bedrag</div>
                            <div class="col-md-3 value">
                                &euro; {{number_format( ($weightedAverageHourlyRate*($billableBudget+$budgets->projectHours['totalBillWithoutBudget'])) + $sumExpense->total , 2, '.', '')}} </div>

                            <div class="col-md-7">Gefactureerde omzet</div>
                            <div class="col-md-4 value">
                                &euro; {{number_format(  !empty($project->billed_amount) ? $project->billed_amount : 0  , 2, '.', '')}}
                                {{--                            FIXME: CORRECT PERMISSION ? --}}
                                @can('recalculate_project')
                                    <span class="glyphicon glyphicon-edit" data-toggle="modal" title="Edit"
                                          data-target="#editBilledAmountModal" aria-hidden="true"
                                          style="position: absolute; margin-left: 5px; margin-top: 2px;"></span>
                                @endcan
                            </div>

                            <div class="col-md-7">Positief onderhanden omzet</div>
                            <div class="col-md-4 value">
                                @if($project->calculated == 0)
                                &euro; {{number_format( ($weightedAverageHourlyRate*($billableBudget+$budgets->projectHours['totalBillWithoutBudget'])  + $sumExpense->total ) - (!empty($project->billed_amount) ? $project->billed_amount : 0) , 2, '.', '')}}
                                @else
                                    -
                                @endif
                            </div>
                            @if($project->calculated == 1)
                                <div class="col-md-7">Meer gefactureerd dan berekend bedrag</div>
                                <div class="col-md-4 value">
                                    &euro; {{number_format( (!empty($project->billed_amount) ? $project->billed_amount : 0) - ($weightedAverageHourlyRate*($billableBudget+$budgets->projectHours['totalBillWithoutBudget']) + $sumExpense->total) , 2, '.', '')}}
                                </div>
                            @endif

                        </div>
                    </div>
                    <div class="col-md-12 subprojects">
                        <div class="col-lg-12">
                            <div class="col-lg-6">
                                <h3>Deelprojecten</h3>
                            </div>
                            <div class="col-lg-6">
                                @if($project->archived != '1')
                                    <button type="button" name="createSubproject" data-toggle=modal
                                            data-backdrop="static"
                                            data-target="#createSubprojectModal"
                                            onclick="loadPopup('/subprojecten/create/{{$project->id}}?ref=projecten-{{$project->id}}','#createSubprojectModal');"
                                            class="btn btn-primary pull-right">+ Maak deelproject
                                    </button>
                                @endif
                            </div>
                        </div>

                        @if($project->Subprojects->isEmpty())
                            Geen deelprojecten
                        @else
                            @foreach($project->Subprojects as $index => $subproject)
                                <div class="col-md-12">
                                    <div class="col-lg-12 subproject" sid="{{$subproject->id}}">
                                        <div class="col-md-5 title">
                                            <div class="col-lg-11">
                                                <h4>
                                                    @if($subproject->locked == 1)
                                                        <span class="glyphicon glyphicon-lock" data-toggle="tooltip"
                                                              title="Locked"></span>&nbsp;&nbsp;
                                                    @endif
                                                    <a href="{{url('/subprojecten/'.$subproject->id) . '?' . http_build_query(['begin' => request('begin'), 'end' => request('end'), 'user' => request('user')])}}">{{$subproject->name}}</a>
                                                </h4>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            @if($subproject->budget > 0)
                                                <div class=" col-md-6">
                                                    <label>Process:</label>
                                                    {{$subprojectHours[$index]->totalBillWithBudget+$subprojectHours[$index]->totalNotBillWithBudget+$subprojectHours[$index]->totalExceedsSubproject}}
                                                    / {{$subproject->budget}}
                                                </div>
                                                <div class="col-md-6" style="text-align: right;">
                                                    <label>Resterend budget:</label>
                                                    {{$subproject->budget - ($subprojectHours[$index]->totalBillWithBudget+$subprojectHours[$index]->totalNotBillWithBudget+$subprojectHours[$index]->totalExceedsSubproject)}}
                                                </div>
                                            @else
                                                <div class=" col-md-6">
                                                    <label>&nbsp;</label>
                                                </div>
                                            @endif
                                            <div class="col-md-12">

                                                @include('partials.generalElements.progressBar',[
                                                    'hoursNoBudget' => $subprojectHours[$index]->totalBillWithoutBudget+$subprojectHours[$index]->totalNotBillWithoutBudget,
                                                    'budget' => $subproject->budget,
                                                    'hoursLeftInBudget' => $subproject->budget - ($subprojectHours[$index]->totalBillWithBudget+$subprojectHours[$index]->totalNotBillWithBudget+$subprojectHours[$index]->totalExceedsSubproject),
                                                    'barWidth' => $subproject->budget > 0 ? (100 / $subproject->budget) *  ($subprojectHours[$index]->totalBillWithBudget+$subprojectHours[$index]->totalNotBillWithBudget+$subprojectHours[$index]->totalExceedsSubproject) : 100,
                                                    'isProject' => true
                                                ])

                                            </div>
                                        </div>
                                        <div class="col-lg-1 pull-right trash">
                                            {{--                            FIXME: CORRECT PERMISSION ? --}}
                                            @if( $project->archived != '1' && ($subproject->locked == 0 || Auth::user()->can('recalculate_project')) )
                                                <form action="/subprojecten/{{ $subproject->id }}" method="post" id="delete-form-deelproject-{{$subproject->id}}">
                                                    @csrf
                                                    @method('DELETE')
                                                    {!! Btn::delete($subproject->id, $name = "deelproject") !!}
                                                </form>
                                            @endif

                                        </div>
                                    </div>
                                </div>
                            @endforeach
                        @endif
                    </div>
                    <div class="col-md-12 costs">
                        <div class="col-lg-12">
                            <h3>Onkosten</h3>
                            <table class="table">
                                <thead>
                                <tr>
                                    @if(\Auth::user()->can('change_all_hours'))
                                        <th>Edit</th>
                                    @endif
                                    <th>Fact</th>
                                    <th>Medewerker</th>
                                    <th>Omschrijving</th>
                                    <th>Type</th>
                                    <th width="10%">Stukprijs</th>
                                    <th width="10%">Aantal</th>
                                    <th width="10%">Totaal</th>
                                    <th></th>
                                </tr>
                                </thead>
                                <tbody>

                                @foreach($project->Subprojects as $subproject)
                                    @if(!$subproject->Expenses->isEmpty())
                                        @foreach($subproject->Expenses as $expense)
                                            <tr>
                                                @if(\Auth::user()->can('change_all_hours'))
                                                    <td>
                                                        @if(empty($expense->billed_at) || $expense->billed_at == '0000-00-00 00:00:00')
                                                            {!! Btn::editExpense($expense, $name = "onkosten", $subproject, $project->Subprojects) !!}
                                                        @else
                                                            <span class="glyphicon glyphicon-lock"
                                                                  data-toggle="tooltip"
                                                                  title="Locked"></span>
                                                        @endif
                                                    </td>
                                                @endif
                                                <td>
                                                    @can('bill_expenses')
                                                        {!! Btn::billed($expense->id, $expense->billed_at) !!}
                                                    @endcan
                                                    @cannot('bill_expenses')
                                                        @if(!empty($expense->billed_at) && $expense->billed_at != '0000-00-00 00:00:00')
                                                            <span class="glyphicon glyphicon-ok" data-toggle="tooltip"
                                                                  title="Gefactureerd" style="color: #2ab27b"></span>
                                                        @else
                                                            <span class="glyphicon glyphicon-bulled"
                                                                  data-toggle="tooltip"
                                                                  title="Niet gefactureerd"></span>
                                                        @endif
                                                    @endcannot
                                                </td>
                                                <td>
                                                    {{$expense->User->name}}
                                                </td>
                                                <td>
                                                    {{$expense->description}}
                                                    <hr style="margin: 5px 0;" />
                                                    in <a href="/subprojecten/{{ $expense->subproject_id }}">Deelproject: {{ $project->Subprojects->where('id', $expense->subproject_id)->first()->name }} </a>
                                                </td>
                                                <td>{{$expense->ExpenseType->name}}</td>
                                                <td>{{floatval($expense->ExpenseType->costs)}}</td>
                                                <td>
                                                    {{$expense->value}} {{$expense->ExpenseType->ExpenseUnit->name}}
                                                </td>
                                                <td>
                                                    &euro; {{floatval($expense->value) * floatval($expense->ExpenseType->costs)}}
                                                </td>
                                                <td>
                                                    @if(empty($expense->locked_at) || $expense->locked_at == '0000-00-00 00:00:00')
                                                        @if($expense->user_id != \Auth::id())
                                                            @can('delete_all_hours')
                                                                <form action="/expense/{{ $expense->id }}" method="POST" id="delete-form-onkosten-{{ $expense->id }}">
                                                                    @csrf
                                                                    @method('DELETE')
                                                                    {!! Btn::delete($expense->id, $name = "onkosten") !!}
                                                                </form>
                                                            @endcan
                                                        @else
                                                            <form action="/expense/{{ $expense->id }}" method="POST" id="delete-form-onkosten-{{ $expense->id }}">
                                                                @csrf
                                                                @method('DELETE')
                                                                {!! Btn::delete($expense->id, $name = "onkosten") !!}
                                                            </form>
                                                        @endif
                                                    @else
                                                        <span class="glyphicon glyphicon-lock"
                                                              data-toggle="tooltip"
                                                              title="Locked"></span>
                                                    @endif
                                                </td>
                                            </tr>
                                        @endforeach
                                    @endif
                                @endforeach
                                <tr>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td><b>Nog factureren: {{$sumExpense->notBilled}} euro</b></td>
                                    <td colspan="2" style="text-align: right;">Totale onkosten:</td>
                                    <td>&euro; {{$sumExpense->total}}</td>
                                    <td></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="col-md-12 members">
                        <div class="col-lg-12">
                            <h3>Projectleden</h3>
                        </div>
                        @if(empty($allData->workers))
                            <div class="col-md-6 row">
                                <div class="project">
                                    <ul class="nav nav-justified tasks">
                                        <li class="col-md-6">
                                            Geen projectleden.
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        @else
                            @foreach($allData->workers as $projectWorker => $projectWorkerHours)
                                <div class="col-lg-6">
                                    <div class="project">
                                        <ul class="nav nav-justified tasks">
                                            <li class="col-md-6">
                                                {{$projectWorker}}
                                            </li>
                                            <li class="col-md-6">
                                                <span class="label label-default pull-right">{{$projectWorkerHours}}
                                                    uur</span>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            @endforeach
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="createSubprojectModal"
         id="createSubprojectModal"></div>
    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="editBilledAmountModal"
         id="editBilledAmountModal">

        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">Wijzig gefactureerd bedrag</h4>
                </div>
                <form action="/storeProjectBilledAmount" method="get" id="billed_amount_form">
                    <div class="modal-body" style="text-align: center;">
                        €
                        <div style="display: inline-block;">
                            <input type="number" name="amount" step="0.01" min="0" class="spinner" placeholder='0'
                                   value="{{!empty($project->billed_amount) ? $project->billed_amount : ''}}">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="hidden" name="id" value="{{$project->id}}" form="billed_amount_form">
                        <input type="submit" value="Bevestig" class="btn btn-primary" form="billed_amount_form">
                    </div>
                </form>
            </div>
        </div>
    </div>
    </div>

@stop
@section('script')
    <script src="{{ asset('js/createFilterParams.js') }}"></script>
@stop