Kelola daftar properti, harga sewa, dan ketersediaan unit
Data Penyewa
Catat identitas penyewa, tanggal masuk, dan masa berakhir sewa
Riwayat Pembayaran
Input manual pembayaran sewa & cetak kuitansi digital
Total Filter TerpilihRp 0
Tanggal & Periode
Unit & Penyewa
Nominal & Metode
Status
Aksi
Tambah Unit Kontrakan
Foto Unit
Tambah Penyewa
Catat Pembayaran Sewa
Kuitansi Pembayaran
MyAsset
Bukti Pembayaran Sewa Properti
#INV-001
LUNAS
Tanggal Bayar-
Telah Terima Dari-
Unit Kontrakan-
Untuk Periode-
Metode Bayar-
Catatan-
Total DibayarRp 0
Terima kasih atas pembayaran sewa tepat waktu. Kuitansi ini sah sebagai bukti transaksi.
Koneksi Database MySQL Hosting
Jika file index.html dan api.php diletakkan di folder yang sama pada cPanel/hosting Anda, cukup isi dengan ./api.php.
1. Buat file api.php di Hosting Anda
Skrip ini otomatis membuat tabel MySQL (units, tenants, payments) saat pertama kali diakses. Cukup sesuaikan nama database, user, dan password MySQL Anda di baris atas:
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type, X-PIN-AUTH");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Content-Type: application/json; charset=UTF-8");
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { exit(0); }
// 1. VALIDASI PIN PERSONAL
$pin = $_SERVER['HTTP_X_PIN_AUTH'] ?? '';
if ($pin !== '888999') {
http_response_code(401);
echo json_encode(['success' => false, 'message' => 'PIN Tidak Valid']);
exit;
}
// 2. KONFIGURASI MYSQL HOSTING ANDA
$host = "localhost";
$dbname = "nama_database_anda";
$username = "user_mysql_anda";
$password = "password_mysql_anda";
try {
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $username, $password, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);
// Auto-Create Tabel jika belum ada
$pdo->exec("CREATE TABLE IF NOT EXISTS units (
id VARCHAR(64) PRIMARY KEY,
name VARCHAR(150) NOT NULL,
address TEXT,
price BIGINT DEFAULT 0,
period VARCHAR(30) DEFAULT 'Bulan',
status VARCHAR(30) DEFAULT 'Tersedia',
notes TEXT,
photo LONGTEXT
)");
try { $pdo->exec("ALTER TABLE units ADD COLUMN photo LONGTEXT"); } catch (Exception $e) {}
id VARCHAR(64) PRIMARY KEY,
unitId VARCHAR(64) NOT NULL,
name VARCHAR(150) NOT NULL,
phone VARCHAR(40),
ktp VARCHAR(40),
startDate DATE,
endDate DATE,
notes TEXT
)");
$pdo->exec("CREATE TABLE IF NOT EXISTS payments (
id VARCHAR(64) PRIMARY KEY,
unitId VARCHAR(64) NOT NULL,
tenantName VARCHAR(150) NOT NULL,
amount BIGINT DEFAULT 0,
date DATE,
period VARCHAR(100),
method VARCHAR(50),
status VARCHAR(30),
notes TEXT
)");
$action = $_GET['action'] ?? 'get_all';
if ($action === 'get_all') {
$units = $pdo->query("SELECT * FROM units")->fetchAll(PDO::FETCH_ASSOC);
$tenants = $pdo->query("SELECT * FROM tenants")->fetchAll(PDO::FETCH_ASSOC);
$payments = $pdo->query("SELECT * FROM payments ORDER BY date DESC")->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(['success' => true, 'units' => $units, 'tenants' => $tenants, 'payments' => $payments]);
exit;
}
$input = json_decode(file_get_contents('php://input'), true);
if ($action === 'save_unit') {
$stmt = $pdo->prepare("REPLACE INTO units (id, name, address, price, period, status, notes, photo) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$input['id'], $input['name'], $input['address'], $input['price'], $input['period'], $input['status'], $input['notes'], $input['photo'] ?? '']);
} elseif ($action === 'delete_unit') {
$pdo->prepare("DELETE FROM units WHERE id = ?")->execute([$input['id']]);
$pdo->prepare("DELETE FROM tenants WHERE unitId = ?")->execute([$input['id']]);
} elseif ($action === 'save_tenant') {
$stmt = $pdo->prepare("REPLACE INTO tenants (id, unitId, name, phone, ktp, startDate, endDate, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$input['id'], $input['unitId'], $input['name'], $input['phone'], $input['ktp'], $input['startDate'], $input['endDate'], $input['notes']]);
$pdo->prepare("UPDATE units SET status = 'Terisi' WHERE id = ?")->execute([$input['unitId']]);
} elseif ($action === 'delete_tenant') {
$stmt = $pdo->prepare("SELECT unitId FROM tenants WHERE id = ?");
$stmt->execute([$input['id']]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$pdo->prepare("DELETE FROM tenants WHERE id = ?")->execute([$input['id']]);
if ($row) {
$pdo->prepare("UPDATE units SET status = 'Tersedia' WHERE id = ?")->execute([$row['unitId']]);
}
} elseif ($action === 'save_payment') {
$stmt = $pdo->prepare("REPLACE INTO payments (id, unitId, tenantName, amount, date, period, method, status, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$input['id'], $input['unitId'], $input['tenantName'], $input['amount'], $input['date'], $input['period'], $input['method'], $input['status'], $input['notes']]);
} elseif ($action === 'delete_payment') {
$pdo->prepare("DELETE FROM payments WHERE id = ?")->execute([$input['id']]);
} elseif ($action === 'import_all') {
foreach ($input['units'] as $u) {
$pdo->prepare("REPLACE INTO units (id, name, address, price, period, status, notes, photo) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")->execute([$u['id'], $u['name'], $u['address'], $u['price'], $u['period'], $u['status'], $u['notes'] ?? '', $u['photo'] ?? '']);
}
foreach ($input['tenants'] as $t) {
$pdo->prepare("REPLACE INTO tenants VALUES (?, ?, ?, ?, ?, ?, ?, ?)")->execute([$t['id'], $t['unitId'], $t['name'], $t['phone'], $t['ktp'] ?? '', $t['startDate'], $t['endDate'], $t['notes'] ?? '']);
}
foreach ($input['payments'] as $p) {
$pdo->prepare("REPLACE INTO payments VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")->execute([$p['id'], $p['unitId'], $p['tenantName'], $p['amount'], $p['date'], $p['period'], $p['method'], $p['status'], $p['notes'] ?? '']);
}
}
echo json_encode(['success' => true]);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
}
?>
Konfirmasi Hapus
Apakah Anda yakin ingin menghapus data ini?
Install MyAsset di HP
Tampilan Layar Penuh (WebView)
Android (Google Chrome)
Ketuk ikon titik tiga (⋮) di pojok kanan atas Chrome.
Pilih menu "Install app" atau "Tambahkan ke Layar utama".
Ketuk Install, ikon MyAsset akan muncul di menu HP Anda.
iPhone / iPad (Safari)
Ketuk ikon Share (kotak dengan panah ke atas) di bagian bawah Safari.