///////////////////////// PROCESS SUBMIT ////////////////////////
/////////////////////////////////////////////////////////////////
if (isset($_POST['submit'])) {
    $date_paid = $_POST['paid'];
    $amount = $_POST['amount'];
    if (empty($date_paid) || empty($amount)) {
        $err = "Form fields marked with an asterix are required";
    } else {
        $tenant_id = (int) $_GET['tid'];
        $dpt = new DepositKPLC();
        $dpt->setTenantId($tenant_id);
        $dpt->setRoomId($tenant_id);
        $dpt->setTenantName($tenant_id);
        $dpt->setPaymentAmount($amount);
        $dpt->generateReceiptNo();
        $dpt->setAgent();
        $dpt->setDatePaid($date_paid);
        /**echo "<tt><pre>".var_export($dpt, true)."</pre></tt>";
        			echo "Last Receipt No: ";
        			echo $dpt->_lastReceiptNo().'<br />';*/
        /**echo "Tenant ID: ";
        			echo $tenant_id;*/
        if ($dpt->save()) {
            Logger::getInstance()->logAction("KPLC DEPOSIT", $amount, "KPLC Deposit of {$tenant->getFullName()}");
            $mesg = "Payment posted";
            $session->message($mesg);
            redirect_to("receipt.php?tid={$tenant_id}&type=deposit_kplc");
        } else {
            $err = "An error occured preventing the payment from being posted";
        }
    }