@php
/* ---------------------------------------------------------------- /
Customer questions
/ ---------------------------------------------------------------- */
$customer_questions = new Customer_questions;
$check_route_names = [
'orders.edit',
'customers.edit'
];
$in_route = in_array($current_route_name, $check_route_names);
if ( $in_route ) {
$current_id = request()->segment(2);
}
$active_questions = $customer_questions->where('status', 1);
$sum_current_order_questions = $current_route_name === 'orders.edit' ? $customer_questions->where('order_id', $current_id)->where('status', 6)->count() : 0;
$questions_counter = $active_questions->count() + $sum_current_order_questions;
@endphp
@if ($questions_counter === 0)
@else
@includeIf('news._form_customer_questions')
@endif
@php
/* ---------------------------------------------------------------- /
reported problems
/ ---------------------------------------------------------------- */
@endphp
@php
/* ---------------------------------------------------------------- /
Tasks given
/ ---------------------------------------------------------------- */
$my_inbox_tasks = News::where('accepted' , $current_user->id )
->where(function ($query) use ($current_user) {
$query->whereNull('archived')
->orWhere('archived', 'not like' , '%,'.$current_user->id.',%');
})
->where(function ($query) use ($current_user) {
$query->whereNull('done')
->orWhere('done', '!=' , $current_user->id);
})
->orderBy('updated_at', "desc")
->get();
$my_tasks_counter = $my_inbox_tasks->count();
@endphp
@if ($my_tasks_counter == 0)
@else
{{-- * ALL NOT ARCHIVED NEWS --}}
{{-- -------------------------- --}}
@foreach ($my_inbox_tasks as $index => $element)
@if(strpos($element->archived , ','.$current_user->id.',') === false)
@php
//------------------------------------------------------------------------------------------------------
$selected_date = $element->updated_at == $element->created_at
? $element->created_at
: $element->updated_at;
$selected_form = $element->updated_at == $element->created_at
? ''
: '
aktualisiert ';
$selected_user = $element->publisher == $current_user->id
? '
von mir '
: ('von '
.'
'
.User::where('id', $element->publisher)->first()->name
.' '
);
$output_time = diff_time_to_human($selected_date);
//------------------------------------------------------------------------------------------------------
@endphp
@if($element->publisher === $current_user->id)
@else
@endif
{{-- News Head --}}
{{ ($my_news_counter - $index).'.) ' }}
{{ 'ID: ' .$element->id }}
@if ($element->priority === 1)
WICHTIG
@endif
@if ($element->priority === 2)
@if (empty($element->accepted))
MIT BESTÄTIGUNG
@else
bestätigt
@endif
@endif
@if ($element->publisher === $current_user->id)
@php
$all_read_user = explode( ',' , str_replace(',,', ',' , trim( $element->read, ',' )) );
$all_target_user = \array_diff( explode( ',' , str_replace(',,', ',' , trim( $element->target, ',' )) ) , ['all']);
@endphp
@if ($all_read_user < $all_target_user)
{{ count($all_read_user) }} von {{ count($all_target_user) }}
@else
alle {{ count($all_read_user) }}
@endif
@endif
{{-- News Buttons --}}
@if (strpos($element->read , ','.$current_user->id.',') === false)
gelesen markieren
@else
gelesen
@if ($element->priority === 2)
@if ($element->done !== $current_user->id && empty($element->done))
erledigt markieren
@else
{{-- --}}
erledigt
archivieren
@endif
@else
archivieren
@endif
@endif
@if (now()->diffInDays($selected_date) > 60)
alle alten archiv
@endif
{{-- News Text --}}
publisher == $current_user->id ? '' : 'style="cursor:text;"' !!}>
{!! $element->text !!}
{{-- News bottom --}}
{!! $selected_user .' ' .$selected_form .' ' .$output_time !!}
@if (!empty($element->accepted))
@if ($element->accepted === $current_user->id)
von mir angenommen
@else
von
angenommen
@endif
@endif
@if (!empty($element->kuid))
@php
$customer = Customer::where('id', $element->kuid)->first();
@endphp
in Bezug auf {{ $customer->KuNr }} - {{ $customer->company }}
@endif
@endif {{-- END check archived --}}
@endforeach
{{-- *------------------------- --}}
@endif
@php
/* ---------------------------------------------------------------- /
News
/ ---------------------------------------------------------------- */
$archived_news = News::where('archived' , 'like' , '%,'.$current_user->id.',%' )
->orderBy('updated_at', "desc")
->get();
foreach ($archived_news as $index => $element) {
if ($element->resubmission == date('Y-m-d').' 00:00:00'){
News::where('id',$element->id)->update([
// 'read' => NULL,
// 'accepted' => NULL,
// 'confirmed' => NULL,
'archived' => NULL,
'resubmission' => NULL,
'updated_at' => DB::raw('updated_at'),
]);
}
}
$my_inbox_news = News::where('target' , 'like' , '%,'.$current_user->id.',%' )
->where(function ($query) use ($current_user) {
$query->whereNull('archived')
->orWhere('archived', 'not like' , '%,'.$current_user->id.',%');
})
->where(function ($query) use ($current_user) {
$query->whereNull('accepted')
->orWhere('accepted', '!=', $current_user->id);
})
->orderBy('updated_at', "desc")
->get();
$my_news_counter = $my_inbox_news->count();
$to_accept_news_counter = $unread_news_counter = $count_important_messages = 0;
foreach ($my_inbox_news as $index => $element) {
if(strpos($element->read , ','.$current_user->id.',') === false){
$unread_news_counter++;
if ($element->priority > 0 && strpos($element->archived , ','.$current_user->id.',') === false) {
//------------------------------------------------------------------------------------------------------
$selected_date = $element->updated_at == $element->created_at
? $element->created_at
: $element->updated_at;
$selected_form = $element->updated_at == $element->created_at
? ''
: '
aktualisiert ';
$selected_user = $element->publisher == $current_user->id
? '
von mir '
: ('von '
.'
'
.User::where('id', $element->publisher)->first()->name
.' '
);
$output_time = diff_time_to_human($selected_date);
//------------------------------------------------------------------------------------------------------
$count_important_messages ++;
$modal_show = true;
}
}
if ($element->priority > 0 && empty($element->accepted)) {
$to_accept_news_counter++;
}
}
@endphp
@if (count($my_inbox_news) === 0)
@else
{{-- * ALL NOT ARCHIVED NEWS --}}
{{-- -------------------------- --}}
@foreach ($my_inbox_news as $index => $element)
@if(strpos($element->archived , ','.$current_user->id.',') === false)
@php
//------------------------------------------------------------------------------------------------------
$selected_date = $element->updated_at == $element->created_at
? $element->created_at
: $element->updated_at;
$selected_form = $element->updated_at == $element->created_at
? ''
: '
aktualisiert ';
$selected_user = $element->publisher == $current_user->id
? '
von mir '
: ('von '
.'
'
.User::where('id', $element->publisher)->first()->name
.' '
);
$output_time = diff_time_to_human($selected_date);
//------------------------------------------------------------------------------------------------------
@endphp
@if($element->publisher === $current_user->id)
@else
@endif
{{-- News Head --}}
{{ ($my_news_counter - $index).'.) ' }}
{{ 'ID: ' .$element->id }}
@if ($element->priority === 1)
WICHTIG
@endif
@if ($element->priority === 2)
@if (empty($element->accepted))
MIT BESTÄTIGUNG
@else
bestätigt
@endif
@endif
@if ($element->publisher === $current_user->id)
@php
$all_read_user = explode( ',' , str_replace(',,', ',' , trim( $element->read, ',' )) );
$all_target_user = \array_diff( explode( ',' , str_replace(',,', ',' , trim( $element->target, ',' )) ) , ['all']);
@endphp
@if ($all_read_user < $all_target_user)
{{ count($all_read_user) }} von {{ count($all_target_user) }}
@else
alle {{ count($all_read_user) }}
@endif
@endif
{{-- News Buttons --}}
@if (strpos($element->read , ','.$current_user->id.',') === false)
gelesen markieren
@else
gelesen
@if ($element->priority === 2)
@if ($element->accepted !== $current_user->id && empty($element->accepted))
annehmen
@else
angenommen
archivieren
@endif
@else
archivieren
@endif
@endif
@if (now()->diffInDays($selected_date) > 60)
alle alten archiv
@endif
{{-- News Text --}}
publisher == $current_user->id ? '' : 'style="cursor:text;"' !!}>
{!! $element->text !!}
{{-- News bottom --}}
{!! $selected_user .' ' .$selected_form .' ' .$output_time !!}
@if (!empty($element->accepted))
@if ($element->accepted === $current_user->id)
von mir angenommen
@else
von {{ User::where('id', $element->accepted)->first()->name }} angenommen
@endif
@endif
@if (!empty($element->kuid))
@php
$customer = Customer::where('id', $element->kuid)->first();
@endphp
in Bezug auf {{ $customer->KuNr }} - {{ $customer->company }}
@endif
@endif {{-- END check archived --}}
@endforeach
{{-- *------------------------- --}}
@endif