sparqapi/api/application/helpers/rentalform_helper.php
2019-08-31 13:24:59 +05:30

262 lines
16 KiB
PHP

<?php
class Rentalform
{
public static function getRentalText($rental_data){
//print_r($rental_data);die();
$rupee_symbol = "<span style='font-family: DejaVu Sans; sans-serif;font-size:10px'>₹</span>";
$address_property = $rental_data['address_property'];
$address_property = str_replace("\n",' ',$address_property);
$address_property .= ' ,'.$rental_data['city_master'].' ,'.$rental_data['state_master'].' - '.$rental_data['pincode_master'].'.';
$address_property = $rental_data['validate_visited_address'] ? $address_property : str_replace("\n",'',$rental_data['other_visited_address']);
$type_of_property = $rental_data['nature_property']['id'] == 1 ? $rental_data['other_nature_property']: $rental_data['nature_property']['name'];
$unit_type = $rental_data['unit_type']['id'] == 1 ? $rental_data['other_unit_type'] : $rental_data['unit_type']['name'];
$no_of_floors = $rental_data['unit_type']['id'] == 6 ? $rental_data['no_floor'] : $rental_data['no_units'];
$area_coverd = $rental_data['unit_type']['id'] == 6 ? $rental_data['multistoried_total_area'] : '';
$area_uom = $rental_data['unit_type']['id'] == 6 ? $rental_data['multistoried_uom']['name'] : '';
$property_owners_name = null;
foreach($rental_data['property_owner'] as $owner){
if($owner['id'] != 0)
{
$property_owners_name .= $owner['name'].' ,';
}
else
{
$property_owners_name .= $rental_data['property_owner_other'].' , ';
}
}
$property_owners_name = substr_replace($property_owners_name,' ',strrpos($property_owners_name,','),1);
if(strrpos($property_owners_name,','))
{
$property_owners_name = substr_replace($property_owners_name,' and ',strrpos($property_owners_name,','),1);
}
$property_showing_persons_name = null;
foreach($rental_data['person_met'] as $person_met){
if($person_met['id'] != 0)
{
$property_showing_persons_name .= $person_met['name'].' ,';
}
else
{
$property_showing_persons_name .= $rental_data['other_person_met'].' , ';
}
}
$property_showing_persons_name = substr_replace($property_showing_persons_name,' ',strrpos($property_showing_persons_name,','),1);
if(strrpos($property_showing_persons_name,','))
{
$property_showing_persons_name = substr_replace($property_showing_persons_name,' and ',strrpos($property_showing_persons_name,','),1);
}
$property_document_proof_visted = $rental_data['property_ownership_proof_documents'] == 1 ? 'Yes': 'No';
$type_of_document_visited = ( $rental_data['property_ownership_proof_documents'] == 1 && substr_count($rental_data['sighted_documents']['name'], 'Others') ) ? $rental_data['other_sighted_documents'] : (isset($rental_data['sighted_documents']['name'] ) ? $rental_data['sighted_documents']['name'] : '');
$property_remark = $rental_data['rental_remark'];
$third_check_details = array();
$third_check_details['done_third_party_check'] = $rental_data['done_third_party_check'];// ? 'Yes' : 'No';
$third_check_details['done_third_party_check'] = $rental_data['done_third_party_check'];// ? 'Yes' : 'No';
$third_check_details['why_third_party_check_not_done'] = isset($rental_data['why_third_party_check_not_done']) && !$rental_data['done_third_party_check'] ? $rental_data['why_third_party_check_not_done'] : '';
$third_check_details['whom_third_party_check_done'] = isset($rental_data['whom_third_party_check_done']) ? $rental_data['whom_third_party_check_done'] : '';
$third_check_details['description_third_party_check_done'] = isset($rental_data['description_third_party_check_done']) ? $rental_data['description_third_party_check_done'] : '';
$third_check_details['rental_rates_third_party_check_done'] = isset($rental_data['rental_rates_third_party_check_done']) ? $rental_data['rental_rates_third_party_check_done'] : '';
$unit_wise_details = array();
foreach ($rental_data['property_unit_details'] as $u_key => $unit) {
$temp = array();
$header_row = '<tr><th style="width:25%;">Particulars</th> <th style="width:25%;">As Per Agreement</th> <th style="width:25%;">As Per Applicant</th> <th style="width:25%;">As Per Tenant</th> </tr>';
$first_owners_row = '<tr><td class="customtd">Property Owner Name</td>';
$second_lessee_name_row = '<tr><td class="customtd">Lessee Name</td>';
$third_area_of_unit_row = '<tr><td class="customtd">Area of Unit</td>';
$fourth_payment_mode_row = '<tr><td class="customtd">Payment Mode</td>';
$fifth_lease_period_row = '<tr><td class="customtd">Lease Period</td>';
$sixth_security_deposit_row = '<tr><td class="customtd">Security Deposit</td>';
$eigth_current_rent_received_row = '<tr><td class="customtd">Rent Received (Rs/ per month)</td>';
$nineth_difference_between_rent_amount_row = '<tr><td class="customtd">Reason for difference between Rent Amount</td>';
//if($unit['tenant_lessees_options'] == 1) { $temp['lesse_name'] = $unit['name_tenant_lessees'];} else { $temp['lesse_name'] = 'Not Available' ; }
// As per Agreement
$owners_name_agreement = '';
if(isset($unit['agreement_property_owners_name']) && count($unit['agreement_property_owners_name']))
{
foreach($unit['agreement_property_owners_name'] as $key => $value)
{
if($value['id'] != 0)
{
$owners_name_agreement .= $value['name'].' ,';
}
else
{
//$owners_name_agreement .= $value['other_person_met'].' , ';
}
}
$owners_name_agreement = substr_replace($owners_name_agreement,' ',strrpos($owners_name_agreement,','),1);
if(strrpos($owners_name_agreement,','))
{
$owners_name_agreement = substr_replace($owners_name_agreement,' and ',strrpos($owners_name_agreement,','),1);
}
}
if($owners_name_agreement == '')
{
$owners_name_agreement = isset($unit['agreement_tenant_lessees_name']) ? $unit['agreement_tenant_lessees_name']:($unit['is_rent_agreement_executed'] != 1 ? 'Rent Agreement Not Executed' : ($unit['rent_agreement_seen'] != 1 ? 'Rent Agreement Not Seen' : ''));
}
$agreement_tenant_lessees_name = isset($unit['agreement_tenant_lessees_name']) ? $unit['agreement_tenant_lessees_name']:($unit['is_rent_agreement_executed'] != 1 ? 'Rent Agreement Not Executed' : ($unit['rent_agreement_seen'] != 1 ? 'Rent Agreement Not Seen' : ''));
$lease_period = isset($unit['agreement_date']) ? 'lease start from '. date_format(date_create_from_format("Y-m-d",explode('T',$unit['agreement_date'])[0]) ,'M-Y') .' to '.date_format(date_create_from_format("d/m/Y",$unit['agreement_expiring_date']),'M-Y') : ($unit['is_rent_agreement_executed'] != 1 ? 'Rent Agreement Not Executed' : ($unit['rent_agreement_seen'] != 1 ? 'Rent Agreement Not Seen' : ''));
$agreement_security_deposit_amount = isset($unit['agreement_security_deposit_amount']) ? $rupee_symbol.' '.$unit['agreement_security_deposit_amount']: ($unit['is_rent_agreement_executed'] != 1 ? 'Rent Agreement Not Executed' : ($unit['rent_agreement_seen'] != 1 ? 'Rent Agreement Not Seen' : ''));
$agreement_monthly_rent_amount = isset($unit['agreement_monthly_rent_amount']) ? $rupee_symbol.' '.$unit['agreement_monthly_rent_amount'] : ($unit['is_rent_agreement_executed'] != 1 ? 'Rent Agreement Not Executed' : ($unit['rent_agreement_seen'] != 1 ? 'Rent Agreement Not Seen' : ''));
//As per Applicant
$tentant_name_applicant = ( isset($unit['name_tenant_lessees']) ? $unit['name_tenant_lessees'] : 'Not Provided <br>'.(isset($unit['name_tenant_lessees_reason']) ? '('. ($unit['name_tenant_lessees_reason']) .')' : ''));
$property_cover_area = $unit['property_cover_area'] .' '. $unit['unit_measurement']['name'];
$payment_mode = $unit['payment_mode']['name'].'<br> (';
$payment_mode .= isset($unit['amount_received_bank']) ? 'from bank: ' . $unit['amount_received_bank'] : '';
$payment_mode .= isset($unit['amount_received_cash']) ? ' from cash: ' .$unit['amount_received_cash'] : '';
$payment_mode .= ')';
$payment_mode .= isset($unit['payment_received_reason']) && $unit['payment_received_reason'] != '' ? '<br>Reason for receiving multiple payment Mode - '. $unit['payment_received_reason'] :'';
$securtity_deposit_amount = $rupee_symbol.' '.$unit['securtity_deposit_amount'];
$monthly_rent_amount = $rupee_symbol.' '.$unit['monthly_rent_amount'];
//As per Tentant
$owners_name_tentant = '';
if(isset($unit['property_owner_per_met']) && count($unit['property_owner_per_met']))
{
foreach($unit['property_owner_per_met'] as $key => $value)
{
if($value['id'] != 0)
{
$owners_name_tentant .= $value['name'].' ,';
}
else
{
$owners_name_tentant .= $unit['property_owner_other_per_met'].' , ';
}
}
$owners_name_tentant = substr_replace($owners_name_tentant,' ',strrpos($owners_name_tentant,','),1);
if(strrpos($owners_name_tentant,','))
{
$owners_name_tentant = substr_replace($owners_name_tentant,' and ',strrpos($owners_name_tentant,','),1);
}
}
if($owners_name_tentant == '')
{
$owners_name_tentant = isset($unit['met_tenant_lessees_options']) && $unit['met_tenant_lessees_options'] != 1 ? ('Tenant Not Met'.(isset($unit['name_tenant_lessees_reason_per_met']) ? ('<br>('. $unit['name_tenant_lessees_reason_per_met'].')') :'')) :'';
}
$name_tenant_lessees_per_met = isset($unit['name_tenant_lessees_per_met']) ? $unit['name_tenant_lessees_per_met'] : ('Tenant Not Met');
$payment_mode_tentant = isset($unit['payment_mode_per_met']['name']) ? $unit['payment_mode_per_met']['name'].'<br> (' : '';
$payment_mode_tentant .= isset($unit['amount_received_bank_per_met']) ? 'from bank: ' . $unit['amount_received_bank_per_met'] : '';
$payment_mode_tentant .= isset($unit['amount_received_cash_per_met']) ? ' from cash: ' .$unit['amount_received_cash_per_met'] : '';
$payment_mode_tentant .= ')';
$payment_mode_tentant = isset($unit['met_tenant_lessees_options']) && $unit['met_tenant_lessees_options'] != 1 ? 'Tenant Not Met' : $payment_mode_tentant;
$payment_mode_tentant .= isset($unit['payment_received_reason_per_met']) && $unit['payment_received_reason_per_met'] != '' ? '<br>Reason for receiving multiple mode - '.$unit['payment_received_reason_per_met'] : '';
$lease_period_tentant = isset($unit['period_of_stay_per_met']) ? $unit['period_of_stay_per_met'].' Months' : 'Tenant Not Met';
$rent_tentant = isset($unit['paid_monthly_rent_per_met']) ? $rupee_symbol.' '.$unit['paid_monthly_rent_per_met'] : 'Tenant Not Met';
$payment_difference_per_met = isset($unit['payment_difference_per_met']) ? $unit['payment_difference_per_met'] : 'Tenant Not Met';
// $temp['agreement_tenant_lessees_name'] = isset($unit['agreement_tenant_lessees_name']) ? $unit['agreement_tenant_lessees_name']: ( isset($unit['name_tenant_lessees']) ? $unit['name_tenant_lessees'] : 'Not Provided <br>('. $unit['name_tenant_lessees_reason'] .')' );
// $temp['agreement_monthly_rent_amount'] = isset($unit['agreement_monthly_rent_amount']) ? $unit['agreement_monthly_rent_amount'] : $unit['monthly_rent_amount'];
// $temp['agreement_security_deposit_amount'] = isset($unit['agreement_security_deposit_amount']) ? $unit['agreement_security_deposit_amount']: $unit['securtity_deposit_amount'];
// $temp['property_cover_area'] = $unit['property_cover_area'] .' '. $unit['unit_measurement']['name'];
// $temp['payment_mode'] = $unit['payment_mode']['name'].'<br> (';
// $temp['payment_mode'] .= isset($unit['amount_received_bank']) ? 'from bank: ' . $unit['amount_received_bank'] : '';
// $temp['payment_mode'] .= isset($unit['amount_received_cash']) ? ' from cash: ' .$unit['amount_received_cash'] : '';
// $temp['payment_mode'] .= ')';
// $temp['rent_agreement_executed'] = $unit['is_rent_agreement_executed'] == 1 ? 'Yes' : 'No' ;
// $temp['rent_agreement_seen'] = isset($unit['rent_agreement_seen']) && $unit['rent_agreement_seen'] == 1 ? 'Yes' : 'No' ;
// $temp['rent_agreement_registered'] = isset($unit['rent_agreement_registered']) && $unit['rent_agreement_registered']== 1 ? 'Yes' : 'No' ;
$first_owners_row .= '<td class="customtd">'. $owners_name_agreement .'</td><td class="customtd">'.$property_owners_name.'</td><td class="customtd">'. $owners_name_tentant .'</td>';
$second_lessee_name_row .= '<td class="customtd">'. $agreement_tenant_lessees_name .'</td><td class="customtd">'.$tentant_name_applicant.'</td><td class="customtd">'. $name_tenant_lessees_per_met .'</td>';
$third_area_of_unit_row .= '<td class="customtd">-</td><td class="customtd">'.$property_cover_area.'</td><td class="customtd">-</td>';
$fourth_payment_mode_row .= '<td class="customtd">-</td><td class="customtd">'. $payment_mode .'</td><td class="customtd">'. $payment_mode_tentant .'</td>';
$fifth_lease_period_row .= '<td class="customtd">'. $lease_period .'</td><td class="customtd">-</td><td class="customtd">'. $lease_period_tentant .'</td></tr>';
$sixth_security_deposit_row .= '<td class="customtd">' . $agreement_security_deposit_amount . '</td><td class="customtd">'.$securtity_deposit_amount.'</td><td class="customtd">-</td>';
$eigth_current_rent_received_row .= '<td class="customtd">' . $agreement_monthly_rent_amount .'</td><td class="customtd">'.$monthly_rent_amount.'</td><td class="customtd">'. $rent_tentant .'</td>';
$nineth_difference_between_rent_amount_row .= '<td class="customtd">-</td><td class="customtd">-</td><td class="customtd">'. $payment_difference_per_met .'</td>';
$temp['unit_name'] = 'Unit - '.($u_key + 1);
$temp['header_row'] = $header_row;
$temp['first_owners_row'] = $first_owners_row.'</tr>';
$temp['second_lessee_name_row'] = $second_lessee_name_row.'</tr>';
$temp['third_area_of_unit_row'] = $third_area_of_unit_row.'</tr>';
$temp['fourth_payment_mode_row'] = $fourth_payment_mode_row.'</tr>';
$temp['fifth_lease_period_row'] = $fifth_lease_period_row.'</tr>';
$temp['sixth_security_deposit_row'] = $sixth_security_deposit_row.'</tr>';
$temp['eigth_current_rent_received_row'] = $eigth_current_rent_received_row.'</tr>';
$temp['nineth_difference_between_rent_amount_row'] = $nineth_difference_between_rent_amount_row.'</tr>';
//$temp['leease_period'] = isset($unit['agreement_date']) ? 'lease start from '. date_format(date_create_from_format("Y-m-d",explode('T',$unit['agreement_date'])[0]) ,'M-Y') .' to '.date_format(date_create_from_format("d/m/Y",$unit['agreement_expiring_date']),'M-Y') : 'NA';
//array_push($unit_wise_details['property_core'][],$temp);
$unit_wise_details['property_core'][] = $temp;
}
$multi_storey = array();
$over_all_multistorey_total = 0;
if(isset($rental_data['multistoried_building_details']) && count($rental_data['multistoried_building_details']))
{
//echo 'multistoried_building_details availavle';
foreach($rental_data['multistoried_building_details'] as $ml_key => $ml_value)
{
$multi_storey_temp['floor_name'] = $ml_value['floor_level'];
$multi_storey_temp['no_units_in_floor'] = $ml_value['no_units_in_floor'];
$multi_storey_temp['same_rent'] = $ml_value['unit_rent_difference_options'] == 1 ? 'Yes' :'No';
$multi_storey_temp['total_floor_rent'] = $rupee_symbol.' '.$ml_value['floor_rent_amount'];
$over_all_multistorey_total += $ml_value['floor_rent_amount'];
if($ml_value['unit_rent_difference_options'] == 1)
{
$multi_storey_temp['unit_details'] = 'per unit '.$rupee_symbol.' '.$ml_value['floor_unit_details'][0]['rent_per_unit'] ;
}
else
{
$units_to_dispaly = '';
foreach($ml_value['floor_unit_details'] as $u_k => $u_v)
{
$units_to_dispaly .= 'Unit-'.($u_k + 1) .' - '.$rupee_symbol.' '.$u_v['rent_per_unit'].'<br>';
}
$multi_storey_temp['unit_details'] = $units_to_dispaly;
}
$multi_storey[] = $multi_storey_temp;
}
}
//print_r($multi_storey);
$unit_wise_details['multistorey'] = $multi_storey;
$unit_wise_details['multistorey_over_all_total'] =$over_all_multistorey_total;
//print_r($unit_wise_details);
return array('address_property' => $address_property,'type_of_property' => $type_of_property,'property_owners_name' => $property_owners_name,'property_showing_persons_name' => $property_showing_persons_name,'property_document_proof_visted' => $property_document_proof_visted,'type_of_document_visited' => $type_of_document_visited,'no_of_floors' => $no_of_floors, 'area_coverd' => $area_coverd,'area_uom' => $area_uom,'unit_details' => $unit_wise_details,'property_remark' => $property_remark,'third_check_details' => $third_check_details,'unit_type' => $unit_type);
}
}
?>