Esempio n. 1
0
        ?>
</td>
        <td align="right"><?php 
        echo $tnt->getPhoneNumber();
        ?>
</td>
        <td align="right"><?php 
        echo $tnt->getBusinessName();
        ?>
</td>
        <td align="right"><?php 
        echo $tnt->getPaymentStatus();
        ?>
</td>
        <td align="right"><?php 
        echo Room::findByTenantId($tnt->id)->getRent();
        ?>
</td>
        <td align="right"><?php 
        echo $arrears;
        ?>
</td>
    </tr>
    <?php 
    }
    ?>
    </tbody>
    </table>
    <?php 
} elseif (!empty($prop_id)) {
    echo "<p>The selected property has no tenants in it yet</p>";
    <tr>
        <td><label for="receipt">Receipt No
        <span class="required-field">*</span></label></td>
        <td><input type="text" name="receipt" id="receipt" /></td>
        <td><input type="submit" name="submit" value="Search" /></td>
    </tr>
    </table>
    </form>        
    </div>
    
    <?php 
if (!empty($payment)) {
    ?>
    <?php 
    $tenant = Tenant::findById($payment->getTenantId())->getFullName();
    $room_no = Room::findByTenantId($payment->getTenantId())->getRoomLabel();
    ?>
    <table cellpadding="5" class="bordered">
    <thead>
    <tr>
    	<th>Name of Tenant</th>
        <th>Room No.</th>
        <th>Month</th>
        <th>Amount</th>
        <th>Receipt No</th>
        <th>Date Paid</th>
        <th>Agent</th>
    </tr>
    </thead>
    <tbody>
    <tr>
Esempio n. 3
0
 /**
  * Edit the amount paid as rent for a particular month
  * @param int $amount The new payment amount
  * @return boolean
  */
 public function editPayment($amount)
 {
     $start = $this->_start_date;
     $end = $this->_end_date;
     $tenant_id = $this->_tid;
     $rent_pm = Room::findByTenantId($tenant_id)->getRent();
     $rent_pm = (int) str_replace(',', '', $rent_pm);
     $amount = (int) str_replace(',', '', $amount);
     $curr_amount = (int) $this->_amount;
     $db = Database::getInstance();
     $mysqli = $db->getConnection();
     if (PaymentStatus::paymentStatusOK($tenant_id, $start, $end) && $amount < $rent_pm) {
         // Change payment status for tenant during period
         $statusObj = PaymentStatus::findByPeriod($tenant_id, $start, $end);
         $statusObj->setStatus(0);
         // Create a new arrears object
         $arrears = new Arrears();
         $bal_owed = $rent_pm - $amount;
         $arrears->setTenantId($tenant_id);
         $arrears->setStartPeriod($start);
         $arrears->setEndPeriod($end);
         $arrears->setAmountOwed($bal_owed);
         // Change Amount
         $this->setPaymentAmount($amount);
         $mysqli->autocommit(false);
         $arrears->save();
         $statusObj->save();
         $this->save();
         if (!$mysqli->commit()) {
             $mysqli->rollback();
             $mysqli->autocommit(true);
             return false;
         } else {
             $mysqli->autocommit(true);
             return true;
         }
     } elseif (!PaymentStatus::paymentStatusOK($tenant_id, $start, $end) && $amount == $rent_pm) {
         // Change payment status for tenant during period
         $statusObj = PaymentStatus::findByPeriod($tenant_id, $start, $end);
         $statusObj->setStatus(1);
         // Find corresponding arrears
         $arrears = Arrears::findByPeriodForTenant($tenant_id, $start, $end);
         // Change Amount
         $this->setPaymentAmount($amount);
         $mysqli->autocommit(false);
         $arrears->delete();
         $statusObj->save();
         $this->save();
         if (!$mysqli->commit()) {
             $mysqli->rollback();
             $mysqli->autocommit(true);
             return false;
         } else {
             $mysqli->autocommit(true);
             return true;
         }
     } elseif (!PaymentStatus::paymentStatusOK($tenant_id, $start, $end) && $amount < $rent_pm) {
         // reduce amount paid and increase amount owed
         $arrears = Arrears::findByPeriodForTenant($tenant_id, $start, $end);
         $new_arrears = $rent_pm - $amount;
         $arrears->setAmountOwed($new_arrears);
         $this->setPaymentAmount($amount);
         $mysqli->autocommit(false);
         $arrears->save();
         $this->save();
         if (!$mysqli->commit()) {
             $mysqli->rollback();
             $mysqli->autocommit(true);
             return false;
         } else {
             $mysqli->autocommit(true);
             return true;
         }
     }
 }
Esempio n. 4
0
    <tr>
        <th>Name of Tenant</th>
        <th>Room Label</th>
        <th>Business Name</th>
        <th>Details</th>
    </tr>
    </thead>
    <tbody>
    <?php 
    $tenants = Tenant::findByPropertyId($property->id);
    ?>
    <?php 
    foreach ($tenants as $tenant) {
        ?>
    <?php 
        $room = Room::findByTenantId($tenant->id);
        ?>
    <?php 
        /**echo "Tenant: ";
           echo "<tt></pre>".var_dump($tenant)."</pre></tt>";
           echo "Room: ";
           echo "<tt><pre>".var_dump($room)."</pre></tt>";*/
        ?>
    <tr>
        <td><?php 
        echo $tenant->getFullName();
        ?>
</td>
        <td><?php 
        echo $room->getRoomLabel();
        ?>
?>
    
    <?php 
if (!empty($tenants)) {
    ?>
    <?php 
    foreach ($tenants as $tnt) {
        ?>
    <p><a href="tenant.php?tid=<?php 
        echo $tnt->id;
        ?>
"><?php 
        echo $tnt->getFullName();
        ?>
</a>&nbsp;&nbsp;<?php 
        echo "Room No: " . Room::findByTenantId($tnt->id)->getRoomLabel();
        ?>
</p>
    <?php 
    }
    ?>
    <?php 
} elseif (empty($tenants) && !empty($name)) {
    echo "<p>Search returned no results</p>";
}
?>
    
    </div>

<?php 
include_layout_template('admin_footer.php');
 /**
  * Record rent arrears for a particular month in the event
  * that no amont was paid as rent
  * @param int $tenant_id The ID used to identify the tenant
  * @param string $start Date string specifying start of the period
  * @param string $end Date string specifying end of the period
  * @return boolean
  */
 public function recordArrears($tenant_id, $start, $end)
 {
     $db = Database::getInstance();
     $mysqli = $db->getConnection();
     // Get monthly rental amount
     $rent_pm = Room::findByTenantId($tenant_id)->getRent();
     $rent_pm = (int) str_replace(',', '', $rent_pm);
     // Create a new arrears object to hold arrears information
     //$arrears = new Arrears();
     $this->setTenantId($tenant_id);
     $this->setAmountOwed($rent_pm);
     $this->setStartPeriod($start);
     $this->setEndPeriod($end);
     // Payment Status set to 0 - denoting incompletion
     $pst = new PaymentStatus();
     $pst->setTenantId($tenant_id);
     $pst->setStartPeriod($start);
     $pst->setEndPeriod($end);
     $pst->setStatus(0);
     $mysqli->autocommit(false);
     $this->save();
     $pst->save();
     if (!$mysqli->commit()) {
         $mysqli->rollback();
         $mysqli->autocommit(true);
         return false;
     } else {
         $mysqli->autocommit(true);
         return true;
     }
 }
 /**
  * Move out a tenant from a room
  * @return boolean
  */
 public function moveOut()
 {
     $db = Database::getInstance();
     $mysqli = $db->getConnection();
     // Initantiate old tenant object and set its
     // properties to correspond to current objects property values
     $this->_date_left = strftime("%Y-%m-%d", time());
     $this->_active = 0;
     $mysqli->autocommit(false);
     // Set room's status to vacant
     $room = Room::findByTenantId($this->id);
     $room->setRoomStatus(0);
     $room->unsetTenantId();
     if (!$this->save()) {
         $mysqli->rollback();
         $mysqli->autocommit(true);
         return false;
     }
     if (!$room->save()) {
         $mysqli->rollback();
         $mysqli->autocommit(true);
         return false;
     }
     // Try to commit all the changes to database
     if (!$mysqli->commit()) {
         $mysqli->rollback();
         $mysqli->autocommit(true);
         return false;
     }
     return true;
 }
        }
    }
}
/////////////////////////////////////////////////////////////////
///////////////////////// PROCESS SUBMIT ////////////////////////
/////////////////////////////////////////////////////////////////
if (isset($_POST['submit'])) {
    $start_date = $_POST['start_date'];
    $end_date = $_POST['end_date'];
    $amount_owed = $_POST['amount'];
    if (empty($start_date) || empty($end_date) || empty($amount_owed)) {
        $err = "Form fields marked with an asterix are required";
    } else {
        $arrears = Arrears::findById($arrears_id);
        $amount = (int) $arrears->removeCommasFromCurrency($_POST['amount']);
        $rent_pm = Room::findByTenantId($tenant_id)->getRent();
        $rent_pm = (int) $arrears->removeCommasFromCurrency($rent_pm);
        if ($amount > $rent_pm) {
            $err = "Arrears cannot exceed the tenants monthly rent";
        } elseif (PaymentStatus::paymentStatusOK($tenant_id, $start, $end)) {
            $mesg = "Tenant already paid the full rent for the specified period and therefore cannot have arrears";
            $session->message($mesg);
            redirect_to("tenant_arrears.php?tid={$tenant_id}");
        } else {
            $arrears->setTenantId($tenant->id);
            $arrears->setStartPeriod($start_date);
            $arrears->setEndPeriod($end_date);
            $arrears->setAmountOwed($amount_owed);
            if ($arrears->save()) {
                $mesg = "Changes Saved";
                $session->message($mesg);
 /**
  * Set the rid property to the ID of the
  * room occupied by the tenant
  * @param int $tenant_id
  */
 public function setRoomId($tenant_id)
 {
     $room = Room::findByTenantId($tenant_id);
     $this->_rid = $room->id;
 }