/**
  * Calculate the no. of months in the specified period
  * @param string $start Date string specifying start of period
  * @param string $end Date string specifying end of period
  * @return int $num_months
  */
 public function getNumMonthsInPeriod($start, $end)
 {
     $datetime_start = new DateTime($start);
     $datetime_end = new DateTime($end);
     $interval = $datetime_end->diff($datetime_start);
     //$num_months = $interval->format("%m") + 1;
     $num_days = $interval->days + 1;
     //$valid_diff = array(28, 29, 30, 31);
     if (valid_date_range($start, $end)) {
         $num_months = 1;
     } else {
         $num_months = floor($num_days / 29.5);
     }
     return $num_months;
 }
Example #2
0
    		echo 'No. of Months: ';
    		echo var_dump($num_months);
    		echo 'No. of Days: ';
    		echo var_dump($num_days);
    		if(in_array($num_days, $valid_diff)){
    			echo "One Month<br />";	
    		} else {
    			echo "Not one month<br />";	
    		}
    		echo 'Valid Date Range: ';
    		echo var_dump(valid_date_range($start, $end));
    		echo 'Month One == Month Two: ';
    		echo var_dump($month_one == $month_two);*/
    if (empty($prop_id) || empty($start) || empty($end)) {
        $err = "Form fields marked with an asterix are required";
    } elseif (!valid_date_range($start, $end)) {
        $err = "Rent payment status of tenants can only be specified monthly. Specify a month by entering the start and end dates of the month";
    } else {
        $month = get_month_from_date($start);
        $property = Property::findById($prop_id);
        $tenants = Tenant::showPaymentStatusOfTenantsByProperty($prop_id, $start, $end);
    }
}
include_layout_template('admin_header.php');
?>

	<div id="container">
    <h3>Actions</h3>
    <div id="side-bar">
	<?php 
$actions = array("tenants" => "Tenants", "tenant_search" => "Search Tenant", "tenants_old" => "Previous Tenants", "payment_search" => "Search Payment");
    }
}
/////////////////////////////////////////////////////////////////
///////////////////////// PROCESS SUBMIT ////////////////////////
/////////////////////////////////////////////////////////////////
if (isset($_POST['submit'])) {
    $prop_id = $session->sessionVar("pid");
    $tenant_id = $session->sessionVar("tid");
    $start_date = $_POST['start_date'];
    $end_date = $_POST['end_date'];
    $amount = $_POST['amount'];
    $mode = $_POST['mode'];
    $remarks = $_POST['remarks'];
    if (empty($start_date) || empty($end_date) || empty($amount)) {
        $err = "Form fields marked with an asterx are required";
    } elseif (!valid_date_range($start_date, $end_date)) {
        $mesg = "Rent payments can only be entered monthly. Specify a month ";
        $mesg .= "by choosing the start and end dates of the month";
        $session->message($mesg);
        redirect_to("tenant.php?tid={$tenant_id}");
    } elseif ($tenant->hasPaidFullRent($tenant_id, $start_date, $end_date)) {
        $mesg = "This tenant has already paid the rent for the specified period";
        $session->message($mesg);
        redirect_to("tenant.php?tid={$tenant_id}");
    } elseif ($tenant->hasPaidPartialRent($tenant_id, $start_date, $end_date)) {
        $mesg = "This tenant has paid PART of the rent for the specified period. ";
        $mesg .= "Check the amount of arrears owed by the tenant for the period ";
        $mesg .= "you've specified and deduct the necessary amount from it";
        $session->message($mesg);
        redirect_to("tenant.php?tid={$tenant_id}");
    } else {