Rentava Documentation

Rent Availability Controller Documentation

File: /controllers/rentava.php

Purpose: Displays rental product availability and rental store status for equipment and product rental operations

Last Updated: December 20, 2024

Total Functions: 1

Lines of Code: ~145

---

๐Ÿ“‹ Overview

The Rent Availability Controller is a simple display controller that provides visibility into the rental inventory system. It shows available rental products and displays the rental store history, giving users an overview of what equipment/products are available for rental and their rental history. This controller is part of the rental management system separate from real estate operations.

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Primary Tables (Read-Only Operations)

Table NamePurposeKey Columns
**rentproducts**Rental product master datarentproductid, name
**rentstore**Rental inventory statusid, rentproductid, status, dates
### Reference Tables

Table NamePurposeKey Columns
**supplier**Equipment supplierssupplierid, suppliername
**client**Rental customersclientid, clientname
**save**Cash registers/safessaveid, savename
**rentbill**Rental billsrentbillid, clientid
**rentbillprop**Rental bill propertiesid, billid, productid
### Supporting DAO Classes

DAO ClassEntityPurpose
**RentproductMySqlDAO**RentproductProduct data access
**RentstoreMySqlDAO**RentstoreStore data access
**SupplierMySqlDAO**SupplierSupplier data access
**ClientMySqlDAO**ClientClient data access
**SaveMySqlDAO**SaveSave data access
**RentbillMySqlDAO**RentbillBill data access
**RentbillpropMySqlDAO**RentbillpropBill properties access
---

๐Ÿ”‘ Key Functions

1. Default Action - Rental Availability Display

Location: Line 117

Purpose: Displays the main rental availability interface with product list and store history

Function Signature:

// Triggered when: do parameter is empty
if (empty($do))

Process Flow:

1. Initialize DAO Objects - Create all necessary data access objects

2. Load Authentication - Include permission checks

3. Query Rental Products - Get all available rental products

4. Query Store History - Get all rental store records

5. Enhance Store Data - Add product names to store records

6. Assign Template Variables - Pass data to Smarty template

7. Display Template - Show rental availability interface

DAO Initialization:

// Rental-specific DAOs
$rentProducts = new Rentproduct();
$myrentProducts = new RentproductMySqlDAO();
$extrentProducts = new RentproductMySqlExtDAO();

$rentStore = new Rentstore();
$myrentStore = new RentstoreMySqlDAO();
$extrentStore = new RentstoreMySqlExtDAO();

// Supporting DAOs
$supplier = new Supplier();
$client = new Client();
$save = new Save();
$rentbill = new Rentbill();
$rentbillpro = new Rentbillprop();

Data Processing:

// Get all rental products
$products = $myrentProducts->queryAll();

// Get all rental store records
$allpros = $myrentStore->queryAll();

// Enhance store records with product names
foreach ($allpros as $sinpro) {
    $productinfo = $myrentProducts->load($sinpro->rentproductid);
    $sinpro->productname = $productinfo->name;
}

Template Assignment:

$smarty->assign('products', $products);
$smarty->assign('allpros', $allpros);
$smarty->assign('showsearch', 1);
$smarty->display("rent/reports/rentava.html");

---

๐Ÿ”„ Workflows

Workflow 1: Rental Availability Check

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
START: View Rental Availability
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
1Initialize System Components
- Load authentication
- Initialize DAO objects
- Set up accounting components
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
2Query Rental Products
- Load all rental products from database
- Get product details (name, ID, etc.)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
3Query Rental Store Status
- Load all rental store records
- Get current status of rental items
- Include rental history information
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
4Enhance Data with Product Names
FOR EACH store record:
โ†’ Look up product details
โ†’ Add product name to record
โ”‚ โ””โ”€โ†’ Prepare for display โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
5Display Rental Availability Interface
- Show product list
- Show store status/history
- Enable search functionality
- Display via rentava.html template
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

๐ŸŒ URL Routes & Actions

URL ParameterFunction CalledDescription
`do=` (empty)Default displayShow rental availability interface
### Template Variables Assigned

Product Data:

Global Variables:

---

๐Ÿงฎ Calculation Methods

Product Name Resolution

foreach ($allpros as $sinpro) {
    $productinfo = $myrentProducts->load($sinpro->rentproductid);
    $sinpro->productname = $productinfo->name;
}

Search Functionality Setup

$showsearch = 1;
$smarty->assign('showsearch', $showsearch);

---

๐Ÿ”’ Security & Permissions

Authentication Check

include_once("../public/authentication.php");

Global Security Includes

include("../public/impOpreation.php");  // Main operations file
include_once("../public/config.php");   // Configuration
include("../public/include_dao.php");   // DAO includes

Session Management

---

๐Ÿ“Š Performance Considerations

Database Queries

1. Query Patterns:

- Simple queryAll() operations on rental tables

- Individual load() operations in loop for product names

- No complex joins or aggregations

2. Optimization Opportunities:

- Could optimize product name lookup with single JOIN query

- Consider caching product data for frequently accessed items

Current Implementation:

// Less efficient: N+1 query pattern
$allpros = $myrentStore->queryAll();
foreach ($allpros as $sinpro) {
    $productinfo = $myrentProducts->load($sinpro->rentproductid);  // Individual query per item
    $sinpro->productname = $productinfo->name;
}

Optimized Alternative:

-- Single query approach
SELECT rs.*, rp.name as productname 
FROM rentstore rs 
LEFT JOIN rentproducts rp ON rs.rentproductid = rp.rentproductid;

Memory Usage

---

๐Ÿ› Common Issues & Troubleshooting

1. Missing Product Names

Issue: Store records show without product names

Cause: Broken foreign key relationships or missing product records

Debug:

-- Check for orphaned store records
SELECT rs.id, rs.rentproductid, rp.rentproductid as product_exists
FROM rentstore rs
LEFT JOIN rentproducts rp ON rs.rentproductid = rp.rentproductid
WHERE rp.rentproductid IS NULL;

Fix:

-- Remove orphaned records or add missing products
DELETE FROM rentstore WHERE rentproductid NOT IN (SELECT rentproductid FROM rentproducts);

2. Empty Product List

Issue: No products appear in availability list

Cause: Empty rentproducts table or DAO connection issues

Debug:

-- Check product table
SELECT COUNT(*) as product_count FROM rentproducts;
SELECT * FROM rentproducts LIMIT 5;

3. Template Display Issues

Issue: Page loads but shows no data

Cause: Template path issues or variable assignment problems

Debug:

// Add before template display
echo "Products count: " . count($products) . "<br>";
echo "Store records count: " . count($allpros) . "<br>";
var_dump($products);

4. DAO Initialization Errors

Issue: Fatal errors on DAO object creation

Cause: Missing DAO class files or incorrect include paths

Check:

// Verify DAO files exist
file_exists('../models/mysql/RentproductMySqlDAO.class.php');
file_exists('../models/mysql/RentstoreMySqlDAO.class.php');

---

๐Ÿงช Testing Scenarios

Test Case 1: Basic Functionality

1. Navigate to rentava.php (no parameters)
2. Verify page loads without errors
3. Check that product list displays
4. Verify store records show with product names
5. Confirm search functionality is enabled

Test Case 2: Data Integrity

1. Check that all store records have corresponding products
2. Verify product names are correctly resolved
3. Test with empty product table
4. Test with empty store table
5. Verify graceful handling of missing data

Test Case 3: Performance

1. Test with large number of products (100+)
2. Test with large number of store records (1000+)
3. Measure page load time
4. Check memory usage
5. Verify responsiveness with large datasets

Debug Mode Enable

// Add at top of controller for debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Debug data loading
echo "<pre>";
print_r($products);
print_r($allpros);
echo "</pre>";

---

๐Ÿ“š Related Documentation

File Dependencies

Core Includes:

Template Files:

---

Documented By: AI Assistant

Review Status: โœ… Complete

Next Review: When rental system changes occur