@extends('_version_02.commons.layouts.admin')
@section('content')
@include('_version_02.commons.layouts.partials._alert')
{!! Form::model($model, ['class'=>'form-horizontal','method'=>'get']) !!}
{{App\Language::trans('Filter By')}}
{!! Form::close() !!}
@if(isset($report_data['house']))
@php
//dd($report_data);
$renting_head_count = array();
$house_other_information = strlen($report_data['house']['house_other_information']) > 0 ? json_decode($report_data['house']['house_other_information'],true) : array();
//dd($house_other_information);
$total_year = 6 ;
$total_months = $total_year * 12;
$start = 0 - $total_months/3;
$end = $total_months/3;
for ($i=$start; $i<=$end; $i++) {
//dd($i);
$action = $i < 0 ? '- '.abs($i) : '+ '.$i;
$string = date('m-Y', strtotime($action.' month'));
$month_years[(string) $string] = (string) $string;
}
//dd($month_year);
foreach($report_data['rooms'] as $room)
{
$temp_house_room_members = strlen($room['house_room_members']) > 3 ? json_decode($room['house_room_members'], true): array();
if(count($temp_house_room_members ) == 0)
{
continue;
}
foreach ($temp_house_room_members as $index => $row)
{
if(!isset($row['user_id']))
{
unset($temp_house_room_members [$index]);
}
}
//dd($temp_house_room_member);
foreach ($temp_house_room_members as $index => $member)
{//dd($member);
foreach ($month_years as $month_year)
{//dd($member['check_in_date'].' = '.$month_year);
if(!isset($member['check_in_date']))
{
continue;
}
if($member['check_in_date'] == '')
{
continue;
}
if(date('Y-m' ,strtotime($member['check_in_date'])) >= date('Y-m' ,strtotime($month_year)))
{
$renting_head_count[$month_year]['air_cond'] = isset($renting_head_count[$month_year]['air_cond']) ? $renting_head_count[$month_year]['air_cond'] : 0;
$renting_head_count[$month_year]['wifi'] = isset($renting_head_count[$month_year]['wifi']) ? $renting_head_count[$month_year]['wifi'] : 0;
$renting_head_count[$month_year]['utility'] = isset($renting_head_count[$month_year]['utility']) ? $renting_head_count[$month_year]['utility'] : 0;
if(isset($member['others']))
{
if($member['others'] == true)
{
$renting_head_count[$month_year]['utility'] ++;
}
}else{
$renting_head_count[$month_year]['utility'] ++;
}
if(isset($member['air_cond'])){
if($member['air_cond'] == 1)
{
$renting_head_count[$month_year]['air_cond'] ++;
}
}
if(isset($member['wifi'])){
if($member['wifi'] == 1)
{
$renting_head_count[$month_year]['wifi'] ++;
}
}
}
//dd($renting_head_count);
}
}//end generate head count
//dd($renting_head_count);
}
$house_fee_items = json_decode($report_data['house']['house_fee_items'],true);
//=dd($house_fee_items);
//Calculate fee rule
$utilityData_my = array();
$utilityData = $report_data['utilityData'];
foreach($utilityData as $utility_data)
{
//dd($utility_data);
$utilityData_my[$utility_data['month_year']][$utility_data['bill_type']] = isset($utilityData_my[$utility_data['month_year']][$utility_data['bill_type']]) ? $utilityData_my[$utility_data['month_year']][$utility_data['bill_type']] : array();
array_push( $utilityData_my[$utility_data['month_year']][$utility_data['bill_type']] , $utility_data);
}
$average_datas = array();
foreach($utilityData_my as $month_year => $utility_datas)
{
$head_count = isset($renting_head_count[$month_year]['utility']) ? $renting_head_count[$month_year]['utility'] : false;
if($head_count == false)
{
dd( $month_year);
continue;
}
foreach ($utility_datas as $fee_type => $utility_data_model)
{
if($fee_type == 'wifi')
{
$head_count = isset($renting_head_count[$month_year]['wifi']) ? $renting_head_count[$month_year]['wifi'] : false;
}else{
$head_count = isset($renting_head_count[$month_year]['utility']) ? $renting_head_count[$month_year]['utility'] : false;
}
//dd($utility_data_model);
$utility_data_model = isset($utility_data_model[0]) ? $utility_data_model[0] : false;
if(!isset($utility_data_model['amount']))
{
//dd($utility_data_model);
}
if($house_other_information['is_aircond_unit'] == true && $fee_type == 'electric')
{
$aircond_head_count = isset($renting_head_count[$month_year]['air_cond']) ? $renting_head_count[$month_year]['air_cond'] : 0;
if($aircond_head_count == 0)
{
$average_fee = $utility_data_model['amount']/$head_count;
$average_datas[$month_year][$fee_type] = isset($average_data[$month_year][$fee_type]) ? $average_data[$month_year][$fee_type] : array();
$average_datas[$month_year][$fee_type] = ['total'=> $utility_data_model['amount'] , 'head_count' => $head_count, 'amount' => $average_fee];
}else{
$temp_average = (($utility_data_model['amount'] - ($head_count * $house_other_information['fix_aircond_electric_fee_charges'])))/$aircond_head_count ;
$average_datas[$month_year][$fee_type] = isset($average_data[$month_year][$fee_type]) ? $average_data[$month_year][$fee_type] : array();
$average_datas[$month_year][$fee_type] = ['total'=> $utility_data_model['amount'] , 'head_count' => $head_count, 'amount' => $house_other_information['fix_aircond_electric_fee_charges']];
$average_datas[$month_year][$fee_type.'_air_cond'] = isset($average_data[$month_year][$fee_type]) ? $average_data[$month_year][$fee_type] : array();
$average_datas[$month_year][$fee_type.'_air_cond'] = ['total'=> $utility_data_model['amount'] , 'head_count' => $head_count, 'amount' => $temp_average];
}
}else{
$average_fee = $utility_data_model['amount']/$head_count;
$average_datas[$month_year][$fee_type] = isset($average_data[$month_year][$fee_type]) ? $average_data[$month_year][$fee_type] : array();
$average_datas[$month_year][$fee_type] = ['total'=> $utility_data_model['amount'] , 'head_count' => $head_count, 'amount' => $average_fee];
}
}
}
ksort($average_datas);
//dd($average_datas);
@endphp
{{App\Language::trans('Recipient List')}}
Month |
@foreach($house_fee_items as $fee_item)
{{App\Language::trans(ucfirst(str_replace('_', ' ', $fee_item)))}} |
@endforeach
{{App\Language::trans('Subtotal')}} |
@php
$fee_subtotal = array();
$utilityData_my = App\Setting::sortByDateColumn($utilityData_my)
@endphp
@foreach($utilityData_my as $month_year => $u_model)
{{ $month_year }} |
@foreach($house_fee_items as $fee_item)
@php
$fee = isset($u_model[$fee_item][0]) ? $u_model[$fee_item][0]['amount'] : 0 ;
$fee_subtotal[$month_year]['subtotal'] = isset($fee_subtotal[$month_year]['subtotal']) ? $fee_subtotal[$month_year]['subtotal'] + $fee : $fee;
$fee_subtotal[$fee_item] = isset($fee_subtotal[$fee_item]) ? $fee_subtotal[$fee_item] + $fee : $fee;
@endphp
{{ $fee }} |
@endforeach
{{ $fee_subtotal[$month_year]['subtotal'] }} |
@endforeach
@php
//dd($fee_subtotal);
@endphp
@foreach($report_data['rooms'] as $room)
{{App\Language::trans('Room : ')}} {{ $room['house_room_name'] }} |
# |
{{App\Language::trans('Name')}} |
{{App\Language::trans('Phone No')}} |
{{App\Language::trans('Check Out Date')}} |
@php
///dd($report_data['members']);
///dd($room);
$listing_index = 1 ;
$room_members = json_decode($room['house_room_members'] , true);
$is_aircond = false;
$is_wifi = false;
$is_others = true;
foreach($room_members as $r_member)
{
$is_aircond = isset($r_member['air_cond']) ? $r_member['air_cond'] : false;
$is_wifi = isset($r_member['wifi']) ? $r_member['wifi'] : false;
if($is_others == true)
{
$is_others = isset($r_member['is_others']) ? $r_member['is_others'] : true;
}
if(isset($r_member['is_others']))
{
//dd($is_others);
//dd($room);
}
}
@endphp
@foreach($room_members as $member_info)
@php
if(!isset($member_info['user_id']))
{
continue;
}
$member = isset($report_data['members'][$member_info['user_id']]) ? $report_data['members'][$member_info['user_id']]: false;
if($member == false)
{
continue;
}
//dd($room);
//$is_aircond =
@endphp
{{ $listing_index }} |
{{ $member['fullname'] }} |
{{ $member['email'] }} |
{{ $member['phone_number'] }} |
|
@endforeach
@php
$fee_index = 1;
$listing_index ++;
$grand_total = 0;
@endphp
@if(count($average_datas) > 0)
@php $subtotal_datas = array(); @endphp
{{App\Language::trans('Month')}} |
@foreach($average_datas as $month_year => $average_data)
{{ $month_year }} |
@endforeach
@foreach ($house_fee_items as $house_fee_item)
@php
if($house_fee_item == 'wifi' && $is_wifi == false){
continue;
}
$other_utilities = ['electric','indah_water', 'water_fee'];
if(in_array($house_fee_item , $other_utilities) == true && $is_others == 0){
continue;
}
@endphp
{{App\Language::trans(ucwords(str_replace('_', ' ', $house_fee_item)))}} |
@foreach($average_datas as $month_year => $average_data)
@php
$fee_data = isset($average_data[$house_fee_item]) ? $average_data[$house_fee_item] : '-';
@endphp
{{ isset($fee_data['amount']) ? number_format($fee_data['amount'],2) : $fee_data }} |
@php
$subtotal_datas[$month_year] = isset($subtotal_datas[$month_year]) ? $subtotal_datas[$month_year] :0 ;
$subtotal_datas[$month_year] = $subtotal_datas[$month_year] + (isset($fee_data['amount']) ? $fee_data['amount'] : 0) ;
@endphp
@endforeach
@if($house_fee_item == 'electric' && $is_aircond == true)
@php
$house_fee_item = 'electric_air_cond';
//dd($member );
@endphp
{{App\Language::trans(ucwords(str_replace('_', ' ', $house_fee_item)))}} |
@foreach($average_datas as $month_year => $average_data)
@php
$fee_data = isset($average_data[$house_fee_item]) ? $average_data[$house_fee_item] : '-';
@endphp
{{ isset($fee_data['amount']) ? number_format($fee_data['amount'],2) : $fee_data }} |
@php
$subtotal_datas[$month_year] = isset($subtotal_datas[$month_year]) ? $subtotal_datas[$month_year] :0 ;
$subtotal_datas[$month_year] = $subtotal_datas[$month_year] + (isset($fee_data['amount']) ? $fee_data['amount'] : 0) ;
@endphp
@endforeach
@endif
@endforeach
{{App\Language::trans('Sub-Total')}} |
@foreach($subtotal_datas as $month_year => $amount)
{{ number_format($amount,2) }} |
@endforeach
@else
No record found. |
@endif
|
@endforeach
{{App\Language::trans('Total')}}: |
{{number_format($grand_total, 2)}} |
@else
@endif
@endsection
@section('script')
@endsection