403Webshell
Server IP : 72.60.21.38  /  Your IP : 216.73.216.25
Web Server : LiteSpeed
System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : u390967363 ( 390967363)
PHP Version : 8.2.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/u390967363/domains/aibenproperties.com/public_html/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/u390967363/domains/aibenproperties.com/public_html/app/ajax_get_rental_details.php
<?php
require_once 'includes/db.php';
require_once 'includes/functions.php';

header('Content-Type: application/json');

if (!isset($_GET['id'])) {
    echo json_encode(['success' => false, 'error' => 'No ID provided']);
    exit;
}

$lease_id = intval($_GET['id']);

try {
    // 1. Fetch Lease Details
    $query = "SELECT l.*, 
              p.title as property_title, p.id as property_id, p.address as property_address, p.price as property_price,
              u.name as tenant_name, u.email as tenant_email,
              a.name as agent_name
              FROM leases l
              JOIN properties p ON l.property_id = p.id
              JOIN users u ON l.tenant_id = u.id
              LEFT JOIN users a ON l.agent_id = a.id
              WHERE l.id = ?";
    
    $stmt = $pdo->prepare($query);
    $stmt->execute([$lease_id]);
    $lease = $stmt->fetch(PDO::FETCH_ASSOC);

    if (!$lease) {
        echo json_encode(['success' => false, 'error' => 'Lease not found']);
        exit;
    }

    $lease['tenant_phone'] = 'N/A'; // Mock phone since column missing

    // 2. Fetch Payment History (Mock or Real)
    // Checking if payments table has lease_id or similar. 
    // For now, we'll try to fetch from 'payments' if it has a 'lease_id' column, otherwise return empty or mock.
    $payments = [];
    try {
        $stmt = $pdo->prepare("SELECT * FROM payments WHERE lease_id = ? ORDER BY payment_date DESC");
        $stmt->execute([$lease_id]);
        $payments = $stmt->fetchAll(PDO::FETCH_ASSOC);
    } catch (Exception $e) {
        // If table or column doesn't exist, we'll send an empty array or mock data for demo
        // For demo purposes if no payments found:
        if (empty($payments)) {
            $payments = [
                [
                    'id' => 1,
                    'amount' => $lease['deposit_amount'],
                    'payment_date' => $lease['start_date'],
                    'type' => 'Deposit',
                    'status' => 'completed',
                    'reference' => 'DEP-' . $lease_id
                ],
                [
                    'id' => 2,
                    'amount' => $lease['rent_amount'],
                    'payment_date' => $lease['start_date'],
                    'type' => 'Rent',
                    'status' => 'completed',
                    'reference' => 'RNT-' . $lease_id . '-01'
                ]
            ];
        }
    }

    // 3. Fetch Documents (Mock or Real)
    // Similar logic, assuming a documents table or mock
    $documents = [
        [
            'id' => 1,
            'title' => 'Lease Agreement',
            'type' => 'pdf',
            'date' => $lease['created_at'],
            'url' => '#'
        ],
        [
            'id' => 2,
            'title' => 'Property Inventory',
            'type' => 'pdf',
            'date' => $lease['start_date'],
            'url' => '#'
        ]
    ];

    // 4. Calculate Stats
    $days_total = (strtotime($lease['end_date']) - strtotime($lease['start_date'])) / (60 * 60 * 24);
    $days_passed = (time() - strtotime($lease['start_date'])) / (60 * 60 * 24);
    $progress = $days_total > 0 ? min(100, max(0, ($days_passed / $days_total) * 100)) : 0;

    echo json_encode([
        'success' => true,
        'lease' => $lease,
        'payments' => $payments,
        'documents' => $documents,
        'stats' => [
            'progress' => round($progress),
            'days_remaining' => max(0, round($days_total - $days_passed)),
            'total_value' => ($lease['rent_amount'] * 12) // Rough estimate if monthly
        ]
    ]);

} catch (Exception $e) {
    echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}

Youez - 2016 - github.com/yon3zu
LinuXploit