| Server IP : 13.126.101.145 / Your IP : 216.73.216.63 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.3.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/rentals_updated/wp-content/plugins/woocommerce-rfq/ |
Upload File : |
<?php
include('../../../wp-config.php');
global $wpdb;
global $product;
$header_image = get_header_image();
$qty = $_REQUEST['quantity'];
$shift = $_REQUEST['shift'];
$user_id = intval($_REQUEST["user_id"]);
$user_info = get_userdata($user_id);
$user_name = $user_info->user_login;
$user_email = $user_info->user_email;
$start_date = sanitize_text_field($_REQUEST["start_date"]);
$end_date = sanitize_text_field($_REQUEST["end_date"]);
$shift = intval($_REQUEST["shift"]);
$location = sanitize_text_field($_REQUEST["location"]);
$region = getRegion($location);
$product_id = intval($_REQUEST["product_id"]);
$product = wc_get_product($product_id);
$product_name = $product->get_name();
$base_price = $product->get_price();
$start_date_obj = new DateTime($start_date);
$end_date_obj = new DateTime($end_date);
$interval = $start_date_obj->diff($end_date_obj);
$days = $interval->days + 1; // Include the end date
$hours_per_day = 8; // Default hours per shift
$total_hours = $days * $shift * $hours_per_day;
$calculated_price = ($total_hours / 8) * $base_price;
$table_name = $wpdb->prefix . "download_std_ratecard";
$wpdb->insert($table_name, [
"user_id" => $user_id,
"user_name" => $user_name,
"user_email" => $user_email,
"product_id" => $product_id,
"product_name" => $product_name,
"start_date" => $start_date,
"end_date" => $end_date,
"shift" => $shift,
"location" => $location,
"region" => $region,
"calculated_price" => $calculated_price,
"downloaded_on" => date('Y-m-d H:i:s'),
]);
// In App Notification
create_notification(
'User Downloaded Std Rate card',
'User "' . $user_login .'" has downloaded standard rate card for product '. $product_name .' ',
array(
'meta_input' => array(
'user_id' => $user->ID,
'action' => 'std_rate_card_download',
)
)
);
/**function getRegion($location) {
$south = ['Karnataka', 'Kerala', 'Tamil Nadu'];
$east = ['Andhra Pradesh', 'Telangana'];
$west = ['Maharashtra', 'Goa', 'Gujarat'];
$north = ['Madhya Pradesh', 'Chhattisgarh'];
if (in_array($location, $south)) {
return 'South';
} elseif (in_array($location, $north)) {
return 'North';
} elseif (in_array($location, $east)) {
return 'East';
} elseif (in_array($location, $west)) {
return 'West';
} else {
return 'Others';
}
} **/
?>
<!DOCTYPE html>
<html lang="en, id">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>
Standard Rate Card
</title>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="css/quotes.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js" integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- <style>
.invoice {
page-break-inside: avoid !important;
}
.invoice-total-amount,
.terms-condition-cls {
page-break-inside: avoid !important;
}
table, thead, tbody, tr, td, th {
page-break-inside: avoid !important;
}
.abcd, ol, p {
page-break-inside: avoid !important;
}
</style> -->
<style>
.avoid-page-break {
page-break-inside: avoid;
}
.page-break {
page-break-before: always;
}
</style>
</head>
<body>
<section class="wrapper-invoice" id="invoice-container">
<!-- switch mode rtl by adding class rtl on invoice class -->
<div class="invoice">
<div class="invoice-information">
<p><b>Standard Quote </b> </p>
<p><b>Date </b>: <?php echo date('F, d Y');?></p>
</div>
<!-- logo brand invoice -->
<div class="invoice-logo-brand">
<!-- <h2>Tampsh.</h2> -->
<?php
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo_url = wp_get_attachment_image_url( $custom_logo_id , 'full' );
?>
<img src="<?php echo esc_url( $logo_url );?>" alt="<?php echo get_bloginfo( 'name' );?>" />
</div>
<!-- invoice head -->
<div class="invoice-head">
<div class="head client-info">
<p>GMMCO Limited.</p>
<p>No.6, G.S.T Road,</p>
<p>ST Thomas Mount,</p>
<p>Chennai - 600 016</p>
<p>GSTIN :27AABCG0949C1ZX</p>
<p>Phone: +91 44 2267 6000</p>
<p>Email: contact@gmmco.in</p>
</div>
<div class="head client-data">
<?php
$current_user = wp_get_current_user();
?>
<p>Name: <?php echo $current_user->first_name.' '.$current_user->last_name;?></p>
<p>Phone: <?php echo $current_user->user_phone ?? 'N/A';?></p>
<p>Email: <?php echo $current_user->user_email ?? 'N/A';?></p>
<p>Location: <?php echo $location ?? 'Not Selected';?></p>
</div>
</div>
<!-- invoice body-->
<div class="invoice-body">
<table class="table">
<thead>
<tr>
<th>SNO</th>
<th>Product Image</th>
<th>Product Description</th>
<th>Qty</th>
<th>Shifts</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>
<?php
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $product_id ), 'single-post-thumbnail' );
$product_description = get_post( $product_id )->post_title;
?>
<img src="<?php echo $image[0];?>" width="200" height="100"></img>
</td>
<td>
<?php echo $product_description;?>
</td>
<td><?php echo $qty;?></td>
<td><?php echo $shift;?></td>
<td><?php echo $days.' days';?></td>
</tr>
</tbody>
</table>
<div class="flex-table">
<div class="flex-column"></div>
<div class="flex-column">
<table class="table-subtotal">
<tbody>
<tr>
<td>Price (8 hrs)</td>
<td>₹<?php echo $base_price.'.00';?></td>
</tr>
<tr>
<td>Discount</td>
<td>₹0.00</td>
</tr>
<tr>
<td>Subtotal</td>
<td>₹<?php
echo $calculated_price.'.00';?></td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- invoice total -->
<div class="invoice-total-amount">
<p>Total : ₹<?php echo $calculated_price.'.00';?> (Exclusive of GST)</p>
</div>
<div class="abcd" style="font-size:12px;line-height:25px;">
<h3><b>General Terms & Condition</b></h3>
<ol>
<li class="avoid-page-break">The rental charges for the above-mentioned machine will be for a minimum billing of 240 hours per month for 26 working days.</li>
<li class="avoid-page-break">Customer will pay extra charges @ Prorate Basis for every additional hour used beyond 240 hrs.</li>
<li class="avoid-page-break">GST as applicable will be charged separately on the invoice value and will be payable by the Customer extra at actual.</li>
<li class="avoid-page-break">Customer shall pay an amount of two months' rental charges as a security deposit along with the Work Order, which shall be adjusted against the last two months' rental charges.</li>
<li class="avoid-page-break">To & Fro Transportation will be borne by Customer Scope. In case of rental duration for more than 6 months, one side transportation will be Gmmco's scope.</li>
<li class="avoid-page-break">Order confirmation will be subject to equipment availability of stock.</li>
<li>Transit insurance and third-party insurance will be Gmmco's responsibility.</li>
<li class="avoid-page-break">Gmmco will dispatch the machine after getting a confirmed order along with the security deposit.</li>
<li class="avoid-page-break">One Operator for Single Shift Operation is considered in the above price and the same will be borne by Gmmco.</li>
<li class="avoid-page-break">If you want extra Operator, anadditional charge will need to be paid</li>
<li class="avoid-page-break">Food, accommodation, and transportation for the Operators to the site will be borne by the Customer.</li>
<li class="avoid-page-break">Uncontaminated High-Speed Diesel required for the operation of the equipment shall be provided by the Customer at the site at his costs.</li>
<li class="avoid-page-break">GET & Oils shall be organized by the customer as per OEM recommendation.</li>
<li class="avoid-page-break">Repair and Maintenance of the equipment will be under Gmmco's scope.</li>
<li class="avoid-page-break">The Rental charges shall be paid by the Customer within ten days from the date of invoice submission, by way of RTGS in favor of Gmmco Limited.</li>
<li class="avoid-page-break">Gmmco will dehire the machine in case payment is not received within fifteen days from the date of Invoice.</li>
<li class="avoid-page-break">Gmmco will raise invoices for utilization of the Equipment for each calendar month and submit the same to the customer based on Log sheets.</li>
<li class="avoid-page-break">Customer will use the equipment only for the purpose it is hired and shall not misuse or abuse the equipment or use the Equipment for any unlawful or illegal purposes.</li>
<li class="avoid-page-break">Prices are subject to change without notice.</li>
<li class="avoid-page-break">Customer will ensure the safe custody of the equipment by providing necessary security, parking bay, etc., and will be liable for any loss or damage or destruction to the machine at prevailing prices, taxes, freight, etc. Customer shall ensure safe procedures and practices at the site.</li>
<li class="avoid-page-break">In case the customer dehires the machines before the contract period, then both mobilization and demobilization will be the customer's account.</li>
<li class="avoid-page-break">Any terms and conditions missing in the above shall be mutually agreed upon at the time of signing the contract.</li>
<li class="avoid-page-break">All above indicated T & C, actually may vary as per contracts and site conditions.</li>
</ol><br>
<p style="font-size:14px; color:grey; font-weight:600;">Note: This is system generated Standard Quote and price mentioned in the rate card is dynamic and subject to change</p>
</div>
</div>
<!-- invoice footer -->
<!-- <div class="invoice-footer">
<p>Note: This is system generated Standard Quote and price mentioned in the rate card is dynamic and subject to change</p>
</div> -->
</div>
</section>
<script>
function addPageBreaks() {
const invoiceContainer = document.getElementById('invoice-container');
const sections = invoiceContainer.getElementsByClassName('abcd');
let cumulativeHeight = 0;
const pageHeight = 1080; // Approximate height for an A4 page in pixels
const marginTop = 20; // Margin to add to the top of content on new pages
Array.from(sections).forEach((section, index) => {
cumulativeHeight += section.offsetHeight;
// Add a page break if the cumulative height exceeds the page height
if (cumulativeHeight > pageHeight) {
// Create a new div for the page break
const pageBreak = document.createElement('div');
pageBreak.style.pageBreakBefore = 'always';
pageBreak.style.marginTop = `${marginTop}px`; // Ensure space before the next section
// Insert the page break before the current section
section.parentNode.insertBefore(pageBreak, section);
// Apply a 20px margin to the top of the current section starting on a new page
section.style.marginTop = `${marginTop}px`;
// Reset cumulative height after a page break, including the added margin
cumulativeHeight = section.offsetHeight + marginTop; // Account for the margin added
}
});
}
function exportHTMLtoPDF() {
addPageBreaks();
let htmlElement = document.getElementById('invoice-container');
var fileName = '<?php echo $product_description.'_Standard_RateCard.pdf';?>';
// Configure options for html2pdf
const options = {
margin: [10, 10, 10, 0], // Top, Right, Bottom, Left margins in millimeters
filename: fileName, // Provide the file name directly to html2pdf
html2canvas: { scale: 2 }, // For better resolution
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
// Generate PDF with margins and output as a Blob
// Generate and download PDF
html2pdf().set(options).from(htmlElement).save().then(function() {
// Optional: Close the current window after download (if needed)
setTimeout(() => {
window.open('', '_self').close();
}, 1000); // Adjust the delay as needed
}).catch((error) => {
console.error('PDF generation error: ', error);
});
}
exportHTMLtoPDF();
</script>
</body>
</html>