|
Server IP : 217.21.85.138 / Your IP : 216.73.216.103 Web Server : LiteSpeed System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u915722082 ( 915722082) PHP Version : 7.4.33 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 Directory (0755) : /home/u915722082/public_html/js/../pms/config/../admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
session_start();
if (!isset($_SESSION['admin_id'])) {
header("Location: login.php");
exit;
}
require_once '../config/config.php';
require_once '../config/db.php';
$proposal_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if (!$proposal_id) {
header("Location: proposals.php");
exit;
}
// Get proposal details
$query = "SELECT p.*,
c.customer_name, c.customer_code, c.contact_person, c.email, c.phone,
c.address_line1, c.address_line2, c.city, c.state, c.pincode, c.country,
c.gst_number, c.pan_number,
t.template_name, t.introduction, t.company_overview, t.terms_conditions, t.conclusion, t.color_scheme
FROM tbl_proposals p
LEFT JOIN tbl_customers c ON p.customer_id = c.customer_id
LEFT JOIN tbl_proposal_templates t ON p.template_id = t.template_id
WHERE p.proposal_id = $proposal_id";
$result = mysqli_query($con, $query);
if (!$result || mysqli_num_rows($result) === 0) {
die("Proposal not found");
}
$proposal = mysqli_fetch_assoc($result);
$line_items = json_decode($proposal['proposal_items'], true) ?? [];
// Get template color (from template or default)
$color = $proposal['color_scheme'] ?? '#1E88E5';
// Smart text color detection - if dark color, use white text
function getTextColor($hexColor) {
// Remove # if present
$hex = str_replace('#', '', $hexColor);
// Convert to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// Calculate brightness (perceived luminance)
$brightness = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
// If dark color (brightness < 128), use white text, else use black
return ($brightness < 128) ? '#FFFFFF' : '#1e1e2d';
}
$textColor = getTextColor($color);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="../" />
<title><?php echo $proposal['proposal_code']; ?> - View Proposal</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700" />
<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
<style>
@media print {
.no-print { display: none !important; }
body { background: white !important; }
.app-sidebar, .app-header, .app-toolbar, .app-footer { display: none !important; }
.app-wrapper { padding: 0 !important; }
.app-main { padding: 0 !important; margin: 0 !important; }
#kt_app_content_container { padding: 0 !important; max-width: 100% !important; }
.proposal-card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
.proposal-card {
background: white;
box-shadow: 0 0 20px rgba(0,0,0,0.08);
}
.header-section {
background: linear-gradient(135deg, <?php echo $color; ?> 0%, <?php echo $color; ?>dd 100%);
color: <?php echo $textColor; ?>;
padding: 40px;
}
.info-box {
background: #f9fafb;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 20px;
}
.table-modern {
width: 100%;
border-collapse: collapse;
}
.table-modern thead th {
background: <?php echo $color; ?>;
color: <?php echo $textColor; ?>;
padding: 15px;
text-align: left;
font-weight: 600;
border: none;
}
.table-modern tbody td {
padding: 12px 15px;
border-bottom: 1px solid #e5e7eb;
}
.table-modern tbody tr:hover {
background: #f9fafb;
}
.totals-table {
width: 100%;
margin-top: 20px;
}
.totals-table td {
padding: 10px 15px;
}
.grand-total-row {
background: <?php echo $color; ?>;
color: <?php echo $textColor; ?>;
font-weight: bold;
font-size: 1.3rem;
}
.section-header {
background: #f3f4f6;
padding: 12px 20px;
margin: 30px 0 15px 0;
border-left: 4px solid <?php echo $color; ?>;
font-weight: 600;
font-size: 1.1rem;
}
.color-accent {
color: <?php echo $color; ?>;
}
.border-accent {
border-color: <?php echo $color; ?>;
}
</style>
</head>
<body id="kt_app_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true"
data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true"
data-kt-app-sidebar-hoverable="true" data-kt-app-sidebar-push-header="true"
data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true"
data-kt-app-toolbar-enabled="true" class="app-default">
<script>
var defaultThemeMode = "light";
var themeMode;
if (document.documentElement) {
if (document.documentElement.hasAttribute("data-bs-theme-mode")) {
themeMode = document.documentElement.getAttribute("data-bs-theme-mode");
} else {
if (localStorage.getItem("data-bs-theme") !== null) {
themeMode = localStorage.getItem("data-bs-theme");
} else {
themeMode = defaultThemeMode;
}
}
if (themeMode === "system") {
themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
document.documentElement.setAttribute("data-bs-theme", themeMode);
}
</script>
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
<div class="app-page flex-column flex-column-fluid" id="kt_app_page">
<?php include 'includes/header.php'; ?>
<div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
<?php include 'includes/sidebar.php'; ?>
<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
<div class="d-flex flex-column flex-column-fluid">
<!-- Toolbar -->
<div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6 no-print">
<div id="kt_app_toolbar_container" class="app-container container-xxl d-flex flex-stack">
<div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
<h1 class="page-heading d-flex text-gray-900 fw-bold fs-3 flex-column my-0">
📄 View Proposal
</h1>
<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
<li class="breadcrumb-item text-muted">
<a href="admin/proposals.php" class="text-muted text-hover-primary">Proposals</a>
</li>
<li class="breadcrumb-item">
<span class="bullet bg-gray-500 w-5px h-2px"></span>
</li>
<li class="breadcrumb-item text-muted"><?php echo $proposal['proposal_code']; ?></li>
</ul>
</div>
<div class="d-flex align-items-center gap-2">
<button onclick="window.print()" class="btn btn-light-primary">
<i class="ki-duotone ki-printer fs-2">
<span class="path1"></span>
<span class="path2"></span>
</i>
Print
</button>
<button onclick="generatePDF()" class="btn btn-primary">
<i class="ki-duotone ki-file-down fs-2">
<span class="path1"></span>
<span class="path2"></span>
</i>
Download PDF
</button>
<a href="admin/proposals.php" class="btn btn-light">
<i class="ki-duotone ki-arrow-left fs-2">
<span class="path1"></span>
<span class="path2"></span>
</i>
Back
</a>
</div>
</div>
</div>
<!-- Content -->
<div id="kt_app_content" class="app-content flex-column-fluid">
<div id="kt_app_content_container" class="app-container container-xxl">
<div class="card proposal-card" id="proposal-content">
<!-- Header Section - Uses Template Color -->
<div class="header-section">
<div class="row align-items-center">
<div class="col-md-6">
<h1 class="fw-bolder mb-2" style="font-size: 2rem; color: <?php echo $textColor; ?>;">BUSINESS PROPOSAL</h1>
<h2 class="mb-0" style="font-size: 1.5rem; color: <?php echo $textColor; ?>;"><?php echo htmlspecialchars($proposal['proposal_code']); ?></h2>
</div>
<div class="col-md-6 text-end">
<div class="mb-2">
<span class="me-2" style="color: <?php echo $textColor; ?>88;">Date:</span>
<span class="fw-bold" style="color: <?php echo $textColor; ?>;"><?php echo date('d-M-Y', strtotime($proposal['proposal_date'])); ?></span>
</div>
<div>
<span class="me-2" style="color: <?php echo $textColor; ?>88;">Valid Until:</span>
<span class="fw-bold" style="color: <?php echo $textColor; ?>;"><?php echo date('d-M-Y', strtotime($proposal['valid_until'])); ?></span>
</div>
</div>
</div>
</div>
<!-- Card Body -->
<div class="card-body p-10">
<!-- Customer & Proposal Info -->
<div class="row g-5 mb-10">
<!-- Prepared For -->
<div class="col-md-6">
<div class="info-box">
<h4 class="fw-bold text-gray-900 mb-5">PREPARED FOR</h4>
<div class="fs-4 fw-bold text-gray-900 mb-4">
<?php echo htmlspecialchars($proposal['customer_name']); ?>
</div>
<div class="mb-3">
<span class="text-gray-600 fw-semibold">Contact Person:</span>
<span class="text-gray-900 ms-2"><?php echo htmlspecialchars($proposal['contact_person']); ?></span>
</div>
<div class="mb-3">
<span class="text-gray-600 fw-semibold">Email:</span>
<span class="text-gray-900 ms-2"><?php echo htmlspecialchars($proposal['email']); ?></span>
</div>
<div class="mb-3">
<span class="text-gray-600 fw-semibold">Phone:</span>
<span class="text-gray-900 ms-2"><?php echo htmlspecialchars($proposal['phone']); ?></span>
</div>
<?php if($proposal['gst_number']): ?>
<div class="mb-3">
<span class="text-gray-600 fw-semibold">GST No:</span>
<span class="text-gray-900 ms-2"><?php echo htmlspecialchars($proposal['gst_number']); ?></span>
</div>
<?php endif; ?>
<div class="mt-4 pt-3 border-top">
<div class="text-gray-700">
<?php echo htmlspecialchars($proposal['address_line1']); ?>
<?php if($proposal['address_line2']): ?>, <?php echo htmlspecialchars($proposal['address_line2']); ?><?php endif; ?><br>
<?php echo htmlspecialchars($proposal['city']); ?>, <?php echo htmlspecialchars($proposal['state']); ?> - <?php echo htmlspecialchars($proposal['pincode']); ?>
</div>
</div>
</div>
</div>
<!-- Proposal Title -->
<div class="col-md-6">
<div class="info-box h-100">
<h4 class="fw-bold text-gray-900 mb-5">PROPOSAL TITLE</h4>
<div class="fs-3 fw-bold text-gray-900 mb-5">
<?php echo htmlspecialchars($proposal['proposal_title']); ?>
</div>
<div class="mb-3">
<span class="text-gray-600 fw-semibold">Template:</span>
<span class="badge badge-light-primary ms-2"><?php echo htmlspecialchars($proposal['template_name']); ?></span>
</div>
<div class="mb-3">
<span class="text-gray-600 fw-semibold">Status:</span>
<?php
$status_colors = [
'Draft' => 'warning',
'Sent' => 'info',
'Accepted' => 'success',
'Rejected' => 'danger',
'Expired' => 'secondary'
];
$badge_color = $status_colors[$proposal['status']] ?? 'secondary';
?>
<span class="badge badge-light-<?php echo $badge_color; ?> ms-2 fs-6">
<?php echo $proposal['status']; ?>
</span>
</div>
<div class="mt-4">
<span class="text-gray-600 fw-semibold">Theme Color:</span>
<span class="badge ms-2" style="background: <?php echo $color; ?>; color: <?php echo $textColor; ?>;">
<?php echo $color; ?>
</span>
</div>
</div>
</div>
</div>
<div class="separator separator-dashed my-10"></div>
<!-- Line Items Section -->
<div class="section-header">PROJECT SCOPE & PRICING</div>
<div class="table-responsive">
<table class="table-modern">
<thead>
<tr>
<th style="width: 5%;">#</th>
<th style="width: 30%;">Item / Service</th>
<th style="width: 35%;">Description</th>
<th style="width: 10%; text-align: center;">Qty</th>
<th style="width: 10%; text-align: right;">Rate (₹)</th>
<th style="width: 10%; text-align: right;">Amount (₹)</th>
</tr>
</thead>
<tbody>
<?php $counter = 1; foreach($line_items as $item): ?>
<tr>
<td class="text-center fw-bold"><?php echo $counter; ?></td>
<td class="fw-bold text-gray-900"><?php echo htmlspecialchars($item['name']); ?></td>
<td class="text-gray-600"><?php echo htmlspecialchars($item['description']); ?></td>
<td class="text-center"><?php echo $item['quantity']; ?></td>
<td class="text-end"><?php echo number_format($item['rate'], 2); ?></td>
<td class="text-end fw-bold"><?php echo number_format($item['amount'], 2); ?></td>
</tr>
<?php $counter++; endforeach; ?>
</tbody>
</table>
</div>
<!-- Totals - Uses Template Color -->
<div class="d-flex justify-content-end">
<div style="width: 400px;">
<table class="totals-table">
<tr style="background: #f9fafb;">
<td class="text-end fw-bold">Subtotal:</td>
<td class="text-end fw-bold">₹<?php echo number_format($proposal['total_amount'], 2); ?></td>
</tr>
<?php if($proposal['discount_percentage'] > 0): ?>
<tr style="background: #fef2f2;">
<td class="text-end">Discount (<?php echo $proposal['discount_percentage']; ?>%):</td>
<td class="text-end text-danger">-₹<?php echo number_format($proposal['discount_amount'], 2); ?></td>
</tr>
<?php endif; ?>
<tr class="grand-total-row">
<td class="text-end">GRAND TOTAL:</td>
<td class="text-end">₹<?php echo number_format($proposal['final_amount'], 2); ?></td>
</tr>
</table>
</div>
</div>
<!-- Template Content Sections -->
<?php if($proposal['introduction']): ?>
<div class="section-header">INTRODUCTION</div>
<div class="text-gray-700 mb-8">
<?php echo $proposal['introduction']; ?>
</div>
<?php endif; ?>
<?php if($proposal['company_overview']): ?>
<div class="section-header">ABOUT US</div>
<div class="text-gray-700 mb-8">
<?php echo $proposal['company_overview']; ?>
</div>
<?php endif; ?>
<?php if($proposal['terms_conditions']): ?>
<div class="section-header">TERMS & CONDITIONS</div>
<div class="text-gray-700 mb-8">
<?php echo $proposal['terms_conditions']; ?>
</div>
<?php endif; ?>
<?php if($proposal['conclusion']): ?>
<div class="section-header">CONCLUSION</div>
<div class="text-gray-700 mb-8">
<?php echo $proposal['conclusion']; ?>
</div>
<?php endif; ?>
<!-- Footer -->
<div class="mt-10 pt-5 border-top border-accent">
<div class="row">
<div class="col-md-6">
<div class="text-gray-600">
<strong>Customer Code:</strong> <?php echo htmlspecialchars($proposal['customer_code']); ?>
</div>
</div>
<div class="col-md-6 text-end">
<div class="text-gray-600">
<strong>Generated on:</strong> <?php echo date('d-M-Y h:i A'); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
</div>
</div>
</div>
</div>
<!-- Scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="assets/plugins/global/plugins.bundle.js"></script>
<script src="assets/js/scripts.bundle.js"></script>
<!-- HTML2PDF Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
<script>
function generatePDF() {
Swal.fire({
title: 'Generating PDF...',
html: 'Creating professional PDF document<br><small>Please wait...</small>',
allowOutsideClick: false,
didOpen: () => {
Swal.showLoading();
}
});
const element = document.getElementById('proposal-content');
const opt = {
margin: [10, 10, 10, 10],
filename: '<?php echo $proposal['proposal_code']; ?>_<?php echo date('Y-m-d'); ?>.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: {
scale: 2,
useCORS: true,
logging: false,
letterRendering: true
},
jsPDF: {
unit: 'mm',
format: 'a4',
orientation: 'portrait',
compress: true
},
pagebreak: { mode: ['avoid-all', 'css', 'legacy'] }
};
html2pdf().set(opt).from(element).save().then(function() {
Swal.fire({
icon: 'success',
title: 'PDF Generated Successfully!',
html: '<strong><?php echo $proposal['proposal_code']; ?>.pdf</strong><br>has been downloaded',
timer: 2500,
showConfirmButton: false
});
}).catch(function(error) {
Swal.fire({
icon: 'error',
title: 'PDF Generation Failed',
text: 'Please try again or contact support',
confirmButtonText: 'OK'
});
console.error('PDF Error:', error);
});
}
</script>
<?php include 'includes/chat_widget.php'; ?>
</body>
</html>