$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 { // Continue with processing $rent = new Rent(); $rent->setPropertyId($prop_id); $rent->setTenantId($tenant_id); $rent->setStartPeriod($start_date); $rent->setEndPeriod($end_date); $rent->setDatePaid(); $rent->setPaymentAmount($amount); $rent->generateReceiptNo(); $rent->setPaymentMode($mode); $rent->setReceivingAgent($session); $rent->setRemarks($remarks); //echo var_dump($rent); if ($tenant->payRent($rent, $start_date, $end_date)) { Logger::getInstance()->logAction("RENT", $amount, "Rent of {$tenant->getFullName()} for {$rent->getMonth()}"); $last_id = Rent::lastPaymentId(); /*$session->sessionVar('start', $start_date); $session->sessionVar('end', $end_date)*/ if ($mode == "cheque") { // Cheque Payment $session->sessionVar("type", "rent");